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