[AST] Reduce Decl::getASTContext() calls.
 - This function is not at all free; pass it around along some hot paths instead
   of recomputing it deep inside various VarDecl methods.

llvm-svn: 152363
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 33656c9..062e4aa 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6747,7 +6747,7 @@
         for (unsigned I = 0, N = Notes.size(); I != N; ++I)
           Diag(Notes[I].first, Notes[I].second);
       }
-    } else if (var->isUsableInConstantExpressions()) {
+    } else if (var->isUsableInConstantExpressions(Context)) {
       // Check whether the initializer of a const variable of integral or
       // enumeration type is an ICE now, since we can't tell whether it was
       // initialized by a constant expression if we check later.
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b989fac..64008e1 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10145,7 +10145,7 @@
                                SourceLocation Loc) {
   // Keep track of used but undefined variables.
   // FIXME: We shouldn't suppress this warning for static data members.
-  if (Var->hasDefinition() == VarDecl::DeclarationOnly &&
+  if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly &&
       Var->getLinkage() != ExternalLinkage &&
       !(Var->isStaticDataMember() && Var->hasInit())) {
     SourceLocation &old = SemaRef.UndefinedInternals[Var->getCanonicalDecl()];
@@ -10218,7 +10218,8 @@
     assert(MSInfo && "Missing member specialization information?");
     bool AlreadyInstantiated = !MSInfo->getPointOfInstantiation().isInvalid();
     if (MSInfo->getTemplateSpecializationKind() == TSK_ImplicitInstantiation &&
-        (!AlreadyInstantiated || Var->isUsableInConstantExpressions())) {
+        (!AlreadyInstantiated ||
+         Var->isUsableInConstantExpressions(SemaRef.Context))) {
       if (!AlreadyInstantiated) {
         // This is a modification of an existing AST node. Notify listeners.
         if (ASTMutationListener *L = SemaRef.getASTMutationListener())
@@ -10226,7 +10227,7 @@
         MSInfo->setPointOfInstantiation(Loc);
       }
       SourceLocation PointOfInstantiation = MSInfo->getPointOfInstantiation();
-      if (Var->isUsableInConstantExpressions())
+      if (Var->isUsableInConstantExpressions(SemaRef.Context))
         // Do not defer instantiations of variables which could be used in a
         // constant expression.
         SemaRef.InstantiateStaticDataMemberDefinition(PointOfInstantiation,Var);
@@ -10246,7 +10247,7 @@
   // apply to references, since they are not objects.
   const VarDecl *DefVD;
   if (E && !isa<ParmVarDecl>(Var) && !Var->getType()->isReferenceType() &&
-      Var->isUsableInConstantExpressions() &&
+      Var->isUsableInConstantExpressions(SemaRef.Context) &&
       Var->getAnyInitializer(DefVD) && DefVD->checkInitIsICE())
     SemaRef.MaybeODRUseExprs.insert(E);
   else