forked from OSchip/llvm-project
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
This commit is contained in:
parent
e37f33c466
commit
75f34c1386
|
@ -2107,14 +2107,11 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
|
||||||
// blocks will be pointed to be "Block".
|
// blocks will be pointed to be "Block".
|
||||||
CFGBlock *LastBlock = addStmt(I->getCond());
|
CFGBlock *LastBlock = addStmt(I->getCond());
|
||||||
|
|
||||||
// Finally, if the IfStmt contains a condition variable, add both the IfStmt
|
// Finally, if the IfStmt contains a condition variable, add it and its
|
||||||
// and the condition variable initialization to the CFG.
|
// initializer to the CFG.
|
||||||
if (VarDecl *VD = I->getConditionVariable()) {
|
if (const DeclStmt* DS = I->getConditionVariableDeclStmt()) {
|
||||||
if (Expr *Init = VD->getInit()) {
|
|
||||||
autoCreateBlock();
|
autoCreateBlock();
|
||||||
appendStmt(Block, I->getConditionVariableDeclStmt());
|
LastBlock = addStmt(const_cast<DeclStmt *>(DS));
|
||||||
LastBlock = addStmt(Init);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return LastBlock;
|
return LastBlock;
|
||||||
|
|
|
@ -611,18 +611,18 @@ int testConsistencyNestedNormalReturn(bool value) {
|
||||||
// CHECK: [B5 (ENTRY)]
|
// CHECK: [B5 (ENTRY)]
|
||||||
// CHECK: Succs (1): B4
|
// CHECK: Succs (1): B4
|
||||||
// CHECK: [B1]
|
// CHECK: [B1]
|
||||||
// CHECK: 1: [B4.7].~C() (Implicit destructor)
|
// CHECK: 1: [B4.6].~C() (Implicit destructor)
|
||||||
// CHECK: Succs (1): B0
|
// CHECK: Succs (1): B0
|
||||||
// CHECK: [B2]
|
// CHECK: [B2]
|
||||||
// CHECK: 1: 0
|
// CHECK: 1: 0
|
||||||
// CHECK: 2: return [B2.1];
|
// CHECK: 2: return [B2.1];
|
||||||
// CHECK: 3: [B4.7].~C() (Implicit destructor)
|
// CHECK: 3: [B4.6].~C() (Implicit destructor)
|
||||||
// CHECK: Preds (1): B4
|
// CHECK: Preds (1): B4
|
||||||
// CHECK: Succs (1): B0
|
// CHECK: Succs (1): B0
|
||||||
// CHECK: [B3]
|
// CHECK: [B3]
|
||||||
// CHECK: 1: 1
|
// CHECK: 1: 1
|
||||||
// CHECK: 2: return [B3.1];
|
// CHECK: 2: return [B3.1];
|
||||||
// CHECK: 3: [B4.7].~C() (Implicit destructor)
|
// CHECK: 3: [B4.6].~C() (Implicit destructor)
|
||||||
// CHECK: Preds (1): B4
|
// CHECK: Preds (1): B4
|
||||||
// CHECK: Succs (1): B0
|
// CHECK: Succs (1): B0
|
||||||
// CHECK: [B4]
|
// CHECK: [B4]
|
||||||
|
@ -631,8 +631,8 @@ int testConsistencyNestedNormalReturn(bool value) {
|
||||||
// CHECK: 3: [B4.2] (ImplicitCastExpr, NoOp, const struct C)
|
// CHECK: 3: [B4.2] (ImplicitCastExpr, NoOp, const struct C)
|
||||||
// CHECK: 4: [B4.3]
|
// CHECK: 4: [B4.3]
|
||||||
// CHECK: 5: [B4.4] (CXXConstructExpr, struct C)
|
// CHECK: 5: [B4.4] (CXXConstructExpr, struct C)
|
||||||
// CHECK: 6: ~C() (Temporary object destructor)
|
// CHECK: 6: C c = C();
|
||||||
// CHECK: 7: C c = C();
|
// CHECK: 7: ~C() (Temporary object destructor)
|
||||||
// CHECK: 8: c
|
// CHECK: 8: c
|
||||||
// CHECK: 9: [B4.8].operator bool
|
// CHECK: 9: [B4.8].operator bool
|
||||||
// CHECK: 10: [B4.8]
|
// CHECK: 10: [B4.8]
|
||||||
|
|
Loading…
Reference in New Issue