[cfe-commits] r49353 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclBase.h include/clang/AST/Expr.h include/clang/AST/Stmt.h lib/AST/DeclSerialization.cpp lib/AST/StmtSerialization.cpp lib/AST/TranslationUnit.cpp lib/AST/TypeSerialization.cpp

Sam Bishop sam at bishop.dhs.org
Mon Apr 7 14:55:54 PDT 2008


Author: sbishop
Date: Mon Apr  7 16:55:54 2008
New Revision: 49353

URL: http://llvm.org/viewvc/llvm-project?rev=49353&view=rev
Log:
Pass the ASTContext object around when deserializing Decl and Stmt objects, so
they can be created using the same allocator as in the "from source code" case.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/include/clang/AST/Stmt.h
    cfe/trunk/lib/AST/DeclSerialization.cpp
    cfe/trunk/lib/AST/StmtSerialization.cpp
    cfe/trunk/lib/AST/TranslationUnit.cpp
    cfe/trunk/lib/AST/TypeSerialization.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Apr  7 16:55:54 2008
@@ -42,7 +42,7 @@
   
 protected:
   void EmitInRec(llvm::Serializer& S) const;
-  void ReadInRec(llvm::Deserializer& D);
+  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ScopedDecl - Represent lexically scoped names, used for all ValueDecl's
@@ -97,10 +97,10 @@
   
 protected:
   void EmitInRec(llvm::Serializer& S) const;
-  void ReadInRec(llvm::Deserializer& D);
+  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
   
   void EmitOutRec(llvm::Serializer& S) const;
