aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-11-15 22:59:22 +0000
committerTed Kremenek <kremenek@apple.com>2010-11-15 22:59:22 +0000
commite4ae4dc87fa57e3062077514964b6d75bfa1fed1 (patch)
treeb49b51ff5b140ea3b88fae463c01c3ffe6a3944e
parent82f3c50fa163f99d1407849e556d3859a09afd78 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119284 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/CFG.cpp3
-rw-r--r--test/Analysis/misc-ps.m9
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);
+}
+
+