]> granicus.if.org Git - clang/commitdiff
Implemented serialization of EnumDecl and EnumConstantDecl.
authorTed Kremenek <kremenek@apple.com>
Wed, 14 Nov 2007 18:12:19 +0000 (18:12 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 14 Nov 2007 18:12:19 +0000 (18:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44127 91177308-0d34-0410-b5e6-96231b3b80d8

AST/DeclSerialization.cpp
include/clang/AST/Decl.h

index 3e2ce0fcc8c74c48ad7ba738b90cc862e4a8a17d..51c93fbd12d2b9e5753893e6fa1121f84f68771f 100644 (file)
@@ -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);
       
@@ -219,6 +225,64 @@ ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D) {
   return decl;
 }
 
+//===----------------------------------------------------------------------===//
+//      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();
   
index 5930d967113216eea6fbed137113f93d12c4446a..fa1b3a7ad97881702ae5ccbb7b77b8a8f73a92ed 100644 (file)
@@ -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);