]> granicus.if.org Git - clang/commitdiff
Handle StmtExprs whose last contained statement is not an expression.
authorTed Kremenek <kremenek@apple.com>
Sat, 15 Mar 2008 03:27:30 +0000 (03:27 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 15 Mar 2008 03:27:30 +0000 (03:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48388 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRExprEngine.cpp

index fd8d0f5c1d61042c68f2471728c8d084f5f3b85f..f1108df405198b8bb3bd938025bb3b8f316a2e40 100644 (file)
@@ -1421,9 +1421,17 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
       StmtExpr* SE = cast<StmtExpr>(S);
       
       ValueState* St = GetState(Pred);
-      Expr* LastExpr = cast<Expr>(*SE->getSubStmt()->body_rbegin());
-      Nodify(Dst, SE, Pred, SetRVal(St, SE, GetRVal(St, LastExpr)));
-      break;      
+      
+      // 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()))
+        Nodify(Dst, SE, Pred, SetRVal(St, SE, GetRVal(St, LastExpr)));
+      else
+        Dst.Add(Pred);
+      
+      break;
     }
       
       // FIXME: We may wish to always bind state to ReturnStmts so