Sebastian Redl | 904c9c8 | 2010-08-18 23:57:11 +0000 | [diff] [blame] | 1 | //===--- ASTReaderDecl.cpp - Decl Deserialization ---------------*- C++ -*-===// |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 10 | // This file implements the ASTReader::ReadDeclRecord method, which is the |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 11 | // entrypoint for loading a decl. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 15 | #include "ASTCommon.h" |
Sebastian Redl | 6ab7cd8 | 2010-08-18 23:57:17 +0000 | [diff] [blame] | 16 | #include "clang/Serialization/ASTReader.h" |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 17 | #include "clang/Sema/IdentifierResolver.h" |
| 18 | #include "clang/Sema/Sema.h" |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 19 | #include "clang/Sema/SemaDiagnostic.h" |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 20 | #include "clang/AST/ASTConsumer.h" |
| 21 | #include "clang/AST/ASTContext.h" |
| 22 | #include "clang/AST/DeclVisitor.h" |
| 23 | #include "clang/AST/DeclGroup.h" |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 24 | #include "clang/AST/DeclCXX.h" |
| 25 | #include "clang/AST/DeclTemplate.h" |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 26 | #include "clang/AST/Expr.h" |
| 27 | using namespace clang; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 28 | using namespace clang::serialization; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 29 | |
| 30 | //===----------------------------------------------------------------------===// |
| 31 | // Declaration deserialization |
| 32 | //===----------------------------------------------------------------------===// |
| 33 | |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 34 | namespace clang { |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 35 | class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> { |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 36 | ASTReader &Reader; |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 37 | ModuleFile &F; |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 38 | llvm::BitstreamCursor &Cursor; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 39 | const DeclID ThisDeclID; |
Argyrios Kyrtzidis | 9d31fa7 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 40 | const unsigned RawLocation; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 41 | typedef ASTReader::RecordData RecordData; |
| 42 | const RecordData &Record; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 43 | unsigned &Idx; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 44 | TypeID TypeIDForTypeDecl; |
Douglas Gregor | 67da6f6 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 45 | |
| 46 | DeclID DeclContextIDForTemplateParmDecl; |
| 47 | DeclID LexicalDeclContextIDForTemplateParmDecl; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 48 | |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 49 | uint64_t GetCurrentCursorOffset(); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 50 | |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 51 | SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 52 | return Reader.ReadSourceLocation(F, R, I); |
| 53 | } |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 54 | |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 55 | SourceRange ReadSourceRange(const RecordData &R, unsigned &I) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 56 | return Reader.ReadSourceRange(F, R, I); |
| 57 | } |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 58 | |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 59 | TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 60 | return Reader.GetTypeSourceInfo(F, R, I); |
| 61 | } |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 62 | |
| 63 | serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) { |
| 64 | return Reader.ReadDeclID(F, R, I); |
| 65 | } |
| 66 | |
| 67 | Decl *ReadDecl(const RecordData &R, unsigned &I) { |
| 68 | return Reader.ReadDecl(F, R, I); |
| 69 | } |
| 70 | |
| 71 | template<typename T> |
| 72 | T *ReadDeclAs(const RecordData &R, unsigned &I) { |
| 73 | return Reader.ReadDeclAs<T>(F, R, I); |
| 74 | } |
| 75 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 76 | void ReadQualifierInfo(QualifierInfo &Info, |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 77 | const RecordData &R, unsigned &I) { |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 78 | Reader.ReadQualifierInfo(F, Info, R, I); |
| 79 | } |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 80 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 81 | void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name, |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 82 | const RecordData &R, unsigned &I) { |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 83 | Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I); |
| 84 | } |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 85 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 86 | void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 87 | const RecordData &R, unsigned &I) { |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 88 | Reader.ReadDeclarationNameInfo(F, NameInfo, R, I); |
| 89 | } |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 90 | |
Douglas Gregor | ecc2c09 | 2011-12-01 22:20:10 +0000 | [diff] [blame] | 91 | serialization::SubmoduleID readSubmoduleID(const RecordData &R, |
| 92 | unsigned &I) { |
| 93 | if (I >= R.size()) |
| 94 | return 0; |
| 95 | |
| 96 | return Reader.getGlobalSubmoduleID(F, R[I++]); |
| 97 | } |
| 98 | |
Douglas Gregor | 15de72c | 2011-12-02 23:23:56 +0000 | [diff] [blame] | 99 | Module *readModule(const RecordData &R, unsigned &I) { |
| 100 | return Reader.getSubmodule(readSubmoduleID(R, I)); |
| 101 | } |
| 102 | |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 103 | void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data, |
| 104 | const RecordData &R, unsigned &I); |
| 105 | |
| 106 | void InitializeCXXDefinitionData(CXXRecordDecl *D, |
| 107 | CXXRecordDecl *DefinitionDecl, |
| 108 | const RecordData &Record, unsigned &Idx); |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 109 | |
| 110 | /// \brief RAII class used to capture the first ID within a redeclaration |
| 111 | /// chain and to introduce it into the list of pending redeclaration chains |
| 112 | /// on destruction. |
| 113 | /// |
| 114 | /// The caller can choose not to introduce this ID into the redeclaration |
| 115 | /// chain by calling \c suppress(). |
| 116 | class RedeclarableResult { |
| 117 | ASTReader &Reader; |
| 118 | GlobalDeclID FirstID; |
| 119 | mutable bool Owning; |
| 120 | |
| 121 | RedeclarableResult &operator=(RedeclarableResult&); // DO NOT IMPLEMENT |
| 122 | |
| 123 | public: |
| 124 | RedeclarableResult(ASTReader &Reader, GlobalDeclID FirstID) |
| 125 | : Reader(Reader), FirstID(FirstID), Owning(true) { } |
| 126 | |
| 127 | RedeclarableResult(const RedeclarableResult &Other) |
| 128 | : Reader(Other.Reader), FirstID(Other.FirstID), Owning(Other.Owning) |
| 129 | { |
| 130 | Other.Owning = false; |
| 131 | } |
| 132 | |
| 133 | ~RedeclarableResult() { |
Douglas Gregor | bf1739c | 2011-12-22 22:05:07 +0000 | [diff] [blame^] | 134 | // FIXME: We want to suppress this when the declaration is local to |
| 135 | // a function, since there's no reason to search other AST files |
| 136 | // for redeclarations (they can't exist). However, this is hard to |
| 137 | // do locally because the declaration hasn't necessarily loaded its |
| 138 | // declaration context yet. Also, local externs still have the function |
| 139 | // as their (semantic) declaration context, which is wrong and would |
| 140 | // break this optimize. |
| 141 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 142 | if (FirstID && Owning && Reader.PendingDeclChainsKnown.insert(FirstID)) |
| 143 | Reader.PendingDeclChains.push_back(FirstID); |
| 144 | } |
| 145 | |
| 146 | /// \brief Retrieve the first ID. |
| 147 | GlobalDeclID getFirstID() const { return FirstID; } |
| 148 | |
| 149 | /// \brief Do not introduce this declaration ID into the set of pending |
| 150 | /// declaration chains. |
| 151 | void suppress() { |
| 152 | Owning = false; |
| 153 | } |
| 154 | }; |
| 155 | |
| 156 | /// \brief Class used to capture the result of searching for an existing |
| 157 | /// declaration of a specific kind and name, along with the ability |
| 158 | /// to update the place where this result was found (the declaration |
| 159 | /// chain hanging off an identifier or the DeclContext we searched in) |
| 160 | /// if requested. |
| 161 | class FindExistingResult { |
| 162 | ASTReader &Reader; |
| 163 | NamedDecl *New; |
| 164 | NamedDecl *Existing; |
| 165 | mutable bool AddResult; |
| 166 | |
| 167 | FindExistingResult &operator=(FindExistingResult&); // DO NOT IMPLEMENT |
| 168 | |
| 169 | public: |
| 170 | FindExistingResult(ASTReader &Reader) |
| 171 | : Reader(Reader), New(0), Existing(0), AddResult(false) { } |
| 172 | |
| 173 | FindExistingResult(ASTReader &Reader, NamedDecl *New, NamedDecl *Existing) |
| 174 | : Reader(Reader), New(New), Existing(Existing), AddResult(true) { } |
| 175 | |
| 176 | FindExistingResult(const FindExistingResult &Other) |
| 177 | : Reader(Other.Reader), New(Other.New), Existing(Other.Existing), |
| 178 | AddResult(Other.AddResult) |
| 179 | { |
| 180 | Other.AddResult = false; |
| 181 | } |
| 182 | |
| 183 | ~FindExistingResult(); |
| 184 | |
| 185 | operator NamedDecl*() const { return Existing; } |
| 186 | |
| 187 | template<typename T> |
| 188 | operator T*() const { return dyn_cast_or_null<T>(Existing); } |
| 189 | }; |
| 190 | |
| 191 | FindExistingResult findExisting(NamedDecl *D); |
| 192 | |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 193 | public: |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 194 | ASTDeclReader(ASTReader &Reader, ModuleFile &F, |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 195 | llvm::BitstreamCursor &Cursor, DeclID thisDeclID, |
Argyrios Kyrtzidis | 9d31fa7 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 196 | unsigned RawLocation, |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 197 | const RecordData &Record, unsigned &Idx) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 198 | : Reader(Reader), F(F), Cursor(Cursor), ThisDeclID(thisDeclID), |
Argyrios Kyrtzidis | 9d31fa7 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 199 | RawLocation(RawLocation), Record(Record), Idx(Idx), |
| 200 | TypeIDForTypeDecl(0) { } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 201 | |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 202 | static void attachPreviousDecl(Decl *D, Decl *previous); |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 203 | static void attachLatestDecl(Decl *D, Decl *latest); |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 204 | |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 205 | void Visit(Decl *D); |
| 206 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 207 | void UpdateDecl(Decl *D, ModuleFile &ModuleFile, |
Sebastian Redl | f79a719 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 208 | const RecordData &Record); |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 209 | |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 210 | static void setNextObjCCategory(ObjCCategoryDecl *Cat, |
| 211 | ObjCCategoryDecl *Next) { |
| 212 | Cat->NextClassCategory = Next; |
| 213 | } |
| 214 | |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 215 | void VisitDecl(Decl *D); |
| 216 | void VisitTranslationUnitDecl(TranslationUnitDecl *TU); |
| 217 | void VisitNamedDecl(NamedDecl *ND); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 218 | void VisitLabelDecl(LabelDecl *LD); |
Douglas Gregor | 0cef483 | 2010-02-21 18:22:14 +0000 | [diff] [blame] | 219 | void VisitNamespaceDecl(NamespaceDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 220 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); |
| 221 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 222 | void VisitTypeDecl(TypeDecl *TD); |
Douglas Gregor | 0f45682 | 2011-12-19 14:40:25 +0000 | [diff] [blame] | 223 | void VisitTypedefNameDecl(TypedefNameDecl *TD); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 224 | void VisitTypedefDecl(TypedefDecl *TD); |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 225 | void VisitTypeAliasDecl(TypeAliasDecl *TD); |
Argyrios Kyrtzidis | 8f4eae9 | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 226 | void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 227 | void VisitTagDecl(TagDecl *TD); |
| 228 | void VisitEnumDecl(EnumDecl *ED); |
| 229 | void VisitRecordDecl(RecordDecl *RD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 230 | void VisitCXXRecordDecl(CXXRecordDecl *D); |
| 231 | void VisitClassTemplateSpecializationDecl( |
| 232 | ClassTemplateSpecializationDecl *D); |
| 233 | void VisitClassTemplatePartialSpecializationDecl( |
| 234 | ClassTemplatePartialSpecializationDecl *D); |
Sebastian Redl | 14c3633 | 2011-08-31 13:59:56 +0000 | [diff] [blame] | 235 | void VisitClassScopeFunctionSpecializationDecl( |
| 236 | ClassScopeFunctionSpecializationDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 237 | void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 238 | void VisitValueDecl(ValueDecl *VD); |
| 239 | void VisitEnumConstantDecl(EnumConstantDecl *ECD); |
Argyrios Kyrtzidis | 8f4eae9 | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 240 | void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 241 | void VisitDeclaratorDecl(DeclaratorDecl *DD); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 242 | void VisitFunctionDecl(FunctionDecl *FD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 243 | void VisitCXXMethodDecl(CXXMethodDecl *D); |
| 244 | void VisitCXXConstructorDecl(CXXConstructorDecl *D); |
| 245 | void VisitCXXDestructorDecl(CXXDestructorDecl *D); |
| 246 | void VisitCXXConversionDecl(CXXConversionDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 247 | void VisitFieldDecl(FieldDecl *FD); |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 248 | void VisitIndirectFieldDecl(IndirectFieldDecl *FD); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 249 | void VisitVarDecl(VarDecl *VD); |
| 250 | void VisitImplicitParamDecl(ImplicitParamDecl *PD); |
| 251 | void VisitParmVarDecl(ParmVarDecl *PD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 252 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); |
| 253 | void VisitTemplateDecl(TemplateDecl *D); |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 254 | void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 255 | void VisitClassTemplateDecl(ClassTemplateDecl *D); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 256 | void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 257 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); |
Richard Smith | 3e4c6c4 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 258 | void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D); |
Argyrios Kyrtzidis | b01a552 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 259 | void VisitUsingDecl(UsingDecl *D); |
| 260 | void VisitUsingShadowDecl(UsingShadowDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 261 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 262 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD); |
Douglas Gregor | 15de72c | 2011-12-02 23:23:56 +0000 | [diff] [blame] | 263 | void VisitImportDecl(ImportDecl *D); |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 264 | void VisitAccessSpecDecl(AccessSpecDecl *D); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 265 | void VisitFriendDecl(FriendDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 266 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); |
| 267 | void VisitStaticAssertDecl(StaticAssertDecl *D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 268 | void VisitBlockDecl(BlockDecl *BD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 269 | |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 270 | std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC); |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 271 | |
| 272 | template <typename T> |
| 273 | RedeclarableResult VisitRedeclarable(Redeclarable<T> *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 274 | |
Sean Hunt | 9a55591 | 2010-05-30 07:21:58 +0000 | [diff] [blame] | 275 | // FIXME: Reorder according to DeclNodes.td? |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 276 | void VisitObjCMethodDecl(ObjCMethodDecl *D); |
| 277 | void VisitObjCContainerDecl(ObjCContainerDecl *D); |
| 278 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); |
| 279 | void VisitObjCIvarDecl(ObjCIvarDecl *D); |
| 280 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); |
| 281 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); |
| 282 | void VisitObjCClassDecl(ObjCClassDecl *D); |
| 283 | void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D); |
| 284 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); |
| 285 | void VisitObjCImplDecl(ObjCImplDecl *D); |
| 286 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); |
| 287 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); |
| 288 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); |
| 289 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
| 290 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
| 291 | }; |
| 292 | } |
| 293 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 294 | uint64_t ASTDeclReader::GetCurrentCursorOffset() { |
Douglas Gregor | 8f1231b | 2011-07-22 06:10:01 +0000 | [diff] [blame] | 295 | return F.DeclsCursor.GetCurrentBitNo() + F.GlobalBitOffset; |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 296 | } |
| 297 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 298 | void ASTDeclReader::Visit(Decl *D) { |
| 299 | DeclVisitor<ASTDeclReader, void>::Visit(D); |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 300 | |
Jonathan D. Turner | 953c564 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 301 | if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) { |
| 302 | if (DD->DeclInfo) { |
| 303 | DeclaratorDecl::ExtInfo *Info = |
| 304 | DD->DeclInfo.get<DeclaratorDecl::ExtInfo *>(); |
| 305 | Info->TInfo = |
| 306 | GetTypeSourceInfo(Record, Idx); |
| 307 | } |
| 308 | else { |
| 309 | DD->DeclInfo = GetTypeSourceInfo(Record, Idx); |
| 310 | } |
| 311 | } |
| 312 | |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 313 | if (TypeDecl *TD = dyn_cast<TypeDecl>(D)) { |
Douglas Gregor | deacbdc | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 314 | // if we have a fully initialized TypeDecl, we can safely read its type now. |
Douglas Gregor | 1ab55e9 | 2010-12-10 17:03:06 +0000 | [diff] [blame] | 315 | TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull()); |
Douglas Gregor | 0af5501 | 2011-12-16 03:12:41 +0000 | [diff] [blame] | 316 | } else if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) { |
| 317 | // if we have a fully initialized TypeDecl, we can safely read its type now. |
| 318 | ID->TypeForDecl = Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull(); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 319 | } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
| 320 | // FunctionDecl's body was written last after all other Stmts/Exprs. |
| 321 | if (Record[Idx++]) |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 322 | FD->setLazyBody(GetCurrentCursorOffset()); |
Douglas Gregor | 67da6f6 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 323 | } else if (D->isTemplateParameter()) { |
| 324 | // If we have a fully initialized template parameter, we can now |
| 325 | // set its DeclContext. |
| 326 | D->setDeclContext( |
| 327 | cast_or_null<DeclContext>( |
| 328 | Reader.GetDecl(DeclContextIDForTemplateParmDecl))); |
| 329 | D->setLexicalDeclContext( |
| 330 | cast_or_null<DeclContext>( |
| 331 | Reader.GetDecl(LexicalDeclContextIDForTemplateParmDecl))); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 332 | } |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 333 | } |
| 334 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 335 | void ASTDeclReader::VisitDecl(Decl *D) { |
Douglas Gregor | 67da6f6 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 336 | if (D->isTemplateParameter()) { |
| 337 | // We don't want to deserialize the DeclContext of a template |
| 338 | // parameter immediately, because the template parameter might be |
| 339 | // used in the formulation of its DeclContext. Use the translation |
| 340 | // unit DeclContext as a placeholder. |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 341 | DeclContextIDForTemplateParmDecl = ReadDeclID(Record, Idx); |
| 342 | LexicalDeclContextIDForTemplateParmDecl = ReadDeclID(Record, Idx); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 343 | D->setDeclContext(Reader.getContext().getTranslationUnitDecl()); |
Douglas Gregor | 67da6f6 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 344 | } else { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 345 | D->setDeclContext(ReadDeclAs<DeclContext>(Record, Idx)); |
| 346 | D->setLexicalDeclContext(ReadDeclAs<DeclContext>(Record, Idx)); |
Douglas Gregor | 67da6f6 | 2011-03-05 01:35:54 +0000 | [diff] [blame] | 347 | } |
Argyrios Kyrtzidis | 9d31fa7 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 348 | D->setLocation(Reader.ReadSourceLocation(F, RawLocation)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 349 | D->setInvalidDecl(Record[Idx++]); |
Argyrios Kyrtzidis | 4eb9fc0 | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 350 | if (Record[Idx++]) { // hasAttrs |
Sean Hunt | cf807c4 | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 351 | AttrVec Attrs; |
Argyrios Kyrtzidis | 4eb9fc0 | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 352 | Reader.ReadAttributes(F, Attrs, Record, Idx); |
Sean Hunt | cf807c4 | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 353 | D->setAttrs(Attrs); |
| 354 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 355 | D->setImplicit(Record[Idx++]); |
Douglas Gregor | e0762c9 | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 356 | D->setUsed(Record[Idx++]); |
Argyrios Kyrtzidis | 6b6b42a | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 357 | D->setReferenced(Record[Idx++]); |
Argyrios Kyrtzidis | c14a03d | 2011-11-23 20:27:36 +0000 | [diff] [blame] | 358 | D->TopLevelDeclInObjCContainer = Record[Idx++]; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 359 | D->setAccess((AccessSpecifier)Record[Idx++]); |
Douglas Gregor | 08e0bc1 | 2011-09-10 00:09:20 +0000 | [diff] [blame] | 360 | D->FromASTFile = true; |
Douglas Gregor | 8d267c5 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 361 | D->ModulePrivate = Record[Idx++]; |
Douglas Gregor | ecc2c09 | 2011-12-01 22:20:10 +0000 | [diff] [blame] | 362 | |
| 363 | // Determine whether this declaration is part of a (sub)module. If so, it |
| 364 | // may not yet be visible. |
| 365 | if (unsigned SubmoduleID = readSubmoduleID(Record, Idx)) { |
| 366 | // Module-private declarations are never visible, so there is no work to do. |
| 367 | if (!D->ModulePrivate) { |
| 368 | if (Module *Owner = Reader.getSubmodule(SubmoduleID)) { |
| 369 | if (Owner->NameVisibility != Module::AllVisible) { |
| 370 | // The owning module is not visible. Mark this declaration as |
| 371 | // module-private, |
| 372 | D->ModulePrivate = true; |
| 373 | |
| 374 | // Note that this declaration was hidden because its owning module is |
| 375 | // not yet visible. |
| 376 | Reader.HiddenNamesMap[Owner].push_back(D); |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 381 | } |
| 382 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 383 | void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { |
Douglas Gregor | 6bf2b9f | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 384 | llvm_unreachable("Translation units are not serialized"); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 385 | } |
| 386 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 387 | void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 388 | VisitDecl(ND); |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 389 | ND->setDeclName(Reader.ReadDeclarationName(F, Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 390 | } |
| 391 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 392 | void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 393 | VisitNamedDecl(TD); |
Abramo Bagnara | 344577e | 2011-03-06 15:48:19 +0000 | [diff] [blame] | 394 | TD->setLocStart(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 395 | // Delay type reading until after we have fully initialized the decl. |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 396 | TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 397 | } |
| 398 | |
Douglas Gregor | 0f45682 | 2011-12-19 14:40:25 +0000 | [diff] [blame] | 399 | void ASTDeclReader::VisitTypedefNameDecl(TypedefNameDecl *TD) { |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 400 | VisitRedeclarable(TD); |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 401 | VisitTypeDecl(TD); |
Douglas Gregor | 0f45682 | 2011-12-19 14:40:25 +0000 | [diff] [blame] | 402 | TD->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
| 403 | } |
| 404 | |
| 405 | void ASTDeclReader::VisitTypedefDecl(TypedefDecl *TD) { |
| 406 | VisitTypedefNameDecl(TD); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 409 | void ASTDeclReader::VisitTypeAliasDecl(TypeAliasDecl *TD) { |
Douglas Gregor | 0f45682 | 2011-12-19 14:40:25 +0000 | [diff] [blame] | 410 | VisitTypedefNameDecl(TD); |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 411 | } |
| 412 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 413 | void ASTDeclReader::VisitTagDecl(TagDecl *TD) { |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 414 | VisitRedeclarable(TD); |
Douglas Gregor | d488b3a | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 415 | VisitTypeDecl(TD); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 416 | TD->IdentifierNamespace = Record[Idx++]; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 417 | TD->setTagKind((TagDecl::TagKind)Record[Idx++]); |
John McCall | 5e1cdac | 2011-10-07 06:10:15 +0000 | [diff] [blame] | 418 | TD->setCompleteDefinition(Record[Idx++]); |
Douglas Gregor | b37b648 | 2010-02-12 17:40:34 +0000 | [diff] [blame] | 419 | TD->setEmbeddedInDeclarator(Record[Idx++]); |
Argyrios Kyrtzidis | 717a20b | 2011-09-30 22:11:31 +0000 | [diff] [blame] | 420 | TD->setFreeStanding(Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 421 | TD->setRBraceLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 422 | if (Record[Idx++]) { // hasExtInfo |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 423 | TagDecl::ExtInfo *Info = new (Reader.getContext()) TagDecl::ExtInfo(); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 424 | ReadQualifierInfo(*Info, Record, Idx); |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 425 | TD->TypedefNameDeclOrQualifier = Info; |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 426 | } else |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 427 | TD->setTypedefNameForAnonDecl(ReadDeclAs<TypedefNameDecl>(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 428 | } |
| 429 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 430 | void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 431 | VisitTagDecl(ED); |
Douglas Gregor | 1274ccd | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 432 | if (TypeSourceInfo *TI = Reader.GetTypeSourceInfo(F, Record, Idx)) |
| 433 | ED->setIntegerTypeSourceInfo(TI); |
| 434 | else |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 435 | ED->setIntegerType(Reader.readType(F, Record, Idx)); |
| 436 | ED->setPromotionType(Reader.readType(F, Record, Idx)); |
John McCall | 1b5a618 | 2010-05-06 08:49:23 +0000 | [diff] [blame] | 437 | ED->setNumPositiveBits(Record[Idx++]); |
| 438 | ED->setNumNegativeBits(Record[Idx++]); |
Douglas Gregor | 1274ccd | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 439 | ED->IsScoped = Record[Idx++]; |
Abramo Bagnara | a88cefd | 2010-12-03 18:54:17 +0000 | [diff] [blame] | 440 | ED->IsScopedUsingClassTag = Record[Idx++]; |
Douglas Gregor | 1274ccd | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 441 | ED->IsFixed = Record[Idx++]; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 442 | ED->setInstantiationOfMemberEnum(ReadDeclAs<EnumDecl>(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 443 | } |
| 444 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 445 | void ASTDeclReader::VisitRecordDecl(RecordDecl *RD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 446 | VisitTagDecl(RD); |
| 447 | RD->setHasFlexibleArrayMember(Record[Idx++]); |
| 448 | RD->setAnonymousStructOrUnion(Record[Idx++]); |
Fariborz Jahanian | 643b7df | 2009-07-08 16:37:44 +0000 | [diff] [blame] | 449 | RD->setHasObjectMember(Record[Idx++]); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 450 | } |
| 451 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 452 | void ASTDeclReader::VisitValueDecl(ValueDecl *VD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 453 | VisitNamedDecl(VD); |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 454 | VD->setType(Reader.readType(F, Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 455 | } |
| 456 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 457 | void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 458 | VisitValueDecl(ECD); |
| 459 | if (Record[Idx++]) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 460 | ECD->setInitExpr(Reader.ReadExpr(F)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 461 | ECD->setInitVal(Reader.ReadAPSInt(Record, Idx)); |
| 462 | } |
| 463 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 464 | void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 465 | VisitValueDecl(DD); |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 466 | DD->setInnerLocStart(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 467 | if (Record[Idx++]) { // hasExtInfo |
| 468 | DeclaratorDecl::ExtInfo *Info |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 469 | = new (Reader.getContext()) DeclaratorDecl::ExtInfo(); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 470 | ReadQualifierInfo(*Info, Record, Idx); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 471 | DD->DeclInfo = Info; |
Jonathan D. Turner | 953c564 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 472 | } |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 473 | } |
| 474 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 475 | void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 476 | VisitRedeclarable(FD); |
Douglas Gregor | d488b3a | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 477 | VisitDeclaratorDecl(FD); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 478 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 479 | ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName(), Record, Idx); |
Argyrios Kyrtzidis | c8f9af2 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 480 | FD->IdentifierNamespace = Record[Idx++]; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 481 | switch ((FunctionDecl::TemplatedKind)Record[Idx++]) { |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 482 | default: llvm_unreachable("Unhandled TemplatedKind!"); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 483 | case FunctionDecl::TK_NonTemplate: |
| 484 | break; |
| 485 | case FunctionDecl::TK_FunctionTemplate: |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 486 | FD->setDescribedFunctionTemplate(ReadDeclAs<FunctionTemplateDecl>(Record, |
| 487 | Idx)); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 488 | break; |
| 489 | case FunctionDecl::TK_MemberSpecialization: { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 490 | FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>(Record, Idx); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 491 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 492 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 493 | FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 494 | FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI); |
| 495 | break; |
| 496 | } |
| 497 | case FunctionDecl::TK_FunctionTemplateSpecialization: { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 498 | FunctionTemplateDecl *Template = ReadDeclAs<FunctionTemplateDecl>(Record, |
| 499 | Idx); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 500 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
| 501 | |
| 502 | // Template arguments. |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 503 | SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 504 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 505 | |
| 506 | // Template args as written. |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 507 | SmallVector<TemplateArgumentLoc, 8> TemplArgLocs; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 508 | SourceLocation LAngleLoc, RAngleLoc; |
Argyrios Kyrtzidis | 71a7605 | 2011-09-22 20:07:09 +0000 | [diff] [blame] | 509 | bool HasTemplateArgumentsAsWritten = Record[Idx++]; |
| 510 | if (HasTemplateArgumentsAsWritten) { |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 511 | unsigned NumTemplateArgLocs = Record[Idx++]; |
| 512 | TemplArgLocs.reserve(NumTemplateArgLocs); |
| 513 | for (unsigned i=0; i != NumTemplateArgLocs; ++i) |
Sebastian Redl | 577d479 | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 514 | TemplArgLocs.push_back( |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 515 | Reader.ReadTemplateArgumentLoc(F, Record, Idx)); |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 516 | |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 517 | LAngleLoc = ReadSourceLocation(Record, Idx); |
| 518 | RAngleLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 519 | } |
Argyrios Kyrtzidis | 7b081c8 | 2010-07-05 10:37:55 +0000 | [diff] [blame] | 520 | |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 521 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 522 | |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 523 | ASTContext &C = Reader.getContext(); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 524 | TemplateArgumentList *TemplArgList |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 525 | = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), TemplArgs.size()); |
Argyrios Kyrtzidis | 71a7605 | 2011-09-22 20:07:09 +0000 | [diff] [blame] | 526 | TemplateArgumentListInfo TemplArgsInfo(LAngleLoc, RAngleLoc); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 527 | for (unsigned i=0, e = TemplArgLocs.size(); i != e; ++i) |
Argyrios Kyrtzidis | 71a7605 | 2011-09-22 20:07:09 +0000 | [diff] [blame] | 528 | TemplArgsInfo.addArgument(TemplArgLocs[i]); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 529 | FunctionTemplateSpecializationInfo *FTInfo |
| 530 | = FunctionTemplateSpecializationInfo::Create(C, FD, Template, TSK, |
| 531 | TemplArgList, |
Argyrios Kyrtzidis | 71a7605 | 2011-09-22 20:07:09 +0000 | [diff] [blame] | 532 | HasTemplateArgumentsAsWritten ? &TemplArgsInfo : 0, |
| 533 | POI); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 534 | FD->TemplateOrSpecialization = FTInfo; |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 535 | |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 536 | if (FD->isCanonicalDecl()) { // if canonical add to template's set. |
Argyrios Kyrtzidis | 99a8ca0 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 537 | // The template that contains the specializations set. It's not safe to |
| 538 | // use getCanonicalDecl on Template since it may still be initializing. |
| 539 | FunctionTemplateDecl *CanonTemplate |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 540 | = ReadDeclAs<FunctionTemplateDecl>(Record, Idx); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 541 | // Get the InsertPos by FindNodeOrInsertPos() instead of calling |
| 542 | // InsertNode(FTInfo) directly to avoid the getASTContext() call in |
| 543 | // FunctionTemplateSpecializationInfo's Profile(). |
| 544 | // We avoid getASTContext because a decl in the parent hierarchy may |
| 545 | // be initializing. |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 546 | llvm::FoldingSetNodeID ID; |
| 547 | FunctionTemplateSpecializationInfo::Profile(ID, TemplArgs.data(), |
| 548 | TemplArgs.size(), C); |
| 549 | void *InsertPos = 0; |
Argyrios Kyrtzidis | 99a8ca0 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 550 | CanonTemplate->getSpecializations().FindNodeOrInsertPos(ID, InsertPos); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 551 | assert(InsertPos && "Another specialization already inserted!"); |
Argyrios Kyrtzidis | 99a8ca0 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 552 | CanonTemplate->getSpecializations().InsertNode(FTInfo, InsertPos); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 553 | } |
Argyrios Kyrtzidis | dc767e3 | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 554 | break; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 555 | } |
| 556 | case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { |
| 557 | // Templates. |
| 558 | UnresolvedSet<8> TemplDecls; |
| 559 | unsigned NumTemplates = Record[Idx++]; |
| 560 | while (NumTemplates--) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 561 | TemplDecls.addDecl(ReadDeclAs<NamedDecl>(Record, Idx)); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 562 | |
| 563 | // Templates args. |
| 564 | TemplateArgumentListInfo TemplArgs; |
| 565 | unsigned NumArgs = Record[Idx++]; |
| 566 | while (NumArgs--) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 567 | TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(F, Record, Idx)); |
| 568 | TemplArgs.setLAngleLoc(ReadSourceLocation(Record, Idx)); |
| 569 | TemplArgs.setRAngleLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 570 | |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 571 | FD->setDependentTemplateSpecialization(Reader.getContext(), |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 572 | TemplDecls, TemplArgs); |
Argyrios Kyrtzidis | dc767e3 | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 573 | break; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 574 | } |
| 575 | } |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 576 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 577 | // FunctionDecl's body is handled last at ASTDeclReader::Visit, |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 578 | // after everything else is read. |
| 579 | |
Douglas Gregor | 381d34e | 2010-12-06 18:36:25 +0000 | [diff] [blame] | 580 | FD->SClass = (StorageClass)Record[Idx++]; |
Argyrios Kyrtzidis | 20df8e7 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 581 | FD->SClassAsWritten = (StorageClass)Record[Idx++]; |
Douglas Gregor | 8f15094 | 2010-12-09 16:59:22 +0000 | [diff] [blame] | 582 | FD->IsInline = Record[Idx++]; |
| 583 | FD->IsInlineSpecified = Record[Idx++]; |
Argyrios Kyrtzidis | 20df8e7 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 584 | FD->IsVirtualAsWritten = Record[Idx++]; |
| 585 | FD->IsPure = Record[Idx++]; |
| 586 | FD->HasInheritedPrototype = Record[Idx++]; |
| 587 | FD->HasWrittenPrototype = Record[Idx++]; |
| 588 | FD->IsDeleted = Record[Idx++]; |
| 589 | FD->IsTrivial = Record[Idx++]; |
Sean Hunt | 2be7e90 | 2011-05-12 22:46:29 +0000 | [diff] [blame] | 590 | FD->IsDefaulted = Record[Idx++]; |
| 591 | FD->IsExplicitlyDefaulted = Record[Idx++]; |
Argyrios Kyrtzidis | 20df8e7 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 592 | FD->HasImplicitReturnZero = Record[Idx++]; |
Richard Smith | af1fc7a | 2011-08-15 21:04:07 +0000 | [diff] [blame] | 593 | FD->IsConstexpr = Record[Idx++]; |
Argyrios Kyrtzidis | 20df8e7 | 2011-01-03 17:57:40 +0000 | [diff] [blame] | 594 | FD->EndRangeLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 595 | |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 596 | // Read in the parameters. |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 597 | unsigned NumParams = Record[Idx++]; |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 598 | SmallVector<ParmVarDecl *, 16> Params; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 599 | Params.reserve(NumParams); |
| 600 | for (unsigned I = 0; I != NumParams; ++I) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 601 | Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx)); |
David Blaikie | 4278c65 | 2011-09-21 18:16:56 +0000 | [diff] [blame] | 602 | FD->setParams(Reader.getContext(), Params); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 603 | } |
| 604 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 605 | void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 606 | VisitNamedDecl(MD); |
| 607 | if (Record[Idx++]) { |
| 608 | // In practice, this won't be executed (since method definitions |
| 609 | // don't occur in header files). |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 610 | MD->setBody(Reader.ReadStmt(F)); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 611 | MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx)); |
| 612 | MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 613 | } |
| 614 | MD->setInstanceMethod(Record[Idx++]); |
| 615 | MD->setVariadic(Record[Idx++]); |
| 616 | MD->setSynthesized(Record[Idx++]); |
Fariborz Jahanian | 3fe1041 | 2010-07-22 18:24:20 +0000 | [diff] [blame] | 617 | MD->setDefined(Record[Idx++]); |
Argyrios Kyrtzidis | 72b2625 | 2011-10-14 17:41:52 +0000 | [diff] [blame] | 618 | |
| 619 | MD->IsRedeclaration = Record[Idx++]; |
| 620 | MD->HasRedeclaration = Record[Idx++]; |
| 621 | if (MD->HasRedeclaration) |
| 622 | Reader.getContext().setObjCMethodRedeclaration(MD, |
| 623 | ReadDeclAs<ObjCMethodDecl>(Record, Idx)); |
| 624 | |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 625 | MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]); |
| 626 | MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); |
Douglas Gregor | 926df6c | 2011-06-11 01:09:30 +0000 | [diff] [blame] | 627 | MD->SetRelatedResultType(Record[Idx++]); |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 628 | MD->setResultType(Reader.readType(F, Record, Idx)); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 629 | MD->setResultTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
| 630 | MD->setEndLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 631 | unsigned NumParams = Record[Idx++]; |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 632 | SmallVector<ParmVarDecl *, 16> Params; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 633 | Params.reserve(NumParams); |
| 634 | for (unsigned I = 0; I != NumParams; ++I) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 635 | Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx)); |
Argyrios Kyrtzidis | 491306a | 2011-10-03 06:37:04 +0000 | [diff] [blame] | 636 | |
| 637 | MD->SelLocsKind = Record[Idx++]; |
| 638 | unsigned NumStoredSelLocs = Record[Idx++]; |
| 639 | SmallVector<SourceLocation, 16> SelLocs; |
| 640 | SelLocs.reserve(NumStoredSelLocs); |
| 641 | for (unsigned i = 0; i != NumStoredSelLocs; ++i) |
| 642 | SelLocs.push_back(ReadSourceLocation(Record, Idx)); |
| 643 | |
| 644 | MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 645 | } |
| 646 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 647 | void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 648 | VisitNamedDecl(CD); |
Argyrios Kyrtzidis | 1711fc9 | 2011-10-04 04:48:02 +0000 | [diff] [blame] | 649 | CD->setAtStartLoc(ReadSourceLocation(Record, Idx)); |
| 650 | CD->setAtEndRange(ReadSourceRange(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 651 | } |
| 652 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 653 | void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { |
Douglas Gregor | cce54aa | 2011-12-22 19:44:59 +0000 | [diff] [blame] | 654 | // Record the declaration -> global ID mapping. |
| 655 | Reader.DeclToID[ID] = ThisDeclID; |
| 656 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 657 | RedeclarableResult Redecl = VisitRedeclarable(ID); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 658 | VisitObjCContainerDecl(ID); |
Douglas Gregor | 0af5501 | 2011-12-16 03:12:41 +0000 | [diff] [blame] | 659 | TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]); |
Douglas Gregor | cce54aa | 2011-12-22 19:44:59 +0000 | [diff] [blame] | 660 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 661 | // Determine whether we need to merge this declaration with another @interface |
| 662 | // with the same name. |
| 663 | // FIXME: Not needed unless the module file graph is a DAG. |
| 664 | if (FindExistingResult ExistingRes = findExisting(ID)) { |
| 665 | if (ObjCInterfaceDecl *Existing = ExistingRes) { |
| 666 | ObjCInterfaceDecl *ExistingCanon = Existing->getCanonicalDecl(); |
| 667 | ObjCInterfaceDecl *IDCanon = ID->getCanonicalDecl(); |
| 668 | if (ExistingCanon != IDCanon) { |
| 669 | // Have our redeclaration link point back at the canonical declaration |
| 670 | // of the existing declaration, so that this declaration has the |
| 671 | // appropriate canonical declaration. |
| 672 | ID->RedeclLink = ObjCInterfaceDecl::PreviousDeclLink(ExistingCanon); |
| 673 | |
Douglas Gregor | cce54aa | 2011-12-22 19:44:59 +0000 | [diff] [blame] | 674 | // Don't introduce IDCanon into the set of pending declaration chains. |
| 675 | Redecl.suppress(); |
| 676 | |
| 677 | // Introduce ExistingCanon into the set of pending declaration chains, |
| 678 | // if in fact it came from a module file. |
| 679 | if (ExistingCanon->isFromASTFile()) { |
| 680 | GlobalDeclID ExistingCanonID = Reader.DeclToID[ExistingCanon]; |
| 681 | assert(ExistingCanonID && "Unrecorded canonical declaration ID?"); |
| 682 | if (Reader.PendingDeclChainsKnown.insert(ExistingCanonID)) |
| 683 | Reader.PendingDeclChains.push_back(ExistingCanonID); |
| 684 | } |
| 685 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 686 | // If this declaration was the canonical declaration, make a note of |
Douglas Gregor | c3cfd2a | 2011-12-22 21:40:42 +0000 | [diff] [blame] | 687 | // that. We accept the linear algorithm here because the number of |
| 688 | // unique canonical declarations of an entity should always be tiny. |
| 689 | if (IDCanon == ID) { |
| 690 | SmallVectorImpl<DeclID> &Merged = Reader.MergedDecls[ExistingCanon]; |
| 691 | if (std::find(Merged.begin(), Merged.end(), Redecl.getFirstID()) |
| 692 | == Merged.end()) |
| 693 | Merged.push_back(Redecl.getFirstID()); |
| 694 | } |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 695 | } |
| 696 | } |
| 697 | } |
| 698 | |
Douglas Gregor | 2e5c15b | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 699 | ObjCInterfaceDecl *Def = ReadDeclAs<ObjCInterfaceDecl>(Record, Idx); |
| 700 | if (ID == Def) { |
| 701 | // Read the definition. |
| 702 | ID->allocateDefinitionData(); |
| 703 | |
| 704 | ObjCInterfaceDecl::DefinitionData &Data = ID->data(); |
| 705 | |
| 706 | // Read the superclass. |
| 707 | Data.SuperClass = ReadDeclAs<ObjCInterfaceDecl>(Record, Idx); |
| 708 | Data.SuperClassLoc = ReadSourceLocation(Record, Idx); |
| 709 | |
Douglas Gregor | 05c272f | 2011-12-15 22:34:59 +0000 | [diff] [blame] | 710 | Data.EndLoc = ReadSourceLocation(Record, Idx); |
| 711 | |
Douglas Gregor | 2e5c15b | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 712 | // Read the directly referenced protocols and their SourceLocations. |
| 713 | unsigned NumProtocols = Record[Idx++]; |
| 714 | SmallVector<ObjCProtocolDecl *, 16> Protocols; |
| 715 | Protocols.reserve(NumProtocols); |
| 716 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 717 | Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
| 718 | SmallVector<SourceLocation, 16> ProtoLocs; |
| 719 | ProtoLocs.reserve(NumProtocols); |
| 720 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 721 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
| 722 | ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(), |
| 723 | Reader.getContext()); |
Ted Kremenek | 53b9441 | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 724 | |
Douglas Gregor | 2e5c15b | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 725 | // Read the transitive closure of protocols referenced by this class. |
| 726 | NumProtocols = Record[Idx++]; |
| 727 | Protocols.clear(); |
| 728 | Protocols.reserve(NumProtocols); |
| 729 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 730 | Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
| 731 | ID->data().AllReferencedProtocols.set(Protocols.data(), NumProtocols, |
| 732 | Reader.getContext()); |
Ted Kremenek | 53b9441 | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 733 | |
Douglas Gregor | 2e5c15b | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 734 | // Read the ivars. |
| 735 | unsigned NumIvars = Record[Idx++]; |
| 736 | SmallVector<ObjCIvarDecl *, 16> IVars; |
| 737 | IVars.reserve(NumIvars); |
| 738 | for (unsigned I = 0; I != NumIvars; ++I) |
| 739 | IVars.push_back(ReadDeclAs<ObjCIvarDecl>(Record, Idx)); |
| 740 | |
| 741 | // Read the categories. |
| 742 | ID->setCategoryList(ReadDeclAs<ObjCCategoryDecl>(Record, Idx)); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 743 | |
Douglas Gregor | 2e5c15b | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 744 | // We will rebuild this list lazily. |
| 745 | ID->setIvarList(0); |
| 746 | |
Douglas Gregor | 21cf08b | 2011-12-19 20:51:16 +0000 | [diff] [blame] | 747 | // Note that we have deserialized a definition. |
| 748 | Reader.PendingDefinitions.insert(ID); |
| 749 | } else if (Def && Def->Data) { |
| 750 | ID->Data = Def->Data; |
Douglas Gregor | 2e5c15b | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 751 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 752 | } |
| 753 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 754 | void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 755 | VisitFieldDecl(IVD); |
| 756 | IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]); |
Fariborz Jahanian | 2c18bb7 | 2010-08-20 21:21:08 +0000 | [diff] [blame] | 757 | // This field will be built lazily. |
| 758 | IVD->setNextIvar(0); |
Fariborz Jahanian | ac0021b | 2010-07-17 18:35:47 +0000 | [diff] [blame] | 759 | bool synth = Record[Idx++]; |
| 760 | IVD->setSynthesize(synth); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 761 | } |
| 762 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 763 | void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 764 | VisitObjCContainerDecl(PD); |
Argyrios Kyrtzidis | b05d7b2 | 2011-10-17 19:48:06 +0000 | [diff] [blame] | 765 | PD->InitiallyForwardDecl = Record[Idx++]; |
Argyrios Kyrtzidis | ad834d5 | 2011-11-12 21:07:46 +0000 | [diff] [blame] | 766 | PD->isForwardProtoDecl = Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 767 | PD->setLocEnd(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 768 | unsigned NumProtoRefs = Record[Idx++]; |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 769 | SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 770 | ProtoRefs.reserve(NumProtoRefs); |
| 771 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 772 | ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 773 | SmallVector<SourceLocation, 16> ProtoLocs; |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 774 | ProtoLocs.reserve(NumProtoRefs); |
| 775 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 776 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 777 | PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 778 | Reader.getContext()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 779 | } |
| 780 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 781 | void ASTDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 782 | VisitFieldDecl(FD); |
| 783 | } |
| 784 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 785 | void ASTDeclReader::VisitObjCClassDecl(ObjCClassDecl *CD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 786 | VisitDecl(CD); |
Douglas Gregor | af76472 | 2011-12-14 17:12:03 +0000 | [diff] [blame] | 787 | CD->Interface = ReadDeclAs<ObjCInterfaceDecl>(Record, Idx); |
| 788 | CD->InterfaceLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 789 | } |
| 790 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 791 | void ASTDeclReader::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *FPD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 792 | VisitDecl(FPD); |
| 793 | unsigned NumProtoRefs = Record[Idx++]; |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 794 | SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 795 | ProtoRefs.reserve(NumProtoRefs); |
| 796 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 797 | ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 798 | SmallVector<SourceLocation, 16> ProtoLocs; |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 799 | ProtoLocs.reserve(NumProtoRefs); |
| 800 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 801 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 802 | FPD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 803 | Reader.getContext()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 804 | } |
| 805 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 806 | void ASTDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 807 | VisitObjCContainerDecl(CD); |
Argyrios Kyrtzidis | 955fadb | 2011-08-30 19:43:26 +0000 | [diff] [blame] | 808 | CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>(Record, Idx); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 809 | unsigned NumProtoRefs = Record[Idx++]; |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 810 | SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 811 | ProtoRefs.reserve(NumProtoRefs); |
| 812 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 813 | ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx)); |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 814 | SmallVector<SourceLocation, 16> ProtoLocs; |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 815 | ProtoLocs.reserve(NumProtoRefs); |
| 816 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 817 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 818 | CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 819 | Reader.getContext()); |
Argyrios Kyrtzidis | 955fadb | 2011-08-30 19:43:26 +0000 | [diff] [blame] | 820 | CD->NextClassCategory = ReadDeclAs<ObjCCategoryDecl>(Record, Idx); |
Fariborz Jahanian | 000835d | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 821 | CD->setHasSynthBitfield(Record[Idx++]); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 822 | CD->setCategoryNameLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 823 | } |
| 824 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 825 | void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 826 | VisitNamedDecl(CAD); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 827 | CAD->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 828 | } |
| 829 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 830 | void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 831 | VisitNamedDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 832 | D->setAtLoc(ReadSourceLocation(Record, Idx)); |
| 833 | D->setType(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 834 | // FIXME: stable encoding |
| 835 | D->setPropertyAttributes( |
| 836 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Fariborz Jahanian | 80aa1cd | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 837 | D->setPropertyAttributesAsWritten( |
| 838 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 839 | // FIXME: stable encoding |
| 840 | D->setPropertyImplementation( |
| 841 | (ObjCPropertyDecl::PropertyControl)Record[Idx++]); |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 842 | D->setGetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector()); |
| 843 | D->setSetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector()); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 844 | D->setGetterMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx)); |
| 845 | D->setSetterMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx)); |
| 846 | D->setPropertyIvarDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 847 | } |
| 848 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 849 | void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) { |
Argyrios Kyrtzidis | aecae62 | 2009-07-27 19:04:32 +0000 | [diff] [blame] | 850 | VisitObjCContainerDecl(D); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 851 | D->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 852 | } |
| 853 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 854 | void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 855 | VisitObjCImplDecl(D); |
Douglas Gregor | 95eab17 | 2011-07-28 20:55:49 +0000 | [diff] [blame] | 856 | D->setIdentifier(Reader.GetIdentifierInfo(F, Record, Idx)); |
Argyrios Kyrtzidis | c699400 | 2011-12-09 00:31:40 +0000 | [diff] [blame] | 857 | D->CategoryNameLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 858 | } |
| 859 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 860 | void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 861 | VisitObjCImplDecl(D); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 862 | D->setSuperClass(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx)); |
Argyrios Kyrtzidis | 9d50c06 | 2010-08-09 10:54:20 +0000 | [diff] [blame] | 863 | llvm::tie(D->IvarInitializers, D->NumIvarInitializers) |
Sean Hunt | cbb6748 | 2011-01-08 20:30:50 +0000 | [diff] [blame] | 864 | = Reader.ReadCXXCtorInitializers(F, Record, Idx); |
Fariborz Jahanian | 000835d | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 865 | D->setHasSynthBitfield(Record[Idx++]); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 866 | } |
| 867 | |
| 868 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 869 | void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 870 | VisitDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 871 | D->setAtLoc(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 872 | D->setPropertyDecl(ReadDeclAs<ObjCPropertyDecl>(Record, Idx)); |
| 873 | D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>(Record, Idx); |
Douglas Gregor | a4ffd85 | 2010-11-17 01:03:52 +0000 | [diff] [blame] | 874 | D->IvarLoc = ReadSourceLocation(Record, Idx); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 875 | D->setGetterCXXConstructor(Reader.ReadExpr(F)); |
| 876 | D->setSetterCXXAssignment(Reader.ReadExpr(F)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 877 | } |
| 878 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 879 | void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 880 | VisitDeclaratorDecl(FD); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 881 | FD->setMutable(Record[Idx++]); |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 882 | int BitWidthOrInitializer = Record[Idx++]; |
| 883 | if (BitWidthOrInitializer == 1) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 884 | FD->setBitWidth(Reader.ReadExpr(F)); |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 885 | else if (BitWidthOrInitializer == 2) |
| 886 | FD->setInClassInitializer(Reader.ReadExpr(F)); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 887 | if (!FD->getDeclName()) { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 888 | if (FieldDecl *Tmpl = ReadDeclAs<FieldDecl>(Record, Idx)) |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 889 | Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 890 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 891 | } |
| 892 | |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 893 | void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) { |
| 894 | VisitValueDecl(FD); |
| 895 | |
| 896 | FD->ChainingSize = Record[Idx++]; |
| 897 | assert(FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2"); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 898 | FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize]; |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 899 | |
| 900 | for (unsigned I = 0; I != FD->ChainingSize; ++I) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 901 | FD->Chaining[I] = ReadDeclAs<NamedDecl>(Record, Idx); |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 902 | } |
| 903 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 904 | void ASTDeclReader::VisitVarDecl(VarDecl *VD) { |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 905 | VisitRedeclarable(VD); |
Douglas Gregor | d488b3a | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 906 | VisitDeclaratorDecl(VD); |
John McCall | f1e4fbf | 2011-05-01 02:13:58 +0000 | [diff] [blame] | 907 | VD->VarDeclBits.SClass = (StorageClass)Record[Idx++]; |
| 908 | VD->VarDeclBits.SClassAsWritten = (StorageClass)Record[Idx++]; |
| 909 | VD->VarDeclBits.ThreadSpecified = Record[Idx++]; |
| 910 | VD->VarDeclBits.HasCXXDirectInit = Record[Idx++]; |
| 911 | VD->VarDeclBits.ExceptionVar = Record[Idx++]; |
| 912 | VD->VarDeclBits.NRVOVariable = Record[Idx++]; |
| 913 | VD->VarDeclBits.CXXForRangeDecl = Record[Idx++]; |
John McCall | 7acddac | 2011-06-17 06:42:21 +0000 | [diff] [blame] | 914 | VD->VarDeclBits.ARCPseudoStrong = Record[Idx++]; |
Richard Smith | 099e7f6 | 2011-12-19 06:19:21 +0000 | [diff] [blame] | 915 | if (uint64_t Val = Record[Idx++]) { |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 916 | VD->setInit(Reader.ReadExpr(F)); |
Richard Smith | 099e7f6 | 2011-12-19 06:19:21 +0000 | [diff] [blame] | 917 | if (Val > 1) { |
| 918 | EvaluatedStmt *Eval = VD->ensureEvaluatedStmt(); |
| 919 | Eval->CheckedICE = true; |
| 920 | Eval->IsICE = Val == 3; |
| 921 | } |
| 922 | } |
Argyrios Kyrtzidis | 9421adc | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 923 | |
| 924 | if (Record[Idx++]) { // HasMemberSpecializationInfo. |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 925 | VarDecl *Tmpl = ReadDeclAs<VarDecl>(Record, Idx); |
Argyrios Kyrtzidis | 9421adc | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 926 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 927 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 928 | Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI); |
Argyrios Kyrtzidis | 9421adc | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 929 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 930 | } |
| 931 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 932 | void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 933 | VisitVarDecl(PD); |
| 934 | } |
| 935 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 936 | void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 937 | VisitVarDecl(PD); |
John McCall | 7079886 | 2011-05-02 00:30:12 +0000 | [diff] [blame] | 938 | unsigned isObjCMethodParam = Record[Idx++]; |
| 939 | unsigned scopeDepth = Record[Idx++]; |
| 940 | unsigned scopeIndex = Record[Idx++]; |
| 941 | unsigned declQualifier = Record[Idx++]; |
| 942 | if (isObjCMethodParam) { |
| 943 | assert(scopeDepth == 0); |
| 944 | PD->setObjCMethodScopeInfo(scopeIndex); |
| 945 | PD->ParmVarDeclBits.ScopeDepthOrObjCQuals = declQualifier; |
| 946 | } else { |
| 947 | PD->setScopeInfo(scopeDepth, scopeIndex); |
| 948 | } |
John McCall | f1e4fbf | 2011-05-01 02:13:58 +0000 | [diff] [blame] | 949 | PD->ParmVarDeclBits.IsKNRPromoted = Record[Idx++]; |
| 950 | PD->ParmVarDeclBits.HasInheritedDefaultArg = Record[Idx++]; |
Argyrios Kyrtzidis | 691d77f | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 951 | if (Record[Idx++]) // hasUninstantiatedDefaultArg. |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 952 | PD->setUninstantiatedDefaultArg(Reader.ReadExpr(F)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 953 | } |
| 954 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 955 | void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 956 | VisitDecl(AD); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 957 | AD->setAsmString(cast<StringLiteral>(Reader.ReadExpr(F))); |
Abramo Bagnara | 21e006e | 2011-03-03 14:20:18 +0000 | [diff] [blame] | 958 | AD->setRParenLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 959 | } |
| 960 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 961 | void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 962 | VisitDecl(BD); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 963 | BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(F))); |
| 964 | BD->setSignatureAsWritten(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 965 | unsigned NumParams = Record[Idx++]; |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 966 | SmallVector<ParmVarDecl *, 16> Params; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 967 | Params.reserve(NumParams); |
| 968 | for (unsigned I = 0; I != NumParams; ++I) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 969 | Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx)); |
David Blaikie | 4278c65 | 2011-09-21 18:16:56 +0000 | [diff] [blame] | 970 | BD->setParams(Params); |
John McCall | 469a1eb | 2011-02-02 13:00:07 +0000 | [diff] [blame] | 971 | |
| 972 | bool capturesCXXThis = Record[Idx++]; |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 973 | unsigned numCaptures = Record[Idx++]; |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 974 | SmallVector<BlockDecl::Capture, 16> captures; |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 975 | captures.reserve(numCaptures); |
| 976 | for (unsigned i = 0; i != numCaptures; ++i) { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 977 | VarDecl *decl = ReadDeclAs<VarDecl>(Record, Idx); |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 978 | unsigned flags = Record[Idx++]; |
| 979 | bool byRef = (flags & 1); |
| 980 | bool nested = (flags & 2); |
| 981 | Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) : 0); |
| 982 | |
| 983 | captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr)); |
| 984 | } |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 985 | BD->setCaptures(Reader.getContext(), captures.begin(), |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 986 | captures.end(), capturesCXXThis); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 987 | } |
| 988 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 989 | void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 990 | VisitDecl(D); |
| 991 | D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]); |
Abramo Bagnara | a2026c9 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 992 | D->setExternLoc(ReadSourceLocation(Record, Idx)); |
Abramo Bagnara | 5f6bcbe | 2011-03-03 14:52:38 +0000 | [diff] [blame] | 993 | D->setRBraceLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 994 | } |
| 995 | |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 996 | void ASTDeclReader::VisitLabelDecl(LabelDecl *D) { |
| 997 | VisitNamedDecl(D); |
Abramo Bagnara | 6784304 | 2011-03-05 18:21:20 +0000 | [diff] [blame] | 998 | D->setLocStart(ReadSourceLocation(Record, Idx)); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1002 | void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1003 | VisitNamedDecl(D); |
Douglas Gregor | 0a0c3e7 | 2010-10-05 20:41:58 +0000 | [diff] [blame] | 1004 | D->IsInline = Record[Idx++]; |
Abramo Bagnara | acba90f | 2011-03-08 12:38:20 +0000 | [diff] [blame] | 1005 | D->LocStart = ReadSourceLocation(Record, Idx); |
| 1006 | D->RBraceLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 06c9193 | 2010-10-27 19:49:05 +0000 | [diff] [blame] | 1007 | D->NextNamespace = Record[Idx++]; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1008 | |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1009 | bool IsOriginal = Record[Idx++]; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1010 | // FIXME: Modules will likely have trouble with pointing directly at |
| 1011 | // the original namespace. |
Argyrios Kyrtzidis | a038c1d | 2010-07-03 07:57:53 +0000 | [diff] [blame] | 1012 | D->OrigOrAnonNamespace.setInt(IsOriginal); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1013 | D->OrigOrAnonNamespace.setPointer(ReadDeclAs<NamespaceDecl>(Record, Idx)); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1014 | } |
| 1015 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1016 | void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1017 | VisitNamedDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1018 | D->NamespaceLoc = ReadSourceLocation(Record, Idx); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1019 | D->IdentLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | 0cfaf6a | 2011-02-25 17:08:07 +0000 | [diff] [blame] | 1020 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1021 | D->Namespace = ReadDeclAs<NamedDecl>(Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1024 | void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1025 | VisitNamedDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1026 | D->setUsingLocation(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1027 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1028 | ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1029 | D->FirstUsingShadow = ReadDeclAs<UsingShadowDecl>(Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1030 | D->setTypeName(Record[Idx++]); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1031 | if (NamedDecl *Pattern = ReadDeclAs<NamedDecl>(Record, Idx)) |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1032 | Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1033 | } |
| 1034 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1035 | void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1036 | VisitNamedDecl(D); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1037 | D->setTargetDecl(ReadDeclAs<NamedDecl>(Record, Idx)); |
| 1038 | D->UsingOrNextShadow = ReadDeclAs<NamedDecl>(Record, Idx); |
| 1039 | UsingShadowDecl *Pattern = ReadDeclAs<UsingShadowDecl>(Record, Idx); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 1040 | if (Pattern) |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1041 | Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1042 | } |
| 1043 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1044 | void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1045 | VisitNamedDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1046 | D->UsingLoc = ReadSourceLocation(Record, Idx); |
| 1047 | D->NamespaceLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | db99241 | 2011-02-25 16:33:46 +0000 | [diff] [blame] | 1048 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1049 | D->NominatedNamespace = ReadDeclAs<NamedDecl>(Record, Idx); |
| 1050 | D->CommonAncestor = ReadDeclAs<DeclContext>(Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1051 | } |
| 1052 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1053 | void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1054 | VisitValueDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1055 | D->setUsingLoc(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1056 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1057 | ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1058 | } |
| 1059 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1060 | void ASTDeclReader::VisitUnresolvedUsingTypenameDecl( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1061 | UnresolvedUsingTypenameDecl *D) { |
| 1062 | VisitTypeDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1063 | D->TypenameLocation = ReadSourceLocation(Record, Idx); |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1064 | D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1065 | } |
| 1066 | |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1067 | void ASTDeclReader::ReadCXXDefinitionData( |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 1068 | struct CXXRecordDecl::DefinitionData &Data, |
| 1069 | const RecordData &Record, unsigned &Idx) { |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1070 | Data.UserDeclaredConstructor = Record[Idx++]; |
| 1071 | Data.UserDeclaredCopyConstructor = Record[Idx++]; |
Douglas Gregor | 58e9797 | 2011-09-06 16:38:46 +0000 | [diff] [blame] | 1072 | Data.UserDeclaredMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1073 | Data.UserDeclaredCopyAssignment = Record[Idx++]; |
Douglas Gregor | 58e9797 | 2011-09-06 16:38:46 +0000 | [diff] [blame] | 1074 | Data.UserDeclaredMoveAssignment = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1075 | Data.UserDeclaredDestructor = Record[Idx++]; |
| 1076 | Data.Aggregate = Record[Idx++]; |
| 1077 | Data.PlainOldData = Record[Idx++]; |
| 1078 | Data.Empty = Record[Idx++]; |
| 1079 | Data.Polymorphic = Record[Idx++]; |
| 1080 | Data.Abstract = Record[Idx++]; |
Chandler Carruth | ec997dc | 2011-04-30 10:07:30 +0000 | [diff] [blame] | 1081 | Data.IsStandardLayout = Record[Idx++]; |
Chandler Carruth | a822544 | 2011-04-30 09:17:45 +0000 | [diff] [blame] | 1082 | Data.HasNoNonEmptyBases = Record[Idx++]; |
| 1083 | Data.HasPrivateFields = Record[Idx++]; |
| 1084 | Data.HasProtectedFields = Record[Idx++]; |
| 1085 | Data.HasPublicFields = Record[Idx++]; |
Douglas Gregor | 2bb1101 | 2011-05-13 01:05:07 +0000 | [diff] [blame] | 1086 | Data.HasMutableFields = Record[Idx++]; |
Sean Hunt | 023df37 | 2011-05-09 18:22:59 +0000 | [diff] [blame] | 1087 | Data.HasTrivialDefaultConstructor = Record[Idx++]; |
Richard Smith | 6b8bc07 | 2011-08-10 18:11:37 +0000 | [diff] [blame] | 1088 | Data.HasConstexprNonCopyMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1089 | Data.HasTrivialCopyConstructor = Record[Idx++]; |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1090 | Data.HasTrivialMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1091 | Data.HasTrivialCopyAssignment = Record[Idx++]; |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1092 | Data.HasTrivialMoveAssignment = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1093 | Data.HasTrivialDestructor = Record[Idx++]; |
Chandler Carruth | 9b6347c | 2011-04-24 02:49:34 +0000 | [diff] [blame] | 1094 | Data.HasNonLiteralTypeFieldsOrBases = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1095 | Data.ComputedVisibleConversions = Record[Idx++]; |
Sean Hunt | cdee3fe | 2011-05-11 22:34:38 +0000 | [diff] [blame] | 1096 | Data.UserProvidedDefaultConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1097 | Data.DeclaredDefaultConstructor = Record[Idx++]; |
| 1098 | Data.DeclaredCopyConstructor = Record[Idx++]; |
Douglas Gregor | 58e9797 | 2011-09-06 16:38:46 +0000 | [diff] [blame] | 1099 | Data.DeclaredMoveConstructor = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1100 | Data.DeclaredCopyAssignment = Record[Idx++]; |
Douglas Gregor | 58e9797 | 2011-09-06 16:38:46 +0000 | [diff] [blame] | 1101 | Data.DeclaredMoveAssignment = Record[Idx++]; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1102 | Data.DeclaredDestructor = Record[Idx++]; |
Sebastian Redl | 14c3633 | 2011-08-31 13:59:56 +0000 | [diff] [blame] | 1103 | Data.FailedImplicitMoveConstructor = Record[Idx++]; |
| 1104 | Data.FailedImplicitMoveAssignment = Record[Idx++]; |
Anders Carlsson | faa6afd | 2011-01-22 18:11:02 +0000 | [diff] [blame] | 1105 | |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1106 | Data.NumBases = Record[Idx++]; |
Douglas Gregor | 7c789c1 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 1107 | if (Data.NumBases) |
Douglas Gregor | e92b8a1 | 2011-08-04 00:01:48 +0000 | [diff] [blame] | 1108 | Data.Bases = Reader.readCXXBaseSpecifiers(F, Record, Idx); |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1109 | Data.NumVBases = Record[Idx++]; |
Douglas Gregor | 7c789c1 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 1110 | if (Data.NumVBases) |
Douglas Gregor | e92b8a1 | 2011-08-04 00:01:48 +0000 | [diff] [blame] | 1111 | Data.VBases = Reader.readCXXBaseSpecifiers(F, Record, Idx); |
Douglas Gregor | 7c789c1 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 1112 | |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1113 | Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx); |
| 1114 | Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx); |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1115 | assert(Data.Definition && "Data.Definition should be already set!"); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1116 | Data.FirstFriend = ReadDeclAs<FriendDecl>(Record, Idx); |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 1117 | } |
| 1118 | |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 1119 | void ASTDeclReader::InitializeCXXDefinitionData(CXXRecordDecl *D, |
| 1120 | CXXRecordDecl *DefinitionDecl, |
| 1121 | const RecordData &Record, |
| 1122 | unsigned &Idx) { |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1123 | ASTContext &C = Reader.getContext(); |
Argyrios Kyrtzidis | 9703b0d | 2010-10-20 00:11:15 +0000 | [diff] [blame] | 1124 | |
Argyrios Kyrtzidis | 134db1f | 2010-10-24 17:26:31 +0000 | [diff] [blame] | 1125 | if (D == DefinitionDecl) { |
| 1126 | D->DefinitionData = new (C) struct CXXRecordDecl::DefinitionData(D); |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 1127 | ReadCXXDefinitionData(*D->DefinitionData, Record, Idx); |
Douglas Gregor | 21cf08b | 2011-12-19 20:51:16 +0000 | [diff] [blame] | 1128 | |
Douglas Gregor | fc529f7 | 2011-12-19 19:00:47 +0000 | [diff] [blame] | 1129 | // Note that we have deserialized a definition. |
| 1130 | Reader.PendingDefinitions.insert(D); |
Douglas Gregor | 21cf08b | 2011-12-19 20:51:16 +0000 | [diff] [blame] | 1131 | } else if (DefinitionDecl && DefinitionDecl->DefinitionData) { |
| 1132 | D->DefinitionData = DefinitionDecl->DefinitionData; |
Argyrios Kyrtzidis | 37ffed3 | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 1133 | } |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) { |
| 1137 | VisitRecordDecl(D); |
| 1138 | |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1139 | CXXRecordDecl *DefinitionDecl = ReadDeclAs<CXXRecordDecl>(Record, Idx); |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 1140 | InitializeCXXDefinitionData(D, DefinitionDecl, Record, Idx); |
| 1141 | |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1142 | ASTContext &C = Reader.getContext(); |
Argyrios Kyrtzidis | 37ffed3 | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 1143 | |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1144 | enum CXXRecKind { |
| 1145 | CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization |
| 1146 | }; |
| 1147 | switch ((CXXRecKind)Record[Idx++]) { |
| 1148 | default: |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 1149 | llvm_unreachable("Out of sync with ASTDeclWriter::VisitCXXRecordDecl?"); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1150 | case CXXRecNotTemplate: |
| 1151 | break; |
| 1152 | case CXXRecTemplate: |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1153 | D->TemplateOrInstantiation = ReadDeclAs<ClassTemplateDecl>(Record, Idx); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1154 | break; |
| 1155 | case CXXRecMemberSpecialization: { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1156 | CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(Record, Idx); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1157 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1158 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 8b996b8 | 2010-09-13 11:45:25 +0000 | [diff] [blame] | 1159 | MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK); |
| 1160 | MSI->setPointOfInstantiation(POI); |
| 1161 | D->TemplateOrInstantiation = MSI; |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1162 | break; |
| 1163 | } |
| 1164 | } |
Argyrios Kyrtzidis | 36d2fd4 | 2010-10-14 20:14:38 +0000 | [diff] [blame] | 1165 | |
| 1166 | // Load the key function to avoid deserializing every method so we can |
| 1167 | // compute it. |
John McCall | 5e1cdac | 2011-10-07 06:10:15 +0000 | [diff] [blame] | 1168 | if (D->IsCompleteDefinition) { |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1169 | if (CXXMethodDecl *Key = ReadDeclAs<CXXMethodDecl>(Record, Idx)) |
Argyrios Kyrtzidis | 36d2fd4 | 2010-10-14 20:14:38 +0000 | [diff] [blame] | 1170 | C.KeyFunctions[D] = Key; |
| 1171 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1172 | } |
| 1173 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1174 | void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1175 | VisitFunctionDecl(D); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 1176 | unsigned NumOverridenMethods = Record[Idx++]; |
| 1177 | while (NumOverridenMethods--) { |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 1178 | // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod, |
| 1179 | // MD may be initializing. |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1180 | if (CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>(Record, Idx)) |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1181 | Reader.getContext().addOverriddenMethod(D, MD); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 1182 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1183 | } |
| 1184 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1185 | void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1186 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1187 | |
| 1188 | D->IsExplicitSpecified = Record[Idx++]; |
| 1189 | D->ImplicitlyDefined = Record[Idx++]; |
Sean Hunt | cbb6748 | 2011-01-08 20:30:50 +0000 | [diff] [blame] | 1190 | llvm::tie(D->CtorInitializers, D->NumCtorInitializers) |
| 1191 | = Reader.ReadCXXCtorInitializers(F, Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1192 | } |
| 1193 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1194 | void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1195 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1196 | |
| 1197 | D->ImplicitlyDefined = Record[Idx++]; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1198 | D->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1199 | } |
| 1200 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1201 | void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1202 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1203 | D->IsExplicitSpecified = Record[Idx++]; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1204 | } |
| 1205 | |
Douglas Gregor | 15de72c | 2011-12-02 23:23:56 +0000 | [diff] [blame] | 1206 | void ASTDeclReader::VisitImportDecl(ImportDecl *D) { |
| 1207 | VisitDecl(D); |
| 1208 | D->ImportedAndComplete.setPointer(readModule(Record, Idx)); |
| 1209 | D->ImportedAndComplete.setInt(Record[Idx++]); |
| 1210 | SourceLocation *StoredLocs = reinterpret_cast<SourceLocation *>(D + 1); |
| 1211 | for (unsigned I = 0, N = Record.back(); I != N; ++I) |
| 1212 | StoredLocs[I] = ReadSourceLocation(Record, Idx); |
| 1213 | ++Idx; |
| 1214 | } |
| 1215 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1216 | void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) { |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1217 | VisitDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1218 | D->setColonLoc(ReadSourceLocation(Record, Idx)); |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1219 | } |
| 1220 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1221 | void ASTDeclReader::VisitFriendDecl(FriendDecl *D) { |
Argyrios Kyrtzidis | c8f9af2 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 1222 | VisitDecl(D); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1223 | if (Record[Idx++]) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1224 | D->Friend = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1225 | else |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1226 | D->Friend = ReadDeclAs<NamedDecl>(Record, Idx); |
Douglas Gregor | 69aecc6 | 2010-10-27 20:23:41 +0000 | [diff] [blame] | 1227 | D->NextFriend = Record[Idx++]; |
John McCall | 6102ca1 | 2010-10-16 06:59:13 +0000 | [diff] [blame] | 1228 | D->UnsupportedFriend = (Record[Idx++] != 0); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1229 | D->FriendLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1230 | } |
| 1231 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1232 | void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { |
Argyrios Kyrtzidis | 554e6aa | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1233 | VisitDecl(D); |
| 1234 | unsigned NumParams = Record[Idx++]; |
| 1235 | D->NumParams = NumParams; |
| 1236 | D->Params = new TemplateParameterList*[NumParams]; |
| 1237 | for (unsigned i = 0; i != NumParams; ++i) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1238 | D->Params[i] = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 554e6aa | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1239 | if (Record[Idx++]) // HasFriendDecl |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1240 | D->Friend = ReadDeclAs<NamedDecl>(Record, Idx); |
Argyrios Kyrtzidis | 554e6aa | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1241 | else |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1242 | D->Friend = GetTypeSourceInfo(Record, Idx); |
| 1243 | D->FriendLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1244 | } |
| 1245 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1246 | void ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) { |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1247 | VisitNamedDecl(D); |
| 1248 | |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1249 | NamedDecl *TemplatedDecl = ReadDeclAs<NamedDecl>(Record, Idx); |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1250 | TemplateParameterList* TemplateParams |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1251 | = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1252 | D->init(TemplatedDecl, TemplateParams); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1255 | void ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1256 | // Initialize CommonOrPrev before VisitTemplateDecl so that getCommonPtr() |
| 1257 | // can be used while this is still initializing. |
Douglas Gregor | fc529f7 | 2011-12-19 19:00:47 +0000 | [diff] [blame] | 1258 | enum RedeclKind { FirstDeclaration, FirstInFile, PointsToPrevious }; |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1259 | RedeclKind Kind = (RedeclKind)Record[Idx++]; |
| 1260 | |
| 1261 | // Determine the first declaration ID. |
| 1262 | DeclID FirstDeclID; |
| 1263 | switch (Kind) { |
| 1264 | case FirstDeclaration: { |
| 1265 | FirstDeclID = ThisDeclID; |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1266 | |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1267 | // Since this is the first declaration of the template, fill in the |
| 1268 | // information for the 'common' pointer. |
| 1269 | if (D->CommonOrPrev.isNull()) { |
| 1270 | RedeclarableTemplateDecl::CommonBase *Common |
| 1271 | = D->newCommon(Reader.getContext()); |
| 1272 | Common->Latest = D; |
| 1273 | D->CommonOrPrev = Common; |
| 1274 | } |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 1275 | |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1276 | if (RedeclarableTemplateDecl *RTD |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 1277 | = ReadDeclAs<RedeclarableTemplateDecl>(Record, Idx)) { |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1278 | assert(RTD->getKind() == D->getKind() && |
| 1279 | "InstantiatedFromMemberTemplate kind mismatch"); |
| 1280 | D->setInstantiatedFromMemberTemplateImpl(RTD); |
| 1281 | if (Record[Idx++]) |
| 1282 | D->setMemberSpecialization(); |
| 1283 | } |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1284 | break; |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1285 | } |
Douglas Gregor | fc529f7 | 2011-12-19 19:00:47 +0000 | [diff] [blame] | 1286 | |
| 1287 | case FirstInFile: |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1288 | case PointsToPrevious: { |
| 1289 | FirstDeclID = ReadDeclID(Record, Idx); |
| 1290 | DeclID PrevDeclID = ReadDeclID(Record, Idx); |
| 1291 | |
| 1292 | RedeclarableTemplateDecl *FirstDecl |
| 1293 | = cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(FirstDeclID)); |
| 1294 | |
| 1295 | // We delay loading of the redeclaration chain to avoid deeply nested calls. |
| 1296 | // We temporarily set the first (canonical) declaration as the previous one |
| 1297 | // which is the one that matters and mark the real previous DeclID to be |
| 1298 | // loaded and attached later on. |
| 1299 | D->CommonOrPrev = FirstDecl; |
| 1300 | |
Douglas Gregor | fc529f7 | 2011-12-19 19:00:47 +0000 | [diff] [blame] | 1301 | if (Kind == PointsToPrevious) { |
| 1302 | // Make a note that we need to wire up this declaration to its |
| 1303 | // previous declaration, later. We don't need to do this for the first |
| 1304 | // declaration in any given module file, because those will be wired |
| 1305 | // together later. |
| 1306 | Reader.PendingPreviousDecls.push_back(std::make_pair(D, PrevDeclID)); |
| 1307 | } |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1308 | break; |
| 1309 | } |
| 1310 | } |
| 1311 | |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1312 | VisitTemplateDecl(D); |
| 1313 | D->IdentifierNamespace = Record[Idx++]; |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1314 | } |
| 1315 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1316 | void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1317 | VisitRedeclarableTemplateDecl(D); |
| 1318 | |
| 1319 | if (D->getPreviousDeclaration() == 0) { |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1320 | // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of |
| 1321 | // the specializations. |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 1322 | SmallVector<serialization::DeclID, 2> SpecIDs; |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1323 | SpecIDs.push_back(0); |
| 1324 | |
| 1325 | // Specializations. |
| 1326 | unsigned Size = Record[Idx++]; |
| 1327 | SpecIDs[0] += Size; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1328 | for (unsigned I = 0; I != Size; ++I) |
| 1329 | SpecIDs.push_back(ReadDeclID(Record, Idx)); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1330 | |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1331 | // Partial specializations. |
| 1332 | Size = Record[Idx++]; |
| 1333 | SpecIDs[0] += Size; |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1334 | for (unsigned I = 0; I != Size; ++I) |
| 1335 | SpecIDs.push_back(ReadDeclID(Record, Idx)); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1336 | |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1337 | if (SpecIDs[0]) { |
| 1338 | typedef serialization::DeclID DeclID; |
| 1339 | |
| 1340 | ClassTemplateDecl::Common *CommonPtr = D->getCommonPtr(); |
| 1341 | CommonPtr->LazySpecializations |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1342 | = new (Reader.getContext()) DeclID [SpecIDs.size()]; |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1343 | memcpy(CommonPtr->LazySpecializations, SpecIDs.data(), |
| 1344 | SpecIDs.size() * sizeof(DeclID)); |
| 1345 | } |
| 1346 | |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1347 | // InjectedClassNameType is computed. |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1348 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1349 | } |
| 1350 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1351 | void ASTDeclReader::VisitClassTemplateSpecializationDecl( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1352 | ClassTemplateSpecializationDecl *D) { |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1353 | VisitCXXRecordDecl(D); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1354 | |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1355 | ASTContext &C = Reader.getContext(); |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1356 | if (Decl *InstD = ReadDecl(Record, Idx)) { |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1357 | if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) { |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1358 | D->SpecializedTemplate = CTD; |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1359 | } else { |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 1360 | SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1361 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1362 | TemplateArgumentList *ArgList |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 1363 | = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), |
| 1364 | TemplArgs.size()); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1365 | ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS |
| 1366 | = new (C) ClassTemplateSpecializationDecl:: |
| 1367 | SpecializedPartialSpecialization(); |
| 1368 | PS->PartialSpecialization |
| 1369 | = cast<ClassTemplatePartialSpecializationDecl>(InstD); |
| 1370 | PS->TemplateArgs = ArgList; |
| 1371 | D->SpecializedTemplate = PS; |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1372 | } |
| 1373 | } |
| 1374 | |
| 1375 | // Explicit info. |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1376 | if (TypeSourceInfo *TyInfo = GetTypeSourceInfo(Record, Idx)) { |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1377 | ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo |
| 1378 | = new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo; |
| 1379 | ExplicitInfo->TypeAsWritten = TyInfo; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1380 | ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx); |
| 1381 | ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1382 | D->ExplicitInfo = ExplicitInfo; |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1383 | } |
| 1384 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 1385 | SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1386 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 1387 | D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), |
| 1388 | TemplArgs.size()); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1389 | D->PointOfInstantiation = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 586c715 | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1390 | D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++]; |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1391 | |
Argyrios Kyrtzidis | bc5ab7c | 2010-07-20 13:59:40 +0000 | [diff] [blame] | 1392 | if (D->isCanonicalDecl()) { // It's kept in the folding set. |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1393 | ClassTemplateDecl *CanonPattern = ReadDeclAs<ClassTemplateDecl>(Record,Idx); |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1394 | if (ClassTemplatePartialSpecializationDecl *Partial |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1395 | = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) { |
| 1396 | CanonPattern->getCommonPtr()->PartialSpecializations.InsertNode(Partial); |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1397 | } else { |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 1398 | CanonPattern->getCommonPtr()->Specializations.InsertNode(D); |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1399 | } |
| 1400 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1401 | } |
| 1402 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1403 | void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1404 | ClassTemplatePartialSpecializationDecl *D) { |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1405 | VisitClassTemplateSpecializationDecl(D); |
| 1406 | |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1407 | ASTContext &C = Reader.getContext(); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1408 | D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1409 | |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1410 | unsigned NumArgs = Record[Idx++]; |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1411 | if (NumArgs) { |
| 1412 | D->NumArgsAsWritten = NumArgs; |
| 1413 | D->ArgsAsWritten = new (C) TemplateArgumentLoc[NumArgs]; |
| 1414 | for (unsigned i=0; i != NumArgs; ++i) |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1415 | D->ArgsAsWritten[i] = Reader.ReadTemplateArgumentLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1416 | } |
| 1417 | |
| 1418 | D->SequenceNumber = Record[Idx++]; |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1419 | |
| 1420 | // These are read/set from/to the first declaration. |
| 1421 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1422 | D->InstantiatedFromMember.setPointer( |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1423 | ReadDeclAs<ClassTemplatePartialSpecializationDecl>(Record, Idx)); |
Argyrios Kyrtzidis | 8fed4b4 | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1424 | D->InstantiatedFromMember.setInt(Record[Idx++]); |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1425 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1426 | } |
| 1427 | |
Sebastian Redl | 14c3633 | 2011-08-31 13:59:56 +0000 | [diff] [blame] | 1428 | void ASTDeclReader::VisitClassScopeFunctionSpecializationDecl( |
| 1429 | ClassScopeFunctionSpecializationDecl *D) { |
Francois Pichet | bc84532 | 2011-08-17 01:06:54 +0000 | [diff] [blame] | 1430 | VisitDecl(D); |
| 1431 | D->Specialization = ReadDeclAs<CXXMethodDecl>(Record, Idx); |
| 1432 | } |
| 1433 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1434 | void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1435 | VisitRedeclarableTemplateDecl(D); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1436 | |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1437 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1438 | // This FunctionTemplateDecl owns a CommonPtr; read it. |
| 1439 | |
Argyrios Kyrtzidis | 057d9af | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1440 | // Read the function specialization declarations. |
| 1441 | // FunctionTemplateDecl's FunctionTemplateSpecializationInfos are filled |
Argyrios Kyrtzidis | 99a8ca0 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 1442 | // when reading the specialized FunctionDecl. |
Argyrios Kyrtzidis | 057d9af | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1443 | unsigned NumSpecs = Record[Idx++]; |
| 1444 | while (NumSpecs--) |
Douglas Gregor | 409448c | 2011-07-21 22:35:25 +0000 | [diff] [blame] | 1445 | (void)ReadDecl(Record, Idx); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1446 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1447 | } |
| 1448 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1449 | void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1450 | VisitTypeDecl(D); |
| 1451 | |
| 1452 | D->setDeclaredWithTypename(Record[Idx++]); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1453 | |
| 1454 | bool Inherited = Record[Idx++]; |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1455 | TypeSourceInfo *DefArg = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1456 | D->setDefaultArgument(DefArg, Inherited); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1457 | } |
| 1458 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1459 | void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { |
John McCall | 76a4021 | 2011-02-09 01:13:10 +0000 | [diff] [blame] | 1460 | VisitDeclaratorDecl(D); |
Argyrios Kyrtzidis | b24e199 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1461 | // TemplateParmPosition. |
| 1462 | D->setDepth(Record[Idx++]); |
| 1463 | D->setPosition(Record[Idx++]); |
Douglas Gregor | 6952f1e | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1464 | if (D->isExpandedParameterPack()) { |
| 1465 | void **Data = reinterpret_cast<void **>(D + 1); |
| 1466 | for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) { |
Douglas Gregor | 393f249 | 2011-07-22 00:38:23 +0000 | [diff] [blame] | 1467 | Data[2*I] = Reader.readType(F, Record, Idx).getAsOpaquePtr(); |
Douglas Gregor | 6952f1e | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1468 | Data[2*I + 1] = GetTypeSourceInfo(Record, Idx); |
| 1469 | } |
| 1470 | } else { |
| 1471 | // Rest of NonTypeTemplateParmDecl. |
| 1472 | D->ParameterPack = Record[Idx++]; |
| 1473 | if (Record[Idx++]) { |
| 1474 | Expr *DefArg = Reader.ReadExpr(F); |
| 1475 | bool Inherited = Record[Idx++]; |
| 1476 | D->setDefaultArgument(DefArg, Inherited); |
| 1477 | } |
| 1478 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1479 | } |
| 1480 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1481 | void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { |
Argyrios Kyrtzidis | bfcc92c | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1482 | VisitTemplateDecl(D); |
| 1483 | // TemplateParmPosition. |
| 1484 | D->setDepth(Record[Idx++]); |
| 1485 | D->setPosition(Record[Idx++]); |
| 1486 | // Rest of TemplateTemplateParmDecl. |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1487 | TemplateArgumentLoc Arg = Reader.ReadTemplateArgumentLoc(F, Record, Idx); |
Argyrios Kyrtzidis | bfcc92c | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1488 | bool IsInherited = Record[Idx++]; |
| 1489 | D->setDefaultArgument(Arg, IsInherited); |
Douglas Gregor | 61c4d28 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1490 | D->ParameterPack = Record[Idx++]; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1491 | } |
| 1492 | |
Richard Smith | 3e4c6c4 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1493 | void ASTDeclReader::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { |
| 1494 | VisitRedeclarableTemplateDecl(D); |
| 1495 | } |
| 1496 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1497 | void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) { |
Argyrios Kyrtzidis | 0d39689 | 2010-07-22 17:28:12 +0000 | [diff] [blame] | 1498 | VisitDecl(D); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1499 | D->AssertExpr = Reader.ReadExpr(F); |
| 1500 | D->Message = cast<StringLiteral>(Reader.ReadExpr(F)); |
Abramo Bagnara | a2026c9 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 1501 | D->RParenLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1502 | } |
| 1503 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1504 | std::pair<uint64_t, uint64_t> |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1505 | ASTDeclReader::VisitDeclContext(DeclContext *DC) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1506 | uint64_t LexicalOffset = Record[Idx++]; |
| 1507 | uint64_t VisibleOffset = Record[Idx++]; |
| 1508 | return std::make_pair(LexicalOffset, VisibleOffset); |
| 1509 | } |
| 1510 | |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1511 | template <typename T> |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 1512 | ASTDeclReader::RedeclarableResult |
| 1513 | ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { |
Douglas Gregor | fc529f7 | 2011-12-19 19:00:47 +0000 | [diff] [blame] | 1514 | enum RedeclKind { FirstDeclaration = 0, FirstInFile, PointsToPrevious }; |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1515 | RedeclKind Kind = (RedeclKind)Record[Idx++]; |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 1516 | |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1517 | DeclID FirstDeclID; |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1518 | switch (Kind) { |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1519 | case FirstDeclaration: |
| 1520 | FirstDeclID = ThisDeclID; |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1521 | break; |
Douglas Gregor | fc529f7 | 2011-12-19 19:00:47 +0000 | [diff] [blame] | 1522 | |
| 1523 | case FirstInFile: |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1524 | case PointsToPrevious: { |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1525 | FirstDeclID = ReadDeclID(Record, Idx); |
| 1526 | DeclID PrevDeclID = ReadDeclID(Record, Idx); |
| 1527 | |
| 1528 | T *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID)); |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 1529 | |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1530 | // We delay loading of the redeclaration chain to avoid deeply nested calls. |
| 1531 | // We temporarily set the first (canonical) declaration as the previous one |
| 1532 | // which is the one that matters and mark the real previous DeclID to be |
| 1533 | // loaded & attached later on. |
Douglas Gregor | d488b3a | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1534 | D->RedeclLink = typename Redeclarable<T>::PreviousDeclLink(FirstDecl); |
Douglas Gregor | d488b3a | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1535 | |
Douglas Gregor | fc529f7 | 2011-12-19 19:00:47 +0000 | [diff] [blame] | 1536 | if (Kind == PointsToPrevious) { |
| 1537 | // Make a note that we need to wire up this declaration to its |
| 1538 | // previous declaration, later. We don't need to do this for the first |
| 1539 | // declaration in any given module file, because those will be wired |
| 1540 | // together later. |
| 1541 | Reader.PendingPreviousDecls.push_back(std::make_pair(static_cast<T*>(D), |
| 1542 | PrevDeclID)); |
| 1543 | } |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1544 | break; |
| 1545 | } |
Douglas Gregor | d488b3a | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1546 | } |
Douglas Gregor | f63b0a5 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1547 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 1548 | // The result structure takes care of note that we need to load the |
| 1549 | // other declaration chains for this ID. |
| 1550 | return RedeclarableResult(Reader, FirstDeclID); |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1551 | } |
| 1552 | |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1553 | //===----------------------------------------------------------------------===// |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1554 | // Attribute Reading |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1555 | //===----------------------------------------------------------------------===// |
| 1556 | |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1557 | /// \brief Reads attributes from the current stream position. |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1558 | void ASTReader::ReadAttributes(ModuleFile &F, AttrVec &Attrs, |
Argyrios Kyrtzidis | 4eb9fc0 | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 1559 | const RecordData &Record, unsigned &Idx) { |
| 1560 | for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) { |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1561 | Attr *New = 0; |
Sean Hunt | 387475d | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1562 | attr::Kind Kind = (attr::Kind)Record[Idx++]; |
Argyrios Kyrtzidis | 768d6ca | 2011-09-13 16:05:58 +0000 | [diff] [blame] | 1563 | SourceRange Range = ReadSourceRange(F, Record, Idx); |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1564 | |
Sean Hunt | cf807c4 | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 1565 | #include "clang/Serialization/AttrPCHRead.inc" |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1566 | |
| 1567 | assert(New && "Unable to decode attribute?"); |
Sean Hunt | cf807c4 | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 1568 | Attrs.push_back(New); |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1569 | } |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1570 | } |
| 1571 | |
| 1572 | //===----------------------------------------------------------------------===// |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1573 | // ASTReader Implementation |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1574 | //===----------------------------------------------------------------------===// |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1575 | |
| 1576 | /// \brief Note that we have loaded the declaration with the given |
| 1577 | /// Index. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1578 | /// |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1579 | /// This routine notes that this declaration has already been loaded, |
| 1580 | /// so that future GetDecl calls will return this declaration rather |
| 1581 | /// than trying to load a new declaration. |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1582 | inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) { |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1583 | assert(!DeclsLoaded[Index] && "Decl loaded twice?"); |
| 1584 | DeclsLoaded[Index] = D; |
| 1585 | } |
| 1586 | |
| 1587 | |
| 1588 | /// \brief Determine whether the consumer will be interested in seeing |
| 1589 | /// this declaration (via HandleTopLevelDecl). |
| 1590 | /// |
| 1591 | /// This routine should return true for anything that might affect |
| 1592 | /// code generation, e.g., inline function definitions, Objective-C |
| 1593 | /// declarations with metadata, etc. |
| 1594 | static bool isConsumerInterestedIn(Decl *D) { |
Argyrios Kyrtzidis | 144b38a | 2011-09-13 21:35:00 +0000 | [diff] [blame] | 1595 | // An ObjCMethodDecl is never considered as "interesting" because its |
| 1596 | // implementation container always is. |
| 1597 | |
Douglas Gregor | 94da158 | 2011-09-10 00:22:34 +0000 | [diff] [blame] | 1598 | if (isa<FileScopeAsmDecl>(D) || |
| 1599 | isa<ObjCProtocolDecl>(D) || |
| 1600 | isa<ObjCImplDecl>(D)) |
Daniel Dunbar | 04a0b50 | 2009-09-17 03:06:44 +0000 | [diff] [blame] | 1601 | return true; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1602 | if (VarDecl *Var = dyn_cast<VarDecl>(D)) |
Argyrios Kyrtzidis | 3f95477 | 2010-08-05 09:47:59 +0000 | [diff] [blame] | 1603 | return Var->isFileVarDecl() && |
| 1604 | Var->isThisDeclarationADefinition() == VarDecl::Definition; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1605 | if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D)) |
Sean Hunt | 10620eb | 2011-05-06 20:44:56 +0000 | [diff] [blame] | 1606 | return Func->doesThisDeclarationHaveABody(); |
Douglas Gregor | 94da158 | 2011-09-10 00:22:34 +0000 | [diff] [blame] | 1607 | |
| 1608 | return false; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1609 | } |
| 1610 | |
Douglas Gregor | 96e973f | 2011-07-20 00:27:43 +0000 | [diff] [blame] | 1611 | /// \brief Get the correct cursor and offset for loading a declaration. |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1612 | ASTReader::RecordLocation |
Argyrios Kyrtzidis | 9d31fa7 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 1613 | ASTReader::DeclCursorForID(DeclID ID, unsigned &RawLocation) { |
Sebastian Redl | 0b17c61 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1614 | // See if there's an override. |
| 1615 | DeclReplacementMap::iterator It = ReplacedDecls.find(ID); |
Argyrios Kyrtzidis | ef23b60 | 2011-10-31 07:20:15 +0000 | [diff] [blame] | 1616 | if (It != ReplacedDecls.end()) { |
| 1617 | RawLocation = It->second.RawLoc; |
| 1618 | return RecordLocation(It->second.Mod, It->second.Offset); |
| 1619 | } |
Sebastian Redl | 0b17c61 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1620 | |
Douglas Gregor | 96e973f | 2011-07-20 00:27:43 +0000 | [diff] [blame] | 1621 | GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID); |
| 1622 | assert(I != GlobalDeclMap.end() && "Corrupted global declaration map"); |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1623 | ModuleFile *M = I->second; |
Argyrios Kyrtzidis | 9d31fa7 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 1624 | const DeclOffset & |
| 1625 | DOffs = M->DeclOffsets[ID - M->BaseDeclID - NUM_PREDEF_DECL_IDS]; |
| 1626 | RawLocation = DOffs.Loc; |
| 1627 | return RecordLocation(M, DOffs.BitOffset); |
Sebastian Redl | cb526aa | 2010-07-20 22:46:15 +0000 | [diff] [blame] | 1628 | } |
| 1629 | |
Douglas Gregor | 8f1231b | 2011-07-22 06:10:01 +0000 | [diff] [blame] | 1630 | ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) { |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1631 | ContinuousRangeMap<uint64_t, ModuleFile*, 4>::iterator I |
Douglas Gregor | 8f1231b | 2011-07-22 06:10:01 +0000 | [diff] [blame] | 1632 | = GlobalBitOffsetsMap.find(GlobalOffset); |
| 1633 | |
| 1634 | assert(I != GlobalBitOffsetsMap.end() && "Corrupted global bit offsets map"); |
| 1635 | return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset); |
| 1636 | } |
| 1637 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 1638 | uint64_t ASTReader::getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset) { |
Douglas Gregor | e92b8a1 | 2011-08-04 00:01:48 +0000 | [diff] [blame] | 1639 | return LocalOffset + M.GlobalBitOffset; |
| 1640 | } |
| 1641 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 1642 | /// \brief Determine whether the two declarations refer to the same entity. |
| 1643 | static bool isSameEntity(NamedDecl *X, NamedDecl *Y) { |
| 1644 | assert(X->getDeclName() == Y->getDeclName() && "Declaration name mismatch!"); |
| 1645 | |
| 1646 | if (X == Y) |
| 1647 | return true; |
| 1648 | |
| 1649 | // Must have the same kind. |
| 1650 | if (X->getKind() != Y->getKind()) |
| 1651 | return false; |
| 1652 | |
| 1653 | // Must be in the same context. |
| 1654 | if (!X->getDeclContext()->getRedeclContext()->Equals( |
| 1655 | Y->getDeclContext()->getRedeclContext())) |
| 1656 | return false; |
| 1657 | |
| 1658 | // Objective-C classes with the same name always match. |
| 1659 | if (isa<ObjCInterfaceDecl>(X)) |
| 1660 | return true; |
| 1661 | |
| 1662 | // FIXME: Many other cases to implement. |
| 1663 | return false; |
| 1664 | } |
| 1665 | |
| 1666 | ASTDeclReader::FindExistingResult::~FindExistingResult() { |
| 1667 | if (!AddResult) |
| 1668 | return; |
| 1669 | |
| 1670 | DeclContext *DC = New->getDeclContext()->getRedeclContext(); |
| 1671 | if (DC->isTranslationUnit() && Reader.SemaObj) { |
| 1672 | if (!Existing) { |
| 1673 | Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName()); |
| 1674 | } |
| 1675 | } |
| 1676 | } |
| 1677 | |
| 1678 | ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) { |
| 1679 | DeclContext *DC = D->getDeclContext()->getRedeclContext(); |
| 1680 | if (!DC->isFileContext()) |
| 1681 | return FindExistingResult(Reader); |
| 1682 | |
| 1683 | if (DC->isTranslationUnit() && Reader.SemaObj) { |
| 1684 | IdentifierResolver &IdResolver = Reader.SemaObj->IdResolver; |
| 1685 | for (IdentifierResolver::iterator I = IdResolver.begin(D->getDeclName()), |
| 1686 | IEnd = IdResolver.end(); |
| 1687 | I != IEnd; ++I) { |
| 1688 | if (isSameEntity(*I, D)) |
| 1689 | return FindExistingResult(Reader, D, *I); |
| 1690 | } |
| 1691 | } |
| 1692 | |
| 1693 | // FIXME: Search in the DeclContext. |
| 1694 | |
| 1695 | return FindExistingResult(Reader, D, /*Existing=*/0); |
| 1696 | } |
| 1697 | |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1698 | void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *previous) { |
| 1699 | assert(D && previous); |
| 1700 | if (TagDecl *TD = dyn_cast<TagDecl>(D)) { |
| 1701 | TD->RedeclLink.setPointer(cast<TagDecl>(previous)); |
| 1702 | } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
| 1703 | FD->RedeclLink.setPointer(cast<FunctionDecl>(previous)); |
| 1704 | } else if (VarDecl *VD = dyn_cast<VarDecl>(D)) { |
| 1705 | VD->RedeclLink.setPointer(cast<VarDecl>(previous)); |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 1706 | } else if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) { |
| 1707 | TD->RedeclLink.setPointer(cast<TypedefNameDecl>(previous)); |
| 1708 | } else if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) { |
Douglas Gregor | 0af5501 | 2011-12-16 03:12:41 +0000 | [diff] [blame] | 1709 | ID->RedeclLink.setPointer(cast<ObjCInterfaceDecl>(previous)); |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1710 | } else { |
| 1711 | RedeclarableTemplateDecl *TD = cast<RedeclarableTemplateDecl>(D); |
| 1712 | TD->CommonOrPrev = cast<RedeclarableTemplateDecl>(previous); |
| 1713 | } |
| 1714 | } |
| 1715 | |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 1716 | void ASTDeclReader::attachLatestDecl(Decl *D, Decl *Latest) { |
| 1717 | assert(D && Latest); |
| 1718 | if (TagDecl *TD = dyn_cast<TagDecl>(D)) { |
| 1719 | TD->RedeclLink |
| 1720 | = Redeclarable<TagDecl>::LatestDeclLink(cast<TagDecl>(Latest)); |
| 1721 | } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
| 1722 | FD->RedeclLink |
| 1723 | = Redeclarable<FunctionDecl>::LatestDeclLink(cast<FunctionDecl>(Latest)); |
| 1724 | } else if (VarDecl *VD = dyn_cast<VarDecl>(D)) { |
| 1725 | VD->RedeclLink |
| 1726 | = Redeclarable<VarDecl>::LatestDeclLink(cast<VarDecl>(Latest)); |
| 1727 | } else if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) { |
| 1728 | TD->RedeclLink |
| 1729 | = Redeclarable<TypedefNameDecl>::LatestDeclLink( |
| 1730 | cast<TypedefNameDecl>(Latest)); |
| 1731 | } else if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) { |
| 1732 | ID->RedeclLink |
| 1733 | = Redeclarable<ObjCInterfaceDecl>::LatestDeclLink( |
| 1734 | cast<ObjCInterfaceDecl>(Latest)); |
| 1735 | } else { |
| 1736 | RedeclarableTemplateDecl *TD = cast<RedeclarableTemplateDecl>(D); |
| 1737 | TD->getCommonPtr()->Latest = cast<RedeclarableTemplateDecl>(Latest); |
| 1738 | } |
| 1739 | } |
| 1740 | |
Douglas Gregor | c3cfd2a | 2011-12-22 21:40:42 +0000 | [diff] [blame] | 1741 | ASTReader::MergedDeclsMap::iterator |
| 1742 | ASTReader::combineStoredMergedDecls(Decl *Canon, GlobalDeclID CanonID) { |
| 1743 | // If we don't have any stored merged declarations, just look in the |
| 1744 | // merged declarations set. |
| 1745 | StoredMergedDeclsMap::iterator StoredPos = StoredMergedDecls.find(CanonID); |
| 1746 | if (StoredPos == StoredMergedDecls.end()) |
| 1747 | return MergedDecls.find(Canon); |
| 1748 | |
| 1749 | // Append the stored merged declarations to the merged declarations set. |
| 1750 | MergedDeclsMap::iterator Pos = MergedDecls.find(Canon); |
| 1751 | if (Pos == MergedDecls.end()) |
| 1752 | Pos = MergedDecls.insert(std::make_pair(Canon, |
| 1753 | SmallVector<DeclID, 2>())).first; |
| 1754 | Pos->second.append(StoredPos->second.begin(), StoredPos->second.end()); |
| 1755 | StoredMergedDecls.erase(StoredPos); |
| 1756 | |
| 1757 | // Sort and uniquify the set of merged declarations. |
| 1758 | llvm::array_pod_sort(Pos->second.begin(), Pos->second.end()); |
| 1759 | Pos->second.erase(std::unique(Pos->second.begin(), Pos->second.end()), |
| 1760 | Pos->second.end()); |
| 1761 | return Pos; |
| 1762 | } |
| 1763 | |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1764 | void ASTReader::loadAndAttachPreviousDecl(Decl *D, serialization::DeclID ID) { |
| 1765 | Decl *previous = GetDecl(ID); |
| 1766 | ASTDeclReader::attachPreviousDecl(D, previous); |
| 1767 | } |
| 1768 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1769 | /// \brief Read the declaration at the given offset from the AST file. |
Douglas Gregor | 496c709 | 2011-08-03 15:48:04 +0000 | [diff] [blame] | 1770 | Decl *ASTReader::ReadDeclRecord(DeclID ID) { |
Douglas Gregor | 6bf2b9f | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 1771 | unsigned Index = ID - NUM_PREDEF_DECL_IDS; |
Argyrios Kyrtzidis | 9d31fa7 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 1772 | unsigned RawLocation = 0; |
| 1773 | RecordLocation Loc = DeclCursorForID(ID, RawLocation); |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1774 | llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1775 | // Keep track of where we are in the stream, then jump back there |
| 1776 | // after reading this declaration. |
Chris Lattner | da93061 | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1777 | SavedStreamPosition SavedPosition(DeclsCursor); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1778 | |
Argyrios Kyrtzidis | 919e693 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1779 | ReadingKindTracker ReadingKind(Read_Decl, *this); |
| 1780 | |
Douglas Gregor | d89275b | 2009-07-06 18:54:52 +0000 | [diff] [blame] | 1781 | // Note that we are loading a declaration record. |
Argyrios Kyrtzidis | 29ee3a2 | 2010-07-30 10:03:16 +0000 | [diff] [blame] | 1782 | Deserializing ADecl(this); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1783 | |
Sebastian Redl | c363273 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1784 | DeclsCursor.JumpToBit(Loc.Offset); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1785 | RecordData Record; |
Chris Lattner | da93061 | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1786 | unsigned Code = DeclsCursor.ReadCode(); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1787 | unsigned Idx = 0; |
Argyrios Kyrtzidis | 9d31fa7 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 1788 | ASTDeclReader Reader(*this, *Loc.F, DeclsCursor, ID, RawLocation, Record,Idx); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1789 | |
Chris Lattner | da93061 | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1790 | Decl *D = 0; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1791 | switch ((DeclCode)DeclsCursor.ReadRecord(Code, Record)) { |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1792 | case DECL_CONTEXT_LEXICAL: |
| 1793 | case DECL_CONTEXT_VISIBLE: |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 1794 | llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord"); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1795 | case DECL_TYPEDEF: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1796 | D = TypedefDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Abramo Bagnara | 344577e | 2011-03-06 15:48:19 +0000 | [diff] [blame] | 1797 | 0, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1798 | break; |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 1799 | case DECL_TYPEALIAS: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1800 | D = TypeAliasDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 1801 | 0, 0); |
| 1802 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1803 | case DECL_ENUM: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1804 | D = EnumDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1805 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1806 | case DECL_RECORD: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1807 | D = RecordDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1808 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1809 | case DECL_ENUM_CONSTANT: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1810 | D = EnumConstantDecl::Create(Context, 0, SourceLocation(), 0, QualType(), |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1811 | 0, llvm::APSInt()); |
| 1812 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1813 | case DECL_FUNCTION: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1814 | D = FunctionDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1815 | DeclarationName(), QualType(), 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1816 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1817 | case DECL_LINKAGE_SPEC: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1818 | D = LinkageSpecDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1819 | (LinkageSpecDecl::LanguageIDs)0, |
Abramo Bagnara | 55a9637 | 2011-03-03 16:52:29 +0000 | [diff] [blame] | 1820 | SourceLocation()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1821 | break; |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 1822 | case DECL_LABEL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1823 | D = LabelDecl::Create(Context, 0, SourceLocation(), 0); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 1824 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1825 | case DECL_NAMESPACE: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1826 | D = NamespaceDecl::Create(Context, 0, SourceLocation(), |
Abramo Bagnara | acba90f | 2011-03-08 12:38:20 +0000 | [diff] [blame] | 1827 | SourceLocation(), 0); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1828 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1829 | case DECL_NAMESPACE_ALIAS: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1830 | D = NamespaceAliasDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | 0cfaf6a | 2011-02-25 17:08:07 +0000 | [diff] [blame] | 1831 | SourceLocation(), 0, |
| 1832 | NestedNameSpecifierLoc(), |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1833 | SourceLocation(), 0); |
| 1834 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1835 | case DECL_USING: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1836 | D = UsingDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1837 | NestedNameSpecifierLoc(), DeclarationNameInfo(), |
| 1838 | false); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1839 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1840 | case DECL_USING_SHADOW: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1841 | D = UsingShadowDecl::Create(Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1842 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1843 | case DECL_USING_DIRECTIVE: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1844 | D = UsingDirectiveDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | db99241 | 2011-02-25 16:33:46 +0000 | [diff] [blame] | 1845 | SourceLocation(), NestedNameSpecifierLoc(), |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1846 | SourceLocation(), 0, 0); |
| 1847 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1848 | case DECL_UNRESOLVED_USING_VALUE: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1849 | D = UnresolvedUsingValueDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1850 | NestedNameSpecifierLoc(), |
Abramo Bagnara | ef3dce8 | 2010-08-12 11:46:03 +0000 | [diff] [blame] | 1851 | DeclarationNameInfo()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1852 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1853 | case DECL_UNRESOLVED_USING_TYPENAME: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1854 | D = UnresolvedUsingTypenameDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 1855 | SourceLocation(), |
| 1856 | NestedNameSpecifierLoc(), |
| 1857 | SourceLocation(), |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1858 | DeclarationName()); |
| 1859 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1860 | case DECL_CXX_RECORD: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1861 | D = CXXRecordDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1862 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1863 | case DECL_CXX_METHOD: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1864 | D = CXXMethodDecl::Create(Context, 0, SourceLocation(), |
Douglas Gregor | f525160 | 2011-03-08 17:10:18 +0000 | [diff] [blame] | 1865 | DeclarationNameInfo(), QualType(), 0, |
Richard Smith | af1fc7a | 2011-08-15 21:04:07 +0000 | [diff] [blame] | 1866 | false, SC_None, false, false, SourceLocation()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1867 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1868 | case DECL_CXX_CONSTRUCTOR: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1869 | D = CXXConstructorDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1870 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1871 | case DECL_CXX_DESTRUCTOR: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1872 | D = CXXDestructorDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1873 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1874 | case DECL_CXX_CONVERSION: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1875 | D = CXXConversionDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1876 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1877 | case DECL_ACCESS_SPEC: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1878 | D = AccessSpecDecl::Create(Context, Decl::EmptyShell()); |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1879 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1880 | case DECL_FRIEND: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1881 | D = FriendDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1882 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1883 | case DECL_FRIEND_TEMPLATE: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1884 | D = FriendTemplateDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1885 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1886 | case DECL_CLASS_TEMPLATE: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1887 | D = ClassTemplateDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1888 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1889 | case DECL_CLASS_TEMPLATE_SPECIALIZATION: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1890 | D = ClassTemplateSpecializationDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1891 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1892 | case DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1893 | D = ClassTemplatePartialSpecializationDecl::Create(Context, |
Douglas Gregor | 9a299e0 | 2011-03-04 17:52:15 +0000 | [diff] [blame] | 1894 | Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1895 | break; |
Francois Pichet | af0f4d0 | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 1896 | case DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1897 | D = ClassScopeFunctionSpecializationDecl::Create(Context, |
Francois Pichet | af0f4d0 | 2011-08-14 03:52:19 +0000 | [diff] [blame] | 1898 | Decl::EmptyShell()); |
| 1899 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1900 | case DECL_FUNCTION_TEMPLATE: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1901 | D = FunctionTemplateDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1902 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1903 | case DECL_TEMPLATE_TYPE_PARM: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1904 | D = TemplateTypeParmDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1905 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1906 | case DECL_NON_TYPE_TEMPLATE_PARM: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1907 | D = NonTypeTemplateParmDecl::Create(Context, 0, SourceLocation(), |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1908 | SourceLocation(), 0, 0, 0, QualType(), |
| 1909 | false, 0); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1910 | break; |
Douglas Gregor | 6952f1e | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1911 | case DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1912 | D = NonTypeTemplateParmDecl::Create(Context, 0, SourceLocation(), |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1913 | SourceLocation(), 0, 0, 0, QualType(), |
| 1914 | 0, 0, Record[Idx++], 0); |
Douglas Gregor | 6952f1e | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1915 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1916 | case DECL_TEMPLATE_TEMPLATE_PARM: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1917 | D = TemplateTemplateParmDecl::Create(Context, 0, SourceLocation(), 0, 0, |
Douglas Gregor | 61c4d28 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1918 | false, 0, 0); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1919 | break; |
Richard Smith | 3e4c6c4 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1920 | case DECL_TYPE_ALIAS_TEMPLATE: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1921 | D = TypeAliasTemplateDecl::Create(Context, Decl::EmptyShell()); |
Richard Smith | 3e4c6c4 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1922 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1923 | case DECL_STATIC_ASSERT: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1924 | D = StaticAssertDecl::Create(Context, 0, SourceLocation(), 0, 0, |
Abramo Bagnara | a2026c9 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 1925 | SourceLocation()); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1926 | break; |
| 1927 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1928 | case DECL_OBJC_METHOD: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1929 | D = ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(), |
Douglas Gregor | 4bc1cb6 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 1930 | Selector(), QualType(), 0, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1931 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1932 | case DECL_OBJC_INTERFACE: |
Douglas Gregor | 0af5501 | 2011-12-16 03:12:41 +0000 | [diff] [blame] | 1933 | D = ObjCInterfaceDecl::CreateEmpty(Context); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1934 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1935 | case DECL_OBJC_IVAR: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1936 | D = ObjCIvarDecl::Create(Context, 0, SourceLocation(), SourceLocation(), |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1937 | 0, QualType(), 0, ObjCIvarDecl::None); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1938 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1939 | case DECL_OBJC_PROTOCOL: |
Argyrios Kyrtzidis | 1711fc9 | 2011-10-04 04:48:02 +0000 | [diff] [blame] | 1940 | D = ObjCProtocolDecl::Create(Context, 0, 0, SourceLocation(), |
Argyrios Kyrtzidis | b05d7b2 | 2011-10-17 19:48:06 +0000 | [diff] [blame] | 1941 | SourceLocation(), 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1942 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1943 | case DECL_OBJC_AT_DEFS_FIELD: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1944 | D = ObjCAtDefsFieldDecl::Create(Context, 0, SourceLocation(), |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1945 | SourceLocation(), 0, QualType(), 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1946 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1947 | case DECL_OBJC_CLASS: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1948 | D = ObjCClassDecl::Create(Context, 0, SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1949 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1950 | case DECL_OBJC_FORWARD_PROTOCOL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1951 | D = ObjCForwardProtocolDecl::Create(Context, 0, SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1952 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1953 | case DECL_OBJC_CATEGORY: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1954 | D = ObjCCategoryDecl::Create(Context, Decl::EmptyShell()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1955 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1956 | case DECL_OBJC_CATEGORY_IMPL: |
Argyrios Kyrtzidis | 1711fc9 | 2011-10-04 04:48:02 +0000 | [diff] [blame] | 1957 | D = ObjCCategoryImplDecl::Create(Context, 0, 0, 0, SourceLocation(), |
Argyrios Kyrtzidis | c699400 | 2011-12-09 00:31:40 +0000 | [diff] [blame] | 1958 | SourceLocation(), SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1959 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1960 | case DECL_OBJC_IMPLEMENTATION: |
Argyrios Kyrtzidis | 1711fc9 | 2011-10-04 04:48:02 +0000 | [diff] [blame] | 1961 | D = ObjCImplementationDecl::Create(Context, 0, 0, 0, SourceLocation(), |
| 1962 | SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1963 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1964 | case DECL_OBJC_COMPATIBLE_ALIAS: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1965 | D = ObjCCompatibleAliasDecl::Create(Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1966 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1967 | case DECL_OBJC_PROPERTY: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1968 | D = ObjCPropertyDecl::Create(Context, 0, SourceLocation(), 0, SourceLocation(), |
John McCall | 83a230c | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 1969 | 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1970 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1971 | case DECL_OBJC_PROPERTY_IMPL: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1972 | D = ObjCPropertyImplDecl::Create(Context, 0, SourceLocation(), |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1973 | SourceLocation(), 0, |
Douglas Gregor | a4ffd85 | 2010-11-17 01:03:52 +0000 | [diff] [blame] | 1974 | ObjCPropertyImplDecl::Dynamic, 0, |
| 1975 | SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1976 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1977 | case DECL_FIELD: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1978 | D = FieldDecl::Create(Context, 0, SourceLocation(), SourceLocation(), 0, |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 1979 | QualType(), 0, 0, false, false); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1980 | break; |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 1981 | case DECL_INDIRECTFIELD: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1982 | D = IndirectFieldDecl::Create(Context, 0, SourceLocation(), 0, QualType(), |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 1983 | 0, 0); |
| 1984 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1985 | case DECL_VAR: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1986 | D = VarDecl::Create(Context, 0, SourceLocation(), SourceLocation(), 0, |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1987 | QualType(), 0, SC_None, SC_None); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1988 | break; |
| 1989 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1990 | case DECL_IMPLICIT_PARAM: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1991 | D = ImplicitParamDecl::Create(Context, 0, SourceLocation(), 0, QualType()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1992 | break; |
| 1993 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1994 | case DECL_PARM_VAR: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1995 | D = ParmVarDecl::Create(Context, 0, SourceLocation(), SourceLocation(), 0, |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1996 | QualType(), 0, SC_None, SC_None, 0); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1997 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1998 | case DECL_FILE_SCOPE_ASM: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 1999 | D = FileScopeAsmDecl::Create(Context, 0, 0, SourceLocation(), |
Abramo Bagnara | 21e006e | 2011-03-03 14:20:18 +0000 | [diff] [blame] | 2000 | SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 2001 | break; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2002 | case DECL_BLOCK: |
Douglas Gregor | 3594277 | 2011-09-09 21:34:22 +0000 | [diff] [blame] | 2003 | D = BlockDecl::Create(Context, 0, SourceLocation()); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 2004 | break; |
Douglas Gregor | 7c789c1 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 2005 | case DECL_CXX_BASE_SPECIFIERS: |
| 2006 | Error("attempt to read a C++ base-specifier record as a declaration"); |
| 2007 | return 0; |
Douglas Gregor | 15de72c | 2011-12-02 23:23:56 +0000 | [diff] [blame] | 2008 | case DECL_IMPORT: |
| 2009 | // Note: last entry of the ImportDecl record is the number of stored source |
| 2010 | // locations. |
| 2011 | D = ImportDecl::CreateEmpty(Context, Record.back()); |
| 2012 | break; |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 2013 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 2014 | |
Sebastian Redl | d527cc0 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 2015 | assert(D && "Unknown declaration reading AST file"); |
Chris Lattner | 4e3fcc8 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 2016 | LoadedDecl(Index, D); |
| 2017 | Reader.Visit(D); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 2018 | |
| 2019 | // If this declaration is also a declaration context, get the |
| 2020 | // offsets for its tables of lexical and visible declarations. |
| 2021 | if (DeclContext *DC = dyn_cast<DeclContext>(D)) { |
| 2022 | std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC); |
| 2023 | if (Offsets.first || Offsets.second) { |
Douglas Gregor | 0d95f77 | 2011-08-24 19:03:07 +0000 | [diff] [blame] | 2024 | if (Offsets.first != 0) |
| 2025 | DC->setHasExternalLexicalStorage(true); |
| 2026 | if (Offsets.second != 0) |
| 2027 | DC->setHasExternalVisibleStorage(true); |
| 2028 | if (ReadDeclContextStorage(*Loc.F, DeclsCursor, Offsets, |
| 2029 | Loc.F->DeclContextInfos[DC])) |
Sebastian Redl | 681d723 | 2010-07-27 00:17:23 +0000 | [diff] [blame] | 2030 | return 0; |
Sebastian Redl | 024e1c4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 2031 | } |
Sebastian Redl | e1dde81 | 2010-08-24 00:50:04 +0000 | [diff] [blame] | 2032 | |
Sebastian Redl | 024e1c4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 2033 | // Now add the pending visible updates for this decl context, if it has any. |
| 2034 | DeclContextVisibleUpdatesPending::iterator I = |
| 2035 | PendingVisibleUpdates.find(ID); |
| 2036 | if (I != PendingVisibleUpdates.end()) { |
| 2037 | // There are updates. This means the context has external visible |
| 2038 | // storage, even if the original stored version didn't. |
| 2039 | DC->setHasExternalVisibleStorage(true); |
| 2040 | DeclContextVisibleUpdates &U = I->second; |
Sebastian Redl | 024e1c4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 2041 | for (DeclContextVisibleUpdates::iterator UI = U.begin(), UE = U.end(); |
| 2042 | UI != UE; ++UI) { |
Douglas Gregor | 0d95f77 | 2011-08-24 19:03:07 +0000 | [diff] [blame] | 2043 | UI->second->DeclContextInfos[DC].NameLookupTableData = UI->first; |
Sebastian Redl | e1dde81 | 2010-08-24 00:50:04 +0000 | [diff] [blame] | 2044 | } |
Sebastian Redl | 024e1c4 | 2011-04-24 16:27:54 +0000 | [diff] [blame] | 2045 | PendingVisibleUpdates.erase(I); |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 2046 | } |
| 2047 | } |
| 2048 | assert(Idx == Record.size()); |
| 2049 | |
Douglas Gregor | 6bf2b9f | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 2050 | // Load any relevant update records. |
| 2051 | loadDeclUpdateRecords(ID, D); |
Argyrios Kyrtzidis | 5a17499 | 2011-11-14 07:07:59 +0000 | [diff] [blame] | 2052 | |
| 2053 | // Load the category chain after recursive loading is finished. |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 2054 | if (ObjCChainedCategoriesInterfaces.count(ID)) |
Argyrios Kyrtzidis | 5a17499 | 2011-11-14 07:07:59 +0000 | [diff] [blame] | 2055 | PendingChainedObjCCategories.push_back( |
| 2056 | std::make_pair(cast<ObjCInterfaceDecl>(D), ID)); |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 2057 | |
Douglas Gregor | 6bf2b9f | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 2058 | // If we have deserialized a declaration that has a definition the |
| 2059 | // AST consumer might need to know about, queue it. |
| 2060 | // We don't pass it to the consumer immediately because we may be in recursive |
| 2061 | // loading, and some declarations may still be initializing. |
Argyrios Kyrtzidis | 144b38a | 2011-09-13 21:35:00 +0000 | [diff] [blame] | 2062 | if (isConsumerInterestedIn(D)) |
Douglas Gregor | 94da158 | 2011-09-10 00:22:34 +0000 | [diff] [blame] | 2063 | InterestingDecls.push_back(D); |
Douglas Gregor | 94da158 | 2011-09-10 00:22:34 +0000 | [diff] [blame] | 2064 | |
Douglas Gregor | 6bf2b9f | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 2065 | return D; |
| 2066 | } |
| 2067 | |
| 2068 | void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) { |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 2069 | // The declaration may have been modified by files later in the chain. |
| 2070 | // If this is the case, read the record containing the updates from each file |
| 2071 | // and pass it to ASTDeclReader to make the modifications. |
| 2072 | DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID); |
| 2073 | if (UpdI != DeclUpdateOffsets.end()) { |
| 2074 | FileOffsetsTy &UpdateOffsets = UpdI->second; |
| 2075 | for (FileOffsetsTy::iterator |
Douglas Gregor | 6bf2b9f | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 2076 | I = UpdateOffsets.begin(), E = UpdateOffsets.end(); I != E; ++I) { |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2077 | ModuleFile *F = I->first; |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 2078 | uint64_t Offset = I->second; |
| 2079 | llvm::BitstreamCursor &Cursor = F->DeclsCursor; |
| 2080 | SavedStreamPosition SavedPosition(Cursor); |
| 2081 | Cursor.JumpToBit(Offset); |
| 2082 | RecordData Record; |
| 2083 | unsigned Code = Cursor.ReadCode(); |
| 2084 | unsigned RecCode = Cursor.ReadRecord(Code, Record); |
| 2085 | (void)RecCode; |
| 2086 | assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!"); |
Douglas Gregor | 6bf2b9f | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 2087 | |
| 2088 | unsigned Idx = 0; |
Argyrios Kyrtzidis | 9d31fa7 | 2011-10-27 18:47:35 +0000 | [diff] [blame] | 2089 | ASTDeclReader Reader(*this, *F, Cursor, ID, 0, Record, Idx); |
Sebastian Redl | f79a719 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 2090 | Reader.UpdateDecl(D, *F, Record); |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 2091 | } |
| 2092 | } |
Chris Lattner | 698f925 | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 2093 | } |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 2094 | |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 2095 | namespace { |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2096 | struct CompareLocalRedeclarationsInfoToID { |
| 2097 | bool operator()(const LocalRedeclarationsInfo &X, DeclID Y) { |
| 2098 | return X.FirstID < Y; |
| 2099 | } |
| 2100 | |
| 2101 | bool operator()(DeclID X, const LocalRedeclarationsInfo &Y) { |
| 2102 | return X < Y.FirstID; |
| 2103 | } |
| 2104 | |
| 2105 | bool operator()(const LocalRedeclarationsInfo &X, |
| 2106 | const LocalRedeclarationsInfo &Y) { |
| 2107 | return X.FirstID < Y.FirstID; |
| 2108 | } |
| 2109 | bool operator()(DeclID X, DeclID Y) { |
| 2110 | return X < Y; |
| 2111 | } |
| 2112 | }; |
| 2113 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2114 | /// \brief Module visitor class that finds all of the redeclarations of a |
| 2115 | /// |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2116 | class RedeclChainVisitor { |
| 2117 | ASTReader &Reader; |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2118 | SmallVectorImpl<DeclID> &SearchDecls; |
| 2119 | GlobalDeclID CanonID; |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2120 | llvm::SmallVector<std::pair<Decl *, Decl *>, 4> Chains; |
| 2121 | |
| 2122 | public: |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2123 | RedeclChainVisitor(ASTReader &Reader, SmallVectorImpl<DeclID> &SearchDecls, |
| 2124 | GlobalDeclID CanonID) |
| 2125 | : Reader(Reader), SearchDecls(SearchDecls), CanonID(CanonID) { } |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2126 | |
| 2127 | static bool visit(ModuleFile &M, bool Preorder, void *UserData) { |
| 2128 | if (Preorder) |
| 2129 | return false; |
| 2130 | |
| 2131 | return static_cast<RedeclChainVisitor *>(UserData)->visit(M); |
| 2132 | } |
| 2133 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2134 | void searchForID(ModuleFile &M, GlobalDeclID GlobalID) { |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2135 | // Map global ID of the first declaration down to the local ID |
| 2136 | // used in this module file. |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2137 | DeclID ID = Reader.mapGlobalIDToModuleFileGlobalID(M, GlobalID); |
| 2138 | if (!ID) |
| 2139 | return; |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2140 | |
| 2141 | // Perform a binary search to find the local redeclarations for this |
| 2142 | // declaration (if any). |
| 2143 | const LocalRedeclarationsInfo *Result |
| 2144 | = std::lower_bound(M.RedeclarationsInfo, |
| 2145 | M.RedeclarationsInfo + M.LocalNumRedeclarationsInfos, |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2146 | ID, CompareLocalRedeclarationsInfoToID()); |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2147 | if (Result == M.RedeclarationsInfo + M.LocalNumRedeclarationsInfos || |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2148 | Result->FirstID != ID) { |
| 2149 | // If we have a previously-canonical singleton declaration that was |
| 2150 | // merged into another redeclaration chain, create a trivial chain |
| 2151 | // for this single declaration so that it will get wired into the |
| 2152 | // complete redeclaration chain. |
| 2153 | if (GlobalID != CanonID && |
| 2154 | GlobalID - NUM_PREDEF_DECL_IDS >= M.BaseDeclID && |
| 2155 | GlobalID - NUM_PREDEF_DECL_IDS < M.BaseDeclID + M.LocalNumDecls) { |
| 2156 | if (Decl *D = Reader.GetDecl(GlobalID)) |
| 2157 | Chains.push_back(std::make_pair(D, D)); |
| 2158 | } |
| 2159 | |
| 2160 | return; |
| 2161 | } |
| 2162 | |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2163 | // Dig out the starting/ending declarations. |
| 2164 | Decl *FirstLocalDecl = Reader.GetLocalDecl(M, Result->FirstLocalID); |
| 2165 | Decl *LastLocalDecl = Reader.GetLocalDecl(M, Result->LastLocalID); |
| 2166 | if (!FirstLocalDecl || !LastLocalDecl) |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2167 | return; |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2168 | |
| 2169 | // Append this redeclaration chain to the list. |
| 2170 | Chains.push_back(std::make_pair(FirstLocalDecl, LastLocalDecl)); |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2171 | } |
| 2172 | |
| 2173 | bool visit(ModuleFile &M) { |
| 2174 | // Visit each of the declarations. |
| 2175 | for (unsigned I = 0, N = SearchDecls.size(); I != N; ++I) |
| 2176 | searchForID(M, SearchDecls[I]); |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2177 | return false; |
| 2178 | } |
| 2179 | |
| 2180 | ArrayRef<std::pair<Decl *, Decl *> > getChains() const { |
| 2181 | return Chains; |
| 2182 | } |
| 2183 | |
| 2184 | void addParsed(Decl *FirstParsedDecl, Decl *LastParsedDecl) { |
| 2185 | Chains.push_back(std::make_pair(FirstParsedDecl, LastParsedDecl)); |
| 2186 | } |
| 2187 | }; |
| 2188 | } |
| 2189 | |
| 2190 | /// \brief Retrieve the previous declaration to D. |
| 2191 | static Decl *getPreviousDecl(Decl *D) { |
| 2192 | if (TagDecl *TD = dyn_cast<TagDecl>(D)) |
| 2193 | return TD->getPreviousDeclaration(); |
| 2194 | if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) |
| 2195 | return FD->getPreviousDeclaration(); |
| 2196 | if (VarDecl *VD = dyn_cast<VarDecl>(D)) |
| 2197 | return VD->getPreviousDeclaration(); |
| 2198 | if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) |
| 2199 | return TD->getPreviousDeclaration(); |
| 2200 | if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) |
| 2201 | return ID->getPreviousDeclaration(); |
| 2202 | |
| 2203 | return cast<RedeclarableTemplateDecl>(D)->getPreviousDeclaration(); |
| 2204 | } |
| 2205 | |
| 2206 | /// \brief Retrieve the most recent declaration of D. |
| 2207 | static Decl *getMostRecentDecl(Decl *D) { |
| 2208 | if (TagDecl *TD = dyn_cast<TagDecl>(D)) |
| 2209 | return TD->getMostRecentDeclaration(); |
| 2210 | if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) |
| 2211 | return FD->getMostRecentDeclaration(); |
| 2212 | if (VarDecl *VD = dyn_cast<VarDecl>(D)) |
| 2213 | return VD->getMostRecentDeclaration(); |
| 2214 | if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) |
| 2215 | return TD->getMostRecentDeclaration(); |
| 2216 | if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) |
| 2217 | return ID->getMostRecentDeclaration(); |
| 2218 | |
| 2219 | return cast<RedeclarableTemplateDecl>(D)->getMostRecentDeclaration(); |
| 2220 | } |
| 2221 | |
| 2222 | void ASTReader::loadPendingDeclChain(serialization::GlobalDeclID ID) { |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2223 | Decl *D = GetDecl(ID); |
| 2224 | Decl *CanonDecl = D->getCanonicalDecl(); |
Douglas Gregor | c3cfd2a | 2011-12-22 21:40:42 +0000 | [diff] [blame] | 2225 | |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2226 | // Determine the set of declaration IDs we'll be searching for. |
| 2227 | llvm::SmallVector<DeclID, 1> SearchDecls; |
| 2228 | GlobalDeclID CanonID = 0; |
| 2229 | if (D == CanonDecl) { |
| 2230 | SearchDecls.push_back(ID); // Always first. |
| 2231 | CanonID = ID; |
| 2232 | } |
Douglas Gregor | c3cfd2a | 2011-12-22 21:40:42 +0000 | [diff] [blame] | 2233 | MergedDeclsMap::iterator MergedPos = combineStoredMergedDecls(CanonDecl, ID); |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2234 | if (MergedPos != MergedDecls.end()) |
| 2235 | SearchDecls.append(MergedPos->second.begin(), MergedPos->second.end()); |
| 2236 | |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2237 | // Build up the list of redeclaration chains. |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2238 | RedeclChainVisitor Visitor(*this, SearchDecls, CanonID); |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2239 | ModuleMgr.visitDepthFirst(&RedeclChainVisitor::visit, &Visitor); |
| 2240 | |
| 2241 | // Retrieve the chains. |
| 2242 | ArrayRef<std::pair<Decl *, Decl *> > Chains = Visitor.getChains(); |
| 2243 | if (Chains.empty()) |
| 2244 | return; |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2245 | |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2246 | // Capture all of the parsed declarations and put them at the end. |
| 2247 | Decl *MostRecent = getMostRecentDecl(CanonDecl); |
| 2248 | Decl *FirstParsed = MostRecent; |
| 2249 | if (CanonDecl != MostRecent && !MostRecent->isFromASTFile()) { |
| 2250 | Decl *Current = MostRecent; |
| 2251 | while (Decl *Prev = getPreviousDecl(Current)) { |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2252 | if (Prev == CanonDecl) |
| 2253 | break; |
| 2254 | |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2255 | if (Prev->isFromASTFile()) { |
| 2256 | Current = Prev; |
| 2257 | continue; |
| 2258 | } |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2259 | |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2260 | // Chain all of the parsed declarations together. |
| 2261 | ASTDeclReader::attachPreviousDecl(FirstParsed, Prev); |
| 2262 | FirstParsed = Prev; |
| 2263 | Current = Prev; |
| 2264 | } |
| 2265 | |
| 2266 | Visitor.addParsed(FirstParsed, MostRecent); |
| 2267 | } |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2268 | |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2269 | // Hook up the separate chains. |
| 2270 | Chains = Visitor.getChains(); |
Douglas Gregor | 0f75323 | 2011-12-22 01:48:48 +0000 | [diff] [blame] | 2271 | if (Chains[0].first != CanonDecl) |
| 2272 | ASTDeclReader::attachPreviousDecl(Chains[0].first, CanonDecl); |
Douglas Gregor | a1be278 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 2273 | for (unsigned I = 1, N = Chains.size(); I != N; ++I) |
| 2274 | ASTDeclReader::attachPreviousDecl(Chains[I].first, Chains[I-1].second); |
| 2275 | ASTDeclReader::attachLatestDecl(CanonDecl, Chains.back().second); |
| 2276 | } |
| 2277 | |
| 2278 | namespace { |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 2279 | /// \brief Given an ObjC interface, goes through the modules and links to the |
| 2280 | /// interface all the categories for it. |
| 2281 | class ObjCChainedCategoriesVisitor { |
| 2282 | ASTReader &Reader; |
| 2283 | serialization::GlobalDeclID InterfaceID; |
| 2284 | ObjCInterfaceDecl *Interface; |
| 2285 | ObjCCategoryDecl *GlobHeadCat, *GlobTailCat; |
| 2286 | llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap; |
| 2287 | |
| 2288 | public: |
| 2289 | ObjCChainedCategoriesVisitor(ASTReader &Reader, |
| 2290 | serialization::GlobalDeclID InterfaceID, |
| 2291 | ObjCInterfaceDecl *Interface) |
| 2292 | : Reader(Reader), InterfaceID(InterfaceID), Interface(Interface), |
| 2293 | GlobHeadCat(0), GlobTailCat(0) { } |
| 2294 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2295 | static bool visit(ModuleFile &M, void *UserData) { |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 2296 | return static_cast<ObjCChainedCategoriesVisitor *>(UserData)->visit(M); |
| 2297 | } |
| 2298 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2299 | bool visit(ModuleFile &M) { |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 2300 | if (Reader.isDeclIDFromModule(InterfaceID, M)) |
| 2301 | return true; // We reached the module where the interface originated |
| 2302 | // from. Stop traversing the imported modules. |
| 2303 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2304 | ModuleFile::ChainedObjCCategoriesMap::iterator |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 2305 | I = M.ChainedObjCCategories.find(InterfaceID); |
| 2306 | if (I == M.ChainedObjCCategories.end()) |
| 2307 | return false; |
| 2308 | |
| 2309 | ObjCCategoryDecl * |
| 2310 | HeadCat = Reader.GetLocalDeclAs<ObjCCategoryDecl>(M, I->second.first); |
| 2311 | ObjCCategoryDecl * |
| 2312 | TailCat = Reader.GetLocalDeclAs<ObjCCategoryDecl>(M, I->second.second); |
| 2313 | |
| 2314 | addCategories(HeadCat, TailCat); |
| 2315 | return false; |
| 2316 | } |
| 2317 | |
| 2318 | void addCategories(ObjCCategoryDecl *HeadCat, |
| 2319 | ObjCCategoryDecl *TailCat = 0) { |
| 2320 | if (!HeadCat) { |
| 2321 | assert(!TailCat); |
| 2322 | return; |
| 2323 | } |
| 2324 | |
| 2325 | if (!TailCat) { |
| 2326 | TailCat = HeadCat; |
| 2327 | while (TailCat->getNextClassCategory()) |
| 2328 | TailCat = TailCat->getNextClassCategory(); |
| 2329 | } |
| 2330 | |
| 2331 | if (!GlobHeadCat) { |
| 2332 | GlobHeadCat = HeadCat; |
| 2333 | GlobTailCat = TailCat; |
| 2334 | } else { |
| 2335 | ASTDeclReader::setNextObjCCategory(GlobTailCat, HeadCat); |
| 2336 | GlobTailCat = TailCat; |
| 2337 | } |
| 2338 | |
| 2339 | llvm::DenseSet<DeclarationName> Checked; |
| 2340 | for (ObjCCategoryDecl *Cat = HeadCat, |
| 2341 | *CatEnd = TailCat->getNextClassCategory(); |
| 2342 | Cat != CatEnd; Cat = Cat->getNextClassCategory()) { |
| 2343 | if (Checked.count(Cat->getDeclName())) |
| 2344 | continue; |
| 2345 | Checked.insert(Cat->getDeclName()); |
| 2346 | checkForDuplicate(Cat); |
| 2347 | } |
| 2348 | } |
| 2349 | |
| 2350 | /// \brief Warns for duplicate categories that come from different modules. |
| 2351 | void checkForDuplicate(ObjCCategoryDecl *Cat) { |
| 2352 | DeclarationName Name = Cat->getDeclName(); |
| 2353 | // Find the top category with the same name. We do not want to warn for |
| 2354 | // duplicates along the established chain because there were already |
| 2355 | // warnings for them when the module was created. We only want to warn for |
| 2356 | // duplicates between non-dependent modules: |
| 2357 | // |
Argyrios Kyrtzidis | fa77cba | 2011-09-01 03:07:11 +0000 | [diff] [blame] | 2358 | // MT // |
| 2359 | // / \ // |
| 2360 | // ML MR // |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 2361 | // |
| 2362 | // We want to warn for duplicates between ML and MR,not between ML and MT. |
| 2363 | // |
| 2364 | // FIXME: We should not warn for duplicates in diamond: |
| 2365 | // |
Argyrios Kyrtzidis | fa77cba | 2011-09-01 03:07:11 +0000 | [diff] [blame] | 2366 | // MT // |
| 2367 | // / \ // |
| 2368 | // ML MR // |
| 2369 | // \ / // |
| 2370 | // MB // |
Argyrios Kyrtzidis | e6b8d68 | 2011-09-01 00:58:55 +0000 | [diff] [blame] | 2371 | // |
| 2372 | // If there are duplicates in ML/MR, there will be warning when creating |
| 2373 | // MB *and* when importing MB. We should not warn when importing. |
| 2374 | for (ObjCCategoryDecl *Next = Cat->getNextClassCategory(); Next; |
| 2375 | Next = Next->getNextClassCategory()) { |
| 2376 | if (Next->getDeclName() == Name) |
| 2377 | Cat = Next; |
| 2378 | } |
| 2379 | |
| 2380 | ObjCCategoryDecl *&PrevCat = NameCategoryMap[Name]; |
| 2381 | if (!PrevCat) |
| 2382 | PrevCat = Cat; |
| 2383 | |
| 2384 | if (PrevCat != Cat) { |
| 2385 | Reader.Diag(Cat->getLocation(), diag::warn_dup_category_def) |
| 2386 | << Interface->getDeclName() << Name; |
| 2387 | Reader.Diag(PrevCat->getLocation(), diag::note_previous_definition); |
| 2388 | } |
| 2389 | } |
| 2390 | |
| 2391 | ObjCCategoryDecl *getHeadCategory() const { return GlobHeadCat; } |
| 2392 | }; |
| 2393 | } |
| 2394 | |
| 2395 | void ASTReader::loadObjCChainedCategories(serialization::GlobalDeclID ID, |
| 2396 | ObjCInterfaceDecl *D) { |
| 2397 | ObjCChainedCategoriesVisitor Visitor(*this, ID, D); |
| 2398 | ModuleMgr.visit(ObjCChainedCategoriesVisitor::visit, &Visitor); |
| 2399 | // Also add the categories that the interface already links to. |
| 2400 | Visitor.addCategories(D->getCategoryList()); |
| 2401 | D->setCategoryList(Visitor.getHeadCategory()); |
| 2402 | } |
Douglas Gregor | 6bf2b9f | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 2403 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2404 | void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, |
Sebastian Redl | f79a719 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 2405 | const RecordData &Record) { |
Argyrios Kyrtzidis | 565bf30 | 2010-10-24 17:26:50 +0000 | [diff] [blame] | 2406 | unsigned Idx = 0; |
| 2407 | while (Idx < Record.size()) { |
| 2408 | switch ((DeclUpdateKind)Record[Idx++]) { |
| 2409 | case UPD_CXX_SET_DEFINITIONDATA: { |
| 2410 | CXXRecordDecl *RD = cast<CXXRecordDecl>(D); |
Douglas Gregor | 496c709 | 2011-08-03 15:48:04 +0000 | [diff] [blame] | 2411 | CXXRecordDecl *DefinitionDecl |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2412 | = Reader.ReadDeclAs<CXXRecordDecl>(ModuleFile, Record, Idx); |
Argyrios Kyrtzidis | 565bf30 | 2010-10-24 17:26:50 +0000 | [diff] [blame] | 2413 | assert(!RD->DefinitionData && "DefinitionData is already set!"); |
| 2414 | InitializeCXXDefinitionData(RD, DefinitionDecl, Record, Idx); |
| 2415 | break; |
| 2416 | } |
Argyrios Kyrtzidis | b6cc0e1 | 2010-10-24 17:26:54 +0000 | [diff] [blame] | 2417 | |
| 2418 | case UPD_CXX_ADDED_IMPLICIT_MEMBER: |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2419 | cast<CXXRecordDecl>(D)->addedMember(Reader.ReadDecl(ModuleFile, Record, Idx)); |
Argyrios Kyrtzidis | b6cc0e1 | 2010-10-24 17:26:54 +0000 | [diff] [blame] | 2420 | break; |
Argyrios Kyrtzidis | bef1a7b | 2010-10-28 07:38:42 +0000 | [diff] [blame] | 2421 | |
| 2422 | case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: |
| 2423 | // It will be added to the template's specializations set when loaded. |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2424 | (void)Reader.ReadDecl(ModuleFile, Record, Idx); |
Sebastian Redl | 7c0837f | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 2425 | break; |
| 2426 | |
| 2427 | case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: { |
Douglas Gregor | 496c709 | 2011-08-03 15:48:04 +0000 | [diff] [blame] | 2428 | NamespaceDecl *Anon |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2429 | = Reader.ReadDeclAs<NamespaceDecl>(ModuleFile, Record, Idx); |
Sebastian Redl | 74b485a | 2011-04-24 16:28:21 +0000 | [diff] [blame] | 2430 | // Guard against these being loaded out of original order. Don't use |
| 2431 | // getNextNamespace(), since it tries to access the context and can't in |
| 2432 | // the middle of deserialization. |
| 2433 | if (!Anon->NextNamespace) { |
| 2434 | if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D)) |
| 2435 | TU->setAnonymousNamespace(Anon); |
| 2436 | else |
| 2437 | cast<NamespaceDecl>(D)->OrigOrAnonNamespace.setPointer(Anon); |
| 2438 | } |
Sebastian Redl | 7c0837f | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 2439 | break; |
| 2440 | } |
Sebastian Redl | f79a719 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 2441 | |
| 2442 | case UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER: |
| 2443 | cast<VarDecl>(D)->getMemberSpecializationInfo()->setPointOfInstantiation( |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2444 | Reader.ReadSourceLocation(ModuleFile, Record, Idx)); |
Sebastian Redl | f79a719 | 2011-04-29 08:19:30 +0000 | [diff] [blame] | 2445 | break; |
Douglas Gregor | 53df7a1 | 2011-12-15 18:03:09 +0000 | [diff] [blame] | 2446 | |
| 2447 | case UPD_OBJC_SET_CLASS_DEFINITIONDATA: { |
| 2448 | ObjCInterfaceDecl *ID = cast<ObjCInterfaceDecl>(D); |
| 2449 | ObjCInterfaceDecl *Def |
| 2450 | = Reader.ReadDeclAs<ObjCInterfaceDecl>(ModuleFile, Record, Idx); |
Douglas Gregor | 21cf08b | 2011-12-19 20:51:16 +0000 | [diff] [blame] | 2451 | if (Def->Data) |
Douglas Gregor | 26fec63 | 2011-12-15 18:17:27 +0000 | [diff] [blame] | 2452 | ID->Data = Def->Data; |
Douglas Gregor | 53df7a1 | 2011-12-15 18:03:09 +0000 | [diff] [blame] | 2453 | break; |
| 2454 | } |
Argyrios Kyrtzidis | 565bf30 | 2010-10-24 17:26:50 +0000 | [diff] [blame] | 2455 | } |
| 2456 | } |
Argyrios Kyrtzidis | 7b90340 | 2010-10-24 17:26:36 +0000 | [diff] [blame] | 2457 | } |