Sebastian Redl | 904c9c8 | 2010-08-18 23:57:11 +0000 | [diff] [blame] | 1 | //===--- ASTReaderDecl.cpp - Decl Deserialization ---------------*- C++ -*-===// |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 10 | // This file implements the ASTReader::ReadDeclRecord method, which is the |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 11 | // entrypoint for loading a decl. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 15 | #include "ASTCommon.h" |
Sebastian Redl | 6ab7cd8 | 2010-08-18 23:57:17 +0000 | [diff] [blame] | 16 | #include "clang/Serialization/ASTReader.h" |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 17 | #include "clang/AST/ASTConsumer.h" |
| 18 | #include "clang/AST/ASTContext.h" |
| 19 | #include "clang/AST/DeclVisitor.h" |
| 20 | #include "clang/AST/DeclGroup.h" |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 21 | #include "clang/AST/DeclCXX.h" |
| 22 | #include "clang/AST/DeclTemplate.h" |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 23 | #include "clang/AST/Expr.h" |
| 24 | using namespace clang; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 25 | using namespace clang::serialization; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 26 | |
| 27 | //===----------------------------------------------------------------------===// |
| 28 | // Declaration deserialization |
| 29 | //===----------------------------------------------------------------------===// |
| 30 | |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 31 | namespace clang { |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 32 | class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> { |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 33 | ASTReader &Reader; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 34 | ASTReader::PerFileData &F; |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 35 | llvm::BitstreamCursor &Cursor; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 36 | const DeclID ThisDeclID; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 37 | typedef ASTReader::RecordData RecordData; |
| 38 | const RecordData &Record; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 39 | unsigned &Idx; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 40 | TypeID TypeIDForTypeDecl; |
Douglas Gregor | 67da6f6 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 41 | |
| 42 | DeclID DeclContextIDForTemplateParmDecl; |
| 43 | DeclID LexicalDeclContextIDForTemplateParmDecl; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 44 | |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 45 | uint64_t GetCurrentCursorOffset(); |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 46 | SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 47 | return Reader.ReadSourceLocation(F, R, I); |
| 48 | } |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 49 | SourceRange ReadSourceRange(const RecordData &R, unsigned &I) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 50 | return Reader.ReadSourceRange(F, R, I); |
| 51 | } |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 52 | TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 53 | return Reader.GetTypeSourceInfo(F, R, I); |
| 54 | } |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 55 | void ReadQualifierInfo(QualifierInfo &Info, |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 56 | const RecordData &R, unsigned &I) { |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 57 | Reader.ReadQualifierInfo(F, Info, R, I); |
| 58 | } |
| 59 | void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name, |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 60 | const RecordData &R, unsigned &I) { |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 61 | Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I); |
| 62 | } |
| 63 | void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 64 | const RecordData &R, unsigned &I) { |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 65 | Reader.ReadDeclarationNameInfo(F, NameInfo, R, I); |
| 66 | } |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 67 | |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 68 | void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data, |
| 69 | const RecordData &R, unsigned &I); |
| 70 | |
| 71 | void InitializeCXXDefinitionData(CXXRecordDecl *D, |
| 72 | CXXRecordDecl *DefinitionDecl, |
| 73 | const RecordData &Record, unsigned &Idx); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 74 | public: |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 75 | ASTDeclReader(ASTReader &Reader, ASTReader::PerFileData &F, |
| 76 | llvm::BitstreamCursor &Cursor, DeclID thisDeclID, |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 77 | const RecordData &Record, unsigned &Idx) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 78 | : Reader(Reader), F(F), Cursor(Cursor), ThisDeclID(thisDeclID), |
| 79 | Record(Record), Idx(Idx), TypeIDForTypeDecl(0) { } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 80 | |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 81 | static void attachPreviousDecl(Decl *D, Decl *previous); |
| 82 | |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 83 | void Visit(Decl *D); |
| 84 | |
Sebastian Redl | f79a719 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 85 | void UpdateDecl(Decl *D, ASTReader::PerFileData &Module, |
| 86 | const RecordData &Record); |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 87 | |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 88 | void VisitDecl(Decl *D); |
| 89 | void VisitTranslationUnitDecl(TranslationUnitDecl *TU); |
| 90 | void VisitNamedDecl(NamedDecl *ND); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 91 | void VisitLabelDecl(LabelDecl *LD); |
Douglas Gregor | 0cef483 | 2010-02-21 18:22:14 +0000 | [diff] [blame] | 92 | void VisitNamespaceDecl(NamespaceDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 93 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); |
| 94 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 95 | void VisitTypeDecl(TypeDecl *TD); |
| 96 | void VisitTypedefDecl(TypedefDecl *TD); |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 97 | void VisitTypeAliasDecl(TypeAliasDecl *TD); |
Argyrios Kyrtzidis | 8f4eae9 | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 98 | void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 99 | void VisitTagDecl(TagDecl *TD); |
| 100 | void VisitEnumDecl(EnumDecl *ED); |
| 101 | void VisitRecordDecl(RecordDecl *RD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 102 | void VisitCXXRecordDecl(CXXRecordDecl *D); |
| 103 | void VisitClassTemplateSpecializationDecl( |
| 104 | ClassTemplateSpecializationDecl *D); |
| 105 | void VisitClassTemplatePartialSpecializationDecl( |
| 106 | ClassTemplatePartialSpecializationDecl *D); |
| 107 | void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 108 | void VisitValueDecl(ValueDecl *VD); |
| 109 | void VisitEnumConstantDecl(EnumConstantDecl *ECD); |
Argyrios Kyrtzidis | 8f4eae9 | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 110 | void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 111 | void VisitDeclaratorDecl(DeclaratorDecl *DD); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 112 | void VisitFunctionDecl(FunctionDecl *FD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 113 | void VisitCXXMethodDecl(CXXMethodDecl *D); |
| 114 | void VisitCXXConstructorDecl(CXXConstructorDecl *D); |
| 115 | void VisitCXXDestructorDecl(CXXDestructorDecl *D); |
| 116 | void VisitCXXConversionDecl(CXXConversionDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 117 | void VisitFieldDecl(FieldDecl *FD); |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 118 | void VisitIndirectFieldDecl(IndirectFieldDecl *FD); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 119 | void VisitVarDecl(VarDecl *VD); |
| 120 | void VisitImplicitParamDecl(ImplicitParamDecl *PD); |
| 121 | void VisitParmVarDecl(ParmVarDecl *PD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 122 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); |
| 123 | void VisitTemplateDecl(TemplateDecl *D); |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 124 | void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 125 | void VisitClassTemplateDecl(ClassTemplateDecl *D); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 126 | void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 127 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); |
Richard Smith | 3e4c6c4 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 128 | void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D); |
Argyrios Kyrtzidis | b01a552 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 129 | void VisitUsingDecl(UsingDecl *D); |
| 130 | void VisitUsingShadowDecl(UsingShadowDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 131 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 132 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD); |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 133 | void VisitAccessSpecDecl(AccessSpecDecl *D); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 134 | void VisitFriendDecl(FriendDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 135 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); |
| 136 | void VisitStaticAssertDecl(StaticAssertDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 137 | void VisitBlockDecl(BlockDecl *BD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 138 | |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 139 | std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC); |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 140 | template <typename T> void VisitRedeclarable(Redeclarable<T> *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 141 | |
Sean Hunt | 9a55591 | 2010-05-30 07:21:58 +0000 | [diff] [blame] | 142 | // FIXME: Reorder according to DeclNodes.td? |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 143 | void VisitObjCMethodDecl(ObjCMethodDecl *D); |
| 144 | void VisitObjCContainerDecl(ObjCContainerDecl *D); |
| 145 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); |
| 146 | void VisitObjCIvarDecl(ObjCIvarDecl *D); |
| 147 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); |
| 148 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); |
| 149 | void VisitObjCClassDecl(ObjCClassDecl *D); |
| 150 | void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D); |
| 151 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); |
| 152 | void VisitObjCImplDecl(ObjCImplDecl *D); |
| 153 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); |
| 154 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); |
| 155 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); |
| 156 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
| 157 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
| 158 | }; |
| 159 | } |
| 160 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 161 | uint64_t ASTDeclReader::GetCurrentCursorOffset() { |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 162 | uint64_t Off = 0; |
| 163 | for (unsigned I = 0, N = Reader.Chain.size(); I != N; ++I) { |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 164 | ASTReader::PerFileData &F = *Reader.Chain[N - I - 1]; |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 165 | if (&Cursor == &F.DeclsCursor) { |
| 166 | Off += F.DeclsCursor.GetCurrentBitNo(); |
| 167 | break; |
| 168 | } |
| 169 | Off += F.SizeInBits; |
| 170 | } |
| 171 | return Off; |
| 172 | } |
| 173 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 174 | void ASTDeclReader::Visit(Decl *D) { |
| 175 | DeclVisitor<ASTDeclReader, void>::Visit(D); |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 176 | |
Jonathan D. Turner | 953c564 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 177 | if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) { |
| 178 | if (DD->DeclInfo) { |
| 179 | DeclaratorDecl::ExtInfo *Info = |
| 180 | DD->DeclInfo.get<DeclaratorDecl::ExtInfo *>(); |
| 181 | Info->TInfo = |
| 182 | GetTypeSourceInfo(Record, Idx); |
| 183 | } |
| 184 | else { |
| 185 | DD->DeclInfo = GetTypeSourceInfo(Record, Idx); |
| 186 | } |
| 187 | } |
| 188 | |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 189 | if (TypeDecl *TD = dyn_cast<TypeDecl>(D)) { |
Douglas Gregor | deacbdc | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 190 | // if we have a fully initialized TypeDecl, we can safely read its type now. |
Douglas Gregor | 1ab55e9 | 2010-12-10 17:03:06 +0000 | [diff] [blame] | 191 | TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull()); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 192 | } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
| 193 | // FunctionDecl's body was written last after all other Stmts/Exprs. |
| 194 | if (Record[Idx++]) |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 195 | FD->setLazyBody(GetCurrentCursorOffset()); |
Douglas Gregor | 67da6f6 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 196 | } else if (D->isTemplateParameter()) { |
| 197 | // If we have a fully initialized template parameter, we can now |
| 198 | // set its DeclContext. |
| 199 | D->setDeclContext( |
| 200 | cast_or_null<DeclContext>( |
| 201 | Reader.GetDecl(DeclContextIDForTemplateParmDecl))); |
| 202 | D->setLexicalDeclContext( |
| 203 | cast_or_null<DeclContext>( |
| 204 | Reader.GetDecl(LexicalDeclContextIDForTemplateParmDecl))); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 205 | } |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 206 | } |
| 207 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 208 | void ASTDeclReader::VisitDecl(Decl *D) { |
Douglas Gregor | 67da6f6 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 209 | if (D->isTemplateParameter()) { |
| 210 | // We don't want to deserialize the DeclContext of a template |
| 211 | // parameter immediately, because the template parameter might be |
| 212 | // used in the formulation of its DeclContext. Use the translation |
| 213 | // unit DeclContext as a placeholder. |
| 214 | DeclContextIDForTemplateParmDecl = Record[Idx++]; |
| 215 | LexicalDeclContextIDForTemplateParmDecl = Record[Idx++]; |
| 216 | D->setDeclContext(Reader.getContext()->getTranslationUnitDecl()); |
| 217 | } else { |
| 218 | D->setDeclContext(cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++]))); |
| 219 | D->setLexicalDeclContext( |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 220 | cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 67da6f6 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 221 | } |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 222 | D->setLocation(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 223 | D->setInvalidDecl(Record[Idx++]); |
Argyrios Kyrtzidis | 4eb9fc0 | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 224 | if (Record[Idx++]) { // hasAttrs |
Sean Hunt | cf807c4 | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 225 | AttrVec Attrs; |
Argyrios Kyrtzidis | 4eb9fc0 | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 226 | Reader.ReadAttributes(F, Attrs, Record, Idx); |
Sean Hunt | cf807c4 | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 227 | D->setAttrs(Attrs); |
| 228 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 229 | D->setImplicit(Record[Idx++]); |
Douglas Gregor | e0762c9 | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 230 | D->setUsed(Record[Idx++]); |
Argyrios Kyrtzidis | 6b6b42a | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 231 | D->setReferenced(Record[Idx++]); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 232 | D->setAccess((AccessSpecifier)Record[Idx++]); |
Sebastian Redl | 1d9f1fe | 2010-10-05 16:15:19 +0000 | [diff] [blame] | 233 | D->setPCHLevel(Record[Idx++] + (F.Type <= ASTReader::PCH)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 234 | } |
| 235 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 236 | void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 237 | VisitDecl(TU); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 238 | TU->setAnonymousNamespace( |
| 239 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 240 | } |
| 241 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 242 | void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 243 | VisitDecl(ND); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 244 | ND->setDeclName(Reader.ReadDeclarationName(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 247 | void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 248 | VisitNamedDecl(TD); |
Abramo Bagnara | 344577e | 2011-03-06 15:48:19 +0000 | [diff] [blame] | 249 | TD->setLocStart(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 250 | // Delay type reading until after we have fully initialized the decl. |
Douglas Gregor | deacbdc | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 251 | TypeIDForTypeDecl = Record[Idx++]; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 252 | } |
| 253 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 254 | void ASTDeclReader::VisitTypedefDecl(TypedefDecl *TD) { |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 255 | VisitTypeDecl(TD); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 256 | TD->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 257 | } |
| 258 | |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 259 | void ASTDeclReader::VisitTypeAliasDecl(TypeAliasDecl *TD) { |
| 260 | VisitTypeDecl(TD); |
| 261 | TD->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
| 262 | } |
| 263 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 264 | void ASTDeclReader::VisitTagDecl(TagDecl *TD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 265 | VisitTypeDecl(TD); |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 266 | VisitRedeclarable(TD); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 267 | TD->IdentifierNamespace = Record[Idx++]; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 268 | TD->setTagKind((TagDecl::TagKind)Record[Idx++]); |
| 269 | TD->setDefinition(Record[Idx++]); |
Douglas Gregor | b37b648 | 2010-02-12 17:40:34 +0000 | [diff] [blame] | 270 | TD->setEmbeddedInDeclarator(Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 271 | TD->setRBraceLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 272 | if (Record[Idx++]) { // hasExtInfo |
| 273 | TagDecl::ExtInfo *Info = new (*Reader.getContext()) TagDecl::ExtInfo(); |
| 274 | ReadQualifierInfo(*Info, Record, Idx); |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 275 | TD->TypedefNameDeclOrQualifier = Info; |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 276 | } else |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 277 | TD->setTypedefNameForAnonDecl( |
| 278 | cast_or_null<TypedefNameDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 279 | } |
| 280 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 281 | void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 282 | VisitTagDecl(ED); |
Douglas Gregor | 1274ccd | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 283 | if (TypeSourceInfo *TI = Reader.GetTypeSourceInfo(F, Record, Idx)) |
| 284 | ED->setIntegerTypeSourceInfo(TI); |
| 285 | else |
| 286 | ED->setIntegerType(Reader.GetType(Record[Idx++])); |
John McCall | 842aef8 | 2009-12-09 09:09:27 +0000 | [diff] [blame] | 287 | ED->setPromotionType(Reader.GetType(Record[Idx++])); |
John McCall | 1b5a618 | 2010-05-06 08:49:23 +0000 | [diff] [blame] | 288 | ED->setNumPositiveBits(Record[Idx++]); |
| 289 | ED->setNumNegativeBits(Record[Idx++]); |
Douglas Gregor | 1274ccd | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 290 | ED->IsScoped = Record[Idx++]; |
Abramo Bagnara | a88cefd | 2010-12-03 18:54:17 +0000 | [diff] [blame] | 291 | ED->IsScopedUsingClassTag = Record[Idx++]; |
Douglas Gregor | 1274ccd | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 292 | ED->IsFixed = Record[Idx++]; |
Argyrios Kyrtzidis | 7422827 | 2010-07-06 15:36:48 +0000 | [diff] [blame] | 293 | ED->setInstantiationOfMemberEnum( |
| 294 | cast_or_null<EnumDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 297 | void ASTDeclReader::VisitRecordDecl(RecordDecl *RD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 298 | VisitTagDecl(RD); |
| 299 | RD->setHasFlexibleArrayMember(Record[Idx++]); |
| 300 | RD->setAnonymousStructOrUnion(Record[Idx++]); |
Fariborz Jahanian | 643b7df | 2009-07-08 16:37:44 +0000 | [diff] [blame] | 301 | RD->setHasObjectMember(Record[Idx++]); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 302 | } |
| 303 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 304 | void ASTDeclReader::VisitValueDecl(ValueDecl *VD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 305 | VisitNamedDecl(VD); |
| 306 | VD->setType(Reader.GetType(Record[Idx++])); |
| 307 | } |
| 308 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 309 | void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 310 | VisitValueDecl(ECD); |
| 311 | if (Record[Idx++]) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 312 | ECD->setInitExpr(Reader.ReadExpr(F)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 313 | ECD->setInitVal(Reader.ReadAPSInt(Record, Idx)); |
| 314 | } |
| 315 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 316 | void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 317 | VisitValueDecl(DD); |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 318 | DD->setInnerLocStart(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 319 | if (Record[Idx++]) { // hasExtInfo |
| 320 | DeclaratorDecl::ExtInfo *Info |
| 321 | = new (*Reader.getContext()) DeclaratorDecl::ExtInfo(); |
| 322 | ReadQualifierInfo(*Info, Record, Idx); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 323 | DD->DeclInfo = Info; |
Jonathan D. Turner | 953c564 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 324 | } |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 327 | void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 328 | VisitDeclaratorDecl(FD); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 329 | VisitRedeclarable(FD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 330 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 331 | ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName(), Record, Idx); |
Argyrios Kyrtzidis | c8f9af2 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 332 | FD->IdentifierNamespace = Record[Idx++]; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 333 | switch ((FunctionDecl::TemplatedKind)Record[Idx++]) { |
Argyrios Kyrtzidis | dc767e3 | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 334 | default: assert(false && "Unhandled TemplatedKind!"); |
| 335 | break; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 336 | case FunctionDecl::TK_NonTemplate: |
| 337 | break; |
| 338 | case FunctionDecl::TK_FunctionTemplate: |
| 339 | FD->setDescribedFunctionTemplate( |
| 340 | cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]))); |
| 341 | break; |
| 342 | case FunctionDecl::TK_MemberSpecialization: { |
| 343 | FunctionDecl *InstFD = cast<FunctionDecl>(Reader.GetDecl(Record[Idx++])); |
| 344 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 345 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 346 | FD->setInstantiationOfMemberFunction(*Reader.getContext(), InstFD, TSK); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 347 | FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI); |
| 348 | break; |
| 349 | } |
| 350 | case FunctionDecl::TK_FunctionTemplateSpecialization: { |
| 351 | FunctionTemplateDecl *Template |
| 352 | = cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
| 353 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
| 354 | |
| 355 | // Template arguments. |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 356 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 357 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 358 | |
| 359 | // Template args as written. |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 360 | llvm::SmallVector<TemplateArgumentLoc, 8> TemplArgLocs; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 361 | SourceLocation LAngleLoc, RAngleLoc; |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 362 | if (Record[Idx++]) { // TemplateArgumentsAsWritten != 0 |
| 363 | unsigned NumTemplateArgLocs = Record[Idx++]; |
| 364 | TemplArgLocs.reserve(NumTemplateArgLocs); |
| 365 | for (unsigned i=0; i != NumTemplateArgLocs; ++i) |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 366 | TemplArgLocs.push_back( |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 367 | Reader.ReadTemplateArgumentLoc(F, Record, Idx)); |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 368 | |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 369 | LAngleLoc = ReadSourceLocation(Record, Idx); |
| 370 | RAngleLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 371 | } |
Argyrios Kyrtzidis | 7b081c8 | 2010-07-05 10:37:55 +0000 | [diff] [blame] | 372 | |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 373 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 374 | |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 375 | ASTContext &C = *Reader.getContext(); |
| 376 | TemplateArgumentList *TemplArgList |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 377 | = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), TemplArgs.size()); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 378 | TemplateArgumentListInfo *TemplArgsInfo |
| 379 | = new (C) TemplateArgumentListInfo(LAngleLoc, RAngleLoc); |
| 380 | for (unsigned i=0, e = TemplArgLocs.size(); i != e; ++i) |
| 381 | TemplArgsInfo->addArgument(TemplArgLocs[i]); |
| 382 | FunctionTemplateSpecializationInfo *FTInfo |
| 383 | = FunctionTemplateSpecializationInfo::Create(C, FD, Template, TSK, |
| 384 | TemplArgList, |
| 385 | TemplArgsInfo, POI); |
| 386 | FD->TemplateOrSpecialization = FTInfo; |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 387 | |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 388 | if (FD->isCanonicalDecl()) { // if canonical add to template's set. |
Argyrios Kyrtzidis | 99a8ca0 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 389 | // The template that contains the specializations set. It's not safe to |
| 390 | // use getCanonicalDecl on Template since it may still be initializing. |
| 391 | FunctionTemplateDecl *CanonTemplate |
| 392 | = cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 393 | // Get the InsertPos by FindNodeOrInsertPos() instead of calling |
| 394 | // InsertNode(FTInfo) directly to avoid the getASTContext() call in |
| 395 | // FunctionTemplateSpecializationInfo's Profile(). |
| 396 | // We avoid getASTContext because a decl in the parent hierarchy may |
| 397 | // be initializing. |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 398 | llvm::FoldingSetNodeID ID; |
| 399 | FunctionTemplateSpecializationInfo::Profile(ID, TemplArgs.data(), |
| 400 | TemplArgs.size(), C); |
| 401 | void *InsertPos = 0; |
Argyrios Kyrtzidis | 99a8ca0 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 402 | CanonTemplate->getSpecializations().FindNodeOrInsertPos(ID, InsertPos); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 403 | assert(InsertPos && "Another specialization already inserted!"); |
Argyrios Kyrtzidis | 99a8ca0 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 404 | CanonTemplate->getSpecializations().InsertNode(FTInfo, InsertPos); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 405 | } |
Argyrios Kyrtzidis | dc767e3 | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 406 | break; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 407 | } |
| 408 | case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { |
| 409 | // Templates. |
| 410 | UnresolvedSet<8> TemplDecls; |
| 411 | unsigned NumTemplates = Record[Idx++]; |
| 412 | while (NumTemplates--) |
| 413 | TemplDecls.addDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 414 | |
| 415 | // Templates args. |
| 416 | TemplateArgumentListInfo TemplArgs; |
| 417 | unsigned NumArgs = Record[Idx++]; |
| 418 | while (NumArgs--) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 419 | TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(F, Record, Idx)); |
| 420 | TemplArgs.setLAngleLoc(ReadSourceLocation(Record, Idx)); |
| 421 | TemplArgs.setRAngleLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 422 | |
| 423 | FD->setDependentTemplateSpecialization(*Reader.getContext(), |
| 424 | TemplDecls, TemplArgs); |
Argyrios Kyrtzidis | dc767e3 | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 425 | break; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 426 | } |
| 427 | } |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 428 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 429 | // FunctionDecl's body is handled last at ASTDeclReader::Visit, |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 430 | // after everything else is read. |
| 431 | |
Douglas Gregor | 381d34e | 2010-12-06 18:36:25 +0000 | [diff] [blame] | 432 | FD->SClass = (StorageClass)Record[Idx++]; |
Argyrios Kyrtzidis | 20df8e7 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 433 | FD->SClassAsWritten = (StorageClass)Record[Idx++]; |
Douglas Gregor | 8f15094 | 2010-12-09 16:59:22 +0000 | [diff] [blame] | 434 | FD->IsInline = Record[Idx++]; |
| 435 | FD->IsInlineSpecified = Record[Idx++]; |
Argyrios Kyrtzidis | 20df8e7 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 436 | FD->IsVirtualAsWritten = Record[Idx++]; |
| 437 | FD->IsPure = Record[Idx++]; |
| 438 | FD->HasInheritedPrototype = Record[Idx++]; |
| 439 | FD->HasWrittenPrototype = Record[Idx++]; |
| 440 | FD->IsDeleted = Record[Idx++]; |
| 441 | FD->IsTrivial = Record[Idx++]; |
Sean Hunt | 2be7e90 | 2011-05-12 22:46:29 +0000 | [diff] [blame] | 442 | FD->IsDefaulted = Record[Idx++]; |
| 443 | FD->IsExplicitlyDefaulted = Record[Idx++]; |
Argyrios Kyrtzidis | 20df8e7 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 444 | FD->HasImplicitReturnZero = Record[Idx++]; |
| 445 | FD->EndRangeLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 446 | |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 447 | // Read in the parameters. |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 448 | unsigned NumParams = Record[Idx++]; |
| 449 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 450 | Params.reserve(NumParams); |
| 451 | for (unsigned I = 0; I != NumParams; ++I) |
| 452 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 453 | FD->setParams(*Reader.getContext(), Params.data(), NumParams); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 456 | void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 457 | VisitNamedDecl(MD); |
| 458 | if (Record[Idx++]) { |
| 459 | // In practice, this won't be executed (since method definitions |
| 460 | // don't occur in header files). |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 461 | MD->setBody(Reader.ReadStmt(F)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 462 | MD->setSelfDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); |
| 463 | MD->setCmdDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); |
| 464 | } |
| 465 | MD->setInstanceMethod(Record[Idx++]); |
| 466 | MD->setVariadic(Record[Idx++]); |
| 467 | MD->setSynthesized(Record[Idx++]); |
Fariborz Jahanian | 3fe1041 | 2010-07-22 18:24:20 +0000 | [diff] [blame] | 468 | MD->setDefined(Record[Idx++]); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 469 | MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]); |
| 470 | MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); |
Douglas Gregor | 926df6c | 2011-06-11 01:09:30 +0000 | [diff] [blame] | 471 | MD->SetRelatedResultType(Record[Idx++]); |
Fariborz Jahanian | 7732cc9 | 2010-04-08 21:29:11 +0000 | [diff] [blame] | 472 | MD->setNumSelectorArgs(unsigned(Record[Idx++])); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 473 | MD->setResultType(Reader.GetType(Record[Idx++])); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 474 | MD->setResultTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
| 475 | MD->setEndLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 476 | unsigned NumParams = Record[Idx++]; |
| 477 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 478 | Params.reserve(NumParams); |
| 479 | for (unsigned I = 0; I != NumParams; ++I) |
| 480 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | 4ecb25f | 2010-04-09 15:40:42 +0000 | [diff] [blame] | 481 | MD->setMethodParams(*Reader.getContext(), Params.data(), NumParams, |
| 482 | NumParams); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 483 | } |
| 484 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 485 | void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 486 | VisitNamedDecl(CD); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 487 | SourceLocation A = ReadSourceLocation(Record, Idx); |
| 488 | SourceLocation B = ReadSourceLocation(Record, Idx); |
Ted Kremenek | 782f2f5 | 2010-01-07 01:20:12 +0000 | [diff] [blame] | 489 | CD->setAtEndRange(SourceRange(A, B)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 490 | } |
| 491 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 492 | void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 493 | VisitObjCContainerDecl(ID); |
Douglas Gregor | 1ab55e9 | 2010-12-10 17:03:06 +0000 | [diff] [blame] | 494 | ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtrOrNull()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 495 | ID->setSuperClass(cast_or_null<ObjCInterfaceDecl> |
| 496 | (Reader.GetDecl(Record[Idx++]))); |
Ted Kremenek | 53b9441 | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 497 | |
| 498 | // Read the directly referenced protocols and their SourceLocations. |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 499 | unsigned NumProtocols = Record[Idx++]; |
| 500 | llvm::SmallVector<ObjCProtocolDecl *, 16> Protocols; |
| 501 | Protocols.reserve(NumProtocols); |
| 502 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 503 | Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 504 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 505 | ProtoLocs.reserve(NumProtocols); |
| 506 | for (unsigned I = 0; I != NumProtocols; ++I) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 507 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 508 | ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(), |
| 509 | *Reader.getContext()); |
Ted Kremenek | 53b9441 | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 510 | |
| 511 | // Read the transitive closure of protocols referenced by this class. |
| 512 | NumProtocols = Record[Idx++]; |
| 513 | Protocols.clear(); |
| 514 | Protocols.reserve(NumProtocols); |
| 515 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 516 | Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
| 517 | ID->AllReferencedProtocols.set(Protocols.data(), NumProtocols, |
| 518 | *Reader.getContext()); |
| 519 | |
| 520 | // Read the ivars. |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 521 | unsigned NumIvars = Record[Idx++]; |
| 522 | llvm::SmallVector<ObjCIvarDecl *, 16> IVars; |
| 523 | IVars.reserve(NumIvars); |
| 524 | for (unsigned I = 0; I != NumIvars; ++I) |
| 525 | IVars.push_back(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 526 | ID->setCategoryList( |
| 527 | cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | 2c18bb7 | 2010-08-20 21:21:08 +0000 | [diff] [blame] | 528 | // We will rebuild this list lazily. |
| 529 | ID->setIvarList(0); |
Douglas Gregor | deacbdc | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 530 | ID->setForwardDecl(Record[Idx++]); |
| 531 | ID->setImplicitInterfaceDecl(Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 532 | ID->setClassLoc(ReadSourceLocation(Record, Idx)); |
| 533 | ID->setSuperClassLoc(ReadSourceLocation(Record, Idx)); |
| 534 | ID->setLocEnd(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 535 | } |
| 536 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 537 | void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 538 | VisitFieldDecl(IVD); |
| 539 | IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]); |
Fariborz Jahanian | 2c18bb7 | 2010-08-20 21:21:08 +0000 | [diff] [blame] | 540 | // This field will be built lazily. |
| 541 | IVD->setNextIvar(0); |
Fariborz Jahanian | ac0021b | 2010-07-17 18:35:47 +0000 | [diff] [blame] | 542 | bool synth = Record[Idx++]; |
| 543 | IVD->setSynthesize(synth); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 544 | } |
| 545 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 546 | void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 547 | VisitObjCContainerDecl(PD); |
| 548 | PD->setForwardDecl(Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 549 | PD->setLocEnd(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 550 | unsigned NumProtoRefs = Record[Idx++]; |
| 551 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 552 | ProtoRefs.reserve(NumProtoRefs); |
| 553 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 554 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 555 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 556 | ProtoLocs.reserve(NumProtoRefs); |
| 557 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 558 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 559 | PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 560 | *Reader.getContext()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 561 | } |
| 562 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 563 | void ASTDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 564 | VisitFieldDecl(FD); |
| 565 | } |
| 566 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 567 | void ASTDeclReader::VisitObjCClassDecl(ObjCClassDecl *CD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 568 | VisitDecl(CD); |
| 569 | unsigned NumClassRefs = Record[Idx++]; |
| 570 | llvm::SmallVector<ObjCInterfaceDecl *, 16> ClassRefs; |
| 571 | ClassRefs.reserve(NumClassRefs); |
| 572 | for (unsigned I = 0; I != NumClassRefs; ++I) |
| 573 | ClassRefs.push_back(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Ted Kremenek | 321c22f | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 574 | llvm::SmallVector<SourceLocation, 16> SLocs; |
| 575 | SLocs.reserve(NumClassRefs); |
| 576 | for (unsigned I = 0; I != NumClassRefs; ++I) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 577 | SLocs.push_back(ReadSourceLocation(Record, Idx)); |
Ted Kremenek | 321c22f | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 578 | CD->setClassList(*Reader.getContext(), ClassRefs.data(), SLocs.data(), |
| 579 | NumClassRefs); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 580 | } |
| 581 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 582 | void ASTDeclReader::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *FPD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 583 | VisitDecl(FPD); |
| 584 | unsigned NumProtoRefs = Record[Idx++]; |
| 585 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 586 | ProtoRefs.reserve(NumProtoRefs); |
| 587 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 588 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 589 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 590 | ProtoLocs.reserve(NumProtoRefs); |
| 591 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 592 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 593 | FPD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 594 | *Reader.getContext()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 595 | } |
| 596 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 597 | void ASTDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 598 | VisitObjCContainerDecl(CD); |
| 599 | CD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 600 | unsigned NumProtoRefs = Record[Idx++]; |
| 601 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 602 | ProtoRefs.reserve(NumProtoRefs); |
| 603 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 604 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 605 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 606 | ProtoLocs.reserve(NumProtoRefs); |
| 607 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 608 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 609 | CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 610 | *Reader.getContext()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 611 | CD->setNextClassCategory(cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | 000835d | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 612 | CD->setHasSynthBitfield(Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 613 | CD->setAtLoc(ReadSourceLocation(Record, Idx)); |
| 614 | CD->setCategoryNameLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 615 | } |
| 616 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 617 | void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 618 | VisitNamedDecl(CAD); |
| 619 | CAD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 620 | } |
| 621 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 622 | void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 623 | VisitNamedDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 624 | D->setAtLoc(ReadSourceLocation(Record, Idx)); |
| 625 | D->setType(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 626 | // FIXME: stable encoding |
| 627 | D->setPropertyAttributes( |
| 628 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Fariborz Jahanian | 80aa1cd | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 629 | D->setPropertyAttributesAsWritten( |
| 630 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 631 | // FIXME: stable encoding |
| 632 | D->setPropertyImplementation( |
| 633 | (ObjCPropertyDecl::PropertyControl)Record[Idx++]); |
| 634 | D->setGetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector()); |
| 635 | D->setSetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector()); |
| 636 | D->setGetterMethodDecl( |
| 637 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 638 | D->setSetterMethodDecl( |
| 639 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 640 | D->setPropertyIvarDecl( |
| 641 | cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
| 642 | } |
| 643 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 644 | void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) { |
Argyrios Kyrtzidis | aecae62 | 2009-07-27 19:04:32 +0000 | [diff] [blame] | 645 | VisitObjCContainerDecl(D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 646 | D->setClassInterface( |
| 647 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 648 | } |
| 649 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 650 | void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 651 | VisitObjCImplDecl(D); |
| 652 | D->setIdentifier(Reader.GetIdentifierInfo(Record, Idx)); |
| 653 | } |
| 654 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 655 | void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 656 | VisitObjCImplDecl(D); |
| 657 | D->setSuperClass( |
| 658 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Argyrios Kyrtzidis | 9d50c06 | 2010-08-09 10:54:20 +0000 | [diff] [blame] | 659 | llvm::tie(D->IvarInitializers, D->NumIvarInitializers) |
Sean Hunt | cbb6748 | 2011-01-08 20:30:50 +0000 | [diff] [blame] | 660 | = Reader.ReadCXXCtorInitializers(F, Record, Idx); |
Fariborz Jahanian | 000835d | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 661 | D->setHasSynthBitfield(Record[Idx++]); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 665 | void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 666 | VisitDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 667 | D->setAtLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 668 | D->setPropertyDecl( |
| 669 | cast_or_null<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | a4ffd85 | 2010-11-17 01:03:52 +0000 | [diff] [blame] | 670 | D->PropertyIvarDecl = |
| 671 | cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])); |
| 672 | D->IvarLoc = ReadSourceLocation(Record, Idx); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 673 | D->setGetterCXXConstructor(Reader.ReadExpr(F)); |
| 674 | D->setSetterCXXAssignment(Reader.ReadExpr(F)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 675 | } |
| 676 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 677 | void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 678 | VisitDeclaratorDecl(FD); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 679 | FD->setMutable(Record[Idx++]); |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 680 | int BitWidthOrInitializer = Record[Idx++]; |
| 681 | if (BitWidthOrInitializer == 1) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 682 | FD->setBitWidth(Reader.ReadExpr(F)); |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 683 | else if (BitWidthOrInitializer == 2) |
| 684 | FD->setInClassInitializer(Reader.ReadExpr(F)); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 685 | if (!FD->getDeclName()) { |
| 686 | FieldDecl *Tmpl = cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])); |
| 687 | if (Tmpl) |
| 688 | Reader.getContext()->setInstantiatedFromUnnamedFieldDecl(FD, Tmpl); |
| 689 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 690 | } |
| 691 | |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 692 | void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) { |
| 693 | VisitValueDecl(FD); |
| 694 | |
| 695 | FD->ChainingSize = Record[Idx++]; |
| 696 | assert(FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2"); |
| 697 | FD->Chaining = new (*Reader.getContext())NamedDecl*[FD->ChainingSize]; |
| 698 | |
| 699 | for (unsigned I = 0; I != FD->ChainingSize; ++I) |
| 700 | FD->Chaining[I] = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
| 701 | } |
| 702 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 703 | void ASTDeclReader::VisitVarDecl(VarDecl *VD) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 704 | VisitDeclaratorDecl(VD); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 705 | VisitRedeclarable(VD); |
John McCall | f1e4fbf | 2011-05-01 02:13:58 +0000 | [diff] [blame] | 706 | VD->VarDeclBits.SClass = (StorageClass)Record[Idx++]; |
| 707 | VD->VarDeclBits.SClassAsWritten = (StorageClass)Record[Idx++]; |
| 708 | VD->VarDeclBits.ThreadSpecified = Record[Idx++]; |
| 709 | VD->VarDeclBits.HasCXXDirectInit = Record[Idx++]; |
| 710 | VD->VarDeclBits.ExceptionVar = Record[Idx++]; |
| 711 | VD->VarDeclBits.NRVOVariable = Record[Idx++]; |
| 712 | VD->VarDeclBits.CXXForRangeDecl = Record[Idx++]; |
John McCall | 7acddac | 2011-06-17 06:42:21 +0000 | [diff] [blame] | 713 | VD->VarDeclBits.ARCPseudoStrong = Record[Idx++]; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 714 | if (Record[Idx++]) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 715 | VD->setInit(Reader.ReadExpr(F)); |
Argyrios Kyrtzidis | 9421adc | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 716 | |
| 717 | if (Record[Idx++]) { // HasMemberSpecializationInfo. |
| 718 | VarDecl *Tmpl = cast<VarDecl>(Reader.GetDecl(Record[Idx++])); |
| 719 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 720 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 9421adc | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 721 | Reader.getContext()->setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI); |
| 722 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 723 | } |
| 724 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 725 | void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 726 | VisitVarDecl(PD); |
| 727 | } |
| 728 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 729 | void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 730 | VisitVarDecl(PD); |
John McCall | 7079886 | 2011-05-02 00:30:12 +0000 | [diff] [blame] | 731 | unsigned isObjCMethodParam = Record[Idx++]; |
| 732 | unsigned scopeDepth = Record[Idx++]; |
| 733 | unsigned scopeIndex = Record[Idx++]; |
| 734 | unsigned declQualifier = Record[Idx++]; |
| 735 | if (isObjCMethodParam) { |
| 736 | assert(scopeDepth == 0); |
| 737 | PD->setObjCMethodScopeInfo(scopeIndex); |
| 738 | PD->ParmVarDeclBits.ScopeDepthOrObjCQuals = declQualifier; |
| 739 | } else { |
| 740 | PD->setScopeInfo(scopeDepth, scopeIndex); |
| 741 | } |
John McCall | f1e4fbf | 2011-05-01 02:13:58 +0000 | [diff] [blame] | 742 | PD->ParmVarDeclBits.IsKNRPromoted = Record[Idx++]; |
| 743 | PD->ParmVarDeclBits.HasInheritedDefaultArg = Record[Idx++]; |
Argyrios Kyrtzidis | 691d77f | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 744 | if (Record[Idx++]) // hasUninstantiatedDefaultArg. |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 745 | PD->setUninstantiatedDefaultArg(Reader.ReadExpr(F)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 746 | } |
| 747 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 748 | void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 749 | VisitDecl(AD); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 750 | AD->setAsmString(cast<StringLiteral>(Reader.ReadExpr(F))); |
Abramo Bagnara | 21e006e | 2011-03-03 14:20:18 +0000 | [diff] [blame] | 751 | AD->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 752 | } |
| 753 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 754 | void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 755 | VisitDecl(BD); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 756 | BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(F))); |
| 757 | BD->setSignatureAsWritten(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 758 | unsigned NumParams = Record[Idx++]; |
| 759 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 760 | Params.reserve(NumParams); |
| 761 | for (unsigned I = 0; I != NumParams; ++I) |
| 762 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 838db38 | 2010-02-11 01:19:42 +0000 | [diff] [blame] | 763 | BD->setParams(Params.data(), NumParams); |
John McCall | 469a1eb | 2011-02-02 13:00:07 +0000 | [diff] [blame] | 764 | |
| 765 | bool capturesCXXThis = Record[Idx++]; |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 766 | unsigned numCaptures = Record[Idx++]; |
| 767 | llvm::SmallVector<BlockDecl::Capture, 16> captures; |
| 768 | captures.reserve(numCaptures); |
| 769 | for (unsigned i = 0; i != numCaptures; ++i) { |
| 770 | VarDecl *decl = cast<VarDecl>(Reader.GetDecl(Record[Idx++])); |
| 771 | unsigned flags = Record[Idx++]; |
| 772 | bool byRef = (flags & 1); |
| 773 | bool nested = (flags & 2); |
| 774 | Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) : 0); |
| 775 | |
| 776 | captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr)); |
| 777 | } |
| 778 | BD->setCaptures(*Reader.getContext(), captures.begin(), |
| 779 | captures.end(), capturesCXXThis); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 780 | } |
| 781 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 782 | void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 783 | VisitDecl(D); |
| 784 | D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]); |
Abramo Bagnara | a2026c9 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 785 | D->setExternLoc(ReadSourceLocation(Record, Idx)); |
Abramo Bagnara | 5f6bcbe | 2011-03-03 14:52:38 +0000 | [diff] [blame] | 786 | D->setRBraceLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 787 | } |
| 788 | |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 789 | void ASTDeclReader::VisitLabelDecl(LabelDecl *D) { |
| 790 | VisitNamedDecl(D); |
Abramo Bagnara | 6784304 | 2011-03-05 18:21:20 +0000 | [diff] [blame] | 791 | D->setLocStart(ReadSourceLocation(Record, Idx)); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 795 | void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 796 | VisitNamedDecl(D); |
Douglas Gregor | 0a0c3e7 | 2010-10-05 20:41:58 +0000 | [diff] [blame] | 797 | D->IsInline = Record[Idx++]; |
Abramo Bagnara | acba90f | 2011-03-08 12:38:20 +0000 | [diff] [blame] | 798 | D->LocStart = ReadSourceLocation(Record, Idx); |
| 799 | D->RBraceLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 06c9193 | 2010-10-27 19:49:05 +0000 | [diff] [blame] | 800 | D->NextNamespace = Record[Idx++]; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 801 | |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 802 | bool IsOriginal = Record[Idx++]; |
Argyrios Kyrtzidis | a038c1d | 2010-07-03 07:57:53 +0000 | [diff] [blame] | 803 | D->OrigOrAnonNamespace.setInt(IsOriginal); |
| 804 | D->OrigOrAnonNamespace.setPointer( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 805 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 806 | } |
| 807 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 808 | void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 809 | VisitNamedDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 810 | D->NamespaceLoc = ReadSourceLocation(Record, Idx); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 811 | D->IdentLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 0cfaf6a | 2011-02-25 17:08:07 +0000 | [diff] [blame] | 812 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Douglas Gregor | 8ea5b9d | 2010-09-01 00:08:19 +0000 | [diff] [blame] | 813 | D->Namespace = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 814 | } |
| 815 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 816 | void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 817 | VisitNamedDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 818 | D->setUsingLocation(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 819 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 820 | ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx); |
Argyrios Kyrtzidis | 826faa2 | 2010-11-10 05:40:41 +0000 | [diff] [blame] | 821 | D->FirstUsingShadow = cast_or_null<UsingShadowDecl>(Reader.GetDecl(Record[Idx++])); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 822 | D->setTypeName(Record[Idx++]); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 823 | NamedDecl *Pattern = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
| 824 | if (Pattern) |
| 825 | Reader.getContext()->setInstantiatedFromUsingDecl(D, Pattern); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 826 | } |
| 827 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 828 | void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 829 | VisitNamedDecl(D); |
| 830 | D->setTargetDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
Argyrios Kyrtzidis | 826faa2 | 2010-11-10 05:40:41 +0000 | [diff] [blame] | 831 | D->UsingOrNextShadow = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 832 | UsingShadowDecl *Pattern |
| 833 | = cast_or_null<UsingShadowDecl>(Reader.GetDecl(Record[Idx++])); |
| 834 | if (Pattern) |
| 835 | Reader.getContext()->setInstantiatedFromUsingShadowDecl(D, Pattern); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 836 | } |
| 837 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 838 | void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 839 | VisitNamedDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 840 | D->UsingLoc = ReadSourceLocation(Record, Idx); |
| 841 | D->NamespaceLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | db99241 | 2011-02-25 16:33:46 +0000 | [diff] [blame] | 842 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Douglas Gregor | 0a35bce | 2010-09-01 03:07:18 +0000 | [diff] [blame] | 843 | D->NominatedNamespace = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
| 844 | D->CommonAncestor = cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++])); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 845 | } |
| 846 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 847 | void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 848 | VisitValueDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 849 | D->setUsingLoc(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 850 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 851 | ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 852 | } |
| 853 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 854 | void ASTDeclReader::VisitUnresolvedUsingTypenameDecl( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 855 | UnresolvedUsingTypenameDecl *D) { |
| 856 | VisitTypeDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 857 | D->TypenameLocation = ReadSourceLocation(Record, Idx); |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 858 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 859 | } |
| 860 | |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 861 | void ASTDeclReader::ReadCXXDefinitionData( |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 862 | struct CXXRecordDecl::DefinitionData &Data, |
| 863 | const RecordData &Record, unsigned &Idx) { |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 864 | Data.UserDeclaredConstructor = Record[Idx++]; |
| 865 | Data.UserDeclaredCopyConstructor = Record[Idx++]; |
| 866 | Data.UserDeclaredCopyAssignment = Record[Idx++]; |
| 867 | Data.UserDeclaredDestructor = Record[Idx++]; |
| 868 | Data.Aggregate = Record[Idx++]; |
| 869 | Data.PlainOldData = Record[Idx++]; |
| 870 | Data.Empty = Record[Idx++]; |
| 871 | Data.Polymorphic = Record[Idx++]; |
| 872 | Data.Abstract = Record[Idx++]; |
Chandler Carruth | ec997dc | 2011-04-30 10:07:30 +0000 | [diff] [blame] | 873 | Data.IsStandardLayout = Record[Idx++]; |
Chandler Carruth | a822544 | 2011-04-30 09:17:45 +0000 | [diff] [blame] | 874 | Data.HasNoNonEmptyBases = Record[Idx++]; |
| 875 | Data.HasPrivateFields = Record[Idx++]; |
| 876 | Data.HasProtectedFields = Record[Idx++]; |
| 877 | Data.HasPublicFields = Record[Idx++]; |
Douglas Gregor | 2bb1101 | 2011-05-13 01:05:07 +0000 | [diff] [blame] | 878 | Data.HasMutableFields = Record[Idx++]; |
Sean Hunt | 023df37 | 2011-05-09 18:22:59 +0000 | [diff] [blame] | 879 | Data.HasTrivialDefaultConstructor = Record[Idx++]; |
Chandler Carruth | 9b6347c | 2011-04-24 02:49:34 +0000 | [diff] [blame] | 880 | Data.HasConstExprNonCopyMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 881 | Data.HasTrivialCopyConstructor = Record[Idx++]; |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 882 | Data.HasTrivialMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 883 | Data.HasTrivialCopyAssignment = Record[Idx++]; |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 884 | Data.HasTrivialMoveAssignment = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 885 | Data.HasTrivialDestructor = Record[Idx++]; |
Chandler Carruth | 9b6347c | 2011-04-24 02:49:34 +0000 | [diff] [blame] | 886 | Data.HasNonLiteralTypeFieldsOrBases = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 887 | Data.ComputedVisibleConversions = Record[Idx++]; |
Sean Hunt | cdee3fe | 2011-05-11 22:34:38 +0000 | [diff] [blame] | 888 | Data.UserProvidedDefaultConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 889 | Data.DeclaredDefaultConstructor = Record[Idx++]; |
| 890 | Data.DeclaredCopyConstructor = Record[Idx++]; |
| 891 | Data.DeclaredCopyAssignment = Record[Idx++]; |
| 892 | Data.DeclaredDestructor = Record[Idx++]; |
Anders Carlsson | faa6afd | 2011-01-22 18:11:02 +0000 | [diff] [blame] | 893 | |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 894 | Data.NumBases = Record[Idx++]; |
Douglas Gregor | 7c789c1 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 895 | if (Data.NumBases) |
| 896 | Data.Bases = Reader.GetCXXBaseSpecifiersOffset(Record[Idx++]); |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 897 | Data.NumVBases = Record[Idx++]; |
Douglas Gregor | 7c789c1 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 898 | if (Data.NumVBases) |
| 899 | Data.VBases = Reader.GetCXXBaseSpecifiersOffset(Record[Idx++]); |
| 900 | |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 901 | Reader.ReadUnresolvedSet(Data.Conversions, Record, Idx); |
| 902 | Reader.ReadUnresolvedSet(Data.VisibleConversions, Record, Idx); |
| 903 | assert(Data.Definition && "Data.Definition should be already set!"); |
| 904 | Data.FirstFriend |
| 905 | = cast_or_null<FriendDecl>(Reader.GetDecl(Record[Idx++])); |
| 906 | } |
| 907 | |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 908 | void ASTDeclReader::InitializeCXXDefinitionData(CXXRecordDecl *D, |
| 909 | CXXRecordDecl *DefinitionDecl, |
| 910 | const RecordData &Record, |
| 911 | unsigned &Idx) { |
Argyrios Kyrtzidis | 134db1f | 2010-10-24 17:26:31 +0000 | [diff] [blame] | 912 | ASTContext &C = *Reader.getContext(); |
Argyrios Kyrtzidis | 9703b0d | 2010-10-20 00:11:15 +0000 | [diff] [blame] | 913 | |
Argyrios Kyrtzidis | 134db1f | 2010-10-24 17:26:31 +0000 | [diff] [blame] | 914 | if (D == DefinitionDecl) { |
| 915 | D->DefinitionData = new (C) struct CXXRecordDecl::DefinitionData(D); |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 916 | ReadCXXDefinitionData(*D->DefinitionData, Record, Idx); |
Argyrios Kyrtzidis | 134db1f | 2010-10-24 17:26:31 +0000 | [diff] [blame] | 917 | // We read the definition info. Check if there are pending forward |
| 918 | // references that need to point to this DefinitionData pointer. |
| 919 | ASTReader::PendingForwardRefsMap::iterator |
| 920 | FindI = Reader.PendingForwardRefs.find(D); |
| 921 | if (FindI != Reader.PendingForwardRefs.end()) { |
| 922 | ASTReader::ForwardRefs &Refs = FindI->second; |
| 923 | for (ASTReader::ForwardRefs::iterator |
| 924 | I = Refs.begin(), E = Refs.end(); I != E; ++I) |
| 925 | (*I)->DefinitionData = D->DefinitionData; |
| 926 | #ifndef NDEBUG |
| 927 | // We later check whether PendingForwardRefs is empty to make sure all |
| 928 | // pending references were linked. |
| 929 | Reader.PendingForwardRefs.erase(D); |
| 930 | #endif |
| 931 | } |
| 932 | } else if (DefinitionDecl) { |
| 933 | if (DefinitionDecl->DefinitionData) { |
| 934 | D->DefinitionData = DefinitionDecl->DefinitionData; |
| 935 | } else { |
| 936 | // The definition is still initializing. |
| 937 | Reader.PendingForwardRefs[DefinitionDecl].push_back(D); |
| 938 | } |
Argyrios Kyrtzidis | 37ffed3 | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 939 | } |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) { |
| 943 | VisitRecordDecl(D); |
| 944 | |
| 945 | CXXRecordDecl *DefinitionDecl |
| 946 | = cast_or_null<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])); |
| 947 | InitializeCXXDefinitionData(D, DefinitionDecl, Record, Idx); |
| 948 | |
| 949 | ASTContext &C = *Reader.getContext(); |
Argyrios Kyrtzidis | 37ffed3 | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 950 | |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 951 | enum CXXRecKind { |
| 952 | CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization |
| 953 | }; |
| 954 | switch ((CXXRecKind)Record[Idx++]) { |
| 955 | default: |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 956 | assert(false && "Out of sync with ASTDeclWriter::VisitCXXRecordDecl?"); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 957 | case CXXRecNotTemplate: |
| 958 | break; |
| 959 | case CXXRecTemplate: |
Argyrios Kyrtzidis | 8b996b8 | 2010-09-13 11:45:25 +0000 | [diff] [blame] | 960 | D->TemplateOrInstantiation |
| 961 | = cast<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 962 | break; |
| 963 | case CXXRecMemberSpecialization: { |
| 964 | CXXRecordDecl *RD = cast<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])); |
| 965 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 966 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 8b996b8 | 2010-09-13 11:45:25 +0000 | [diff] [blame] | 967 | MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK); |
| 968 | MSI->setPointOfInstantiation(POI); |
| 969 | D->TemplateOrInstantiation = MSI; |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 970 | break; |
| 971 | } |
| 972 | } |
Argyrios Kyrtzidis | 36d2fd4 | 2010-10-14 20:14:38 +0000 | [diff] [blame] | 973 | |
| 974 | // Load the key function to avoid deserializing every method so we can |
| 975 | // compute it. |
| 976 | if (D->IsDefinition) { |
| 977 | CXXMethodDecl *Key |
| 978 | = cast_or_null<CXXMethodDecl>(Reader.GetDecl(Record[Idx++])); |
| 979 | if (Key) |
| 980 | C.KeyFunctions[D] = Key; |
| 981 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 982 | } |
| 983 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 984 | void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 985 | VisitFunctionDecl(D); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 986 | unsigned NumOverridenMethods = Record[Idx++]; |
| 987 | while (NumOverridenMethods--) { |
| 988 | CXXMethodDecl *MD = cast<CXXMethodDecl>(Reader.GetDecl(Record[Idx++])); |
| 989 | // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod, |
| 990 | // MD may be initializing. |
| 991 | Reader.getContext()->addOverriddenMethod(D, MD); |
| 992 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 993 | } |
| 994 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 995 | void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 996 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 997 | |
| 998 | D->IsExplicitSpecified = Record[Idx++]; |
| 999 | D->ImplicitlyDefined = Record[Idx++]; |
Sean Hunt | cbb6748 | 2011-01-08 20:30:50 +0000 | [diff] [blame] | 1000 | llvm::tie(D->CtorInitializers, D->NumCtorInitializers) |
| 1001 | = Reader.ReadCXXCtorInitializers(F, Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1002 | } |
| 1003 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1004 | void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1005 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1006 | |
| 1007 | D->ImplicitlyDefined = Record[Idx++]; |
| 1008 | D->OperatorDelete = cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1009 | } |
| 1010 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1011 | void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1012 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1013 | D->IsExplicitSpecified = Record[Idx++]; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1014 | } |
| 1015 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1016 | void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) { |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1017 | VisitDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1018 | D->setColonLoc(ReadSourceLocation(Record, Idx)); |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1021 | void ASTDeclReader::VisitFriendDecl(FriendDecl *D) { |
Argyrios Kyrtzidis | c8f9af2 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 1022 | VisitDecl(D); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1023 | if (Record[Idx++]) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1024 | D->Friend = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1025 | else |
| 1026 | D->Friend = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
Douglas Gregor | 69aecc6 | 2010-10-27 20:23:41 +0000 | [diff] [blame] | 1027 | D->NextFriend = Record[Idx++]; |
John McCall | 6102ca1 | 2010-10-16 06:59:13 +0000 | [diff] [blame] | 1028 | D->UnsupportedFriend = (Record[Idx++] != 0); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1029 | D->FriendLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1030 | } |
| 1031 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1032 | void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { |
Argyrios Kyrtzidis | 554e6aa | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1033 | VisitDecl(D); |
| 1034 | unsigned NumParams = Record[Idx++]; |
| 1035 | D->NumParams = NumParams; |
| 1036 | D->Params = new TemplateParameterList*[NumParams]; |
| 1037 | for (unsigned i = 0; i != NumParams; ++i) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1038 | D->Params[i] = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 554e6aa | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1039 | if (Record[Idx++]) // HasFriendDecl |
| 1040 | D->Friend = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
| 1041 | else |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1042 | D->Friend = GetTypeSourceInfo(Record, Idx); |
| 1043 | D->FriendLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1044 | } |
| 1045 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1046 | void ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) { |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1047 | VisitNamedDecl(D); |
| 1048 | |
Argyrios Kyrtzidis | bfcc92c | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1049 | NamedDecl *TemplatedDecl |
| 1050 | = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1051 | TemplateParameterList* TemplateParams |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1052 | = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1053 | D->init(TemplatedDecl, TemplateParams); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1054 | } |
| 1055 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1056 | void ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1057 | // Initialize CommonOrPrev before VisitTemplateDecl so that getCommonPtr() |
| 1058 | // can be used while this is still initializing. |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1059 | |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1060 | assert(D->CommonOrPrev.isNull() && "getCommonPtr was called earlier on this"); |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1061 | DeclID PreviousDeclID = Record[Idx++]; |
| 1062 | DeclID FirstDeclID = PreviousDeclID ? Record[Idx++] : 0; |
| 1063 | // We delay loading of the redeclaration chain to avoid deeply nested calls. |
| 1064 | // We temporarily set the first (canonical) declaration as the previous one |
| 1065 | // which is the one that matters and mark the real previous DeclID to be |
| 1066 | // loaded & attached later on. |
| 1067 | RedeclarableTemplateDecl *FirstDecl = |
| 1068 | cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(FirstDeclID)); |
| 1069 | assert((FirstDecl == 0 || FirstDecl->getKind() == D->getKind()) && |
| 1070 | "FirstDecl kind mismatch"); |
| 1071 | if (FirstDecl) { |
| 1072 | D->CommonOrPrev = FirstDecl; |
| 1073 | // Mark the real previous DeclID to be loaded & attached later on. |
| 1074 | if (PreviousDeclID != FirstDeclID) |
| 1075 | Reader.PendingPreviousDecls.push_back(std::make_pair(D, PreviousDeclID)); |
| 1076 | } else { |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1077 | D->CommonOrPrev = D->newCommon(*Reader.getContext()); |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1078 | if (RedeclarableTemplateDecl *RTD |
| 1079 | = cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(Record[Idx++]))) { |
| 1080 | assert(RTD->getKind() == D->getKind() && |
| 1081 | "InstantiatedFromMemberTemplate kind mismatch"); |
| 1082 | D->setInstantiatedFromMemberTemplateImpl(RTD); |
| 1083 | if (Record[Idx++]) |
| 1084 | D->setMemberSpecialization(); |
| 1085 | } |
Peter Collingbourne | 8a798a7 | 2010-07-29 16:12:01 +0000 | [diff] [blame] | 1086 | |
| 1087 | RedeclarableTemplateDecl *LatestDecl = |
| 1088 | cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1089 | |
| 1090 | // This decl is a first one and the latest declaration that it points to is |
Sebastian Redl | 3c7f413 | 2010-08-18 23:57:06 +0000 | [diff] [blame] | 1091 | // in the same AST file. However, if this actually needs to point to a |
| 1092 | // redeclaration in another AST file, we need to update it by checking |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1093 | // the FirstLatestDeclIDs map which tracks this kind of decls. |
| 1094 | assert(Reader.GetDecl(ThisDeclID) == D && "Invalid ThisDeclID ?"); |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1095 | ASTReader::FirstLatestDeclIDMap::iterator I |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1096 | = Reader.FirstLatestDeclIDs.find(ThisDeclID); |
| 1097 | if (I != Reader.FirstLatestDeclIDs.end()) { |
| 1098 | Decl *NewLatest = Reader.GetDecl(I->second); |
| 1099 | assert((LatestDecl->getLocation().isInvalid() || |
| 1100 | NewLatest->getLocation().isInvalid() || |
Argyrios Kyrtzidis | 441fff1 | 2010-10-20 23:48:40 +0000 | [diff] [blame] | 1101 | !Reader.SourceMgr.isBeforeInTranslationUnit( |
| 1102 | NewLatest->getLocation(), |
| 1103 | LatestDecl->getLocation())) && |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1104 | "The new latest is supposed to come after the previous latest"); |
| 1105 | LatestDecl = cast<RedeclarableTemplateDecl>(NewLatest); |
| 1106 | } |
| 1107 | |
Peter Collingbourne | 8a798a7 | 2010-07-29 16:12:01 +0000 | [diff] [blame] | 1108 | assert(LatestDecl->getKind() == D->getKind() && "Latest kind mismatch"); |
| 1109 | D->getCommonPtr()->Latest = LatestDecl; |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1110 | } |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1111 | |
| 1112 | VisitTemplateDecl(D); |
| 1113 | D->IdentifierNamespace = Record[Idx++]; |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1116 | void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1117 | VisitRedeclarableTemplateDecl(D); |
| 1118 | |
| 1119 | if (D->getPreviousDeclaration() == 0) { |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1120 | // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of |
| 1121 | // the specializations. |
| 1122 | llvm::SmallVector<serialization::DeclID, 2> SpecIDs; |
| 1123 | SpecIDs.push_back(0); |
| 1124 | |
| 1125 | // Specializations. |
| 1126 | unsigned Size = Record[Idx++]; |
| 1127 | SpecIDs[0] += Size; |
| 1128 | SpecIDs.append(Record.begin() + Idx, Record.begin() + Idx + Size); |
| 1129 | Idx += Size; |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1130 | |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1131 | // Partial specializations. |
| 1132 | Size = Record[Idx++]; |
| 1133 | SpecIDs[0] += Size; |
| 1134 | SpecIDs.append(Record.begin() + Idx, Record.begin() + Idx + Size); |
| 1135 | Idx += Size; |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1136 | |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1137 | if (SpecIDs[0]) { |
| 1138 | typedef serialization::DeclID DeclID; |
| 1139 | |
| 1140 | ClassTemplateDecl::Common *CommonPtr = D->getCommonPtr(); |
| 1141 | CommonPtr->LazySpecializations |
| 1142 | = new (*Reader.getContext()) DeclID [SpecIDs.size()]; |
| 1143 | memcpy(CommonPtr->LazySpecializations, SpecIDs.data(), |
| 1144 | SpecIDs.size() * sizeof(DeclID)); |
| 1145 | } |
| 1146 | |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1147 | // InjectedClassNameType is computed. |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1148 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1151 | void ASTDeclReader::VisitClassTemplateSpecializationDecl( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1152 | ClassTemplateSpecializationDecl *D) { |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1153 | VisitCXXRecordDecl(D); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1154 | |
| 1155 | ASTContext &C = *Reader.getContext(); |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1156 | if (Decl *InstD = Reader.GetDecl(Record[Idx++])) { |
| 1157 | if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) { |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1158 | D->SpecializedTemplate = CTD; |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1159 | } else { |
| 1160 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1161 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1162 | TemplateArgumentList *ArgList |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 1163 | = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), |
| 1164 | TemplArgs.size()); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1165 | ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS |
| 1166 | = new (C) ClassTemplateSpecializationDecl:: |
| 1167 | SpecializedPartialSpecialization(); |
| 1168 | PS->PartialSpecialization |
| 1169 | = cast<ClassTemplatePartialSpecializationDecl>(InstD); |
| 1170 | PS->TemplateArgs = ArgList; |
| 1171 | D->SpecializedTemplate = PS; |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1172 | } |
| 1173 | } |
| 1174 | |
| 1175 | // Explicit info. |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1176 | if (TypeSourceInfo *TyInfo = GetTypeSourceInfo(Record, Idx)) { |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1177 | ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo |
| 1178 | = new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo; |
| 1179 | ExplicitInfo->TypeAsWritten = TyInfo; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1180 | ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx); |
| 1181 | ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1182 | D->ExplicitInfo = ExplicitInfo; |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1186 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 1187 | D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), |
| 1188 | TemplArgs.size()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1189 | D->PointOfInstantiation = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1190 | D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++]; |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1191 | |
Argyrios Kyrtzidis | bc5ab7c | 2010-07-20 13:59:40 +0000 | [diff] [blame] | 1192 | if (D->isCanonicalDecl()) { // It's kept in the folding set. |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1193 | ClassTemplateDecl *CanonPattern |
| 1194 | = cast<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
| 1195 | if (ClassTemplatePartialSpecializationDecl *Partial |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1196 | = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) { |
| 1197 | CanonPattern->getCommonPtr()->PartialSpecializations.InsertNode(Partial); |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1198 | } else { |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1199 | CanonPattern->getCommonPtr()->Specializations.InsertNode(D); |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1200 | } |
| 1201 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1204 | void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1205 | ClassTemplatePartialSpecializationDecl *D) { |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1206 | VisitClassTemplateSpecializationDecl(D); |
| 1207 | |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1208 | ASTContext &C = *Reader.getContext(); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1209 | D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1210 | |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1211 | unsigned NumArgs = Record[Idx++]; |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1212 | if (NumArgs) { |
| 1213 | D->NumArgsAsWritten = NumArgs; |
| 1214 | D->ArgsAsWritten = new (C) TemplateArgumentLoc[NumArgs]; |
| 1215 | for (unsigned i=0; i != NumArgs; ++i) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1216 | D->ArgsAsWritten[i] = Reader.ReadTemplateArgumentLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1217 | } |
| 1218 | |
| 1219 | D->SequenceNumber = Record[Idx++]; |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1220 | |
| 1221 | // These are read/set from/to the first declaration. |
| 1222 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1223 | D->InstantiatedFromMember.setPointer( |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1224 | cast_or_null<ClassTemplatePartialSpecializationDecl>( |
| 1225 | Reader.GetDecl(Record[Idx++]))); |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1226 | D->InstantiatedFromMember.setInt(Record[Idx++]); |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1227 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1228 | } |
| 1229 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1230 | void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1231 | VisitRedeclarableTemplateDecl(D); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1232 | |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1233 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1234 | // This FunctionTemplateDecl owns a CommonPtr; read it. |
| 1235 | |
Argyrios Kyrtzidis | 057d9af | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1236 | // Read the function specialization declarations. |
| 1237 | // FunctionTemplateDecl's FunctionTemplateSpecializationInfos are filled |
Argyrios Kyrtzidis | 99a8ca0 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 1238 | // when reading the specialized FunctionDecl. |
Argyrios Kyrtzidis | 057d9af | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1239 | unsigned NumSpecs = Record[Idx++]; |
| 1240 | while (NumSpecs--) |
| 1241 | Reader.GetDecl(Record[Idx++]); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1242 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1243 | } |
| 1244 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1245 | void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1246 | VisitTypeDecl(D); |
| 1247 | |
| 1248 | D->setDeclaredWithTypename(Record[Idx++]); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1249 | |
| 1250 | bool Inherited = Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1251 | TypeSourceInfo *DefArg = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1252 | D->setDefaultArgument(DefArg, Inherited); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1255 | void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { |
John McCall | 76a4021 | 2011-02-09 01:13:10 +0000 | [diff] [blame] | 1256 | VisitDeclaratorDecl(D); |
Argyrios Kyrtzidis | b24e199 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1257 | // TemplateParmPosition. |
| 1258 | D->setDepth(Record[Idx++]); |
| 1259 | D->setPosition(Record[Idx++]); |
Douglas Gregor | 6952f1e | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1260 | if (D->isExpandedParameterPack()) { |
| 1261 | void **Data = reinterpret_cast<void **>(D + 1); |
| 1262 | for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) { |
| 1263 | Data[2*I] = Reader.GetType(Record[Idx++]).getAsOpaquePtr(); |
| 1264 | Data[2*I + 1] = GetTypeSourceInfo(Record, Idx); |
| 1265 | } |
| 1266 | } else { |
| 1267 | // Rest of NonTypeTemplateParmDecl. |
| 1268 | D->ParameterPack = Record[Idx++]; |
| 1269 | if (Record[Idx++]) { |
| 1270 | Expr *DefArg = Reader.ReadExpr(F); |
| 1271 | bool Inherited = Record[Idx++]; |
| 1272 | D->setDefaultArgument(DefArg, Inherited); |
| 1273 | } |
| 1274 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1277 | void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { |
Argyrios Kyrtzidis | bfcc92c | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1278 | VisitTemplateDecl(D); |
| 1279 | // TemplateParmPosition. |
| 1280 | D->setDepth(Record[Idx++]); |
| 1281 | D->setPosition(Record[Idx++]); |
| 1282 | // Rest of TemplateTemplateParmDecl. |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1283 | TemplateArgumentLoc Arg = Reader.ReadTemplateArgumentLoc(F, Record, Idx); |
Argyrios Kyrtzidis | bfcc92c | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1284 | bool IsInherited = Record[Idx++]; |
| 1285 | D->setDefaultArgument(Arg, IsInherited); |
Douglas Gregor | 61c4d28 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1286 | D->ParameterPack = Record[Idx++]; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1287 | } |
| 1288 | |
Richard Smith | 3e4c6c4 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1289 | void ASTDeclReader::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { |
| 1290 | VisitRedeclarableTemplateDecl(D); |
| 1291 | } |
| 1292 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1293 | void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) { |
Argyrios Kyrtzidis | 0d39689 | 2010-07-22 17:28:12 +0000 | [diff] [blame] | 1294 | VisitDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1295 | D->AssertExpr = Reader.ReadExpr(F); |
| 1296 | D->Message = cast<StringLiteral>(Reader.ReadExpr(F)); |
Abramo Bagnara | a2026c9 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 1297 | D->RParenLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1298 | } |
| 1299 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1300 | std::pair<uint64_t, uint64_t> |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1301 | ASTDeclReader::VisitDeclContext(DeclContext *DC) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1302 | uint64_t LexicalOffset = Record[Idx++]; |
| 1303 | uint64_t VisibleOffset = Record[Idx++]; |
| 1304 | return std::make_pair(LexicalOffset, VisibleOffset); |
| 1305 | } |
| 1306 | |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1307 | template <typename T> |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1308 | void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1309 | enum RedeclKind { NoRedeclaration = 0, PointsToPrevious, PointsToLatest }; |
| 1310 | RedeclKind Kind = (RedeclKind)Record[Idx++]; |
| 1311 | switch (Kind) { |
| 1312 | default: |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1313 | assert(0 && "Out of sync with ASTDeclWriter::VisitRedeclarable or messed up" |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1314 | " reading"); |
| 1315 | case NoRedeclaration: |
| 1316 | break; |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1317 | case PointsToPrevious: { |
| 1318 | DeclID PreviousDeclID = Record[Idx++]; |
| 1319 | DeclID FirstDeclID = Record[Idx++]; |
| 1320 | // We delay loading of the redeclaration chain to avoid deeply nested calls. |
| 1321 | // We temporarily set the first (canonical) declaration as the previous one |
| 1322 | // which is the one that matters and mark the real previous DeclID to be |
| 1323 | // loaded & attached later on. |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1324 | D->RedeclLink = typename Redeclarable<T>::PreviousDeclLink( |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1325 | cast_or_null<T>(Reader.GetDecl(FirstDeclID))); |
| 1326 | if (PreviousDeclID != FirstDeclID) |
| 1327 | Reader.PendingPreviousDecls.push_back(std::make_pair(static_cast<T*>(D), |
| 1328 | PreviousDeclID)); |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1329 | break; |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1330 | } |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1331 | case PointsToLatest: |
| 1332 | D->RedeclLink = typename Redeclarable<T>::LatestDeclLink( |
| 1333 | cast_or_null<T>(Reader.GetDecl(Record[Idx++]))); |
| 1334 | break; |
| 1335 | } |
| 1336 | |
| 1337 | assert(!(Kind == PointsToPrevious && |
| 1338 | Reader.FirstLatestDeclIDs.find(ThisDeclID) != |
| 1339 | Reader.FirstLatestDeclIDs.end()) && |
| 1340 | "This decl is not first, it should not be in the map"); |
| 1341 | if (Kind == PointsToPrevious) |
| 1342 | return; |
| 1343 | |
| 1344 | // This decl is a first one and the latest declaration that it points to is in |
Sebastian Redl | 3c7f413 | 2010-08-18 23:57:06 +0000 | [diff] [blame] | 1345 | // the same AST file. However, if this actually needs to point to a |
| 1346 | // redeclaration in another AST file, we need to update it by checking the |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1347 | // FirstLatestDeclIDs map which tracks this kind of decls. |
| 1348 | assert(Reader.GetDecl(ThisDeclID) == static_cast<T*>(D) && |
| 1349 | "Invalid ThisDeclID ?"); |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1350 | ASTReader::FirstLatestDeclIDMap::iterator I |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1351 | = Reader.FirstLatestDeclIDs.find(ThisDeclID); |
| 1352 | if (I != Reader.FirstLatestDeclIDs.end()) { |
| 1353 | Decl *NewLatest = Reader.GetDecl(I->second); |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1354 | D->RedeclLink |
| 1355 | = typename Redeclarable<T>::LatestDeclLink(cast_or_null<T>(NewLatest)); |
| 1356 | } |
| 1357 | } |
| 1358 | |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1359 | //===----------------------------------------------------------------------===// |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1360 | // Attribute Reading |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1361 | //===----------------------------------------------------------------------===// |
| 1362 | |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1363 | /// \brief Reads attributes from the current stream position. |
Argyrios Kyrtzidis | 4eb9fc0 | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 1364 | void ASTReader::ReadAttributes(PerFileData &F, AttrVec &Attrs, |
| 1365 | const RecordData &Record, unsigned &Idx) { |
| 1366 | for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) { |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1367 | Attr *New = 0; |
Sean Hunt | 387475d | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1368 | attr::Kind Kind = (attr::Kind)Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1369 | SourceLocation Loc = ReadSourceLocation(F, Record, Idx); |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1370 | |
Sean Hunt | cf807c4 | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 1371 | #include "clang/Serialization/AttrPCHRead.inc" |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1372 | |
| 1373 | assert(New && "Unable to decode attribute?"); |
Sean Hunt | cf807c4 | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 1374 | Attrs.push_back(New); |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1375 | } |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1376 | } |
| 1377 | |
| 1378 | //===----------------------------------------------------------------------===// |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1379 | // ASTReader Implementation |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1380 | //===----------------------------------------------------------------------===// |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1381 | |
| 1382 | /// \brief Note that we have loaded the declaration with the given |
| 1383 | /// Index. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1384 | /// |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1385 | /// This routine notes that this declaration has already been loaded, |
| 1386 | /// so that future GetDecl calls will return this declaration rather |
| 1387 | /// than trying to load a new declaration. |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1388 | inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1389 | assert(!DeclsLoaded[Index] && "Decl loaded twice?"); |
| 1390 | DeclsLoaded[Index] = D; |
| 1391 | } |
| 1392 | |
| 1393 | |
| 1394 | /// \brief Determine whether the consumer will be interested in seeing |
| 1395 | /// this declaration (via HandleTopLevelDecl). |
| 1396 | /// |
| 1397 | /// This routine should return true for anything that might affect |
| 1398 | /// code generation, e.g., inline function definitions, Objective-C |
| 1399 | /// declarations with metadata, etc. |
| 1400 | static bool isConsumerInterestedIn(Decl *D) { |
Daniel Dunbar | 04a0b50 | 2009-09-17 03:06:44 +0000 | [diff] [blame] | 1401 | if (isa<FileScopeAsmDecl>(D)) |
| 1402 | return true; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1403 | if (VarDecl *Var = dyn_cast<VarDecl>(D)) |
Argyrios Kyrtzidis | 3f95477 | 2010-08-05 09:47:59 +0000 | [diff] [blame] | 1404 | return Var->isFileVarDecl() && |
| 1405 | Var->isThisDeclarationADefinition() == VarDecl::Definition; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1406 | if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D)) |
Sean Hunt | 10620eb | 2011-05-06 20:44:56 +0000 | [diff] [blame] | 1407 | return Func->doesThisDeclarationHaveABody(); |
Argyrios Kyrtzidis | 9d50c06 | 2010-08-09 10:54:20 +0000 | [diff] [blame] | 1408 | return isa<ObjCProtocolDecl>(D) || isa<ObjCImplementationDecl>(D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1409 | } |
| 1410 | |
Sebastian Redl | cb526aa | 2010-07-20 22:46:15 +0000 | [diff] [blame] | 1411 | /// \brief Get the correct cursor and offset for loading a type. |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1412 | ASTReader::RecordLocation |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1413 | ASTReader::DeclCursorForIndex(unsigned Index, DeclID ID) { |
Sebastian Redl | 0b17c61 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1414 | // See if there's an override. |
| 1415 | DeclReplacementMap::iterator It = ReplacedDecls.find(ID); |
| 1416 | if (It != ReplacedDecls.end()) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1417 | return RecordLocation(It->second.first, It->second.second); |
Sebastian Redl | 0b17c61 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1418 | |
Sebastian Redl | cb526aa | 2010-07-20 22:46:15 +0000 | [diff] [blame] | 1419 | PerFileData *F = 0; |
| 1420 | for (unsigned I = 0, N = Chain.size(); I != N; ++I) { |
| 1421 | F = Chain[N - I - 1]; |
| 1422 | if (Index < F->LocalNumDecls) |
| 1423 | break; |
| 1424 | Index -= F->LocalNumDecls; |
| 1425 | } |
| 1426 | assert(F && F->LocalNumDecls > Index && "Broken chain"); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1427 | return RecordLocation(F, F->DeclOffsets[Index]); |
Sebastian Redl | cb526aa | 2010-07-20 22:46:15 +0000 | [diff] [blame] | 1428 | } |
| 1429 | |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1430 | void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *previous) { |
| 1431 | assert(D && previous); |
| 1432 | if (TagDecl *TD = dyn_cast<TagDecl>(D)) { |
| 1433 | TD->RedeclLink.setPointer(cast<TagDecl>(previous)); |
| 1434 | } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
| 1435 | FD->RedeclLink.setPointer(cast<FunctionDecl>(previous)); |
| 1436 | } else if (VarDecl *VD = dyn_cast<VarDecl>(D)) { |
| 1437 | VD->RedeclLink.setPointer(cast<VarDecl>(previous)); |
| 1438 | } else { |
| 1439 | RedeclarableTemplateDecl *TD = cast<RedeclarableTemplateDecl>(D); |
| 1440 | TD->CommonOrPrev = cast<RedeclarableTemplateDecl>(previous); |
| 1441 | } |
| 1442 | } |
| 1443 | |
| 1444 | void ASTReader::loadAndAttachPreviousDecl(Decl *D, serialization::DeclID ID) { |
| 1445 | Decl *previous = GetDecl(ID); |
| 1446 | ASTDeclReader::attachPreviousDecl(D, previous); |
| 1447 | } |
| 1448 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1449 | /// \brief Read the declaration at the given offset from the AST file. |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1450 | Decl *ASTReader::ReadDeclRecord(unsigned Index, DeclID ID) { |
Sebastian Redl | 0b17c61 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1451 | RecordLocation Loc = DeclCursorForIndex(Index, ID); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1452 | llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1453 | // Keep track of where we are in the stream, then jump back there |
| 1454 | // after reading this declaration. |
Chris Lattner | da93061 | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1455 | SavedStreamPosition SavedPosition(DeclsCursor); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1456 | |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1457 | ReadingKindTracker ReadingKind(Read_Decl, *this); |
| 1458 | |
Douglas Gregor | d89275b | 2009-07-06 18:54:52 +0000 | [diff] [blame] | 1459 | // Note that we are loading a declaration record. |
Argyrios Kyrtzidis | 29ee3a2 | 2010-07-30 10:03:16 +0000 | [diff] [blame] | 1460 | Deserializing ADecl(this); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1461 | |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1462 | DeclsCursor.JumpToBit(Loc.Offset); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1463 | RecordData Record; |
Chris Lattner | da93061 | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1464 | unsigned Code = DeclsCursor.ReadCode(); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1465 | unsigned Idx = 0; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1466 | ASTDeclReader Reader(*this, *Loc.F, DeclsCursor, ID, Record, Idx); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1467 | |
Chris Lattner | da93061 | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1468 | Decl *D = 0; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1469 | switch ((DeclCode)DeclsCursor.ReadRecord(Code, Record)) { |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1470 | case DECL_CONTEXT_LEXICAL: |
| 1471 | case DECL_CONTEXT_VISIBLE: |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1472 | assert(false && "Record cannot be de-serialized with ReadDeclRecord"); |
| 1473 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1474 | case DECL_TRANSLATION_UNIT: |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1475 | assert(Index == 0 && "Translation unit must be at index 0"); |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1476 | D = Context->getTranslationUnitDecl(); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1477 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1478 | case DECL_TYPEDEF: |
Abramo Bagnara | 344577e | 2011-03-06 15:48:19 +0000 | [diff] [blame] | 1479 | D = TypedefDecl::Create(*Context, 0, SourceLocation(), SourceLocation(), |
| 1480 | 0, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1481 | break; |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 1482 | case DECL_TYPEALIAS: |
| 1483 | D = TypeAliasDecl::Create(*Context, 0, SourceLocation(), SourceLocation(), |
| 1484 | 0, 0); |
| 1485 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1486 | case DECL_ENUM: |
Argyrios Kyrtzidis | b8b03e6 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1487 | D = EnumDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1488 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1489 | case DECL_RECORD: |
Argyrios Kyrtzidis | b8b03e6 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1490 | D = RecordDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1491 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1492 | case DECL_ENUM_CONSTANT: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1493 | D = EnumConstantDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1494 | 0, llvm::APSInt()); |
| 1495 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1496 | case DECL_FUNCTION: |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1497 | D = FunctionDecl::Create(*Context, 0, SourceLocation(), SourceLocation(), |
| 1498 | DeclarationName(), QualType(), 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1499 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1500 | case DECL_LINKAGE_SPEC: |
Abramo Bagnara | a2026c9 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 1501 | D = LinkageSpecDecl::Create(*Context, 0, SourceLocation(), SourceLocation(), |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1502 | (LinkageSpecDecl::LanguageIDs)0, |
Abramo Bagnara | 55a9637 | 2011-03-03 16:52:29 +0000 | [diff] [blame] | 1503 | SourceLocation()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1504 | break; |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 1505 | case DECL_LABEL: |
| 1506 | D = LabelDecl::Create(*Context, 0, SourceLocation(), 0); |
| 1507 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1508 | case DECL_NAMESPACE: |
Abramo Bagnara | acba90f | 2011-03-08 12:38:20 +0000 | [diff] [blame] | 1509 | D = NamespaceDecl::Create(*Context, 0, SourceLocation(), |
| 1510 | SourceLocation(), 0); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1511 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1512 | case DECL_NAMESPACE_ALIAS: |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1513 | D = NamespaceAliasDecl::Create(*Context, 0, SourceLocation(), |
Douglas Gregor | 0cfaf6a | 2011-02-25 17:08:07 +0000 | [diff] [blame] | 1514 | SourceLocation(), 0, |
| 1515 | NestedNameSpecifierLoc(), |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1516 | SourceLocation(), 0); |
| 1517 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1518 | case DECL_USING: |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1519 | D = UsingDecl::Create(*Context, 0, SourceLocation(), |
| 1520 | NestedNameSpecifierLoc(), DeclarationNameInfo(), |
| 1521 | false); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1522 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1523 | case DECL_USING_SHADOW: |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1524 | D = UsingShadowDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
| 1525 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1526 | case DECL_USING_DIRECTIVE: |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1527 | D = UsingDirectiveDecl::Create(*Context, 0, SourceLocation(), |
Douglas Gregor | db99241 | 2011-02-25 16:33:46 +0000 | [diff] [blame] | 1528 | SourceLocation(), NestedNameSpecifierLoc(), |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1529 | SourceLocation(), 0, 0); |
| 1530 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1531 | case DECL_UNRESOLVED_USING_VALUE: |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1532 | D = UnresolvedUsingValueDecl::Create(*Context, 0, SourceLocation(), |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1533 | NestedNameSpecifierLoc(), |
Abramo Bagnara | ef3dce8 | 2010-08-12 11:46:03 +0000 | [diff] [blame] | 1534 | DeclarationNameInfo()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1535 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1536 | case DECL_UNRESOLVED_USING_TYPENAME: |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1537 | D = UnresolvedUsingTypenameDecl::Create(*Context, 0, SourceLocation(), |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1538 | SourceLocation(), |
| 1539 | NestedNameSpecifierLoc(), |
| 1540 | SourceLocation(), |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1541 | DeclarationName()); |
| 1542 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1543 | case DECL_CXX_RECORD: |
Argyrios Kyrtzidis | b8b03e6 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1544 | D = CXXRecordDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1545 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1546 | case DECL_CXX_METHOD: |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1547 | D = CXXMethodDecl::Create(*Context, 0, SourceLocation(), |
Douglas Gregor | f525160 | 2011-03-08 17:10:18 +0000 | [diff] [blame] | 1548 | DeclarationNameInfo(), QualType(), 0, |
| 1549 | false, SC_None, false, SourceLocation()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1550 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1551 | case DECL_CXX_CONSTRUCTOR: |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1552 | D = CXXConstructorDecl::Create(*Context, Decl::EmptyShell()); |
| 1553 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1554 | case DECL_CXX_DESTRUCTOR: |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1555 | D = CXXDestructorDecl::Create(*Context, Decl::EmptyShell()); |
| 1556 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1557 | case DECL_CXX_CONVERSION: |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1558 | D = CXXConversionDecl::Create(*Context, Decl::EmptyShell()); |
| 1559 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1560 | case DECL_ACCESS_SPEC: |
Argyrios Kyrtzidis | 65b63ec | 2010-09-08 21:32:35 +0000 | [diff] [blame] | 1561 | D = AccessSpecDecl::Create(*Context, Decl::EmptyShell()); |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1562 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1563 | case DECL_FRIEND: |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1564 | D = FriendDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1565 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1566 | case DECL_FRIEND_TEMPLATE: |
Argyrios Kyrtzidis | 554e6aa | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1567 | D = FriendTemplateDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1568 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1569 | case DECL_CLASS_TEMPLATE: |
Douglas Gregor | 9a299e0 | 2011-03-04 17:52:15 +0000 | [diff] [blame] | 1570 | D = ClassTemplateDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1571 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1572 | case DECL_CLASS_TEMPLATE_SPECIALIZATION: |
Argyrios Kyrtzidis | b8b03e6 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1573 | D = ClassTemplateSpecializationDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1574 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1575 | case DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION: |
Argyrios Kyrtzidis | b8b03e6 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1576 | D = ClassTemplatePartialSpecializationDecl::Create(*Context, |
Douglas Gregor | 9a299e0 | 2011-03-04 17:52:15 +0000 | [diff] [blame] | 1577 | Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1578 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1579 | case DECL_FUNCTION_TEMPLATE: |
Douglas Gregor | 9a299e0 | 2011-03-04 17:52:15 +0000 | [diff] [blame] | 1580 | D = FunctionTemplateDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1581 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1582 | case DECL_TEMPLATE_TYPE_PARM: |
Argyrios Kyrtzidis | b8b03e6 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1583 | D = TemplateTypeParmDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1584 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1585 | case DECL_NON_TYPE_TEMPLATE_PARM: |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1586 | D = NonTypeTemplateParmDecl::Create(*Context, 0, SourceLocation(), |
| 1587 | SourceLocation(), 0, 0, 0, QualType(), |
| 1588 | false, 0); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1589 | break; |
Douglas Gregor | 6952f1e | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1590 | case DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK: |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1591 | D = NonTypeTemplateParmDecl::Create(*Context, 0, SourceLocation(), |
| 1592 | SourceLocation(), 0, 0, 0, QualType(), |
| 1593 | 0, 0, Record[Idx++], 0); |
Douglas Gregor | 6952f1e | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1594 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1595 | case DECL_TEMPLATE_TEMPLATE_PARM: |
Douglas Gregor | 61c4d28 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1596 | D = TemplateTemplateParmDecl::Create(*Context, 0, SourceLocation(), 0, 0, |
| 1597 | false, 0, 0); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1598 | break; |
Richard Smith | 3e4c6c4 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1599 | case DECL_TYPE_ALIAS_TEMPLATE: |
| 1600 | D = TypeAliasTemplateDecl::Create(*Context, Decl::EmptyShell()); |
| 1601 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1602 | case DECL_STATIC_ASSERT: |
Abramo Bagnara | a2026c9 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 1603 | D = StaticAssertDecl::Create(*Context, 0, SourceLocation(), 0, 0, |
| 1604 | SourceLocation()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1605 | break; |
| 1606 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1607 | case DECL_OBJC_METHOD: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1608 | D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(), |
Douglas Gregor | 4bc1cb6 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 1609 | Selector(), QualType(), 0, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1610 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1611 | case DECL_OBJC_INTERFACE: |
Douglas Gregor | deacbdc | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 1612 | D = ObjCInterfaceDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1613 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1614 | case DECL_OBJC_IVAR: |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1615 | D = ObjCIvarDecl::Create(*Context, 0, SourceLocation(), SourceLocation(), |
| 1616 | 0, QualType(), 0, ObjCIvarDecl::None); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1617 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1618 | case DECL_OBJC_PROTOCOL: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1619 | D = ObjCProtocolDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1620 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1621 | case DECL_OBJC_AT_DEFS_FIELD: |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1622 | D = ObjCAtDefsFieldDecl::Create(*Context, 0, SourceLocation(), |
| 1623 | SourceLocation(), 0, QualType(), 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1624 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1625 | case DECL_OBJC_CLASS: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1626 | D = ObjCClassDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1627 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1628 | case DECL_OBJC_FORWARD_PROTOCOL: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1629 | D = ObjCForwardProtocolDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1630 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1631 | case DECL_OBJC_CATEGORY: |
Douglas Gregor | 3db211b | 2010-01-16 16:38:58 +0000 | [diff] [blame] | 1632 | D = ObjCCategoryDecl::Create(*Context, 0, SourceLocation(), |
| 1633 | SourceLocation(), SourceLocation(), 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1634 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1635 | case DECL_OBJC_CATEGORY_IMPL: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1636 | D = ObjCCategoryImplDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1637 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1638 | case DECL_OBJC_IMPLEMENTATION: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1639 | D = ObjCImplementationDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1640 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1641 | case DECL_OBJC_COMPATIBLE_ALIAS: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1642 | D = ObjCCompatibleAliasDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1643 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1644 | case DECL_OBJC_PROPERTY: |
Fariborz Jahanian | d050240 | 2010-01-21 17:36:00 +0000 | [diff] [blame] | 1645 | D = ObjCPropertyDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(), |
John McCall | 83a230c | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 1646 | 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1647 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1648 | case DECL_OBJC_PROPERTY_IMPL: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1649 | D = ObjCPropertyImplDecl::Create(*Context, 0, SourceLocation(), |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1650 | SourceLocation(), 0, |
Douglas Gregor | a4ffd85 | 2010-11-17 01:03:52 +0000 | [diff] [blame] | 1651 | ObjCPropertyImplDecl::Dynamic, 0, |
| 1652 | SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1653 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1654 | case DECL_FIELD: |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1655 | D = FieldDecl::Create(*Context, 0, SourceLocation(), SourceLocation(), 0, |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 1656 | QualType(), 0, 0, false, false); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1657 | break; |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 1658 | case DECL_INDIRECTFIELD: |
| 1659 | D = IndirectFieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), |
| 1660 | 0, 0); |
| 1661 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1662 | case DECL_VAR: |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1663 | D = VarDecl::Create(*Context, 0, SourceLocation(), SourceLocation(), 0, |
| 1664 | QualType(), 0, SC_None, SC_None); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1665 | break; |
| 1666 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1667 | case DECL_IMPLICIT_PARAM: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1668 | D = ImplicitParamDecl::Create(*Context, 0, SourceLocation(), 0, QualType()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1669 | break; |
| 1670 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1671 | case DECL_PARM_VAR: |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1672 | D = ParmVarDecl::Create(*Context, 0, SourceLocation(), SourceLocation(), 0, |
| 1673 | QualType(), 0, SC_None, SC_None, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1674 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1675 | case DECL_FILE_SCOPE_ASM: |
Abramo Bagnara | 21e006e | 2011-03-03 14:20:18 +0000 | [diff] [blame] | 1676 | D = FileScopeAsmDecl::Create(*Context, 0, 0, SourceLocation(), |
| 1677 | SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1678 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1679 | case DECL_BLOCK: |
Chris Lattner | d1d64a0 | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1680 | D = BlockDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1681 | break; |
Douglas Gregor | 7c789c1 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 1682 | case DECL_CXX_BASE_SPECIFIERS: |
| 1683 | Error("attempt to read a C++ base-specifier record as a declaration"); |
| 1684 | return 0; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1685 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1686 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1687 | assert(D && "Unknown declaration reading AST file"); |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1688 | LoadedDecl(Index, D); |
| 1689 | Reader.Visit(D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1690 | |
| 1691 | // If this declaration is also a declaration context, get the |
| 1692 | // offsets for its tables of lexical and visible declarations. |
| 1693 | if (DeclContext *DC = dyn_cast<DeclContext>(D)) { |
| 1694 | std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC); |
| 1695 | if (Offsets.first || Offsets.second) { |
| 1696 | DC->setHasExternalLexicalStorage(Offsets.first != 0); |
| 1697 | DC->setHasExternalVisibleStorage(Offsets.second != 0); |
Sebastian Redl | 681d723 | 2010-07-27 00:17:23 +0000 | [diff] [blame] | 1698 | DeclContextInfo Info; |
| 1699 | if (ReadDeclContextStorage(DeclsCursor, Offsets, Info)) |
| 1700 | return 0; |
Sebastian Redl | d692af7 | 2010-07-27 18:24:41 +0000 | [diff] [blame] | 1701 | DeclContextInfos &Infos = DeclContextOffsets[DC]; |
Sebastian Redl | e1dde81 | 2010-08-24 00:50:04 +0000 | [diff] [blame] | 1702 | // Reading the TU will happen after reading its lexical update blocks, |
| 1703 | // so we need to make sure we insert in front. For all other contexts, |
| 1704 | // the vector is empty here anyway, so there's no loss in efficiency. |
Sebastian Redl | d692af7 | 2010-07-27 18:24:41 +0000 | [diff] [blame] | 1705 | Infos.insert(Infos.begin(), Info); |
Sebastian Redl | 024e1c4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 1706 | } |
Sebastian Redl | e1dde81 | 2010-08-24 00:50:04 +0000 | [diff] [blame] | 1707 | |
Sebastian Redl | 024e1c4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 1708 | // Now add the pending visible updates for this decl context, if it has any. |
| 1709 | DeclContextVisibleUpdatesPending::iterator I = |
| 1710 | PendingVisibleUpdates.find(ID); |
| 1711 | if (I != PendingVisibleUpdates.end()) { |
| 1712 | // There are updates. This means the context has external visible |
| 1713 | // storage, even if the original stored version didn't. |
| 1714 | DC->setHasExternalVisibleStorage(true); |
| 1715 | DeclContextVisibleUpdates &U = I->second; |
| 1716 | DeclContextInfos &Infos = DeclContextOffsets[DC]; |
| 1717 | DeclContextInfo Info; |
| 1718 | Info.LexicalDecls = 0; |
| 1719 | Info.NumLexicalDecls = 0; |
| 1720 | for (DeclContextVisibleUpdates::iterator UI = U.begin(), UE = U.end(); |
| 1721 | UI != UE; ++UI) { |
| 1722 | Info.NameLookupTableData = *UI; |
| 1723 | Infos.push_back(Info); |
Sebastian Redl | e1dde81 | 2010-08-24 00:50:04 +0000 | [diff] [blame] | 1724 | } |
Sebastian Redl | 024e1c4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 1725 | PendingVisibleUpdates.erase(I); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1726 | } |
| 1727 | } |
| 1728 | assert(Idx == Record.size()); |
| 1729 | |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 1730 | // The declaration may have been modified by files later in the chain. |
| 1731 | // If this is the case, read the record containing the updates from each file |
| 1732 | // and pass it to ASTDeclReader to make the modifications. |
| 1733 | DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID); |
| 1734 | if (UpdI != DeclUpdateOffsets.end()) { |
| 1735 | FileOffsetsTy &UpdateOffsets = UpdI->second; |
| 1736 | for (FileOffsetsTy::iterator |
| 1737 | I = UpdateOffsets.begin(), E = UpdateOffsets.end(); I != E; ++I) { |
| 1738 | PerFileData *F = I->first; |
| 1739 | uint64_t Offset = I->second; |
| 1740 | llvm::BitstreamCursor &Cursor = F->DeclsCursor; |
| 1741 | SavedStreamPosition SavedPosition(Cursor); |
| 1742 | Cursor.JumpToBit(Offset); |
| 1743 | RecordData Record; |
| 1744 | unsigned Code = Cursor.ReadCode(); |
| 1745 | unsigned RecCode = Cursor.ReadRecord(Code, Record); |
| 1746 | (void)RecCode; |
| 1747 | assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!"); |
Sebastian Redl | f79a719 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 1748 | Reader.UpdateDecl(D, *F, Record); |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 1749 | } |
| 1750 | } |
| 1751 | |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1752 | // If we have deserialized a declaration that has a definition the |
Argyrios Kyrtzidis | bb80a8e | 2010-07-07 15:46:26 +0000 | [diff] [blame] | 1753 | // AST consumer might need to know about, queue it. |
| 1754 | // We don't pass it to the consumer immediately because we may be in recursive |
| 1755 | // loading, and some declarations may still be initializing. |
| 1756 | if (isConsumerInterestedIn(D)) |
| 1757 | InterestingDecls.push_back(D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1758 | |
| 1759 | return D; |
| 1760 | } |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 1761 | |
Sebastian Redl | f79a719 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 1762 | void ASTDeclReader::UpdateDecl(Decl *D, ASTReader::PerFileData &Module, |
| 1763 | const RecordData &Record) { |
Argyrios Kyrtzidis | 565bf30 | 2010-10-24 17:26:50 +0000 | [diff] [blame] | 1764 | unsigned Idx = 0; |
| 1765 | while (Idx < Record.size()) { |
| 1766 | switch ((DeclUpdateKind)Record[Idx++]) { |
| 1767 | case UPD_CXX_SET_DEFINITIONDATA: { |
| 1768 | CXXRecordDecl *RD = cast<CXXRecordDecl>(D); |
| 1769 | CXXRecordDecl * |
| 1770 | DefinitionDecl = cast<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])); |
| 1771 | assert(!RD->DefinitionData && "DefinitionData is already set!"); |
| 1772 | InitializeCXXDefinitionData(RD, DefinitionDecl, Record, Idx); |
| 1773 | break; |
| 1774 | } |
Argyrios Kyrtzidis | b6cc0e1 | 2010-10-24 17:26:54 +0000 | [diff] [blame] | 1775 | |
| 1776 | case UPD_CXX_ADDED_IMPLICIT_MEMBER: |
| 1777 | cast<CXXRecordDecl>(D)->addedMember(Reader.GetDecl(Record[Idx++])); |
| 1778 | break; |
Argyrios Kyrtzidis | bef1a7b | 2010-10-28 07:38:42 +0000 | [diff] [blame] | 1779 | |
| 1780 | case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: |
| 1781 | // It will be added to the template's specializations set when loaded. |
| 1782 | Reader.GetDecl(Record[Idx++]); |
Sebastian Redl | 7c0837f | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 1783 | break; |
| 1784 | |
| 1785 | case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: { |
| 1786 | NamespaceDecl *Anon = cast<NamespaceDecl>(Reader.GetDecl(Record[Idx++])); |
Sebastian Redl | 74b485a | 2011-04-24 16:28:21 +0000 | [diff] [blame] | 1787 | // Guard against these being loaded out of original order. Don't use |
| 1788 | // getNextNamespace(), since it tries to access the context and can't in |
| 1789 | // the middle of deserialization. |
| 1790 | if (!Anon->NextNamespace) { |
| 1791 | if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D)) |
| 1792 | TU->setAnonymousNamespace(Anon); |
| 1793 | else |
| 1794 | cast<NamespaceDecl>(D)->OrigOrAnonNamespace.setPointer(Anon); |
| 1795 | } |
Sebastian Redl | 7c0837f | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 1796 | break; |
| 1797 | } |
Sebastian Redl | f79a719 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 1798 | |
| 1799 | case UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER: |
| 1800 | cast<VarDecl>(D)->getMemberSpecializationInfo()->setPointOfInstantiation( |
| 1801 | Reader.ReadSourceLocation(Module, Record, Idx)); |
| 1802 | break; |
Argyrios Kyrtzidis | 565bf30 | 2010-10-24 17:26:50 +0000 | [diff] [blame] | 1803 | } |
| 1804 | } |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 1805 | } |