]> granicus.if.org Git - clang/commitdiff
Cleanup title/description of "undefined branch" BugType and add some test cases for...
authorTed Kremenek <kremenek@apple.com>
Mon, 23 Nov 2009 17:58:48 +0000 (17:58 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 23 Nov 2009 17:58:48 +0000 (17:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89679 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/UndefBranchChecker.cpp
test/Analysis/misc-ps.m

index 8d72b5a96be2b06c76a6d26658bdfbded0c4ba69..0a66e21de94452b838f8dd0d6e6852f027ce15df 100644 (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);
index 85095f4e079bfd3f28e0b415bc89e3b872da94a4..385fcafdc578b18aa47742451c7384bfa643a428 100644 (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.
 //===----------------------------------------------------------------------===//