Cleanup DeclContext::addDecl and DeclContext::insert interface, from Piotr Rak

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62122 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 6aeda8b..9b419e5 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -106,7 +106,7 @@
   // found later. Declarations without a context won't be inserted
   // into any context.
   if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D))
-    CurContext->addDecl(Context, SD);
+    CurContext->addDecl(SD);
 
   // C++ [basic.scope]p4:
   //   -- exactly one declaration shall declare a class name or
@@ -931,7 +931,7 @@
         //   definition, the members of the anonymous union are
         //   considered to have been defined in the scope in which the
         //   anonymous union is declared.
-        Owner->insert(Context, *F);
+        Owner->insert(*F);
         S->AddDecl(*F);
         IdResolver.AddDecl(*F);
       }
@@ -1090,7 +1090,7 @@
   // Add the anonymous struct/union object to the current
   // context. We'll be referencing this object when we refer to one of
   // its members.
-  Owner->addDecl(Context, Anon);
+  Owner->addDecl(Anon);
 
   // Inject the members of the anonymous struct/union into the owning
   // context and into the identifier resolver chain for name lookup
@@ -3126,7 +3126,7 @@
     } else 
       PushOnScopeChains(New, S);
   } else {
-    LexicalContext->addDecl(Context, New);
+    LexicalContext->addDecl(New);
   }
 
   return New;
@@ -3296,7 +3296,7 @@
   if (II) {
     PushOnScopeChains(NewFD, S);
   } else
-    Record->addDecl(Context, NewFD);
+    Record->addDecl(NewFD);
 
   return NewFD;
 }
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index dcd3789..d7cef91 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -797,7 +797,7 @@
                                  /*isImplicitlyDeclared=*/true);
     DefaultCon->setAccess(AS_public);
     DefaultCon->setImplicit();
-    ClassDecl->addDecl(Context, DefaultCon);
+    ClassDecl->addDecl(DefaultCon);
 
     // Notify the class that we've added a constructor.
     ClassDecl->addedConstructor(Context, DefaultCon);
@@ -878,7 +878,7 @@
     CopyConstructor->setParams(&FromParam, 1);
 
     ClassDecl->addedConstructor(Context, CopyConstructor);
-    ClassDecl->addDecl(Context, CopyConstructor);
+    ClassDecl->addDecl(CopyConstructor);
   }
 
   if (!ClassDecl->hasUserDeclaredCopyAssignment()) {
@@ -956,7 +956,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()) {
@@ -975,7 +975,7 @@
                                   /*isImplicitlyDeclared=*/true);
     Destructor->setAccess(AS_public);
     Destructor->setImplicit();
-    ClassDecl->addDecl(Context, Destructor);
+    ClassDecl->addDecl(Destructor);
   }
 }
 
@@ -2123,7 +2123,7 @@
   LinkageSpecDecl *D = LinkageSpecDecl::Create(Context, CurContext,
                                                LangLoc, Language, 
                                                LBraceLoc.isValid());
-  CurContext->addDecl(Context, D);
+  CurContext->addDecl(D);
   PushDeclContext(S, D);
   return D;
 }
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index afcf456..f6a245a 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -100,7 +100,7 @@
   
     ObjCInterfaceDecls[ClassName] = IDecl;
     // FIXME: PushOnScopeChains
-    CurContext->addDecl(Context, IDecl);
+    CurContext->addDecl(IDecl);
     // Remember that this needs to be removed when the scope is popped.
     TUScope->AddDecl(IDecl);
   }
@@ -185,7 +185,7 @@
   ObjCAliasDecls[AliasName] = AliasDecl;
 
   // FIXME: PushOnScopeChains?
-  CurContext->addDecl(Context, AliasDecl);
+  CurContext->addDecl(AliasDecl);
   if (!CheckObjCDeclScope(AliasDecl))
     TUScope->AddDecl(AliasDecl);
 
@@ -219,7 +219,7 @@
     PDecl = ObjCProtocolDecl::Create(Context, CurContext, 
                                      AtProtoInterfaceLoc,ProtocolName);
     // FIXME: PushOnScopeChains?
-    CurContext->addDecl(Context, PDecl);
+    CurContext->addDecl(PDecl);
     PDecl->setForwardDecl(false);
     ObjCProtocols[ProtocolName] = PDecl;
   }
@@ -444,7 +444,7 @@
       PDecl = ObjCProtocolDecl::Create(Context, CurContext, 
                                        IdentList[i].second, Ident);
       // FIXME: PushOnScopeChains?
-      CurContext->addDecl(Context, PDecl);
+      CurContext->addDecl(PDecl);
     }
     if (attrList)
       ProcessDeclAttributeList(PDecl, attrList);
@@ -454,7 +454,7 @@
   ObjCForwardProtocolDecl *PDecl = 
     ObjCForwardProtocolDecl::Create(Context, CurContext, AtProtocolLoc,
                                     &Protocols[0], Protocols.size());
-  CurContext->addDecl(Context, PDecl);
+  CurContext->addDecl(PDecl);
   CheckObjCDeclScope(PDecl);
   return PDecl;
 }
