[cfe-commits] r41866 - /cfe/trunk/AST/CFG.cpp
Ted Kremenek
kremenek at apple.com
Tue Sep 11 14:29:43 PDT 2007
Author: kremenek
Date: Tue Sep 11 16:29:43 2007
New Revision: 41866
URL: http://llvm.org/viewvc/llvm-project?rev=41866&view=rev
Log:
Fixed bug where ternary expressions and GCC-style conditional expressions
where not reversing the order of their subexpression blocks.
Added feature where CallExprs are placed in their own statement slot in
a CFGBlock. Thus we have a designated "return site" within a CFGBlock when
reasoning about function calls.
Modified:
cfe/trunk/AST/CFG.cpp
Modified: cfe/trunk/AST/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/CFG.cpp?rev=41866&r1=41865&r2=41866&view=diff
==============================================================================
--- cfe/trunk/AST/CFG.cpp (original)
+++ cfe/trunk/AST/CFG.cpp Tue Sep 11 16:29:43 2007
@@ -116,6 +116,7 @@
CFGBlock* WalkAST_VisitChildren(Stmt* S);
CFGBlock* WalkAST_VisitVarDecl(VarDecl* D);
CFGBlock* WalkAST_VisitStmtExpr(StmtExpr* S);
+ CFGBlock* WalkAST_VisitCallExpr(CallExpr* C);
void FinishBlock(CFGBlock* B);
};
@@ -231,10 +232,12 @@
Succ = ConfluenceBlock;
Block = NULL;
CFGBlock* LHSBlock = Visit(C->getLHS());
+ FinishBlock(LHSBlock);
Succ = ConfluenceBlock;
Block = NULL;
CFGBlock* RHSBlock = Visit(C->getRHS());
+ FinishBlock(RHSBlock);
Block = createBlock(false);
Block->addSuccessor(LHSBlock);
@@ -253,10 +256,12 @@
Succ = ConfluenceBlock;
Block = NULL;
CFGBlock* LHSBlock = Visit(C->getLHS());
-
+ FinishBlock(LHSBlock);
+
Succ = ConfluenceBlock;
Block = NULL;
CFGBlock* RHSBlock = Visit(C->getRHS());
+ FinishBlock(RHSBlock);
Block = createBlock(false);
Block->addSuccessor(LHSBlock);
@@ -279,6 +284,9 @@
if (AlwaysAddStmt) Block->appendStmt(S);
return Block;
}
+
+ case Stmt::CallExprClass:
+ return WalkAST_VisitCallExpr(cast<CallExpr>(S));
case Stmt::StmtExprClass:
return WalkAST_VisitStmtExpr(cast<StmtExpr>(S));
@@ -358,6 +366,14 @@
return VisitCompoundStmt(S->getSubStmt());
}
+/// WalkAST_VisitCallExpr - Utility method to handle function calls that
+/// are nested in expressions. The idea is that each function call should
+/// appear as a distinct statement in the CFGBlock.
+CFGBlock* CFGBuilder::WalkAST_VisitCallExpr(CallExpr* C) {
+ Block->appendStmt(C);
+ return WalkAST_VisitChildren(C);
+}
+
/// VisitStmt - Handle statements with no branching control flow.
CFGBlock* CFGBuilder::VisitStmt(Stmt* Statement) {
// We cannot assume that we are in the middle of a basic block, since
@@ -458,6 +474,7 @@
// newly created blocks will be pointed to be "Block".
return addStmt(I->getCond());
}
+
CFGBlock* CFGBuilder::VisitReturnStmt(ReturnStmt* R) {
// If we were in the middle of a block we stop processing that block
More information about the cfe-commits
mailing list