Index: lib/Analysis/CFG.cpp =================================================================== --- lib/Analysis/CFG.cpp +++ lib/Analysis/CFG.cpp @@ -2983,22 +2983,18 @@ return nullptr; } - if (!KnownVal.isFalse()) { - // Add an intermediate block between the BodyBlock and the - // ExitConditionBlock to represent the "loop back" transition. Create an - // empty block to represent the transition block for looping back to the - // head of the loop. - // FIXME: Can we do this more efficiently without adding another block? - Block = nullptr; - Succ = BodyBlock; - CFGBlock *LoopBackBlock = createBlock(); - LoopBackBlock->setLoopTarget(D); + // Add an intermediate block between the BodyBlock and the + // ExitConditionBlock to represent the "loop back" transition. Create an + // empty block to represent the transition block for looping back to the + // head of the loop. + // FIXME: Can we do this more efficiently without adding another block? + Block = nullptr; + Succ = BodyBlock; + CFGBlock *LoopBackBlock = createBlock(); + LoopBackBlock->setLoopTarget(D); - // Add the loop body entry as a successor to the condition. - addSuccessor(ExitConditionBlock, LoopBackBlock); - } - else - addSuccessor(ExitConditionBlock, nullptr); + // Add the loop body entry as a successor to the condition. + addSuccessor(ExitConditionBlock, LoopBackBlock); } // Link up the condition block with the code that follows the loop. Index: test/Analysis/uninit-sometimes.cpp =================================================================== --- test/Analysis/uninit-sometimes.cpp +++ test/Analysis/uninit-sometimes.cpp @@ -374,9 +374,10 @@ int PR13360(bool b) { int x; // expected-note {{variable}} if (b) { // expected-warning {{variable 'x' is used uninitialized whenever 'if' condition is true}} expected-note {{remove}} - do { + // TODO: Uncomment "do { } while(0);" below. Warning should still be shown. + //do { foo(); - } while (0); + //} while (0); } else { x = 1; } Index: test/Analysis/unreachable-code-path.c =================================================================== --- test/Analysis/unreachable-code-path.c +++ test/Analysis/unreachable-code-path.c @@ -158,3 +158,14 @@ } } } + +// Ensure that ExplodedGraph and unoptimized CFG match. +void test12(int x) { + switch (x) { + case 1: + break; // not unreachable + case 2: + do { } while (0); + break; + } +}