Refactor 'PostStmt' and 'PreStmt' to subclass a common parent 'StmtPoint'.

Educate GRExprEngine::VisitGraph() about 'PreStmt'.

Mark the constructor of 'PostStmt' to be explicit, preventing implicit
conversions and the selection of the wrong 'generateNode' method in
GRStmtNodeBuilder.

Constify a bunch of arguments, which falls out of the changes to ProgramPoint.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76809 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 908211a..04f9cb8 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -2298,9 +2298,9 @@
   // This is the allocation site since the previous node had no bindings
   // for this symbol.
   if (!PrevT) {
-    Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
+    const Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
     
-    if (CallExpr *CE = dyn_cast<CallExpr>(S)) {
+    if (const CallExpr *CE = dyn_cast<CallExpr>(S)) {
       // Get the name of the callee (if it is available).
       SVal X = CurrSt->getSValAsScalarOrLoc(CE->getCallee());
       if (const FunctionDecl* FD = X.getAsFunctionDecl())
@@ -2347,14 +2347,14 @@
         TF.getSummaryOfNode(BRC.getNodeResolver().getOriginalNode(N))) {
     // We only have summaries attached to nodes after evaluating CallExpr and
     // ObjCMessageExprs.
-    Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
+    const Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
     
-    if (CallExpr *CE = dyn_cast<CallExpr>(S)) {
+    if (const CallExpr *CE = dyn_cast<CallExpr>(S)) {
       // Iterate through the parameter expressions and see if the symbol
       // was ever passed as an argument.
       unsigned i = 0;
       
-      for (CallExpr::arg_iterator AI=CE->arg_begin(), AE=CE->arg_end();
+      for (CallExpr::const_arg_iterator AI=CE->arg_begin(), AE=CE->arg_end();
            AI!=AE; ++AI, ++i) {
         
         // Retrieve the value of the argument.  Is it the symbol
@@ -2366,8 +2366,8 @@
         AEffects.push_back(Summ->getArg(i));
       }
     }
-    else if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(S)) {      
-      if (Expr *receiver = ME->getReceiver())
+    else if (const ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(S)) {      
+      if (const Expr *receiver = ME->getReceiver())
         if (CurrSt->getSValAsScalarOrLoc(receiver).getAsLocSymbol() == Sym) {
           // The symbol we are tracking is the receiver.
           AEffects.push_back(Summ->getReceiverEffect());
@@ -2395,7 +2395,7 @@
     // Specially handle CFMakeCollectable and friends.
     if (contains(AEffects, MakeCollectable)) {
       // Get the name of the function.
-      Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
+      const Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
       SVal X = CurrSt->getSValAsScalarOrLoc(cast<CallExpr>(S)->getCallee());
       const FunctionDecl* FD = X.getAsFunctionDecl();
       const std::string& FName = FD->getNameAsString();
@@ -2499,14 +2499,15 @@
   if (os.str().empty())
     return 0; // We have nothing to say!
 
-  Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
+  const Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
   PathDiagnosticLocation Pos(S, BRC.getSourceManager());
   PathDiagnosticPiece* P = new PathDiagnosticEventPiece(Pos, os.str());
   
   // Add the range by scanning the children of the statement for any bindings
   // to Sym.
-  for (Stmt::child_iterator I = S->child_begin(), E = S->child_end(); I!=E; ++I)
-    if (Expr* Exp = dyn_cast_or_null<Expr>(*I))
+  for (Stmt::const_child_iterator I = S->child_begin(), E = S->child_end(); 
+       I!=E; ++I)
+    if (const Expr* Exp = dyn_cast_or_null<Expr>(*I))
       if (CurrSt->getSValAsScalarOrLoc(Exp).getAsLocSymbol() == Sym) {
         P->addRange(Exp->getSourceRange());
         break;
@@ -2602,7 +2603,7 @@
   
   // Get the allocate site.  
   assert(AllocNode);
-  Stmt* FirstStmt = cast<PostStmt>(AllocNode->getLocation()).getStmt();
+  const Stmt* FirstStmt = cast<PostStmt>(AllocNode->getLocation()).getStmt();
   
   SourceManager& SMgr = BRC.getSourceManager();
   unsigned AllocLine =SMgr.getInstantiationLineNumber(FirstStmt->getLocStart());