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/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index fe2ccef..3a79b9e 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -39,7 +39,7 @@
default:
assert (false && "Not implemented.");
break;
-
+
case BlockVar:
return BlockVarDecl::CreateImpl(D);
@@ -106,11 +106,15 @@
void ScopedDecl::EmitInRec(Serializer& S) const {
NamedDecl::EmitInRec(S);
S.EmitPtr(getNext()); // From ScopedDecl.
+ S.EmitPtr(cast_or_null<Decl>(getContext())); // From ScopedDecl.
}
void ScopedDecl::ReadInRec(Deserializer& D) {
NamedDecl::ReadInRec(D);
D.ReadPtr(Next); // From ScopedDecl.
+ Decl *TmpD;
+ D.ReadPtr(TmpD); // From ScopedDecl.
+ CtxDecl = cast_or_null<ContextDecl>(TmpD);
}
//===------------------------------------------------------------===//
@@ -194,7 +198,7 @@
BlockVarDecl* BlockVarDecl::CreateImpl(Deserializer& D) {
BlockVarDecl* decl =
- new BlockVarDecl(SourceLocation(),NULL,QualType(),None,NULL);
+ new BlockVarDecl(0, SourceLocation(),NULL,QualType(),None,NULL);
decl->VarDecl::ReadImpl(D);
@@ -207,7 +211,7 @@
FileVarDecl* FileVarDecl::CreateImpl(Deserializer& D) {
FileVarDecl* decl =
- new FileVarDecl(SourceLocation(),NULL,QualType(),None,NULL);
+ new FileVarDecl(0, SourceLocation(),NULL,QualType(),None,NULL);
decl->VarDecl::ReadImpl(D);
@@ -225,7 +229,7 @@
ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D) {
ParmVarDecl* decl =
- new ParmVarDecl(SourceLocation(),NULL,QualType(),None,NULL);
+ new ParmVarDecl(0, SourceLocation(),NULL,QualType(),None,NULL);
decl->VarDecl::ReadImpl(D);
decl->objcDeclQualifier = static_cast<ObjCDeclQualifier>(D.ReadInt());
@@ -245,7 +249,7 @@
}
EnumDecl* EnumDecl::CreateImpl(Deserializer& D) {
- EnumDecl* decl = new EnumDecl(SourceLocation(),NULL,NULL);
+ EnumDecl* decl = new EnumDecl(0, SourceLocation(),NULL,NULL);
decl->ScopedDecl::ReadInRec(D);
decl->setDefinition(D.ReadBool());
@@ -277,7 +281,7 @@
D.Read(val);
EnumConstantDecl* decl =
- new EnumConstantDecl(SourceLocation(),NULL,QualType(),NULL,
+ new EnumConstantDecl(0, SourceLocation(),NULL,QualType(),NULL,
val,NULL);
decl->ValueDecl::ReadInRec(D);
@@ -302,7 +306,7 @@
}
FieldDecl* FieldDecl::CreateImpl(Deserializer& D) {
- FieldDecl* decl = new FieldDecl(SourceLocation(), NULL, QualType(), 0);
+ FieldDecl* decl = new FieldDecl(0, SourceLocation(), NULL, QualType(), 0);
decl->DeclType.ReadBackpatch(D);
decl->ReadInRec(D);
decl->BitWidth = D.ReadOwnedPtr<Expr>();
@@ -338,7 +342,7 @@
bool IsInline = D.ReadBool();
FunctionDecl* decl =
- new FunctionDecl(SourceLocation(),NULL,QualType(),SClass, IsInline, 0);
+ new FunctionDecl(0, SourceLocation(),NULL,QualType(),SClass, IsInline, 0);
decl->ValueDecl::ReadInRec(D);
D.ReadPtr(decl->DeclChain);
@@ -382,7 +386,7 @@
}
RecordDecl* RecordDecl::CreateImpl(Decl::Kind DK, Deserializer& D) {
- RecordDecl* decl = new RecordDecl(DK,SourceLocation(),NULL,NULL);
+ RecordDecl* decl = new RecordDecl(DK,0,SourceLocation(),NULL,NULL);
decl->ScopedDecl::ReadInRec(D);
decl->setDefinition(D.ReadBool());
@@ -418,7 +422,7 @@
TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D) {
QualType T = QualType::ReadVal(D);
- TypedefDecl* decl = new TypedefDecl(SourceLocation(),NULL,T,NULL);
+ TypedefDecl* decl = new TypedefDecl(0, SourceLocation(),NULL,T,NULL);
decl->ScopedDecl::ReadInRec(D);
decl->ScopedDecl::ReadOutRec(D);