diff options
| author | Ted Kremenek <kremenek@apple.com> | 2007-12-13 22:44:18 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2007-12-13 22:44:18 +0000 |
| commit | 7d9a2e119d5a60e40e6e2086a9e9ccd9c067da4b (patch) | |
| tree | 540cd3ea63c2e6f48bae0b4dd4a915685ae7cadc /clang | |
| parent | c47dc4f5afacc12c6fb309e41e3e4ff5034bbdf0 (diff) | |
| download | bcm5719-llvm-7d9a2e119d5a60e40e6e2086a9e9ccd9c067da4b.tar.gz bcm5719-llvm-7d9a2e119d5a60e40e6e2086a9e9ccd9c067da4b.zip | |
CFG bug fix: for sizeof(expressions), don't expand the control-flow
of "expressions", since they are not really evaluated.
llvm-svn: 45015
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/AST/CFG.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/clang/AST/CFG.cpp b/clang/AST/CFG.cpp index b93d77e3fa0..43e6870511e 100644 --- a/clang/AST/CFG.cpp +++ b/clang/AST/CFG.cpp @@ -225,8 +225,7 @@ CFGBlock* CFGBuilder::WalkAST(Stmt* S, bool AlwaysAddStmt = false) { // of the ternary expression. CFGBlock* ConfluenceBlock = (Block) ? Block : createBlock(); ConfluenceBlock->appendStmt(C); - FinishBlock(ConfluenceBlock); - + FinishBlock(ConfluenceBlock); // Create a block for the LHS expression if there is an LHS expression. // A GCC extension allows LHS to be NULL, causing the condition to @@ -317,6 +316,20 @@ CFGBlock* CFGBuilder::WalkAST(Stmt* S, bool AlwaysAddStmt = false) { case Stmt::StmtExprClass: return WalkAST_VisitStmtExpr(cast<StmtExpr>(S)); + case Stmt::UnaryOperatorClass: { + UnaryOperator* U = cast<UnaryOperator>(S); + + // sizeof(expressions). For such expressions, + // the subexpression is not really evaluated, so + // we don't care about control-flow within the sizeof. + if (U->getOpcode() == UnaryOperator::SizeOf) { + Block->appendStmt(S); + return Block; + } + + break; + } + case Stmt::BinaryOperatorClass: { BinaryOperator* B = cast<BinaryOperator>(S); @@ -345,14 +358,16 @@ CFGBlock* CFGBuilder::WalkAST(Stmt* S, bool AlwaysAddStmt = false) { addStmt(B->getRHS()); return addStmt(B->getLHS()); } - - // Fall through to the default case. + + break; } default: - if (AlwaysAddStmt) Block->appendStmt(S); - return WalkAST_VisitChildren(S); + break; }; + + if (AlwaysAddStmt) Block->appendStmt(S); + return WalkAST_VisitChildren(S); } /// WalkAST_VisitDeclSubExprs - Utility method to handle Decls contained in |

