]> granicus.if.org Git - clang/commitdiff
Restructure DereferenceChecker slightly to handle caching out when we would report...
authorTed Kremenek <kremenek@apple.com>
Sat, 21 Nov 2009 01:50:48 +0000 (01:50 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 21 Nov 2009 01:50:48 +0000 (01:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89526 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DereferenceChecker.cpp

index c3aa8f3a2879c0b36409204116d7257521e5850c..a8f5af34a72940820fa5772e69b0102ae2230b6c 100644 (file)
@@ -82,29 +82,32 @@ void DereferenceChecker::VisitLocation(CheckerContext &C, const Stmt *S,
   
   // The explicit NULL case.
   if (nullState) {
-    // Generate an error node.
-    ExplodedNode *N = C.GenerateNode(S, nullState, true);    
-    if (N) {      
-      if (!notNullState) {
-        // We know that 'location' cannot be non-null.  This is what
-        // we call an "explicit" null dereference.        
-        if (!BT_null)
-          BT_null = new BuiltinBug("Null pointer dereference",
-                                   "Dereference of null pointer");
-
-        EnhancedBugReport *report =
-          new EnhancedBugReport(*BT_null, BT_null->getDescription(), N);
-        report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue,
-                                  bugreporter::GetDerefExpr(N));
-        
-        C.EmitReport(report);
+    if (!notNullState) {    
+      // Generate an error node.
+      ExplodedNode *N = C.GenerateNode(S, nullState, true);
+      if (!N)
         return;
-      }
+      
+      // We know that 'location' cannot be non-null.  This is what
+      // we call an "explicit" null dereference.        
+      if (!BT_null)
+        BT_null = new BuiltinBug("Null pointer dereference",
+                                 "Dereference of null pointer");
 
+      EnhancedBugReport *report =
+        new EnhancedBugReport(*BT_null, BT_null->getDescription(), N);
+      report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue,
+                                bugreporter::GetDerefExpr(N));
+      
+      C.EmitReport(report);
+      return;
+    }
+    else {
       // Otherwise, we have the case where the location could either be
       // null or not-null.  Record the error node as an "implicit" null
-      // dereference.
-      ImplicitNullDerefNodes.push_back(N);
+      // dereference.      
+      if (ExplodedNode *N = C.GenerateNode(S, nullState, true))
+        ImplicitNullDerefNodes.push_back(N);
     }
   }