@@ -472,7 +472,7 @@
   ObjCCategoryDecl *CDecl = 
     ObjCCategoryDecl::Create(Context, CurContext, AtInterfaceLoc, CategoryName);
   // FIXME: PushOnScopeChains?
-  CurContext->addDecl(Context, CDecl);
+  CurContext->addDecl(CDecl);
   CDecl->setClassInterface(IDecl);
   
   /// Check that class of this category is already completely declared.
@@ -519,7 +519,7 @@
     Diag(ClassLoc, diag::err_undef_interface) << ClassName;
 
   // FIXME: PushOnScopeChains?
-  CurContext->addDecl(Context, CDecl);
+  CurContext->addDecl(CDecl);
 
   /// TODO: Check that CatName, category name, is not used in another
   // implementation.
@@ -585,7 +585,7 @@
     IDecl->setLocEnd(ClassLoc);
     
     // FIXME: PushOnScopeChains?
-    CurContext->addDecl(Context, IDecl);
+    CurContext->addDecl(IDecl);
     // Remember that this needs to be removed when the scope is popped.
     TUScope->AddDecl(IDecl);
   }
@@ -595,7 +595,7 @@
                                    ClassName, IDecl, SDecl);
   
   // FIXME: PushOnScopeChains?
-  CurContext->addDecl(Context, IMPDecl);
+  CurContext->addDecl(IMPDecl);
 
   if (CheckObjCDeclScope(IMPDecl))
     return IMPDecl;
@@ -938,7 +938,7 @@
       ObjCInterfaceDecls[IdentList[i]] = IDecl;
 
       // FIXME: PushOnScopeChains?
-      CurContext->addDecl(Context, IDecl);
+      CurContext->addDecl(IDecl);
       // Remember that this needs to be removed when the scope is popped.
       TUScope->AddDecl(IDecl);
     }
@@ -949,7 +949,7 @@
   ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc,
                                                &Interfaces[0],
                                                Interfaces.size());
-  CurContext->addDecl(Context, CDecl);
+  CurContext->addDecl(CDecl);
   CheckObjCDeclScope(CDecl);
   return CDecl;  
 }
@@ -1114,7 +1114,7 @@
                               ObjCPropertyDecl::Optional) ? 
                              ObjCMethodDecl::Optional : 
                              ObjCMethodDecl::Required);
-    CD->addDecl(Context, GetterMethod);
+    CD->addDecl(GetterMethod);
   } else
     // A user declared getter will be synthesize when @synthesize of
     // the property with the same name is seen in the @implementation
@@ -1145,7 +1145,7 @@
                                                   VarDecl::None,
                                                   0, 0);
       SetterMethod->setMethodParams(&Argument, 1);
-      CD->addDecl(Context, SetterMethod);
+      CD->addDecl(SetterMethod);
     } else
       // A user declared setter will be synthesize when @synthesize of
       // the property with the same name is seen in the @implementation
@@ -1210,7 +1210,7 @@
             << Method->getDeclName();
           Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
       } else {
-        DC->addDecl(Context, Method);
+        DC->addDecl(Method);
         InsMap[Method->getSelector()] = Method;
         /// The following allows us to typecheck messages to "id".
         AddInstanceMethodToGlobalPool(Method);
@@ -1227,7 +1227,7 @@
           << Method->getDeclName();
         Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
       } else {
-        DC->addDecl(Context, Method);
+        DC->addDecl(Method);
         ClsMap[Method->getSelector()] = Method;
         /// The following allows us to typecheck messages to "Class".
         AddFactoryMethodToGlobalPool(Method);
@@ -1567,7 +1567,7 @@
   assert(DC && "ClassDecl is not a DeclContext");
   ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC, AtLoc, 
                                                      FD.D.getIdentifier(), T);
-  DC->addDecl(Context, PDecl);
+  DC->addDecl(PDecl);
 
   // Regardless of setter/getter attribute, we save the default getter/setter
   // selector names in anticipation of declaration of setter/getter methods.
@@ -1707,7 +1707,7 @@
                                   ObjCPropertyImplDecl::Synthesize 
                                   : ObjCPropertyImplDecl::Dynamic),
                                  Ivar);
-  CurContext->addDecl(Context, PIDecl);
+  CurContext->addDecl(PIDecl);
   if (IC) {
     if (Synthesize)
       if (ObjCPropertyImplDecl *PPIDecl = 
@@ -1801,7 +1801,7 @@
     if (getLangOptions().CPlusPlus)
       PushOnScopeChains(cast<FieldDecl>(FD), S);
     else if (RecordDecl *Record = dyn_cast<RecordDecl>((Decl*)TagD))
-      Record->addDecl(Context, FD);
+      Record->addDecl(FD);
   }
 }
 
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 111dca4..99e00a7 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -540,7 +540,7 @@
   // FIXME: Also add this declaration to the IdentifierResolver, but
   // make sure it is at the end of the chain to coincide with the
   // global scope.
-  ((DeclContext *)TUScope->getEntity())->addDecl(Context, Alloc);
+  ((DeclContext *)TUScope->getEntity())->addDecl(Alloc);
 }
 
 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in: