From: Ted Kremenek Date: Fri, 3 Jul 2009 00:10:50 +0000 (+0000) Subject: Fix a horrible CFG bug reported in . The wrong successor X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed47fc67b8eeabacbbbdf853ba45f4900619904b;p=clang Fix a horrible CFG bug reported in . The wrong successor 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 --- diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index d3087c2f87..69852f5fea 100644 --- a/lib/AST/CFG.cpp +++ b/lib/AST/CFG.cpp @@ -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 ) { diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 07aa15e874..ea41b5bb2f 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -284,3 +284,15 @@ int test_invalidate_by_ref() { return 0; } +// Test for . 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); +} + +