Change references to 'const ProgramState *' to typedef 'ProgramStateRef'.

At this point this is largely cosmetic, but it opens the door to replace
ProgramStateRef with a smart pointer that more eagerly acts in the role
of reclaiming unused ProgramState objects.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149081 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
index 2f2f9d1..57864c7 100644
--- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -50,7 +50,7 @@
                              const ProgramPointTag *t = 0)
   : C(&c), tag(t){}
 
-  ExplodedNode *MakeNode(const ProgramState *state, ExplodedNode *Pred,
+  ExplodedNode *MakeNode(ProgramStateRef state, ExplodedNode *Pred,
                          bool MarkAsSink = false) {
     return C->addTransition(state, Pred, tag, MarkAsSink);
   }
@@ -732,7 +732,7 @@
   const RetainSummary *getSummary(const FunctionDecl *FD);
 
   const RetainSummary *getInstanceMethodSummary(const ObjCMessage &msg,
-                                                const ProgramState *state,
+                                                ProgramStateRef state,
                                                 const LocationContext *LC);
 
   const RetainSummary *getInstanceMethodSummary(const ObjCMessage &msg,
@@ -1298,7 +1298,7 @@
 
 const RetainSummary *
 RetainSummaryManager::getInstanceMethodSummary(const ObjCMessage &msg,
-                                               const ProgramState *state,
+                                               ProgramStateRef state,
                                                const LocationContext *LC) {
 
   // We need the type-information of the tracked receiver object
@@ -1553,13 +1553,13 @@
 } // end GR namespace
 } // end clang namespace
 
-static SymbolRef GetCurrentAutoreleasePool(const ProgramState *state) {
+static SymbolRef GetCurrentAutoreleasePool(ProgramStateRef state) {
   ARStack stack = state->get<AutoreleaseStack>();
   return stack.isEmpty() ? SymbolRef() : stack.getHead();
 }
 
-static const ProgramState *
-SendAutorelease(const ProgramState *state,
+static ProgramStateRef 
+SendAutorelease(ProgramStateRef state,
                 ARCounts::Factory &F,
                 SymbolRef sym) {
   SymbolRef pool = GetCurrentAutoreleasePool(state);
@@ -1838,8 +1838,8 @@
     return NULL;
 
   // Check if the type state has changed.
-  const ProgramState *PrevSt = PrevN->getState();
-  const ProgramState *CurrSt = N->getState();
+  ProgramStateRef PrevSt = PrevN->getState();
+  ProgramStateRef CurrSt = N->getState();
   const LocationContext *LCtx = N->getLocationContext();
 
   const RefVal* CurrT = CurrSt->get<RefBindings>(Sym);
@@ -2121,7 +2121,7 @@
   const MemRegion* FirstBinding = 0;
 
   while (N) {
-    const ProgramState *St = N->getState();
+    ProgramStateRef St = N->getState();
     RefBindings B = St->get<RefBindings>();
 
     if (!B.lookup(Sym))
@@ -2416,7 +2416,7 @@
     return getSummaryManager(C.getASTContext(), C.isObjCGCEnabled());
   }
 
-  void printState(raw_ostream &Out, const ProgramState *State,
+  void printState(raw_ostream &Out, ProgramStateRef State,
                   const char *NL, const char *Sep) const;
 
   void checkBind(SVal loc, SVal val, const Stmt *S, CheckerContext &C) const;
@@ -2431,47 +2431,47 @@
 
   bool evalCall(const CallExpr *CE, CheckerContext &C) const;
 
-  const ProgramState *evalAssume(const ProgramState *state, SVal Cond,
+  ProgramStateRef evalAssume(ProgramStateRef state, SVal Cond,
                                  bool Assumption) const;
 
-  const ProgramState *
-  checkRegionChanges(const ProgramState *state,
+  ProgramStateRef 
+  checkRegionChanges(ProgramStateRef state,
                      const StoreManager::InvalidatedSymbols *invalidated,
                      ArrayRef<const MemRegion *> ExplicitRegions,
                      ArrayRef<const MemRegion *> Regions) const;
                                         
-  bool wantsRegionChangeUpdate(const ProgramState *state) const {
+  bool wantsRegionChangeUpdate(ProgramStateRef state) const {
     return true;
   }
 
   void checkPreStmt(const ReturnStmt *S, CheckerContext &C) const;
   void checkReturnWithRetEffect(const ReturnStmt *S, CheckerContext &C,
                                 ExplodedNode *Pred, RetEffect RE, RefVal X,
-                                SymbolRef Sym, const ProgramState *state) const;
+                                SymbolRef Sym, ProgramStateRef state) const;
                                               
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
   void checkEndPath(CheckerContext &C) const;
 
-  const ProgramState *updateSymbol(const ProgramState *state, SymbolRef sym,
+  ProgramStateRef updateSymbol(ProgramStateRef state, SymbolRef sym,
                                    RefVal V, ArgEffect E, RefVal::Kind &hasErr,
                                    CheckerContext &C) const;
 
-  void processNonLeakError(const ProgramState *St, SourceRange ErrorRange,
+  void processNonLeakError(ProgramStateRef St, SourceRange ErrorRange,
                            RefVal::Kind ErrorKind, SymbolRef Sym,
                            CheckerContext &C) const;
 
   const ProgramPointTag *getDeadSymbolTag(SymbolRef sym) const;
 
-  const ProgramState *handleSymbolDeath(const ProgramState *state,
+  ProgramStateRef handleSymbolDeath(ProgramStateRef state,
                                         SymbolRef sid, RefVal V,
                                       SmallVectorImpl<SymbolRef> &Leaked) const;
 
-  std::pair<ExplodedNode *, const ProgramState *>
-  handleAutoreleaseCounts(const ProgramState *state, 
+  std::pair<ExplodedNode *, ProgramStateRef >
+  handleAutoreleaseCounts(ProgramStateRef state, 
                           GenericNodeBuilderRefCount Bd, ExplodedNode *Pred,
                           CheckerContext &Ctx, SymbolRef Sym, RefVal V) const;
 
-  ExplodedNode *processLeaks(const ProgramState *state,
+  ExplodedNode *processLeaks(ProgramStateRef state,
                              SmallVectorImpl<SymbolRef> &Leaked,
                              GenericNodeBuilderRefCount &Builder,
                              CheckerContext &Ctx,
@@ -2481,10 +2481,10 @@
 
 namespace {
 class StopTrackingCallback : public SymbolVisitor {
-  const ProgramState *state;
+  ProgramStateRef state;
 public:
-  StopTrackingCallback(const ProgramState *st) : state(st) {}
-  const ProgramState *getState() const { return state; }
+  StopTrackingCallback(ProgramStateRef st) : state(st) {}
+  ProgramStateRef getState() const { return state; }
 
   bool VisitSymbol(SymbolRef sym) {
     state = state->remove<RefBindings>(sym);
@@ -2505,7 +2505,7 @@
   if (!BE->getBlockDecl()->hasCaptures())
     return;
 
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
   const BlockDataRegion *R =
     cast<BlockDataRegion>(state->getSVal(BE,
                                          C.getLocationContext()).getAsRegion());
@@ -2557,7 +2557,7 @@
       break;
   }
   
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
   SymbolRef Sym = state->getSVal(CE, C.getLocationContext()).getAsLocSymbol();
   if (!Sym)
     return;
@@ -2580,7 +2580,7 @@
 void RetainCountChecker::checkPostStmt(const CallExpr *CE,
                                        CheckerContext &C) const {
   // Get the callee.
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
   const Expr *Callee = CE->getCallee();
   SVal L = state->getSVal(Callee, C.getLocationContext());
 
@@ -2618,13 +2618,13 @@
   if (!Summ)
     return;
 
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
   checkSummary(*Summ, CallOrObjCMessage(CE, state, C.getLocationContext()), C);
 }
 
 void RetainCountChecker::checkPostObjCMessage(const ObjCMessage &Msg, 
                                               CheckerContext &C) const {
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
 
   RetainSummaryManager &Summaries = getSummaryManager(C);
 
@@ -2674,7 +2674,7 @@
 void RetainCountChecker::checkSummary(const RetainSummary &Summ,
                                       const CallOrObjCMessage &CallOrMsg,
                                       CheckerContext &C) const {
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
 
   // Evaluate the effect of the arguments.
   RefVal::Kind hasErr = (RefVal::Kind) 0;
@@ -2802,8 +2802,8 @@
 }
 
 
-const ProgramState *
-RetainCountChecker::updateSymbol(const ProgramState *state, SymbolRef sym,
+ProgramStateRef 
+RetainCountChecker::updateSymbol(ProgramStateRef state, SymbolRef sym,
                                  RefVal V, ArgEffect E, RefVal::Kind &hasErr,
                                  CheckerContext &C) const {
   // In GC mode [... release] and [... retain] do nothing.
@@ -2939,7 +2939,7 @@
   return state->set<RefBindings>(sym, V);
 }
 
-void RetainCountChecker::processNonLeakError(const ProgramState *St,
+void RetainCountChecker::processNonLeakError(ProgramStateRef St,
                                              SourceRange ErrorRange,
                                              RefVal::Kind ErrorKind,
                                              SymbolRef Sym,
@@ -2988,7 +2988,7 @@
 
 bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const {
   // Get the callee. We're only interested in simple C functions.
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
   const FunctionDecl *FD = C.getCalleeDecl(CE);
   if (!FD)
     return false;
@@ -3071,7 +3071,7 @@
   if (!RetE)
     return;
 
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
   SymbolRef Sym =
     state->getSValAsScalarOrLoc(RetE, C.getLocationContext()).getAsLocSymbol();
   if (!Sym)
@@ -3163,7 +3163,7 @@
                                                   ExplodedNode *Pred,
                                                   RetEffect RE, RefVal X,
                                                   SymbolRef Sym,
-                                              const ProgramState *state) const {
+                                              ProgramStateRef state) const {
   // Any leaks or other errors?
   if (X.isReturnedOwned() && X.getCount() == 0) {
     if (RE.getKind() != RetEffect::NoRet) {
@@ -3240,7 +3240,7 @@
   // (2) we are binding to a memregion that does not have stack storage
   // (3) we are binding to a memregion with stack storage that the store
   //     does not understand.
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
 
   if (loc::MemRegionVal *regionLoc = dyn_cast<loc::MemRegionVal>(&loc)) {
     escapes = !regionLoc->getRegion()->hasStackStorage();
@@ -3265,7 +3265,7 @@
   C.addTransition(state);
 }
 
-const ProgramState *RetainCountChecker::evalAssume(const ProgramState *state,
+ProgramStateRef RetainCountChecker::evalAssume(ProgramStateRef state,
                                                    SVal Cond,
                                                    bool Assumption) const {
 
@@ -3298,8 +3298,8 @@
   return state;
 }
 
-const ProgramState *
-RetainCountChecker::checkRegionChanges(const ProgramState *state,
+ProgramStateRef 
+RetainCountChecker::checkRegionChanges(ProgramStateRef state,
                             const StoreManager::InvalidatedSymbols *invalidated,
                                     ArrayRef<const MemRegion *> ExplicitRegions,
                                     ArrayRef<const MemRegion *> Regions) const {
@@ -3328,8 +3328,8 @@
 // Handle dead symbols and end-of-path.
 //===----------------------------------------------------------------------===//
 
-std::pair<ExplodedNode *, const ProgramState *>
-RetainCountChecker::handleAutoreleaseCounts(const ProgramState *state, 
+std::pair<ExplodedNode *, ProgramStateRef >
+RetainCountChecker::handleAutoreleaseCounts(ProgramStateRef state, 
                                             GenericNodeBuilderRefCount Bd,
                                             ExplodedNode *Pred,
                                             CheckerContext &Ctx,
@@ -3389,11 +3389,11 @@
     Ctx.EmitReport(report);
   }
 
-  return std::make_pair((ExplodedNode *)0, (const ProgramState *)0);
+  return std::make_pair((ExplodedNode *)0, (ProgramStateRef )0);
 }
 
-const ProgramState *
-RetainCountChecker::handleSymbolDeath(const ProgramState *state,
+ProgramStateRef 
+RetainCountChecker::handleSymbolDeath(ProgramStateRef state,
                                       SymbolRef sid, RefVal V,
                                     SmallVectorImpl<SymbolRef> &Leaked) const {
   bool hasLeak = false;
@@ -3410,7 +3410,7 @@
 }
 
 ExplodedNode *
-RetainCountChecker::processLeaks(const ProgramState *state,
+RetainCountChecker::processLeaks(ProgramStateRef state,
                                  SmallVectorImpl<SymbolRef> &Leaked,
                                  GenericNodeBuilderRefCount &Builder,
                                  CheckerContext &Ctx,
@@ -3441,7 +3441,7 @@
 }
 
 void RetainCountChecker::checkEndPath(CheckerContext &Ctx) const {
-  const ProgramState *state = Ctx.getState();
+  ProgramStateRef state = Ctx.getState();
   GenericNodeBuilderRefCount Bd(Ctx);
   RefBindings B = state->get<RefBindings>();
   ExplodedNode *Pred = Ctx.getPredecessor();
@@ -3479,7 +3479,7 @@
                                           CheckerContext &C) const {
   ExplodedNode *Pred = C.getPredecessor();
 
-  const ProgramState *state = C.getState();
+  ProgramStateRef state = C.getState();
   RefBindings B = state->get<RefBindings>();
 
   // Update counts from autorelease pools
@@ -3531,7 +3531,7 @@
 //===----------------------------------------------------------------------===//
 
 static void PrintPool(raw_ostream &Out, SymbolRef Sym,
-                      const ProgramState *State) {
+                      ProgramStateRef State) {
   Out << ' ';
   if (Sym)
     Sym->dumpToStream(Out);
@@ -3547,14 +3547,14 @@
   Out << '}';
 }
 
-static bool UsesAutorelease(const ProgramState *state) {
+static bool UsesAutorelease(ProgramStateRef state) {
   // A state uses autorelease if it allocated an autorelease pool or if it has
   // objects in the caller's autorelease pool.
   return !state->get<AutoreleaseStack>().isEmpty() ||
           state->get<AutoreleasePoolContents>(SymbolRef());
 }
 
-void RetainCountChecker::printState(raw_ostream &Out, const ProgramState *State,
+void RetainCountChecker::printState(raw_ostream &Out, ProgramStateRef State,
                                     const char *NL, const char *Sep) const {
 
   RefBindings B = State->get<RefBindings>();