From: Sam Bishop Date: Mon, 7 Apr 2008 21:55:54 +0000 (+0000) Subject: Pass the ASTContext object around when deserializing Decl and Stmt objects, so X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2563ca02a519c2ad6d64dfed87d6e86c5d3c072;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49353 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index b3dd43cd18..3bae5e2d4c 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -42,7 +42,7 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ protected: 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 @@ protected: 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 @@ protected: 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 @@ protected: 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 @@ protected: 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 @@ protected: 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 @@ protected: 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 @@ protected: 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 @@ public: protected: void EmitInRec(llvm::Serializer& S) const; - void ReadInRec(llvm::Deserializer& D); + void ReadInRec(llvm::Deserializer& D, ASTContext& C); }; } // end namespace clang diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 4f9cc0cb66..a78d04476a 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -177,7 +177,7 @@ public: 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 @@ protected: } 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 diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index b88d5bdac3..2cc32a1c4f 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -134,8 +134,8 @@ public: } static bool classof(const Expr *) { return true; } - static inline Expr* Create(llvm::Deserializer& D) { - return cast(Stmt::Create(D)); + static inline Expr* Create(llvm::Deserializer& D, ASTContext& C) { + return cast(Stmt::Create(D, C)); } }; @@ -167,7 +167,7 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: } 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 { diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 8a882dfd99..5875d008b3 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -26,6 +26,7 @@ using llvm::dyn_cast_or_null; namespace clang { + class ASTContext; class Expr; class Decl; class ScopedDecl; @@ -117,8 +118,8 @@ public: } 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp index a2e9ce1b12..bc5310c414 100644 --- a/lib/AST/DeclSerialization.cpp +++ b/lib/AST/DeclSerialization.cpp @@ -31,45 +31,45 @@ void Decl::Emit(Serializer& S) const { EmitImpl(S); } -Decl* Decl::Create(Deserializer& D) { +Decl* Decl::Create(Deserializer& D, ASTContext& C) { Kind k = static_cast(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 @@ void Decl::EmitInRec(Serializer& S) const { 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 @@ void NamedDecl::EmitInRec(Serializer& S) const { 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 @@ void ScopedDecl::EmitInRec(Serializer& S) const { S.EmitPtr(cast_or_null(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 @@ void ScopedDecl::EmitOutRec(Serializer& S) const { S.EmitOwnedPtr(getNextDeclarator()); // From ScopedDecl. } -void ScopedDecl::ReadOutRec(Deserializer& D) { +void ScopedDecl::ReadOutRec(Deserializer& D, ASTContext& C) { NextDeclarator = - cast_or_null(D.ReadOwnedPtr()); // From ScopedDecl. + cast_or_null(D.ReadOwnedPtr(C)); // From ScopedDecl. } //===----------------------------------------------------------------------===// @@ -141,8 +141,8 @@ void ValueDecl::EmitInRec(Serializer& S) const { 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 @@ void VarDecl::EmitInRec(Serializer& S) const { 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(D.ReadInt()); // From VarDecl. } @@ -172,11 +172,12 @@ void VarDecl::EmitOutRec(Serializer& S) const { 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(next_declarator)); } @@ -187,20 +188,20 @@ void VarDecl::EmitImpl(Serializer& S) const { 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 @@ BlockVarDecl* BlockVarDecl::CreateImpl(Deserializer& D) { // 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 @@ void ParmVarDecl::EmitImpl(llvm::Serializer& S) const { 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(D.ReadInt()); return decl; @@ -248,17 +249,17 @@ void EnumDecl::EmitImpl(Serializer& S) const { 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(Elist); decl->setNextDeclarator(cast_or_null(next_declarator)); @@ -276,7 +277,7 @@ void EnumConstantDecl::EmitImpl(Serializer& S) const { 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 @@ EnumConstantDecl* EnumConstantDecl::CreateImpl(Deserializer& D) { 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(next_declarator)); @@ -305,11 +306,11 @@ void FieldDecl::EmitImpl(Serializer& S) const { 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(); + decl->ReadInRec(D, C); + decl->BitWidth = D.ReadOwnedPtr(C); return decl; } @@ -337,14 +338,14 @@ void FunctionDecl::EmitImpl(Serializer& S) const { } } -FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D) { +FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) { StorageClass SClass = static_cast(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 @@ FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D) { if (hasParamDecls) D.BatchReadOwnedPtrs(decl->getNumParams(), reinterpret_cast(&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(next_declarator)); @@ -385,10 +386,12 @@ void RecordDecl::EmitImpl(Serializer& S) const { 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 @@ RecordDecl* RecordDecl::CreateImpl(Decl::Kind DK, Deserializer& D) { D.BatchReadOwnedPtrs((unsigned) decl->getNumMembers(), (Decl**) &decl->Members[0], - next_declarator); + next_declarator, C); decl->setNextDeclarator(cast_or_null(next_declarator)); } else - decl->ScopedDecl::ReadOutRec(D); + decl->ScopedDecl::ReadOutRec(D, C); return decl; } @@ -419,13 +422,13 @@ void TypedefDecl::EmitImpl(Serializer& S) const { 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 @@ void LinkageSpecDecl::EmitInRec(Serializer& S) const { 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(D.ReadInt()); D.ReadPtr(this->D); } @@ -456,11 +459,11 @@ void FileScopeAsmDecl::EmitImpl(llvm::Serializer& S) const 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(D.ReadOwnedPtr()); + decl->Decl::ReadInRec(D, C); + decl->AsmString = cast(D.ReadOwnedPtr(C)); // D.ReadOwnedPtr(D.ReadOwnedPtr())<#T * * Ptr#>, <#bool AutoRegister#>)(decl->AsmString); return decl; diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp index 433e8e2702..41569df8f2 100644 --- a/lib/AST/StmtSerialization.cpp +++ b/lib/AST/StmtSerialization.cpp @@ -27,7 +27,7 @@ void Stmt::Emit(Serializer& S) const { S.FlushRecord(); } -Stmt* Stmt::Create(Deserializer& D) { +Stmt* Stmt::Create(Deserializer& D, ASTContext& C) { StmtClass SC = static_cast(D.ReadInt()); switch (SC) { @@ -36,155 +36,155 @@ Stmt* Stmt::Create(Deserializer& D) { 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 @@ void AddrLabelExpr::EmitImpl(Serializer& S) const { 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 @@ void ArraySubscriptExpr::EmitImpl(Serializer& S) const { 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 @@ void AsmStmt::EmitImpl(Serializer& S) const { 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 @@ AsmStmt* AsmStmt::CreateImpl(Deserializer& D) { 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()); + Stmt->Exprs.push_back(D.ReadOwnedPtr(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 @@ void BinaryOperator::EmitImpl(Serializer& S) const { S.BatchEmitOwnedPtrs(getLHS(),getRHS()); } -BinaryOperator* BinaryOperator::CreateImpl(Deserializer& D) { +BinaryOperator* BinaryOperator::CreateImpl(Deserializer& D, ASTContext& C) { Opcode Opc = static_cast(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 @@ void BreakStmt::EmitImpl(Serializer& S) const { 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 @@ void CallExpr::EmitImpl(Serializer& S) const { 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 @@ void CaseStmt::EmitImpl(Serializer& S) const { 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 @@ void CastExpr::EmitImpl(Serializer& S) const { 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* Op = D.ReadOwnedPtr(C); return new CastExpr(t,Op,Loc); } @@ -366,7 +366,7 @@ void CharacterLiteral::EmitImpl(Serializer& S) const { 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 @@ void CompoundAssignOperator::EmitImpl(Serializer& S) const { } 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(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 @@ void CompoundLiteralExpr::EmitImpl(Serializer& S) const { 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* Init = D.ReadOwnedPtr(C); return new CompoundLiteralExpr(L, Q, Init, fileScope); } @@ -417,7 +417,7 @@ void CompoundStmt::EmitImpl(Serializer& S) const { 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 @@ CompoundStmt* CompoundStmt::CreateImpl(Deserializer& D) { stmt->Body.reserve(size); for (unsigned i = 0; i < size; ++i) - stmt->Body.push_back(D.ReadOwnedPtr()); + stmt->Body.push_back(D.ReadOwnedPtr(C)); return stmt; } @@ -437,10 +437,12 @@ void ConditionalOperator::EmitImpl(Serializer& S) const { 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 @@ void ContinueStmt::EmitImpl(Serializer& S) const { 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 @@ void DeclRefExpr::EmitImpl(Serializer& S) const { } } -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 @@ DeclRefExpr* DeclRefExpr::CreateImpl(Deserializer& D) { if (!OwnsDecl) D.ReadPtr(decl,false); // No backpatching. else - decl = cast(D.ReadOwnedPtr()); + decl = cast(D.ReadOwnedPtr(C)); return new DeclRefExpr(decl,T,Loc); } - -DeclStmt* DeclStmt::CreateImpl(Deserializer& D) { - ScopedDecl* decl = cast(D.ReadOwnedPtr()); +DeclStmt* DeclStmt::CreateImpl(Deserializer& D, ASTContext& C) { + ScopedDecl* decl = cast(D.ReadOwnedPtr(C)); SourceLocation StartLoc = SourceLocation::ReadVal(D); SourceLocation EndLoc = SourceLocation::ReadVal(D); return new DeclStmt(decl, StartLoc, EndLoc); @@ -518,9 +519,9 @@ void DefaultStmt::EmitImpl(Serializer& S) const { 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* SubStmt = D.ReadOwnedPtr(C); DefaultStmt* stmt = new DefaultStmt(Loc,SubStmt); stmt->setNextSwitchCase(D.ReadPtr()); @@ -534,10 +535,10 @@ void DoStmt::EmitImpl(Serializer& S) const { S.EmitOwnedPtr(getBody()); } -DoStmt* DoStmt::CreateImpl(Deserializer& D) { +DoStmt* DoStmt::CreateImpl(Deserializer& D, ASTContext& C) { SourceLocation DoLoc = SourceLocation::ReadVal(D); - Expr* Cond = D.ReadOwnedPtr(); - Stmt* Body = D.ReadOwnedPtr(); + Expr* Cond = D.ReadOwnedPtr(C); + Stmt* Body = D.ReadOwnedPtr(C); return new DoStmt(Body,Cond,DoLoc); } @@ -548,7 +549,7 @@ void FloatingLiteral::EmitImpl(Serializer& S) const { 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 @@ void ForStmt::EmitImpl(Serializer& S) const { S.EmitOwnedPtr(getBody()); } -ForStmt* ForStmt::CreateImpl(Deserializer& D) { +ForStmt* ForStmt::CreateImpl(Deserializer& D, ASTContext& C) { SourceLocation ForLoc = SourceLocation::ReadVal(D); - Stmt* Init = D.ReadOwnedPtr(); - Expr* Cond = D.ReadOwnedPtr(); - Expr* Inc = D.ReadOwnedPtr(); - Stmt* Body = D.ReadOwnedPtr(); + Stmt* Init = D.ReadOwnedPtr(C); + Expr* Cond = D.ReadOwnedPtr(C); + Expr* Inc = D.ReadOwnedPtr(C); + Stmt* Body = D.ReadOwnedPtr(C); return new ForStmt(Init,Cond,Inc,Body,ForLoc); } @@ -580,7 +581,7 @@ void GotoStmt::EmitImpl(Serializer& S) const { 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 @@ void IfStmt::EmitImpl(Serializer& S) const { S.EmitOwnedPtr(getElse()); } -IfStmt* IfStmt::CreateImpl(Deserializer& D) { +IfStmt* IfStmt::CreateImpl(Deserializer& D, ASTContext& C) { SourceLocation L = SourceLocation::ReadVal(D); - Expr* Cond = D.ReadOwnedPtr(); - Stmt* Then = D.ReadOwnedPtr(); - Stmt* Else = D.ReadOwnedPtr(); + Expr* Cond = D.ReadOwnedPtr(C); + Stmt* Then = D.ReadOwnedPtr(C); + Stmt* Else = D.ReadOwnedPtr(C); return new IfStmt(L,Cond,Then,Else); } @@ -608,9 +609,9 @@ void ImaginaryLiteral::EmitImpl(Serializer& S) const { 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 = D.ReadOwnedPtr(C); assert (isa(expr) || isa(expr)); return new ImaginaryLiteral(expr,t); } @@ -620,9 +621,9 @@ void ImplicitCastExpr::EmitImpl(Serializer& S) const { 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* Op = D.ReadOwnedPtr(C); return new ImplicitCastExpr(t,Op); } @@ -630,8 +631,8 @@ void IndirectGotoStmt::EmitImpl(Serializer& S) const { S.EmitOwnedPtr(Target); } -IndirectGotoStmt* IndirectGotoStmt::CreateImpl(Deserializer& D) { - Expr* Target = D.ReadOwnedPtr(); +IndirectGotoStmt* IndirectGotoStmt::CreateImpl(Deserializer& D, ASTContext& C) { + Expr* Target = D.ReadOwnedPtr(C); return new IndirectGotoStmt(Target); } @@ -642,14 +643,14 @@ void InitListExpr::EmitImpl(Serializer& S) const { 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 @@ void IntegerLiteral::EmitImpl(Serializer& S) const { 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 @@ void LabelStmt::EmitImpl(Serializer& S) const { S.EmitOwnedPtr(SubStmt); } -LabelStmt* LabelStmt::CreateImpl(Deserializer& D) { +LabelStmt* LabelStmt::CreateImpl(Deserializer& D, ASTContext& C) { IdentifierInfo* Label = D.ReadPtr(); SourceLocation IdentLoc = SourceLocation::ReadVal(D); - Stmt* SubStmt = D.ReadOwnedPtr(); + Stmt* SubStmt = D.ReadOwnedPtr(C); return new LabelStmt(IdentLoc,Label,SubStmt); } @@ -693,12 +694,12 @@ void MemberExpr::EmitImpl(Serializer& S) const { S.EmitOwnedPtr(Base); } -MemberExpr* MemberExpr::CreateImpl(Deserializer& D) { +MemberExpr* MemberExpr::CreateImpl(Deserializer& D, ASTContext& C) { SourceLocation L = SourceLocation::ReadVal(D); FieldDecl* MemberDecl = cast(D.ReadPtr()); bool IsArrow = D.ReadBool(); QualType T = QualType::ReadVal(D); - Expr* base = D.ReadOwnedPtr(); + Expr* base = D.ReadOwnedPtr(C); return new MemberExpr(base,IsArrow,MemberDecl,L,T); } @@ -707,7 +708,7 @@ void NullStmt::EmitImpl(Serializer& S) const { 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 @@ void ParenExpr::EmitImpl(Serializer& S) const { 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* val = D.ReadOwnedPtr(C); return new ParenExpr(L,R,val); } @@ -731,7 +732,7 @@ void PreDefinedExpr::EmitImpl(Serializer& S) const { S.Emit(getType()); } -PreDefinedExpr* PreDefinedExpr::CreateImpl(Deserializer& D) { +PreDefinedExpr* PreDefinedExpr::CreateImpl(Deserializer& D, ASTContext& C) { SourceLocation Loc = SourceLocation::ReadVal(D); IdentType it = static_cast(D.ReadInt()); QualType Q = QualType::ReadVal(D); @@ -743,9 +744,9 @@ void ReturnStmt::EmitImpl(Serializer& S) const { 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* RetExpr = D.ReadOwnedPtr(C); return new ReturnStmt(RetLoc,RetExpr); } @@ -757,7 +758,7 @@ void SizeOfAlignOfTypeExpr::EmitImpl(Serializer& S) const { 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 @@ void StmtExpr::EmitImpl(Serializer& S) const { 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(D.ReadOwnedPtr()); + CompoundStmt* SubStmt = cast(D.ReadOwnedPtr(C)); return new StmtExpr(SubStmt,t,L,R); } @@ -793,7 +794,7 @@ void StringLiteral::EmitImpl(Serializer& S) const { 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 @@ void SwitchStmt::EmitImpl(Serializer& S) const { 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* Body = D.ReadOwnedPtr(); + Stmt* Cond = D.ReadOwnedPtr(C); + Stmt* Body = D.ReadOwnedPtr(C); SwitchCase* FirstCase = cast(D.ReadPtr()); SwitchStmt* stmt = new SwitchStmt(cast(Cond)); @@ -839,11 +840,11 @@ void UnaryOperator::EmitImpl(Serializer& S) const { 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(D.ReadInt()); - Expr* Val = D.ReadOwnedPtr(); + Expr* Val = D.ReadOwnedPtr(C); return new UnaryOperator(Val,Opc,t,L); } @@ -853,10 +854,10 @@ void WhileStmt::EmitImpl(Serializer& S) const { S.EmitOwnedPtr(getBody()); } -WhileStmt* WhileStmt::CreateImpl(Deserializer& D) { +WhileStmt* WhileStmt::CreateImpl(Deserializer& D, ASTContext& C) { SourceLocation WhileLoc = SourceLocation::ReadVal(D); - Expr* Cond = D.ReadOwnedPtr(); - Stmt* Body = D.ReadOwnedPtr(); + Expr* Cond = D.ReadOwnedPtr(C); + Stmt* Body = D.ReadOwnedPtr(C); return new WhileStmt(Cond,Body,WhileLoc); } @@ -870,12 +871,12 @@ void ObjCAtCatchStmt::EmitImpl(Serializer& S) const { 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 @@ void ObjCAtFinallyStmt::EmitImpl(Serializer& S) const { 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* AtFinallyStmt = D.ReadOwnedPtr(C); return new ObjCAtFinallyStmt(Loc,AtFinallyStmt); } @@ -896,10 +897,12 @@ void ObjCAtSynchronizedStmt::EmitImpl(Serializer& S) const { 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 @@ void ObjCAtThrowStmt::EmitImpl(Serializer& S) const { 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* Throw = D.ReadOwnedPtr(C); return new ObjCAtThrowStmt(L,Throw); } @@ -919,10 +922,10 @@ void ObjCAtTryStmt::EmitImpl(Serializer& S) const { 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 @@ void ObjCEncodeExpr::EmitImpl(Serializer& S) const { 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 @@ void ObjCForCollectionStmt::EmitImpl(Serializer& S) const { 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 @@ void ObjCIvarRefExpr::EmitImpl(Serializer& S) const { 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 @@ void ObjCSelectorExpr::EmitImpl(Serializer& S) const { 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 @@ void ObjCStringLiteral::EmitImpl(Serializer& S) const { 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(D.ReadOwnedPtr()); + StringLiteral* String = cast(D.ReadOwnedPtr(C)); return new ObjCStringLiteral(String,T,L); } diff --git a/lib/AST/TranslationUnit.cpp b/lib/AST/TranslationUnit.cpp index 3ad134a292..b3a2e68f60 100644 --- a/lib/AST/TranslationUnit.cpp +++ b/lib/AST/TranslationUnit.cpp @@ -221,7 +221,7 @@ TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr, llvm::Deserializer::Location DeclBlockLoc = Dezr.getCurrentBlockLocation(); while (!Dezr.FinishedBlock(DeclBlockLoc)) - TU->AddTopLevelDecl(Dezr.ReadOwnedPtr()); + TU->AddTopLevelDecl(Dezr.ReadOwnedPtr(*TU->Context)); return TU; } diff --git a/lib/AST/TypeSerialization.cpp b/lib/AST/TypeSerialization.cpp index 55c0a48a00..ff86d82f26 100644 --- a/lib/AST/TypeSerialization.cpp +++ b/lib/AST/TypeSerialization.cpp @@ -229,7 +229,7 @@ Type* TagType::CreateImpl(ASTContext& Context, Deserializer& D) { Types.push_back(T); // Deserialize the decl. - T->decl = cast(D.ReadOwnedPtr()); + T->decl = cast(D.ReadOwnedPtr(Context)); return T; } @@ -269,7 +269,7 @@ Type* VariableArrayType::CreateImpl(ASTContext& Context, Deserializer& D) { QualType ElTy = QualType::ReadVal(D); ArraySizeModifier am = static_cast(D.ReadInt()); unsigned ITQ = D.ReadInt(); - Expr* SizeExpr = D.ReadOwnedPtr(); + Expr* SizeExpr = D.ReadOwnedPtr(Context); return Context.getVariableArrayType(ElTy,SizeExpr,am,ITQ).getTypePtr(); }