From 72172e900992a8b184571745eb7bf62af62a8c6d Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 5 Jan 2012 21:55:30 +0000 Subject: [PATCH] When creating declarations that are deserialized from an module file, go through a central allocation routine Decl::AllocateDeserializedDecl(). No actual functionality change (yet). llvm-svn: 147614 --- clang/include/clang/AST/Decl.h | 40 ++++++-- clang/include/clang/AST/DeclBase.h | 12 +++ clang/include/clang/AST/DeclCXX.h | 35 +++++-- clang/include/clang/AST/DeclFriend.h | 2 +- clang/include/clang/AST/DeclObjC.h | 23 ++++- clang/include/clang/AST/DeclTemplate.h | 37 ++++--- clang/lib/AST/Decl.cpp | 102 ++++++++++++++++---- clang/lib/AST/DeclBase.cpp | 6 ++ clang/lib/AST/DeclCXX.cpp | 120 ++++++++++++++++++++--- clang/lib/AST/DeclFriend.cpp | 5 +- clang/lib/AST/DeclObjC.cpp | 76 +++++++++++++-- clang/lib/AST/DeclTemplate.cpp | 89 +++++++++++++---- clang/lib/Serialization/ASTReaderDecl.cpp | 154 ++++++++++-------------------- 13 files changed, 503 insertions(+), 198 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 3cc94ed..f27330b 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -336,7 +336,8 @@ public: static LabelDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II, SourceLocation GnuLabelL); - + static LabelDecl *CreateDeserialized(ASTContext &C, unsigned ID); + LabelStmt *getStmt() const { return TheStmt; } void setStmt(LabelStmt *T) { TheStmt = T; } @@ -400,6 +401,8 @@ public: SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id); + static NamespaceDecl *CreateDeserialized(ASTContext &C, unsigned ID); + /// \brief Returns true if this is an anonymous namespace declaration. /// /// For example: @@ -805,6 +808,8 @@ public: IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, StorageClass SCAsWritten); + static VarDecl *CreateDeserialized(ASTContext &C, unsigned ID); + virtual SourceRange getSourceRange() const; StorageClass getStorageClass() const { @@ -1151,6 +1156,8 @@ public: SourceLocation IdLoc, IdentifierInfo *Id, QualType T); + static ImplicitParamDecl *CreateDeserialized(ASTContext &C, unsigned ID); + ImplicitParamDecl(DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType Type) : VarDecl(ImplicitParam, DC, IdLoc, IdLoc, Id, Type, @@ -1190,6 +1197,8 @@ public: StorageClass S, StorageClass SCAsWritten, Expr *DefArg); + static ParmVarDecl *CreateDeserialized(ASTContext &C, unsigned ID); + virtual SourceRange getSourceRange() const; void setObjCMethodScopeInfo(unsigned parameterIndex) { @@ -1527,6 +1536,8 @@ public: bool hasWrittenPrototype = true, bool isConstexprSpecified = false); + static FunctionDecl *CreateDeserialized(ASTContext &C, unsigned ID); + DeclarationNameInfo getNameInfo() const { return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); } @@ -2027,6 +2038,8 @@ public: TypeSourceInfo *TInfo, Expr *BW, bool Mutable, bool HasInit); + static FieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); + /// getFieldIndex - Returns the index of this field within its record, /// as appropriate for passing to ASTRecordLayout::getFieldOffset. unsigned getFieldIndex() const; @@ -2127,7 +2140,8 @@ public: SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V); - + static EnumConstantDecl *CreateDeserialized(ASTContext &C, unsigned ID); + const Expr *getInitExpr() const { return (const Expr*) Init; } Expr *getInitExpr() { return (Expr*) Init; } const llvm::APSInt &getInitVal() const { return Val; } @@ -2163,6 +2177,8 @@ public: SourceLocation L, IdentifierInfo *Id, QualType T, NamedDecl **CH, unsigned CHS); + static IndirectFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); + typedef NamedDecl * const *chain_iterator; chain_iterator chain_begin() const { return Chaining; } chain_iterator chain_end() const { return Chaining+ChainingSize; } @@ -2293,7 +2309,8 @@ public: static TypedefDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo); - + static TypedefDecl *CreateDeserialized(ASTContext &C, unsigned ID); + SourceRange getSourceRange() const; // Implement isa/cast/dyncast/etc. @@ -2313,6 +2330,7 @@ public: static TypeAliasDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo); + static TypeAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); SourceRange getSourceRange() const; @@ -2628,7 +2646,7 @@ public: IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed); - static EnumDecl *Create(ASTContext &C, EmptyShell Empty); + static EnumDecl *CreateDeserialized(ASTContext &C, unsigned ID); /// completeDefinition - When created, the EnumDecl corresponds to a /// forward-declared enum. This method is used to mark the @@ -2787,7 +2805,7 @@ public: static RecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl* PrevDecl = 0); - static RecordDecl *Create(const ASTContext &C, EmptyShell Empty); + static RecordDecl *CreateDeserialized(const ASTContext &C, unsigned ID); const RecordDecl *getPreviousDeclaration() const { return cast_or_null(TagDecl::getPreviousDeclaration()); @@ -2890,6 +2908,8 @@ public: StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc); + static FileScopeAsmDecl *CreateDeserialized(ASTContext &C, unsigned ID); + SourceLocation getAsmLoc() const { return getLocation(); } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } @@ -2976,8 +2996,9 @@ protected: SignatureAsWritten(0), Captures(0), NumCaptures(0) {} public: - static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L); - + static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L); + static BlockDecl *CreateDeserialized(ASTContext &C, unsigned ID); + SourceLocation getCaretLocation() const { return getLocation(); } bool isVariadic() const { return IsVariadic; } @@ -3100,8 +3121,9 @@ public: SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc); - /// \brief Create a new module import declaration. - static ImportDecl *CreateEmpty(ASTContext &C, unsigned NumLocations); + /// \brief Create a new, deserialized module import declaration. + static ImportDecl *CreateDeserialized(ASTContext &C, unsigned ID, + unsigned NumLocations); /// \brief Retrieve the module that was imported by the import declaration. Module *getImportedModule() const { return ImportedAndComplete.getPointer(); } diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index ecd7762..12f37e5 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -310,6 +310,18 @@ protected: virtual ~Decl(); + /// \brief Allocate memory for a deserialized declaration. + /// + /// This routine must be used to allocate memory for any declaration that is + /// deserialized from a module file. + /// + /// \param Context The context in which we will allocate memory. + /// \param ID The global ID of the deserialized declaration. + /// \param Size The size of the allocated object. + static void *AllocateDeserializedDecl(const ASTContext &Context, + unsigned ID, + unsigned Size); + public: /// \brief Source range that this declaration covers. diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index edbeabd..dcf8c17 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -135,9 +135,7 @@ public: SourceLocation ColonLoc) { return new (C) AccessSpecDecl(AS, DC, ASLoc, ColonLoc); } - static AccessSpecDecl *Create(ASTContext &C, EmptyShell Empty) { - return new (C) AccessSpecDecl(Empty); - } + static AccessSpecDecl *CreateDeserialized(ASTContext &C, unsigned ID); // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -632,7 +630,7 @@ public: SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl* PrevDecl=0, bool DelayTypeCreation = false); - static CXXRecordDecl *Create(const ASTContext &C, EmptyShell Empty); + static CXXRecordDecl *CreateDeserialized(const ASTContext &C, unsigned ID); bool isDynamicClass() const { return data().Polymorphic || data().NumVBases != 0; @@ -1409,6 +1407,8 @@ public: bool isConstexpr, SourceLocation EndLocation); + static CXXMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID); + bool isStatic() const { return getStorageClass() == SC_Static; } bool isInstance() const { return !isStatic(); } @@ -1791,7 +1791,7 @@ class CXXConstructorDecl : public CXXMethodDecl { } public: - static CXXConstructorDecl *Create(ASTContext &C, EmptyShell Empty); + static CXXConstructorDecl *CreateDeserialized(ASTContext &C, unsigned ID); static CXXConstructorDecl *Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, @@ -2010,13 +2010,13 @@ class CXXDestructorDecl : public CXXMethodDecl { } public: - static CXXDestructorDecl *Create(ASTContext& C, EmptyShell Empty); static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo* TInfo, bool isInline, bool isImplicitlyDeclared); + static CXXDestructorDecl *CreateDeserialized(ASTContext & C, unsigned ID); /// isImplicitlyDefined - Whether this destructor was implicitly /// defined. If false, then this destructor was defined by the @@ -2076,7 +2076,6 @@ class CXXConversionDecl : public CXXMethodDecl { IsExplicitSpecified(isExplicitSpecified) { } public: - static CXXConversionDecl *Create(ASTContext &C, EmptyShell Empty); static CXXConversionDecl *Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, @@ -2084,6 +2083,7 @@ public: bool isInline, bool isExplicit, bool isConstexpr, SourceLocation EndLocation); + static CXXConversionDecl *CreateDeserialized(ASTContext &C, unsigned ID); /// IsExplicitSpecified - Whether this conversion function declaration is /// marked "explicit", meaning that it can only be applied when the user @@ -2147,7 +2147,8 @@ public: SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, SourceLocation RBraceLoc = SourceLocation()); - + static LinkageSpecDecl *CreateDeserialized(ASTContext &C, unsigned ID); + /// \brief Return the language specified by this linkage specification. LanguageIDs getLanguage() const { return Language; } /// \brief Set the language specified by this linkage specification. @@ -2272,7 +2273,8 @@ public: SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor); - + static UsingDirectiveDecl *CreateDeserialized(ASTContext &C, unsigned ID); + SourceRange getSourceRange() const { return SourceRange(UsingLoc, getLocation()); } @@ -2363,6 +2365,8 @@ public: SourceLocation IdentLoc, NamedDecl *Namespace); + static NamespaceAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); + virtual SourceRange getSourceRange() const { return SourceRange(NamespaceLoc, IdentLoc); } @@ -2413,6 +2417,8 @@ public: return new (C) UsingShadowDecl(DC, Loc, Using, Target); } + static UsingShadowDecl *CreateDeserialized(ASTContext &C, unsigned ID); + /// \brief Gets the underlying declaration which has been brought into the /// local scope. NamedDecl *getTargetDecl() const { return Underlying; } @@ -2556,6 +2562,8 @@ public: const DeclarationNameInfo &NameInfo, bool IsTypeNameArg); + static UsingDecl *CreateDeserialized(ASTContext &C, unsigned ID); + SourceRange getSourceRange() const { return SourceRange(UsingLocation, getNameInfo().getEndLoc()); } @@ -2624,6 +2632,9 @@ public: NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo); + static UnresolvedUsingValueDecl * + CreateDeserialized(ASTContext &C, unsigned ID); + SourceRange getSourceRange() const { return SourceRange(UsingLocation, getNameInfo().getEndLoc()); } @@ -2689,6 +2700,9 @@ public: SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName); + static UnresolvedUsingTypenameDecl * + CreateDeserialized(ASTContext &C, unsigned ID); + static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const UnresolvedUsingTypenameDecl *D) { return true; } static bool classofKind(Kind K) { return K == UnresolvedUsingTypename; } @@ -2712,7 +2726,8 @@ public: SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc); - + static StaticAssertDecl *CreateDeserialized(ASTContext &C, unsigned ID); + Expr *getAssertExpr() { return AssertExpr; } const Expr *getAssertExpr() const { return AssertExpr; } diff --git a/clang/include/clang/AST/DeclFriend.h b/clang/include/clang/AST/DeclFriend.h index 07f696a..d8fd646 100644 --- a/clang/include/clang/AST/DeclFriend.h +++ b/clang/include/clang/AST/DeclFriend.h @@ -78,7 +78,7 @@ public: static FriendDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL); - static FriendDecl *Create(ASTContext &C, EmptyShell Empty); + static FriendDecl *CreateDeserialized(ASTContext &C, unsigned ID); /// If this friend declaration names an (untemplated but possibly /// dependent) type, return the type; otherwise return null. This diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 1533718..7828868 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -257,6 +257,8 @@ public: ImplementationControl impControl = None, bool HasRelatedResultType = false); + static ObjCMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID); + virtual ObjCMethodDecl *getCanonicalDecl(); const ObjCMethodDecl *getCanonicalDecl() const { return const_cast(this)->getCanonicalDecl(); @@ -623,7 +625,7 @@ public: SourceLocation ClassLoc = SourceLocation(), bool isInternal = false); - static ObjCInterfaceDecl *CreateEmpty(ASTContext &C); + static ObjCInterfaceDecl *CreateDeserialized(ASTContext &C, unsigned ID); virtual SourceRange getSourceRange() const { if (isThisDeclarationADefinition()) @@ -993,6 +995,8 @@ public: AccessControl ac, Expr *BW = NULL, bool synthesized=false); + static ObjCIvarDecl *CreateDeserialized(ASTContext &C, unsigned ID); + /// \brief Return the class interface that this ivar is logically contained /// in; this is either the interface where the ivar was declared, or the /// interface the ivar is conceptually a part of in the case of synthesized @@ -1046,6 +1050,8 @@ public: SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW); + static ObjCAtDefsFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const ObjCAtDefsFieldDecl *D) { return true; } @@ -1113,6 +1119,8 @@ public: SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl); + static ObjCProtocolDecl *CreateDeserialized(ASTContext &C, unsigned ID); + const ObjCProtocolList &getReferencedProtocols() const { assert(hasDefinition() && "No definition available!"); return data().ReferencedProtocols; @@ -1275,7 +1283,7 @@ public: SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl); - static ObjCCategoryDecl *Create(ASTContext &C, EmptyShell Empty); + static ObjCCategoryDecl *CreateDeserialized(ASTContext &C, unsigned ID); ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } @@ -1426,6 +1434,7 @@ public: SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc); + static ObjCCategoryImplDecl *CreateDeserialized(ASTContext &C, unsigned ID); /// getIdentifier - Get the identifier that names the category /// interface associated with this implementation. @@ -1523,6 +1532,8 @@ public: SourceLocation nameLoc, SourceLocation atStartLoc); + static ObjCImplementationDecl *CreateDeserialized(ASTContext &C, unsigned ID); + /// init_iterator - Iterates through the ivar initializer list. typedef CXXCtorInitializer **init_iterator; @@ -1638,6 +1649,9 @@ public: SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl* aliasedClass); + static ObjCCompatibleAliasDecl *CreateDeserialized(ASTContext &C, + unsigned ID); + const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; } ObjCInterfaceDecl *getClassInterface() { return AliasedClass; } void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; } @@ -1709,6 +1723,9 @@ public: IdentifierInfo *Id, SourceLocation AtLocation, TypeSourceInfo *T, PropertyControl propControl = None); + + static ObjCPropertyDecl *CreateDeserialized(ASTContext &C, unsigned ID); + SourceLocation getAtLoc() const { return AtLoc; } void setAtLoc(SourceLocation L) { AtLoc = L; } @@ -1868,6 +1885,8 @@ public: ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc); + static ObjCPropertyImplDecl *CreateDeserialized(ASTContext &C, unsigned ID); + virtual SourceRange getSourceRange() const; SourceLocation getLocStart() const { return AtLoc; } diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index fbf7b34..681765f 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -883,7 +883,7 @@ public: NamedDecl *Decl); /// \brief Create an empty function template node. - static FunctionTemplateDecl *Create(ASTContext &C, EmptyShell); + static FunctionTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID); // Implement isa/cast/dyncast support static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -968,7 +968,8 @@ public: unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack); - static TemplateTypeParmDecl *Create(const ASTContext &C, EmptyShell Empty); + static TemplateTypeParmDecl *CreateDeserialized(const ASTContext &C, + unsigned ID); /// \brief Whether this template type parameter was declared with /// the 'typename' keyword. If not, it was declared with the 'class' @@ -1085,6 +1086,12 @@ public: const QualType *ExpandedTypes, unsigned NumExpandedTypes, TypeSourceInfo **ExpandedTInfos); + static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, + unsigned ID); + static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, + unsigned ID, + unsigned NumExpandedTypes); + using TemplateParmPosition::getDepth; using TemplateParmPosition::setDepth; using TemplateParmPosition::getPosition; @@ -1200,8 +1207,9 @@ public: /// @endcode /// A template template parameter is a TemplateDecl because it defines the /// name of a template and the template parameters allowable for substitution. -class TemplateTemplateParmDecl - : public TemplateDecl, protected TemplateParmPosition { +class TemplateTemplateParmDecl : public TemplateDecl, + protected TemplateParmPosition +{ virtual void anchor(); /// DefaultArgument - The default template argument, if any. @@ -1227,6 +1235,9 @@ public: IdentifierInfo *Id, TemplateParameterList *Params); + static TemplateTemplateParmDecl *CreateDeserialized(ASTContext &C, + unsigned ID); + using TemplateParmPosition::getDepth; using TemplateParmPosition::getPosition; using TemplateParmPosition::getIndex; @@ -1369,7 +1380,7 @@ public: unsigned NumArgs, ClassTemplateSpecializationDecl *PrevDecl); static ClassTemplateSpecializationDecl * - Create(ASTContext &Context, EmptyShell Empty); + CreateDeserialized(ASTContext &C, unsigned ID); virtual void getNameForDiagnostic(std::string &S, const PrintingPolicy &Policy, @@ -1619,7 +1630,7 @@ public: unsigned SequenceNumber); static ClassTemplatePartialSpecializationDecl * - Create(ASTContext &Context, EmptyShell Empty); + CreateDeserialized(ASTContext &C, unsigned ID); ClassTemplatePartialSpecializationDecl *getMostRecentDeclaration() { return cast( @@ -1812,7 +1823,7 @@ public: ClassTemplateDecl *PrevDecl); /// Create an empty class template node. - static ClassTemplateDecl *Create(ASTContext &C, EmptyShell); + static ClassTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID); /// \brief Return the specialization with the provided arguments if it exists, /// otherwise return the insertion point. @@ -1989,7 +2000,7 @@ public: FriendUnion Friend, SourceLocation FriendLoc); - static FriendTemplateDecl *Create(ASTContext &Context, EmptyShell Empty); + static FriendTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID); /// If this friend declaration names a templated type (or /// a dependent member type of a templated type), return that @@ -2088,7 +2099,7 @@ public: NamedDecl *Decl); /// \brief Create an empty alias template node. - static TypeAliasTemplateDecl *Create(ASTContext &C, EmptyShell); + static TypeAliasTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID); // Implement isa/cast/dyncast support static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -2134,11 +2145,9 @@ public: return new (C) ClassScopeFunctionSpecializationDecl(DC , Loc, FD); } - static ClassScopeFunctionSpecializationDecl *Create(ASTContext &Context, - EmptyShell Empty) { - return new (Context)ClassScopeFunctionSpecializationDecl(0, - SourceLocation(), 0); - } + static ClassScopeFunctionSpecializationDecl * + CreateDeserialized(ASTContext &Context, unsigned ID); + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 468baae..e6b3a74 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1152,6 +1152,12 @@ VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, return new (C) VarDecl(Var, DC, StartL, IdL, Id, T, TInfo, S, SCAsWritten); } +VarDecl *VarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(VarDecl)); + return new (Mem) VarDecl(Var, 0, SourceLocation(), SourceLocation(), 0, + QualType(), 0, SC_None, SC_None); +} + void VarDecl::setStorageClass(StorageClass SC) { assert(isLegalForVariable(SC)); if (getStorageClass() != SC) @@ -1513,6 +1519,12 @@ ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC, S, SCAsWritten, DefArg); } +ParmVarDecl *ParmVarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ParmVarDecl)); + return new (Mem) ParmVarDecl(ParmVar, 0, SourceLocation(), SourceLocation(), + 0, QualType(), 0, SC_None, SC_None, 0); +} + SourceRange ParmVarDecl::getSourceRange() const { if (!hasInheritedDefaultArg()) { SourceRange ArgRange = getDefaultArgRange(); @@ -2303,6 +2315,12 @@ FieldDecl *FieldDecl::Create(const ASTContext &C, DeclContext *DC, BW, Mutable, HasInit); } +FieldDecl *FieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FieldDecl)); + return new (Mem) FieldDecl(Field, 0, SourceLocation(), SourceLocation(), + 0, QualType(), 0, 0, false, false); +} + bool FieldDecl::isAnonymousStructOrUnion() const { if (!isImplicit() || getDeclName()) return false; @@ -2469,9 +2487,10 @@ EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, return Enum; } -EnumDecl *EnumDecl::Create(ASTContext &C, EmptyShell Empty) { - return new (C) EnumDecl(0, SourceLocation(), SourceLocation(), 0, 0, - false, false, false); +EnumDecl *EnumDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(EnumDecl)); + return new (Mem) EnumDecl(0, SourceLocation(), SourceLocation(), 0, 0, + false, false, false); } void EnumDecl::completeDefinition(QualType NewType, @@ -2511,9 +2530,10 @@ RecordDecl *RecordDecl::Create(const ASTContext &C, TagKind TK, DeclContext *DC, return R; } -RecordDecl *RecordDecl::Create(const ASTContext &C, EmptyShell Empty) { - return new (C) RecordDecl(Record, TTK_Struct, 0, SourceLocation(), - SourceLocation(), 0, 0); +RecordDecl *RecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(RecordDecl)); + return new (Mem) RecordDecl(Record, TTK_Struct, 0, SourceLocation(), + SourceLocation(), 0, 0); } bool RecordDecl::isInjectedClassName() const { @@ -2641,17 +2661,9 @@ LabelDecl *LabelDecl::Create(ASTContext &C, DeclContext *DC, return new (C) LabelDecl(DC, IdentL, II, 0, GnuLabelL); } -void NamespaceDecl::anchor() { } - -NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation StartLoc, - SourceLocation IdLoc, IdentifierInfo *Id) { - return new (C) NamespaceDecl(DC, StartLoc, IdLoc, Id); -} - -NamespaceDecl *NamespaceDecl::getNextNamespace() { - return dyn_cast_or_null( - NextNamespace.get(getASTContext().getExternalSource())); +LabelDecl *LabelDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(LabelDecl)); + return new (Mem) LabelDecl(0, SourceLocation(), 0, 0, SourceLocation()); } void ValueDecl::anchor() { } @@ -2665,6 +2677,12 @@ ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC, return new (C) ImplicitParamDecl(DC, IdLoc, Id, Type); } +ImplicitParamDecl *ImplicitParamDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ImplicitParamDecl)); + return new (Mem) ImplicitParamDecl(0, SourceLocation(), 0, QualType()); +} + FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, @@ -2681,10 +2699,22 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, return New; } +FunctionDecl *FunctionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FunctionDecl)); + return new (Mem) FunctionDecl(Function, 0, SourceLocation(), + DeclarationNameInfo(), QualType(), 0, + SC_None, SC_None, false, false); +} + BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { return new (C) BlockDecl(DC, L); } +BlockDecl *BlockDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(BlockDecl)); + return new (Mem) BlockDecl(0, SourceLocation()); +} + EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD, SourceLocation L, IdentifierInfo *Id, QualType T, @@ -2692,6 +2722,13 @@ EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD, return new (C) EnumConstantDecl(CD, L, Id, T, E, V); } +EnumConstantDecl * +EnumConstantDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(EnumConstantDecl)); + return new (Mem) EnumConstantDecl(0, SourceLocation(), 0, QualType(), 0, + llvm::APSInt()); +} + void IndirectFieldDecl::anchor() { } IndirectFieldDecl * @@ -2701,6 +2738,13 @@ IndirectFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, return new (C) IndirectFieldDecl(DC, L, Id, T, CH, CHS); } +IndirectFieldDecl *IndirectFieldDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(IndirectFieldDecl)); + return new (Mem) IndirectFieldDecl(0, SourceLocation(), DeclarationName(), + QualType(), 0, 0); +} + SourceRange EnumConstantDecl::getSourceRange() const { SourceLocation End = getLocation(); if (Init) @@ -2718,6 +2762,11 @@ TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC, void TypedefNameDecl::anchor() { } +TypedefDecl *TypedefDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TypedefDecl)); + return new (Mem) TypedefDecl(0, SourceLocation(), SourceLocation(), 0, 0); +} + TypeAliasDecl *TypeAliasDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, @@ -2725,6 +2774,11 @@ TypeAliasDecl *TypeAliasDecl::Create(ASTContext &C, DeclContext *DC, return new (C) TypeAliasDecl(DC, StartLoc, IdLoc, Id, TInfo); } +TypeAliasDecl *TypeAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TypeAliasDecl)); + return new (Mem) TypeAliasDecl(0, SourceLocation(), SourceLocation(), 0, 0); +} + SourceRange TypedefDecl::getSourceRange() const { SourceLocation RangeEnd = getLocation(); if (TypeSourceInfo *TInfo = getTypeSourceInfo()) { @@ -2750,6 +2804,12 @@ FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, DeclContext *DC, return new (C) FileScopeAsmDecl(DC, Str, AsmLoc, RParenLoc); } +FileScopeAsmDecl *FileScopeAsmDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FileScopeAsmDecl)); + return new (Mem) FileScopeAsmDecl(0, 0, SourceLocation(), SourceLocation()); +} + //===----------------------------------------------------------------------===// // ImportDecl Implementation //===----------------------------------------------------------------------===// @@ -2803,9 +2863,11 @@ ImportDecl *ImportDecl::CreateImplicit(ASTContext &C, DeclContext *DC, return Import; } -ImportDecl *ImportDecl::CreateEmpty(ASTContext &C, unsigned NumLocations) { - void *Mem = C.Allocate(sizeof(ImportDecl) + - NumLocations * sizeof(SourceLocation)); +ImportDecl *ImportDecl::CreateDeserialized(ASTContext &C, unsigned ID, + unsigned NumLocations) { + void *Mem = AllocateDeserializedDecl(C, ID, + (sizeof(ImportDecl) + + NumLocations * sizeof(SourceLocation))); return new (Mem) ImportDecl(EmptyShell()); } diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index d60edd0..5548418 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -41,6 +41,12 @@ using namespace clang; static bool StatSwitch = false; +void *Decl::AllocateDeserializedDecl(const ASTContext &Context, + unsigned ID, + unsigned Size) { + return Context.Allocate(Size); +} + const char *Decl::getDeclKindName() const { switch (DeclKind) { default: llvm_unreachable("Declaration not in DeclNodes.inc!"); diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index c1aa35f..0f83c56 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -30,6 +30,12 @@ using namespace clang; void AccessSpecDecl::anchor() { } +AccessSpecDecl *AccessSpecDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(AccessSpecDecl)); + return new (Mem) AccessSpecDecl(EmptyShell()); +} + + CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D) : UserDeclaredConstructor(false), UserDeclaredCopyConstructor(false), UserDeclaredMoveConstructor(false), UserDeclaredCopyAssignment(false), @@ -76,9 +82,11 @@ CXXRecordDecl *CXXRecordDecl::Create(const ASTContext &C, TagKind TK, return R; } -CXXRecordDecl *CXXRecordDecl::Create(const ASTContext &C, EmptyShell Empty) { - return new (C) CXXRecordDecl(CXXRecord, TTK_Struct, 0, SourceLocation(), - SourceLocation(), 0, 0); +CXXRecordDecl * +CXXRecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXRecordDecl)); + return new (Mem) CXXRecordDecl(CXXRecord, TTK_Struct, 0, SourceLocation(), + SourceLocation(), 0, 0); } void @@ -1271,6 +1279,14 @@ CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD, EndLocation); } +CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXMethodDecl)); + return new (Mem) CXXMethodDecl(CXXMethod, 0, SourceLocation(), + DeclarationNameInfo(), QualType(), + 0, false, SC_None, false, false, + SourceLocation()); +} + bool CXXMethodDecl::isUsualDeallocationFunction() const { if (getOverloadedOperator() != OO_Delete && getOverloadedOperator() != OO_Array_Delete) @@ -1511,9 +1527,10 @@ SourceRange CXXCtorInitializer::getSourceRange() const { void CXXConstructorDecl::anchor() { } CXXConstructorDecl * -CXXConstructorDecl::Create(ASTContext &C, EmptyShell Empty) { - return new (C) CXXConstructorDecl(0, SourceLocation(), DeclarationNameInfo(), - QualType(), 0, false, false, false, false); +CXXConstructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXConstructorDecl)); + return new (Mem) CXXConstructorDecl(0, SourceLocation(),DeclarationNameInfo(), + QualType(), 0, false, false, false,false); } CXXConstructorDecl * @@ -1657,8 +1674,9 @@ CXXConstructorDecl::setInheritedConstructor(const CXXConstructorDecl *BaseCtor){ void CXXDestructorDecl::anchor() { } CXXDestructorDecl * -CXXDestructorDecl::Create(ASTContext &C, EmptyShell Empty) { - return new (C) CXXDestructorDecl(0, SourceLocation(), DeclarationNameInfo(), +CXXDestructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXDestructorDecl)); + return new (Mem) CXXDestructorDecl(0, SourceLocation(), DeclarationNameInfo(), QualType(), 0, false, false); } @@ -1678,10 +1696,11 @@ CXXDestructorDecl::Create(ASTContext &C, CXXRecordDecl *RD, void CXXConversionDecl::anchor() { } CXXConversionDecl * -CXXConversionDecl::Create(ASTContext &C, EmptyShell Empty) { - return new (C) CXXConversionDecl(0, SourceLocation(), DeclarationNameInfo(), - QualType(), 0, false, false, false, - SourceLocation()); +CXXConversionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXConversionDecl)); + return new (Mem) CXXConversionDecl(0, SourceLocation(), DeclarationNameInfo(), + QualType(), 0, false, false, false, + SourceLocation()); } CXXConversionDecl * @@ -1710,6 +1729,12 @@ LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C, return new (C) LinkageSpecDecl(DC, ExternLoc, LangLoc, Lang, RBraceLoc); } +LinkageSpecDecl *LinkageSpecDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(LinkageSpecDecl)); + return new (Mem) LinkageSpecDecl(0, SourceLocation(), SourceLocation(), + lang_c, SourceLocation()); +} + void UsingDirectiveDecl::anchor() { } UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC, @@ -1725,6 +1750,14 @@ UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC, IdentLoc, Used, CommonAncestor); } +UsingDirectiveDecl * +UsingDirectiveDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(UsingDirectiveDecl)); + return new (Mem) UsingDirectiveDecl(0, SourceLocation(), SourceLocation(), + NestedNameSpecifierLoc(), + SourceLocation(), 0, 0); +} + NamespaceDecl *UsingDirectiveDecl::getNominatedNamespace() { if (NamespaceAliasDecl *NA = dyn_cast_or_null(NominatedNamespace)) @@ -1732,6 +1765,24 @@ NamespaceDecl *UsingDirectiveDecl::getNominatedNamespace() { return cast_or_null(NominatedNamespace); } +void NamespaceDecl::anchor() { } + +NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC, + SourceLocation StartLoc, + SourceLocation IdLoc, IdentifierInfo *Id) { + return new (C) NamespaceDecl(DC, StartLoc, IdLoc, Id); +} + +NamespaceDecl *NamespaceDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(NamespaceDecl)); + return new (Mem) NamespaceDecl(0, SourceLocation(), SourceLocation(), 0); +} + +NamespaceDecl *NamespaceDecl::getNextNamespace() { + return dyn_cast_or_null( + NextNamespace.get(getASTContext().getExternalSource())); +} + void NamespaceAliasDecl::anchor() { } NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC, @@ -1747,8 +1798,22 @@ NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC, QualifierLoc, IdentLoc, Namespace); } +NamespaceAliasDecl * +NamespaceAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(NamespaceAliasDecl)); + return new (Mem) NamespaceAliasDecl(0, SourceLocation(), SourceLocation(), 0, + NestedNameSpecifierLoc(), + SourceLocation(), 0); +} + void UsingShadowDecl::anchor() { } +UsingShadowDecl * +UsingShadowDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(UsingShadowDecl)); + return new (Mem) UsingShadowDecl(0, SourceLocation(), 0, 0); +} + UsingDecl *UsingShadowDecl::getUsingDecl() const { const UsingShadowDecl *Shadow = this; while (const UsingShadowDecl *NextShadow = @@ -1796,6 +1861,12 @@ UsingDecl *UsingDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation UL, return new (C) UsingDecl(DC, UL, QualifierLoc, NameInfo, IsTypeNameArg); } +UsingDecl *UsingDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(UsingDecl)); + return new (Mem) UsingDecl(0, SourceLocation(), NestedNameSpecifierLoc(), + DeclarationNameInfo(), false); +} + void UnresolvedUsingValueDecl::anchor() { } UnresolvedUsingValueDecl * @@ -1807,6 +1878,14 @@ UnresolvedUsingValueDecl::Create(ASTContext &C, DeclContext *DC, QualifierLoc, NameInfo); } +UnresolvedUsingValueDecl * +UnresolvedUsingValueDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(UnresolvedUsingValueDecl)); + return new (Mem) UnresolvedUsingValueDecl(0, QualType(), SourceLocation(), + NestedNameSpecifierLoc(), + DeclarationNameInfo()); +} + void UnresolvedUsingTypenameDecl::anchor() { } UnresolvedUsingTypenameDecl * @@ -1821,6 +1900,17 @@ UnresolvedUsingTypenameDecl::Create(ASTContext &C, DeclContext *DC, TargetName.getAsIdentifierInfo()); } +UnresolvedUsingTypenameDecl * +UnresolvedUsingTypenameDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, + sizeof(UnresolvedUsingTypenameDecl)); + return new (Mem) UnresolvedUsingTypenameDecl(0, SourceLocation(), + SourceLocation(), + NestedNameSpecifierLoc(), + SourceLocation(), + 0); +} + void StaticAssertDecl::anchor() { } StaticAssertDecl *StaticAssertDecl::Create(ASTContext &C, DeclContext *DC, @@ -1832,6 +1922,12 @@ StaticAssertDecl *StaticAssertDecl::Create(ASTContext &C, DeclContext *DC, RParenLoc); } +StaticAssertDecl *StaticAssertDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(StaticAssertDecl)); + return new (Mem) StaticAssertDecl(0, SourceLocation(), 0, 0,SourceLocation()); +} + static const char *getAccessName(AccessSpecifier AS) { switch (AS) { default: diff --git a/clang/lib/AST/DeclFriend.cpp b/clang/lib/AST/DeclFriend.cpp index e44333e..6e3bd8d 100644 --- a/clang/lib/AST/DeclFriend.cpp +++ b/clang/lib/AST/DeclFriend.cpp @@ -42,6 +42,7 @@ FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC, return FD; } -FriendDecl *FriendDecl::Create(ASTContext &C, EmptyShell Empty) { - return new (C) FriendDecl(Empty); +FriendDecl *FriendDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FriendDecl)); + return new (Mem) FriendDecl(EmptyShell()); } diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 59bfdc6..b0aeabf 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -409,6 +409,12 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, HasRelatedResultType); } +ObjCMethodDecl *ObjCMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCMethodDecl)); + return new (Mem) ObjCMethodDecl(SourceLocation(), SourceLocation(), + Selector(), QualType(), 0, 0); +} + void ObjCMethodDecl::setAsRedeclaration(const ObjCMethodDecl *PrevMethod) { assert(PrevMethod); getASTContext().setObjCMethodRedeclaration(PrevMethod, this); @@ -692,9 +698,11 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C, return Result; } -ObjCInterfaceDecl *ObjCInterfaceDecl::CreateEmpty(ASTContext &C) { - return new (C) ObjCInterfaceDecl(0, SourceLocation(), 0, SourceLocation(), - 0, false); +ObjCInterfaceDecl *ObjCInterfaceDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCInterfaceDecl)); + return new (Mem) ObjCInterfaceDecl(0, SourceLocation(), 0, SourceLocation(), + 0, false); } ObjCInterfaceDecl:: @@ -924,6 +932,12 @@ ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCContainerDecl *DC, ac, BW, synthesized); } +ObjCIvarDecl *ObjCIvarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCIvarDecl)); + return new (Mem) ObjCIvarDecl(0, SourceLocation(), SourceLocation(), 0, + QualType(), 0, ObjCIvarDecl::None, 0, false); +} + const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const { const ObjCContainerDecl *DC = cast(getDeclContext()); @@ -961,6 +975,13 @@ ObjCAtDefsFieldDecl return new (C) ObjCAtDefsFieldDecl(DC, StartLoc, IdLoc, Id, T, BW); } +ObjCAtDefsFieldDecl *ObjCAtDefsFieldDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCAtDefsFieldDecl)); + return new (Mem) ObjCAtDefsFieldDecl(0, SourceLocation(), SourceLocation(), + 0, QualType(), 0); +} + //===----------------------------------------------------------------------===// // ObjCProtocolDecl //===----------------------------------------------------------------------===// @@ -989,6 +1010,13 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, return Result; } +ObjCProtocolDecl *ObjCProtocolDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCProtocolDecl)); + return new (Mem) ObjCProtocolDecl(0, 0, SourceLocation(), SourceLocation(), + 0); +} + ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) { ObjCProtocolDecl *PDecl = this; @@ -1063,9 +1091,11 @@ ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC, return CatDecl; } -ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, EmptyShell Empty) { - return new (C) ObjCCategoryDecl(0, SourceLocation(), SourceLocation(), - SourceLocation(), 0, 0); +ObjCCategoryDecl *ObjCCategoryDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCCategoryDecl)); + return new (Mem) ObjCCategoryDecl(0, SourceLocation(), SourceLocation(), + SourceLocation(), 0, 0); } ObjCCategoryImplDecl *ObjCCategoryDecl::getImplementation() const { @@ -1097,6 +1127,13 @@ ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC, nameLoc, atStartLoc, CategoryNameLoc); } +ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCCategoryImplDecl)); + return new (Mem) ObjCCategoryImplDecl(0, 0, 0, SourceLocation(), + SourceLocation(), SourceLocation()); +} + ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const { // The class interface might be NULL if we are working with invalid code. if (const ObjCInterfaceDecl *ID = getClassInterface()) @@ -1183,6 +1220,13 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC, nameLoc, atStartLoc); } +ObjCImplementationDecl * +ObjCImplementationDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCImplementationDecl)); + return new (Mem) ObjCImplementationDecl(0, 0, 0, SourceLocation(), + SourceLocation()); +} + void ObjCImplementationDecl::setIvarInitializers(ASTContext &C, CXXCtorInitializer ** initializers, unsigned numInitializers) { @@ -1216,6 +1260,12 @@ ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC, return new (C) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass); } +ObjCCompatibleAliasDecl * +ObjCCompatibleAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCCompatibleAliasDecl)); + return new (Mem) ObjCCompatibleAliasDecl(0, SourceLocation(), 0, 0); +} + //===----------------------------------------------------------------------===// // ObjCPropertyDecl //===----------------------------------------------------------------------===// @@ -1231,6 +1281,13 @@ ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC, return new (C) ObjCPropertyDecl(DC, L, Id, AtLoc, T); } +ObjCPropertyDecl *ObjCPropertyDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void * Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCPropertyDecl)); + return new (Mem) ObjCPropertyDecl(0, SourceLocation(), 0, SourceLocation(), + 0); +} + //===----------------------------------------------------------------------===// // ObjCPropertyImplDecl //===----------------------------------------------------------------------===// @@ -1247,6 +1304,13 @@ ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C, ivarLoc); } +ObjCPropertyImplDecl *ObjCPropertyImplDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCPropertyImplDecl)); + return new (Mem) ObjCPropertyImplDecl(0, SourceLocation(), SourceLocation(), + 0, Dynamic, 0, SourceLocation()); +} + SourceRange ObjCPropertyImplDecl::getSourceRange() const { SourceLocation EndLoc = getLocation(); if (IvarLoc.isValid()) diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index a2d5a2d..f505321 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -224,9 +224,11 @@ FunctionTemplateDecl *FunctionTemplateDecl::Create(ASTContext &C, return new (C) FunctionTemplateDecl(DC, L, Name, Params, Decl); } -FunctionTemplateDecl *FunctionTemplateDecl::Create(ASTContext &C, EmptyShell) { - return new (C) FunctionTemplateDecl(0, SourceLocation(), DeclarationName(), - 0, 0); +FunctionTemplateDecl *FunctionTemplateDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FunctionTemplateDecl)); + return new (Mem) FunctionTemplateDecl(0, SourceLocation(), DeclarationName(), + 0, 0); } RedeclarableTemplateDecl::CommonBase * @@ -284,8 +286,10 @@ ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C, return New; } -ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C, EmptyShell Empty) { - return new (C) ClassTemplateDecl(Empty); +ClassTemplateDecl *ClassTemplateDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ClassTemplateDecl)); + return new (Mem) ClassTemplateDecl(EmptyShell()); } void ClassTemplateDecl::LoadLazySpecializations() { @@ -433,9 +437,10 @@ TemplateTypeParmDecl::Create(const ASTContext &C, DeclContext *DC, } TemplateTypeParmDecl * -TemplateTypeParmDecl::Create(const ASTContext &C, EmptyShell Empty) { - return new (C) TemplateTypeParmDecl(0, SourceLocation(), SourceLocation(), - 0, false); +TemplateTypeParmDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TemplateTypeParmDecl)); + return new (Mem) TemplateTypeParmDecl(0, SourceLocation(), SourceLocation(), + 0, false); } SourceLocation TemplateTypeParmDecl::getDefaultArgumentLoc() const { @@ -520,6 +525,27 @@ NonTypeTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC, ExpandedTInfos); } +NonTypeTemplateParmDecl * +NonTypeTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(NonTypeTemplateParmDecl)); + return new (Mem) NonTypeTemplateParmDecl(0, SourceLocation(), + SourceLocation(), 0, 0, 0, + QualType(), false, 0); +} + +NonTypeTemplateParmDecl * +NonTypeTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID, + unsigned NumExpandedTypes) { + unsigned Size = sizeof(NonTypeTemplateParmDecl) + + NumExpandedTypes * 2 * sizeof(void*); + + void *Mem = AllocateDeserializedDecl(C, ID, Size); + return new (Mem) NonTypeTemplateParmDecl(0, SourceLocation(), + SourceLocation(), 0, 0, 0, + QualType(), 0, 0, NumExpandedTypes, + 0); +} + SourceRange NonTypeTemplateParmDecl::getSourceRange() const { if (hasDefaultArgument() && !defaultArgumentWasInherited()) return SourceRange(getOuterLocStart(), @@ -548,6 +574,13 @@ TemplateTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC, Params); } +TemplateTemplateParmDecl * +TemplateTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TemplateTemplateParmDecl)); + return new (Mem) TemplateTemplateParmDecl(0, SourceLocation(), 0, 0, false, + 0, 0); +} + //===----------------------------------------------------------------------===// // TemplateArgumentList Implementation //===----------------------------------------------------------------------===// @@ -636,9 +669,11 @@ ClassTemplateSpecializationDecl::Create(ASTContext &Context, TagKind TK, } ClassTemplateSpecializationDecl * -ClassTemplateSpecializationDecl::Create(ASTContext &Context, EmptyShell Empty) { - return - new (Context)ClassTemplateSpecializationDecl(ClassTemplateSpecialization); +ClassTemplateSpecializationDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, + sizeof(ClassTemplateSpecializationDecl)); + return new (Mem) ClassTemplateSpecializationDecl(ClassTemplateSpecialization); } void @@ -750,9 +785,11 @@ Create(ASTContext &Context, TagKind TK,DeclContext *DC, } ClassTemplatePartialSpecializationDecl * -ClassTemplatePartialSpecializationDecl::Create(ASTContext &Context, - EmptyShell Empty) { - return new (Context)ClassTemplatePartialSpecializationDecl(); +ClassTemplatePartialSpecializationDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, + sizeof(ClassTemplatePartialSpecializationDecl)); + return new (Mem) ClassTemplatePartialSpecializationDecl(); } //===----------------------------------------------------------------------===// @@ -773,9 +810,10 @@ FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context, return Result; } -FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context, - EmptyShell Empty) { - return new (Context) FriendTemplateDecl(Empty); +FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FriendTemplateDecl)); + return new (Mem) FriendTemplateDecl(EmptyShell()); } //===----------------------------------------------------------------------===// @@ -792,10 +830,11 @@ TypeAliasTemplateDecl *TypeAliasTemplateDecl::Create(ASTContext &C, return new (C) TypeAliasTemplateDecl(DC, L, Name, Params, Decl); } -TypeAliasTemplateDecl *TypeAliasTemplateDecl::Create(ASTContext &C, - EmptyShell) { - return new (C) TypeAliasTemplateDecl(0, SourceLocation(), DeclarationName(), - 0, 0); +TypeAliasTemplateDecl *TypeAliasTemplateDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TypeAliasTemplateDecl)); + return new (Mem) TypeAliasTemplateDecl(0, SourceLocation(), DeclarationName(), + 0, 0); } void TypeAliasTemplateDecl::DeallocateCommon(void *Ptr) { @@ -813,3 +852,11 @@ TypeAliasTemplateDecl::newCommon(ASTContext &C) { //===----------------------------------------------------------------------===// void ClassScopeFunctionSpecializationDecl::anchor() { } + +ClassScopeFunctionSpecializationDecl * +ClassScopeFunctionSpecializationDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + void *Mem = AllocateDeserializedDecl(C, ID, + sizeof(ClassScopeFunctionSpecializationDecl)); + return new (Mem) ClassScopeFunctionSpecializationDecl(0, SourceLocation(), 0); +} diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 84f7545..cff8667 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -1877,208 +1877,160 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { case DECL_CONTEXT_VISIBLE: llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord"); case DECL_TYPEDEF: - D = TypedefDecl::Create(Context, 0, SourceLocation(), SourceLocation(), - 0, 0); + D = TypedefDecl::CreateDeserialized(Context, ID); break; case DECL_TYPEALIAS: - D = TypeAliasDecl::Create(Context, 0, SourceLocation(), SourceLocation(), - 0, 0); + D = TypeAliasDecl::CreateDeserialized(Context, ID); break; case DECL_ENUM: - D = EnumDecl::Create(Context, Decl::EmptyShell()); + D = EnumDecl::CreateDeserialized(Context, ID); break; case DECL_RECORD: - D = RecordDecl::Create(Context, Decl::EmptyShell()); + D = RecordDecl::CreateDeserialized(Context, ID); break; case DECL_ENUM_CONSTANT: - D = EnumConstantDecl::Create(Context, 0, SourceLocation(), 0, QualType(), - 0, llvm::APSInt()); + D = EnumConstantDecl::CreateDeserialized(Context, ID); break; case DECL_FUNCTION: - D = FunctionDecl::Create(Context, 0, SourceLocation(), SourceLocation(), - DeclarationName(), QualType(), 0); + D = FunctionDecl::CreateDeserialized(Context, ID); break; case DECL_LINKAGE_SPEC: - D = LinkageSpecDecl::Create(Context, 0, SourceLocation(), SourceLocation(), - (LinkageSpecDecl::LanguageIDs)0, - SourceLocation()); + D = LinkageSpecDecl::CreateDeserialized(Context, ID); break; case DECL_LABEL: - D = LabelDecl::Create(Context, 0, SourceLocation(), 0); + D = LabelDecl::CreateDeserialized(Context, ID); break; case DECL_NAMESPACE: - D = NamespaceDecl::Create(Context, 0, SourceLocation(), - SourceLocation(), 0); + D = NamespaceDecl::CreateDeserialized(Context, ID); break; case DECL_NAMESPACE_ALIAS: - D = NamespaceAliasDecl::Create(Context, 0, SourceLocation(), - SourceLocation(), 0, - NestedNameSpecifierLoc(), - SourceLocation(), 0); + D = NamespaceAliasDecl::CreateDeserialized(Context, ID); break; case DECL_USING: - D = UsingDecl::Create(Context, 0, SourceLocation(), - NestedNameSpecifierLoc(), DeclarationNameInfo(), - false); + D = UsingDecl::CreateDeserialized(Context, ID); break; case DECL_USING_SHADOW: - D = UsingShadowDecl::Create(Context, 0, SourceLocation(), 0, 0); + D = UsingShadowDecl::CreateDeserialized(Context, ID); break; case DECL_USING_DIRECTIVE: - D = UsingDirectiveDecl::Create(Context, 0, SourceLocation(), - SourceLocation(), NestedNameSpecifierLoc(), - SourceLocation(), 0, 0); + D = UsingDirectiveDecl::CreateDeserialized(Context, ID); break; case DECL_UNRESOLVED_USING_VALUE: - D = UnresolvedUsingValueDecl::Create(Context, 0, SourceLocation(), - NestedNameSpecifierLoc(), - DeclarationNameInfo()); + D = UnresolvedUsingValueDecl::CreateDeserialized(Context, ID); break; case DECL_UNRESOLVED_USING_TYPENAME: - D = UnresolvedUsingTypenameDecl::Create(Context, 0, SourceLocation(), - SourceLocation(), - NestedNameSpecifierLoc(), - SourceLocation(), - DeclarationName()); + D = UnresolvedUsingTypenameDecl::CreateDeserialized(Context, ID); break; case DECL_CXX_RECORD: - D = CXXRecordDecl::Create(Context, Decl::EmptyShell()); + D = CXXRecordDecl::CreateDeserialized(Context, ID); break; case DECL_CXX_METHOD: - D = CXXMethodDecl::Create(Context, 0, SourceLocation(), - DeclarationNameInfo(), QualType(), 0, - false, SC_None, false, false, SourceLocation()); + D = CXXMethodDecl::CreateDeserialized(Context, ID); break; case DECL_CXX_CONSTRUCTOR: - D = CXXConstructorDecl::Create(Context, Decl::EmptyShell()); + D = CXXConstructorDecl::CreateDeserialized(Context, ID); break; case DECL_CXX_DESTRUCTOR: - D = CXXDestructorDecl::Create(Context, Decl::EmptyShell()); + D = CXXDestructorDecl::CreateDeserialized(Context, ID); break; case DECL_CXX_CONVERSION: - D = CXXConversionDecl::Create(Context, Decl::EmptyShell()); + D = CXXConversionDecl::CreateDeserialized(Context, ID); break; case DECL_ACCESS_SPEC: - D = AccessSpecDecl::Create(Context, Decl::EmptyShell()); + D = AccessSpecDecl::CreateDeserialized(Context, ID); break; case DECL_FRIEND: - D = FriendDecl::Create(Context, Decl::EmptyShell()); + D = FriendDecl::CreateDeserialized(Context, ID); break; case DECL_FRIEND_TEMPLATE: - D = FriendTemplateDecl::Create(Context, Decl::EmptyShell()); + D = FriendTemplateDecl::CreateDeserialized(Context, ID); break; case DECL_CLASS_TEMPLATE: - D = ClassTemplateDecl::Create(Context, Decl::EmptyShell()); + D = ClassTemplateDecl::CreateDeserialized(Context, ID); break; case DECL_CLASS_TEMPLATE_SPECIALIZATION: - D = ClassTemplateSpecializationDecl::Create(Context, Decl::EmptyShell()); + D = ClassTemplateSpecializationDecl::CreateDeserialized(Context, ID); break; case DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION: - D = ClassTemplatePartialSpecializationDecl::Create(Context, - Decl::EmptyShell()); + D = ClassTemplatePartialSpecializationDecl::CreateDeserialized(Context, ID); break; case DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION: - D = ClassScopeFunctionSpecializationDecl::Create(Context, - Decl::EmptyShell()); + D = ClassScopeFunctionSpecializationDecl::CreateDeserialized(Context, ID); break; case DECL_FUNCTION_TEMPLATE: - D = FunctionTemplateDecl::Create(Context, Decl::EmptyShell()); + D = FunctionTemplateDecl::CreateDeserialized(Context, ID); break; case DECL_TEMPLATE_TYPE_PARM: - D = TemplateTypeParmDecl::Create(Context, Decl::EmptyShell()); + D = TemplateTypeParmDecl::CreateDeserialized(Context, ID); break; case DECL_NON_TYPE_TEMPLATE_PARM: - D = NonTypeTemplateParmDecl::Create(Context, 0, SourceLocation(), - SourceLocation(), 0, 0, 0, QualType(), - false, 0); + D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID); break; case DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK: - D = NonTypeTemplateParmDecl::Create(Context, 0, SourceLocation(), - SourceLocation(), 0, 0, 0, QualType(), - 0, 0, Record[Idx++], 0); + D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID, Record[Idx++]); break; case DECL_TEMPLATE_TEMPLATE_PARM: - D = TemplateTemplateParmDecl::Create(Context, 0, SourceLocation(), 0, 0, - false, 0, 0); + D = TemplateTemplateParmDecl::CreateDeserialized(Context, ID); break; case DECL_TYPE_ALIAS_TEMPLATE: - D = TypeAliasTemplateDecl::Create(Context, Decl::EmptyShell()); + D = TypeAliasTemplateDecl::CreateDeserialized(Context, ID); break; case DECL_STATIC_ASSERT: - D = StaticAssertDecl::Create(Context, 0, SourceLocation(), 0, 0, - SourceLocation()); + D = StaticAssertDecl::CreateDeserialized(Context, ID); break; - case DECL_OBJC_METHOD: - D = ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(), - Selector(), QualType(), 0, 0); + D = ObjCMethodDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_INTERFACE: - D = ObjCInterfaceDecl::CreateEmpty(Context); + D = ObjCInterfaceDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_IVAR: - D = ObjCIvarDecl::Create(Context, 0, SourceLocation(), SourceLocation(), - 0, QualType(), 0, ObjCIvarDecl::None); + D = ObjCIvarDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_PROTOCOL: - D = ObjCProtocolDecl::Create(Context, 0, 0, SourceLocation(), - SourceLocation(), 0); + D = ObjCProtocolDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_AT_DEFS_FIELD: - D = ObjCAtDefsFieldDecl::Create(Context, 0, SourceLocation(), - SourceLocation(), 0, QualType(), 0); + D = ObjCAtDefsFieldDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_CATEGORY: - D = ObjCCategoryDecl::Create(Context, Decl::EmptyShell()); + D = ObjCCategoryDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_CATEGORY_IMPL: - D = ObjCCategoryImplDecl::Create(Context, 0, 0, 0, SourceLocation(), - SourceLocation(), SourceLocation()); + D = ObjCCategoryImplDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_IMPLEMENTATION: - D = ObjCImplementationDecl::Create(Context, 0, 0, 0, SourceLocation(), - SourceLocation()); + D = ObjCImplementationDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_COMPATIBLE_ALIAS: - D = ObjCCompatibleAliasDecl::Create(Context, 0, SourceLocation(), 0, 0); + D = ObjCCompatibleAliasDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_PROPERTY: - D = ObjCPropertyDecl::Create(Context, 0, SourceLocation(), 0, SourceLocation(), - 0); + D = ObjCPropertyDecl::CreateDeserialized(Context, ID); break; case DECL_OBJC_PROPERTY_IMPL: - D = ObjCPropertyImplDecl::Create(Context, 0, SourceLocation(), - SourceLocation(), 0, - ObjCPropertyImplDecl::Dynamic, 0, - SourceLocation()); + D = ObjCPropertyImplDecl::CreateDeserialized(Context, ID); break; case DECL_FIELD: - D = FieldDecl::Create(Context, 0, SourceLocation(), SourceLocation(), 0, - QualType(), 0, 0, false, false); + D = FieldDecl::CreateDeserialized(Context, ID); break; case DECL_INDIRECTFIELD: - D = IndirectFieldDecl::Create(Context, 0, SourceLocation(), 0, QualType(), - 0, 0); + D = IndirectFieldDecl::CreateDeserialized(Context, ID); break; case DECL_VAR: - D = VarDecl::Create(Context, 0, SourceLocation(), SourceLocation(), 0, - QualType(), 0, SC_None, SC_None); + D = VarDecl::CreateDeserialized(Context, ID); break; - case DECL_IMPLICIT_PARAM: - D = ImplicitParamDecl::Create(Context, 0, SourceLocation(), 0, QualType()); + D = ImplicitParamDecl::CreateDeserialized(Context, ID); break; - case DECL_PARM_VAR: - D = ParmVarDecl::Create(Context, 0, SourceLocation(), SourceLocation(), 0, - QualType(), 0, SC_None, SC_None, 0); + D = ParmVarDecl::CreateDeserialized(Context, ID); break; case DECL_FILE_SCOPE_ASM: - D = FileScopeAsmDecl::Create(Context, 0, 0, SourceLocation(), - SourceLocation()); + D = FileScopeAsmDecl::CreateDeserialized(Context, ID); break; case DECL_BLOCK: - D = BlockDecl::Create(Context, 0, SourceLocation()); + D = BlockDecl::CreateDeserialized(Context, ID); break; case DECL_CXX_BASE_SPECIFIERS: Error("attempt to read a C++ base-specifier record as a declaration"); @@ -2086,7 +2038,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { case DECL_IMPORT: // Note: last entry of the ImportDecl record is the number of stored source // locations. - D = ImportDecl::CreateEmpty(Context, Record.back()); + D = ImportDecl::CreateDeserialized(Context, ID, Record.back()); break; } -- 2.7.4