-  void ReadOutRec(llvm::Deserializer& D);
+  void ReadOutRec(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ValueDecl - Represent the declaration of a variable (in which case it is 
@@ -125,7 +125,7 @@
   
 protected:
   void EmitInRec(llvm::Serializer& S) const;
-  void ReadInRec(llvm::Deserializer& D);
+  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// VarDecl - An instance of this class is created to represent a variable
@@ -177,16 +177,16 @@
 
 protected:
   void EmitInRec(llvm::Serializer& S) const;
-  void ReadInRec(llvm::Deserializer& D);
+  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
   
   void EmitOutRec(llvm::Serializer& S) const;
-  void ReadOutRec(llvm::Deserializer& D);
+  void ReadOutRec(llvm::Deserializer& D, ASTContext& C);
   
   /// 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);
+  virtual void ReadImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// BlockVarDecl - Represent a local variable declaration.  Note that this
@@ -209,9 +209,9 @@
 
 protected:
   /// CreateImpl - Deserialize a BlockVarDecl.  Called by Decl::Create.
-  static BlockVarDecl* CreateImpl(llvm::Deserializer& D);  
+  static BlockVarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 
-  friend Decl* Decl::Create(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// FileVarDecl - Represent a file scoped variable declaration. This
@@ -234,9 +234,9 @@
 
 protected:
   /// CreateImpl - Deserialize a FileVarDecl.  Called by Decl::Create.
-  static FileVarDecl* CreateImpl(llvm::Deserializer& D);
+  static FileVarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 
-  friend Decl* Decl::Create(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ParmVarDecl - Represent a parameter to a function.
@@ -271,9 +271,9 @@
   virtual void EmitImpl(llvm::Serializer& S) const;
   
   /// CreateImpl - Deserialize a ParmVarDecl.  Called by Decl::Create.
-  static ParmVarDecl* CreateImpl(llvm::Deserializer& D);
+  static ParmVarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 
-  friend Decl* Decl::Create(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// FunctionDecl - An instance of this class is created to represent a function
@@ -359,9 +359,9 @@
   virtual void EmitImpl(llvm::Serializer& S) const;
   
   /// CreateImpl - Deserialize a FunctionDecl.  Called by Decl::Create.
-  static FunctionDecl* CreateImpl(llvm::Deserializer& D);
+  static FunctionDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
   
-  friend Decl* Decl::Create(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -396,9 +396,9 @@
   virtual void EmitImpl(llvm::Serializer& S) const;
   
   /// CreateImpl - Deserialize a FieldDecl.  Called by Decl::Create.
-  static FieldDecl* CreateImpl(llvm::Deserializer& D);
+  static FieldDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
   
-  friend Decl* Decl::Create(llvm::Deserializer& D);  
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// EnumConstantDecl - An instance of this object exists for each enum constant
@@ -439,9 +439,9 @@
   virtual void EmitImpl(llvm::Serializer& S) const;
   
   /// CreateImpl - Deserialize a EnumConstantDecl.  Called by Decl::Create.
-  static EnumConstantDecl* CreateImpl(llvm::Deserializer& D);
+  static EnumConstantDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
   
-  friend Decl* Decl::Create(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -491,9 +491,9 @@
   virtual void EmitImpl(llvm::Serializer& S) const;
   
   /// CreateImpl - Deserialize a TypedefDecl.  Called by Decl::Create.
-  static TypedefDecl* CreateImpl(llvm::Deserializer& D);
+  static TypedefDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
   
-  friend Decl* Decl::Create(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -585,9 +585,9 @@
   virtual void EmitImpl(llvm::Serializer& S) const;
   
   /// CreateImpl - Deserialize a EnumDecl.  Called by Decl::Create.
-  static EnumDecl* CreateImpl(llvm::Deserializer& D);
+  static EnumDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
   
-  friend Decl* Decl::Create(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -647,9 +647,9 @@
   virtual void EmitImpl(llvm::Serializer& S) const;
   
   /// CreateImpl - Deserialize a RecordDecl.  Called by Decl::Create.
-  static RecordDecl* CreateImpl(Kind DK, llvm::Deserializer& D);
+  static RecordDecl* CreateImpl(Kind DK, llvm::Deserializer& D, ASTContext& C);
   
-  friend Decl* Decl::Create(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 class FileScopeAsmDecl : public Decl {
@@ -671,9 +671,9 @@
   virtual void EmitImpl(llvm::Serializer& S) const;
   
   /// CreateImpl - Deserialize a FileScopeAsmDecl.  Called by Decl::Create.
-  static FileScopeAsmDecl* CreateImpl(llvm::Deserializer& D);
+  static FileScopeAsmDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
   
-  friend Decl* Decl::Create(llvm::Deserializer& D);
+  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// LinkageSpecDecl - This represents a linkage specification.  For example:
@@ -711,7 +711,7 @@
   
 protected:
   void EmitInRec(llvm::Serializer& S) const;
-  void ReadInRec(llvm::Deserializer& D);
+  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
 };
 
 }  // end namespace clang

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Apr  7 16:55:54 2008
@@ -177,7 +177,7 @@
   void Emit(llvm::Serializer& S) const;
     
   /// Create - Deserialize a Decl from Bitcode.
-  static Decl* Create(llvm::Deserializer& D);
+  static Decl* Create(llvm::Deserializer& D, ASTContext& C);
 
 protected:
   /// EmitImpl - Provides the subclass-specific serialization logic for
@@ -188,7 +188,7 @@
   }
   
   void EmitInRec(llvm::Serializer& S) const;
-  void ReadInRec(llvm::Deserializer& D);
+  void ReadInRec(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// DeclContext - This is used only as base class of specific decl types that

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

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Apr  7 16:55:54 2008
@@ -134,8 +134,8 @@
   }
   static bool classof(const Expr *) { return true; }
   
-  static inline Expr* Create(llvm::Deserializer& D) {
-    return cast<Expr>(Stmt::Create(D));    
+  static inline Expr* Create(llvm::Deserializer& D, ASTContext& C) {
+    return cast<Expr>(Stmt::Create(D, C));
   }
 };
 
@@ -167,7 +167,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static DeclRefExpr* CreateImpl(llvm::Deserializer& D);
+  static DeclRefExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// PreDefinedExpr - [C99 6.4.2.2] - A pre-defined identifier such as __func__.
@@ -200,7 +200,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static PreDefinedExpr* CreateImpl(llvm::Deserializer& D);
+  static PreDefinedExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 class IntegerLiteral : public Expr {
@@ -226,7 +226,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static IntegerLiteral* CreateImpl(llvm::Deserializer& D);
+  static IntegerLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 class CharacterLiteral : public Expr {
@@ -253,7 +253,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static CharacterLiteral* CreateImpl(llvm::Deserializer& D);
+  static CharacterLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 class FloatingLiteral : public Expr {
@@ -292,7 +292,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static FloatingLiteral* CreateImpl(llvm::Deserializer& D);
+  static FloatingLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ImaginaryLiteral - We support imaginary integer and floating point literals,
@@ -320,7 +320,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ImaginaryLiteral* CreateImpl(llvm::Deserializer& D);
+  static ImaginaryLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// StringLiteral - This represents a string literal expression, e.g. "foo"
@@ -358,7 +358,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static StringLiteral* CreateImpl(llvm::Deserializer& D);
+  static StringLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ParenExpr - This represents a parethesized expression, e.g. "(1)".  This
@@ -384,7 +384,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ParenExpr* CreateImpl(llvm::Deserializer& D);
+  static ParenExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -465,7 +465,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static UnaryOperator* CreateImpl(llvm::Deserializer& D);
+  static UnaryOperator* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// SizeOfAlignOfTypeExpr - [C99 6.5.3.4] - This is only for sizeof/alignof of
@@ -496,7 +496,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static SizeOfAlignOfTypeExpr* CreateImpl(llvm::Deserializer& D);
+  static SizeOfAlignOfTypeExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 //===----------------------------------------------------------------------===//
@@ -563,7 +563,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ArraySubscriptExpr* CreateImpl(llvm::Deserializer& D);
+  static ArraySubscriptExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -648,7 +648,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static CallExpr* CreateImpl(llvm::Deserializer& D);
+  static CallExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// MemberExpr - [C99 6.5.2.3] Structure and Union Members.
@@ -683,7 +683,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static MemberExpr* CreateImpl(llvm::Deserializer& D);
+  static MemberExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// OCUVectorElementExpr - This represents access to specific elements of a
@@ -785,7 +785,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static CompoundLiteralExpr* CreateImpl(llvm::Deserializer& D);
+  static CompoundLiteralExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ImplicitCastExpr - Allows us to explicitly represent implicit type 
@@ -813,7 +813,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ImplicitCastExpr* CreateImpl(llvm::Deserializer& D);
+  static ImplicitCastExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// CastExpr - [C99 6.5.4] Cast Operators.
@@ -842,7 +842,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static CastExpr* CreateImpl(llvm::Deserializer& D);
+  static CastExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 class BinaryOperator : public Expr {
@@ -919,7 +919,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static BinaryOperator* CreateImpl(llvm::Deserializer& D);
+  static BinaryOperator* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 
 protected:
   BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
@@ -956,7 +956,8 @@
   }
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static CompoundAssignOperator* CreateImpl(llvm::Deserializer& D);
+  static CompoundAssignOperator* CreateImpl(llvm::Deserializer& D,
+                                            ASTContext& C);
 };
 
 /// ConditionalOperator - The ?: operator.  Note that LHS may be null when the
@@ -1007,7 +1008,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ConditionalOperator* CreateImpl(llvm::Deserializer& D);
+  static ConditionalOperator* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// AddrLabelExpr - The GNU address of label extension, representing &&label.
@@ -1035,7 +1036,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static AddrLabelExpr* CreateImpl(llvm::Deserializer& D);
+  static AddrLabelExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
@@ -1066,7 +1067,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static StmtExpr* CreateImpl(llvm::Deserializer& D);
+  static StmtExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// TypesCompatibleExpr - GNU builtin-in function __builtin_type_compatible_p.
@@ -1313,7 +1314,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static InitListExpr* CreateImpl(llvm::Deserializer& D);
+  static InitListExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 
 private:
   // Used by serializer.
@@ -1350,7 +1351,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCStringLiteral* CreateImpl(llvm::Deserializer& D);
+  static ObjCStringLiteral* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
   
 /// ObjCEncodeExpr, used for @encode in Objective-C.
@@ -1379,7 +1380,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCEncodeExpr* CreateImpl(llvm::Deserializer& D);
+  static ObjCEncodeExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ObjCSelectorExpr used for @selector in Objective-C.
@@ -1412,7 +1413,7 @@
   virtual child_iterator child_end();
 
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCSelectorExpr* CreateImpl(llvm::Deserializer& D);
+  static ObjCSelectorExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
   
 /// ObjCProtocolExpr used for protocol in Objective-C.
@@ -1476,7 +1477,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCIvarRefExpr* CreateImpl(llvm::Deserializer& D);
+  static ObjCIvarRefExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 class ObjCMessageExpr : public Expr {

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

==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Mon Apr  7 16:55:54 2008
@@ -26,6 +26,7 @@
 using llvm::dyn_cast_or_null;
 
 namespace clang {
+  class ASTContext;
   class Expr;
   class Decl;
   class ScopedDecl;
@@ -117,8 +118,8 @@
   }
   
   void Emit(llvm::Serializer& S) const;
-  static Stmt* Create(llvm::Deserializer& D);
-  
+  static Stmt* Create(llvm::Deserializer& D, ASTContext& C);
+
   virtual void EmitImpl(llvm::Serializer& S) const {
     // This method will eventually be a pure-virtual function.
     assert (false && "Not implemented.");
@@ -156,7 +157,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static DeclStmt* CreateImpl(llvm::Deserializer& D);
+  static DeclStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// NullStmt - This is the null statement ";": C99 6.8.3p3.
@@ -180,7 +181,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static NullStmt* CreateImpl(llvm::Deserializer& D);
+  static NullStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// CompoundStmt - This represents a group of statements like { stmt stmt }.
@@ -234,7 +235,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static CompoundStmt* CreateImpl(llvm::Deserializer& D);
+  static CompoundStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 // SwitchCase is the base class for CaseStmt and DefaultStmt,
@@ -311,7 +312,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static CaseStmt* CreateImpl(llvm::Deserializer& D);
+  static CaseStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 class DefaultStmt : public SwitchCase {
@@ -340,7 +341,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static DefaultStmt* CreateImpl(llvm::Deserializer& D);
+  static DefaultStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 class LabelStmt : public Stmt {
@@ -374,7 +375,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static LabelStmt* CreateImpl(llvm::Deserializer& D);
+  static LabelStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -418,7 +419,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static IfStmt* CreateImpl(llvm::Deserializer& D);
+  static IfStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// SwitchStmt - This represents a 'switch' stmt.
@@ -466,7 +467,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static SwitchStmt* CreateImpl(llvm::Deserializer& D);
+  static SwitchStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -501,7 +502,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static WhileStmt* CreateImpl(llvm::Deserializer& D);
+  static WhileStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// DoStmt - This represents a 'do/while' stmt.
@@ -536,7 +537,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static DoStmt* CreateImpl(llvm::Deserializer& D);
+  static DoStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -581,7 +582,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ForStmt* CreateImpl(llvm::Deserializer& D);
+  static ForStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
   
 /// GotoStmt - This represents a direct goto.
@@ -609,7 +610,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static GotoStmt* CreateImpl(llvm::Deserializer& D);
+  static GotoStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// IndirectGotoStmt - This represents an indirect goto.
@@ -636,7 +637,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static IndirectGotoStmt* CreateImpl(llvm::Deserializer& D);
+  static IndirectGotoStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -660,7 +661,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ContinueStmt* CreateImpl(llvm::Deserializer& D);
+  static ContinueStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// BreakStmt - This represents a break.
@@ -682,7 +683,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static BreakStmt* CreateImpl(llvm::Deserializer& D);
+  static BreakStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 
@@ -717,7 +718,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ReturnStmt* CreateImpl(llvm::Deserializer& D);
+  static ReturnStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// AsmStmt - This represents a GNU inline-assembly statement extension.
@@ -811,7 +812,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static AsmStmt* CreateImpl(llvm::Deserializer& D);
+  static AsmStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ObjCForCollectionStmt - This represents Objective-c's collection statement;
@@ -853,7 +854,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCForCollectionStmt* CreateImpl(llvm::Deserializer& D);
+  static ObjCForCollectionStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };  
   
 /// ObjCAtCatchStmt - This represents objective-c's @catch statement.
@@ -901,7 +902,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCAtCatchStmt* CreateImpl(llvm::Deserializer& D);
+  static ObjCAtCatchStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
   
 /// ObjCAtFinallyStmt - This represent objective-c's @finally Statement 
@@ -929,7 +930,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCAtFinallyStmt* CreateImpl(llvm::Deserializer& D);    
+  static ObjCAtFinallyStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
   
 /// ObjCAtTryStmt - This represent objective-c's over-all 
@@ -978,7 +979,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCAtTryStmt* CreateImpl(llvm::Deserializer& D);     
+  static ObjCAtTryStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ObjCAtSynchronizedStmt - This is for objective-c's @synchronized statement.
@@ -1028,7 +1029,8 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCAtSynchronizedStmt* CreateImpl(llvm::Deserializer& D);
+  static ObjCAtSynchronizedStmt* CreateImpl(llvm::Deserializer& D,
+                                            ASTContext& C);
 };
   
 /// ObjCAtThrowStmt - This represents objective-c's @throw statement.
@@ -1060,7 +1062,7 @@
   virtual child_iterator child_end();
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static ObjCAtThrowStmt* CreateImpl(llvm::Deserializer& D); 
+  static ObjCAtThrowStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 }  // end namespace clang

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

==============================================================================
--- cfe/trunk/lib/AST/DeclSerialization.cpp (original)
+++ cfe/trunk/lib/AST/DeclSerialization.cpp Mon Apr  7 16:55:54 2008
@@ -31,45 +31,45 @@
   EmitImpl(S);
 }
 
-Decl* Decl::Create(Deserializer& D) {
+Decl* Decl::Create(Deserializer& D, ASTContext& C) {
 
   Kind k = static_cast<Kind>(D.ReadInt());
-  
+
   switch (k) {
     default:
       assert (false && "Not implemented.");
       break;
 
     case BlockVar:
-      return BlockVarDecl::CreateImpl(D);
+      return BlockVarDecl::CreateImpl(D, C);
       
     case Enum:
-      return EnumDecl::CreateImpl(D);
+      return EnumDecl::CreateImpl(D, C);
       
     case EnumConstant:
-      return EnumConstantDecl::CreateImpl(D);
+      return EnumConstantDecl::CreateImpl(D, C);
       
     case Field:
-      return FieldDecl::CreateImpl(D);
+      return FieldDecl::CreateImpl(D, C);
       
     case FileVar:
-      return FileVarDecl::CreateImpl(D);
+      return FileVarDecl::CreateImpl(D, C);
       
     case ParmVar:
-      return ParmVarDecl::CreateImpl(D);
+      return ParmVarDecl::CreateImpl(D, C);
       
     case Function:
-      return FunctionDecl::CreateImpl(D);
+      return FunctionDecl::CreateImpl(D, C);
      
     case Union:
     case Struct:
-      return RecordDecl::CreateImpl(k,D);
+      return RecordDecl::CreateImpl(k, D, C);
       
     case Typedef:
-      return TypedefDecl::CreateImpl(D);
+      return TypedefDecl::CreateImpl(D, C);
       
     case FileScopeAsm:
-      return FileScopeAsmDecl::CreateImpl(D);
+      return FileScopeAsmDecl::CreateImpl(D, C);
   }
 }
 
@@ -81,7 +81,7 @@
   S.Emit(getLocation());                    // From Decl.
 }
 
-void Decl::ReadInRec(Deserializer& D) {
+void Decl::ReadInRec(Deserializer& D, ASTContext& C) {
   Loc = SourceLocation::ReadVal(D);                 // From Decl.
 }
 
@@ -94,8 +94,8 @@
   S.EmitPtr(getIdentifier());               // From NamedDecl.
 }
 
-void NamedDecl::ReadInRec(Deserializer& D) {
-  Decl::ReadInRec(D);
+void NamedDecl::ReadInRec(Deserializer& D, ASTContext& C) {
+  Decl::ReadInRec(D, C);
   D.ReadPtr(Identifier);                            // From NamedDecl.  
 }
 
@@ -109,8 +109,8 @@
   S.EmitPtr(cast_or_null<Decl>(getDeclContext()));  // From ScopedDecl.
 }
 
-void ScopedDecl::ReadInRec(Deserializer& D) {
-  NamedDecl::ReadInRec(D);
+void ScopedDecl::ReadInRec(Deserializer& D, ASTContext& C) {
+  NamedDecl::ReadInRec(D, C);
   D.ReadPtr(Next);                                  // From ScopedDecl.
   Decl *TmpD;
   D.ReadPtr(TmpD);                                  // From ScopedDecl.
@@ -127,9 +127,9 @@
   S.EmitOwnedPtr(getNextDeclarator());   // From ScopedDecl.
 }
 
-void ScopedDecl::ReadOutRec(Deserializer& D) {
+void ScopedDecl::ReadOutRec(Deserializer& D, ASTContext& C) {
   NextDeclarator = 
-    cast_or_null<ScopedDecl>(D.ReadOwnedPtr<Decl>()); // From ScopedDecl.
+    cast_or_null<ScopedDecl>(D.ReadOwnedPtr<Decl>(C)); // From ScopedDecl.
 }
 
 //===----------------------------------------------------------------------===//
@@ -141,8 +141,8 @@
   S.Emit(getType());                        // From ValueDecl.
 }
 
-void ValueDecl::ReadInRec(Deserializer& D) {
-  ScopedDecl::ReadInRec(D);
+void ValueDecl::ReadInRec(Deserializer& D, ASTContext& C) {
+  ScopedDecl::ReadInRec(D, C);
   DeclType = QualType::ReadVal(D);          // From ValueDecl.
 }
 
@@ -155,8 +155,8 @@
   S.EmitInt(getStorageClass());             // From VarDecl.
 }
 
-void VarDecl::ReadInRec(Deserializer& D) {
-  ValueDecl::ReadInRec(D);
+void VarDecl::ReadInRec(Deserializer& D, ASTContext& C) {
+  ValueDecl::ReadInRec(D, C);
   SClass = static_cast<StorageClass>(D.ReadInt());  // From VarDecl. 
 }
 
@@ -172,11 +172,12 @@
                        getNextDeclarator()); // From ScopedDecl.  
 }
 
-void VarDecl::ReadOutRec(Deserializer& D) {
+void VarDecl::ReadOutRec(Deserializer& D, ASTContext& C) {
   Decl* next_declarator;
   
-  D.BatchReadOwnedPtrs(Init,                           // From VarDecl.
-                       next_declarator);  // From ScopedDecl.
+  D.BatchReadOwnedPtrs(Init,             // From VarDecl.
+                       next_declarator,  // From ScopedDecl.
+                       C);
   
   setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
 }
@@ -187,20 +188,20 @@
   VarDecl::EmitOutRec(S);
 }
 
-void VarDecl::ReadImpl(Deserializer& D) {
-  ReadInRec(D);
-  ReadOutRec(D);
+void VarDecl::ReadImpl(Deserializer& D, ASTContext& C) {
+  ReadInRec(D, C);
+  ReadOutRec(D, C);
 }
 
 //===----------------------------------------------------------------------===//
 //      BlockVarDecl Serialization.
 //===----------------------------------------------------------------------===//
 
-BlockVarDecl* BlockVarDecl::CreateImpl(Deserializer& D) {  
+BlockVarDecl* BlockVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {  
   BlockVarDecl* decl = 
     new BlockVarDecl(0, SourceLocation(),NULL,QualType(),None,NULL);
  
-  decl->VarDecl::ReadImpl(D);
+  decl->VarDecl::ReadImpl(D, C);
   
   return decl;
 }
@@ -209,11 +210,11 @@
 //      FileVarDecl Serialization.
 //===----------------------------------------------------------------------===//
 
-FileVarDecl* FileVarDecl::CreateImpl(Deserializer& D) {
+FileVarDecl* FileVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   FileVarDecl* decl =
     new FileVarDecl(0, SourceLocation(),NULL,QualType(),None,NULL);
   
-  decl->VarDecl::ReadImpl(D);
+  decl->VarDecl::ReadImpl(D, C);
 
   return decl;
 }
@@ -227,11 +228,11 @@
   S.EmitInt(getObjCDeclQualifier());        // From ParmVarDecl.
 }
 
-ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D) {
+ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   ParmVarDecl* decl =
     new ParmVarDecl(0, SourceLocation(),NULL,QualType(),None,NULL);
   
-  decl->VarDecl::ReadImpl(D);
+  decl->VarDecl::ReadImpl(D, C);
   decl->objcDeclQualifier = static_cast<ObjCDeclQualifier>(D.ReadInt());
 
   return decl;
@@ -248,17 +249,17 @@
   S.BatchEmitOwnedPtrs(ElementList,getNextDeclarator());
 }
 
-EnumDecl* EnumDecl::CreateImpl(Deserializer& D) {
+EnumDecl* EnumDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   EnumDecl* decl = new EnumDecl(0, SourceLocation(),NULL,NULL);
   
-  decl->ScopedDecl::ReadInRec(D);
+  decl->ScopedDecl::ReadInRec(D, C);
   decl->setDefinition(D.ReadBool());
   decl->IntegerType = QualType::ReadVal(D);
   
   Decl* next_declarator;
   Decl* Elist;
   
-  D.BatchReadOwnedPtrs(Elist,next_declarator);
+  D.BatchReadOwnedPtrs(Elist, next_declarator, C);
   
   decl->ElementList = cast_or_null<EnumConstantDecl>(Elist);
   decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
@@ -276,7 +277,7 @@
   S.BatchEmitOwnedPtrs(getNextDeclarator(),Init);
 }
  
-EnumConstantDecl* EnumConstantDecl::CreateImpl(Deserializer& D) {
+EnumConstantDecl* EnumConstantDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   llvm::APSInt val(1);
   D.Read(val);
   
@@ -284,11 +285,11 @@
     new EnumConstantDecl(0, SourceLocation(),NULL,QualType(),NULL,
                          val,NULL);
   
-  decl->ValueDecl::ReadInRec(D);
+  decl->ValueDecl::ReadInRec(D, C);
   
   Decl* next_declarator;
   
-  D.BatchReadOwnedPtrs(next_declarator,decl->Init);
+  D.BatchReadOwnedPtrs(next_declarator, decl->Init, C);
   
   decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
 
@@ -305,11 +306,11 @@
   S.EmitOwnedPtr(BitWidth);  
 }
 
-FieldDecl* FieldDecl::CreateImpl(Deserializer& D) {
+FieldDecl* FieldDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   FieldDecl* decl = new FieldDecl(SourceLocation(), NULL, QualType(), 0);
   decl->DeclType.ReadBackpatch(D);  
-  decl->ReadInRec(D);
-  decl->BitWidth = D.ReadOwnedPtr<Expr>();
+  decl->ReadInRec(D, C);
+  decl->BitWidth = D.ReadOwnedPtr<Expr>(C);
   return decl;
 }
 
@@ -337,14 +338,14 @@
   }
 }
 
-FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D) {
+FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   StorageClass SClass = static_cast<StorageClass>(D.ReadInt());
   bool IsInline = D.ReadBool();
   
   FunctionDecl* decl =
     new FunctionDecl(0, SourceLocation(),NULL,QualType(),SClass, IsInline, 0);
   
-  decl->ValueDecl::ReadInRec(D);
+  decl->ValueDecl::ReadInRec(D, C);
   D.ReadPtr(decl->DeclChain);
 
   Decl* next_declarator;
@@ -358,9 +359,9 @@
   if (hasParamDecls)
     D.BatchReadOwnedPtrs(decl->getNumParams(),
                          reinterpret_cast<Decl**>(&decl->ParamInfo[0]),
-                         decl->Body, next_declarator);
+                         decl->Body, next_declarator, C);
   else
-    D.BatchReadOwnedPtrs(decl->Body, next_declarator);
+    D.BatchReadOwnedPtrs(decl->Body, next_declarator, C);
   
   decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
   
@@ -385,10 +386,12 @@
     ScopedDecl::EmitOutRec(S);
 }
 
-RecordDecl* RecordDecl::CreateImpl(Decl::Kind DK, Deserializer& D) {
+RecordDecl* RecordDecl::CreateImpl(Decl::Kind DK, Deserializer& D,
+                                   ASTContext& C) {
+
   RecordDecl* decl = new RecordDecl(DK,0,SourceLocation(),NULL,NULL);
     
-  decl->ScopedDecl::ReadInRec(D);
+  decl->ScopedDecl::ReadInRec(D, C);
   decl->setDefinition(D.ReadBool());
   decl->setHasFlexibleArrayMember(D.ReadBool());
   decl->NumMembers = D.ReadSInt();
@@ -399,12 +402,12 @@
                               
     D.BatchReadOwnedPtrs((unsigned) decl->getNumMembers(),
                          (Decl**) &decl->Members[0],
-                         next_declarator);
+                         next_declarator, C);
     
     decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));                             
   }
   else
-    decl->ScopedDecl::ReadOutRec(D);
+    decl->ScopedDecl::ReadOutRec(D, C);
   
   return decl;
 }
@@ -419,13 +422,13 @@
   ScopedDecl::EmitOutRec(S);
 }
 
-TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D) {
+TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType T = QualType::ReadVal(D);
   
   TypedefDecl* decl = new TypedefDecl(0, SourceLocation(),NULL,T,NULL);
   
-  decl->ScopedDecl::ReadInRec(D);
-  decl->ScopedDecl::ReadOutRec(D);
+  decl->ScopedDecl::ReadInRec(D, C);
+  decl->ScopedDecl::ReadOutRec(D, C);
 
   return decl;
 }
@@ -440,8 +443,8 @@
   S.EmitPtr(D);
 }
 
