[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162720 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
index 1045c28..e82b523 100644
--- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
+++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
@@ -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);
diff --git a/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp b/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
index c582cfc..f809a0d 100644
--- a/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp
@@ -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);
       }
diff --git a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
index bd75a4c..a09324e 100644
--- a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -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;
   }
diff --git a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 457958d..1e5189d 100644
--- a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -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;
   }
diff --git a/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp b/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
index 5edcf09..eef29cb 100644
--- a/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -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);
 }
diff --git a/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp b/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
index e98c131..cb0a3ce 100644
--- a/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
@@ -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);
     }
diff --git a/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp b/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
index dcf6a86..3a68598 100644
--- a/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
@@ -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);
   }
 }
diff --git a/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
index caf5b29..afab339 100644
--- a/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
@@ -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;
diff --git a/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp b/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp
index ca2a55d..4abda42 100644
--- a/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp
@@ -55,7 +55,7 @@
 
   report->disablePathPruning();
   report->addRange(RetE->getSourceRange());
-  bugreporter::addTrackNullOrUndefValueVisitor(N, RetE, report);
+  bugreporter::trackNullOrUndefValue(N, RetE, *report);
 
   C.EmitReport(report);
 }
diff --git a/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp
index 70a33c7..8a97b05 100644
--- a/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp
@@ -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();
 
diff --git a/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
index e220499..605f677 100644
--- a/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -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);
diff --git a/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
index 6ae3c18..2765672 100644
--- a/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
@@ -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);
     }
   }
diff --git a/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
index 14a884e..8ae75ea 100644
--- a/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
@@ -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);
diff --git a/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
index d35455c..d298dd9 100644
--- a/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -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;
diff --git a/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp b/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
index fab4adf..b6091f5 100644
--- a/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -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;
 }
diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index a2d0585..a1b7e30 100644
--- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -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());