This patch contains these changes:

-Renamed ContextDecl -> DeclContext
-Removed DeclContext pointer from FieldDecl
-EnumDecl inherits from DeclContext, instead of TagDecl

Patch by Argiris Kirtzidis!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49261 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 9e51b29..0708c70 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1131,8 +1131,7 @@
     FieldDecl *FieldDecls[4];
   
     for (unsigned i = 0; i < 4; ++i)
-      FieldDecls[i] = FieldDecl::Create(*this, CFConstantStringTypeDecl,
-                                        SourceLocation(), 0,
+      FieldDecls[i] = FieldDecl::Create(*this, SourceLocation(), 0,
                                         FieldTypes[i]);
   
     CFConstantStringTypeDecl->defineBody(FieldDecls, 4);
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index b1a2499..d97e0b3 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -204,7 +204,7 @@
 // Decl Allocation/Deallocation Method Implementations
 //===----------------------------------------------------------------------===//
 
-BlockVarDecl *BlockVarDecl::Create(ASTContext &C, ContextDecl *CD,
+BlockVarDecl *BlockVarDecl::Create(ASTContext &C, DeclContext *CD,
                                    SourceLocation L,
                                    IdentifierInfo *Id, QualType T,
                                    StorageClass S, ScopedDecl *PrevDecl) {
@@ -213,7 +213,7 @@
 }
 
 
-FileVarDecl *FileVarDecl::Create(ASTContext &C, ContextDecl *CD,
+FileVarDecl *FileVarDecl::Create(ASTContext &C, DeclContext *CD,
                                  SourceLocation L, IdentifierInfo *Id,
                                  QualType T, StorageClass S,
                                  ScopedDecl *PrevDecl) {
@@ -221,7 +221,7 @@
   return new (Mem) FileVarDecl(CD, L, Id, T, S, PrevDecl);
 }
 
-ParmVarDecl *ParmVarDecl::Create(ASTContext &C, ContextDecl *CD,
+ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *CD,
                                  SourceLocation L, IdentifierInfo *Id,
                                  QualType T, StorageClass S,
                                  ScopedDecl *PrevDecl) {
@@ -229,7 +229,7 @@
   return new (Mem) ParmVarDecl(CD, L, Id, T, S, PrevDecl);
 }
 
-FunctionDecl *FunctionDecl::Create(ASTContext &C, ContextDecl *CD,
+FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *CD,
                                    SourceLocation L, 
                                    IdentifierInfo *Id, QualType T, 
                                    StorageClass S, bool isInline, 
@@ -238,10 +238,10 @@
   return new (Mem) FunctionDecl(CD, L, Id, T, S, isInline, PrevDecl);
 }
 
-FieldDecl *FieldDecl::Create(ASTContext &C, RecordDecl *CD, SourceLocation L,
+FieldDecl *FieldDecl::Create(ASTContext &C, SourceLocation L,
                              IdentifierInfo *Id, QualType T, Expr *BW) {
   void *Mem = C.getAllocator().Allocate<FieldDecl>();
-  return new (Mem) FieldDecl(CD, L, Id, T, BW);
+  return new (Mem) FieldDecl(L, Id, T, BW);
 }
 
 
@@ -254,7 +254,7 @@
   return new (Mem) EnumConstantDecl(CD, L, Id, T, E, V, PrevDecl);
 }
 
-TypedefDecl *TypedefDecl::Create(ASTContext &C, ContextDecl *CD,
+TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *CD,
                                  SourceLocation L,
                                  IdentifierInfo *Id, QualType T,
                                  ScopedDecl *PD) {
@@ -262,14 +262,14 @@
   return new (Mem) TypedefDecl(CD, L, Id, T, PD);
 }
 
-EnumDecl *EnumDecl::Create(ASTContext &C, ContextDecl *CD, SourceLocation L,
+EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *CD, SourceLocation L,
                            IdentifierInfo *Id,
                            ScopedDecl *PrevDecl) {
   void *Mem = C.getAllocator().Allocate<EnumDecl>();
   return new (Mem) EnumDecl(CD, L, Id, PrevDecl);
 }
 
-RecordDecl *RecordDecl::Create(ASTContext &C, Kind DK, ContextDecl *CD,
+RecordDecl *RecordDecl::Create(ASTContext &C, Kind DK, DeclContext *CD,
                                SourceLocation L, IdentifierInfo *Id,
                                ScopedDecl *PrevDecl) {
   void *Mem = C.getAllocator().Allocate<RecordDecl>();
@@ -330,22 +330,22 @@
 }
 
 //===----------------------------------------------------------------------===//
-// ContextDecl Implementation
+// DeclContext Implementation
 //===----------------------------------------------------------------------===//
 
-ContextDecl *ContextDecl::getParent() const {
+DeclContext *DeclContext::getParent() const {
   if (ScopedDecl *SD = dyn_cast<ScopedDecl>(this))
-    return SD->getContextDecl();
+    return SD->getDeclContext();
   else
     return NULL;
 }
 
-Decl *ContextDecl::ToDecl (const ContextDecl *D) {
+Decl *DeclContext::ToDecl (const DeclContext *D) {
   return CastTo<Decl>(D);
 }
 
-ContextDecl *ContextDecl::FromDecl (const Decl *D) {
-  return CastTo<ContextDecl>(D);
+DeclContext *DeclContext::FromDecl (const Decl *D) {
+  return CastTo<DeclContext>(D);
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 5671dbe..a8ef5aa 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -45,11 +45,10 @@
                                      isInternal);
 }
 
-ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCInterfaceDecl *CD,
-                                   SourceLocation L,
+ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L,
                                    IdentifierInfo *Id, QualType T) {
   void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>();
-  return new (Mem) ObjCIvarDecl(CD, L, Id, T);
+  return new (Mem) ObjCIvarDecl(L, Id, T);
 }
 
 ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C,
diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index e6b3f93..a2e9ce1 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -106,7 +106,7 @@
 void ScopedDecl::EmitInRec(Serializer& S) const {
   NamedDecl::EmitInRec(S);
   S.EmitPtr(getNext());                     // From ScopedDecl.  
-  S.EmitPtr(cast_or_null<Decl>(getContextDecl()));  // From ScopedDecl.
+  S.EmitPtr(cast_or_null<Decl>(getDeclContext()));  // From ScopedDecl.
 }
 
 void ScopedDecl::ReadInRec(Deserializer& D) {
@@ -114,7 +114,7 @@
   D.ReadPtr(Next);                                  // From ScopedDecl.
   Decl *TmpD;
   D.ReadPtr(TmpD);                                  // From ScopedDecl.
-  CtxDecl = cast_or_null<ContextDecl>(TmpD);
+  CtxDecl = cast_or_null<DeclContext>(TmpD);
 }
     
   //===------------------------------------------------------------===//
@@ -306,7 +306,7 @@
 }
 
 FieldDecl* FieldDecl::CreateImpl(Deserializer& D) {
-  FieldDecl* decl = new FieldDecl(0, SourceLocation(), NULL, QualType(), 0);
+  FieldDecl* decl = new FieldDecl(SourceLocation(), NULL, QualType(), 0);
   decl->DeclType.ReadBackpatch(D);  
   decl->ReadInRec(D);
   decl->BitWidth = D.ReadOwnedPtr<Expr>();