-void LinkageSpecDecl::ReadInRec(Deserializer& D) {
-  Decl::ReadInRec(D);
+void LinkageSpecDecl::ReadInRec(Deserializer& D, ASTContext& C) {
+  Decl::ReadInRec(D, C);
   Language = static_cast<LanguageIDs>(D.ReadInt());
   D.ReadPtr(this->D);
 }
@@ -456,11 +459,11 @@
   S.EmitOwnedPtr(AsmString);
 }
 
-FileScopeAsmDecl* FileScopeAsmDecl::CreateImpl(Deserializer& D) { 
+FileScopeAsmDecl* FileScopeAsmDecl::CreateImpl(Deserializer& D, ASTContext& C) { 
   FileScopeAsmDecl* decl = new FileScopeAsmDecl(SourceLocation(), 0);
 
-  decl->Decl::ReadInRec(D);
-  decl->AsmString = cast<StringLiteral>(D.ReadOwnedPtr<Expr>());
+  decl->Decl::ReadInRec(D, C);
+  decl->AsmString = cast<StringLiteral>(D.ReadOwnedPtr<Expr>(C));
 //  D.ReadOwnedPtr(D.ReadOwnedPtr<StringLiteral>())<#T * * Ptr#>, <#bool AutoRegister#>)(decl->AsmString);
   
   return decl;

Modified: cfe/trunk/lib/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtSerialization.cpp?rev=49353&r1=49352&r2=49353&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/lib/AST/StmtSerialization.cpp Mon Apr  7 16:55:54 2008
@@ -27,7 +27,7 @@
   S.FlushRecord();
 }  
 
-Stmt* Stmt::Create(Deserializer& D) {
+Stmt* Stmt::Create(Deserializer& D, ASTContext& C) {
   StmtClass SC = static_cast<StmtClass>(D.ReadInt());
   
   switch (SC) {
@@ -36,155 +36,155 @@
       return NULL;
     
     case AddrLabelExprClass:
-      return AddrLabelExpr::CreateImpl(D);
+      return AddrLabelExpr::CreateImpl(D, C);
       
     case ArraySubscriptExprClass:
-      return ArraySubscriptExpr::CreateImpl(D);
+      return ArraySubscriptExpr::CreateImpl(D, C);
       
     case AsmStmtClass:
-      return AsmStmt::CreateImpl(D);
+      return AsmStmt::CreateImpl(D, C);
       
     case BinaryOperatorClass:
-      return BinaryOperator::CreateImpl(D);
+      return BinaryOperator::CreateImpl(D, C);
       
     case BreakStmtClass:
-      return BreakStmt::CreateImpl(D);
+      return BreakStmt::CreateImpl(D, C);
      
     case CallExprClass:
-      return CallExpr::CreateImpl(D);
+      return CallExpr::CreateImpl(D, C);
       
     case CaseStmtClass:
-      return CaseStmt::CreateImpl(D);
+      return CaseStmt::CreateImpl(D, C);
     
     case CastExprClass:
-      return CastExpr::CreateImpl(D);
+      return CastExpr::CreateImpl(D, C);
       
     case CharacterLiteralClass:
-      return CharacterLiteral::CreateImpl(D);
+      return CharacterLiteral::CreateImpl(D, C);
       
     case CompoundAssignOperatorClass:
-      return CompoundAssignOperator::CreateImpl(D);
+      return CompoundAssignOperator::CreateImpl(D, C);
       
     case CompoundLiteralExprClass:
-      return CompoundLiteralExpr::CreateImpl(D);
+      return CompoundLiteralExpr::CreateImpl(D, C);
       
     case CompoundStmtClass:
-      return CompoundStmt::CreateImpl(D);
+      return CompoundStmt::CreateImpl(D, C);
     
     case ConditionalOperatorClass:
-      return ConditionalOperator::CreateImpl(D);
+      return ConditionalOperator::CreateImpl(D, C);
       
     case ContinueStmtClass:
-      return ContinueStmt::CreateImpl(D);
+      return ContinueStmt::CreateImpl(D, C);
       
     case DeclRefExprClass:
-      return DeclRefExpr::CreateImpl(D);
+      return DeclRefExpr::CreateImpl(D, C);
       
     case DeclStmtClass:
-      return DeclStmt::CreateImpl(D);
+      return DeclStmt::CreateImpl(D, C);
       
     case DefaultStmtClass:
-      return DefaultStmt::CreateImpl(D);
+      return DefaultStmt::CreateImpl(D, C);
     
     case DoStmtClass:
-      return DoStmt::CreateImpl(D);
+      return DoStmt::CreateImpl(D, C);
       
     case FloatingLiteralClass:
-      return FloatingLiteral::CreateImpl(D);
+      return FloatingLiteral::CreateImpl(D, C);
 
     case ForStmtClass:
-      return ForStmt::CreateImpl(D);
+      return ForStmt::CreateImpl(D, C);
     
     case GotoStmtClass:
-      return GotoStmt::CreateImpl(D);
+      return GotoStmt::CreateImpl(D, C);
       
     case IfStmtClass:
-      return IfStmt::CreateImpl(D);
+      return IfStmt::CreateImpl(D, C);
     
     case ImaginaryLiteralClass:
-      return ImaginaryLiteral::CreateImpl(D);
+      return ImaginaryLiteral::CreateImpl(D, C);
       
     case ImplicitCastExprClass:
-      return ImplicitCastExpr::CreateImpl(D);
+      return ImplicitCastExpr::CreateImpl(D, C);
       
     case IndirectGotoStmtClass:
-      return IndirectGotoStmt::CreateImpl(D);
+      return IndirectGotoStmt::CreateImpl(D, C);
       
     case InitListExprClass:
-      return InitListExpr::CreateImpl(D);
+      return InitListExpr::CreateImpl(D, C);
       
     case IntegerLiteralClass:
-      return IntegerLiteral::CreateImpl(D);
+      return IntegerLiteral::CreateImpl(D, C);
       
     case LabelStmtClass:
-      return LabelStmt::CreateImpl(D);
+      return LabelStmt::CreateImpl(D, C);
       
     case MemberExprClass:
-      return MemberExpr::CreateImpl(D);
+      return MemberExpr::CreateImpl(D, C);
       
     case NullStmtClass:
-      return NullStmt::CreateImpl(D);
+      return NullStmt::CreateImpl(D, C);
       
     case ParenExprClass:
-      return ParenExpr::CreateImpl(D);
+      return ParenExpr::CreateImpl(D, C);
       
     case PreDefinedExprClass:
-      return PreDefinedExpr::CreateImpl(D);
+      return PreDefinedExpr::CreateImpl(D, C);
       
     case ReturnStmtClass:
-      return ReturnStmt::CreateImpl(D);
+      return ReturnStmt::CreateImpl(D, C);
     
     case SizeOfAlignOfTypeExprClass:
-      return SizeOfAlignOfTypeExpr::CreateImpl(D);
+      return SizeOfAlignOfTypeExpr::CreateImpl(D, C);
       
     case StmtExprClass:
-      return StmtExpr::CreateImpl(D);
+      return StmtExpr::CreateImpl(D, C);
       
     case StringLiteralClass:
-      return StringLiteral::CreateImpl(D);
+      return StringLiteral::CreateImpl(D, C);
       
     case SwitchStmtClass:
-      return SwitchStmt::CreateImpl(D);
+      return SwitchStmt::CreateImpl(D, C);
       
     case UnaryOperatorClass:
-      return UnaryOperator::CreateImpl(D);
+      return UnaryOperator::CreateImpl(D, C);
       
     case WhileStmtClass:
-      return WhileStmt::CreateImpl(D);
+      return WhileStmt::CreateImpl(D, C);
       
     //==--------------------------------------==//
     //    Objective C
     //==--------------------------------------==//
     
     case ObjCAtCatchStmtClass:
-      return ObjCAtCatchStmt::CreateImpl(D);
+      return ObjCAtCatchStmt::CreateImpl(D, C);
       
     case ObjCAtFinallyStmtClass:
-      return ObjCAtFinallyStmt::CreateImpl(D);
+      return ObjCAtFinallyStmt::CreateImpl(D, C);
     
     case ObjCAtSynchronizedStmtClass:
-      return ObjCAtSynchronizedStmt::CreateImpl(D);
+      return ObjCAtSynchronizedStmt::CreateImpl(D, C);
       
     case ObjCAtThrowStmtClass:
-      return ObjCAtThrowStmt::CreateImpl(D);
+      return ObjCAtThrowStmt::CreateImpl(D, C);
       
     case ObjCAtTryStmtClass:
-      return ObjCAtTryStmt::CreateImpl(D);
+      return ObjCAtTryStmt::CreateImpl(D, C);
     
     case ObjCEncodeExprClass:
-      return ObjCEncodeExpr::CreateImpl(D);
+      return ObjCEncodeExpr::CreateImpl(D, C);
       
     case ObjCForCollectionStmtClass:
-      return ObjCForCollectionStmt::CreateImpl(D);
+      return ObjCForCollectionStmt::CreateImpl(D, C);
       
     case ObjCIvarRefExprClass:
-      return ObjCIvarRefExpr::CreateImpl(D);
+      return ObjCIvarRefExpr::CreateImpl(D, C);
       
     case ObjCSelectorExprClass:
-      return ObjCSelectorExpr::CreateImpl(D);
+      return ObjCSelectorExpr::CreateImpl(D, C);
       
     case ObjCStringLiteralClass:
-      return ObjCStringLiteral::CreateImpl(D);
+      return ObjCStringLiteral::CreateImpl(D, C);
   }
 }
 
@@ -199,7 +199,7 @@
   S.EmitPtr(Label);
 }
 
-AddrLabelExpr* AddrLabelExpr::CreateImpl(Deserializer& D) {
+AddrLabelExpr* AddrLabelExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
   SourceLocation AALoc = SourceLocation::ReadVal(D);
   SourceLocation LLoc = SourceLocation::ReadVal(D);
@@ -214,11 +214,11 @@
   S.BatchEmitOwnedPtrs(getLHS(),getRHS());
 }
 
-ArraySubscriptExpr* ArraySubscriptExpr::CreateImpl(Deserializer& D) {
+ArraySubscriptExpr* ArraySubscriptExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
   SourceLocation L = SourceLocation::ReadVal(D);
   Expr *LHS, *RHS;
-  D.BatchReadOwnedPtrs(LHS,RHS);
+  D.BatchReadOwnedPtrs(LHS, RHS, C);
   return new ArraySubscriptExpr(LHS,RHS,t,L);  
 }
 
@@ -249,9 +249,9 @@
     Clobbers[i]->EmitImpl(S);
 }
 
