De-ASTContext-ify DeclContext.

Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating".
Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74506 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 1172d3e..f7c0ada 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -680,7 +680,7 @@
   // Look for a member, first.
   FieldDecl *Member = 0;
   DeclContext::lookup_result Result 
-    = ClassDecl->lookup(Context, MemberOrBase);
+    = ClassDecl->lookup(MemberOrBase);
   if (Result.first != Result.second)
     Member = dyn_cast<FieldDecl>(*Result.first);
 
@@ -847,8 +847,7 @@
     MethodSetTy OverriddenMethods;
     size_t MethodsSize = Methods.size();
 
-    for (RecordDecl::decl_iterator i = RD->decls_begin(Context), 
-         e = RD->decls_end(Context); 
+    for (RecordDecl::decl_iterator i = RD->decls_begin(), e = RD->decls_end(); 
          i != e; ++i) {
       // Traverse the record, looking for methods.
       if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*i)) {
@@ -945,8 +944,8 @@
     bool VisitDeclContext(const DeclContext *DC) {
       bool Invalid = false;
 
-      for (CXXRecordDecl::decl_iterator I = DC->decls_begin(SemaRef.Context),
-           E = DC->decls_end(SemaRef.Context); I != E; ++I)
+      for (CXXRecordDecl::decl_iterator I = DC->decls_begin(),
+           E = DC->decls_end(); I != E; ++I)
         Invalid |= Visit(*I);
 
       return Invalid;
@@ -1022,8 +1021,8 @@
     AbstractClassUsageDiagnoser(*this, RD);
     
   if (RD->hasTrivialConstructor() || RD->hasTrivialDestructor()) {
-    for (RecordDecl::field_iterator i = RD->field_begin(Context), 
-         e = RD->field_end(Context); i != e; ++i) {
+    for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
+         i != e; ++i) {
       // All the nonstatic data members must have trivial constructors.
       QualType FTy = i->getType();
       while (const ArrayType *AT = Context.getAsArrayType(FTy))
@@ -1080,7 +1079,7 @@
                                  /*isImplicitlyDeclared=*/true);
     DefaultCon->setAccess(AS_public);
     DefaultCon->setImplicit();
-    ClassDecl->addDecl(Context, DefaultCon);
+    ClassDecl->addDecl(DefaultCon);
   }
 
   if (!ClassDecl->hasUserDeclaredCopyConstructor()) {
@@ -1112,8 +1111,8 @@
     //        class type M (or array thereof), each such class type
     //        has a copy constructor whose first parameter is of type
     //        const M& or const volatile M&.
-    for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
-         HasConstCopyConstructor && Field != ClassDecl->field_end(Context);
+    for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin();
+         HasConstCopyConstructor && Field != ClassDecl->field_end();
          ++Field) {
       QualType FieldType = (*Field)->getType();
       if (const ArrayType *Array = Context.getAsArrayType(FieldType))
@@ -1157,7 +1156,7 @@
                                                  /*IdentifierInfo=*/0,
                                                  ArgType, VarDecl::None, 0);
     CopyConstructor->setParams(Context, &FromParam, 1);
-    ClassDecl->addDecl(Context, CopyConstructor);
+    ClassDecl->addDecl(CopyConstructor);
   }
 
   if (!ClassDecl->hasUserDeclaredCopyAssignment()) {
@@ -1191,8 +1190,8 @@
     //          type M (or array thereof), each such class type has a copy
     //          assignment operator whose parameter is of type const M&,
     //          const volatile M& or M.
-    for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
-         HasConstCopyAssignment && Field != ClassDecl->field_end(Context);
+    for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin();
+         HasConstCopyAssignment && Field != ClassDecl->field_end();
          ++Field) {
       QualType FieldType = (*Field)->getType();
       if (const ArrayType *Array = Context.getAsArrayType(FieldType))
@@ -1236,7 +1235,7 @@
 
     // Don't call addedAssignmentOperator. There is no way to distinguish an
     // implicit from an explicit assignment operator.
-    ClassDecl->addDecl(Context, CopyAssignment);
+    ClassDecl->addDecl(CopyAssignment);
   }
 
   if (!ClassDecl->hasUserDeclaredDestructor()) {
@@ -1255,7 +1254,7 @@
                                   /*isImplicitlyDeclared=*/true);
     Destructor->setAccess(AS_public);
     Destructor->setImplicit();
-    ClassDecl->addDecl(Context, Destructor);
+    ClassDecl->addDecl(Destructor);
   }
 }
 
