diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-11-23 17:58:48 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-11-23 17:58:48 +0000 |
commit | d4dca6fde6cb03273929db7c6d77de377a536d8d (patch) | |
tree | f5db3681361e7f348b9e75aab596d563dee0ddc1 /clang | |
parent | 8c793172c2bcec9610b07b0bc4fcb12e8a4d1e89 (diff) | |
download | bcm5719-llvm-d4dca6fde6cb03273929db7c6d77de377a536d8d.tar.gz bcm5719-llvm-d4dca6fde6cb03273929db7c6d77de377a536d8d.zip |
Cleanup title/description of "undefined branch" BugType and add some test cases for this check.
llvm-svn: 89679
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Analysis/UndefBranchChecker.cpp | 3 | ||||
-rw-r--r-- | clang/test/Analysis/misc-ps.m | 17 |
2 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/Analysis/UndefBranchChecker.cpp b/clang/lib/Analysis/UndefBranchChecker.cpp index 8d72b5a96be..0a66e21de94 100644 --- a/clang/lib/Analysis/UndefBranchChecker.cpp +++ b/clang/lib/Analysis/UndefBranchChecker.cpp @@ -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); diff --git a/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m index 85095f4e079..385fcafdc57 100644 --- a/clang/test/Analysis/misc-ps.m +++ b/clang/test/Analysis/misc-ps.m @@ -752,6 +752,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. //===----------------------------------------------------------------------===// |