From 989da5eeff9a1052ec253b4d509f3b552b0802b6 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 29 Apr 2010 01:10:26 +0000 Subject: Fix CFG crasher involving statement expressions reported in PR 6938. llvm-svn: 102576 --- clang/lib/Analysis/CFG.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'clang/lib/Analysis/CFG.cpp') diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index e447657e9ef..7c7504a1d82 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -498,8 +498,16 @@ CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, Succ = ConfluenceBlock; Block = NULL; CFGBlock* RHSBlock = addStmt(B->getRHS()); - if (!FinishBlock(RHSBlock)) - return 0; + + if (RHSBlock) { + if (!FinishBlock(RHSBlock)) + return 0; + } + else { + // Create an empty block for cases where the RHS doesn't require + // any explicit statements in the CFG. + RHSBlock = createBlock(); + } // See if this is a known constant. TryResult KnownVal = TryEvaluateBool(B->getLHS()); -- cgit v1.2.3