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