[cfe-commits] r45015 - /cfe/trunk/AST/CFG.cpp
Ted Kremenek
kremenek at apple.com
Thu Dec 13 14:44:19 PST 2007
Author: kremenek
Date: Thu Dec 13 16:44:18 2007
New Revision: 45015
URL: http://llvm.org/viewvc/llvm-project?rev=45015&view=rev
Log:
CFG bug fix: for sizeof(expressions), don't expand the control-flow
of "expressions", since they are not really evaluated.
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=45015&r1=45014&r2=45015&view=diff
==============================================================================
--- cfe/trunk/AST/CFG.cpp (original)
+++ cfe/trunk/AST/CFG.cpp Thu Dec 13 16:44:18 2007
@@ -225,8 +225,7 @@
// 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 @@
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 @@
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
More information about the cfe-commits
mailing list