[cfe-commits] r89682 - in /cfe/trunk: lib/Analysis/UndefBranchChecker.cpp test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Mon Nov 23 10:12:03 PST 2009


Author: kremenek
Date: Mon Nov 23 12:12:03 2009
New Revision: 89682

URL: http://llvm.org/viewvc/llvm-project?rev=89682&view=rev
Log:
Tweak UndefBranchChecker to register the most nested "undefined" expression with bugreporter::registerTrackNullOrUndefValue instead of the condition itself.

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=89682&r1=89681&r2=89682&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/UndefBranchChecker.cpp (original)
+++ cfe/trunk/lib/Analysis/UndefBranchChecker.cpp Mon Nov 23 12:12:03 2009
@@ -73,9 +73,6 @@
       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 @@
 
       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);

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=89682&r1=89681&r2=89682&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Mon Nov 23 12:12:03 2009
@@ -767,6 +767,12 @@
   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.





More information about the cfe-commits mailing list