[cfe-commits] r162720 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/BugReporter/ lib/StaticAnalyzer/Checkers/ lib/StaticAnalyzer/Core/

Jordan Rose jordan_rose at apple.com
Mon Aug 27 17:50:52 PDT 2012


Author: jrose
Date: Mon Aug 27 19:50:51 2012
New Revision: 162720

URL: http://llvm.org/viewvc/llvm-project?rev=162720&view=rev
Log:
[analyzer] Rename addTrackNullOrUndefValueVisitor to trackNullOrUndefValue.

This helper function (in the clang::ento::bugreporter namespace) may add more
than one visitor, but conceptually it's tracking a single use of a null or
undefined value and should do so as best it can.

Also, the BugReport parameter has been made a reference to underscore that
it is non-optional.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
    cfe/trunk/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h Mon Aug 27 19:50:51 2012
@@ -225,8 +225,7 @@
   
 namespace bugreporter {
 
-void addTrackNullOrUndefValueVisitor(const ExplodedNode *N, const Stmt *S,
-                                     BugReport *R);
+void trackNullOrUndefValue(const ExplodedNode *N, const Stmt *S, BugReport &R);
 
 const Stmt *GetDerefExpr(const ExplodedNode *N);
 const Stmt *GetDenomExpr(const ExplodedNode *N);

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp Mon Aug 27 19:50:51 2012
@@ -105,7 +105,7 @@
         // Highlight the range of the argument that was null.
         R->addRange(Call.getArgSourceRange(idx));
         if (const Expr *ArgE = Call.getArgExpr(idx))
-          bugreporter::addTrackNullOrUndefValueVisitor(errorNode, ArgE, R);
+          bugreporter::trackNullOrUndefValue(errorNode, ArgE, *R);
         // Emit the bug report.
         C.EmitReport(R);
       }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp Mon Aug 27 19:50:51 2012
@@ -432,7 +432,7 @@
 
     BugReport *report = new BugReport(*BT, description, N);
     report->addRange(Arg->getSourceRange());
-    bugreporter::addTrackNullOrUndefValueVisitor(N, Arg, report);
+    bugreporter::trackNullOrUndefValue(N, Arg, *report);
     C.EmitReport(report);
     return;
   }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Mon Aug 27 19:50:51 2012
@@ -252,7 +252,7 @@
     BugReport *report = new BugReport(*BT, os.str(), N);
 
     report->addRange(S->getSourceRange());
-    bugreporter::addTrackNullOrUndefValueVisitor(N, S, report);
+    bugreporter::trackNullOrUndefValue(N, S, *report);
     C.EmitReport(report);
     return NULL;
   }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp Mon Aug 27 19:50:51 2012
@@ -75,7 +75,7 @@
   BugReport *R = new BugReport(*BT, BT->getName(), N);
   if (BadE) {
     R->addRange(BadE->getSourceRange());
-    bugreporter::addTrackNullOrUndefValueVisitor(N, BadE, R);
+    bugreporter::trackNullOrUndefValue(N, BadE, *R);
   }
   C.EmitReport(R);
 }
@@ -122,7 +122,7 @@
       BugReport *R = new BugReport(*BT, Desc, N);
       R->addRange(argRange);
       if (argEx)
-        bugreporter::addTrackNullOrUndefValueVisitor(N, argEx, R);
+        bugreporter::trackNullOrUndefValue(N, argEx, *R);
       C.EmitReport(R);
     }
     return true;
@@ -335,7 +335,7 @@
 
       // FIXME: getTrackNullOrUndefValueVisitor can't handle "super" yet.
       if (const Expr *ReceiverE = ME->getInstanceReceiver())
-        bugreporter::addTrackNullOrUndefValueVisitor(N, ReceiverE, R);
+        bugreporter::trackNullOrUndefValue(N, ReceiverE, *R);
       C.EmitReport(R);
     }
     return;
@@ -377,7 +377,7 @@
   report->addRange(ME->getReceiverRange());
   // FIXME: This won't track "self" in messages to super.
   if (const Expr *receiver = ME->getInstanceReceiver()) {
-    bugreporter::addTrackNullOrUndefValueVisitor(N, receiver, report);
+    bugreporter::trackNullOrUndefValue(N, receiver, *report);
   }
   C.EmitReport(report);
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp Mon Aug 27 19:50:51 2012
@@ -166,8 +166,7 @@
                   buf.empty() ? BT_null->getDescription() : buf.str(),
                   N);
 
