diff options
-rw-r--r-- | lib/Analysis/CFG.cpp | 3 | ||||
-rw-r--r-- | test/Analysis/misc-ps.m | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index ef67d3b957..b58e9826d3 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -1204,7 +1204,8 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(ConditionalOperator *C, // 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()); } diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 902bfb6aae..029ca70d28 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -1203,3 +1203,12 @@ Val8663544 bazR8663544() { 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); +} + + |