-AsmStmt* AsmStmt::CreateImpl(Deserializer& D) {
+AsmStmt* AsmStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation ALoc = SourceLocation::ReadVal(D);
-  StringLiteral *AsmStr = StringLiteral::CreateImpl(D);
+  StringLiteral *AsmStr = StringLiteral::CreateImpl(D, C);
   SourceLocation PLoc = SourceLocation::ReadVal(D);
   
   bool IsVolatile = D.ReadBool();
@@ -275,16 +275,16 @@
 
   Stmt->Constraints.reserve(size);
   for (unsigned i = 0; i < size; ++i)
-    Stmt->Constraints.push_back(StringLiteral::CreateImpl(D));
+    Stmt->Constraints.push_back(StringLiteral::CreateImpl(D, C));
   
   Stmt->Exprs.reserve(size);
   for (unsigned i = 0; i < size; ++i)
-    Stmt->Exprs.push_back(D.ReadOwnedPtr<Expr>());
+    Stmt->Exprs.push_back(D.ReadOwnedPtr<Expr>(C));
   
   unsigned NumClobbers = D.ReadInt();
   Stmt->Clobbers.reserve(NumClobbers);
   for (unsigned i = 0; i < NumClobbers; ++i)
-    Stmt->Clobbers.push_back(StringLiteral::CreateImpl(D));
+    Stmt->Clobbers.push_back(StringLiteral::CreateImpl(D, C));
   
   return Stmt;
 }
