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
This commit is contained in:
Ted Kremenek 2010-11-15 22:59:22 +00:00
Родитель 82f3c50fa1
Коммит e4ae4dc87f
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -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());
}

Просмотреть файл

@ -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);
}