Sebastian Redl | 3b3c874 | 2010-08-18 23:57:11 +0000 | [diff] [blame] | 1 | //===--- ASTReaderDecl.cpp - Decl Deserialization ---------------*- C++ -*-===// |
Chris Lattner | 487412d | 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 | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 10 | // This file implements the ASTReader::ReadDeclRecord method, which is the |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 11 | // entrypoint for loading a decl. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Argyrios Kyrtzidis | 65ad569 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 15 | #include "ASTCommon.h" |
Sebastian Redl | f5b1346 | 2010-08-18 23:57:17 +0000 | [diff] [blame] | 16 | #include "clang/Serialization/ASTReader.h" |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 17 | #include "clang/Sema/SemaDiagnostic.h" |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 18 | #include "clang/AST/ASTConsumer.h" |
| 19 | #include "clang/AST/ASTContext.h" |
| 20 | #include "clang/AST/DeclVisitor.h" |
| 21 | #include "clang/AST/DeclGroup.h" |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 22 | #include "clang/AST/DeclCXX.h" |
| 23 | #include "clang/AST/DeclTemplate.h" |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 24 | #include "clang/AST/Expr.h" |
| 25 | using namespace clang; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 26 | using namespace clang::serialization; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 27 | |
| 28 | //===----------------------------------------------------------------------===// |
| 29 | // Declaration deserialization |
| 30 | //===----------------------------------------------------------------------===// |
| 31 | |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 32 | namespace clang { |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 33 | class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> { |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 34 | ASTReader &Reader; |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 35 | ModuleFile &F; |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 36 | llvm::BitstreamCursor &Cursor; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 37 | const DeclID ThisDeclID; |
Argyrios Kyrtzidis | 81ddd18 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 38 | const unsigned RawLocation; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 39 | typedef ASTReader::RecordData RecordData; |
| 40 | const RecordData &Record; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 41 | unsigned &Idx; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 42 | TypeID TypeIDForTypeDecl; |
Douglas Gregor | 250ffb1 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 43 | |
| 44 | DeclID DeclContextIDForTemplateParmDecl; |
| 45 | DeclID LexicalDeclContextIDForTemplateParmDecl; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 46 | |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 47 | uint64_t GetCurrentCursorOffset(); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 48 | |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 49 | SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) { |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 50 | return Reader.ReadSourceLocation(F, R, I); |
| 51 | } |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 52 | |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 53 | SourceRange ReadSourceRange(const RecordData &R, unsigned &I) { |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 54 | return Reader.ReadSourceRange(F, R, I); |
| 55 | } |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 56 | |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 57 | TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) { |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 58 | return Reader.GetTypeSourceInfo(F, R, I); |
| 59 | } |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 60 | |
| 61 | serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) { |
| 62 | return Reader.ReadDeclID(F, R, I); |
| 63 | } |
| 64 | |
| 65 | Decl *ReadDecl(const RecordData &R, unsigned &I) { |
| 66 | return Reader.ReadDecl(F, R, I); |
| 67 | } |
| 68 | |
| 69 | template<typename T> |
| 70 | T *ReadDeclAs(const RecordData &R, unsigned &I) { |
| 71 | return Reader.ReadDeclAs<T>(F, R, I); |
| 72 | } |
| 73 | |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 74 | void ReadQualifierInfo(QualifierInfo &Info, |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 75 | const RecordData &R, unsigned &I) { |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 76 | Reader.ReadQualifierInfo(F, Info, R, I); |
| 77 | } |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 78 | |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 79 | void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name, |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 80 | const RecordData &R, unsigned &I) { |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 81 | Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I); |
| 82 | } |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 83 | |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 84 | void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 85 | const RecordData &R, unsigned &I) { |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 86 | Reader.ReadDeclarationNameInfo(F, NameInfo, R, I); |
| 87 | } |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 88 | |
Douglas Gregor | cf68c58 | 2011-12-01 22:20:10 +0000 | [diff] [blame] | 89 | serialization::SubmoduleID readSubmoduleID(const RecordData &R, |
| 90 | unsigned &I) { |
| 91 | if (I >= R.size()) |
| 92 | return 0; |
| 93 | |
| 94 | return Reader.getGlobalSubmoduleID(F, R[I++]); |
| 95 | } |
| 96 | |
Douglas Gregor | ba34552 | 2011-12-02 23:23:56 +0000 | [diff] [blame^] | 97 | Module *readModule(const RecordData &R, unsigned &I) { |
| 98 | return Reader.getSubmodule(readSubmoduleID(R, I)); |
| 99 | } |
| 100 | |
Argyrios Kyrtzidis | eb39d9a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 101 | void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data, |
| 102 | const RecordData &R, unsigned &I); |
| 103 | |
| 104 | void InitializeCXXDefinitionData(CXXRecordDecl *D, |
| 105 | CXXRecordDecl *DefinitionDecl, |
| 106 | const RecordData &Record, unsigned &Idx); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 107 | public: |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 108 | ASTDeclReader(ASTReader &Reader, ModuleFile &F, |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 109 | llvm::BitstreamCursor &Cursor, DeclID thisDeclID, |
Argyrios Kyrtzidis | 81ddd18 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 110 | unsigned RawLocation, |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 111 | const RecordData &Record, unsigned &Idx) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 112 | : Reader(Reader), F(F), Cursor(Cursor), ThisDeclID(thisDeclID), |
Argyrios Kyrtzidis | 81ddd18 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 113 | RawLocation(RawLocation), Record(Record), Idx(Idx), |
| 114 | TypeIDForTypeDecl(0) { } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 115 | |
Argyrios Kyrtzidis | 9fdd254 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 116 | static void attachPreviousDecl(Decl *D, Decl *previous); |
| 117 | |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 118 | void Visit(Decl *D); |
| 119 | |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 120 | void UpdateDecl(Decl *D, ModuleFile &ModuleFile, |
Sebastian Redl | 2ac2c72 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 121 | const RecordData &Record); |
Argyrios Kyrtzidis | 65ad569 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 122 | |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 123 | static void setNextObjCCategory(ObjCCategoryDecl *Cat, |
| 124 | ObjCCategoryDecl *Next) { |
| 125 | Cat->NextClassCategory = Next; |
| 126 | } |
| 127 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 128 | void VisitDecl(Decl *D); |
| 129 | void VisitTranslationUnitDecl(TranslationUnitDecl *TU); |
| 130 | void VisitNamedDecl(NamedDecl *ND); |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 131 | void VisitLabelDecl(LabelDecl *LD); |
Douglas Gregor | e31bbd9 | 2010-02-21 18:22:14 +0000 | [diff] [blame] | 132 | void VisitNamespaceDecl(NamespaceDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 133 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); |
| 134 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 135 | void VisitTypeDecl(TypeDecl *TD); |
| 136 | void VisitTypedefDecl(TypedefDecl *TD); |
Richard Smith | dda56e4 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 137 | void VisitTypeAliasDecl(TypeAliasDecl *TD); |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 138 | void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 139 | void VisitTagDecl(TagDecl *TD); |
| 140 | void VisitEnumDecl(EnumDecl *ED); |
| 141 | void VisitRecordDecl(RecordDecl *RD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 142 | void VisitCXXRecordDecl(CXXRecordDecl *D); |
| 143 | void VisitClassTemplateSpecializationDecl( |
| 144 | ClassTemplateSpecializationDecl *D); |
| 145 | void VisitClassTemplatePartialSpecializationDecl( |
| 146 | ClassTemplatePartialSpecializationDecl *D); |
Sebastian Redl | b744863 | 2011-08-31 13:59:56 +0000 | [diff] [blame] | 147 | void VisitClassScopeFunctionSpecializationDecl( |
| 148 | ClassScopeFunctionSpecializationDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 149 | void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 150 | void VisitValueDecl(ValueDecl *VD); |
| 151 | void VisitEnumConstantDecl(EnumConstantDecl *ECD); |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 152 | void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 153 | void VisitDeclaratorDecl(DeclaratorDecl *DD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 154 | void VisitFunctionDecl(FunctionDecl *FD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 155 | void VisitCXXMethodDecl(CXXMethodDecl *D); |
| 156 | void VisitCXXConstructorDecl(CXXConstructorDecl *D); |
| 157 | void VisitCXXDestructorDecl(CXXDestructorDecl *D); |
| 158 | void VisitCXXConversionDecl(CXXConversionDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 159 | void VisitFieldDecl(FieldDecl *FD); |
Francois Pichet | 783dd6e | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 160 | void VisitIndirectFieldDecl(IndirectFieldDecl *FD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 161 | void VisitVarDecl(VarDecl *VD); |
| 162 | void VisitImplicitParamDecl(ImplicitParamDecl *PD); |
| 163 | void VisitParmVarDecl(ParmVarDecl *PD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 164 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); |
| 165 | void VisitTemplateDecl(TemplateDecl *D); |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 166 | void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 167 | void VisitClassTemplateDecl(ClassTemplateDecl *D); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 168 | void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 169 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); |
Richard Smith | 3f1b5d0 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 170 | void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D); |
Argyrios Kyrtzidis | 41d4562 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 171 | void VisitUsingDecl(UsingDecl *D); |
| 172 | void VisitUsingShadowDecl(UsingShadowDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 173 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 174 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD); |
Douglas Gregor | ba34552 | 2011-12-02 23:23:56 +0000 | [diff] [blame^] | 175 | void VisitImportDecl(ImportDecl *D); |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 176 | void VisitAccessSpecDecl(AccessSpecDecl *D); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 177 | void VisitFriendDecl(FriendDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 178 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); |
| 179 | void VisitStaticAssertDecl(StaticAssertDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 180 | void VisitBlockDecl(BlockDecl *BD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 181 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 182 | std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC); |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 183 | template <typename T> void VisitRedeclarable(Redeclarable<T> *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 184 | |
Alexis Hunt | ed05325 | 2010-05-30 07:21:58 +0000 | [diff] [blame] | 185 | // FIXME: Reorder according to DeclNodes.td? |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 186 | void VisitObjCMethodDecl(ObjCMethodDecl *D); |
| 187 | void VisitObjCContainerDecl(ObjCContainerDecl *D); |
| 188 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); |
| 189 | void VisitObjCIvarDecl(ObjCIvarDecl *D); |
| 190 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); |
| 191 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); |
| 192 | void VisitObjCClassDecl(ObjCClassDecl *D); |
| 193 | void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D); |
| 194 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); |
| 195 | void VisitObjCImplDecl(ObjCImplDecl *D); |
| 196 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); |
| 197 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); |
| 198 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); |
| 199 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
| 200 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
| 201 | }; |
| 202 | } |
| 203 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 204 | uint64_t ASTDeclReader::GetCurrentCursorOffset() { |
Douglas Gregor | d32f035 | 2011-07-22 06:10:01 +0000 | [diff] [blame] | 205 | return F.DeclsCursor.GetCurrentBitNo() + F.GlobalBitOffset; |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 206 | } |
| 207 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 208 | void ASTDeclReader::Visit(Decl *D) { |
| 209 | DeclVisitor<ASTDeclReader, void>::Visit(D); |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 210 | |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 211 | if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) { |
| 212 | if (DD->DeclInfo) { |
| 213 | DeclaratorDecl::ExtInfo *Info = |
| 214 | DD->DeclInfo.get<DeclaratorDecl::ExtInfo *>(); |
| 215 | Info->TInfo = |
| 216 | GetTypeSourceInfo(Record, Idx); |
| 217 | } |
| 218 | else { |
| 219 | DD->DeclInfo = GetTypeSourceInfo(Record, Idx); |
| 220 | } |
| 221 | } |
| 222 | |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 223 | if (TypeDecl *TD = dyn_cast<TypeDecl>(D)) { |
Douglas Gregor | 1c28331 | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 224 | // if we have a fully initialized TypeDecl, we can safely read its type now. |
Douglas Gregor | 0cdc832 | 2010-12-10 17:03:06 +0000 | [diff] [blame] | 225 | TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull()); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 226 | } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
| 227 | // FunctionDecl's body was written last after all other Stmts/Exprs. |
| 228 | if (Record[Idx++]) |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 229 | FD->setLazyBody(GetCurrentCursorOffset()); |
Douglas Gregor | 250ffb1 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 230 | } else if (D->isTemplateParameter()) { |
| 231 | // If we have a fully initialized template parameter, we can now |
| 232 | // set its DeclContext. |
| 233 | D->setDeclContext( |
| 234 | cast_or_null<DeclContext>( |
| 235 | Reader.GetDecl(DeclContextIDForTemplateParmDecl))); |
| 236 | D->setLexicalDeclContext( |
| 237 | cast_or_null<DeclContext>( |
| 238 | Reader.GetDecl(LexicalDeclContextIDForTemplateParmDecl))); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 239 | } |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 240 | } |
| 241 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 242 | void ASTDeclReader::VisitDecl(Decl *D) { |
Douglas Gregor | 250ffb1 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 243 | if (D->isTemplateParameter()) { |
| 244 | // We don't want to deserialize the DeclContext of a template |
| 245 | // parameter immediately, because the template parameter might be |
| 246 | // used in the formulation of its DeclContext. Use the translation |
| 247 | // unit DeclContext as a placeholder. |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 248 | DeclContextIDForTemplateParmDecl = ReadDeclID(Record, Idx); |
| 249 | LexicalDeclContextIDForTemplateParmDecl = ReadDeclID(Record, Idx); |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 250 | D->setDeclContext(Reader.getContext().getTranslationUnitDecl()); |
Douglas Gregor | 250ffb1 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 251 | } else { |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 252 | D->setDeclContext(ReadDeclAs<DeclContext>(Record, Idx)); |
| 253 | D->setLexicalDeclContext(ReadDeclAs<DeclContext>(Record, Idx)); |
Douglas Gregor | 250ffb1 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 254 | } |
Argyrios Kyrtzidis | 81ddd18 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 255 | D->setLocation(Reader.ReadSourceLocation(F, RawLocation)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 256 | D->setInvalidDecl(Record[Idx++]); |
Argyrios Kyrtzidis | 9beef8e | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 257 | if (Record[Idx++]) { // hasAttrs |
Alexis Hunt | dcfba7b | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 258 | AttrVec Attrs; |
Argyrios Kyrtzidis | 9beef8e | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 259 | Reader.ReadAttributes(F, Attrs, Record, Idx); |
Alexis Hunt | dcfba7b | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 260 | D->setAttrs(Attrs); |
| 261 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 262 | D->setImplicit(Record[Idx++]); |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 263 | D->setUsed(Record[Idx++]); |
Argyrios Kyrtzidis | 1618023 | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 264 | D->setReferenced(Record[Idx++]); |
Argyrios Kyrtzidis | 8ad3bab | 2011-11-23 20:27:36 +0000 | [diff] [blame] | 265 | D->TopLevelDeclInObjCContainer = Record[Idx++]; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 266 | D->setAccess((AccessSpecifier)Record[Idx++]); |
Douglas Gregor | 98c05b2 | 2011-09-10 00:09:20 +0000 | [diff] [blame] | 267 | D->FromASTFile = true; |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 268 | D->ModulePrivate = Record[Idx++]; |
Douglas Gregor | cf68c58 | 2011-12-01 22:20:10 +0000 | [diff] [blame] | 269 | |
| 270 | // Determine whether this declaration is part of a (sub)module. If so, it |
| 271 | // may not yet be visible. |
| 272 | if (unsigned SubmoduleID = readSubmoduleID(Record, Idx)) { |
| 273 | // Module-private declarations are never visible, so there is no work to do. |
| 274 | if (!D->ModulePrivate) { |
| 275 | if (Module *Owner = Reader.getSubmodule(SubmoduleID)) { |
| 276 | if (Owner->NameVisibility != Module::AllVisible) { |
| 277 | // The owning module is not visible. Mark this declaration as |
| 278 | // module-private, |
| 279 | D->ModulePrivate = true; |
| 280 | |
| 281 | // Note that this declaration was hidden because its owning module is |
| 282 | // not yet visible. |
| 283 | Reader.HiddenNamesMap[Owner].push_back(D); |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 288 | } |
| 289 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 290 | void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { |
Douglas Gregor | dab4243 | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 291 | llvm_unreachable("Translation units are not serialized"); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 292 | } |
| 293 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 294 | void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 295 | VisitDecl(ND); |
Douglas Gregor | 903b7e9 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 296 | ND->setDeclName(Reader.ReadDeclarationName(F, Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 299 | void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 300 | VisitNamedDecl(TD); |
Abramo Bagnara | b3185b0 | 2011-03-06 15:48:19 +0000 | [diff] [blame] | 301 | TD->setLocStart(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 302 | // Delay type reading until after we have fully initialized the decl. |
Douglas Gregor | 903b7e9 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 303 | TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 304 | } |
| 305 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 306 | void ASTDeclReader::VisitTypedefDecl(TypedefDecl *TD) { |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 307 | VisitTypeDecl(TD); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 308 | TD->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 309 | } |
| 310 | |
Richard Smith | dda56e4 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 311 | void ASTDeclReader::VisitTypeAliasDecl(TypeAliasDecl *TD) { |
| 312 | VisitTypeDecl(TD); |
| 313 | TD->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
| 314 | } |
| 315 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 316 | void ASTDeclReader::VisitTagDecl(TagDecl *TD) { |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 317 | VisitRedeclarable(TD); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 318 | VisitTypeDecl(TD); |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 319 | TD->IdentifierNamespace = Record[Idx++]; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 320 | TD->setTagKind((TagDecl::TagKind)Record[Idx++]); |
John McCall | f937c02 | 2011-10-07 06:10:15 +0000 | [diff] [blame] | 321 | TD->setCompleteDefinition(Record[Idx++]); |
Douglas Gregor | 5089c76 | 2010-02-12 17:40:34 +0000 | [diff] [blame] | 322 | TD->setEmbeddedInDeclarator(Record[Idx++]); |
Argyrios Kyrtzidis | 201d377 | 2011-09-30 22:11:31 +0000 | [diff] [blame] | 323 | TD->setFreeStanding(Record[Idx++]); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 324 | TD->setRBraceLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 325 | if (Record[Idx++]) { // hasExtInfo |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 326 | TagDecl::ExtInfo *Info = new (Reader.getContext()) TagDecl::ExtInfo(); |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 327 | ReadQualifierInfo(*Info, Record, Idx); |
Richard Smith | dda56e4 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 328 | TD->TypedefNameDeclOrQualifier = Info; |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 329 | } else |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 330 | TD->setTypedefNameForAnonDecl(ReadDeclAs<TypedefNameDecl>(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 331 | } |
| 332 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 333 | void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 334 | VisitTagDecl(ED); |
Douglas Gregor | 0bf3140 | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 335 | if (TypeSourceInfo *TI = Reader.GetTypeSourceInfo(F, Record, Idx)) |
| 336 | ED->setIntegerTypeSourceInfo(TI); |
| 337 | else |
Douglas Gregor | 903b7e9 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 338 | ED->setIntegerType(Reader.readType(F, Record, Idx)); |
| 339 | ED->setPromotionType(Reader.readType(F, Record, Idx)); |
John McCall | 9aa35be | 2010-05-06 08:49:23 +0000 | [diff] [blame] | 340 | ED->setNumPositiveBits(Record[Idx++]); |
| 341 | ED->setNumNegativeBits(Record[Idx++]); |
Douglas Gregor | 0bf3140 | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 342 | ED->IsScoped = Record[Idx++]; |
Abramo Bagnara | 0e05e24 | 2010-12-03 18:54:17 +0000 | [diff] [blame] | 343 | ED->IsScopedUsingClassTag = Record[Idx++]; |
Douglas Gregor | 0bf3140 | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 344 | ED->IsFixed = Record[Idx++]; |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 345 | ED->setInstantiationOfMemberEnum(ReadDeclAs<EnumDecl>(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 346 | } |
| 347 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 348 | void ASTDeclReader::VisitRecordDecl(RecordDecl *RD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 349 | VisitTagDecl(RD); |
| 350 | RD->setHasFlexibleArrayMember(Record[Idx++]); |
| 351 | RD->setAnonymousStructOrUnion(Record[Idx++]); |
Fariborz Jahanian | 8e0d042 | 2009-07-08 16:37:44 +0000 | [diff] [blame] | 352 | RD->setHasObjectMember(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 353 | } |
| 354 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 355 | void ASTDeclReader::VisitValueDecl(ValueDecl *VD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 356 | VisitNamedDecl(VD); |
Douglas Gregor | 903b7e9 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 357 | VD->setType(Reader.readType(F, Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 358 | } |
| 359 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 360 | void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 361 | VisitValueDecl(ECD); |
| 362 | if (Record[Idx++]) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 363 | ECD->setInitExpr(Reader.ReadExpr(F)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 364 | ECD->setInitVal(Reader.ReadAPSInt(Record, Idx)); |
| 365 | } |
| 366 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 367 | void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 368 | VisitValueDecl(DD); |
Abramo Bagnara | dff1930 | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 369 | DD->setInnerLocStart(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 370 | if (Record[Idx++]) { // hasExtInfo |
| 371 | DeclaratorDecl::ExtInfo *Info |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 372 | = new (Reader.getContext()) DeclaratorDecl::ExtInfo(); |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 373 | ReadQualifierInfo(*Info, Record, Idx); |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 374 | DD->DeclInfo = Info; |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 375 | } |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 376 | } |
| 377 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 378 | void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 379 | VisitRedeclarable(FD); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 380 | VisitDeclaratorDecl(FD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 381 | |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 382 | ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName(), Record, Idx); |
Argyrios Kyrtzidis | a95d019 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 383 | FD->IdentifierNamespace = Record[Idx++]; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 384 | switch ((FunctionDecl::TemplatedKind)Record[Idx++]) { |
David Blaikie | 83d382b | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 385 | default: llvm_unreachable("Unhandled TemplatedKind!"); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 386 | case FunctionDecl::TK_NonTemplate: |
| 387 | break; |
| 388 | case FunctionDecl::TK_FunctionTemplate: |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 389 | FD->setDescribedFunctionTemplate(ReadDeclAs<FunctionTemplateDecl>(Record, |
| 390 | Idx)); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 391 | break; |
| 392 | case FunctionDecl::TK_MemberSpecialization: { |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 393 | FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>(Record, Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 394 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 395 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 396 | FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 397 | FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI); |
| 398 | break; |
| 399 | } |
| 400 | case FunctionDecl::TK_FunctionTemplateSpecialization: { |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 401 | FunctionTemplateDecl *Template = ReadDeclAs<FunctionTemplateDecl>(Record, |
| 402 | Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 403 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
| 404 | |
| 405 | // Template arguments. |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 406 | SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 407 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 408 | |
| 409 | // Template args as written. |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 410 | SmallVector<TemplateArgumentLoc, 8> TemplArgLocs; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 411 | SourceLocation LAngleLoc, RAngleLoc; |
Argyrios Kyrtzidis | e9a2443 | 2011-09-22 20:07:09 +0000 | [diff] [blame] | 412 | bool HasTemplateArgumentsAsWritten = Record[Idx++]; |
| 413 | if (HasTemplateArgumentsAsWritten) { |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 414 | unsigned NumTemplateArgLocs = Record[Idx++]; |
| 415 | TemplArgLocs.reserve(NumTemplateArgLocs); |
| 416 | for (unsigned i=0; i != NumTemplateArgLocs; ++i) |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 417 | TemplArgLocs.push_back( |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 418 | Reader.ReadTemplateArgumentLoc(F, Record, Idx)); |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 419 | |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 420 | LAngleLoc = ReadSourceLocation(Record, Idx); |
| 421 | RAngleLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 422 | } |
Argyrios Kyrtzidis | 927d8e0 | 2010-07-05 10:37:55 +0000 | [diff] [blame] | 423 | |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 424 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 425 | |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 426 | ASTContext &C = Reader.getContext(); |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 427 | TemplateArgumentList *TemplArgList |
Douglas Gregor | 1ccc841 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 428 | = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), TemplArgs.size()); |
Argyrios Kyrtzidis | e9a2443 | 2011-09-22 20:07:09 +0000 | [diff] [blame] | 429 | TemplateArgumentListInfo TemplArgsInfo(LAngleLoc, RAngleLoc); |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 430 | for (unsigned i=0, e = TemplArgLocs.size(); i != e; ++i) |
Argyrios Kyrtzidis | e9a2443 | 2011-09-22 20:07:09 +0000 | [diff] [blame] | 431 | TemplArgsInfo.addArgument(TemplArgLocs[i]); |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 432 | FunctionTemplateSpecializationInfo *FTInfo |
| 433 | = FunctionTemplateSpecializationInfo::Create(C, FD, Template, TSK, |
| 434 | TemplArgList, |
Argyrios Kyrtzidis | e9a2443 | 2011-09-22 20:07:09 +0000 | [diff] [blame] | 435 | HasTemplateArgumentsAsWritten ? &TemplArgsInfo : 0, |
| 436 | POI); |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 437 | FD->TemplateOrSpecialization = FTInfo; |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 438 | |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 439 | if (FD->isCanonicalDecl()) { // if canonical add to template's set. |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 440 | // The template that contains the specializations set. It's not safe to |
| 441 | // use getCanonicalDecl on Template since it may still be initializing. |
| 442 | FunctionTemplateDecl *CanonTemplate |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 443 | = ReadDeclAs<FunctionTemplateDecl>(Record, Idx); |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 444 | // Get the InsertPos by FindNodeOrInsertPos() instead of calling |
| 445 | // InsertNode(FTInfo) directly to avoid the getASTContext() call in |
| 446 | // FunctionTemplateSpecializationInfo's Profile(). |
| 447 | // We avoid getASTContext because a decl in the parent hierarchy may |
| 448 | // be initializing. |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 449 | llvm::FoldingSetNodeID ID; |
| 450 | FunctionTemplateSpecializationInfo::Profile(ID, TemplArgs.data(), |
| 451 | TemplArgs.size(), C); |
| 452 | void *InsertPos = 0; |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 453 | CanonTemplate->getSpecializations().FindNodeOrInsertPos(ID, InsertPos); |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 454 | assert(InsertPos && "Another specialization already inserted!"); |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 455 | CanonTemplate->getSpecializations().InsertNode(FTInfo, InsertPos); |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 456 | } |
Argyrios Kyrtzidis | 0b0369a | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 457 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 458 | } |
| 459 | case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { |
| 460 | // Templates. |
| 461 | UnresolvedSet<8> TemplDecls; |
| 462 | unsigned NumTemplates = Record[Idx++]; |
| 463 | while (NumTemplates--) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 464 | TemplDecls.addDecl(ReadDeclAs<NamedDecl>(Record, Idx)); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 465 | |
| 466 | // Templates args. |
| 467 | TemplateArgumentListInfo TemplArgs; |
| 468 | unsigned NumArgs = Record[Idx++]; |
| 469 | while (NumArgs--) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 470 | TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(F, Record, Idx)); |
| 471 | TemplArgs.setLAngleLoc(ReadSourceLocation(Record, Idx)); |
| 472 | TemplArgs.setRAngleLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 473 | |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 474 | FD->setDependentTemplateSpecialization(Reader.getContext(), |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 475 | TemplDecls, TemplArgs); |
Argyrios Kyrtzidis | 0b0369a | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 476 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 477 | } |
| 478 | } |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 479 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 480 | // FunctionDecl's body is handled last at ASTDeclReader::Visit, |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 481 | // after everything else is read. |
| 482 | |
Douglas Gregor | bf62d64 | 2010-12-06 18:36:25 +0000 | [diff] [blame] | 483 | FD->SClass = (StorageClass)Record[Idx++]; |
Argyrios Kyrtzidis | 7cd6924 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 484 | FD->SClassAsWritten = (StorageClass)Record[Idx++]; |
Douglas Gregor | ff76cb9 | 2010-12-09 16:59:22 +0000 | [diff] [blame] | 485 | FD->IsInline = Record[Idx++]; |
| 486 | FD->IsInlineSpecified = Record[Idx++]; |
Argyrios Kyrtzidis | 7cd6924 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 487 | FD->IsVirtualAsWritten = Record[Idx++]; |
| 488 | FD->IsPure = Record[Idx++]; |
| 489 | FD->HasInheritedPrototype = Record[Idx++]; |
| 490 | FD->HasWrittenPrototype = Record[Idx++]; |
| 491 | FD->IsDeleted = Record[Idx++]; |
| 492 | FD->IsTrivial = Record[Idx++]; |
Alexis Hunt | 1f69a02 | 2011-05-12 22:46:29 +0000 | [diff] [blame] | 493 | FD->IsDefaulted = Record[Idx++]; |
| 494 | FD->IsExplicitlyDefaulted = Record[Idx++]; |
Argyrios Kyrtzidis | 7cd6924 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 495 | FD->HasImplicitReturnZero = Record[Idx++]; |
Richard Smith | a77a0a6 | 2011-08-15 21:04:07 +0000 | [diff] [blame] | 496 | FD->IsConstexpr = Record[Idx++]; |
Argyrios Kyrtzidis | 7cd6924 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 497 | FD->EndRangeLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 498 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 499 | // Read in the parameters. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 500 | unsigned NumParams = Record[Idx++]; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 501 | SmallVector<ParmVarDecl *, 16> Params; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 502 | Params.reserve(NumParams); |
| 503 | for (unsigned I = 0; I != NumParams; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 504 | Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx)); |
David Blaikie | 9c70e04 | 2011-09-21 18:16:56 +0000 | [diff] [blame] | 505 | FD->setParams(Reader.getContext(), Params); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 506 | } |
| 507 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 508 | void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 509 | VisitNamedDecl(MD); |
| 510 | if (Record[Idx++]) { |
| 511 | // In practice, this won't be executed (since method definitions |
| 512 | // don't occur in header files). |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 513 | MD->setBody(Reader.ReadStmt(F)); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 514 | MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx)); |
| 515 | MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 516 | } |
| 517 | MD->setInstanceMethod(Record[Idx++]); |
| 518 | MD->setVariadic(Record[Idx++]); |
| 519 | MD->setSynthesized(Record[Idx++]); |
Fariborz Jahanian | 6e7e8cc | 2010-07-22 18:24:20 +0000 | [diff] [blame] | 520 | MD->setDefined(Record[Idx++]); |
Argyrios Kyrtzidis | db21596 | 2011-10-14 17:41:52 +0000 | [diff] [blame] | 521 | |
| 522 | MD->IsRedeclaration = Record[Idx++]; |
| 523 | MD->HasRedeclaration = Record[Idx++]; |
| 524 | if (MD->HasRedeclaration) |
| 525 | Reader.getContext().setObjCMethodRedeclaration(MD, |
| 526 | ReadDeclAs<ObjCMethodDecl>(Record, Idx)); |
| 527 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 528 | MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]); |
| 529 | MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); |
Douglas Gregor | 3382372 | 2011-06-11 01:09:30 +0000 | [diff] [blame] | 530 | MD->SetRelatedResultType(Record[Idx++]); |
Douglas Gregor | 903b7e9 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 531 | MD->setResultType(Reader.readType(F, Record, Idx)); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 532 | MD->setResultTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
| 533 | MD->setEndLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 534 | unsigned NumParams = Record[Idx++]; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 535 | SmallVector<ParmVarDecl *, 16> Params; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 536 | Params.reserve(NumParams); |
| 537 | for (unsigned I = 0; I != NumParams; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 538 | Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx)); |
Argyrios Kyrtzidis | b8c3aaf | 2011-10-03 06:37:04 +0000 | [diff] [blame] | 539 | |
| 540 | MD->SelLocsKind = Record[Idx++]; |
| 541 | unsigned NumStoredSelLocs = Record[Idx++]; |
| 542 | SmallVector<SourceLocation, 16> SelLocs; |
| 543 | SelLocs.reserve(NumStoredSelLocs); |
| 544 | for (unsigned i = 0; i != NumStoredSelLocs; ++i) |
| 545 | SelLocs.push_back(ReadSourceLocation(Record, Idx)); |
| 546 | |
| 547 | MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 550 | void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 551 | VisitNamedDecl(CD); |
Argyrios Kyrtzidis | 52f53fb | 2011-10-04 04:48:02 +0000 | [diff] [blame] | 552 | CD->setAtStartLoc(ReadSourceLocation(Record, Idx)); |
| 553 | CD->setAtEndRange(ReadSourceRange(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 554 | } |
| 555 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 556 | void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 557 | VisitObjCContainerDecl(ID); |
Douglas Gregor | 903b7e9 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 558 | ID->setTypeForDecl(Reader.readType(F, Record, Idx).getTypePtrOrNull()); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 559 | ID->setSuperClass(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx)); |
Ted Kremenek | 0ef508d | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 560 | |
| 561 | // Read the directly referenced protocols and their SourceLocations. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 562 | unsigned NumProtocols = Record[Idx++]; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 563 | SmallVector<ObjCProtocolDecl *, 16> Protocols; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 564 | Protocols.reserve(NumProtocols); |
| 565 | for (unsigned I = 0; I != NumProtocols; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 566 | Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 567 | SmallVector<SourceLocation, 16> ProtoLocs; |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 568 | ProtoLocs.reserve(NumProtocols); |
| 569 | for (unsigned I = 0; I != NumProtocols; ++I) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 570 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 571 | ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(), |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 572 | Reader.getContext()); |
Ted Kremenek | 0ef508d | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 573 | |
| 574 | // Read the transitive closure of protocols referenced by this class. |
| 575 | NumProtocols = Record[Idx++]; |
| 576 | Protocols.clear(); |
| 577 | Protocols.reserve(NumProtocols); |
| 578 | for (unsigned I = 0; I != NumProtocols; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 579 | Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
Ted Kremenek | 0ef508d | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 580 | ID->AllReferencedProtocols.set(Protocols.data(), NumProtocols, |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 581 | Reader.getContext()); |
Ted Kremenek | 0ef508d | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 582 | |
| 583 | // Read the ivars. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 584 | unsigned NumIvars = Record[Idx++]; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 585 | SmallVector<ObjCIvarDecl *, 16> IVars; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 586 | IVars.reserve(NumIvars); |
| 587 | for (unsigned I = 0; I != NumIvars; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 588 | IVars.push_back(ReadDeclAs<ObjCIvarDecl>(Record, Idx)); |
| 589 | ID->setCategoryList(ReadDeclAs<ObjCCategoryDecl>(Record, Idx)); |
| 590 | |
Fariborz Jahanian | a50b3a2 | 2010-08-20 21:21:08 +0000 | [diff] [blame] | 591 | // We will rebuild this list lazily. |
| 592 | ID->setIvarList(0); |
Argyrios Kyrtzidis | 1f4bee5 | 2011-10-17 19:48:06 +0000 | [diff] [blame] | 593 | ID->InitiallyForwardDecl = Record[Idx++]; |
Argyrios Kyrtzidis | b97a402 | 2011-11-12 21:07:46 +0000 | [diff] [blame] | 594 | ID->ForwardDecl = Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 595 | ID->setSuperClassLoc(ReadSourceLocation(Record, Idx)); |
| 596 | ID->setLocEnd(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 597 | } |
| 598 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 599 | void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 600 | VisitFieldDecl(IVD); |
| 601 | IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]); |
Fariborz Jahanian | a50b3a2 | 2010-08-20 21:21:08 +0000 | [diff] [blame] | 602 | // This field will be built lazily. |
| 603 | IVD->setNextIvar(0); |
Fariborz Jahanian | aea8e1e | 2010-07-17 18:35:47 +0000 | [diff] [blame] | 604 | bool synth = Record[Idx++]; |
| 605 | IVD->setSynthesize(synth); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 606 | } |
| 607 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 608 | void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 609 | VisitObjCContainerDecl(PD); |
Argyrios Kyrtzidis | 1f4bee5 | 2011-10-17 19:48:06 +0000 | [diff] [blame] | 610 | PD->InitiallyForwardDecl = Record[Idx++]; |
Argyrios Kyrtzidis | b97a402 | 2011-11-12 21:07:46 +0000 | [diff] [blame] | 611 | PD->isForwardProtoDecl = Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 612 | PD->setLocEnd(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 613 | unsigned NumProtoRefs = Record[Idx++]; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 614 | SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 615 | ProtoRefs.reserve(NumProtoRefs); |
| 616 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 617 | ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 618 | SmallVector<SourceLocation, 16> ProtoLocs; |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 619 | ProtoLocs.reserve(NumProtoRefs); |
| 620 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 621 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 622 | PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 623 | Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 624 | } |
| 625 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 626 | void ASTDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 627 | VisitFieldDecl(FD); |
| 628 | } |
| 629 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 630 | void ASTDeclReader::VisitObjCClassDecl(ObjCClassDecl *CD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 631 | VisitDecl(CD); |
Fariborz Jahanian | 3a039e3 | 2011-08-27 20:50:59 +0000 | [diff] [blame] | 632 | ObjCInterfaceDecl *ClassRef = ReadDeclAs<ObjCInterfaceDecl>(Record, Idx); |
| 633 | SourceLocation SLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 634 | CD->setClass(Reader.getContext(), ClassRef, SLoc); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 635 | } |
| 636 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 637 | void ASTDeclReader::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *FPD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 638 | VisitDecl(FPD); |
| 639 | unsigned NumProtoRefs = Record[Idx++]; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 640 | SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 641 | ProtoRefs.reserve(NumProtoRefs); |
| 642 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 643 | ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 644 | SmallVector<SourceLocation, 16> ProtoLocs; |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 645 | ProtoLocs.reserve(NumProtoRefs); |
| 646 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 647 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 648 | FPD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 649 | Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 650 | } |
| 651 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 652 | void ASTDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 653 | VisitObjCContainerDecl(CD); |
Argyrios Kyrtzidis | 3a5094b | 2011-08-30 19:43:26 +0000 | [diff] [blame] | 654 | CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>(Record, Idx); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 655 | unsigned NumProtoRefs = Record[Idx++]; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 656 | SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 657 | ProtoRefs.reserve(NumProtoRefs); |
| 658 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 659 | ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 660 | SmallVector<SourceLocation, 16> ProtoLocs; |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 661 | ProtoLocs.reserve(NumProtoRefs); |
| 662 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 663 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 664 | CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 665 | Reader.getContext()); |
Argyrios Kyrtzidis | 3a5094b | 2011-08-30 19:43:26 +0000 | [diff] [blame] | 666 | CD->NextClassCategory = ReadDeclAs<ObjCCategoryDecl>(Record, Idx); |
Fariborz Jahanian | bf9294f | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 667 | CD->setHasSynthBitfield(Record[Idx++]); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 668 | CD->setCategoryNameLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 669 | } |
| 670 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 671 | void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 672 | VisitNamedDecl(CAD); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 673 | CAD->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 674 | } |
| 675 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 676 | void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 677 | VisitNamedDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 678 | D->setAtLoc(ReadSourceLocation(Record, Idx)); |
| 679 | D->setType(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 680 | // FIXME: stable encoding |
| 681 | D->setPropertyAttributes( |
| 682 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Fariborz Jahanian | 3bf0ded | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 683 | D->setPropertyAttributesAsWritten( |
| 684 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 685 | // FIXME: stable encoding |
| 686 | D->setPropertyImplementation( |
| 687 | (ObjCPropertyDecl::PropertyControl)Record[Idx++]); |
Douglas Gregor | 903b7e9 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 688 | D->setGetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector()); |
| 689 | D->setSetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector()); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 690 | D->setGetterMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx)); |
| 691 | D->setSetterMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx)); |
| 692 | D->setPropertyIvarDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 693 | } |
| 694 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 695 | void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) { |
Argyrios Kyrtzidis | 067c407 | 2009-07-27 19:04:32 +0000 | [diff] [blame] | 696 | VisitObjCContainerDecl(D); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 697 | D->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 698 | } |
| 699 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 700 | void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 701 | VisitObjCImplDecl(D); |
Douglas Gregor | a3e4153 | 2011-07-28 20:55:49 +0000 | [diff] [blame] | 702 | D->setIdentifier(Reader.GetIdentifierInfo(F, Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 703 | } |
| 704 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 705 | void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 706 | VisitObjCImplDecl(D); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 707 | D->setSuperClass(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx)); |
Argyrios Kyrtzidis | 13257c5 | 2010-08-09 10:54:20 +0000 | [diff] [blame] | 708 | llvm::tie(D->IvarInitializers, D->NumIvarInitializers) |
Alexis Hunt | 1d79265 | 2011-01-08 20:30:50 +0000 | [diff] [blame] | 709 | = Reader.ReadCXXCtorInitializers(F, Record, Idx); |
Fariborz Jahanian | bf9294f | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 710 | D->setHasSynthBitfield(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 714 | void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 715 | VisitDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 716 | D->setAtLoc(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 717 | D->setPropertyDecl(ReadDeclAs<ObjCPropertyDecl>(Record, Idx)); |
| 718 | D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>(Record, Idx); |
Douglas Gregor | b1b71e5 | 2010-11-17 01:03:52 +0000 | [diff] [blame] | 719 | D->IvarLoc = ReadSourceLocation(Record, Idx); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 720 | D->setGetterCXXConstructor(Reader.ReadExpr(F)); |
| 721 | D->setSetterCXXAssignment(Reader.ReadExpr(F)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 722 | } |
| 723 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 724 | void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 725 | VisitDeclaratorDecl(FD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 726 | FD->setMutable(Record[Idx++]); |
Richard Smith | 938f40b | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 727 | int BitWidthOrInitializer = Record[Idx++]; |
| 728 | if (BitWidthOrInitializer == 1) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 729 | FD->setBitWidth(Reader.ReadExpr(F)); |
Richard Smith | 938f40b | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 730 | else if (BitWidthOrInitializer == 2) |
| 731 | FD->setInClassInitializer(Reader.ReadExpr(F)); |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 732 | if (!FD->getDeclName()) { |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 733 | if (FieldDecl *Tmpl = ReadDeclAs<FieldDecl>(Record, Idx)) |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 734 | Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl); |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 735 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 736 | } |
| 737 | |
Francois Pichet | 783dd6e | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 738 | void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) { |
| 739 | VisitValueDecl(FD); |
| 740 | |
| 741 | FD->ChainingSize = Record[Idx++]; |
| 742 | assert(FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2"); |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 743 | FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize]; |
Francois Pichet | 783dd6e | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 744 | |
| 745 | for (unsigned I = 0; I != FD->ChainingSize; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 746 | FD->Chaining[I] = ReadDeclAs<NamedDecl>(Record, Idx); |
Francois Pichet | 783dd6e | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 747 | } |
| 748 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 749 | void ASTDeclReader::VisitVarDecl(VarDecl *VD) { |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 750 | VisitRedeclarable(VD); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 751 | VisitDeclaratorDecl(VD); |
John McCall | beaa11c | 2011-05-01 02:13:58 +0000 | [diff] [blame] | 752 | VD->VarDeclBits.SClass = (StorageClass)Record[Idx++]; |
| 753 | VD->VarDeclBits.SClassAsWritten = (StorageClass)Record[Idx++]; |
| 754 | VD->VarDeclBits.ThreadSpecified = Record[Idx++]; |
| 755 | VD->VarDeclBits.HasCXXDirectInit = Record[Idx++]; |
| 756 | VD->VarDeclBits.ExceptionVar = Record[Idx++]; |
| 757 | VD->VarDeclBits.NRVOVariable = Record[Idx++]; |
| 758 | VD->VarDeclBits.CXXForRangeDecl = Record[Idx++]; |
John McCall | d463132 | 2011-06-17 06:42:21 +0000 | [diff] [blame] | 759 | VD->VarDeclBits.ARCPseudoStrong = Record[Idx++]; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 760 | if (Record[Idx++]) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 761 | VD->setInit(Reader.ReadExpr(F)); |
Argyrios Kyrtzidis | cdb8b3f | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 762 | |
| 763 | if (Record[Idx++]) { // HasMemberSpecializationInfo. |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 764 | VarDecl *Tmpl = ReadDeclAs<VarDecl>(Record, Idx); |
Argyrios Kyrtzidis | cdb8b3f | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 765 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 766 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 767 | Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI); |
Argyrios Kyrtzidis | cdb8b3f | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 768 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 769 | } |
| 770 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 771 | void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 772 | VisitVarDecl(PD); |
| 773 | } |
| 774 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 775 | void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 776 | VisitVarDecl(PD); |
John McCall | 8249083 | 2011-05-02 00:30:12 +0000 | [diff] [blame] | 777 | unsigned isObjCMethodParam = Record[Idx++]; |
| 778 | unsigned scopeDepth = Record[Idx++]; |
| 779 | unsigned scopeIndex = Record[Idx++]; |
| 780 | unsigned declQualifier = Record[Idx++]; |
| 781 | if (isObjCMethodParam) { |
| 782 | assert(scopeDepth == 0); |
| 783 | PD->setObjCMethodScopeInfo(scopeIndex); |
| 784 | PD->ParmVarDeclBits.ScopeDepthOrObjCQuals = declQualifier; |
| 785 | } else { |
| 786 | PD->setScopeInfo(scopeDepth, scopeIndex); |
| 787 | } |
John McCall | beaa11c | 2011-05-01 02:13:58 +0000 | [diff] [blame] | 788 | PD->ParmVarDeclBits.IsKNRPromoted = Record[Idx++]; |
| 789 | PD->ParmVarDeclBits.HasInheritedDefaultArg = Record[Idx++]; |
Argyrios Kyrtzidis | ccde6a0 | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 790 | if (Record[Idx++]) // hasUninstantiatedDefaultArg. |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 791 | PD->setUninstantiatedDefaultArg(Reader.ReadExpr(F)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 792 | } |
| 793 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 794 | void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 795 | VisitDecl(AD); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 796 | AD->setAsmString(cast<StringLiteral>(Reader.ReadExpr(F))); |
Abramo Bagnara | 348823a | 2011-03-03 14:20:18 +0000 | [diff] [blame] | 797 | AD->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 798 | } |
| 799 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 800 | void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 801 | VisitDecl(BD); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 802 | BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(F))); |
| 803 | BD->setSignatureAsWritten(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 804 | unsigned NumParams = Record[Idx++]; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 805 | SmallVector<ParmVarDecl *, 16> Params; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 806 | Params.reserve(NumParams); |
| 807 | for (unsigned I = 0; I != NumParams; ++I) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 808 | Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx)); |
David Blaikie | 9c70e04 | 2011-09-21 18:16:56 +0000 | [diff] [blame] | 809 | BD->setParams(Params); |
John McCall | c63de66 | 2011-02-02 13:00:07 +0000 | [diff] [blame] | 810 | |
| 811 | bool capturesCXXThis = Record[Idx++]; |
John McCall | 351762c | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 812 | unsigned numCaptures = Record[Idx++]; |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 813 | SmallVector<BlockDecl::Capture, 16> captures; |
John McCall | 351762c | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 814 | captures.reserve(numCaptures); |
| 815 | for (unsigned i = 0; i != numCaptures; ++i) { |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 816 | VarDecl *decl = ReadDeclAs<VarDecl>(Record, Idx); |
John McCall | 351762c | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 817 | unsigned flags = Record[Idx++]; |
| 818 | bool byRef = (flags & 1); |
| 819 | bool nested = (flags & 2); |
| 820 | Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) : 0); |
| 821 | |
| 822 | captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr)); |
| 823 | } |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 824 | BD->setCaptures(Reader.getContext(), captures.begin(), |
John McCall | 351762c | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 825 | captures.end(), capturesCXXThis); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 826 | } |
| 827 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 828 | void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 829 | VisitDecl(D); |
| 830 | D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]); |
Abramo Bagnara | ea94788 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 831 | D->setExternLoc(ReadSourceLocation(Record, Idx)); |
Abramo Bagnara | 4a8cda8 | 2011-03-03 14:52:38 +0000 | [diff] [blame] | 832 | D->setRBraceLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 833 | } |
| 834 | |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 835 | void ASTDeclReader::VisitLabelDecl(LabelDecl *D) { |
| 836 | VisitNamedDecl(D); |
Abramo Bagnara | 1c3af96 | 2011-03-05 18:21:20 +0000 | [diff] [blame] | 837 | D->setLocStart(ReadSourceLocation(Record, Idx)); |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 841 | void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 842 | VisitNamedDecl(D); |
Douglas Gregor | 44e5c1f | 2010-10-05 20:41:58 +0000 | [diff] [blame] | 843 | D->IsInline = Record[Idx++]; |
Abramo Bagnara | b5545be | 2011-03-08 12:38:20 +0000 | [diff] [blame] | 844 | D->LocStart = ReadSourceLocation(Record, Idx); |
| 845 | D->RBraceLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 417e87c | 2010-10-27 19:49:05 +0000 | [diff] [blame] | 846 | D->NextNamespace = Record[Idx++]; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 847 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 848 | bool IsOriginal = Record[Idx++]; |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 849 | // FIXME: Modules will likely have trouble with pointing directly at |
| 850 | // the original namespace. |
Argyrios Kyrtzidis | dae2a16 | 2010-07-03 07:57:53 +0000 | [diff] [blame] | 851 | D->OrigOrAnonNamespace.setInt(IsOriginal); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 852 | D->OrigOrAnonNamespace.setPointer(ReadDeclAs<NamespaceDecl>(Record, Idx)); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 853 | } |
| 854 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 855 | void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 856 | VisitNamedDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 857 | D->NamespaceLoc = ReadSourceLocation(Record, Idx); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 858 | D->IdentLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | c05ba2e | 2011-02-25 17:08:07 +0000 | [diff] [blame] | 859 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 860 | D->Namespace = ReadDeclAs<NamedDecl>(Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 861 | } |
| 862 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 863 | void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 864 | VisitNamedDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 865 | D->setUsingLocation(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | a9d87bc | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 866 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 867 | ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 868 | D->FirstUsingShadow = ReadDeclAs<UsingShadowDecl>(Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 869 | D->setTypeName(Record[Idx++]); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 870 | if (NamedDecl *Pattern = ReadDeclAs<NamedDecl>(Record, Idx)) |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 871 | Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 872 | } |
| 873 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 874 | void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 875 | VisitNamedDecl(D); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 876 | D->setTargetDecl(ReadDeclAs<NamedDecl>(Record, Idx)); |
| 877 | D->UsingOrNextShadow = ReadDeclAs<NamedDecl>(Record, Idx); |
| 878 | UsingShadowDecl *Pattern = ReadDeclAs<UsingShadowDecl>(Record, Idx); |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 879 | if (Pattern) |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 880 | Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 881 | } |
| 882 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 883 | void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 884 | VisitNamedDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 885 | D->UsingLoc = ReadSourceLocation(Record, Idx); |
| 886 | D->NamespaceLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 12441b3 | 2011-02-25 16:33:46 +0000 | [diff] [blame] | 887 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 888 | D->NominatedNamespace = ReadDeclAs<NamedDecl>(Record, Idx); |
| 889 | D->CommonAncestor = ReadDeclAs<DeclContext>(Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 890 | } |
| 891 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 892 | void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 893 | VisitValueDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 894 | D->setUsingLoc(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | a9d87bc | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 895 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 896 | ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 897 | } |
| 898 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 899 | void ASTDeclReader::VisitUnresolvedUsingTypenameDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 900 | UnresolvedUsingTypenameDecl *D) { |
| 901 | VisitTypeDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 902 | D->TypenameLocation = ReadSourceLocation(Record, Idx); |
Douglas Gregor | a9d87bc | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 903 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 904 | } |
| 905 | |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 906 | void ASTDeclReader::ReadCXXDefinitionData( |
Argyrios Kyrtzidis | eb39d9a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 907 | struct CXXRecordDecl::DefinitionData &Data, |
| 908 | const RecordData &Record, unsigned &Idx) { |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 909 | Data.UserDeclaredConstructor = Record[Idx++]; |
| 910 | Data.UserDeclaredCopyConstructor = Record[Idx++]; |
Douglas Gregor | cd0d826 | 2011-09-06 16:38:46 +0000 | [diff] [blame] | 911 | Data.UserDeclaredMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 912 | Data.UserDeclaredCopyAssignment = Record[Idx++]; |
Douglas Gregor | cd0d826 | 2011-09-06 16:38:46 +0000 | [diff] [blame] | 913 | Data.UserDeclaredMoveAssignment = Record[Idx++]; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 914 | Data.UserDeclaredDestructor = Record[Idx++]; |
| 915 | Data.Aggregate = Record[Idx++]; |
| 916 | Data.PlainOldData = Record[Idx++]; |
| 917 | Data.Empty = Record[Idx++]; |
| 918 | Data.Polymorphic = Record[Idx++]; |
| 919 | Data.Abstract = Record[Idx++]; |
Chandler Carruth | 583edf8 | 2011-04-30 10:07:30 +0000 | [diff] [blame] | 920 | Data.IsStandardLayout = Record[Idx++]; |
Chandler Carruth | b196374 | 2011-04-30 09:17:45 +0000 | [diff] [blame] | 921 | Data.HasNoNonEmptyBases = Record[Idx++]; |
| 922 | Data.HasPrivateFields = Record[Idx++]; |
| 923 | Data.HasProtectedFields = Record[Idx++]; |
| 924 | Data.HasPublicFields = Record[Idx++]; |
Douglas Gregor | 61226d3 | 2011-05-13 01:05:07 +0000 | [diff] [blame] | 925 | Data.HasMutableFields = Record[Idx++]; |
Alexis Hunt | f479f1b | 2011-05-09 18:22:59 +0000 | [diff] [blame] | 926 | Data.HasTrivialDefaultConstructor = Record[Idx++]; |
Richard Smith | 111af8d | 2011-08-10 18:11:37 +0000 | [diff] [blame] | 927 | Data.HasConstexprNonCopyMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 928 | Data.HasTrivialCopyConstructor = Record[Idx++]; |
Chandler Carruth | ad7d404 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 929 | Data.HasTrivialMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 930 | Data.HasTrivialCopyAssignment = Record[Idx++]; |
Chandler Carruth | ad7d404 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 931 | Data.HasTrivialMoveAssignment = Record[Idx++]; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 932 | Data.HasTrivialDestructor = Record[Idx++]; |
Chandler Carruth | e71d062 | 2011-04-24 02:49:34 +0000 | [diff] [blame] | 933 | Data.HasNonLiteralTypeFieldsOrBases = Record[Idx++]; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 934 | Data.ComputedVisibleConversions = Record[Idx++]; |
Alexis Hunt | ea6f032 | 2011-05-11 22:34:38 +0000 | [diff] [blame] | 935 | Data.UserProvidedDefaultConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 936 | Data.DeclaredDefaultConstructor = Record[Idx++]; |
| 937 | Data.DeclaredCopyConstructor = Record[Idx++]; |
Douglas Gregor | cd0d826 | 2011-09-06 16:38:46 +0000 | [diff] [blame] | 938 | Data.DeclaredMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 939 | Data.DeclaredCopyAssignment = Record[Idx++]; |
Douglas Gregor | cd0d826 | 2011-09-06 16:38:46 +0000 | [diff] [blame] | 940 | Data.DeclaredMoveAssignment = Record[Idx++]; |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 941 | Data.DeclaredDestructor = Record[Idx++]; |
Sebastian Redl | b744863 | 2011-08-31 13:59:56 +0000 | [diff] [blame] | 942 | Data.FailedImplicitMoveConstructor = Record[Idx++]; |
| 943 | Data.FailedImplicitMoveAssignment = Record[Idx++]; |
Anders Carlsson | 703d6e6 | 2011-01-22 18:11:02 +0000 | [diff] [blame] | 944 | |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 945 | Data.NumBases = Record[Idx++]; |
Douglas Gregor | d4c5ed0 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 946 | if (Data.NumBases) |
Douglas Gregor | c27b287 | 2011-08-04 00:01:48 +0000 | [diff] [blame] | 947 | Data.Bases = Reader.readCXXBaseSpecifiers(F, Record, Idx); |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 948 | Data.NumVBases = Record[Idx++]; |
Douglas Gregor | d4c5ed0 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 949 | if (Data.NumVBases) |
Douglas Gregor | c27b287 | 2011-08-04 00:01:48 +0000 | [diff] [blame] | 950 | Data.VBases = Reader.readCXXBaseSpecifiers(F, Record, Idx); |
Douglas Gregor | d4c5ed0 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 951 | |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 952 | Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx); |
| 953 | Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx); |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 954 | assert(Data.Definition && "Data.Definition should be already set!"); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 955 | Data.FirstFriend = ReadDeclAs<FriendDecl>(Record, Idx); |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 956 | } |
| 957 | |
Argyrios Kyrtzidis | eb39d9a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 958 | void ASTDeclReader::InitializeCXXDefinitionData(CXXRecordDecl *D, |
| 959 | CXXRecordDecl *DefinitionDecl, |
| 960 | const RecordData &Record, |
| 961 | unsigned &Idx) { |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 962 | ASTContext &C = Reader.getContext(); |
Argyrios Kyrtzidis | a41f660 | 2010-10-20 00:11:15 +0000 | [diff] [blame] | 963 | |
Argyrios Kyrtzidis | ad5f95c | 2010-10-24 17:26:31 +0000 | [diff] [blame] | 964 | if (D == DefinitionDecl) { |
| 965 | D->DefinitionData = new (C) struct CXXRecordDecl::DefinitionData(D); |
Argyrios Kyrtzidis | eb39d9a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 966 | ReadCXXDefinitionData(*D->DefinitionData, Record, Idx); |
Argyrios Kyrtzidis | ad5f95c | 2010-10-24 17:26:31 +0000 | [diff] [blame] | 967 | // We read the definition info. Check if there are pending forward |
| 968 | // references that need to point to this DefinitionData pointer. |
| 969 | ASTReader::PendingForwardRefsMap::iterator |
| 970 | FindI = Reader.PendingForwardRefs.find(D); |
| 971 | if (FindI != Reader.PendingForwardRefs.end()) { |
| 972 | ASTReader::ForwardRefs &Refs = FindI->second; |
| 973 | for (ASTReader::ForwardRefs::iterator |
| 974 | I = Refs.begin(), E = Refs.end(); I != E; ++I) |
| 975 | (*I)->DefinitionData = D->DefinitionData; |
| 976 | #ifndef NDEBUG |
| 977 | // We later check whether PendingForwardRefs is empty to make sure all |
| 978 | // pending references were linked. |
| 979 | Reader.PendingForwardRefs.erase(D); |
| 980 | #endif |
| 981 | } |
| 982 | } else if (DefinitionDecl) { |
| 983 | if (DefinitionDecl->DefinitionData) { |
| 984 | D->DefinitionData = DefinitionDecl->DefinitionData; |
| 985 | } else { |
| 986 | // The definition is still initializing. |
| 987 | Reader.PendingForwardRefs[DefinitionDecl].push_back(D); |
| 988 | } |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 989 | } |
Argyrios Kyrtzidis | eb39d9a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) { |
| 993 | VisitRecordDecl(D); |
| 994 | |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 995 | CXXRecordDecl *DefinitionDecl = ReadDeclAs<CXXRecordDecl>(Record, Idx); |
Argyrios Kyrtzidis | eb39d9a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 996 | InitializeCXXDefinitionData(D, DefinitionDecl, Record, Idx); |
| 997 | |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 998 | ASTContext &C = Reader.getContext(); |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 999 | |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1000 | enum CXXRecKind { |
| 1001 | CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization |
| 1002 | }; |
| 1003 | switch ((CXXRecKind)Record[Idx++]) { |
| 1004 | default: |
David Blaikie | 83d382b | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 1005 | llvm_unreachable("Out of sync with ASTDeclWriter::VisitCXXRecordDecl?"); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1006 | case CXXRecNotTemplate: |
| 1007 | break; |
| 1008 | case CXXRecTemplate: |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1009 | D->TemplateOrInstantiation = ReadDeclAs<ClassTemplateDecl>(Record, Idx); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1010 | break; |
| 1011 | case CXXRecMemberSpecialization: { |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1012 | CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(Record, Idx); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1013 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1014 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | caf8248 | 2010-09-13 11:45:25 +0000 | [diff] [blame] | 1015 | MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK); |
| 1016 | MSI->setPointOfInstantiation(POI); |
| 1017 | D->TemplateOrInstantiation = MSI; |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1018 | break; |
| 1019 | } |
| 1020 | } |
Argyrios Kyrtzidis | 6843141 | 2010-10-14 20:14:38 +0000 | [diff] [blame] | 1021 | |
| 1022 | // Load the key function to avoid deserializing every method so we can |
| 1023 | // compute it. |
John McCall | f937c02 | 2011-10-07 06:10:15 +0000 | [diff] [blame] | 1024 | if (D->IsCompleteDefinition) { |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1025 | if (CXXMethodDecl *Key = ReadDeclAs<CXXMethodDecl>(Record, Idx)) |
Argyrios Kyrtzidis | 6843141 | 2010-10-14 20:14:38 +0000 | [diff] [blame] | 1026 | C.KeyFunctions[D] = Key; |
| 1027 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1030 | void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1031 | VisitFunctionDecl(D); |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 1032 | unsigned NumOverridenMethods = Record[Idx++]; |
| 1033 | while (NumOverridenMethods--) { |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 1034 | // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod, |
| 1035 | // MD may be initializing. |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1036 | if (CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>(Record, Idx)) |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1037 | Reader.getContext().addOverriddenMethod(D, MD); |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 1038 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1039 | } |
| 1040 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1041 | void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1042 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1043 | |
| 1044 | D->IsExplicitSpecified = Record[Idx++]; |
| 1045 | D->ImplicitlyDefined = Record[Idx++]; |
Alexis Hunt | 1d79265 | 2011-01-08 20:30:50 +0000 | [diff] [blame] | 1046 | llvm::tie(D->CtorInitializers, D->NumCtorInitializers) |
| 1047 | = Reader.ReadCXXCtorInitializers(F, Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1048 | } |
| 1049 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1050 | void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1051 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1052 | |
| 1053 | D->ImplicitlyDefined = Record[Idx++]; |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1054 | D->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1055 | } |
| 1056 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1057 | void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1058 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1059 | D->IsExplicitSpecified = Record[Idx++]; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1060 | } |
| 1061 | |
Douglas Gregor | ba34552 | 2011-12-02 23:23:56 +0000 | [diff] [blame^] | 1062 | void ASTDeclReader::VisitImportDecl(ImportDecl *D) { |
| 1063 | VisitDecl(D); |
| 1064 | D->ImportedAndComplete.setPointer(readModule(Record, Idx)); |
| 1065 | D->ImportedAndComplete.setInt(Record[Idx++]); |
| 1066 | SourceLocation *StoredLocs = reinterpret_cast<SourceLocation *>(D + 1); |
| 1067 | for (unsigned I = 0, N = Record.back(); I != N; ++I) |
| 1068 | StoredLocs[I] = ReadSourceLocation(Record, Idx); |
| 1069 | ++Idx; |
| 1070 | } |
| 1071 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1072 | void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) { |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1073 | VisitDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1074 | D->setColonLoc(ReadSourceLocation(Record, Idx)); |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1075 | } |
| 1076 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1077 | void ASTDeclReader::VisitFriendDecl(FriendDecl *D) { |
Argyrios Kyrtzidis | a95d019 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 1078 | VisitDecl(D); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1079 | if (Record[Idx++]) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1080 | D->Friend = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1081 | else |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1082 | D->Friend = ReadDeclAs<NamedDecl>(Record, Idx); |
Douglas Gregor | e0fb32c | 2010-10-27 20:23:41 +0000 | [diff] [blame] | 1083 | D->NextFriend = Record[Idx++]; |
John McCall | 2c2eb12 | 2010-10-16 06:59:13 +0000 | [diff] [blame] | 1084 | D->UnsupportedFriend = (Record[Idx++] != 0); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1085 | D->FriendLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1086 | } |
| 1087 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1088 | void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { |
Argyrios Kyrtzidis | 165b581 | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1089 | VisitDecl(D); |
| 1090 | unsigned NumParams = Record[Idx++]; |
| 1091 | D->NumParams = NumParams; |
| 1092 | D->Params = new TemplateParameterList*[NumParams]; |
| 1093 | for (unsigned i = 0; i != NumParams; ++i) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1094 | D->Params[i] = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 165b581 | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1095 | if (Record[Idx++]) // HasFriendDecl |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1096 | D->Friend = ReadDeclAs<NamedDecl>(Record, Idx); |
Argyrios Kyrtzidis | 165b581 | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1097 | else |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1098 | D->Friend = GetTypeSourceInfo(Record, Idx); |
| 1099 | D->FriendLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1100 | } |
| 1101 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1102 | void ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) { |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1103 | VisitNamedDecl(D); |
| 1104 | |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1105 | NamedDecl *TemplatedDecl = ReadDeclAs<NamedDecl>(Record, Idx); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1106 | TemplateParameterList* TemplateParams |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1107 | = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1108 | D->init(TemplatedDecl, TemplateParams); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1109 | } |
| 1110 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1111 | void ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1112 | // Initialize CommonOrPrev before VisitTemplateDecl so that getCommonPtr() |
| 1113 | // can be used while this is still initializing. |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1114 | |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1115 | assert(D->CommonOrPrev.isNull() && "getCommonPtr was called earlier on this"); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1116 | DeclID PreviousDeclID = ReadDeclID(Record, Idx); |
| 1117 | DeclID FirstDeclID = PreviousDeclID ? ReadDeclID(Record, Idx) : 0; |
Argyrios Kyrtzidis | 9fdd254 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1118 | // We delay loading of the redeclaration chain to avoid deeply nested calls. |
| 1119 | // We temporarily set the first (canonical) declaration as the previous one |
| 1120 | // which is the one that matters and mark the real previous DeclID to be |
| 1121 | // loaded & attached later on. |
| 1122 | RedeclarableTemplateDecl *FirstDecl = |
| 1123 | cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(FirstDeclID)); |
| 1124 | assert((FirstDecl == 0 || FirstDecl->getKind() == D->getKind()) && |
| 1125 | "FirstDecl kind mismatch"); |
| 1126 | if (FirstDecl) { |
| 1127 | D->CommonOrPrev = FirstDecl; |
| 1128 | // Mark the real previous DeclID to be loaded & attached later on. |
| 1129 | if (PreviousDeclID != FirstDeclID) |
| 1130 | Reader.PendingPreviousDecls.push_back(std::make_pair(D, PreviousDeclID)); |
| 1131 | } else { |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1132 | D->CommonOrPrev = D->newCommon(Reader.getContext()); |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1133 | if (RedeclarableTemplateDecl *RTD |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1134 | = ReadDeclAs<RedeclarableTemplateDecl>(Record, Idx)) { |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1135 | assert(RTD->getKind() == D->getKind() && |
| 1136 | "InstantiatedFromMemberTemplate kind mismatch"); |
| 1137 | D->setInstantiatedFromMemberTemplateImpl(RTD); |
| 1138 | if (Record[Idx++]) |
| 1139 | D->setMemberSpecialization(); |
| 1140 | } |
Peter Collingbourne | 2bf3d24 | 2010-07-29 16:12:01 +0000 | [diff] [blame] | 1141 | |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1142 | RedeclarableTemplateDecl *LatestDecl |
| 1143 | = ReadDeclAs<RedeclarableTemplateDecl>(Record, Idx); |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1144 | |
| 1145 | // This decl is a first one and the latest declaration that it points to is |
Sebastian Redl | d44cd6a | 2010-08-18 23:57:06 +0000 | [diff] [blame] | 1146 | // in the same AST file. However, if this actually needs to point to a |
| 1147 | // redeclaration in another AST file, we need to update it by checking |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1148 | // the FirstLatestDeclIDs map which tracks this kind of decls. |
| 1149 | assert(Reader.GetDecl(ThisDeclID) == D && "Invalid ThisDeclID ?"); |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1150 | ASTReader::FirstLatestDeclIDMap::iterator I |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1151 | = Reader.FirstLatestDeclIDs.find(ThisDeclID); |
| 1152 | if (I != Reader.FirstLatestDeclIDs.end()) { |
Douglas Gregor | aa7cbfd | 2011-08-25 15:28:26 +0000 | [diff] [blame] | 1153 | if (Decl *NewLatest = Reader.GetDecl(I->second)) |
| 1154 | LatestDecl = cast<RedeclarableTemplateDecl>(NewLatest); |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1155 | } |
| 1156 | |
Peter Collingbourne | 2bf3d24 | 2010-07-29 16:12:01 +0000 | [diff] [blame] | 1157 | assert(LatestDecl->getKind() == D->getKind() && "Latest kind mismatch"); |
| 1158 | D->getCommonPtr()->Latest = LatestDecl; |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1159 | } |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1160 | |
| 1161 | VisitTemplateDecl(D); |
| 1162 | D->IdentifierNamespace = Record[Idx++]; |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1165 | void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1166 | VisitRedeclarableTemplateDecl(D); |
| 1167 | |
| 1168 | if (D->getPreviousDeclaration() == 0) { |
Douglas Gregor | 7e8c4e0 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1169 | // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of |
| 1170 | // the specializations. |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 1171 | SmallVector<serialization::DeclID, 2> SpecIDs; |
Douglas Gregor | 7e8c4e0 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1172 | SpecIDs.push_back(0); |
| 1173 | |
| 1174 | // Specializations. |
| 1175 | unsigned Size = Record[Idx++]; |
| 1176 | SpecIDs[0] += Size; |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1177 | for (unsigned I = 0; I != Size; ++I) |
| 1178 | SpecIDs.push_back(ReadDeclID(Record, Idx)); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1179 | |
Douglas Gregor | 7e8c4e0 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1180 | // Partial specializations. |
| 1181 | Size = Record[Idx++]; |
| 1182 | SpecIDs[0] += Size; |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1183 | for (unsigned I = 0; I != Size; ++I) |
| 1184 | SpecIDs.push_back(ReadDeclID(Record, Idx)); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1185 | |
Douglas Gregor | 7e8c4e0 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1186 | if (SpecIDs[0]) { |
| 1187 | typedef serialization::DeclID DeclID; |
| 1188 | |
| 1189 | ClassTemplateDecl::Common *CommonPtr = D->getCommonPtr(); |
| 1190 | CommonPtr->LazySpecializations |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1191 | = new (Reader.getContext()) DeclID [SpecIDs.size()]; |
Douglas Gregor | 7e8c4e0 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1192 | memcpy(CommonPtr->LazySpecializations, SpecIDs.data(), |
| 1193 | SpecIDs.size() * sizeof(DeclID)); |
| 1194 | } |
| 1195 | |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1196 | // InjectedClassNameType is computed. |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1197 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1198 | } |
| 1199 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1200 | void ASTDeclReader::VisitClassTemplateSpecializationDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1201 | ClassTemplateSpecializationDecl *D) { |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1202 | VisitCXXRecordDecl(D); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1203 | |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1204 | ASTContext &C = Reader.getContext(); |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1205 | if (Decl *InstD = ReadDecl(Record, Idx)) { |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1206 | if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) { |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1207 | D->SpecializedTemplate = CTD; |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1208 | } else { |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 1209 | SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1210 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1211 | TemplateArgumentList *ArgList |
Douglas Gregor | 1ccc841 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 1212 | = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), |
| 1213 | TemplArgs.size()); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1214 | ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS |
| 1215 | = new (C) ClassTemplateSpecializationDecl:: |
| 1216 | SpecializedPartialSpecialization(); |
| 1217 | PS->PartialSpecialization |
| 1218 | = cast<ClassTemplatePartialSpecializationDecl>(InstD); |
| 1219 | PS->TemplateArgs = ArgList; |
| 1220 | D->SpecializedTemplate = PS; |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | // Explicit info. |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1225 | if (TypeSourceInfo *TyInfo = GetTypeSourceInfo(Record, Idx)) { |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1226 | ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo |
| 1227 | = new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo; |
| 1228 | ExplicitInfo->TypeAsWritten = TyInfo; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1229 | ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx); |
| 1230 | ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1231 | D->ExplicitInfo = ExplicitInfo; |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1232 | } |
| 1233 | |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 1234 | SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1235 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Douglas Gregor | 1ccc841 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 1236 | D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), |
| 1237 | TemplArgs.size()); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1238 | D->PointOfInstantiation = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1239 | D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++]; |
Douglas Gregor | 7e8c4e0 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1240 | |
Argyrios Kyrtzidis | c1624e9 | 2010-07-20 13:59:40 +0000 | [diff] [blame] | 1241 | if (D->isCanonicalDecl()) { // It's kept in the folding set. |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1242 | ClassTemplateDecl *CanonPattern = ReadDeclAs<ClassTemplateDecl>(Record,Idx); |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1243 | if (ClassTemplatePartialSpecializationDecl *Partial |
Douglas Gregor | 7e8c4e0 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1244 | = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) { |
| 1245 | CanonPattern->getCommonPtr()->PartialSpecializations.InsertNode(Partial); |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1246 | } else { |
Douglas Gregor | 7e8c4e0 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1247 | CanonPattern->getCommonPtr()->Specializations.InsertNode(D); |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1248 | } |
| 1249 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1250 | } |
| 1251 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1252 | void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1253 | ClassTemplatePartialSpecializationDecl *D) { |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1254 | VisitClassTemplateSpecializationDecl(D); |
| 1255 | |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1256 | ASTContext &C = Reader.getContext(); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1257 | D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1258 | |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1259 | unsigned NumArgs = Record[Idx++]; |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1260 | if (NumArgs) { |
| 1261 | D->NumArgsAsWritten = NumArgs; |
| 1262 | D->ArgsAsWritten = new (C) TemplateArgumentLoc[NumArgs]; |
| 1263 | for (unsigned i=0; i != NumArgs; ++i) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1264 | D->ArgsAsWritten[i] = Reader.ReadTemplateArgumentLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1265 | } |
| 1266 | |
| 1267 | D->SequenceNumber = Record[Idx++]; |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1268 | |
| 1269 | // These are read/set from/to the first declaration. |
| 1270 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1271 | D->InstantiatedFromMember.setPointer( |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1272 | ReadDeclAs<ClassTemplatePartialSpecializationDecl>(Record, Idx)); |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1273 | D->InstantiatedFromMember.setInt(Record[Idx++]); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1274 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
Sebastian Redl | b744863 | 2011-08-31 13:59:56 +0000 | [diff] [blame] | 1277 | void ASTDeclReader::VisitClassScopeFunctionSpecializationDecl( |
| 1278 | ClassScopeFunctionSpecializationDecl *D) { |
Francois Pichet | 09af8c3 | 2011-08-17 01:06:54 +0000 | [diff] [blame] | 1279 | VisitDecl(D); |
| 1280 | D->Specialization = ReadDeclAs<CXXMethodDecl>(Record, Idx); |
| 1281 | } |
| 1282 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1283 | void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1284 | VisitRedeclarableTemplateDecl(D); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1285 | |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1286 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1287 | // This FunctionTemplateDecl owns a CommonPtr; read it. |
| 1288 | |
Argyrios Kyrtzidis | 39fdf81 | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1289 | // Read the function specialization declarations. |
| 1290 | // FunctionTemplateDecl's FunctionTemplateSpecializationInfos are filled |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 1291 | // when reading the specialized FunctionDecl. |
Argyrios Kyrtzidis | 39fdf81 | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1292 | unsigned NumSpecs = Record[Idx++]; |
| 1293 | while (NumSpecs--) |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1294 | (void)ReadDecl(Record, Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1295 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1296 | } |
| 1297 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1298 | void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1299 | VisitTypeDecl(D); |
| 1300 | |
| 1301 | D->setDeclaredWithTypename(Record[Idx++]); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1302 | |
| 1303 | bool Inherited = Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1304 | TypeSourceInfo *DefArg = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1305 | D->setDefaultArgument(DefArg, Inherited); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1306 | } |
| 1307 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1308 | void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { |
John McCall | f4cd4f9 | 2011-02-09 01:13:10 +0000 | [diff] [blame] | 1309 | VisitDeclaratorDecl(D); |
Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1310 | // TemplateParmPosition. |
| 1311 | D->setDepth(Record[Idx++]); |
| 1312 | D->setPosition(Record[Idx++]); |
Douglas Gregor | 0231d8d | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1313 | if (D->isExpandedParameterPack()) { |
| 1314 | void **Data = reinterpret_cast<void **>(D + 1); |
| 1315 | for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) { |
Douglas Gregor | 903b7e9 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 1316 | Data[2*I] = Reader.readType(F, Record, Idx).getAsOpaquePtr(); |
Douglas Gregor | 0231d8d | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1317 | Data[2*I + 1] = GetTypeSourceInfo(Record, Idx); |
| 1318 | } |
| 1319 | } else { |
| 1320 | // Rest of NonTypeTemplateParmDecl. |
| 1321 | D->ParameterPack = Record[Idx++]; |
| 1322 | if (Record[Idx++]) { |
| 1323 | Expr *DefArg = Reader.ReadExpr(F); |
| 1324 | bool Inherited = Record[Idx++]; |
| 1325 | D->setDefaultArgument(DefArg, Inherited); |
| 1326 | } |
| 1327 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1328 | } |
| 1329 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1330 | void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { |
Argyrios Kyrtzidis | 9f2d24a | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1331 | VisitTemplateDecl(D); |
| 1332 | // TemplateParmPosition. |
| 1333 | D->setDepth(Record[Idx++]); |
| 1334 | D->setPosition(Record[Idx++]); |
| 1335 | // Rest of TemplateTemplateParmDecl. |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1336 | TemplateArgumentLoc Arg = Reader.ReadTemplateArgumentLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 9f2d24a | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1337 | bool IsInherited = Record[Idx++]; |
| 1338 | D->setDefaultArgument(Arg, IsInherited); |
Douglas Gregor | f550077 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1339 | D->ParameterPack = Record[Idx++]; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1340 | } |
| 1341 | |
Richard Smith | 3f1b5d0 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1342 | void ASTDeclReader::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { |
| 1343 | VisitRedeclarableTemplateDecl(D); |
| 1344 | } |
| 1345 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1346 | void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) { |
Argyrios Kyrtzidis | 2d8891c | 2010-07-22 17:28:12 +0000 | [diff] [blame] | 1347 | VisitDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1348 | D->AssertExpr = Reader.ReadExpr(F); |
| 1349 | D->Message = cast<StringLiteral>(Reader.ReadExpr(F)); |
Abramo Bagnara | ea94788 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 1350 | D->RParenLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1351 | } |
| 1352 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1353 | std::pair<uint64_t, uint64_t> |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1354 | ASTDeclReader::VisitDeclContext(DeclContext *DC) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1355 | uint64_t LexicalOffset = Record[Idx++]; |
| 1356 | uint64_t VisibleOffset = Record[Idx++]; |
| 1357 | return std::make_pair(LexicalOffset, VisibleOffset); |
| 1358 | } |
| 1359 | |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1360 | template <typename T> |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1361 | void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1362 | enum RedeclKind { NoRedeclaration = 0, PointsToPrevious, PointsToLatest }; |
| 1363 | RedeclKind Kind = (RedeclKind)Record[Idx++]; |
| 1364 | switch (Kind) { |
| 1365 | default: |
David Blaikie | 83d382b | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 1366 | llvm_unreachable("Out of sync with ASTDeclWriter::VisitRedeclarable or" |
| 1367 | " messed up reading"); |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1368 | case NoRedeclaration: |
| 1369 | break; |
Argyrios Kyrtzidis | 9fdd254 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1370 | case PointsToPrevious: { |
Douglas Gregor | 7fb0919 | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1371 | DeclID PreviousDeclID = ReadDeclID(Record, Idx); |
| 1372 | DeclID FirstDeclID = ReadDeclID(Record, Idx); |
Argyrios Kyrtzidis | 9fdd254 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1373 | // We delay loading of the redeclaration chain to avoid deeply nested calls. |
| 1374 | // We temporarily set the first (canonical) declaration as the previous one |
| 1375 | // which is the one that matters and mark the real previous DeclID to be |
| 1376 | // loaded & attached later on. |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1377 | T *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID)); |
| 1378 | D->RedeclLink = typename Redeclarable<T>::PreviousDeclLink(FirstDecl); |
Argyrios Kyrtzidis | 9fdd254 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1379 | if (PreviousDeclID != FirstDeclID) |
| 1380 | Reader.PendingPreviousDecls.push_back(std::make_pair(static_cast<T*>(D), |
| 1381 | PreviousDeclID)); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1382 | |
| 1383 | // If the first declaration in the chain is in an inconsistent |
| 1384 | // state where it thinks that it is the only declaration, fix its |
| 1385 | // redeclaration link now to point at this declaration, so that we have a |
| 1386 | // proper redeclaration chain. |
| 1387 | if (FirstDecl->RedeclLink.getPointer() == FirstDecl) { |
| 1388 | FirstDecl->RedeclLink |
| 1389 | = typename Redeclarable<T>::LatestDeclLink(static_cast<T*>(D)); |
| 1390 | } |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1391 | break; |
Argyrios Kyrtzidis | 9fdd254 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1392 | } |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1393 | case PointsToLatest: { |
| 1394 | T *LatestDecl = ReadDeclAs<T>(Record, Idx); |
| 1395 | D->RedeclLink = typename Redeclarable<T>::LatestDeclLink(LatestDecl); |
| 1396 | |
| 1397 | // If the latest declaration in the chain is in an inconsistent |
| 1398 | // state where it thinks that it is the only declaration, fix its |
| 1399 | // redeclaration link now to point at this declaration, so that we have a |
| 1400 | // proper redeclaration chain. |
| 1401 | if (LatestDecl->RedeclLink.getPointer() == LatestDecl) { |
| 1402 | LatestDecl->RedeclLink |
| 1403 | = typename Redeclarable<T>::PreviousDeclLink(static_cast<T*>(D)); |
| 1404 | } |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1405 | break; |
| 1406 | } |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1407 | } |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1408 | |
| 1409 | assert(!(Kind == PointsToPrevious && |
| 1410 | Reader.FirstLatestDeclIDs.find(ThisDeclID) != |
| 1411 | Reader.FirstLatestDeclIDs.end()) && |
| 1412 | "This decl is not first, it should not be in the map"); |
| 1413 | if (Kind == PointsToPrevious) |
| 1414 | return; |
| 1415 | |
| 1416 | // This decl is a first one and the latest declaration that it points to is in |
Sebastian Redl | d44cd6a | 2010-08-18 23:57:06 +0000 | [diff] [blame] | 1417 | // the same AST file. However, if this actually needs to point to a |
| 1418 | // redeclaration in another AST file, we need to update it by checking the |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1419 | // FirstLatestDeclIDs map which tracks this kind of decls. |
| 1420 | assert(Reader.GetDecl(ThisDeclID) == static_cast<T*>(D) && |
| 1421 | "Invalid ThisDeclID ?"); |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1422 | ASTReader::FirstLatestDeclIDMap::iterator I |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1423 | = Reader.FirstLatestDeclIDs.find(ThisDeclID); |
| 1424 | if (I != Reader.FirstLatestDeclIDs.end()) { |
| 1425 | Decl *NewLatest = Reader.GetDecl(I->second); |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1426 | D->RedeclLink |
| 1427 | = typename Redeclarable<T>::LatestDeclLink(cast_or_null<T>(NewLatest)); |
| 1428 | } |
| 1429 | } |
| 1430 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1431 | //===----------------------------------------------------------------------===// |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1432 | // Attribute Reading |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1433 | //===----------------------------------------------------------------------===// |
| 1434 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1435 | /// \brief Reads attributes from the current stream position. |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1436 | void ASTReader::ReadAttributes(ModuleFile &F, AttrVec &Attrs, |
Argyrios Kyrtzidis | 9beef8e | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 1437 | const RecordData &Record, unsigned &Idx) { |
| 1438 | for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) { |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1439 | Attr *New = 0; |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1440 | attr::Kind Kind = (attr::Kind)Record[Idx++]; |
Argyrios Kyrtzidis | 309b4c4 | 2011-09-13 16:05:58 +0000 | [diff] [blame] | 1441 | SourceRange Range = ReadSourceRange(F, Record, Idx); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1442 | |
Alexis Hunt | dcfba7b | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 1443 | #include "clang/Serialization/AttrPCHRead.inc" |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1444 | |
| 1445 | assert(New && "Unable to decode attribute?"); |
Alexis Hunt | dcfba7b | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 1446 | Attrs.push_back(New); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1447 | } |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1448 | } |
| 1449 | |
| 1450 | //===----------------------------------------------------------------------===// |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1451 | // ASTReader Implementation |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1452 | //===----------------------------------------------------------------------===// |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1453 | |
| 1454 | /// \brief Note that we have loaded the declaration with the given |
| 1455 | /// Index. |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1456 | /// |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1457 | /// This routine notes that this declaration has already been loaded, |
| 1458 | /// so that future GetDecl calls will return this declaration rather |
| 1459 | /// than trying to load a new declaration. |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1460 | inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1461 | assert(!DeclsLoaded[Index] && "Decl loaded twice?"); |
| 1462 | DeclsLoaded[Index] = D; |
| 1463 | } |
| 1464 | |
| 1465 | |
| 1466 | /// \brief Determine whether the consumer will be interested in seeing |
| 1467 | /// this declaration (via HandleTopLevelDecl). |
| 1468 | /// |
| 1469 | /// This routine should return true for anything that might affect |
| 1470 | /// code generation, e.g., inline function definitions, Objective-C |
| 1471 | /// declarations with metadata, etc. |
| 1472 | static bool isConsumerInterestedIn(Decl *D) { |
Argyrios Kyrtzidis | a98e861 | 2011-09-13 21:35:00 +0000 | [diff] [blame] | 1473 | // An ObjCMethodDecl is never considered as "interesting" because its |
| 1474 | // implementation container always is. |
| 1475 | |
Douglas Gregor | 87d8124 | 2011-09-10 00:22:34 +0000 | [diff] [blame] | 1476 | if (isa<FileScopeAsmDecl>(D) || |
| 1477 | isa<ObjCProtocolDecl>(D) || |
| 1478 | isa<ObjCImplDecl>(D)) |
Daniel Dunbar | 865c2a7 | 2009-09-17 03:06:44 +0000 | [diff] [blame] | 1479 | return true; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1480 | if (VarDecl *Var = dyn_cast<VarDecl>(D)) |
Argyrios Kyrtzidis | 4ba81b2 | 2010-08-05 09:47:59 +0000 | [diff] [blame] | 1481 | return Var->isFileVarDecl() && |
| 1482 | Var->isThisDeclarationADefinition() == VarDecl::Definition; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1483 | if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D)) |
Alexis Hunt | 4a8ea10 | 2011-05-06 20:44:56 +0000 | [diff] [blame] | 1484 | return Func->doesThisDeclarationHaveABody(); |
Douglas Gregor | 87d8124 | 2011-09-10 00:22:34 +0000 | [diff] [blame] | 1485 | |
| 1486 | return false; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1487 | } |
| 1488 | |
Douglas Gregor | 047d2ef | 2011-07-20 00:27:43 +0000 | [diff] [blame] | 1489 | /// \brief Get the correct cursor and offset for loading a declaration. |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1490 | ASTReader::RecordLocation |
Argyrios Kyrtzidis | 81ddd18 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 1491 | ASTReader::DeclCursorForID(DeclID ID, unsigned &RawLocation) { |
Sebastian Redl | e7c1fe6 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1492 | // See if there's an override. |
| 1493 | DeclReplacementMap::iterator It = ReplacedDecls.find(ID); |
Argyrios Kyrtzidis | 6fb6003 | 2011-10-31 07:20:15 +0000 | [diff] [blame] | 1494 | if (It != ReplacedDecls.end()) { |
| 1495 | RawLocation = It->second.RawLoc; |
| 1496 | return RecordLocation(It->second.Mod, It->second.Offset); |
| 1497 | } |
Sebastian Redl | e7c1fe6 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1498 | |
Douglas Gregor | 047d2ef | 2011-07-20 00:27:43 +0000 | [diff] [blame] | 1499 | GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID); |
| 1500 | assert(I != GlobalDeclMap.end() && "Corrupted global declaration map"); |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1501 | ModuleFile *M = I->second; |
Argyrios Kyrtzidis | 81ddd18 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 1502 | const DeclOffset & |
| 1503 | DOffs = M->DeclOffsets[ID - M->BaseDeclID - NUM_PREDEF_DECL_IDS]; |
| 1504 | RawLocation = DOffs.Loc; |
| 1505 | return RecordLocation(M, DOffs.BitOffset); |
Sebastian Redl | 3462779 | 2010-07-20 22:46:15 +0000 | [diff] [blame] | 1506 | } |
| 1507 | |
Douglas Gregor | d32f035 | 2011-07-22 06:10:01 +0000 | [diff] [blame] | 1508 | ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) { |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1509 | ContinuousRangeMap<uint64_t, ModuleFile*, 4>::iterator I |
Douglas Gregor | d32f035 | 2011-07-22 06:10:01 +0000 | [diff] [blame] | 1510 | = GlobalBitOffsetsMap.find(GlobalOffset); |
| 1511 | |
| 1512 | assert(I != GlobalBitOffsetsMap.end() && "Corrupted global bit offsets map"); |
| 1513 | return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset); |
| 1514 | } |
| 1515 | |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1516 | uint64_t ASTReader::getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset) { |
Douglas Gregor | c27b287 | 2011-08-04 00:01:48 +0000 | [diff] [blame] | 1517 | return LocalOffset + M.GlobalBitOffset; |
| 1518 | } |
| 1519 | |
Argyrios Kyrtzidis | 9fdd254 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1520 | void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *previous) { |
| 1521 | assert(D && previous); |
| 1522 | if (TagDecl *TD = dyn_cast<TagDecl>(D)) { |
| 1523 | TD->RedeclLink.setPointer(cast<TagDecl>(previous)); |
| 1524 | } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
| 1525 | FD->RedeclLink.setPointer(cast<FunctionDecl>(previous)); |
| 1526 | } else if (VarDecl *VD = dyn_cast<VarDecl>(D)) { |
| 1527 | VD->RedeclLink.setPointer(cast<VarDecl>(previous)); |
| 1528 | } else { |
| 1529 | RedeclarableTemplateDecl *TD = cast<RedeclarableTemplateDecl>(D); |
| 1530 | TD->CommonOrPrev = cast<RedeclarableTemplateDecl>(previous); |
| 1531 | } |
| 1532 | } |
| 1533 | |
| 1534 | void ASTReader::loadAndAttachPreviousDecl(Decl *D, serialization::DeclID ID) { |
| 1535 | Decl *previous = GetDecl(ID); |
| 1536 | ASTDeclReader::attachPreviousDecl(D, previous); |
| 1537 | } |
| 1538 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1539 | /// \brief Read the declaration at the given offset from the AST file. |
Douglas Gregor | f718062 | 2011-08-03 15:48:04 +0000 | [diff] [blame] | 1540 | Decl *ASTReader::ReadDeclRecord(DeclID ID) { |
Douglas Gregor | dab4243 | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 1541 | unsigned Index = ID - NUM_PREDEF_DECL_IDS; |
Argyrios Kyrtzidis | 81ddd18 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 1542 | unsigned RawLocation = 0; |
| 1543 | RecordLocation Loc = DeclCursorForID(ID, RawLocation); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1544 | llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1545 | // Keep track of where we are in the stream, then jump back there |
| 1546 | // after reading this declaration. |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1547 | SavedStreamPosition SavedPosition(DeclsCursor); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1548 | |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1549 | ReadingKindTracker ReadingKind(Read_Decl, *this); |
| 1550 | |
Douglas Gregor | 1342e84 | 2009-07-06 18:54:52 +0000 | [diff] [blame] | 1551 | // Note that we are loading a declaration record. |
Argyrios Kyrtzidis | b24355a | 2010-07-30 10:03:16 +0000 | [diff] [blame] | 1552 | Deserializing ADecl(this); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1553 | |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1554 | DeclsCursor.JumpToBit(Loc.Offset); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1555 | RecordData Record; |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1556 | unsigned Code = DeclsCursor.ReadCode(); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1557 | unsigned Idx = 0; |
Argyrios Kyrtzidis | 81ddd18 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 1558 | ASTDeclReader Reader(*this, *Loc.F, DeclsCursor, ID, RawLocation, Record,Idx); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1559 | |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1560 | Decl *D = 0; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1561 | switch ((DeclCode)DeclsCursor.ReadRecord(Code, Record)) { |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1562 | case DECL_CONTEXT_LEXICAL: |
| 1563 | case DECL_CONTEXT_VISIBLE: |
David Blaikie | 83d382b | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 1564 | llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord"); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1565 | case DECL_TYPEDEF: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1566 | D = TypedefDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Abramo Bagnara | b3185b0 | 2011-03-06 15:48:19 +0000 | [diff] [blame] | 1567 | 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1568 | break; |
Richard Smith | dda56e4 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 1569 | case DECL_TYPEALIAS: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1570 | D = TypeAliasDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Richard Smith | dda56e4 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 1571 | 0, 0); |
| 1572 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1573 | case DECL_ENUM: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1574 | D = EnumDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1575 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1576 | case DECL_RECORD: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1577 | D = RecordDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1578 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1579 | case DECL_ENUM_CONSTANT: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1580 | D = EnumConstantDecl::Create(Context, 0, SourceLocation(), 0, QualType(), |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1581 | 0, llvm::APSInt()); |
| 1582 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1583 | case DECL_FUNCTION: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1584 | D = FunctionDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Abramo Bagnara | dff1930 | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1585 | DeclarationName(), QualType(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1586 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1587 | case DECL_LINKAGE_SPEC: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1588 | D = LinkageSpecDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1589 | (LinkageSpecDecl::LanguageIDs)0, |
Abramo Bagnara | 66a35d7 | 2011-03-03 16:52:29 +0000 | [diff] [blame] | 1590 | SourceLocation()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1591 | break; |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 1592 | case DECL_LABEL: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1593 | D = LabelDecl::Create(Context, 0, SourceLocation(), 0); |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 1594 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1595 | case DECL_NAMESPACE: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1596 | D = NamespaceDecl::Create(Context, 0, SourceLocation(), |
Abramo Bagnara | b5545be | 2011-03-08 12:38:20 +0000 | [diff] [blame] | 1597 | SourceLocation(), 0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1598 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1599 | case DECL_NAMESPACE_ALIAS: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1600 | D = NamespaceAliasDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | c05ba2e | 2011-02-25 17:08:07 +0000 | [diff] [blame] | 1601 | SourceLocation(), 0, |
| 1602 | NestedNameSpecifierLoc(), |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1603 | SourceLocation(), 0); |
| 1604 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1605 | case DECL_USING: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1606 | D = UsingDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | a9d87bc | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1607 | NestedNameSpecifierLoc(), DeclarationNameInfo(), |
| 1608 | false); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1609 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1610 | case DECL_USING_SHADOW: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1611 | D = UsingShadowDecl::Create(Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1612 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1613 | case DECL_USING_DIRECTIVE: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1614 | D = UsingDirectiveDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | 12441b3 | 2011-02-25 16:33:46 +0000 | [diff] [blame] | 1615 | SourceLocation(), NestedNameSpecifierLoc(), |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1616 | SourceLocation(), 0, 0); |
| 1617 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1618 | case DECL_UNRESOLVED_USING_VALUE: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1619 | D = UnresolvedUsingValueDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | a9d87bc | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1620 | NestedNameSpecifierLoc(), |
Abramo Bagnara | 8de74e9 | 2010-08-12 11:46:03 +0000 | [diff] [blame] | 1621 | DeclarationNameInfo()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1622 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1623 | case DECL_UNRESOLVED_USING_TYPENAME: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1624 | D = UnresolvedUsingTypenameDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | a9d87bc | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1625 | SourceLocation(), |
| 1626 | NestedNameSpecifierLoc(), |
| 1627 | SourceLocation(), |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1628 | DeclarationName()); |
| 1629 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1630 | case DECL_CXX_RECORD: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1631 | D = CXXRecordDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1632 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1633 | case DECL_CXX_METHOD: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1634 | D = CXXMethodDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | f2f0806 | 2011-03-08 17:10:18 +0000 | [diff] [blame] | 1635 | DeclarationNameInfo(), QualType(), 0, |
Richard Smith | a77a0a6 | 2011-08-15 21:04:07 +0000 | [diff] [blame] | 1636 | false, SC_None, false, false, SourceLocation()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1637 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1638 | case DECL_CXX_CONSTRUCTOR: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1639 | D = CXXConstructorDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1640 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1641 | case DECL_CXX_DESTRUCTOR: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1642 | D = CXXDestructorDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1643 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1644 | case DECL_CXX_CONVERSION: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1645 | D = CXXConversionDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1646 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1647 | case DECL_ACCESS_SPEC: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1648 | D = AccessSpecDecl::Create(Context, Decl::EmptyShell()); |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1649 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1650 | case DECL_FRIEND: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1651 | D = FriendDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1652 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1653 | case DECL_FRIEND_TEMPLATE: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1654 | D = FriendTemplateDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1655 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1656 | case DECL_CLASS_TEMPLATE: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1657 | D = ClassTemplateDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1658 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1659 | case DECL_CLASS_TEMPLATE_SPECIALIZATION: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1660 | D = ClassTemplateSpecializationDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1661 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1662 | case DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1663 | D = ClassTemplatePartialSpecializationDecl::Create(Context, |
Douglas Gregor | fd7c225 | 2011-03-04 17:52:15 +0000 | [diff] [blame] | 1664 | Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1665 | break; |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 1666 | case DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1667 | D = ClassScopeFunctionSpecializationDecl::Create(Context, |
Francois Pichet | 00c7e6c | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 1668 | Decl::EmptyShell()); |
| 1669 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1670 | case DECL_FUNCTION_TEMPLATE: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1671 | D = FunctionTemplateDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1672 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1673 | case DECL_TEMPLATE_TYPE_PARM: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1674 | D = TemplateTypeParmDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1675 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1676 | case DECL_NON_TYPE_TEMPLATE_PARM: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1677 | D = NonTypeTemplateParmDecl::Create(Context, 0, SourceLocation(), |
Abramo Bagnara | dff1930 | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1678 | SourceLocation(), 0, 0, 0, QualType(), |
| 1679 | false, 0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1680 | break; |
Douglas Gregor | 0231d8d | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1681 | case DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1682 | D = NonTypeTemplateParmDecl::Create(Context, 0, SourceLocation(), |
Abramo Bagnara | dff1930 | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1683 | SourceLocation(), 0, 0, 0, QualType(), |
| 1684 | 0, 0, Record[Idx++], 0); |
Douglas Gregor | 0231d8d | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1685 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1686 | case DECL_TEMPLATE_TEMPLATE_PARM: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1687 | D = TemplateTemplateParmDecl::Create(Context, 0, SourceLocation(), 0, 0, |
Douglas Gregor | f550077 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1688 | false, 0, 0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1689 | break; |
Richard Smith | 3f1b5d0 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1690 | case DECL_TYPE_ALIAS_TEMPLATE: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1691 | D = TypeAliasTemplateDecl::Create(Context, Decl::EmptyShell()); |
Richard Smith | 3f1b5d0 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1692 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1693 | case DECL_STATIC_ASSERT: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1694 | D = StaticAssertDecl::Create(Context, 0, SourceLocation(), 0, 0, |
Abramo Bagnara | ea94788 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 1695 | SourceLocation()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1696 | break; |
| 1697 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1698 | case DECL_OBJC_METHOD: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1699 | D = ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(), |
Douglas Gregor | 12852d9 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 1700 | Selector(), QualType(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1701 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1702 | case DECL_OBJC_INTERFACE: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1703 | D = ObjCInterfaceDecl::Create(Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1704 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1705 | case DECL_OBJC_IVAR: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1706 | D = ObjCIvarDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Abramo Bagnara | dff1930 | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1707 | 0, QualType(), 0, ObjCIvarDecl::None); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1708 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1709 | case DECL_OBJC_PROTOCOL: |
Argyrios Kyrtzidis | 52f53fb | 2011-10-04 04:48:02 +0000 | [diff] [blame] | 1710 | D = ObjCProtocolDecl::Create(Context, 0, 0, SourceLocation(), |
Argyrios Kyrtzidis | 1f4bee5 | 2011-10-17 19:48:06 +0000 | [diff] [blame] | 1711 | SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1712 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1713 | case DECL_OBJC_AT_DEFS_FIELD: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1714 | D = ObjCAtDefsFieldDecl::Create(Context, 0, SourceLocation(), |
Abramo Bagnara | dff1930 | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1715 | SourceLocation(), 0, QualType(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1716 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1717 | case DECL_OBJC_CLASS: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1718 | D = ObjCClassDecl::Create(Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1719 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1720 | case DECL_OBJC_FORWARD_PROTOCOL: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1721 | D = ObjCForwardProtocolDecl::Create(Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1722 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1723 | case DECL_OBJC_CATEGORY: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1724 | D = ObjCCategoryDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1725 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1726 | case DECL_OBJC_CATEGORY_IMPL: |
Argyrios Kyrtzidis | 52f53fb | 2011-10-04 04:48:02 +0000 | [diff] [blame] | 1727 | D = ObjCCategoryImplDecl::Create(Context, 0, 0, 0, SourceLocation(), |
| 1728 | SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1729 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1730 | case DECL_OBJC_IMPLEMENTATION: |
Argyrios Kyrtzidis | 52f53fb | 2011-10-04 04:48:02 +0000 | [diff] [blame] | 1731 | D = ObjCImplementationDecl::Create(Context, 0, 0, 0, SourceLocation(), |
| 1732 | SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1733 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1734 | case DECL_OBJC_COMPATIBLE_ALIAS: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1735 | D = ObjCCompatibleAliasDecl::Create(Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1736 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1737 | case DECL_OBJC_PROPERTY: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1738 | D = ObjCPropertyDecl::Create(Context, 0, SourceLocation(), 0, SourceLocation(), |
John McCall | 339bb66 | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 1739 | 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1740 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1741 | case DECL_OBJC_PROPERTY_IMPL: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1742 | D = ObjCPropertyImplDecl::Create(Context, 0, SourceLocation(), |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1743 | SourceLocation(), 0, |
Douglas Gregor | b1b71e5 | 2010-11-17 01:03:52 +0000 | [diff] [blame] | 1744 | ObjCPropertyImplDecl::Dynamic, 0, |
| 1745 | SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1746 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1747 | case DECL_FIELD: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1748 | D = FieldDecl::Create(Context, 0, SourceLocation(), SourceLocation(), 0, |
Richard Smith | 938f40b | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 1749 | QualType(), 0, 0, false, false); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1750 | break; |
Francois Pichet | 783dd6e | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 1751 | case DECL_INDIRECTFIELD: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1752 | D = IndirectFieldDecl::Create(Context, 0, SourceLocation(), 0, QualType(), |
Francois Pichet | 783dd6e | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 1753 | 0, 0); |
| 1754 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1755 | case DECL_VAR: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1756 | D = VarDecl::Create(Context, 0, SourceLocation(), SourceLocation(), 0, |
Abramo Bagnara | dff1930 | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1757 | QualType(), 0, SC_None, SC_None); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1758 | break; |
| 1759 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1760 | case DECL_IMPLICIT_PARAM: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1761 | D = ImplicitParamDecl::Create(Context, 0, SourceLocation(), 0, QualType()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1762 | break; |
| 1763 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1764 | case DECL_PARM_VAR: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1765 | D = ParmVarDecl::Create(Context, 0, SourceLocation(), SourceLocation(), 0, |
Abramo Bagnara | dff1930 | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1766 | QualType(), 0, SC_None, SC_None, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1767 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1768 | case DECL_FILE_SCOPE_ASM: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1769 | D = FileScopeAsmDecl::Create(Context, 0, 0, SourceLocation(), |
Abramo Bagnara | 348823a | 2011-03-03 14:20:18 +0000 | [diff] [blame] | 1770 | SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1771 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1772 | case DECL_BLOCK: |
Douglas Gregor | 4163aca | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1773 | D = BlockDecl::Create(Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1774 | break; |
Douglas Gregor | d4c5ed0 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 1775 | case DECL_CXX_BASE_SPECIFIERS: |
| 1776 | Error("attempt to read a C++ base-specifier record as a declaration"); |
| 1777 | return 0; |
Douglas Gregor | ba34552 | 2011-12-02 23:23:56 +0000 | [diff] [blame^] | 1778 | case DECL_IMPORT: |
| 1779 | // Note: last entry of the ImportDecl record is the number of stored source |
| 1780 | // locations. |
| 1781 | D = ImportDecl::CreateEmpty(Context, Record.back()); |
| 1782 | break; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1783 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1784 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1785 | assert(D && "Unknown declaration reading AST file"); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1786 | LoadedDecl(Index, D); |
| 1787 | Reader.Visit(D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1788 | |
| 1789 | // If this declaration is also a declaration context, get the |
| 1790 | // offsets for its tables of lexical and visible declarations. |
| 1791 | if (DeclContext *DC = dyn_cast<DeclContext>(D)) { |
| 1792 | std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC); |
| 1793 | if (Offsets.first || Offsets.second) { |
Douglas Gregor | 94619c8 | 2011-08-24 19:03:07 +0000 | [diff] [blame] | 1794 | if (Offsets.first != 0) |
| 1795 | DC->setHasExternalLexicalStorage(true); |
| 1796 | if (Offsets.second != 0) |
| 1797 | DC->setHasExternalVisibleStorage(true); |
| 1798 | if (ReadDeclContextStorage(*Loc.F, DeclsCursor, Offsets, |
| 1799 | Loc.F->DeclContextInfos[DC])) |
Sebastian Redl | 66c5eef | 2010-07-27 00:17:23 +0000 | [diff] [blame] | 1800 | return 0; |
Sebastian Redl | f830df4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 1801 | } |
Sebastian Redl | d7dce0a | 2010-08-24 00:50:04 +0000 | [diff] [blame] | 1802 | |
Sebastian Redl | f830df4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 1803 | // Now add the pending visible updates for this decl context, if it has any. |
| 1804 | DeclContextVisibleUpdatesPending::iterator I = |
| 1805 | PendingVisibleUpdates.find(ID); |
| 1806 | if (I != PendingVisibleUpdates.end()) { |
| 1807 | // There are updates. This means the context has external visible |
| 1808 | // storage, even if the original stored version didn't. |
| 1809 | DC->setHasExternalVisibleStorage(true); |
| 1810 | DeclContextVisibleUpdates &U = I->second; |
Sebastian Redl | f830df4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 1811 | for (DeclContextVisibleUpdates::iterator UI = U.begin(), UE = U.end(); |
| 1812 | UI != UE; ++UI) { |
Douglas Gregor | 94619c8 | 2011-08-24 19:03:07 +0000 | [diff] [blame] | 1813 | UI->second->DeclContextInfos[DC].NameLookupTableData = UI->first; |
Sebastian Redl | d7dce0a | 2010-08-24 00:50:04 +0000 | [diff] [blame] | 1814 | } |
Sebastian Redl | f830df4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 1815 | PendingVisibleUpdates.erase(I); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1816 | } |
| 1817 | } |
| 1818 | assert(Idx == Record.size()); |
| 1819 | |
Douglas Gregor | dab4243 | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 1820 | // Load any relevant update records. |
| 1821 | loadDeclUpdateRecords(ID, D); |
Argyrios Kyrtzidis | 7d268c3 | 2011-11-14 07:07:59 +0000 | [diff] [blame] | 1822 | |
| 1823 | // Load the category chain after recursive loading is finished. |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 1824 | if (ObjCChainedCategoriesInterfaces.count(ID)) |
Argyrios Kyrtzidis | 7d268c3 | 2011-11-14 07:07:59 +0000 | [diff] [blame] | 1825 | PendingChainedObjCCategories.push_back( |
| 1826 | std::make_pair(cast<ObjCInterfaceDecl>(D), ID)); |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 1827 | |
Douglas Gregor | dab4243 | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 1828 | // If we have deserialized a declaration that has a definition the |
| 1829 | // AST consumer might need to know about, queue it. |
| 1830 | // We don't pass it to the consumer immediately because we may be in recursive |
| 1831 | // loading, and some declarations may still be initializing. |
Argyrios Kyrtzidis | a98e861 | 2011-09-13 21:35:00 +0000 | [diff] [blame] | 1832 | if (isConsumerInterestedIn(D)) |
Douglas Gregor | 87d8124 | 2011-09-10 00:22:34 +0000 | [diff] [blame] | 1833 | InterestingDecls.push_back(D); |
Douglas Gregor | 87d8124 | 2011-09-10 00:22:34 +0000 | [diff] [blame] | 1834 | |
Douglas Gregor | dab4243 | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 1835 | return D; |
| 1836 | } |
| 1837 | |
| 1838 | void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) { |
Argyrios Kyrtzidis | 65ad569 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 1839 | // The declaration may have been modified by files later in the chain. |
| 1840 | // If this is the case, read the record containing the updates from each file |
| 1841 | // and pass it to ASTDeclReader to make the modifications. |
| 1842 | DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID); |
| 1843 | if (UpdI != DeclUpdateOffsets.end()) { |
| 1844 | FileOffsetsTy &UpdateOffsets = UpdI->second; |
| 1845 | for (FileOffsetsTy::iterator |
Douglas Gregor | dab4243 | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 1846 | I = UpdateOffsets.begin(), E = UpdateOffsets.end(); I != E; ++I) { |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1847 | ModuleFile *F = I->first; |
Argyrios Kyrtzidis | 65ad569 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 1848 | uint64_t Offset = I->second; |
| 1849 | llvm::BitstreamCursor &Cursor = F->DeclsCursor; |
| 1850 | SavedStreamPosition SavedPosition(Cursor); |
| 1851 | Cursor.JumpToBit(Offset); |
| 1852 | RecordData Record; |
| 1853 | unsigned Code = Cursor.ReadCode(); |
| 1854 | unsigned RecCode = Cursor.ReadRecord(Code, Record); |
| 1855 | (void)RecCode; |
| 1856 | assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!"); |
Douglas Gregor | dab4243 | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 1857 | |
| 1858 | unsigned Idx = 0; |
Argyrios Kyrtzidis | 81ddd18 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 1859 | ASTDeclReader Reader(*this, *F, Cursor, ID, 0, Record, Idx); |
Sebastian Redl | 2ac2c72 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 1860 | Reader.UpdateDecl(D, *F, Record); |
Argyrios Kyrtzidis | 65ad569 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 1861 | } |
| 1862 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1863 | } |
Argyrios Kyrtzidis | 65ad569 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 1864 | |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 1865 | namespace { |
| 1866 | /// \brief Given an ObjC interface, goes through the modules and links to the |
| 1867 | /// interface all the categories for it. |
| 1868 | class ObjCChainedCategoriesVisitor { |
| 1869 | ASTReader &Reader; |
| 1870 | serialization::GlobalDeclID InterfaceID; |
| 1871 | ObjCInterfaceDecl *Interface; |
| 1872 | ObjCCategoryDecl *GlobHeadCat, *GlobTailCat; |
| 1873 | llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap; |
| 1874 | |
| 1875 | public: |
| 1876 | ObjCChainedCategoriesVisitor(ASTReader &Reader, |
| 1877 | serialization::GlobalDeclID InterfaceID, |
| 1878 | ObjCInterfaceDecl *Interface) |
| 1879 | : Reader(Reader), InterfaceID(InterfaceID), Interface(Interface), |
| 1880 | GlobHeadCat(0), GlobTailCat(0) { } |
| 1881 | |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1882 | static bool visit(ModuleFile &M, void *UserData) { |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 1883 | return static_cast<ObjCChainedCategoriesVisitor *>(UserData)->visit(M); |
| 1884 | } |
| 1885 | |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1886 | bool visit(ModuleFile &M) { |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 1887 | if (Reader.isDeclIDFromModule(InterfaceID, M)) |
| 1888 | return true; // We reached the module where the interface originated |
| 1889 | // from. Stop traversing the imported modules. |
| 1890 | |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1891 | ModuleFile::ChainedObjCCategoriesMap::iterator |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 1892 | I = M.ChainedObjCCategories.find(InterfaceID); |
| 1893 | if (I == M.ChainedObjCCategories.end()) |
| 1894 | return false; |
| 1895 | |
| 1896 | ObjCCategoryDecl * |
| 1897 | HeadCat = Reader.GetLocalDeclAs<ObjCCategoryDecl>(M, I->second.first); |
| 1898 | ObjCCategoryDecl * |
| 1899 | TailCat = Reader.GetLocalDeclAs<ObjCCategoryDecl>(M, I->second.second); |
| 1900 | |
| 1901 | addCategories(HeadCat, TailCat); |
| 1902 | return false; |
| 1903 | } |
| 1904 | |
| 1905 | void addCategories(ObjCCategoryDecl *HeadCat, |
| 1906 | ObjCCategoryDecl *TailCat = 0) { |
| 1907 | if (!HeadCat) { |
| 1908 | assert(!TailCat); |
| 1909 | return; |
| 1910 | } |
| 1911 | |
| 1912 | if (!TailCat) { |
| 1913 | TailCat = HeadCat; |
| 1914 | while (TailCat->getNextClassCategory()) |
| 1915 | TailCat = TailCat->getNextClassCategory(); |
| 1916 | } |
| 1917 | |
| 1918 | if (!GlobHeadCat) { |
| 1919 | GlobHeadCat = HeadCat; |
| 1920 | GlobTailCat = TailCat; |
| 1921 | } else { |
| 1922 | ASTDeclReader::setNextObjCCategory(GlobTailCat, HeadCat); |
| 1923 | GlobTailCat = TailCat; |
| 1924 | } |
| 1925 | |
| 1926 | llvm::DenseSet<DeclarationName> Checked; |
| 1927 | for (ObjCCategoryDecl *Cat = HeadCat, |
| 1928 | *CatEnd = TailCat->getNextClassCategory(); |
| 1929 | Cat != CatEnd; Cat = Cat->getNextClassCategory()) { |
| 1930 | if (Checked.count(Cat->getDeclName())) |
| 1931 | continue; |
| 1932 | Checked.insert(Cat->getDeclName()); |
| 1933 | checkForDuplicate(Cat); |
| 1934 | } |
| 1935 | } |
| 1936 | |
| 1937 | /// \brief Warns for duplicate categories that come from different modules. |
| 1938 | void checkForDuplicate(ObjCCategoryDecl *Cat) { |
| 1939 | DeclarationName Name = Cat->getDeclName(); |
| 1940 | // Find the top category with the same name. We do not want to warn for |
| 1941 | // duplicates along the established chain because there were already |
| 1942 | // warnings for them when the module was created. We only want to warn for |
| 1943 | // duplicates between non-dependent modules: |
| 1944 | // |
Argyrios Kyrtzidis | 019f3c2 | 2011-09-01 03:07:11 +0000 | [diff] [blame] | 1945 | // MT // |
| 1946 | // / \ // |
| 1947 | // ML MR // |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 1948 | // |
| 1949 | // We want to warn for duplicates between ML and MR,not between ML and MT. |
| 1950 | // |
| 1951 | // FIXME: We should not warn for duplicates in diamond: |
| 1952 | // |
Argyrios Kyrtzidis | 019f3c2 | 2011-09-01 03:07:11 +0000 | [diff] [blame] | 1953 | // MT // |
| 1954 | // / \ // |
| 1955 | // ML MR // |
| 1956 | // \ / // |
| 1957 | // MB // |
Argyrios Kyrtzidis | 7d847c9 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 1958 | // |
| 1959 | // If there are duplicates in ML/MR, there will be warning when creating |
| 1960 | // MB *and* when importing MB. We should not warn when importing. |
| 1961 | for (ObjCCategoryDecl *Next = Cat->getNextClassCategory(); Next; |
| 1962 | Next = Next->getNextClassCategory()) { |
| 1963 | if (Next->getDeclName() == Name) |
| 1964 | Cat = Next; |
| 1965 | } |
| 1966 | |
| 1967 | ObjCCategoryDecl *&PrevCat = NameCategoryMap[Name]; |
| 1968 | if (!PrevCat) |
| 1969 | PrevCat = Cat; |
| 1970 | |
| 1971 | if (PrevCat != Cat) { |
| 1972 | Reader.Diag(Cat->getLocation(), diag::warn_dup_category_def) |
| 1973 | << Interface->getDeclName() << Name; |
| 1974 | Reader.Diag(PrevCat->getLocation(), diag::note_previous_definition); |
| 1975 | } |
| 1976 | } |
| 1977 | |
| 1978 | ObjCCategoryDecl *getHeadCategory() const { return GlobHeadCat; } |
| 1979 | }; |
| 1980 | } |
| 1981 | |
| 1982 | void ASTReader::loadObjCChainedCategories(serialization::GlobalDeclID ID, |
| 1983 | ObjCInterfaceDecl *D) { |
| 1984 | ObjCChainedCategoriesVisitor Visitor(*this, ID, D); |
| 1985 | ModuleMgr.visit(ObjCChainedCategoriesVisitor::visit, &Visitor); |
| 1986 | // Also add the categories that the interface already links to. |
| 1987 | Visitor.addCategories(D->getCategoryList()); |
| 1988 | D->setCategoryList(Visitor.getHeadCategory()); |
| 1989 | } |
Douglas Gregor | dab4243 | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 1990 | |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1991 | void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, |
Sebastian Redl | 2ac2c72 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 1992 | const RecordData &Record) { |
Argyrios Kyrtzidis | d170d84 | 2010-10-24 17:26:50 +0000 | [diff] [blame] | 1993 | unsigned Idx = 0; |
| 1994 | while (Idx < Record.size()) { |
| 1995 | switch ((DeclUpdateKind)Record[Idx++]) { |
| 1996 | case UPD_CXX_SET_DEFINITIONDATA: { |
| 1997 | CXXRecordDecl *RD = cast<CXXRecordDecl>(D); |
Douglas Gregor | f718062 | 2011-08-03 15:48:04 +0000 | [diff] [blame] | 1998 | CXXRecordDecl *DefinitionDecl |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1999 | = Reader.ReadDeclAs<CXXRecordDecl>(ModuleFile, Record, Idx); |
Argyrios Kyrtzidis | d170d84 | 2010-10-24 17:26:50 +0000 | [diff] [blame] | 2000 | assert(!RD->DefinitionData && "DefinitionData is already set!"); |
| 2001 | InitializeCXXDefinitionData(RD, DefinitionDecl, Record, Idx); |
| 2002 | break; |
| 2003 | } |
Argyrios Kyrtzidis | e16a530 | 2010-10-24 17:26:54 +0000 | [diff] [blame] | 2004 | |
| 2005 | case UPD_CXX_ADDED_IMPLICIT_MEMBER: |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2006 | cast<CXXRecordDecl>(D)->addedMember(Reader.ReadDecl(ModuleFile, Record, Idx)); |
Argyrios Kyrtzidis | e16a530 | 2010-10-24 17:26:54 +0000 | [diff] [blame] | 2007 | break; |
Argyrios Kyrtzidis | 402dbbb | 2010-10-28 07:38:42 +0000 | [diff] [blame] | 2008 | |
| 2009 | case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: |
| 2010 | // It will be added to the template's specializations set when loaded. |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2011 | (void)Reader.ReadDecl(ModuleFile, Record, Idx); |
Sebastian Redl | fa1f370 | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 2012 | break; |
| 2013 | |
| 2014 | case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: { |
Douglas Gregor | f718062 | 2011-08-03 15:48:04 +0000 | [diff] [blame] | 2015 | NamespaceDecl *Anon |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2016 | = Reader.ReadDeclAs<NamespaceDecl>(ModuleFile, Record, Idx); |
Sebastian Redl | 010288f | 2011-04-24 16:28:21 +0000 | [diff] [blame] | 2017 | // Guard against these being loaded out of original order. Don't use |
| 2018 | // getNextNamespace(), since it tries to access the context and can't in |
| 2019 | // the middle of deserialization. |
| 2020 | if (!Anon->NextNamespace) { |
| 2021 | if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D)) |
| 2022 | TU->setAnonymousNamespace(Anon); |
| 2023 | else |
| 2024 | cast<NamespaceDecl>(D)->OrigOrAnonNamespace.setPointer(Anon); |
| 2025 | } |
Sebastian Redl | fa1f370 | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 2026 | break; |
| 2027 | } |
Sebastian Redl | 2ac2c72 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 2028 | |
| 2029 | case UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER: |
| 2030 | cast<VarDecl>(D)->getMemberSpecializationInfo()->setPointOfInstantiation( |
Douglas Gregor | de3ef50 | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2031 | Reader.ReadSourceLocation(ModuleFile, Record, Idx)); |
Sebastian Redl | 2ac2c72 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 2032 | break; |
Argyrios Kyrtzidis | d170d84 | 2010-10-24 17:26:50 +0000 | [diff] [blame] | 2033 | } |
| 2034 | } |
Argyrios Kyrtzidis | 65ad569 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 2035 | } |