@@ -296,12 +296,12 @@
   S.BatchEmitOwnedPtrs(getLHS(),getRHS());
 }
 
-BinaryOperator* BinaryOperator::CreateImpl(Deserializer& D) {
+BinaryOperator* BinaryOperator::CreateImpl(Deserializer& D, ASTContext& C) {
   Opcode Opc = static_cast<Opcode>(D.ReadInt());
   SourceLocation OpLoc = SourceLocation::ReadVal(D);
   QualType Result = QualType::ReadVal(D);
   Expr *LHS, *RHS;
-  D.BatchReadOwnedPtrs(LHS,RHS);
+  D.BatchReadOwnedPtrs(LHS, RHS, C);
 
   return new BinaryOperator(LHS,RHS,Opc,Result,OpLoc);
 }
@@ -310,7 +310,7 @@
   S.Emit(BreakLoc);
 }
 
-BreakStmt* BreakStmt::CreateImpl(Deserializer& D) {
+BreakStmt* BreakStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
   return new BreakStmt(Loc);
 }
@@ -322,12 +322,12 @@
   S.BatchEmitOwnedPtrs(NumArgs+1,SubExprs);  
 }
 
-CallExpr* CallExpr::CreateImpl(Deserializer& D) {
+CallExpr* CallExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
   SourceLocation L = SourceLocation::ReadVal(D);
   unsigned NumArgs = D.ReadInt();
   Expr** SubExprs = new Expr*[NumArgs+1];
-  D.BatchReadOwnedPtrs(NumArgs+1,SubExprs);
+  D.BatchReadOwnedPtrs(NumArgs+1, SubExprs, C);
 
   return new CallExpr(SubExprs,NumArgs,t,L);  
 }
