Introduce ContextDecl, patch by Argiris Kirtzidis!

-Added ContextDecl (no TranslationUnitDecl)
-ScopedDecl class has a ContextDecl member
-FieldDecl class has a ContextDecl member, so that a Field or a ObjCIvar can be traced back to their RecordDecl/ObjCInterfaceDecl easily
-FunctionDecl, ObjCMethodDecl, TagDecl, ObjCInterfaceDecl inherit from ContextDecl. With TagDecl as ContextDecl, enum constants have a EnumDecl as their context.
-Moved Decl class to a "DeclBase.h" along with ContextDecl class
-CurContext is handled by Sema




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49208 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 69a1022..6b9b9e2 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -33,6 +33,7 @@
   
   // Allow all of Sema to see that we are entering a method definition.
   CurMethodDecl = MDecl;
+  PushContextDecl(MDecl);
 
   // Create Decl objects for each parameter, entrring them in the scope for
   // binding to their use.
@@ -813,23 +814,6 @@
     Diag(MethodLoc, diag::error_missing_method_context);
     return 0;
   }
-  llvm::SmallVector<ParmVarDecl*, 16> Params;
-  
-  for (unsigned i = 0; i < Sel.getNumArgs(); i++) {
-    // FIXME: arg->AttrList must be stored too!
-    QualType argType;
-    
-    if (ArgTypes[i])
-      argType = QualType::getFromOpaquePtr(ArgTypes[i]);
-    else
-      argType = Context.getObjCIdType();
-    ParmVarDecl* Param = ParmVarDecl::Create(Context, SourceLocation(/*FIXME*/),
-                                             ArgNames[i], argType,
-                                             VarDecl::None, 0);
-    Param->setObjCDeclQualifier(
-      CvtQTToAstBitMask(ArgQT[i].getObjCDeclQualifier()));
-    Params.push_back(Param);
-  }
   QualType resultDeclType;
   
   if (ReturnType)
@@ -845,6 +829,25 @@
                            ObjCMethodDecl::Optional : 
                            ObjCMethodDecl::Required);
   
+  llvm::SmallVector<ParmVarDecl*, 16> Params;
+  
+  for (unsigned i = 0; i < Sel.getNumArgs(); i++) {
+    // FIXME: arg->AttrList must be stored too!
+    QualType argType;
+    
+    if (ArgTypes[i])
+      argType = QualType::getFromOpaquePtr(ArgTypes[i]);
+    else
+      argType = Context.getObjCIdType();
+    ParmVarDecl* Param = ParmVarDecl::Create(Context, ObjCMethod,
+                                             SourceLocation(/*FIXME*/),
+                                             ArgNames[i], argType,
+                                             VarDecl::None, 0);
+    Param->setObjCDeclQualifier(
+      CvtQTToAstBitMask(ArgQT[i].getObjCDeclQualifier()));
+    Params.push_back(Param);
+  }
+
   ObjCMethod->setMethodParams(&Params[0], Sel.getNumArgs());
   ObjCMethod->setObjCDeclQualifier(
     CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier()));