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

Ted Kremenek kremenek at apple.com
Mon Nov 12 16:15:40 PST 2007


Author: kremenek
Date: Mon Nov 12 18:15:39 2007
New Revision: 44033

URL: http://llvm.org/viewvc/llvm-project?rev=44033&view=rev
Log:
Restructured serialization code for decls to make it cleaner, easier to
understand, and batched the emission owned subobjects (using
BatchEmitOwnedPtr) to get a smaller output bitcode size.

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=44033&r1=44032&r2=44033&view=diff

==============================================================================
--- cfe/trunk/AST/DeclSerialization.cpp (original)
+++ cfe/trunk/AST/DeclSerialization.cpp Mon Nov 12 18:15:39 2007
@@ -16,39 +16,23 @@
 #include "llvm/Bitcode/Serialize.h"
 #include "llvm/Bitcode/Deserialize.h"
 
+using llvm::Serializer;
+using llvm::Deserializer;
+using llvm::SerializedPtrID;
+
 using namespace clang;
 
-void Decl::Emit(llvm::Serializer& S) const {
-  S.EmitInt(getKind());
+//===----------------------------------------------------------------------===//
+// Decl Serialization: Dispatch code to handle specialized decl types.
+//===----------------------------------------------------------------------===//
 
-  switch (getKind()) {
-    default:
-      assert (false && "Not implemented.");
-      break;
-      
-    case BlockVar:
-      cast<BlockVarDecl>(this)->Emit(S);
-      break;
-      
-    case FileVar:
-      cast<FileVarDecl>(this)->Emit(S);
-      break;
-      
-    case ParmVar:
-      cast<ParmVarDecl>(this)->Emit(S);
-      break;
-      
-    case Function:
-      cast<FunctionDecl>(this)->Emit(S);
-      break;
-      
-    case Typedef:
-      cast<TypedefDecl>(this)->Emit(S);
-      break;
-  }
+void Decl::Emit(Serializer& S) const {
+  S.EmitInt(getKind());
+  EmitImpl(S);
 }
 
-Decl* Decl::Materialize(llvm::Deserializer& D) {
+Decl* Decl::Create(Deserializer& D) {
+
   Kind k = static_cast<Kind>(D.ReadInt());
   
   switch (k) {
@@ -57,149 +41,239 @@
       break;
       
     case BlockVar:
-      return BlockVarDecl::Materialize(D);
+      return BlockVarDecl::CreateImpl(D);
       
     case FileVar:
-      return FileVarDecl::Materialize(D);
+      return FileVarDecl::CreateImpl(D);
       
     case ParmVar:
-      return ParmVarDecl::Materialize(D);
+      return ParmVarDecl::CreateImpl(D);
       
     case Function:
-      return FunctionDecl::Materialize(D);
+      return FunctionDecl::CreateImpl(D);
       
     case Typedef:
-      return TypedefDecl::Materialize(D);
+      return TypedefDecl::CreateImpl(D);
   }
 }
 
-void NamedDecl::InternalEmit(llvm::Serializer& S) const {
-  S.EmitPtr(Identifier);
+//===----------------------------------------------------------------------===//
+//      Common serialization logic for subclasses of Decl.
+//===----------------------------------------------------------------------===//
+
+void Decl::EmitInRec(Serializer& S) const {
+  S.Emit(getLocation());                    // From Decl.
 }
 
-void NamedDecl::InternalRead(llvm::Deserializer& D) {
-  D.ReadPtr(Identifier);
+void Decl::ReadInRec(Deserializer& D) {
+  Loc = SourceLocation::ReadVal(D);                 // From Decl.
 }
 
-void ScopedDecl::InternalEmit(llvm::Serializer& S) const {
-  NamedDecl::InternalEmit(S);
-  S.EmitPtr(Next);
-  S.EmitOwnedPtr<Decl>(NextDeclarator);  
+//===----------------------------------------------------------------------===//
+//      Common serialization logic for subclasses of NamedDecl.
+//===----------------------------------------------------------------------===//
+
+void NamedDecl::EmitInRec(Serializer& S) const {
+  Decl::EmitInRec(S);
+  S.EmitPtr(getIdentifier());               // From NamedDecl.
 }
 
-void ScopedDecl::InternalRead(llvm::Deserializer& D) {
-  NamedDecl::InternalRead(D);
-  D.ReadPtr(Next);
-  NextDeclarator = cast_or_null<ScopedDecl>(D.ReadOwnedPtr<Decl>());
+void NamedDecl::ReadInRec(Deserializer& D) {
+  Decl::ReadInRec(D);
+  D.ReadPtr(Identifier);                            // From NamedDecl.  
 }
 
-void ValueDecl::InternalEmit(llvm::Serializer& S) const {
-  S.Emit(DeclType);
-  ScopedDecl::InternalEmit(S);
+//===----------------------------------------------------------------------===//
+//      Common serialization logic for subclasses of ScopedDecl.
+//===----------------------------------------------------------------------===//
+
+void ScopedDecl::EmitInRec(Serializer& S) const {
+  NamedDecl::EmitInRec(S);
+  S.EmitPtr(getNext());                     // From ScopedDecl.  
 }
 
-void ValueDecl::InternalRead(llvm::Deserializer& D) {
-  D.Read(DeclType);
-  ScopedDecl::InternalRead(D);
+void ScopedDecl::ReadInRec(Deserializer& D) {
+  NamedDecl::ReadInRec(D);
+  D.ReadPtr(Next);                                  // From ScopedDecl.
 }
+    
+  //===------------------------------------------------------------===//
+  // NOTE: Not all subclasses of ScopedDecl will use the "OutRec"     //
+  //   methods.  This is because owned pointers are usually "batched" //
+  //   together for efficiency.                                       //
+  //===------------------------------------------------------------===//
 
-void VarDecl::InternalEmit(llvm::Serializer& S) const {
-  S.EmitInt(SClass);
-  S.EmitInt(objcDeclQualifier);
-  ValueDecl::InternalEmit(S);
-  S.EmitOwnedPtr(Init);
+void ScopedDecl::EmitOutRec(Serializer& S) const {
+  S.EmitOwnedPtr(getNextDeclarator());   // From ScopedDecl.
 }
 
-void VarDecl::InternalRead(llvm::Deserializer& D) {
-  SClass = D.ReadInt();
-  objcDeclQualifier = static_cast<ObjcDeclQualifier>(D.ReadInt());
-  ValueDecl::InternalRead(D);
-  D.ReadOwnedPtr(Init);
+void ScopedDecl::ReadOutRec(Deserializer& D) {
+  NextDeclarator = 
+    cast_or_null<ScopedDecl>(D.ReadOwnedPtr<Decl>()); // From ScopedDecl.
 }
 
+//===----------------------------------------------------------------------===//
+//      Common serialization logic for subclasses of ValueDecl.
+//===----------------------------------------------------------------------===//
 
-void BlockVarDecl::Emit(llvm::Serializer& S) const {
-  S.Emit(getLocation());  
-  VarDecl::InternalEmit(S);  
+void ValueDecl::EmitInRec(Serializer& S) const {
+  ScopedDecl::EmitInRec(S);
+  S.Emit(getType());                        // From ValueDecl.
 }
 
-BlockVarDecl* BlockVarDecl::Materialize(llvm::Deserializer& D) {
-  SourceLocation L = SourceLocation::ReadVal(D);
-  BlockVarDecl* decl = new BlockVarDecl(L,NULL,QualType(),None,NULL);
-  decl->VarDecl::InternalRead(D);
-  return decl;
+void ValueDecl::ReadInRec(Deserializer& D) {
+  ScopedDecl::ReadInRec(D);
+  DeclType = QualType::ReadVal(D);          // From ValueDecl.
 }
 
-void FileVarDecl::Emit(llvm::Serializer& S) const {
-  S.Emit(getLocation());  
-  VarDecl::InternalEmit(S);  
+//===----------------------------------------------------------------------===//
+//      Common serialization logic for subclasses of VarDecl.
+//===----------------------------------------------------------------------===//
+
+void VarDecl::EmitInRec(Serializer& S) const {
+  ValueDecl::EmitInRec(S);
+  S.EmitInt(getStorageClass());             // From VarDecl.
+  S.EmitInt(getObjcDeclQualifier());        // From VarDecl.
 }
 
-FileVarDecl* FileVarDecl::Materialize(llvm::Deserializer& D) {
-  SourceLocation L = SourceLocation::ReadVal(D);
-  FileVarDecl* decl = new FileVarDecl(L,NULL,QualType(),None,NULL);
-  decl->VarDecl::InternalRead(D);
-  return decl;
+void VarDecl::ReadInRec(Deserializer& D) {
+  ValueDecl::ReadInRec(D);
+  SClass = static_cast<StorageClass>(D.ReadInt());  // From VarDecl.  
+  objcDeclQualifier = static_cast<ObjcDeclQualifier>(D.ReadInt());  // VarDecl.
+}
+
+    //===------------------------------------------------------------===//
+    // NOTE: VarDecl has its own "OutRec" methods that doesn't use      //
+    //  the one define in ScopedDecl.  This is to batch emit the        //
+    //  owned pointers, which results in a smaller output.
+    //===------------------------------------------------------------===//
+
+void VarDecl::EmitOutRec(Serializer& S) const {
+  // Emit these last because they will create records of their own.
+  S.BatchEmitOwnedPtrs(getInit(),            // From VarDecl.
+                       getNextDeclarator()); // From ScopedDecl.  
+}
+
+void VarDecl::ReadOutRec(Deserializer& D) {
+  Decl* next_declarator;
+  
+  D.BatchReadOwnedPtrs(Init,                           // From VarDecl.
+                       next_declarator);  // From ScopedDecl.
+  
+  setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
 }
 
-void ParmVarDecl::Emit(llvm::Serializer& S) const {
-  S.Emit(getLocation());  
-  VarDecl::InternalEmit(S);  
+
+void VarDecl::EmitImpl(Serializer& S) const {
+  VarDecl::EmitInRec(S);
+  VarDecl::EmitOutRec(S);
 }
 
-ParmVarDecl* ParmVarDecl::Materialize(llvm::Deserializer& D) {
-  SourceLocation L = SourceLocation::ReadVal(D);
-  ParmVarDecl* decl = new ParmVarDecl(L,NULL,QualType(),None,NULL);
-  decl->VarDecl::InternalRead(D);
+void VarDecl::ReadImpl(Deserializer& D) {
+  ReadInRec(D);
+  ReadOutRec(D);
+}
+
+//===----------------------------------------------------------------------===//
+//      BlockVarDecl Serialization.
+//===----------------------------------------------------------------------===//
+
+BlockVarDecl* BlockVarDecl::CreateImpl(Deserializer& D) {  
+  BlockVarDecl* decl = 
+    new BlockVarDecl(SourceLocation(),NULL,QualType(),None,NULL);
+ 
+  decl->VarDecl::ReadImpl(D);
+  
+  return decl;
+}
+
+//===----------------------------------------------------------------------===//
+//      FileVarDecl Serialization.
+//===----------------------------------------------------------------------===//
+
+FileVarDecl* FileVarDecl::CreateImpl(Deserializer& D) {
+  FileVarDecl* decl =
+    new FileVarDecl(SourceLocation(),NULL,QualType(),None,NULL);
+  
+  decl->VarDecl::ReadImpl(D);
+
   return decl;
 }
 
-void FunctionDecl::Emit(llvm::Serializer& S) const {
-  S.Emit(getLocation());
-  S.EmitInt(SClass);
-  S.EmitBool(IsInline);
+//===----------------------------------------------------------------------===//
+//      ParmDecl Serialization.
+//===----------------------------------------------------------------------===//
+
+ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D) {
+  ParmVarDecl* decl =
+    new ParmVarDecl(SourceLocation(),NULL,QualType(),None,NULL);
+  
+  decl->VarDecl::ReadImpl(D);
   
-  ValueDecl::InternalEmit(S);
+  return decl;
+}
 
-  unsigned NumParams = getNumParams();
-  S.EmitInt(NumParams);
+//===----------------------------------------------------------------------===//
+//      FunctionDecl Serialization.
+//===----------------------------------------------------------------------===//
+
+void FunctionDecl::EmitImpl(Serializer& S) const {
+  S.EmitInt(SClass);           // From FunctionDecl.
+  S.EmitBool(IsInline);        // From FunctionDecl.
+  ValueDecl::EmitInRec(S);
+  S.EmitPtr(DeclChain);
   
-  for (unsigned i = 0 ; i < NumParams; ++i)
-    S.EmitOwnedPtr(ParamInfo[i]);
+  // NOTE: We do not need to serialize out the number of parameters, because
+  //  that is encoded in the type (accessed via getNumParams()).
   
-  S.EmitOwnedPtr(Body);
+  S.BatchEmitOwnedPtrs(getNumParams(),&ParamInfo[0], // From FunctionDecl.
+                       Body, // From FunctionDecl.
+                       getNextDeclarator());  // From ScopedDecl.
 }
 
-FunctionDecl* FunctionDecl::Materialize(llvm::Deserializer& D) {
-  SourceLocation L = SourceLocation::ReadVal(D);
+FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D) {
   StorageClass SClass = static_cast<StorageClass>(D.ReadInt());
   bool IsInline = D.ReadBool();
-
-  FunctionDecl* decl = new FunctionDecl(L,NULL,QualType(),SClass,IsInline);
   
-  decl->ValueDecl::InternalRead(D);
-
-  unsigned NumParams = D.ReadInt();
-  decl->ParamInfo = NumParams ? new ParmVarDecl*[NumParams] : NULL;
+  FunctionDecl* decl =
+    new FunctionDecl(SourceLocation(),NULL,QualType(),SClass,IsInline);
   
-  for (unsigned i = 0 ; i < NumParams; ++i)
-    D.ReadOwnedPtr(decl->ParamInfo[i]);
-
-  D.ReadOwnedPtr(decl->Body);
+  decl->ValueDecl::ReadInRec(D);
+  D.ReadPtr(decl->DeclChain);
+  
+  decl->ParamInfo = decl->getNumParams()
+                    ? new ParmVarDecl*[decl->getNumParams()] 
+                    : NULL;
+  
+  Decl* next_declarator;
+  
+  D.BatchReadOwnedPtrs(decl->getNumParams(),
+                reinterpret_cast<Decl**>(&decl->ParamInfo[0]), // FunctionDecl.
+                decl->Body,  // From FunctionDecl.
+                next_declarator); // From ScopedDecl.
+  
+  decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
   
   return decl;
 }
 
-void TypedefDecl::Emit(llvm::Serializer& S) const {
-  S.Emit(getLocation());
+//===----------------------------------------------------------------------===//
+//      TypedefDecl Serialization.
+//===----------------------------------------------------------------------===//
+
+void TypedefDecl::EmitImpl(Serializer& S) const {
   S.Emit(UnderlyingType);
-  InternalEmit(S);
+  ScopedDecl::EmitInRec(S);
+  ScopedDecl::EmitOutRec(S);
 }
 
-TypedefDecl* TypedefDecl::Materialize(llvm::Deserializer& D) {
-  SourceLocation L = SourceLocation::ReadVal(D);
-  TypedefDecl* decl = new TypedefDecl(L,NULL,QualType(),NULL);
-  D.Read(decl->UnderlyingType);
-  decl->InternalRead(D);
+TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D) {
+  QualType T = QualType::ReadVal(D);
+  
+  TypedefDecl* decl = new TypedefDecl(SourceLocation(),NULL,T,NULL);
+  
+  decl->ScopedDecl::ReadInRec(D);
+  decl->ScopedDecl::ReadOutRec(D);
+
   return decl;
 }

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

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Nov 12 18:15:39 2007
@@ -108,7 +108,7 @@
 private:
   /// Loc - The location that this decl.
   SourceLocation Loc;
-
+  
   /// DeclKind - This indicates which class this is.
   Kind DeclKind   :  8;
   
@@ -163,9 +163,23 @@
   
   /// Emit - Serialize this Decl to Bitcode.
   void Emit(llvm::Serializer& S) const;
+    
+  /// Create - Deserialize a Decl from Bitcode.
+  static Decl* Create(llvm::Deserializer& D);
   
-  /// Materialize - Deserialize a Decl from Bitcode.
-  static Decl* Materialize(llvm::Deserializer& D);
+  /// Materialize - Deserialize a Decl from Bitcode. (DEPRECATED)
+  static Decl* Materialize(llvm::Deserializer& D) { return Create(D); }
+
+protected:
+  /// EmitImpl - Provides the subclass-specific serialization logic for
+  ///   serializing out a decl.
+  virtual void EmitImpl(llvm::Serializer& S) const {
+    // FIXME: This will eventually be a pure virtual function.
+    assert (false && "Not implemented.");
+  }
+  
+  void EmitInRec(llvm::Serializer& S) const;
+  void ReadInRec(llvm::Deserializer& D);
 };
 
 /// NamedDecl - This represents a decl with an identifier for a name.  Many
@@ -180,22 +194,20 @@
   
   IdentifierInfo *getIdentifier() const { return Identifier; }
   const char *getName() const;
-  
-  
+    
   static bool classof(const Decl *D) {
     return D->getKind() >= NamedFirst && D->getKind() <= NamedLast;
   }
   static bool classof(const NamedDecl *D) { return true; }
-    
+  
 protected:
-  void InternalEmit(llvm::Serializer& S) const;
-  void InternalRead(llvm::Deserializer& D);  
+  void EmitInRec(llvm::Serializer& S) const;
+  void ReadInRec(llvm::Deserializer& D);
 };
 
 /// ScopedDecl - Represent lexically scoped names, used for all ValueDecl's
 /// and TypeDecl's.
 class ScopedDecl : public NamedDecl {
-  
   /// NextDeclarator - If this decl was part of a multi-declarator declaration,
   /// such as "int X, Y, *Z;" this indicates Decl for the next declarator.
   ScopedDecl *NextDeclarator;
@@ -205,9 +217,11 @@
   /// Decls are relinked onto a containing decl object.
   ///
   ScopedDecl *Next;
+
 protected:
   ScopedDecl(Kind DK, SourceLocation L, IdentifierInfo *Id,ScopedDecl *PrevDecl)
     : NamedDecl(DK, L, Id), NextDeclarator(PrevDecl), Next(0) {}
+  
 public:
   ScopedDecl *getNext() const { return Next; }
   void setNext(ScopedDecl *N) { Next = N; }
@@ -224,10 +238,13 @@
     return D->getKind() >= ScopedFirst && D->getKind() <= ScopedLast;
   }
   static bool classof(const ScopedDecl *D) { return true; }
-    
+  
 protected:
-  void InternalEmit(llvm::Serializer& S) const;
-  void InternalRead(llvm::Deserializer& D);  
+  void EmitInRec(llvm::Serializer& S) const;
+  void ReadInRec(llvm::Deserializer& D);
+  
+  void EmitOutRec(llvm::Serializer& S) const;
+  void ReadOutRec(llvm::Deserializer& D);
 };
 
 /// ValueDecl - Represent the declaration of a variable (in which case it is 
@@ -248,10 +265,10 @@
     return D->getKind() >= ValueFirst && D->getKind() <= ValueLast;
   }
   static bool classof(const ValueDecl *D) { return true; }
-    
+  
 protected:
-  void InternalEmit(llvm::Serializer& S) const;
-  void InternalRead(llvm::Deserializer& D); 
+  void EmitInRec(llvm::Serializer& S) const;
+  void ReadInRec(llvm::Deserializer& D);
 };
 
 /// VarDecl - An instance of this class is created to represent a variable
@@ -323,8 +340,17 @@
   friend class StmtIteratorBase;
   
 protected:
-  void InternalEmit(llvm::Serializer& S) const;
-  void InternalRead(llvm::Deserializer& D); 
+  void EmitInRec(llvm::Serializer& S) const;
+  void ReadInRec(llvm::Deserializer& D);
+  
+  void EmitOutRec(llvm::Serializer& S) const;
+  void ReadOutRec(llvm::Deserializer& D);
+  
+  /// EmitImpl - Serialize this VarDecl. Called by Decl::Emit.
+  virtual void EmitImpl(llvm::Serializer& S) const;
+  
+  /// ReadImpl - Deserialize this VarDecl. Called by subclasses.
+  virtual void ReadImpl(llvm::Deserializer& S);
 };
 
 /// BlockVarDecl - Represent a local variable declaration.
@@ -338,11 +364,11 @@
   static bool classof(const Decl *D) { return D->getKind() == BlockVar; }
   static bool classof(const BlockVarDecl *D) { return true; }  
 
-  /// Emit - Serialize this BlockVarDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
-  
-  /// Materialize - Deserialize a BlockVarDecl from Bitcode.
-  static BlockVarDecl* Materialize(llvm::Deserializer& D);
+protected:
+  /// CreateImpl - Deserialize a BlockVarDecl.  Called by Decl::Create.
+  static BlockVarDecl* CreateImpl(llvm::Deserializer& D);  
+
+  friend Decl* Decl::Create(llvm::Deserializer& D);
 };
 
 /// FileVarDecl - Represent a file scoped variable declaration. This
@@ -358,12 +384,12 @@
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return D->getKind() == FileVar; }
   static bool classof(const FileVarDecl *D) { return true; }
-  
-  /// Emit - Serialize this FileVarDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
-  
-  /// Materialize - Deserialize a FileVarDecl from Bitcode.
-  static FileVarDecl* Materialize(llvm::Deserializer& D);
+
+protected:
+  /// CreateImpl - Deserialize a FileVarDecl.  Called by Decl::Create.
+  static FileVarDecl* CreateImpl(llvm::Deserializer& D);
+
+  friend Decl* Decl::Create(llvm::Deserializer& D);
 };
 
 /// ParmVarDecl - Represent a parameter to a function.
@@ -377,11 +403,11 @@
   static bool classof(const Decl *D) { return D->getKind() == ParmVar; }
   static bool classof(const ParmVarDecl *D) { return true; }
   
-  /// Emit - Serialize this ParmVarDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
-  
-  /// Materialize - Deserialize a ParmVarDecl from Bitcode.
-  static ParmVarDecl* Materialize(llvm::Deserializer& D);
+protected:
+  /// CreateImpl - Deserialize a ParmVarDecl.  Called by Decl::Create.
+  static ParmVarDecl* CreateImpl(llvm::Deserializer& D);
+
+  friend Decl* Decl::Create(llvm::Deserializer& D);
 };
 
 /// FunctionDecl - An instance of this class is created to represent a function
@@ -424,6 +450,7 @@
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return D->getKind() == Function; }
   static bool classof(const FunctionDecl *D) { return true; }
+  
 private:
   /// ParamInfo - new[]'d array of pointers to VarDecls for the formal
   /// parameters of this function.  This is null if a prototype or if there are
@@ -440,12 +467,14 @@
   StorageClass SClass : 2;
   bool IsInline : 1;
 
-public:
-  /// Emit - Serialize this FunctionDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
+protected:
+  /// EmitImpl - Serialize this FunctionDecl.  Called by Decl::Emit.
+  virtual void EmitImpl(llvm::Serializer& S) const;
   
-  /// Materialize - Deserialize a FunctionDecl from Bitcode.
-  static FunctionDecl* Materialize(llvm::Deserializer& D);
+  /// CreateImpl - Deserialize a FunctionDecl.  Called by Decl::Create.
+  static FunctionDecl* CreateImpl(llvm::Deserializer& D);
+  
+  friend Decl* Decl::Create(llvm::Deserializer& D);
 };
 
 
@@ -472,13 +501,6 @@
     return D->getKind() >= FieldFirst && D->getKind() <= FieldLast;
   }
   static bool classof(const FieldDecl *D) { return true; }
-  
-public:
-  /// Emit - Serialize this FieldDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
-  
-  /// Materialize - Deserialize a FieldDecl from Bitcode.
-  static FieldDecl* Materialize(llvm::Deserializer& D);
 };
 
 /// EnumConstantDecl - An instance of this object exists for each enum constant
@@ -505,12 +527,6 @@
   static bool classof(const EnumConstantDecl *D) { return true; }
   
   friend class StmtIteratorBase;
-  
-  /// Emit - Serialize this EnumConstantDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
-  
-  /// Materialize - Deserialize a EnumConstantDecl from Bitcode.
-  static EnumConstantDecl* Materialize(llvm::Deserializer& D);
 };
 
 
@@ -531,12 +547,6 @@
     return D->getKind() >= TypeFirst && D->getKind() <= TypeLast;
   }
   static bool classof(const TypeDecl *D) { return true; }
-  
-  /// Emit - Serialize this TypeDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
-  
-  /// Materialize - Deserialize a TypeDecl from Bitcode.
-  static TypeDecl* Materialize(llvm::Deserializer& D);
 };
 
 
