Cleanup title/description of "undefined branch" BugType and add some test cases for this check.

llvm-svn: 89679
This commit is contained in:
Ted Kremenek 2009-11-23 17:58:48 +00:00
parent 8c793172c2
commit d4dca6fde6
2 changed files with 18 additions and 2 deletions

View File

@ -72,8 +72,7 @@ void UndefBranchChecker::VisitBranchCondition(GRBranchNodeBuilder &Builder,
if (N) {
N->markAsSink();
if (!BT)
BT = new BuiltinBug("Undefined branch",
"Branch condition evaluates to an undefined or garbage value");
BT = new BuiltinBug("Branch condition evaluates to a garbage value");
EnhancedBugReport *R = new EnhancedBugReport(*BT, BT->getDescription(),N);
R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue,
Condition);

View File

@ -751,6 +751,23 @@ void test_undefined_array_subscript() {
}
@end
//===----------------------------------------------------------------------===//
// Test using an uninitialized value as a branch condition.
//===----------------------------------------------------------------------===//
int test_uninit_branch(void) {
int x;
if (x) // expected-warning{{Branch condition evaluates to a garbage value}}
return 1;
return 0;
}
int test_uninit_branch_b(void) {
int x;
return x ? 1 : 0; // expected-warning{{Branch condition evaluates to a garbage value}}
}
//===----------------------------------------------------------------------===//
// Test passing an undefined value in a message or function call.
//===----------------------------------------------------------------------===//