diff options
-rw-r--r-- | lib/Analysis/UndefBranchChecker.cpp | 7 | ||||
-rw-r--r-- | test/Analysis/misc-ps.m | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/Analysis/UndefBranchChecker.cpp b/lib/Analysis/UndefBranchChecker.cpp index 0a66e21de9..b6861ba5a0 100644 --- a/lib/Analysis/UndefBranchChecker.cpp +++ b/lib/Analysis/UndefBranchChecker.cpp @@ -73,9 +73,6 @@ void UndefBranchChecker::VisitBranchCondition(GRBranchNodeBuilder &Builder, N->markAsSink(); if (!BT) BT = new BuiltinBug("Branch condition evaluates to a garbage value"); - EnhancedBugReport *R = new EnhancedBugReport(*BT, BT->getDescription(),N); - R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, - Condition); // What's going on here: we want to highlight the subexpression of the // condition that is the most likely source of the "uninitialized @@ -105,6 +102,10 @@ void UndefBranchChecker::VisitBranchCondition(GRBranchNodeBuilder &Builder, FindUndefExpr FindIt(Eng.getStateManager(), St); Ex = FindIt.FindExpr(Ex); + + // Emit the bug report. + EnhancedBugReport *R = new EnhancedBugReport(*BT, BT->getDescription(),N); + R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, Ex); R->addRange(Ex->getSourceRange()); Eng.getBugReporter().EmitReport(R); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 385fcafdc5..1722f7a8ef 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -767,6 +767,12 @@ int test_uninit_branch_b(void) { return x ? 1 : 0; // expected-warning{{Branch condition evaluates to a garbage value}} } +int test_uninit_branch_c(void) { + int x; + if ((short)x) // expected-warning{{Branch condition evaluates to a garbage value}} + return 1; + return 0; +} //===----------------------------------------------------------------------===// // Test passing an undefined value in a message or function call. |