@@ -1798,7 +1797,7 @@
   // or translation unit scope. We add UsingDirectiveDecls, into
   // it's lookup structure.
   if (DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity()))
-    Ctx->addDecl(Context, UDir);
+    Ctx->addDecl(UDir);
   else
     // Otherwise it is block-sope. using-directives will affect lookup
     // only to the end of scope.
@@ -1899,7 +1898,7 @@
                                (NestedNameSpecifier *)SS.getScopeRep(),
                                IdentLoc, R);
   
-  CurContext->addDecl(Context, AliasDecl);
+  CurContext->addDecl(AliasDecl);
   return DeclPtrTy::make(AliasDecl);
 }
 
@@ -1935,8 +1934,8 @@
       }
     }
   }
-  for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
-       Field != ClassDecl->field_end(Context);
+  for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin();
+       Field != ClassDecl->field_end();
        ++Field) {
     QualType FieldType = Context.getCanonicalType((*Field)->getType());
     if (const ArrayType *Array = Context.getAsArrayType(FieldType))
@@ -2004,8 +2003,8 @@
     }
   }
   
-  for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
-       Field != ClassDecl->field_end(Context);
+  for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin();
+       Field != ClassDecl->field_end();
        ++Field) {
     QualType FieldType = Context.getCanonicalType((*Field)->getType());
     if (const ArrayType *Array = Context.getAsArrayType(FieldType))
@@ -2052,8 +2051,8 @@
           getAssignOperatorMethod(MethodDecl->getParamDecl(0), BaseClassDecl))
       MarkDeclarationReferenced(CurrentLocation, BaseAssignOpMethod);
   }
-  for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
-       Field != ClassDecl->field_end(Context);
+  for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin();
+       Field != ClassDecl->field_end();
        ++Field) {
     QualType FieldType = Context.getCanonicalType((*Field)->getType());
     if (const ArrayType *Array = Context.getAsArrayType(FieldType))
@@ -2139,9 +2138,9 @@
         BaseClassDecl->getCopyConstructor(Context, TypeQuals))
       MarkDeclarationReferenced(CurrentLocation, BaseCopyCtor);
   }
-  for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
-       Field != ClassDecl->field_end(Context);
-       ++Field) {
+  for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
+                                  FieldEnd = ClassDecl->field_end();
+       Field != FieldEnd; ++Field) {
     QualType FieldType = Context.getCanonicalType((*Field)->getType());
     if (const ArrayType *Array = Context.getAsArrayType(FieldType))
       FieldType = Array->getElementType();
@@ -2308,7 +2307,7 @@
     = Context.DeclarationNames.getCXXConstructorName(
                        Context.getCanonicalType(ClassType.getUnqualifiedType()));
   DeclContext::lookup_const_iterator Con, ConEnd;
-  for (llvm::tie(Con, ConEnd) = ClassDecl->lookup(Context, ConstructorName);
+  for (llvm::tie(Con, ConEnd) = ClassDecl->lookup(ConstructorName);
        Con != ConEnd; ++Con) {
     CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
     if ((Kind == IK_Direct) ||
@@ -2918,7 +2917,7 @@
   LinkageSpecDecl *D = LinkageSpecDecl::Create(Context, CurContext,
                                                LangLoc, Language, 
                                                LBraceLoc.isValid());
-  CurContext->addDecl(Context, D);
+  CurContext->addDecl(D);
   PushDeclContext(S, D);
   return DeclPtrTy::make(D);
 }
@@ -3032,7 +3031,7 @@
   if (II)
     PushOnScopeChains(ExDecl, S);
   else
-    CurContext->addDecl(Context, ExDecl);
+    CurContext->addDecl(ExDecl);
 
   ProcessDeclAttributes(S, ExDecl, D);
   return DeclPtrTy::make(ExDecl);
@@ -3066,7 +3065,7 @@
   Decl *Decl = StaticAssertDecl::Create(Context, CurContext, AssertLoc, 
                                         AssertExpr, AssertMessage);
   
-  CurContext->addDecl(Context, Decl);
+  CurContext->addDecl(Decl);
   return DeclPtrTy::make(Decl);
 }