Fixed logic error in UnreachableCodeChecker's marking algorithm that would sometimes allow for multiple sequential statements to be flagged.

llvm-svn: 110353
This commit is contained in:
Tom Care 2010-08-05 17:53:44 +00:00
parent a9731a4179
commit 16ba7c652e
2 changed files with 20 additions and 3 deletions

View File

@ -149,10 +149,13 @@ void UnreachableCodeChecker::FindUnreachableEntryPoints(const CFGBlock *CB) {
for (CFGBlock::const_pred_iterator I = CB->pred_begin(); I != CB->pred_end();
++I) {
// Recurse over all unreachable blocks
if (!reachable.count((*I)->getBlockID())
&& !visited.count((*I)->getBlockID())) {
FindUnreachableEntryPoints(*I);
if (!reachable.count((*I)->getBlockID())) {
// At least one predeccessor was unreachable
allPredecessorsReachable = false;
// Only visit the block once
if (!visited.count((*I)->getBlockID()))
FindUnreachableEntryPoints(*I);
}
}

View File

@ -88,3 +88,17 @@ void test8() {
a = 5;
}
// Check for bugs where multiple statements are reported
void test9(unsigned a) {
switch (a) {
if (a) // expected-warning{{never executed}}
foo(a + 5); // no-warning
else // no-warning
foo(a); // no-warning
case 1:
case 2:
break;
default:
break;
}
}