FunctionDecl::getBody() is getting an ASTContext argument for use in
lazy PCH deserialization. Propagate that argument wherever it needs to
be. No functionality change, except that I've tightened up a few PCH
tests in preparation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69406 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index 566c197..9047d9d 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -525,7 +525,7 @@
           
           // Scan the method for ivar references.  While this requires an
           // entire AST scan, the cost should not be high in practice.
-          St = scanForIvars(MD->getBody(), PD, St);
+          St = scanForIvars(MD->getBody(getContext()), PD, St);
         }
       }
     }
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index 01f5e81..7e7132a 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -140,7 +140,7 @@
                                             const ExplodedNode<GRState>* N);
   
   ParentMap& getParentMap() {
-    if (PM.get() == 0) PM.reset(new ParentMap(CodeDecl.getBody()));
+    if (PM.get() == 0) PM.reset(new ParentMap(CodeDecl.getBody(getContext())));
     return *PM.get();
   }
   
@@ -163,7 +163,7 @@
   BugReport& getReport() { return *R; }
   GRBugReporter& getBugReporter() { return BR; }
   GRStateManager& getStateManager() { return BR.getStateManager(); }
-  
+
   PathDiagnosticLocation getEnclosingStmtLocation(const Stmt *S);
   
   PathDiagnosticLocation
@@ -189,7 +189,7 @@
   if (Stmt *S = GetNextStmt(N))
     return PathDiagnosticLocation(S, SMgr);
 
-  return FullSourceLoc(CodeDecl.getBody()->getRBracLoc(), SMgr);
+  return FullSourceLoc(CodeDecl.getBody(getContext())->getRBracLoc(), SMgr);
 }
   
 PathDiagnosticLocation
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index cfeabd0..7443c52 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -2903,7 +2903,8 @@
   }
   
   if (!L.isValid()) {
-    CompoundStmt *CS = BR.getStateManager().getCodeDecl().getBody();
+    CompoundStmt *CS 
+      = BR.getStateManager().getCodeDecl().getBody(BR.getContext());
     L = PathDiagnosticLocation(CS->getRBracLoc(), SMgr);
   }
 
diff --git a/lib/Analysis/CheckObjCDealloc.cpp b/lib/Analysis/CheckObjCDealloc.cpp
index a14ae26..0d6e7e4 100644
--- a/lib/Analysis/CheckObjCDealloc.cpp
+++ b/lib/Analysis/CheckObjCDealloc.cpp
@@ -172,7 +172,7 @@
   }
   
   // dealloc found.  Scan for missing [super dealloc].
-  if (MD->getBody() && !scan_dealloc(MD->getBody(), S)) {
+  if (MD->getBody(Ctx) && !scan_dealloc(MD->getBody(Ctx), S)) {
     
     const char* name = LOpts.getGCMode() == LangOptions::NonGC
                        ? "missing [super dealloc]"
@@ -223,7 +223,7 @@
               
     // ivar must be released if and only if the kind of setter was not 'assign'
     bool requiresRelease = PD->getSetterKind() != ObjCPropertyDecl::Assign;
-    if(scan_ivar_release(MD->getBody(), ID, PD, RS, SelfII, Ctx) 
+    if(scan_ivar_release(MD->getBody(Ctx), ID, PD, RS, SelfII, Ctx) 
        != requiresRelease) {
       const char *name;
       const char* category = "Memory (Core Foundation/Objective-C)";
diff --git a/lib/Analysis/CheckObjCUnusedIVars.cpp b/lib/Analysis/CheckObjCUnusedIVars.cpp
index 658a6b1..57fad8d 100644
--- a/lib/Analysis/CheckObjCUnusedIVars.cpp
+++ b/lib/Analysis/CheckObjCUnusedIVars.cpp
@@ -85,7 +85,7 @@
   // Now scan the methods for accesses.
   for (ObjCImplementationDecl::instmeth_iterator I = D->instmeth_begin(),
        E = D->instmeth_end(); I!=E; ++I)
-    Scan(M, (*I)->getBody());
+    Scan(M, (*I)->getBody(BR.getContext()));
   
   // Scan for @synthesized property methods that act as setters/getters
   // to an ivar.
diff --git a/lib/Analysis/PathDiagnostic.cpp b/lib/Analysis/PathDiagnostic.cpp
index da007c1..1d00727 100644
--- a/lib/Analysis/PathDiagnostic.cpp
+++ b/lib/Analysis/PathDiagnostic.cpp
@@ -171,8 +171,13 @@
     case DeclK:
       if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
         return MD->getSourceRange();
-      if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
-        return FD->getBody()->getSourceRange();
+      if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+        // FIXME: We would like to always get the function body, even
+        // when it needs to be de-serialized, but getting the
+        // ASTContext here requires significant changes.
+        if (CompoundStmt *Body = FD->getBodyIfAvailable())
+          return Body->getSourceRange();
+      }
       else {
         SourceLocation L = D->getLocation();
         return SourceRange(L, L);