[cfe-commits] r119284 - in /cfe/trunk: lib/Analysis/CFG.cpp test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Mon Nov 15 14:59:22 PST 2010


Author: kremenek
Date: Mon Nov 15 16:59:22 2010
New Revision: 119284

URL: http://llvm.org/viewvc/llvm-project?rev=119284&view=rev
Log:
Remove invalid assertion from CFG builder.  When building the CFG pieces for a ternary '?' expression,
it is possible for the confluence block to only have a single predecessor due to calls to 'noreturn'
functions.  Fixes assertion failure reported in PR 8619.

Modified:
    cfe/trunk/lib/Analysis/CFG.cpp
    cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=119284&r1=119283&r2=119284&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Mon Nov 15 16:59:22 2010
@@ -1204,7 +1204,8 @@
       // want the first predecessor to the the block containing the expression
       // for the case when the ternary expression evaluates to true.
       AddSuccessor(Block, ConfluenceBlock);
-      assert(ConfluenceBlock->pred_size() == 2);
+      // Note that there can possibly only be one predecessor if one of the
+      // subexpressions resulted in calling a noreturn function.
       std::reverse(ConfluenceBlock->pred_begin(),
                    ConfluenceBlock->pred_end());
     }

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=119284&r1=119283&r2=119284&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Mon Nov 15 16:59:22 2010
@@ -1203,3 +1203,12 @@
   return func();
 }
 
+// PR 8619 - Handle ternary expressions with a call to a noreturn function.
+// This previously resulted in a crash.
+void pr8619_noreturn(int x) __attribute__((noreturn));
+
+void pr8619(int a, int b, int c) {
+  a ?: pr8619_noreturn(b || c);
+}
+
+





More information about the cfe-commits mailing list