diff options
author | Manuel Klimek <klimek@google.com> | 2014-05-05 18:21:06 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2014-05-05 18:21:06 +0000 |
commit | 75f34c1386f6ee8e3d28f6c3f30b83d2bb7f6584 (patch) | |
tree | d239a9c93f0f2560a62baf3a383909c192f37c83 /clang/lib/Analysis/CFG.cpp | |
parent | e37f33c46607d119446ff2d8c891f5e422c27fa8 (diff) | |
download | bcm5719-llvm-75f34c1386f6ee8e3d28f6c3f30b83d2bb7f6584.tar.gz bcm5719-llvm-75f34c1386f6ee8e3d28f6c3f30b83d2bb7f6584.zip |
Fix handling of condition variables in the face of temp dtors.
The assignment needs to be before the destruction of the temporary.
This patch calls out to addStmt, which invokes VisitDeclStmt, which has
all the correct logic for handling temporaries.
llvm-svn: 207985
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 7c716116eb9..fc0cc2dba82 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -2107,14 +2107,11 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) { // blocks will be pointed to be "Block". CFGBlock *LastBlock = addStmt(I->getCond()); - // Finally, if the IfStmt contains a condition variable, add both the IfStmt - // and the condition variable initialization to the CFG. - if (VarDecl *VD = I->getConditionVariable()) { - if (Expr *Init = VD->getInit()) { - autoCreateBlock(); - appendStmt(Block, I->getConditionVariableDeclStmt()); - LastBlock = addStmt(Init); - } + // Finally, if the IfStmt contains a condition variable, add it and its + // initializer to the CFG. + if (const DeclStmt* DS = I->getConditionVariableDeclStmt()) { + autoCreateBlock(); + LastBlock = addStmt(const_cast<DeclStmt *>(DS)); } return LastBlock; |