@@ -553,12 +563,15 @@
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return D->getKind() == Typedef; }
   static bool classof(const TypedefDecl *D) { return true; }
+
+protected:
+  /// EmitImpl - Serialize this TypedefDecl.  Called by Decl::Emit.
+  virtual void EmitImpl(llvm::Serializer& S) const;
   
-  /// Emit - Serialize this TypedefDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
+  /// CreateImpl - Deserialize a TypedefDecl.  Called by Decl::Create.
+  static TypedefDecl* CreateImpl(llvm::Deserializer& D);
   
-  /// Materialize - Deserialize a TypedefDecl from Bitcode.
-  static TypedefDecl* Materialize(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D);
 };
 
 
@@ -596,13 +609,6 @@
   static bool classof(const TagDecl *D) { return true; }
 protected:
   void setDefinition(bool V) { IsDefinition = V; }
-  
-public:
-  /// Emit - Serialize this TagDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
-  
-  /// Materialize - Deserialize a TagDecl from Bitcode.
-  static TagDecl* Materialize(llvm::Deserializer& D);
 };
 
 /// EnumDecl - Represents an enum.  As an extension, we allow forward-declared
@@ -644,13 +650,6 @@
   
   static bool classof(const Decl *D) { return D->getKind() == Enum; }
   static bool classof(const EnumDecl *D) { return true; }
-  
-public:
-  /// Emit - Serialize this EnumDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
-  
-  /// Materialize - Deserialize a EnumDecl from Bitcode.
-  static EnumDecl* Materialize(llvm::Deserializer& D);
 };
 
 
@@ -698,13 +697,6 @@
     return D->getKind() >= RecordFirst && D->getKind() <= RecordLast;
   }
   static bool classof(const RecordDecl *D) { return true; }
-  
-public:
-  /// Emit - Serialize this RecordDecl to Bitcode.
-  void Emit(llvm::Serializer& S) const;
-  
-  /// Materialize - Deserialize a RecordDecl from Bitcode.
-  static RecordDecl* Materialize(llvm::Deserializer& D);
 };
 
 }  // end namespace clang





More information about the cfe-commits mailing list