Make all CXXConstructExpr's block-level expressions. This is required by

method inlining. Temporarily fail a test case.

llvm-svn: 117907
This commit is contained in:
Zhongxing Xu 2010-11-01 06:46:05 +00:00
parent 2623343625
commit 0b51d4db8c
4 changed files with 749 additions and 667 deletions

View File

@ -260,6 +260,9 @@ private:
CFGBlock *VisitCXXCatchStmt(CXXCatchStmt *S);
CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
CFGBlock *VisitCXXConstructExpr(CXXConstructExpr *C, AddStmtChoice asc);
CFGBlock *VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
AddStmtChoice asc);
CFGBlock *VisitCXXMemberCallExpr(CXXMemberCallExpr *C, AddStmtChoice asc);
CFGBlock *VisitCallExpr(CallExpr *C, AddStmtChoice asc);
CFGBlock *VisitCaseStmt(CaseStmt *C);
@ -761,6 +764,12 @@ tryAgain:
return Visit(cast<CXXExprWithTemporaries>(S)->getSubExpr(), asc);
}
case Stmt::CXXConstructExprClass:
return VisitCXXConstructExpr(cast<CXXConstructExpr>(S), asc);
case Stmt::CXXTemporaryObjectExprClass:
return VisitCXXTemporaryObjectExpr(cast<CXXTemporaryObjectExpr>(S), asc);
case Stmt::CXXMemberCallExprClass:
return VisitCXXMemberCallExpr(cast<CXXMemberCallExpr>(S), asc);
@ -2282,6 +2291,24 @@ CFGBlock* CFGBuilder::VisitCXXCatchStmt(CXXCatchStmt* CS) {
return CatchBlock;
}
CFGBlock *CFGBuilder::VisitCXXConstructExpr(CXXConstructExpr *C,
AddStmtChoice asc) {
AddStmtChoice::Kind K = asc.asLValue() ? AddStmtChoice::AlwaysAddAsLValue
: AddStmtChoice::AlwaysAdd;
autoCreateBlock();
AppendStmt(Block, C, AddStmtChoice(K));
return VisitChildren(C);
}
CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
AddStmtChoice asc) {
AddStmtChoice::Kind K = asc.asLValue() ? AddStmtChoice::AlwaysAddAsLValue
: AddStmtChoice::AlwaysAdd;
autoCreateBlock();
AppendStmt(Block, C, AddStmtChoice(K));
return VisitChildren(C);
}
CFGBlock *CFGBuilder::VisitCXXMemberCallExpr(CXXMemberCallExpr *C,
AddStmtChoice asc) {
AddStmtChoice::Kind K = asc.asLValue() ? AddStmtChoice::AlwaysAddAsLValue
@ -2751,7 +2778,7 @@ static void print_elem(llvm::raw_ostream &OS, StmtPrinterHelper* Helper,
OS << ".~" << T->getAsCXXRecordDecl()->getName() << "()";
OS << " (Member object destructor)\n";
}
}
}
static void print_block(llvm::raw_ostream& OS, const CFG* cfg,
const CFGBlock& B,

File diff suppressed because it is too large Load Diff

View File

@ -44,46 +44,51 @@ TestControlFlow::TestControlFlow(bool b)
int v;
}
// CHECK: [ B2 (ENTRY) ]
// CHECK: Predecessors (0):
// CHECK: Successors (1): B1
// CHECK: [ B1 ]
// CHECK: 1: A() (Base initializer)
// CHECK: 2: C() (Base initializer)
// CHECK: 3: B() (Base initializer)
// CHECK: 4: A() (Base initializer)
// CHECK: 5: i(/*implicit*/int()) (Member initializer)
// CHECK: 6: r(this->i) (Member initializer)
// CHECK: 7: A a;
// CHECK: Predecessors (1): B2
// CHECK: Successors (1): B0
// CHECK: [ B0 (EXIT) ]
// CHECK: Predecessors (1): B1
// CHECK: Successors (0):
// CHECK: [ B5 (ENTRY) ]
// CHECK: Predecessors (0):
// CHECK: Successors (1): B4
// CHECK: [ B1 ]
// CHECK: 1: [B4.2] ? [B2.1] : [B3.1]
// CHECK: 2: y([B1.1]) (Member initializer)
// CHECK: 3: z(this->y) (Member initializer)
// CHECK: 4: int v;
// CHECK: Predecessors (2): B2 B3
// CHECK: Successors (1): B0
// CHECK: [ B2 ]
// CHECK: 1: 0
// CHECK: Predecessors (1): B4
// CHECK: Successors (1): B1
// CHECK: [ B3 ]
// CHECK: 1: 1
// CHECK: Predecessors (1): B4
// CHECK: Successors (1): B1
// CHECK: [ B4 ]
// CHECK: 1: x(0) (Member initializer)
// CHECK: 2: b
// CHECK: T: [B4.2] ? ... : ...
// CHECK: Predecessors (1): B5
// CHECK: Successors (2): B2 B3
// CHECK: [ B0 (EXIT) ]
// CHECK: Predecessors (1): B1
// CHECK: Successors (0):
// CHECK: [ B2 (ENTRY) ]
// CHECK: Predecessors (0):
// CHECK: Successors (1): B1
// CHECK: [ B1 ]
// CHECK: 1:
// CHECK: 2: A([B1.1]) (Base initializer)
// CHECK: 3:
// CHECK: 4: C([B1.3]) (Base initializer)
// CHECK: 5:
// CHECK: 6: B([B1.5]) (Base initializer)
// CHECK: 7:
// CHECK: 8: A([B1.7]) (Base initializer)
// CHECK: 9: i(/*implicit*/int()) (Member initializer)
// CHECK: 10: r(this->i) (Member initializer)
// CHECK: 11:
// CHECK: 12: A a;
// CHECK: Predecessors (1): B2
// CHECK: Successors (1): B0
// CHECK: [ B0 (EXIT) ]
// CHECK: Predecessors (1): B1
// CHECK: Successors (0):
// CHECK: [ B5 (ENTRY) ]
// CHECK: Predecessors (0):
// CHECK: Successors (1): B4
// CHECK: [ B1 ]
// CHECK: 1: [B4.2] ? [B2.1] : [B3.1]
// CHECK: 2: y([B1.1]) (Member initializer)
// CHECK: 3: z(this->y) (Member initializer)
// CHECK: 4: int v;
// CHECK: Predecessors (2): B2 B3
// CHECK: Successors (1): B0
// CHECK: [ B2 ]
// CHECK: 1: 0
// CHECK: Predecessors (1): B4
// CHECK: Successors (1): B1
// CHECK: [ B3 ]
// CHECK: 1: 1
// CHECK: Predecessors (1): B4
// CHECK: Successors (1): B1
// CHECK: [ B4 ]
// CHECK: 1: x(0) (Member initializer)
// CHECK: 2: b
// CHECK: T: [B4.2] ? ... : ...
// CHECK: Predecessors (1): B5
// CHECK: Successors (2): B2 B3
// CHECK: [ B0 (EXIT) ]
// CHECK: Predecessors (1): B1
// CHECK: Successors (0):

View File

@ -1,4 +1,5 @@
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
// XFAIL: *
struct A {
int x;
A(int a) { x = a; }