@@ -338,11 +338,11 @@
   S.BatchEmitOwnedPtrs((unsigned) END_EXPR,&SubExprs[0]);
 }
 
-CaseStmt* CaseStmt::CreateImpl(Deserializer& D) {
+CaseStmt* CaseStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation CaseLoc = SourceLocation::ReadVal(D);
   CaseStmt* stmt = new CaseStmt(NULL,NULL,NULL,CaseLoc);  
   D.ReadPtr(stmt->NextSwitchCase);
-  D.BatchReadOwnedPtrs((unsigned) END_EXPR,&stmt->SubExprs[0]);
+  D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0], C);
   return stmt;
 }
 
@@ -352,10 +352,10 @@
   S.EmitOwnedPtr(Op);
 }
 
-CastExpr* CastExpr::CreateImpl(Deserializer& D) {
+CastExpr* CastExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
   SourceLocation Loc = SourceLocation::ReadVal(D);
-  Expr* Op = D.ReadOwnedPtr<Expr>();
+  Expr* Op = D.ReadOwnedPtr<Expr>(C);
   return new CastExpr(t,Op,Loc);
 }
   
@@ -366,7 +366,7 @@
   S.Emit(getType());
 }
 
-CharacterLiteral* CharacterLiteral::CreateImpl(Deserializer& D) {
+CharacterLiteral* CharacterLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
   unsigned value = D.ReadInt();
   SourceLocation Loc = SourceLocation::ReadVal(D);
   QualType T = QualType::ReadVal(D);
@@ -382,13 +382,13 @@
 }
 
 CompoundAssignOperator* 
-CompoundAssignOperator::CreateImpl(Deserializer& D) {
+CompoundAssignOperator::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
   QualType c = QualType::ReadVal(D);
   SourceLocation L = SourceLocation::ReadVal(D);
   Opcode Opc = static_cast<Opcode>(D.ReadInt());
   Expr* LHS, *RHS;
-  D.BatchReadOwnedPtrs(LHS,RHS);
+  D.BatchReadOwnedPtrs(LHS, RHS, C);
   
   return new CompoundAssignOperator(LHS,RHS,Opc,t,c,L);
 }
@@ -400,11 +400,11 @@
   S.EmitOwnedPtr(Init);
 }
 
-CompoundLiteralExpr* CompoundLiteralExpr::CreateImpl(Deserializer& D) {
+CompoundLiteralExpr* CompoundLiteralExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType Q = QualType::ReadVal(D);
   SourceLocation L = SourceLocation::ReadVal(D);
   bool fileScope = D.ReadBool();
-  Expr* Init = D.ReadOwnedPtr<Expr>();
+  Expr* Init = D.ReadOwnedPtr<Expr>(C);
   return new CompoundLiteralExpr(L, Q, Init, fileScope);
 }
 
@@ -417,7 +417,7 @@
     S.EmitOwnedPtr(*I);
 }
 
-CompoundStmt* CompoundStmt::CreateImpl(Deserializer& D) {
+CompoundStmt* CompoundStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation LB = SourceLocation::ReadVal(D);
   SourceLocation RB = SourceLocation::ReadVal(D);
   unsigned size = D.ReadInt();
@@ -427,7 +427,7 @@
   stmt->Body.reserve(size);
   
   for (unsigned i = 0; i < size; ++i)
-    stmt->Body.push_back(D.ReadOwnedPtr<Stmt>());
+    stmt->Body.push_back(D.ReadOwnedPtr<Stmt>(C));
   
   return stmt;
 }
@@ -437,10 +437,12 @@
   S.BatchEmitOwnedPtrs((unsigned) END_EXPR, SubExprs);
 }
 
-ConditionalOperator* ConditionalOperator::CreateImpl(Deserializer& D) {
+ConditionalOperator* ConditionalOperator::CreateImpl(Deserializer& D,
+                                                     ASTContext& C) {
+
   QualType t = QualType::ReadVal(D);
   ConditionalOperator* c = new ConditionalOperator(NULL,NULL,NULL,t);
-  D.BatchReadOwnedPtrs((unsigned) END_EXPR, c->SubExprs);
+  D.BatchReadOwnedPtrs((unsigned) END_EXPR, c->SubExprs, C);
   return c;
 }
 
@@ -448,7 +450,7 @@
   S.Emit(ContinueLoc);
 }
 
-ContinueStmt* ContinueStmt::CreateImpl(Deserializer& D) {
+ContinueStmt* ContinueStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
   return new ContinueStmt(Loc);
 }
@@ -490,7 +492,7 @@
   }
 }
 
-DeclRefExpr* DeclRefExpr::CreateImpl(Deserializer& D) {
+DeclRefExpr* DeclRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
   QualType T = QualType::ReadVal(D);  
   bool OwnsDecl = D.ReadBool();
@@ -499,14 +501,13 @@
   if (!OwnsDecl)
     D.ReadPtr(decl,false); // No backpatching.
   else
-    decl = cast<ValueDecl>(D.ReadOwnedPtr<Decl>());
+    decl = cast<ValueDecl>(D.ReadOwnedPtr<Decl>(C));
   
   return new DeclRefExpr(decl,T,Loc);
 }
 
-
-DeclStmt* DeclStmt::CreateImpl(Deserializer& D) {
-  ScopedDecl* decl = cast<ScopedDecl>(D.ReadOwnedPtr<Decl>());
+DeclStmt* DeclStmt::CreateImpl(Deserializer& D, ASTContext& C) {
+  ScopedDecl* decl = cast<ScopedDecl>(D.ReadOwnedPtr<Decl>(C));
   SourceLocation StartLoc = SourceLocation::ReadVal(D);
   SourceLocation EndLoc = SourceLocation::ReadVal(D);
   return new DeclStmt(decl, StartLoc, EndLoc);
@@ -518,9 +519,9 @@
   S.EmitPtr(getNextSwitchCase());
 }
 
-DefaultStmt* DefaultStmt::CreateImpl(Deserializer& D) {
+DefaultStmt* DefaultStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
-  Stmt* SubStmt = D.ReadOwnedPtr<Stmt>();
+  Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(C);
   
   DefaultStmt* stmt = new DefaultStmt(Loc,SubStmt);
   stmt->setNextSwitchCase(D.ReadPtr<SwitchCase>());
@@ -534,10 +535,10 @@
   S.EmitOwnedPtr(getBody());
 }
 
-DoStmt* DoStmt::CreateImpl(Deserializer& D) {
+DoStmt* DoStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation DoLoc = SourceLocation::ReadVal(D);
-  Expr* Cond = D.ReadOwnedPtr<Expr>();
-  Stmt* Body = D.ReadOwnedPtr<Stmt>();
+  Expr* Cond = D.ReadOwnedPtr<Expr>(C);
+  Stmt* Body = D.ReadOwnedPtr<Stmt>(C);
   return new DoStmt(Body,Cond,DoLoc);
 }
 
@@ -548,7 +549,7 @@
   S.Emit(Value);
 }
 
-FloatingLiteral* FloatingLiteral::CreateImpl(Deserializer& D) {
+FloatingLiteral* FloatingLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
   QualType t = QualType::ReadVal(D);
   bool isExact = D.ReadBool();
@@ -565,12 +566,12 @@
   S.EmitOwnedPtr(getBody());
 }
 
-ForStmt* ForStmt::CreateImpl(Deserializer& D) {
+ForStmt* ForStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation ForLoc = SourceLocation::ReadVal(D);
-  Stmt* Init = D.ReadOwnedPtr<Stmt>();
-  Expr* Cond = D.ReadOwnedPtr<Expr>();
-  Expr* Inc = D.ReadOwnedPtr<Expr>();
-  Stmt* Body = D.ReadOwnedPtr<Stmt>();
+  Stmt* Init = D.ReadOwnedPtr<Stmt>(C);
+  Expr* Cond = D.ReadOwnedPtr<Expr>(C);
+  Expr* Inc = D.ReadOwnedPtr<Expr>(C);
+  Stmt* Body = D.ReadOwnedPtr<Stmt>(C);
   return new ForStmt(Init,Cond,Inc,Body,ForLoc);
 }
 
@@ -580,7 +581,7 @@
   S.EmitPtr(Label);
 }
 
-GotoStmt* GotoStmt::CreateImpl(Deserializer& D) {
+GotoStmt* GotoStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation GotoLoc = SourceLocation::ReadVal(D);
   SourceLocation LabelLoc = SourceLocation::ReadVal(D);
   GotoStmt* stmt = new GotoStmt(NULL,GotoLoc,LabelLoc);
@@ -595,11 +596,11 @@
   S.EmitOwnedPtr(getElse());
 }
 