-  bugreporter::addTrackNullOrUndefValueVisitor(N, bugreporter::GetDerefExpr(N),
-                                               report);
+  bugreporter::trackNullOrUndefValue(N, bugreporter::GetDerefExpr(N), *report);
 
   for (SmallVectorImpl<SourceRange>::iterator
        I = Ranges.begin(), E = Ranges.end(); I!=E; ++I)
@@ -191,9 +190,8 @@
 
       BugReport *report =
         new BugReport(*BT_undef, BT_undef->getDescription(), N);
-      bugreporter::addTrackNullOrUndefValueVisitor(N,
-                                                   bugreporter::GetDerefExpr(N),
-                                                   report);
+      bugreporter::trackNullOrUndefValue(N, bugreporter::GetDerefExpr(N),
+                                         *report);
       report->disablePathPruning();
       C.EmitReport(report);
     }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp Mon Aug 27 19:50:51 2012
@@ -39,12 +39,8 @@
     if (!BT)
       BT.reset(new BuiltinBug("Division by zero"));
 
-    BugReport *R =
-      new BugReport(*BT, Msg, N);
-
-    bugreporter::addTrackNullOrUndefValueVisitor(N,
-                                                 bugreporter::GetDenomExpr(N),
-                                                 R);
+    BugReport *R = new BugReport(*BT, Msg, N);
+    bugreporter::trackNullOrUndefValue(N, bugreporter::GetDenomExpr(N), *R);
     C.EmitReport(R);
   }
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp Mon Aug 27 19:50:51 2012
@@ -49,7 +49,7 @@
                                   "for @synchronized"));
       BugReport *report =
         new BugReport(*BT_undef, BT_undef->getDescription(), N);
-      bugreporter::addTrackNullOrUndefValueVisitor(N, Ex, report);
+      bugreporter::trackNullOrUndefValue(N, Ex, *report);
       C.EmitReport(report);
     }
     return;
@@ -72,7 +72,7 @@
                                    "(no synchronization will occur)"));
         BugReport *report =
           new BugReport(*BT_null, BT_null->getDescription(), N);
-        bugreporter::addTrackNullOrUndefValueVisitor(N, Ex, report);
+        bugreporter::trackNullOrUndefValue(N, Ex, *report);
 
         C.EmitReport(report);
         return;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp Mon Aug 27 19:50:51 2012
@@ -55,7 +55,7 @@
 
   report->disablePathPruning();
   report->addRange(RetE->getSourceRange());
-  bugreporter::addTrackNullOrUndefValueVisitor(N, RetE, report);
+  bugreporter::trackNullOrUndefValue(N, RetE, *report);
 
   C.EmitReport(report);
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp Mon Aug 27 19:50:51 2012
@@ -99,7 +99,7 @@
 
       // Emit the bug report.
       BugReport *R = new BugReport(*BT, BT->getDescription(), N);
-      bugreporter::addTrackNullOrUndefValueVisitor(N, Ex, R);
+      bugreporter::trackNullOrUndefValue(N, Ex, *R);
       R->addRange(Ex->getSourceRange());
       R->disablePathPruning();
 

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp Mon Aug 27 19:50:51 2012
@@ -76,10 +76,10 @@
     BugReport *report = new BugReport(*BT, OS.str(), N);
     if (Ex) {
       report->addRange(Ex->getSourceRange());
-      bugreporter::addTrackNullOrUndefValueVisitor(N, Ex, report);
+      bugreporter::trackNullOrUndefValue(N, Ex, *report);
     }
     else
-      bugreporter::addTrackNullOrUndefValueVisitor(N, B, report);
+      bugreporter::trackNullOrUndefValue(N, B, *report);
     
     report->disablePathPruning();
     C.EmitReport(report);

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp Mon Aug 27 19:50:51 2012
@@ -42,7 +42,7 @@
       // Generate a report for this bug.
       BugReport *R = new BugReport(*BT, BT->getName(), N);
       R->addRange(A->getIdx()->getSourceRange());
-      bugreporter::addTrackNullOrUndefValueVisitor(N, A->getIdx(), R);
+      bugreporter::trackNullOrUndefValue(N, A->getIdx(), *R);
       C.EmitReport(R);
     }
   }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp Mon Aug 27 19:50:51 2012
