[cfe-commits] r44127 - in /cfe/trunk: AST/DeclSerialization.cpp include/clang/AST/Decl.h

Ted Kremenek kremenek at apple.com
Wed Nov 14 10:12:21 PST 2007


Author: kremenek
Date: Wed Nov 14 12:12:19 2007
New Revision: 44127

URL: http://llvm.org/viewvc/llvm-project?rev=44127&view=rev
Log:
Implemented serialization of EnumDecl and EnumConstantDecl.

Modified:
    cfe/trunk/AST/DeclSerialization.cpp
    cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/AST/DeclSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/DeclSerialization.cpp?rev=44127&r1=44126&r2=44127&view=diff

==============================================================================
--- cfe/trunk/AST/DeclSerialization.cpp (original)
+++ cfe/trunk/AST/DeclSerialization.cpp Wed Nov 14 12:12:19 2007
@@ -43,6 +43,12 @@
     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 @@
 }
 
 //===----------------------------------------------------------------------===//
+//      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 @@
 //      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 @@
 
 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();
   

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=44127&r1=44126&r2=44127&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Nov 14 12:12:19 2007
@@ -540,6 +540,15 @@
   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 @@
   
   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 @@
   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);





More information about the cfe-commits mailing list