[cfe-commits] r89679 - in /cfe/trunk: lib/Analysis/UndefBranchChecker.cpp test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Mon Nov 23 09:58:48 PST 2009
Author: kremenek
Date: Mon Nov 23 11:58:48 2009
New Revision: 89679
URL: http://llvm.org/viewvc/llvm-project?rev=89679&view=rev
Log:
Cleanup title/description of "undefined branch" BugType and add some test cases for this check.
Modified:
cfe/trunk/lib/Analysis/UndefBranchChecker.cpp
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/lib/Analysis/UndefBranchChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UndefBranchChecker.cpp?rev=89679&r1=89678&r2=89679&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/UndefBranchChecker.cpp (original)
+++ cfe/trunk/lib/Analysis/UndefBranchChecker.cpp Mon Nov 23 11:58:48 2009
@@ -72,8 +72,7 @@
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);
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=89679&r1=89678&r2=89679&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Mon Nov 23 11:58:48 2009
@@ -752,6 +752,23 @@
@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.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list