]> granicus.if.org Git - clang/commitdiff
GRExprEngine: Handle empty statement expressions.
authorTed Kremenek <kremenek@apple.com>
Sat, 14 Feb 2009 05:55:08 +0000 (05:55 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 14 Feb 2009 05:55:08 +0000 (05:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64541 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/GRExprEngine.cpp
test/Analysis/misc-ps.m

index 9b02af44e1e2d9baf9eb7c0a1737d59c261839a8..a48b18c9c6d91dd21284d271b8b7f98c9b90d1b8 100644 (file)
@@ -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);
       
index 4e7f0ad5b32d8989e280035ab0ceb5423583f2d5..0ddce3aa73043b5d25159953b3d96ce2714bb1ba 100644 (file)
@@ -108,3 +108,9 @@ void pr3422() {
   pr3422_helper(&q[1]);
 }
 
+// PR 3543 (handle empty statement expressions)
+int pr_3543(void) {
+  ({});
+}
+
+