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/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index c564576..b7c65a5 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -822,7 +822,7 @@
         std::string RecName = clsDeclared->getIdentifier()->getName();
         RecName += "_IMPL";
         IdentifierInfo *II = &Context->Idents.get(RecName.c_str());
-        RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, 
+        RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, NULL,
                                             SourceLocation(), II, 0);
         assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
         QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -1581,7 +1581,8 @@
   QualType getFuncType = Context->getFunctionType(Context->getObjCSelType(),
                                                    &ArgTys[0], ArgTys.size(),
                                                    false /*isVariadic*/);
-  SelGetUidFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
+  SelGetUidFunctionDecl = FunctionDecl::Create(*Context, NULL,
+                                           SourceLocation(), 
                                            SelGetUidIdent, getFuncType,
                                            FunctionDecl::Extern, false, 0);
 }
@@ -1595,7 +1596,8 @@
   QualType getFuncType = Context->getFunctionType(Context->getObjCProtoType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   false /*isVariadic*/);
-  GetProtocolFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
+  GetProtocolFunctionDecl = FunctionDecl::Create(*Context, NULL,
+                                             SourceLocation(), 
                                              SelGetProtoIdent, getFuncType,
                                              FunctionDecl::Extern, false, 0);
 }
@@ -1622,7 +1624,8 @@
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   false);
-  SuperContructorFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
+  SuperContructorFunctionDecl = FunctionDecl::Create(*Context, NULL,
+                                         SourceLocation(), 
                                          msgSendIdent, msgSendType,
                                          FunctionDecl::Extern, false, 0);
 }
@@ -1640,7 +1643,8 @@
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
+  MsgSendFunctionDecl = FunctionDecl::Create(*Context, NULL,
+                                         SourceLocation(),
                                          msgSendIdent, msgSendType,
                                          FunctionDecl::Extern, false, 0);
 }
@@ -1649,7 +1653,8 @@
 void RewriteTest::SynthMsgSendSuperFunctionDecl() {
   IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper");
   llvm::SmallVector<QualType, 16> ArgTys;
-  RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, SourceLocation(),
+  RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, NULL,
+                                      SourceLocation(),
                                       &Context->Idents.get("objc_super"), 0);
   QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
   assert(!argT.isNull() && "Can't build 'struct objc_super *' type");
@@ -1660,7 +1665,8 @@
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
+  MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, NULL,
+                                              SourceLocation(), 
                                               msgSendIdent, msgSendType,
                                               FunctionDecl::Extern, false, 0);
 }
@@ -1678,7 +1684,8 @@
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
+  MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, NULL,
+                                         SourceLocation(), 
                                          msgSendIdent, msgSendType,
                                          FunctionDecl::Extern, false, 0);
 }
@@ -1689,7 +1696,8 @@
   IdentifierInfo *msgSendIdent = 
     &Context->Idents.get("objc_msgSendSuper_stret");
   llvm::SmallVector<QualType, 16> ArgTys;
-  RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, SourceLocation(),
+  RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, NULL,
+                                      SourceLocation(),
                                       &Context->Idents.get("objc_super"), 0);
   QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
   assert(!argT.isNull() && "Can't build 'struct objc_super *' type");
@@ -1700,7 +1708,7 @@
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context,
+  MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, NULL,
                                                        SourceLocation(), 
                                               msgSendIdent, msgSendType,
                                               FunctionDecl::Extern, false, 0);
@@ -1719,7 +1727,8 @@
   QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
                                                   &ArgTys[0], ArgTys.size(),
                                                   true /*isVariadic*/);
-  MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
+  MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, NULL,
+                                              SourceLocation(), 
                                               msgSendIdent, msgSendType,
                                               FunctionDecl::Extern, false, 0);
 }
@@ -1733,7 +1742,8 @@
   QualType getClassType = Context->getFunctionType(Context->getObjCIdType(),
                                                    &ArgTys[0], ArgTys.size(),
                                                    false /*isVariadic*/);
-  GetClassFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
+  GetClassFunctionDecl = FunctionDecl::Create(*Context, NULL,
+                                          SourceLocation(), 
                                           getClassIdent, getClassType,
                                           FunctionDecl::Extern, false, 0);
 }
@@ -1747,7 +1757,8 @@
   QualType getClassType = Context->getFunctionType(Context->getObjCIdType(),
                                                    &ArgTys[0], ArgTys.size(),
                                                    false /*isVariadic*/);
-  GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, SourceLocation(), 
+  GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, NULL,
+                                              SourceLocation(), 
                                               getClassIdent, getClassType,
                                               FunctionDecl::Extern, false, 0);
 }
@@ -1769,7 +1780,7 @@
   // The minus 2 removes the begin/end double quotes.
   Preamble += utostr(prettyBuf.str().size()-2) + "};\n";
   
-  FileVarDecl *NewVD = FileVarDecl::Create(*Context, SourceLocation(), 
+  FileVarDecl *NewVD = FileVarDecl::Create(*Context, NULL, SourceLocation(), 
                                        &Context->Idents.get(S.c_str()), strType, 
                                        VarDecl::Static, NULL);
   DeclRefExpr *DRE = new DeclRefExpr(NewVD, strType, SourceLocation());
@@ -1817,7 +1828,7 @@
 // struct objc_super { struct objc_object *receiver; struct objc_class *super; };
 QualType RewriteTest::getSuperStructType() {
   if (!SuperStructDecl) {
-    SuperStructDecl = RecordDecl::Create(*Context, Decl::Struct,
+    SuperStructDecl = RecordDecl::Create(*Context, Decl::Struct, NULL,
                                          SourceLocation(), 
                                          &Context->Idents.get("objc_super"), 0);
     QualType FieldTypes[2];
@@ -1830,7 +1841,8 @@
     FieldDecl *FieldDecls[2];
   
     for (unsigned i = 0; i < 2; ++i)
-      FieldDecls[i] = FieldDecl::Create(*Context, SourceLocation(), 0, 
+      FieldDecls[i] = FieldDecl::Create(*Context, SuperStructDecl,
+                                        SourceLocation(), 0, 
                                         FieldTypes[i]);
   
     SuperStructDecl->defineBody(FieldDecls, 4);
@@ -1840,7 +1852,7 @@
 
 QualType RewriteTest::getConstantStringStructType() {
   if (!ConstantStringDecl) {
-    ConstantStringDecl = RecordDecl::Create(*Context, Decl::Struct,
+    ConstantStringDecl = RecordDecl::Create(*Context, Decl::Struct, NULL,
                                             SourceLocation(), 
                          &Context->Idents.get("__NSConstantStringImpl"), 0);
     QualType FieldTypes[4];
@@ -1857,7 +1869,8 @@
     FieldDecl *FieldDecls[4];
   
     for (unsigned i = 0; i < 4; ++i)
-      FieldDecls[i] = FieldDecl::Create(*Context, SourceLocation(), 0,
+      FieldDecls[i] = FieldDecl::Create(*Context, ConstantStringDecl,
+                                        SourceLocation(), 0,
                                         FieldTypes[i]);
   
     ConstantStringDecl->defineBody(FieldDecls, 4);