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

Ted Kremenek kremenek at apple.com
Wed Nov 14 09:47:02 PST 2007


Author: kremenek
Date: Wed Nov 14 11:47:01 2007
New Revision: 44126

URL: http://llvm.org/viewvc/llvm-project?rev=44126&view=rev
Log:
Implemented serialization of FieldDecls.

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=44126&r1=44125&r2=44126&view=diff

==============================================================================
--- cfe/trunk/AST/DeclSerialization.cpp (original)
+++ cfe/trunk/AST/DeclSerialization.cpp Wed Nov 14 11:47:01 2007
@@ -43,6 +43,9 @@
     case BlockVar:
       return BlockVarDecl::CreateImpl(D);
       
+    case Field:
+      return FieldDecl::CreateImpl(D);
+      
     case FileVar:
       return FileVarDecl::CreateImpl(D);
       
@@ -217,6 +220,24 @@
 }
 
 //===----------------------------------------------------------------------===//
+//      FieldDecl Serialization.
+//===----------------------------------------------------------------------===//
+
+void FieldDecl::EmitImpl(Serializer& S) const {
+  S.Emit(getType());
+  NamedDecl::EmitInRec(S);
+  S.EmitOwnedPtr(BitWidth);  
+}
+
+FieldDecl* FieldDecl::CreateImpl(Deserializer& D) {
+  QualType DeclType = QualType::ReadVal(D);
+  FieldDecl* decl = new FieldDecl(SourceLocation(),NULL,DeclType);
+  decl->ReadInRec(D);
+  decl->BitWidth = D.ReadOwnedPtr<Expr>();
+  return decl;
+}
+
+//===----------------------------------------------------------------------===//
 //      FunctionDecl Serialization.
 //===----------------------------------------------------------------------===//
 

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

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Nov 14 11:47:01 2007
@@ -505,6 +505,15 @@
     return D->getKind() >= FieldFirst && D->getKind() <= FieldLast;
   }
   static bool classof(const FieldDecl *D) { return true; }
+
+protected:
+  /// EmitImpl - Serialize this FieldDecl.  Called by Decl::Emit.
+  virtual void EmitImpl(llvm::Serializer& S) const;
+  
+  /// CreateImpl - Deserialize a FieldDecl.  Called by Decl::Create.
+  static FieldDecl* CreateImpl(llvm::Deserializer& D);
+  
+  friend Decl* Decl::Create(llvm::Deserializer& D);  
 };
 
 /// EnumConstantDecl - An instance of this object exists for each enum constant





More information about the cfe-commits mailing list