diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-14 05:55:08 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-14 05:55:08 +0000 |
commit | a3d1eb85853eae7b719f679b40923826b5e4b7df (patch) | |
tree | 12ea1553740cd1b0462ec9a59d0418901d06401c | |
parent | c41ec23d9f8ef80b8c62df978013c22dcdcbdbe3 (diff) |
GRExprEngine: Handle empty statement expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64541 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 20 | ||||
-rw-r--r-- | test/Analysis/misc-ps.m | 6 |
2 files changed, 18 insertions, 8 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 9b02af44e1..a48b18c9c6 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -356,15 +356,19 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) { case Stmt::StmtExprClass: { StmtExpr* SE = cast<StmtExpr>(S); - - const GRState* state = GetState(Pred); - - // FIXME: Not certain if we can have empty StmtExprs. If so, we should - // probably just remove these from the CFG. - assert (!SE->getSubStmt()->body_empty()); - - if (Expr* LastExpr = dyn_cast<Expr>(*SE->getSubStmt()->body_rbegin())) + + if (SE->getSubStmt()->body_empty()) { + // Empty statement expression. + assert(SE->getType() == getContext().VoidTy + && "Empty statement expression must have void type."); + Dst.Add(Pred); + break; + } + + if (Expr* LastExpr = dyn_cast<Expr>(*SE->getSubStmt()->body_rbegin())) { + const GRState* state = GetState(Pred); MakeNode(Dst, SE, Pred, BindExpr(state, SE, GetSVal(state, LastExpr))); + } else Dst.Add(Pred); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 4e7f0ad5b3..0ddce3aa73 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -108,3 +108,9 @@ void pr3422() { pr3422_helper(&q[1]); } +// PR 3543 (handle empty statement expressions) +int pr_3543(void) { + ({}); +} + + |