-IfStmt* IfStmt::CreateImpl(Deserializer& D) {
+IfStmt* IfStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation L = SourceLocation::ReadVal(D);
-  Expr* Cond = D.ReadOwnedPtr<Expr>();
-  Stmt* Then = D.ReadOwnedPtr<Stmt>();
-  Stmt* Else = D.ReadOwnedPtr<Stmt>();
+  Expr* Cond = D.ReadOwnedPtr<Expr>(C);
+  Stmt* Then = D.ReadOwnedPtr<Stmt>(C);
+  Stmt* Else = D.ReadOwnedPtr<Stmt>(C);
   return new IfStmt(L,Cond,Then,Else);
 }
 
@@ -608,9 +609,9 @@
   S.EmitOwnedPtr(Val);    
 }
 
-ImaginaryLiteral* ImaginaryLiteral::CreateImpl(Deserializer& D) {
+ImaginaryLiteral* ImaginaryLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
-  Expr* expr = D.ReadOwnedPtr<Expr>();
+  Expr* expr = D.ReadOwnedPtr<Expr>(C);
   assert (isa<FloatingLiteral>(expr) || isa<IntegerLiteral>(expr));
   return new ImaginaryLiteral(expr,t);
 }
@@ -620,9 +621,9 @@
   S.EmitOwnedPtr(Op);
 }
 
-ImplicitCastExpr* ImplicitCastExpr::CreateImpl(Deserializer& D) {
+ImplicitCastExpr* ImplicitCastExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
-  Expr* Op = D.ReadOwnedPtr<Expr>();
+  Expr* Op = D.ReadOwnedPtr<Expr>(C);
   return new ImplicitCastExpr(t,Op);
 }
 
@@ -630,8 +631,8 @@
   S.EmitOwnedPtr(Target);  
 }
 
-IndirectGotoStmt* IndirectGotoStmt::CreateImpl(Deserializer& D) {
-  Expr* Target = D.ReadOwnedPtr<Expr>();
+IndirectGotoStmt* IndirectGotoStmt::CreateImpl(Deserializer& D, ASTContext& C) {
+  Expr* Target = D.ReadOwnedPtr<Expr>(C);
   return new IndirectGotoStmt(Target);
 }
 
@@ -642,14 +643,14 @@
   S.BatchEmitOwnedPtrs(NumInits,InitExprs);
 }
 
-InitListExpr* InitListExpr::CreateImpl(Deserializer& D) {
+InitListExpr* InitListExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   InitListExpr* expr = new InitListExpr();
   expr->LBraceLoc = SourceLocation::ReadVal(D);
   expr->RBraceLoc = SourceLocation::ReadVal(D);
   expr->NumInits = D.ReadInt();
   assert(expr->NumInits);
   expr->InitExprs = new Expr*[expr->NumInits];
-  D.BatchReadOwnedPtrs(expr->NumInits,expr->InitExprs);
+  D.BatchReadOwnedPtrs(expr->NumInits, expr->InitExprs, C);
   return expr;
 }
 
@@ -659,7 +660,7 @@
   S.Emit(getValue());
 }
 
-IntegerLiteral* IntegerLiteral::CreateImpl(Deserializer& D) {
+IntegerLiteral* IntegerLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
   QualType T = QualType::ReadVal(D);
   
@@ -678,10 +679,10 @@
   S.EmitOwnedPtr(SubStmt);
 }
 
-LabelStmt* LabelStmt::CreateImpl(Deserializer& D) {
+LabelStmt* LabelStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   IdentifierInfo* Label = D.ReadPtr<IdentifierInfo>();
   SourceLocation IdentLoc = SourceLocation::ReadVal(D);
-  Stmt* SubStmt = D.ReadOwnedPtr<Stmt>();
+  Stmt* SubStmt = D.ReadOwnedPtr<Stmt>(C);
   return new LabelStmt(IdentLoc,Label,SubStmt);
 }
 
@@ -693,12 +694,12 @@
   S.EmitOwnedPtr(Base);
 }
 
-MemberExpr* MemberExpr::CreateImpl(Deserializer& D) {
+MemberExpr* MemberExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation L = SourceLocation::ReadVal(D);
   FieldDecl* MemberDecl = cast<FieldDecl>(D.ReadPtr<Decl>());
   bool IsArrow = D.ReadBool();
   QualType T = QualType::ReadVal(D);
-  Expr* base = D.ReadOwnedPtr<Expr>();
+  Expr* base = D.ReadOwnedPtr<Expr>(C);
   
   return new MemberExpr(base,IsArrow,MemberDecl,L,T); 
 }
@@ -707,7 +708,7 @@
   S.Emit(SemiLoc);
 }
 
-NullStmt* NullStmt::CreateImpl(Deserializer& D) {
+NullStmt* NullStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation SemiLoc = SourceLocation::ReadVal(D);
   return new NullStmt(SemiLoc);
 }
@@ -718,10 +719,10 @@
   S.EmitOwnedPtr(Val);
 }
 
-ParenExpr* ParenExpr::CreateImpl(Deserializer& D) {
+ParenExpr* ParenExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation L = SourceLocation::ReadVal(D);
   SourceLocation R = SourceLocation::ReadVal(D);
-  Expr* val = D.ReadOwnedPtr<Expr>();  
+  Expr* val = D.ReadOwnedPtr<Expr>(C);
   return new ParenExpr(L,R,val);
 }
 
@@ -731,7 +732,7 @@
   S.Emit(getType());  
 }
 
-PreDefinedExpr* PreDefinedExpr::CreateImpl(Deserializer& D) {
+PreDefinedExpr* PreDefinedExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
   IdentType it = static_cast<IdentType>(D.ReadInt());
   QualType Q = QualType::ReadVal(D);
@@ -743,9 +744,9 @@
   S.EmitOwnedPtr(RetExpr);
 }
 
-ReturnStmt* ReturnStmt::CreateImpl(Deserializer& D) {
+ReturnStmt* ReturnStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation RetLoc = SourceLocation::ReadVal(D);
-  Expr* RetExpr = D.ReadOwnedPtr<Expr>();  
+  Expr* RetExpr = D.ReadOwnedPtr<Expr>(C);
   return new ReturnStmt(RetLoc,RetExpr);
 }
 
@@ -757,7 +758,7 @@
   S.Emit(RParenLoc);
 }
 
-SizeOfAlignOfTypeExpr* SizeOfAlignOfTypeExpr::CreateImpl(Deserializer& D) {
+SizeOfAlignOfTypeExpr* SizeOfAlignOfTypeExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   bool isSizeof = D.ReadBool();
   QualType Ty = QualType::ReadVal(D);
   QualType Res = QualType::ReadVal(D);
@@ -774,11 +775,11 @@
   S.EmitOwnedPtr(SubStmt);
 }
 
-StmtExpr* StmtExpr::CreateImpl(Deserializer& D) {
+StmtExpr* StmtExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
   SourceLocation L = SourceLocation::ReadVal(D);
   SourceLocation R = SourceLocation::ReadVal(D);
-  CompoundStmt* SubStmt = cast<CompoundStmt>(D.ReadOwnedPtr<Stmt>());
+  CompoundStmt* SubStmt = cast<CompoundStmt>(D.ReadOwnedPtr<Stmt>(C));
   return new StmtExpr(SubStmt,t,L,R);
 }
 
@@ -793,7 +794,7 @@
     S.EmitInt(StrData[i]);
 }
 
-StringLiteral* StringLiteral::CreateImpl(Deserializer& D) {
+StringLiteral* StringLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
   SourceLocation firstTokLoc = SourceLocation::ReadVal(D);
   SourceLocation lastTokLoc = SourceLocation::ReadVal(D);
@@ -819,10 +820,10 @@
   S.EmitPtr(FirstCase);  
 }
 
-SwitchStmt* SwitchStmt::CreateImpl(Deserializer& D) {
+SwitchStmt* SwitchStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
-  Stmt* Cond = D.ReadOwnedPtr<Stmt>();
-  Stmt* Body = D.ReadOwnedPtr<Stmt>();
+  Stmt* Cond = D.ReadOwnedPtr<Stmt>(C);
+  Stmt* Body = D.ReadOwnedPtr<Stmt>(C);
   SwitchCase* FirstCase = cast<SwitchCase>(D.ReadPtr<Stmt>());
   
   SwitchStmt* stmt = new SwitchStmt(cast<Expr>(Cond));
@@ -839,11 +840,11 @@
   S.EmitOwnedPtr(Val);
 }
 