@@ -78,7 +78,7 @@
   BugReport *R = new BugReport(*BT, str, N);
   if (ex) {
     R->addRange(ex->getSourceRange());
-    bugreporter::addTrackNullOrUndefValueVisitor(N, ex, R);
+    bugreporter::trackNullOrUndefValue(N, ex, *R);
   }
   R->disablePathPruning();
   C.EmitReport(R);

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp Mon Aug 27 19:50:51 2012
@@ -224,7 +224,7 @@
   BugReport *report = new BugReport(*BT_mallocZero, os.str(), N);
 
   report->addRange(arg->getSourceRange());
-  bugreporter::addTrackNullOrUndefValueVisitor(N, arg, report);
+  bugreporter::trackNullOrUndefValue(N, arg, *report);
   C.EmitReport(report);
 
   return true;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp Mon Aug 27 19:50:51 2012
@@ -69,7 +69,7 @@
 
   BugReport *report = new BugReport(*BT, os.str(), N);
   report->addRange(SizeE->getSourceRange());
-  bugreporter::addTrackNullOrUndefValueVisitor(N, SizeE, report);
+  bugreporter::trackNullOrUndefValue(N, SizeE, *report);
   C.EmitReport(report);
   return;
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=162720&r1=162719&r2=162720&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Mon Aug 27 19:50:51 2012
@@ -210,7 +210,7 @@
     llvm::tie(StNonZero, StZero) = State->assume(cast<DefinedSVal>(V));
     if (StZero && !StNonZero) {
       // If we're returning 0, we should track where that 0 came from.
-      bugreporter::addTrackNullOrUndefValueVisitor(N, RetE, &BR);
+      bugreporter::trackNullOrUndefValue(N, RetE, BR);
 
       if (isa<Loc>(V)) {
         if (RetE->getType()->isObjCObjectPointerType())
@@ -435,9 +435,8 @@
   return NULL;
 }
 
-void bugreporter::addTrackNullOrUndefValueVisitor(const ExplodedNode *N,
-                                                  const Stmt *S,
-                                                  BugReport *report) {
+void bugreporter::trackNullOrUndefValue(const ExplodedNode *N, const Stmt *S,
+                                        BugReport &report) {
   if (!S || !N)
     return;
 
@@ -477,17 +476,17 @@
 
         // Mark both the variable region and its contents as interesting.
         SVal V = state->getRawSVal(loc::MemRegionVal(R));
-        report->markInteresting(R);
-        report->markInteresting(V);
+        report.markInteresting(R);
+        report.markInteresting(V);
 
         // If the contents are symbolic, find out when they became null.
         if (V.getAsLocSymbol()) {
           BugReporterVisitor *ConstraintTracker
             = new TrackConstraintBRVisitor(cast<loc::MemRegionVal>(V), false);
-          report->addVisitor(ConstraintTracker);
+          report.addVisitor(ConstraintTracker);
         }
 
-        report->addVisitor(new FindLastStoreBRVisitor(V, R));
+        report.addVisitor(new FindLastStoreBRVisitor(V, R));
         return;
       }
     }
@@ -505,14 +504,14 @@
   if (loc::MemRegionVal *L = dyn_cast<loc::MemRegionVal>(&V)) {
     const MemRegion *Base = L->getRegion()->getBaseRegion();
     if (isa<SymbolicRegion>(Base)) {
-      report->markInteresting(Base);
-      report->addVisitor(new TrackConstraintBRVisitor(loc::MemRegionVal(Base),
+      report.markInteresting(Base);
+      report.addVisitor(new TrackConstraintBRVisitor(loc::MemRegionVal(Base),
                                                       false));
     }
   } else {
     // Otherwise, if the value came from an inlined function call,
     // we should at least make sure that function isn't pruned in our output.
-    ReturnVisitor::addVisitorIfNecessary(N, S, *report);
+    ReturnVisitor::addVisitorIfNecessary(N, S, report);
   }
 }
 
@@ -555,7 +554,7 @@
   // The receiver was nil, and hence the method was skipped.
   // Register a BugReporterVisitor to issue a message telling us how
   // the receiver was null.
-  bugreporter::addTrackNullOrUndefValueVisitor(N, Receiver, &BR);
+  bugreporter::trackNullOrUndefValue(N, Receiver, BR);
   // Issue a message saying that the method was skipped.
   PathDiagnosticLocation L(Receiver, BRC.getSourceManager(),
                                      N->getLocationContext());





More information about the cfe-commits mailing list