aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AST/DeclSerialization.cpp70
-rw-r--r--include/clang/AST/Decl.h22
2 files changed, 88 insertions, 4 deletions
diff --git a/AST/DeclSerialization.cpp b/AST/DeclSerialization.cpp
index 3e2ce0fcc8..51c93fbd12 100644
--- a/AST/DeclSerialization.cpp
+++ b/AST/DeclSerialization.cpp
@@ -43,6 +43,12 @@ Decl* Decl::Create(Deserializer& D) {
case BlockVar:
return BlockVarDecl::CreateImpl(D);
+ case Enum:
+ return EnumDecl::CreateImpl(D);
+
+ case EnumConstant:
+ return EnumConstantDecl::CreateImpl(D);
+
case Field:
return FieldDecl::CreateImpl(D);
@@ -220,6 +226,64 @@ ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D) {
}
//===----------------------------------------------------------------------===//
+// EnumDecl Serialization.
+//===----------------------------------------------------------------------===//
+
+void EnumDecl::EmitImpl(Serializer& S) const {
+ ScopedDecl::EmitInRec(S);
+ S.EmitBool(isDefinition());
+ S.Emit(IntegerType);
+ S.BatchEmitOwnedPtrs(ElementList,getNextDeclarator());
+}
+
+EnumDecl* EnumDecl::CreateImpl(Deserializer& D) {
+ EnumDecl* decl = new EnumDecl(SourceLocation(),NULL,NULL);
+
+ decl->ScopedDecl::ReadInRec(D);
+ decl->setDefinition(D.ReadBool());
+ decl->IntegerType = QualType::ReadVal(D);
+
+ Decl* next_declarator;
+ Decl* Elist;
+
+ D.BatchReadOwnedPtrs(Elist,next_declarator);
+
+ decl->ElementList = cast_or_null<EnumConstantDecl>(Elist);
+ decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
+
+ return decl;
+}
+
+//===----------------------------------------------------------------------===//
+// EnumConstantDecl Serialization.
+//===----------------------------------------------------------------------===//
+
+void EnumConstantDecl::EmitImpl(Serializer& S) const {
+ S.Emit(Val);
+ ValueDecl::EmitInRec(S);
+ S.BatchEmitOwnedPtrs(getNextDeclarator(),Init);
+}
+
+EnumConstantDecl* EnumConstantDecl::CreateImpl(Deserializer& D) {
+ llvm::APSInt val(0);
+ D.Read(val);
+
+ EnumConstantDecl* decl =
+ new EnumConstantDecl(SourceLocation(),NULL,QualType(),NULL,
+ val,NULL);
+
+ decl->ValueDecl::ReadInRec(D);
+
+ Decl* next_declarator;
+
+ D.BatchReadOwnedPtrs(next_declarator,decl->Init);
+
+ decl->setNextDeclarator(cast<ScopedDecl>(next_declarator));
+
+ return decl;
+}
+
+//===----------------------------------------------------------------------===//
// FieldDecl Serialization.
//===----------------------------------------------------------------------===//
@@ -295,8 +359,9 @@ FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D) {
// RecordDecl Serialization.
//===----------------------------------------------------------------------===//
-void RecordDecl::EmitImpl(llvm::Serializer& S) const {
+void RecordDecl::EmitImpl(Serializer& S) const {
ScopedDecl::EmitInRec(S);
+ S.EmitBool(isDefinition());
S.EmitBool(hasFlexibleArrayMember());
S.EmitSInt(getNumMembers());
if (getNumMembers() > 0) {
@@ -310,8 +375,9 @@ void RecordDecl::EmitImpl(llvm::Serializer& S) const {
RecordDecl* RecordDecl::CreateImpl(Decl::Kind DK, Deserializer& D) {
RecordDecl* decl = new RecordDecl(DK,SourceLocation(),NULL,NULL);
-
+
decl->ScopedDecl::ReadInRec(D);
+ decl->setDefinition(D.ReadBool());
decl->setHasFlexibleArrayMember(D.ReadBool());
decl->NumMembers = D.ReadSInt();
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 5930d96711..fa1b3a7ad9 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -540,6 +540,15 @@ public:
static bool classof(const EnumConstantDecl *D) { return true; }
friend class StmtIteratorBase;
+
+protected:
+ /// EmitImpl - Serialize this EnumConstantDecl. Called by Decl::Emit.
+ virtual void EmitImpl(llvm::Serializer& S) const;
+
+ /// CreateImpl - Deserialize a EnumConstantDecl. Called by Decl::Create.
+ static EnumConstantDecl* CreateImpl(llvm::Deserializer& D);
+
+ friend Decl* Decl::Create(llvm::Deserializer& D);
};
@@ -663,6 +672,15 @@ public:
static bool classof(const Decl *D) { return D->getKind() == Enum; }
static bool classof(const EnumDecl *D) { return true; }
+
+protected:
+ /// EmitImpl - Serialize this EnumDecl. Called by Decl::Emit.
+ virtual void EmitImpl(llvm::Serializer& S) const;
+
+ /// CreateImpl - Deserialize a EnumDecl. Called by Decl::Create.
+ static EnumDecl* CreateImpl(llvm::Deserializer& D);
+
+ friend Decl* Decl::Create(llvm::Deserializer& D);
};
@@ -712,10 +730,10 @@ public:
static bool classof(const RecordDecl *D) { return true; }
protected:
- /// EmitImpl - Serialize this TypedefDecl. Called by Decl::Emit.
+ /// EmitImpl - Serialize this RecordDecl. Called by Decl::Emit.
virtual void EmitImpl(llvm::Serializer& S) const;
- /// CreateImpl - Deserialize a TypedefDecl. Called by Decl::Create.
+ /// CreateImpl - Deserialize a RecordDecl. Called by Decl::Create.
static RecordDecl* CreateImpl(Kind DK, llvm::Deserializer& D);
friend Decl* Decl::Create(llvm::Deserializer& D);