-UnaryOperator* UnaryOperator::CreateImpl(Deserializer& D) {
+UnaryOperator* UnaryOperator::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
   SourceLocation L = SourceLocation::ReadVal(D);
   Opcode Opc = static_cast<Opcode>(D.ReadInt());
-  Expr* Val = D.ReadOwnedPtr<Expr>();
+  Expr* Val = D.ReadOwnedPtr<Expr>(C);
   return new UnaryOperator(Val,Opc,t,L);
 }
 
@@ -853,10 +854,10 @@
   S.EmitOwnedPtr(getBody());
 }
 
-WhileStmt* WhileStmt::CreateImpl(Deserializer& D) {
+WhileStmt* WhileStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation WhileLoc = SourceLocation::ReadVal(D);
-  Expr* Cond = D.ReadOwnedPtr<Expr>();
-  Stmt* Body = D.ReadOwnedPtr<Stmt>();
+  Expr* Cond = D.ReadOwnedPtr<Expr>(C);
+  Stmt* Body = D.ReadOwnedPtr<Stmt>(C);
   return new WhileStmt(Cond,Body,WhileLoc);
 }
 
@@ -870,12 +871,12 @@
   S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubExprs[0]);
 }
 
-ObjCAtCatchStmt* ObjCAtCatchStmt::CreateImpl(Deserializer& D) {
+ObjCAtCatchStmt* ObjCAtCatchStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation AtCatchLoc = SourceLocation::ReadVal(D);
   SourceLocation RParenLoc = SourceLocation::ReadVal(D);
   
   ObjCAtCatchStmt* stmt = new ObjCAtCatchStmt(AtCatchLoc,RParenLoc);
-  D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0]);
+  D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubExprs[0], C);
 
   return stmt;
 }
@@ -885,9 +886,9 @@
   S.EmitOwnedPtr(AtFinallyStmt);
 }
 
-ObjCAtFinallyStmt* ObjCAtFinallyStmt::CreateImpl(Deserializer& D) {
+ObjCAtFinallyStmt* ObjCAtFinallyStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
-  Stmt* AtFinallyStmt = D.ReadOwnedPtr<Stmt>();
+  Stmt* AtFinallyStmt = D.ReadOwnedPtr<Stmt>(C);
   return new ObjCAtFinallyStmt(Loc,AtFinallyStmt);  
 }
 
@@ -896,10 +897,12 @@
   S.BatchEmitOwnedPtrs((unsigned) END_EXPR,&SubStmts[0]);
  }
 
-ObjCAtSynchronizedStmt* ObjCAtSynchronizedStmt::CreateImpl(Deserializer& D) {
+ObjCAtSynchronizedStmt* ObjCAtSynchronizedStmt::CreateImpl(Deserializer& D,
+                                                           ASTContext& C) {
+
   SourceLocation L = SourceLocation::ReadVal(D);
   ObjCAtSynchronizedStmt* stmt = new ObjCAtSynchronizedStmt(L,0,0);
-  D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0]);
+  D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0], C);
   return stmt;
 }
 
@@ -908,9 +911,9 @@
   S.EmitOwnedPtr(Throw);
 }
 
-ObjCAtThrowStmt* ObjCAtThrowStmt::CreateImpl(Deserializer& D) {
+ObjCAtThrowStmt* ObjCAtThrowStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation L = SourceLocation::ReadVal(D);
-  Stmt* Throw = D.ReadOwnedPtr<Stmt>();
+  Stmt* Throw = D.ReadOwnedPtr<Stmt>(C);
   return new ObjCAtThrowStmt(L,Throw);  
 }
   
@@ -919,10 +922,10 @@
   S.BatchEmitOwnedPtrs((unsigned) END_EXPR, &SubStmts[0]);
 }
 
-ObjCAtTryStmt* ObjCAtTryStmt::CreateImpl(Deserializer& D) {
+ObjCAtTryStmt* ObjCAtTryStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation L = SourceLocation::ReadVal(D);
   ObjCAtTryStmt* stmt = new ObjCAtTryStmt(L,NULL,NULL,NULL);
-  D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0]);
+  D.BatchReadOwnedPtrs((unsigned) END_EXPR, &stmt->SubStmts[0], C);
   return stmt;
 }
 
@@ -933,7 +936,7 @@
   S.Emit(EncType);
 }
 
-ObjCEncodeExpr* ObjCEncodeExpr::CreateImpl(Deserializer& D) {
+ObjCEncodeExpr* ObjCEncodeExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation AtLoc = SourceLocation::ReadVal(D);
   SourceLocation RParenLoc = SourceLocation::ReadVal(D);  
   QualType T = QualType::ReadVal(D);
@@ -947,13 +950,13 @@
   S.BatchEmitOwnedPtrs(getElement(),getCollection(),getBody());
 }
 
-ObjCForCollectionStmt* ObjCForCollectionStmt::CreateImpl(Deserializer& D) {
+ObjCForCollectionStmt* ObjCForCollectionStmt::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation ForLoc = SourceLocation::ReadVal(D);
   SourceLocation RParenLoc = SourceLocation::ReadVal(D);
   Stmt* Element;
   Expr* Collection;
   Stmt* Body;
-  D.BatchReadOwnedPtrs(Element,Collection,Body);  
+  D.BatchReadOwnedPtrs(Element, Collection, Body, C);
   return new ObjCForCollectionStmt(Element,Collection,Body,ForLoc, RParenLoc);
 }
 
@@ -963,7 +966,7 @@
   S.EmitPtr(getDecl());
 }
   
-ObjCIvarRefExpr* ObjCIvarRefExpr::CreateImpl(Deserializer& D) {
+ObjCIvarRefExpr* ObjCIvarRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation Loc = SourceLocation::ReadVal(D);
   QualType T = QualType::ReadVal(D);
   ObjCIvarRefExpr* dr = new ObjCIvarRefExpr(NULL,T,Loc);
@@ -978,7 +981,7 @@
   S.Emit(SelName);
 }
 
-ObjCSelectorExpr* ObjCSelectorExpr::CreateImpl(Deserializer& D) {
+ObjCSelectorExpr* ObjCSelectorExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation AtLoc = SourceLocation::ReadVal(D);
   SourceLocation RParenLoc = SourceLocation::ReadVal(D);
   QualType T = QualType::ReadVal(D);
@@ -993,9 +996,9 @@
   S.EmitOwnedPtr(String);
 }
 
-ObjCStringLiteral* ObjCStringLiteral::CreateImpl(Deserializer& D) {
+ObjCStringLiteral* ObjCStringLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
   SourceLocation L = SourceLocation::ReadVal(D);
   QualType T = QualType::ReadVal(D);
-  StringLiteral* String = cast<StringLiteral>(D.ReadOwnedPtr<Stmt>());
+  StringLiteral* String = cast<StringLiteral>(D.ReadOwnedPtr<Stmt>(C));
   return new ObjCStringLiteral(String,T,L);
 }

Modified: cfe/trunk/lib/AST/TranslationUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TranslationUnit.cpp?rev=49353&r1=49352&r2=49353&view=diff

==============================================================================
--- cfe/trunk/lib/AST/TranslationUnit.cpp (original)
+++ cfe/trunk/lib/AST/TranslationUnit.cpp Mon Apr  7 16:55:54 2008
@@ -221,7 +221,7 @@
   llvm::Deserializer::Location DeclBlockLoc = Dezr.getCurrentBlockLocation();
   
   while (!Dezr.FinishedBlock(DeclBlockLoc))
-    TU->AddTopLevelDecl(Dezr.ReadOwnedPtr<Decl>());
+    TU->AddTopLevelDecl(Dezr.ReadOwnedPtr<Decl>(*TU->Context));
 
   return TU;
 }

Modified: cfe/trunk/lib/AST/TypeSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeSerialization.cpp?rev=49353&r1=49352&r2=49353&view=diff

==============================================================================
--- cfe/trunk/lib/AST/TypeSerialization.cpp (original)
+++ cfe/trunk/lib/AST/TypeSerialization.cpp Mon Apr  7 16:55:54 2008
@@ -229,7 +229,7 @@
   Types.push_back(T);
   
   // Deserialize the decl.
-  T->decl = cast<TagDecl>(D.ReadOwnedPtr<Decl>());
+  T->decl = cast<TagDecl>(D.ReadOwnedPtr<Decl>(Context));
 
   return T;
 }
@@ -269,7 +269,7 @@
   QualType ElTy = QualType::ReadVal(D);
   ArraySizeModifier am = static_cast<ArraySizeModifier>(D.ReadInt());
   unsigned ITQ = D.ReadInt();  
-  Expr* SizeExpr = D.ReadOwnedPtr<Expr>();
+  Expr* SizeExpr = D.ReadOwnedPtr<Expr>(Context);
   
   return Context.getVariableArrayType(ElTy,SizeExpr,am,ITQ).getTypePtr();
 }





More information about the cfe-commits mailing list