aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/CFG.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r--clang/lib/Analysis/CFG.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index fc74226951a4..edc86c41c3b9 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -4773,11 +4773,11 @@ CFGBlock *CFGBuilder::VisitChildrenForTemporaryDtors(Stmt *E,
CFGBlock *CFGBuilder::VisitBinaryOperatorForTemporaryDtors(
BinaryOperator *E, bool ExternallyDestructed, TempDtorContext &Context) {
if (E->isCommaOp()) {
- // For comma operator LHS expression is visited
- // before RHS expression. For destructors visit them in reverse order.
- CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS(), ExternallyDestructed, Context);
+ // For the comma operator, the LHS expression is evaluated before the RHS
+ // expression, so prepend temporary destructors for the LHS first.
CFGBlock *LHSBlock = VisitForTemporaryDtors(E->getLHS(), false, Context);
- return LHSBlock ? LHSBlock : RHSBlock;
+ CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS(), ExternallyDestructed, Context);
+ return RHSBlock ? RHSBlock : LHSBlock;
}
if (E->isLogicalOp()) {
@@ -4798,19 +4798,15 @@ CFGBlock *CFGBuilder::VisitBinaryOperatorForTemporaryDtors(
}
if (E->isAssignmentOp()) {
- // For assignment operator (=) LHS expression is visited
- // before RHS expression. For destructors visit them in reverse order.
+ // For assignment operators, the RHS expression is evaluated before the LHS
+ // expression, so prepend temporary destructors for the RHS first.
CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS(), false, Context);
CFGBlock *LHSBlock = VisitForTemporaryDtors(E->getLHS(), false, Context);
return LHSBlock ? LHSBlock : RHSBlock;
}
- // For any other binary operator RHS expression is visited before
- // LHS expression (order of children). For destructors visit them in reverse
- // order.
- CFGBlock *LHSBlock = VisitForTemporaryDtors(E->getLHS(), false, Context);
- CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS(), false, Context);
- return RHSBlock ? RHSBlock : LHSBlock;
+ // Any other operator is visited normally.
+ return VisitChildrenForTemporaryDtors(E, ExternallyDestructed, Context);
}
CFGBlock *CFGBuilder::VisitCXXBindTemporaryExprForTemporaryDtors(
@@ -4917,14 +4913,13 @@ CFGBlock *CFGBuilder::VisitOMPExecutableDirective(OMPExecutableDirective *D,
B = R;
}
// Visit associated structured block if any.
- if (!D->isStandaloneDirective())
- if (CapturedStmt *CS = D->getInnermostCapturedStmt()) {
- Stmt *S = CS->getCapturedStmt();
- if (!isa<CompoundStmt>(S))
- addLocalScopeAndDtors(S);
- if (CFGBlock *R = addStmt(S))
- B = R;
- }
+ if (!D->isStandaloneDirective()) {
+ Stmt *S = D->getRawStmt();
+ if (!isa<CompoundStmt>(S))
+ addLocalScopeAndDtors(S);
+ if (CFGBlock *R = addStmt(S))
+ B = R;
+ }
return B;
}