From 3b4a8ef9e5c97fbd4d1164b8b542cc8888c8b348 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sat, 15 Mar 2008 03:27:30 +0000 Subject: [PATCH] Handle StmtExprs whose last contained statement is not an expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48388 91177308-0d34-0410-b5e6-96231b3b80d8 --- Analysis/GRExprEngine.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp index fd8d0f5c1d..f1108df405 100644 --- a/Analysis/GRExprEngine.cpp +++ b/Analysis/GRExprEngine.cpp @@ -1421,9 +1421,17 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) { StmtExpr* SE = cast(S); ValueState* St = GetState(Pred); - Expr* LastExpr = cast(*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(*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 -- 2.40.0