]> granicus.if.org Git - clang/commitdiff
Fix a horrible CFG bug reported in <rdar://problem/7027684>. The wrong successor
authorTed Kremenek <kremenek@apple.com>
Fri, 3 Jul 2009 00:10:50 +0000 (00:10 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 3 Jul 2009 00:10:50 +0000 (00:10 +0000)
block would get hooked up in some cases when processing empty compound
statements.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74743 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/CFG.cpp
test/Analysis/misc-ps.m

index d3087c2f87da9b1581fb7e5fe4ec364514cb9e9e..69852f5fea57d8493cc73c01a3a688b0bde606c7 100644 (file)
@@ -556,7 +556,7 @@ CFGBlock* CFGBuilder::VisitNullStmt(NullStmt* Statement) {
 
 CFGBlock* CFGBuilder::VisitCompoundStmt(CompoundStmt* C) {
   
-  CFGBlock* LastBlock = NULL;
+  CFGBlock* LastBlock = Block;
 
   for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend();
                                                                I != E; ++I ) {
index 07aa15e87463a9c8738a9895add1ad5ba8e44092..ea41b5bb2f35f4e506a2f1482235ef97d220d0b8 100644 (file)
@@ -284,3 +284,15 @@ int test_invalidate_by_ref() {
   return 0;  
 }
 
+// Test for <rdar://problem/7027684>.  This just tests that the CFG is
+// constructed correctly.  Previously, the successor block of the entrance
+// was the block containing the merge for '?', which would trigger an
+// assertion failure.
+int rdar_7027684_aux();
+int rdar_7027684_aux_2() __attribute__((noreturn));
+void rdar_7027684(int x, int y) {
+  {}; // this empty compound statement is critical.
+  (rdar_7027684_aux() ? rdar_7027684_aux_2() : (void) 0);
+}
+
+