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 | |
Sebastian Redl | f5b1346 | 2010-08-18 23:57:17 +0000 | [diff] [blame] | 15 | #include "clang/Serialization/ASTReader.h" |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 16 | #include "clang/AST/ASTConsumer.h" |
| 17 | #include "clang/AST/ASTContext.h" |
| 18 | #include "clang/AST/DeclVisitor.h" |
| 19 | #include "clang/AST/DeclGroup.h" |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 20 | #include "clang/AST/DeclCXX.h" |
| 21 | #include "clang/AST/DeclTemplate.h" |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 22 | #include "clang/AST/Expr.h" |
| 23 | using namespace clang; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 24 | using namespace clang::serialization; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 25 | |
| 26 | //===----------------------------------------------------------------------===// |
| 27 | // Declaration deserialization |
| 28 | //===----------------------------------------------------------------------===// |
| 29 | |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 30 | namespace clang { |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 31 | class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> { |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 32 | ASTReader &Reader; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 33 | ASTReader::PerFileData &F; |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 34 | llvm::BitstreamCursor &Cursor; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 35 | const DeclID ThisDeclID; |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 36 | const ASTReader::RecordData &Record; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 37 | unsigned &Idx; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 38 | TypeID TypeIDForTypeDecl; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 39 | |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 40 | uint64_t GetCurrentCursorOffset(); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 41 | SourceLocation ReadSourceLocation(const ASTReader::RecordData &R, |
| 42 | unsigned &I) { |
| 43 | return Reader.ReadSourceLocation(F, R, I); |
| 44 | } |
| 45 | SourceRange ReadSourceRange(const ASTReader::RecordData &R, unsigned &I) { |
| 46 | return Reader.ReadSourceRange(F, R, I); |
| 47 | } |
| 48 | TypeSourceInfo *GetTypeSourceInfo(const ASTReader::RecordData &R, |
| 49 | unsigned &I) { |
| 50 | return Reader.GetTypeSourceInfo(F, R, I); |
| 51 | } |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 52 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 53 | public: |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 54 | ASTDeclReader(ASTReader &Reader, ASTReader::PerFileData &F, |
| 55 | llvm::BitstreamCursor &Cursor, DeclID thisDeclID, |
| 56 | const ASTReader::RecordData &Record, unsigned &Idx) |
| 57 | : Reader(Reader), F(F), Cursor(Cursor), ThisDeclID(thisDeclID), |
| 58 | Record(Record), Idx(Idx), TypeIDForTypeDecl(0) { } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 59 | |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 60 | void Visit(Decl *D); |
| 61 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 62 | void VisitDecl(Decl *D); |
| 63 | void VisitTranslationUnitDecl(TranslationUnitDecl *TU); |
| 64 | void VisitNamedDecl(NamedDecl *ND); |
Douglas Gregor | e31bbd9 | 2010-02-21 18:22:14 +0000 | [diff] [blame] | 65 | void VisitNamespaceDecl(NamespaceDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 66 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); |
| 67 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 68 | void VisitTypeDecl(TypeDecl *TD); |
| 69 | void VisitTypedefDecl(TypedefDecl *TD); |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 70 | void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 71 | void VisitTagDecl(TagDecl *TD); |
| 72 | void VisitEnumDecl(EnumDecl *ED); |
| 73 | void VisitRecordDecl(RecordDecl *RD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 74 | void VisitCXXRecordDecl(CXXRecordDecl *D); |
| 75 | void VisitClassTemplateSpecializationDecl( |
| 76 | ClassTemplateSpecializationDecl *D); |
| 77 | void VisitClassTemplatePartialSpecializationDecl( |
| 78 | ClassTemplatePartialSpecializationDecl *D); |
| 79 | void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 80 | void VisitValueDecl(ValueDecl *VD); |
| 81 | void VisitEnumConstantDecl(EnumConstantDecl *ECD); |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 82 | void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 83 | void VisitDeclaratorDecl(DeclaratorDecl *DD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 84 | void VisitFunctionDecl(FunctionDecl *FD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 85 | void VisitCXXMethodDecl(CXXMethodDecl *D); |
| 86 | void VisitCXXConstructorDecl(CXXConstructorDecl *D); |
| 87 | void VisitCXXDestructorDecl(CXXDestructorDecl *D); |
| 88 | void VisitCXXConversionDecl(CXXConversionDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 89 | void VisitFieldDecl(FieldDecl *FD); |
| 90 | void VisitVarDecl(VarDecl *VD); |
| 91 | void VisitImplicitParamDecl(ImplicitParamDecl *PD); |
| 92 | void VisitParmVarDecl(ParmVarDecl *PD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 93 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); |
| 94 | void VisitTemplateDecl(TemplateDecl *D); |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 95 | void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 96 | void VisitClassTemplateDecl(ClassTemplateDecl *D); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 97 | void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 98 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); |
Argyrios Kyrtzidis | 41d4562 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 99 | void VisitUsingDecl(UsingDecl *D); |
| 100 | void VisitUsingShadowDecl(UsingShadowDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 101 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 102 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD); |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 103 | void VisitAccessSpecDecl(AccessSpecDecl *D); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 104 | void VisitFriendDecl(FriendDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 105 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); |
| 106 | void VisitStaticAssertDecl(StaticAssertDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 107 | void VisitBlockDecl(BlockDecl *BD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 108 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 109 | std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC); |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 110 | template <typename T> void VisitRedeclarable(Redeclarable<T> *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 111 | |
Alexis Hunt | ed05325 | 2010-05-30 07:21:58 +0000 | [diff] [blame] | 112 | // FIXME: Reorder according to DeclNodes.td? |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 113 | void VisitObjCMethodDecl(ObjCMethodDecl *D); |
| 114 | void VisitObjCContainerDecl(ObjCContainerDecl *D); |
| 115 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); |
| 116 | void VisitObjCIvarDecl(ObjCIvarDecl *D); |
| 117 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); |
| 118 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); |
| 119 | void VisitObjCClassDecl(ObjCClassDecl *D); |
| 120 | void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D); |
| 121 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); |
| 122 | void VisitObjCImplDecl(ObjCImplDecl *D); |
| 123 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); |
| 124 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); |
| 125 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); |
| 126 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
| 127 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
| 128 | }; |
| 129 | } |
| 130 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 131 | uint64_t ASTDeclReader::GetCurrentCursorOffset() { |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 132 | uint64_t Off = 0; |
| 133 | for (unsigned I = 0, N = Reader.Chain.size(); I != N; ++I) { |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 134 | ASTReader::PerFileData &F = *Reader.Chain[N - I - 1]; |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 135 | if (&Cursor == &F.DeclsCursor) { |
| 136 | Off += F.DeclsCursor.GetCurrentBitNo(); |
| 137 | break; |
| 138 | } |
| 139 | Off += F.SizeInBits; |
| 140 | } |
| 141 | return Off; |
| 142 | } |
| 143 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 144 | void ASTDeclReader::Visit(Decl *D) { |
| 145 | DeclVisitor<ASTDeclReader, void>::Visit(D); |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 146 | |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 147 | if (TypeDecl *TD = dyn_cast<TypeDecl>(D)) { |
Douglas Gregor | 1c28331 | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 148 | // if we have a fully initialized TypeDecl, we can safely read its type now. |
| 149 | TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtr()); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 150 | } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
| 151 | // FunctionDecl's body was written last after all other Stmts/Exprs. |
| 152 | if (Record[Idx++]) |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 153 | FD->setLazyBody(GetCurrentCursorOffset()); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 154 | } |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 157 | void ASTDeclReader::VisitDecl(Decl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 158 | D->setDeclContext(cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++]))); |
| 159 | D->setLexicalDeclContext( |
| 160 | cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++]))); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 161 | D->setLocation(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 162 | D->setInvalidDecl(Record[Idx++]); |
Alexis Hunt | dcfba7b | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 163 | if (Record[Idx++]) { |
| 164 | AttrVec Attrs; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 165 | Reader.ReadAttributes(F, Attrs); |
Alexis Hunt | dcfba7b | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 166 | D->setAttrs(Attrs); |
| 167 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 168 | D->setImplicit(Record[Idx++]); |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 169 | D->setUsed(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 170 | D->setAccess((AccessSpecifier)Record[Idx++]); |
Sebastian Redl | 009e7f2 | 2010-10-05 16:15:19 +0000 | [diff] [blame^] | 171 | D->setPCHLevel(Record[Idx++] + (F.Type <= ASTReader::PCH)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 174 | void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 175 | VisitDecl(TU); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 176 | TU->setAnonymousNamespace( |
| 177 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 180 | void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 181 | VisitDecl(ND); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 182 | ND->setDeclName(Reader.ReadDeclarationName(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 185 | void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 186 | VisitNamedDecl(TD); |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 187 | // Delay type reading until after we have fully initialized the decl. |
Douglas Gregor | 1c28331 | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 188 | TypeIDForTypeDecl = Record[Idx++]; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 191 | void ASTDeclReader::VisitTypedefDecl(TypedefDecl *TD) { |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 192 | VisitTypeDecl(TD); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 193 | TD->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 194 | } |
| 195 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 196 | void ASTDeclReader::VisitTagDecl(TagDecl *TD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 197 | VisitTypeDecl(TD); |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 198 | VisitRedeclarable(TD); |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 199 | TD->IdentifierNamespace = Record[Idx++]; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 200 | TD->setTagKind((TagDecl::TagKind)Record[Idx++]); |
| 201 | TD->setDefinition(Record[Idx++]); |
Douglas Gregor | 5089c76 | 2010-02-12 17:40:34 +0000 | [diff] [blame] | 202 | TD->setEmbeddedInDeclarator(Record[Idx++]); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 203 | TD->setRBraceLoc(ReadSourceLocation(Record, Idx)); |
| 204 | TD->setTagKeywordLoc(ReadSourceLocation(Record, Idx)); |
John McCall | 3e11ebe | 2010-03-15 10:12:16 +0000 | [diff] [blame] | 205 | // FIXME: maybe read optional qualifier and its range. |
| 206 | TD->setTypedefForAnonDecl( |
| 207 | cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 208 | } |
| 209 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 210 | void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 211 | VisitTagDecl(ED); |
| 212 | ED->setIntegerType(Reader.GetType(Record[Idx++])); |
John McCall | 5677499 | 2009-12-09 09:09:27 +0000 | [diff] [blame] | 213 | ED->setPromotionType(Reader.GetType(Record[Idx++])); |
John McCall | 9aa35be | 2010-05-06 08:49:23 +0000 | [diff] [blame] | 214 | ED->setNumPositiveBits(Record[Idx++]); |
| 215 | ED->setNumNegativeBits(Record[Idx++]); |
Argyrios Kyrtzidis | 282b36b | 2010-07-06 15:36:48 +0000 | [diff] [blame] | 216 | ED->setInstantiationOfMemberEnum( |
| 217 | cast_or_null<EnumDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 220 | void ASTDeclReader::VisitRecordDecl(RecordDecl *RD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 221 | VisitTagDecl(RD); |
| 222 | RD->setHasFlexibleArrayMember(Record[Idx++]); |
| 223 | RD->setAnonymousStructOrUnion(Record[Idx++]); |
Fariborz Jahanian | 8e0d042 | 2009-07-08 16:37:44 +0000 | [diff] [blame] | 224 | RD->setHasObjectMember(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 227 | void ASTDeclReader::VisitValueDecl(ValueDecl *VD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 228 | VisitNamedDecl(VD); |
| 229 | VD->setType(Reader.GetType(Record[Idx++])); |
| 230 | } |
| 231 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 232 | void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 233 | VisitValueDecl(ECD); |
| 234 | if (Record[Idx++]) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 235 | ECD->setInitExpr(Reader.ReadExpr(F)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 236 | ECD->setInitVal(Reader.ReadAPSInt(Record, Idx)); |
| 237 | } |
| 238 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 239 | void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 240 | VisitValueDecl(DD); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 241 | TypeSourceInfo *TInfo = GetTypeSourceInfo(Record, Idx); |
John McCall | bcd0350 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 242 | if (TInfo) |
| 243 | DD->setTypeSourceInfo(TInfo); |
John McCall | 3e11ebe | 2010-03-15 10:12:16 +0000 | [diff] [blame] | 244 | // FIXME: read optional qualifier and its range. |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 247 | void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 248 | VisitDeclaratorDecl(FD); |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 249 | VisitRedeclarable(FD); |
Abramo Bagnara | d6d2f18 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 250 | // FIXME: read DeclarationNameLoc. |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 251 | |
Argyrios Kyrtzidis | a95d019 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 252 | FD->IdentifierNamespace = Record[Idx++]; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 253 | switch ((FunctionDecl::TemplatedKind)Record[Idx++]) { |
Argyrios Kyrtzidis | 0b0369a | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 254 | default: assert(false && "Unhandled TemplatedKind!"); |
| 255 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 256 | case FunctionDecl::TK_NonTemplate: |
| 257 | break; |
| 258 | case FunctionDecl::TK_FunctionTemplate: |
| 259 | FD->setDescribedFunctionTemplate( |
| 260 | cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]))); |
| 261 | break; |
| 262 | case FunctionDecl::TK_MemberSpecialization: { |
| 263 | FunctionDecl *InstFD = cast<FunctionDecl>(Reader.GetDecl(Record[Idx++])); |
| 264 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 265 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 266 | FD->setInstantiationOfMemberFunction(*Reader.getContext(), InstFD, TSK); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 267 | FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI); |
| 268 | break; |
| 269 | } |
| 270 | case FunctionDecl::TK_FunctionTemplateSpecialization: { |
| 271 | FunctionTemplateDecl *Template |
| 272 | = cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
| 273 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
| 274 | |
| 275 | // Template arguments. |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 276 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 277 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 278 | |
| 279 | // Template args as written. |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 280 | llvm::SmallVector<TemplateArgumentLoc, 8> TemplArgLocs; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 281 | SourceLocation LAngleLoc, RAngleLoc; |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 282 | if (Record[Idx++]) { // TemplateArgumentsAsWritten != 0 |
| 283 | unsigned NumTemplateArgLocs = Record[Idx++]; |
| 284 | TemplArgLocs.reserve(NumTemplateArgLocs); |
| 285 | for (unsigned i=0; i != NumTemplateArgLocs; ++i) |
Sebastian Redl | c67764e | 2010-07-22 22:43:28 +0000 | [diff] [blame] | 286 | TemplArgLocs.push_back( |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 287 | Reader.ReadTemplateArgumentLoc(F, Record, Idx)); |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 288 | |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 289 | LAngleLoc = ReadSourceLocation(Record, Idx); |
| 290 | RAngleLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 291 | } |
Argyrios Kyrtzidis | 927d8e0 | 2010-07-05 10:37:55 +0000 | [diff] [blame] | 292 | |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 293 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 294 | |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 295 | ASTContext &C = *Reader.getContext(); |
| 296 | TemplateArgumentList *TemplArgList |
| 297 | = new (C) TemplateArgumentList(C, TemplArgs.data(), TemplArgs.size()); |
| 298 | TemplateArgumentListInfo *TemplArgsInfo |
| 299 | = new (C) TemplateArgumentListInfo(LAngleLoc, RAngleLoc); |
| 300 | for (unsigned i=0, e = TemplArgLocs.size(); i != e; ++i) |
| 301 | TemplArgsInfo->addArgument(TemplArgLocs[i]); |
| 302 | FunctionTemplateSpecializationInfo *FTInfo |
| 303 | = FunctionTemplateSpecializationInfo::Create(C, FD, Template, TSK, |
| 304 | TemplArgList, |
| 305 | TemplArgsInfo, POI); |
| 306 | FD->TemplateOrSpecialization = FTInfo; |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 307 | |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 308 | if (FD->isCanonicalDecl()) { // if canonical add to template's set. |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 309 | // The template that contains the specializations set. It's not safe to |
| 310 | // use getCanonicalDecl on Template since it may still be initializing. |
| 311 | FunctionTemplateDecl *CanonTemplate |
| 312 | = cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 313 | // Get the InsertPos by FindNodeOrInsertPos() instead of calling |
| 314 | // InsertNode(FTInfo) directly to avoid the getASTContext() call in |
| 315 | // FunctionTemplateSpecializationInfo's Profile(). |
| 316 | // We avoid getASTContext because a decl in the parent hierarchy may |
| 317 | // be initializing. |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 318 | llvm::FoldingSetNodeID ID; |
| 319 | FunctionTemplateSpecializationInfo::Profile(ID, TemplArgs.data(), |
| 320 | TemplArgs.size(), C); |
| 321 | void *InsertPos = 0; |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 322 | CanonTemplate->getSpecializations().FindNodeOrInsertPos(ID, InsertPos); |
Argyrios Kyrtzidis | e262a95 | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 323 | assert(InsertPos && "Another specialization already inserted!"); |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 324 | CanonTemplate->getSpecializations().InsertNode(FTInfo, InsertPos); |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 325 | } |
Argyrios Kyrtzidis | 0b0369a | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 326 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 327 | } |
| 328 | case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { |
| 329 | // Templates. |
| 330 | UnresolvedSet<8> TemplDecls; |
| 331 | unsigned NumTemplates = Record[Idx++]; |
| 332 | while (NumTemplates--) |
| 333 | TemplDecls.addDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 334 | |
| 335 | // Templates args. |
| 336 | TemplateArgumentListInfo TemplArgs; |
| 337 | unsigned NumArgs = Record[Idx++]; |
| 338 | while (NumArgs--) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 339 | TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(F, Record, Idx)); |
| 340 | TemplArgs.setLAngleLoc(ReadSourceLocation(Record, Idx)); |
| 341 | TemplArgs.setRAngleLoc(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 342 | |
| 343 | FD->setDependentTemplateSpecialization(*Reader.getContext(), |
| 344 | TemplDecls, TemplArgs); |
Argyrios Kyrtzidis | 0b0369a | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 345 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 346 | } |
| 347 | } |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 348 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 349 | // FunctionDecl's body is handled last at ASTDeclReader::Visit, |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 350 | // after everything else is read. |
| 351 | |
John McCall | 8e7d656 | 2010-08-26 03:08:43 +0000 | [diff] [blame] | 352 | FD->setStorageClass((StorageClass)Record[Idx++]); |
| 353 | FD->setStorageClassAsWritten((StorageClass)Record[Idx++]); |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 354 | FD->setInlineSpecified(Record[Idx++]); |
| 355 | FD->setVirtualAsWritten(Record[Idx++]); |
| 356 | FD->setPure(Record[Idx++]); |
| 357 | FD->setHasInheritedPrototype(Record[Idx++]); |
| 358 | FD->setHasWrittenPrototype(Record[Idx++]); |
| 359 | FD->setDeleted(Record[Idx++]); |
| 360 | FD->setTrivial(Record[Idx++]); |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 361 | FD->setHasImplicitReturnZero(Record[Idx++]); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 362 | FD->setLocEnd(ReadSourceLocation(Record, Idx)); |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 363 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 364 | // Read in the parameters. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 365 | unsigned NumParams = Record[Idx++]; |
| 366 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 367 | Params.reserve(NumParams); |
| 368 | for (unsigned I = 0; I != NumParams; ++I) |
| 369 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 370 | FD->setParams(*Reader.getContext(), Params.data(), NumParams); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 373 | void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 374 | VisitNamedDecl(MD); |
| 375 | if (Record[Idx++]) { |
| 376 | // In practice, this won't be executed (since method definitions |
| 377 | // don't occur in header files). |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 378 | MD->setBody(Reader.ReadStmt(F)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 379 | MD->setSelfDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); |
| 380 | MD->setCmdDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); |
| 381 | } |
| 382 | MD->setInstanceMethod(Record[Idx++]); |
| 383 | MD->setVariadic(Record[Idx++]); |
| 384 | MD->setSynthesized(Record[Idx++]); |
Fariborz Jahanian | 6e7e8cc | 2010-07-22 18:24:20 +0000 | [diff] [blame] | 385 | MD->setDefined(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 386 | MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]); |
| 387 | MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); |
Fariborz Jahanian | d9235db | 2010-04-08 21:29:11 +0000 | [diff] [blame] | 388 | MD->setNumSelectorArgs(unsigned(Record[Idx++])); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 389 | MD->setResultType(Reader.GetType(Record[Idx++])); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 390 | MD->setResultTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); |
| 391 | MD->setEndLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 392 | unsigned NumParams = Record[Idx++]; |
| 393 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 394 | Params.reserve(NumParams); |
| 395 | for (unsigned I = 0; I != NumParams; ++I) |
| 396 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | cdabb31 | 2010-04-09 15:40:42 +0000 | [diff] [blame] | 397 | MD->setMethodParams(*Reader.getContext(), Params.data(), NumParams, |
| 398 | NumParams); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 399 | } |
| 400 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 401 | void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 402 | VisitNamedDecl(CD); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 403 | SourceLocation A = ReadSourceLocation(Record, Idx); |
| 404 | SourceLocation B = ReadSourceLocation(Record, Idx); |
Ted Kremenek | c7c6431 | 2010-01-07 01:20:12 +0000 | [diff] [blame] | 405 | CD->setAtEndRange(SourceRange(A, B)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 406 | } |
| 407 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 408 | void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 409 | VisitObjCContainerDecl(ID); |
Douglas Gregor | 1c28331 | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 410 | ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 411 | ID->setSuperClass(cast_or_null<ObjCInterfaceDecl> |
| 412 | (Reader.GetDecl(Record[Idx++]))); |
Ted Kremenek | 0ef508d | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 413 | |
| 414 | // Read the directly referenced protocols and their SourceLocations. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 415 | unsigned NumProtocols = Record[Idx++]; |
| 416 | llvm::SmallVector<ObjCProtocolDecl *, 16> Protocols; |
| 417 | Protocols.reserve(NumProtocols); |
| 418 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 419 | Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 420 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 421 | ProtoLocs.reserve(NumProtocols); |
| 422 | for (unsigned I = 0; I != NumProtocols; ++I) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 423 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 424 | ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(), |
| 425 | *Reader.getContext()); |
Ted Kremenek | 0ef508d | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 426 | |
| 427 | // Read the transitive closure of protocols referenced by this class. |
| 428 | NumProtocols = Record[Idx++]; |
| 429 | Protocols.clear(); |
| 430 | Protocols.reserve(NumProtocols); |
| 431 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 432 | Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
| 433 | ID->AllReferencedProtocols.set(Protocols.data(), NumProtocols, |
| 434 | *Reader.getContext()); |
| 435 | |
| 436 | // Read the ivars. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 437 | unsigned NumIvars = Record[Idx++]; |
| 438 | llvm::SmallVector<ObjCIvarDecl *, 16> IVars; |
| 439 | IVars.reserve(NumIvars); |
| 440 | for (unsigned I = 0; I != NumIvars; ++I) |
| 441 | IVars.push_back(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 442 | ID->setCategoryList( |
| 443 | cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | a50b3a2 | 2010-08-20 21:21:08 +0000 | [diff] [blame] | 444 | // We will rebuild this list lazily. |
| 445 | ID->setIvarList(0); |
Douglas Gregor | 1c28331 | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 446 | ID->setForwardDecl(Record[Idx++]); |
| 447 | ID->setImplicitInterfaceDecl(Record[Idx++]); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 448 | ID->setClassLoc(ReadSourceLocation(Record, Idx)); |
| 449 | ID->setSuperClassLoc(ReadSourceLocation(Record, Idx)); |
| 450 | ID->setLocEnd(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 451 | } |
| 452 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 453 | void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 454 | VisitFieldDecl(IVD); |
| 455 | IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]); |
Fariborz Jahanian | a50b3a2 | 2010-08-20 21:21:08 +0000 | [diff] [blame] | 456 | // This field will be built lazily. |
| 457 | IVD->setNextIvar(0); |
Fariborz Jahanian | aea8e1e | 2010-07-17 18:35:47 +0000 | [diff] [blame] | 458 | bool synth = Record[Idx++]; |
| 459 | IVD->setSynthesize(synth); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 460 | } |
| 461 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 462 | void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 463 | VisitObjCContainerDecl(PD); |
| 464 | PD->setForwardDecl(Record[Idx++]); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 465 | PD->setLocEnd(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 466 | unsigned NumProtoRefs = Record[Idx++]; |
| 467 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 468 | ProtoRefs.reserve(NumProtoRefs); |
| 469 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 470 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 471 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 472 | ProtoLocs.reserve(NumProtoRefs); |
| 473 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 474 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 475 | PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 476 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 477 | } |
| 478 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 479 | void ASTDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 480 | VisitFieldDecl(FD); |
| 481 | } |
| 482 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 483 | void ASTDeclReader::VisitObjCClassDecl(ObjCClassDecl *CD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 484 | VisitDecl(CD); |
| 485 | unsigned NumClassRefs = Record[Idx++]; |
| 486 | llvm::SmallVector<ObjCInterfaceDecl *, 16> ClassRefs; |
| 487 | ClassRefs.reserve(NumClassRefs); |
| 488 | for (unsigned I = 0; I != NumClassRefs; ++I) |
| 489 | ClassRefs.push_back(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Ted Kremenek | 9b124e1 | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 490 | llvm::SmallVector<SourceLocation, 16> SLocs; |
| 491 | SLocs.reserve(NumClassRefs); |
| 492 | for (unsigned I = 0; I != NumClassRefs; ++I) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 493 | SLocs.push_back(ReadSourceLocation(Record, Idx)); |
Ted Kremenek | 9b124e1 | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 494 | CD->setClassList(*Reader.getContext(), ClassRefs.data(), SLocs.data(), |
| 495 | NumClassRefs); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 496 | } |
| 497 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 498 | void ASTDeclReader::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *FPD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 499 | VisitDecl(FPD); |
| 500 | unsigned NumProtoRefs = Record[Idx++]; |
| 501 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 502 | ProtoRefs.reserve(NumProtoRefs); |
| 503 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 504 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 505 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 506 | ProtoLocs.reserve(NumProtoRefs); |
| 507 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 508 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 509 | FPD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 510 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 511 | } |
| 512 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 513 | void ASTDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 514 | VisitObjCContainerDecl(CD); |
| 515 | CD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 516 | unsigned NumProtoRefs = Record[Idx++]; |
| 517 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 518 | ProtoRefs.reserve(NumProtoRefs); |
| 519 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 520 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 521 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 522 | ProtoLocs.reserve(NumProtoRefs); |
| 523 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 524 | ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 525 | CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 526 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 527 | CD->setNextClassCategory(cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | bf9294f | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 528 | CD->setHasSynthBitfield(Record[Idx++]); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 529 | CD->setAtLoc(ReadSourceLocation(Record, Idx)); |
| 530 | CD->setCategoryNameLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 531 | } |
| 532 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 533 | void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 534 | VisitNamedDecl(CAD); |
| 535 | CAD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 536 | } |
| 537 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 538 | void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 539 | VisitNamedDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 540 | D->setAtLoc(ReadSourceLocation(Record, Idx)); |
| 541 | D->setType(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 542 | // FIXME: stable encoding |
| 543 | D->setPropertyAttributes( |
| 544 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Fariborz Jahanian | 3bf0ded | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 545 | D->setPropertyAttributesAsWritten( |
| 546 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 547 | // FIXME: stable encoding |
| 548 | D->setPropertyImplementation( |
| 549 | (ObjCPropertyDecl::PropertyControl)Record[Idx++]); |
| 550 | D->setGetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector()); |
| 551 | D->setSetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector()); |
| 552 | D->setGetterMethodDecl( |
| 553 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 554 | D->setSetterMethodDecl( |
| 555 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 556 | D->setPropertyIvarDecl( |
| 557 | cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
| 558 | } |
| 559 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 560 | void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) { |
Argyrios Kyrtzidis | 067c407 | 2009-07-27 19:04:32 +0000 | [diff] [blame] | 561 | VisitObjCContainerDecl(D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 562 | D->setClassInterface( |
| 563 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 564 | } |
| 565 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 566 | void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 567 | VisitObjCImplDecl(D); |
| 568 | D->setIdentifier(Reader.GetIdentifierInfo(Record, Idx)); |
| 569 | } |
| 570 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 571 | void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 572 | VisitObjCImplDecl(D); |
| 573 | D->setSuperClass( |
| 574 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Argyrios Kyrtzidis | 13257c5 | 2010-08-09 10:54:20 +0000 | [diff] [blame] | 575 | llvm::tie(D->IvarInitializers, D->NumIvarInitializers) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 576 | = Reader.ReadCXXBaseOrMemberInitializers(F, Record, Idx); |
Fariborz Jahanian | bf9294f | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 577 | D->setHasSynthBitfield(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 581 | void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 582 | VisitDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 583 | D->setAtLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 584 | D->setPropertyDecl( |
| 585 | cast_or_null<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++]))); |
| 586 | D->setPropertyIvarDecl( |
| 587 | cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 588 | D->setGetterCXXConstructor(Reader.ReadExpr(F)); |
| 589 | D->setSetterCXXAssignment(Reader.ReadExpr(F)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 590 | } |
| 591 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 592 | void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 593 | VisitDeclaratorDecl(FD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 594 | FD->setMutable(Record[Idx++]); |
| 595 | if (Record[Idx++]) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 596 | FD->setBitWidth(Reader.ReadExpr(F)); |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 597 | if (!FD->getDeclName()) { |
| 598 | FieldDecl *Tmpl = cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])); |
| 599 | if (Tmpl) |
| 600 | Reader.getContext()->setInstantiatedFromUnnamedFieldDecl(FD, Tmpl); |
| 601 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 602 | } |
| 603 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 604 | void ASTDeclReader::VisitVarDecl(VarDecl *VD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 605 | VisitDeclaratorDecl(VD); |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 606 | VisitRedeclarable(VD); |
John McCall | 8e7d656 | 2010-08-26 03:08:43 +0000 | [diff] [blame] | 607 | VD->setStorageClass((StorageClass)Record[Idx++]); |
| 608 | VD->setStorageClassAsWritten((StorageClass)Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 609 | VD->setThreadSpecified(Record[Idx++]); |
| 610 | VD->setCXXDirectInitializer(Record[Idx++]); |
Douglas Gregor | 3f324d56 | 2010-05-03 18:51:14 +0000 | [diff] [blame] | 611 | VD->setExceptionVariable(Record[Idx++]); |
Douglas Gregor | 6fd1b18 | 2010-05-15 06:01:05 +0000 | [diff] [blame] | 612 | VD->setNRVOVariable(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 613 | if (Record[Idx++]) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 614 | VD->setInit(Reader.ReadExpr(F)); |
Argyrios Kyrtzidis | cdb8b3f | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 615 | |
| 616 | if (Record[Idx++]) { // HasMemberSpecializationInfo. |
| 617 | VarDecl *Tmpl = cast<VarDecl>(Reader.GetDecl(Record[Idx++])); |
| 618 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 619 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | cdb8b3f | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 620 | Reader.getContext()->setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI); |
| 621 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 622 | } |
| 623 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 624 | void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 625 | VisitVarDecl(PD); |
| 626 | } |
| 627 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 628 | void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 629 | VisitVarDecl(PD); |
| 630 | PD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); |
John McCall | f3cd665 | 2010-03-12 18:31:32 +0000 | [diff] [blame] | 631 | PD->setHasInheritedDefaultArg(Record[Idx++]); |
Argyrios Kyrtzidis | ccde6a0 | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 632 | if (Record[Idx++]) // hasUninstantiatedDefaultArg. |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 633 | PD->setUninstantiatedDefaultArg(Reader.ReadExpr(F)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 634 | } |
| 635 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 636 | void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 637 | VisitDecl(AD); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 638 | AD->setAsmString(cast<StringLiteral>(Reader.ReadExpr(F))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 639 | } |
| 640 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 641 | void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 642 | VisitDecl(BD); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 643 | BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(F))); |
| 644 | BD->setSignatureAsWritten(GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 645 | unsigned NumParams = Record[Idx++]; |
| 646 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 647 | Params.reserve(NumParams); |
| 648 | for (unsigned I = 0; I != NumParams; ++I) |
| 649 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | d505812 | 2010-02-11 01:19:42 +0000 | [diff] [blame] | 650 | BD->setParams(Params.data(), NumParams); |
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::VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 654 | VisitDecl(D); |
| 655 | D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]); |
| 656 | D->setHasBraces(Record[Idx++]); |
| 657 | } |
| 658 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 659 | void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 660 | VisitNamedDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 661 | D->setLBracLoc(ReadSourceLocation(Record, Idx)); |
| 662 | D->setRBracLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 663 | D->setNextNamespace( |
| 664 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 665 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 666 | bool IsOriginal = Record[Idx++]; |
Argyrios Kyrtzidis | dae2a16 | 2010-07-03 07:57:53 +0000 | [diff] [blame] | 667 | D->OrigOrAnonNamespace.setInt(IsOriginal); |
| 668 | D->OrigOrAnonNamespace.setPointer( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 669 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 670 | } |
| 671 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 672 | void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 673 | VisitNamedDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 674 | D->NamespaceLoc = ReadSourceLocation(Record, Idx); |
| 675 | D->setQualifierRange(ReadSourceRange(Record, Idx)); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 676 | D->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 677 | D->IdentLoc = ReadSourceLocation(Record, Idx); |
Douglas Gregor | f9e43ce | 2010-09-01 00:08:19 +0000 | [diff] [blame] | 678 | D->Namespace = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 679 | } |
| 680 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 681 | void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 682 | VisitNamedDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 683 | D->setUsingLocation(ReadSourceLocation(Record, Idx)); |
| 684 | D->setNestedNameRange(ReadSourceRange(Record, Idx)); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 685 | D->setTargetNestedNameDecl(Reader.ReadNestedNameSpecifier(Record, Idx)); |
Abramo Bagnara | 8de74e9 | 2010-08-12 11:46:03 +0000 | [diff] [blame] | 686 | // FIXME: read the DNLoc component. |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 687 | |
| 688 | // FIXME: It would probably be more efficient to read these into a vector |
| 689 | // and then re-cosntruct the shadow decl set over that vector since it |
| 690 | // would avoid existence checks. |
| 691 | unsigned NumShadows = Record[Idx++]; |
| 692 | for(unsigned I = 0; I != NumShadows; ++I) { |
Argyrios Kyrtzidis | 00dda6a | 2010-07-08 13:09:41 +0000 | [diff] [blame] | 693 | // Avoid invariant checking of UsingDecl::addShadowDecl, the decl may still |
| 694 | // be initializing. |
| 695 | D->Shadows.insert(cast<UsingShadowDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 696 | } |
| 697 | D->setTypeName(Record[Idx++]); |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 698 | NamedDecl *Pattern = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
| 699 | if (Pattern) |
| 700 | Reader.getContext()->setInstantiatedFromUsingDecl(D, Pattern); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 701 | } |
| 702 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 703 | void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 704 | VisitNamedDecl(D); |
| 705 | D->setTargetDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 706 | D->setUsingDecl(cast<UsingDecl>(Reader.GetDecl(Record[Idx++]))); |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 707 | UsingShadowDecl *Pattern |
| 708 | = cast_or_null<UsingShadowDecl>(Reader.GetDecl(Record[Idx++])); |
| 709 | if (Pattern) |
| 710 | Reader.getContext()->setInstantiatedFromUsingShadowDecl(D, Pattern); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 711 | } |
| 712 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 713 | void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 714 | VisitNamedDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 715 | D->UsingLoc = ReadSourceLocation(Record, Idx); |
| 716 | D->NamespaceLoc = ReadSourceLocation(Record, Idx); |
| 717 | D->QualifierRange = ReadSourceRange(Record, Idx); |
Douglas Gregor | 01a43013 | 2010-09-01 03:07:18 +0000 | [diff] [blame] | 718 | D->Qualifier = Reader.ReadNestedNameSpecifier(Record, Idx); |
| 719 | D->NominatedNamespace = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
| 720 | D->CommonAncestor = cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++])); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 721 | } |
| 722 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 723 | void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 724 | VisitValueDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 725 | D->setTargetNestedNameRange(ReadSourceRange(Record, Idx)); |
| 726 | D->setUsingLoc(ReadSourceLocation(Record, Idx)); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 727 | D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
Abramo Bagnara | 8de74e9 | 2010-08-12 11:46:03 +0000 | [diff] [blame] | 728 | // FIXME: read the DNLoc component. |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 729 | } |
| 730 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 731 | void ASTDeclReader::VisitUnresolvedUsingTypenameDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 732 | UnresolvedUsingTypenameDecl *D) { |
| 733 | VisitTypeDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 734 | D->TargetNestedNameRange = ReadSourceRange(Record, Idx); |
| 735 | D->UsingLocation = ReadSourceLocation(Record, Idx); |
| 736 | D->TypenameLocation = ReadSourceLocation(Record, Idx); |
Douglas Gregor | a9aa29c | 2010-09-01 19:52:22 +0000 | [diff] [blame] | 737 | D->TargetNestedNameSpecifier = Reader.ReadNestedNameSpecifier(Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 738 | } |
| 739 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 740 | void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) { |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 741 | ASTContext &C = *Reader.getContext(); |
| 742 | |
Argyrios Kyrtzidis | 181431c | 2010-07-06 15:36:58 +0000 | [diff] [blame] | 743 | // We need to allocate the DefinitionData struct ahead of VisitRecordDecl |
| 744 | // so that the other CXXRecordDecls can get a pointer even when the owner |
| 745 | // is still initializing. |
| 746 | bool OwnsDefinitionData = false; |
| 747 | enum DataOwnership { Data_NoDefData, Data_Owner, Data_NotOwner }; |
| 748 | switch ((DataOwnership)Record[Idx++]) { |
| 749 | default: |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 750 | assert(0 && "Out of sync with ASTDeclWriter or messed up reading"); |
Argyrios Kyrtzidis | 181431c | 2010-07-06 15:36:58 +0000 | [diff] [blame] | 751 | case Data_NoDefData: |
| 752 | break; |
| 753 | case Data_Owner: |
| 754 | OwnsDefinitionData = true; |
| 755 | D->DefinitionData = new (C) struct CXXRecordDecl::DefinitionData(D); |
| 756 | break; |
| 757 | case Data_NotOwner: |
| 758 | D->DefinitionData |
| 759 | = cast<CXXRecordDecl>(Reader.GetDecl(Record[Idx++]))->DefinitionData; |
| 760 | break; |
| 761 | } |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 762 | |
Argyrios Kyrtzidis | 181431c | 2010-07-06 15:36:58 +0000 | [diff] [blame] | 763 | VisitRecordDecl(D); |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 764 | |
Argyrios Kyrtzidis | 181431c | 2010-07-06 15:36:58 +0000 | [diff] [blame] | 765 | if (OwnsDefinitionData) { |
| 766 | assert(D->DefinitionData); |
| 767 | struct CXXRecordDecl::DefinitionData &Data = *D->DefinitionData; |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 768 | |
Argyrios Kyrtzidis | 181431c | 2010-07-06 15:36:58 +0000 | [diff] [blame] | 769 | Data.UserDeclaredConstructor = Record[Idx++]; |
| 770 | Data.UserDeclaredCopyConstructor = Record[Idx++]; |
| 771 | Data.UserDeclaredCopyAssignment = Record[Idx++]; |
| 772 | Data.UserDeclaredDestructor = Record[Idx++]; |
| 773 | Data.Aggregate = Record[Idx++]; |
| 774 | Data.PlainOldData = Record[Idx++]; |
| 775 | Data.Empty = Record[Idx++]; |
| 776 | Data.Polymorphic = Record[Idx++]; |
| 777 | Data.Abstract = Record[Idx++]; |
| 778 | Data.HasTrivialConstructor = Record[Idx++]; |
| 779 | Data.HasTrivialCopyConstructor = Record[Idx++]; |
| 780 | Data.HasTrivialCopyAssignment = Record[Idx++]; |
| 781 | Data.HasTrivialDestructor = Record[Idx++]; |
| 782 | Data.ComputedVisibleConversions = Record[Idx++]; |
| 783 | Data.DeclaredDefaultConstructor = Record[Idx++]; |
| 784 | Data.DeclaredCopyConstructor = Record[Idx++]; |
| 785 | Data.DeclaredCopyAssignment = Record[Idx++]; |
| 786 | Data.DeclaredDestructor = Record[Idx++]; |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 787 | |
Argyrios Kyrtzidis | 181431c | 2010-07-06 15:36:58 +0000 | [diff] [blame] | 788 | // setBases() is unsuitable since it may try to iterate the bases of an |
Nick Lewycky | 19b9f95 | 2010-07-26 16:56:01 +0000 | [diff] [blame] | 789 | // uninitialized base. |
Argyrios Kyrtzidis | 181431c | 2010-07-06 15:36:58 +0000 | [diff] [blame] | 790 | Data.NumBases = Record[Idx++]; |
| 791 | Data.Bases = new(C) CXXBaseSpecifier [Data.NumBases]; |
| 792 | for (unsigned i = 0; i != Data.NumBases; ++i) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 793 | Data.Bases[i] = Reader.ReadCXXBaseSpecifier(F, Record, Idx); |
Argyrios Kyrtzidis | 181431c | 2010-07-06 15:36:58 +0000 | [diff] [blame] | 794 | |
| 795 | // FIXME: Make VBases lazily computed when needed to avoid storing them. |
| 796 | Data.NumVBases = Record[Idx++]; |
| 797 | Data.VBases = new(C) CXXBaseSpecifier [Data.NumVBases]; |
| 798 | for (unsigned i = 0; i != Data.NumVBases; ++i) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 799 | Data.VBases[i] = Reader.ReadCXXBaseSpecifier(F, Record, Idx); |
Argyrios Kyrtzidis | 181431c | 2010-07-06 15:36:58 +0000 | [diff] [blame] | 800 | |
| 801 | Reader.ReadUnresolvedSet(Data.Conversions, Record, Idx); |
| 802 | Reader.ReadUnresolvedSet(Data.VisibleConversions, Record, Idx); |
| 803 | assert(Data.Definition && "Data.Definition should be already set!"); |
| 804 | Data.FirstFriend |
| 805 | = cast_or_null<FriendDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 806 | } |
| 807 | |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 808 | enum CXXRecKind { |
| 809 | CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization |
| 810 | }; |
| 811 | switch ((CXXRecKind)Record[Idx++]) { |
| 812 | default: |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 813 | assert(false && "Out of sync with ASTDeclWriter::VisitCXXRecordDecl?"); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 814 | case CXXRecNotTemplate: |
| 815 | break; |
| 816 | case CXXRecTemplate: |
Argyrios Kyrtzidis | caf8248 | 2010-09-13 11:45:25 +0000 | [diff] [blame] | 817 | D->TemplateOrInstantiation |
| 818 | = cast<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 819 | break; |
| 820 | case CXXRecMemberSpecialization: { |
| 821 | CXXRecordDecl *RD = cast<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])); |
| 822 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 823 | SourceLocation POI = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | caf8248 | 2010-09-13 11:45:25 +0000 | [diff] [blame] | 824 | MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK); |
| 825 | MSI->setPointOfInstantiation(POI); |
| 826 | D->TemplateOrInstantiation = MSI; |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 827 | break; |
| 828 | } |
| 829 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 830 | } |
| 831 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 832 | void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 833 | VisitFunctionDecl(D); |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 834 | unsigned NumOverridenMethods = Record[Idx++]; |
| 835 | while (NumOverridenMethods--) { |
| 836 | CXXMethodDecl *MD = cast<CXXMethodDecl>(Reader.GetDecl(Record[Idx++])); |
| 837 | // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod, |
| 838 | // MD may be initializing. |
| 839 | Reader.getContext()->addOverriddenMethod(D, MD); |
| 840 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 841 | } |
| 842 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 843 | void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 844 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 845 | |
| 846 | D->IsExplicitSpecified = Record[Idx++]; |
| 847 | D->ImplicitlyDefined = Record[Idx++]; |
Argyrios Kyrtzidis | 5b6a03f | 2010-08-09 10:54:12 +0000 | [diff] [blame] | 848 | llvm::tie(D->BaseOrMemberInitializers, D->NumBaseOrMemberInitializers) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 849 | = Reader.ReadCXXBaseOrMemberInitializers(F, Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 850 | } |
| 851 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 852 | void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 853 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 854 | |
| 855 | D->ImplicitlyDefined = Record[Idx++]; |
| 856 | D->OperatorDelete = cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 857 | } |
| 858 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 859 | void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 860 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 861 | D->IsExplicitSpecified = Record[Idx++]; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 862 | } |
| 863 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 864 | void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) { |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 865 | VisitDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 866 | D->setColonLoc(ReadSourceLocation(Record, Idx)); |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 867 | } |
| 868 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 869 | void ASTDeclReader::VisitFriendDecl(FriendDecl *D) { |
Argyrios Kyrtzidis | a95d019 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 870 | VisitDecl(D); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 871 | if (Record[Idx++]) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 872 | D->Friend = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 873 | else |
| 874 | D->Friend = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
| 875 | D->NextFriend = cast_or_null<FriendDecl>(Reader.GetDecl(Record[Idx++])); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 876 | D->FriendLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 877 | } |
| 878 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 879 | void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { |
Argyrios Kyrtzidis | 165b581 | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 880 | VisitDecl(D); |
| 881 | unsigned NumParams = Record[Idx++]; |
| 882 | D->NumParams = NumParams; |
| 883 | D->Params = new TemplateParameterList*[NumParams]; |
| 884 | for (unsigned i = 0; i != NumParams; ++i) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 885 | D->Params[i] = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 165b581 | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 886 | if (Record[Idx++]) // HasFriendDecl |
| 887 | D->Friend = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
| 888 | else |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 889 | D->Friend = GetTypeSourceInfo(Record, Idx); |
| 890 | D->FriendLoc = ReadSourceLocation(Record, Idx); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 891 | } |
| 892 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 893 | void ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) { |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 894 | VisitNamedDecl(D); |
| 895 | |
Argyrios Kyrtzidis | 9f2d24a | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 896 | NamedDecl *TemplatedDecl |
| 897 | = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 898 | TemplateParameterList* TemplateParams |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 899 | = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 900 | D->init(TemplatedDecl, TemplateParams); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 901 | } |
| 902 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 903 | void ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 904 | // Initialize CommonOrPrev before VisitTemplateDecl so that getCommonPtr() |
| 905 | // can be used while this is still initializing. |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 906 | |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 907 | assert(D->CommonOrPrev.isNull() && "getCommonPtr was called earlier on this"); |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 908 | RedeclarableTemplateDecl *PrevDecl = |
| 909 | cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
| 910 | assert((PrevDecl == 0 || PrevDecl->getKind() == D->getKind()) && |
| 911 | "PrevDecl kind mismatch"); |
| 912 | if (PrevDecl) |
| 913 | D->CommonOrPrev = PrevDecl; |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 914 | if (PrevDecl == 0) { |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 915 | D->CommonOrPrev = D->newCommon(*Reader.getContext()); |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 916 | if (RedeclarableTemplateDecl *RTD |
| 917 | = cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(Record[Idx++]))) { |
| 918 | assert(RTD->getKind() == D->getKind() && |
| 919 | "InstantiatedFromMemberTemplate kind mismatch"); |
| 920 | D->setInstantiatedFromMemberTemplateImpl(RTD); |
| 921 | if (Record[Idx++]) |
| 922 | D->setMemberSpecialization(); |
| 923 | } |
Peter Collingbourne | 2bf3d24 | 2010-07-29 16:12:01 +0000 | [diff] [blame] | 924 | |
| 925 | RedeclarableTemplateDecl *LatestDecl = |
| 926 | cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 927 | |
| 928 | // This decl is a first one and the latest declaration that it points to is |
Sebastian Redl | d44cd6a | 2010-08-18 23:57:06 +0000 | [diff] [blame] | 929 | // in the same AST file. However, if this actually needs to point to a |
| 930 | // redeclaration in another AST file, we need to update it by checking |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 931 | // the FirstLatestDeclIDs map which tracks this kind of decls. |
| 932 | assert(Reader.GetDecl(ThisDeclID) == D && "Invalid ThisDeclID ?"); |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 933 | ASTReader::FirstLatestDeclIDMap::iterator I |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 934 | = Reader.FirstLatestDeclIDs.find(ThisDeclID); |
| 935 | if (I != Reader.FirstLatestDeclIDs.end()) { |
| 936 | Decl *NewLatest = Reader.GetDecl(I->second); |
| 937 | assert((LatestDecl->getLocation().isInvalid() || |
| 938 | NewLatest->getLocation().isInvalid() || |
| 939 | Reader.SourceMgr.isBeforeInTranslationUnit( |
| 940 | LatestDecl->getLocation(), |
| 941 | NewLatest->getLocation())) && |
| 942 | "The new latest is supposed to come after the previous latest"); |
| 943 | LatestDecl = cast<RedeclarableTemplateDecl>(NewLatest); |
| 944 | } |
| 945 | |
Peter Collingbourne | 2bf3d24 | 2010-07-29 16:12:01 +0000 | [diff] [blame] | 946 | assert(LatestDecl->getKind() == D->getKind() && "Latest kind mismatch"); |
| 947 | D->getCommonPtr()->Latest = LatestDecl; |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 948 | } |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 949 | |
| 950 | VisitTemplateDecl(D); |
| 951 | D->IdentifierNamespace = Record[Idx++]; |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 952 | } |
| 953 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 954 | void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 955 | VisitRedeclarableTemplateDecl(D); |
| 956 | |
| 957 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 958 | // This ClassTemplateDecl owns a CommonPtr; read it. |
| 959 | |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 960 | // FoldingSets are filled in VisitClassTemplateSpecializationDecl. |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 961 | unsigned size = Record[Idx++]; |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 962 | while (size--) |
| 963 | cast<ClassTemplateSpecializationDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 964 | |
| 965 | size = Record[Idx++]; |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 966 | while (size--) |
| 967 | cast<ClassTemplatePartialSpecializationDecl>( |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 968 | Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 969 | |
| 970 | // InjectedClassNameType is computed. |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 971 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 972 | } |
| 973 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 974 | void ASTDeclReader::VisitClassTemplateSpecializationDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 975 | ClassTemplateSpecializationDecl *D) { |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 976 | VisitCXXRecordDecl(D); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 977 | |
| 978 | ASTContext &C = *Reader.getContext(); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 979 | if (Decl *InstD = Reader.GetDecl(Record[Idx++])) { |
| 980 | if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) { |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 981 | D->SpecializedTemplate = CTD; |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 982 | } else { |
| 983 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 984 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 985 | TemplateArgumentList *ArgList |
| 986 | = new (C) TemplateArgumentList(C, TemplArgs.data(), TemplArgs.size()); |
| 987 | ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS |
| 988 | = new (C) ClassTemplateSpecializationDecl:: |
| 989 | SpecializedPartialSpecialization(); |
| 990 | PS->PartialSpecialization |
| 991 | = cast<ClassTemplatePartialSpecializationDecl>(InstD); |
| 992 | PS->TemplateArgs = ArgList; |
| 993 | D->SpecializedTemplate = PS; |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 994 | } |
| 995 | } |
| 996 | |
| 997 | // Explicit info. |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 998 | if (TypeSourceInfo *TyInfo = GetTypeSourceInfo(Record, Idx)) { |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 999 | ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo |
| 1000 | = new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo; |
| 1001 | ExplicitInfo->TypeAsWritten = TyInfo; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1002 | ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx); |
| 1003 | ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1004 | D->ExplicitInfo = ExplicitInfo; |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1005 | } |
| 1006 | |
| 1007 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1008 | Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1009 | D->TemplateArgs.init(C, TemplArgs.data(), TemplArgs.size()); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1010 | D->PointOfInstantiation = ReadSourceLocation(Record, Idx); |
Argyrios Kyrtzidis | b4c659b | 2010-09-13 11:45:32 +0000 | [diff] [blame] | 1011 | D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++]; |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1012 | |
Argyrios Kyrtzidis | c1624e9 | 2010-07-20 13:59:40 +0000 | [diff] [blame] | 1013 | if (D->isCanonicalDecl()) { // It's kept in the folding set. |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1014 | ClassTemplateDecl *CanonPattern |
| 1015 | = cast<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
| 1016 | if (ClassTemplatePartialSpecializationDecl *Partial |
| 1017 | = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) { |
Argyrios Kyrtzidis | f4cc7dc | 2010-07-12 21:41:31 +0000 | [diff] [blame] | 1018 | CanonPattern->getPartialSpecializations().InsertNode(Partial); |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1019 | } else { |
Argyrios Kyrtzidis | f4cc7dc | 2010-07-12 21:41:31 +0000 | [diff] [blame] | 1020 | CanonPattern->getSpecializations().InsertNode(D); |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1021 | } |
| 1022 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1023 | } |
| 1024 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1025 | void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1026 | ClassTemplatePartialSpecializationDecl *D) { |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1027 | VisitClassTemplateSpecializationDecl(D); |
| 1028 | |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1029 | ASTContext &C = *Reader.getContext(); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1030 | D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx); |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1031 | |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1032 | unsigned NumArgs = Record[Idx++]; |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1033 | if (NumArgs) { |
| 1034 | D->NumArgsAsWritten = NumArgs; |
| 1035 | D->ArgsAsWritten = new (C) TemplateArgumentLoc[NumArgs]; |
| 1036 | for (unsigned i=0; i != NumArgs; ++i) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1037 | D->ArgsAsWritten[i] = Reader.ReadTemplateArgumentLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1038 | } |
| 1039 | |
| 1040 | D->SequenceNumber = Record[Idx++]; |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1041 | |
| 1042 | // These are read/set from/to the first declaration. |
| 1043 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1044 | D->InstantiatedFromMember.setPointer( |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1045 | cast_or_null<ClassTemplatePartialSpecializationDecl>( |
| 1046 | Reader.GetDecl(Record[Idx++]))); |
Argyrios Kyrtzidis | 0e8b3ce | 2010-09-13 11:45:41 +0000 | [diff] [blame] | 1047 | D->InstantiatedFromMember.setInt(Record[Idx++]); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1048 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1049 | } |
| 1050 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1051 | void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1052 | VisitRedeclarableTemplateDecl(D); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1053 | |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1054 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1055 | // This FunctionTemplateDecl owns a CommonPtr; read it. |
| 1056 | |
Argyrios Kyrtzidis | 39fdf81 | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1057 | // Read the function specialization declarations. |
| 1058 | // FunctionTemplateDecl's FunctionTemplateSpecializationInfos are filled |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 1059 | // when reading the specialized FunctionDecl. |
Argyrios Kyrtzidis | 39fdf81 | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1060 | unsigned NumSpecs = Record[Idx++]; |
| 1061 | while (NumSpecs--) |
| 1062 | Reader.GetDecl(Record[Idx++]); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1063 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1064 | } |
| 1065 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1066 | void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1067 | VisitTypeDecl(D); |
| 1068 | |
| 1069 | D->setDeclaredWithTypename(Record[Idx++]); |
| 1070 | D->setParameterPack(Record[Idx++]); |
| 1071 | |
| 1072 | bool Inherited = Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1073 | TypeSourceInfo *DefArg = GetTypeSourceInfo(Record, Idx); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 1074 | D->setDefaultArgument(DefArg, Inherited); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1075 | } |
| 1076 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1077 | void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { |
Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1078 | VisitVarDecl(D); |
| 1079 | // TemplateParmPosition. |
| 1080 | D->setDepth(Record[Idx++]); |
| 1081 | D->setPosition(Record[Idx++]); |
| 1082 | // Rest of NonTypeTemplateParmDecl. |
| 1083 | if (Record[Idx++]) { |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1084 | Expr *DefArg = Reader.ReadExpr(F); |
Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1085 | bool Inherited = Record[Idx++]; |
| 1086 | D->setDefaultArgument(DefArg, Inherited); |
| 1087 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1088 | } |
| 1089 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1090 | void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { |
Argyrios Kyrtzidis | 9f2d24a | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1091 | VisitTemplateDecl(D); |
| 1092 | // TemplateParmPosition. |
| 1093 | D->setDepth(Record[Idx++]); |
| 1094 | D->setPosition(Record[Idx++]); |
| 1095 | // Rest of TemplateTemplateParmDecl. |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1096 | TemplateArgumentLoc Arg = Reader.ReadTemplateArgumentLoc(F, Record, Idx); |
Argyrios Kyrtzidis | 9f2d24a | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1097 | bool IsInherited = Record[Idx++]; |
| 1098 | D->setDefaultArgument(Arg, IsInherited); |
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::VisitStaticAssertDecl(StaticAssertDecl *D) { |
Argyrios Kyrtzidis | 2d8891c | 2010-07-22 17:28:12 +0000 | [diff] [blame] | 1102 | VisitDecl(D); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1103 | D->AssertExpr = Reader.ReadExpr(F); |
| 1104 | D->Message = cast<StringLiteral>(Reader.ReadExpr(F)); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1107 | std::pair<uint64_t, uint64_t> |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1108 | ASTDeclReader::VisitDeclContext(DeclContext *DC) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1109 | uint64_t LexicalOffset = Record[Idx++]; |
| 1110 | uint64_t VisibleOffset = Record[Idx++]; |
| 1111 | return std::make_pair(LexicalOffset, VisibleOffset); |
| 1112 | } |
| 1113 | |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1114 | template <typename T> |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1115 | void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1116 | enum RedeclKind { NoRedeclaration = 0, PointsToPrevious, PointsToLatest }; |
| 1117 | RedeclKind Kind = (RedeclKind)Record[Idx++]; |
| 1118 | switch (Kind) { |
| 1119 | default: |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1120 | assert(0 && "Out of sync with ASTDeclWriter::VisitRedeclarable or messed up" |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1121 | " reading"); |
| 1122 | case NoRedeclaration: |
| 1123 | break; |
| 1124 | case PointsToPrevious: |
| 1125 | D->RedeclLink = typename Redeclarable<T>::PreviousDeclLink( |
| 1126 | cast_or_null<T>(Reader.GetDecl(Record[Idx++]))); |
| 1127 | break; |
| 1128 | case PointsToLatest: |
| 1129 | D->RedeclLink = typename Redeclarable<T>::LatestDeclLink( |
| 1130 | cast_or_null<T>(Reader.GetDecl(Record[Idx++]))); |
| 1131 | break; |
| 1132 | } |
| 1133 | |
| 1134 | assert(!(Kind == PointsToPrevious && |
| 1135 | Reader.FirstLatestDeclIDs.find(ThisDeclID) != |
| 1136 | Reader.FirstLatestDeclIDs.end()) && |
| 1137 | "This decl is not first, it should not be in the map"); |
| 1138 | if (Kind == PointsToPrevious) |
| 1139 | return; |
| 1140 | |
| 1141 | // This decl is a first one and the latest declaration that it points to is in |
Sebastian Redl | d44cd6a | 2010-08-18 23:57:06 +0000 | [diff] [blame] | 1142 | // the same AST file. However, if this actually needs to point to a |
| 1143 | // redeclaration in another AST file, we need to update it by checking the |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1144 | // FirstLatestDeclIDs map which tracks this kind of decls. |
| 1145 | assert(Reader.GetDecl(ThisDeclID) == static_cast<T*>(D) && |
| 1146 | "Invalid ThisDeclID ?"); |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1147 | ASTReader::FirstLatestDeclIDMap::iterator I |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1148 | = Reader.FirstLatestDeclIDs.find(ThisDeclID); |
| 1149 | if (I != Reader.FirstLatestDeclIDs.end()) { |
| 1150 | Decl *NewLatest = Reader.GetDecl(I->second); |
| 1151 | assert((D->getMostRecentDeclaration()->getLocation().isInvalid() || |
| 1152 | NewLatest->getLocation().isInvalid() || |
| 1153 | Reader.SourceMgr.isBeforeInTranslationUnit( |
| 1154 | D->getMostRecentDeclaration()->getLocation(), |
| 1155 | NewLatest->getLocation())) && |
| 1156 | "The new latest is supposed to come after the previous latest"); |
| 1157 | D->RedeclLink |
| 1158 | = typename Redeclarable<T>::LatestDeclLink(cast_or_null<T>(NewLatest)); |
| 1159 | } |
| 1160 | } |
| 1161 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1162 | //===----------------------------------------------------------------------===// |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1163 | // Attribute Reading |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1164 | //===----------------------------------------------------------------------===// |
| 1165 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1166 | /// \brief Reads attributes from the current stream position. |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1167 | void ASTReader::ReadAttributes(PerFileData &F, AttrVec &Attrs) { |
| 1168 | llvm::BitstreamCursor &DeclsCursor = F.DeclsCursor; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1169 | unsigned Code = DeclsCursor.ReadCode(); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1170 | assert(Code == llvm::bitc::UNABBREV_RECORD && |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1171 | "Expected unabbreviated record"); (void)Code; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1172 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1173 | RecordData Record; |
| 1174 | unsigned Idx = 0; |
| 1175 | unsigned RecCode = DeclsCursor.ReadRecord(Code, Record); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1176 | assert(RecCode == DECL_ATTR && "Expected attribute record"); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1177 | (void)RecCode; |
| 1178 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1179 | while (Idx < Record.size()) { |
| 1180 | Attr *New = 0; |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1181 | attr::Kind Kind = (attr::Kind)Record[Idx++]; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1182 | SourceLocation Loc = ReadSourceLocation(F, Record, Idx); |
Alexis Hunt | dcfba7b | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 1183 | bool isInherited = Record[Idx++]; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1184 | |
Alexis Hunt | dcfba7b | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 1185 | #include "clang/Serialization/AttrPCHRead.inc" |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1186 | |
| 1187 | assert(New && "Unable to decode attribute?"); |
Alexis Hunt | dcfba7b | 2010-08-18 23:23:40 +0000 | [diff] [blame] | 1188 | New->setInherited(isInherited); |
| 1189 | Attrs.push_back(New); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1190 | } |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1191 | } |
| 1192 | |
| 1193 | //===----------------------------------------------------------------------===// |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1194 | // ASTReader Implementation |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1195 | //===----------------------------------------------------------------------===// |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1196 | |
| 1197 | /// \brief Note that we have loaded the declaration with the given |
| 1198 | /// Index. |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1199 | /// |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1200 | /// This routine notes that this declaration has already been loaded, |
| 1201 | /// so that future GetDecl calls will return this declaration rather |
| 1202 | /// than trying to load a new declaration. |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1203 | inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1204 | assert(!DeclsLoaded[Index] && "Decl loaded twice?"); |
| 1205 | DeclsLoaded[Index] = D; |
| 1206 | } |
| 1207 | |
| 1208 | |
| 1209 | /// \brief Determine whether the consumer will be interested in seeing |
| 1210 | /// this declaration (via HandleTopLevelDecl). |
| 1211 | /// |
| 1212 | /// This routine should return true for anything that might affect |
| 1213 | /// code generation, e.g., inline function definitions, Objective-C |
| 1214 | /// declarations with metadata, etc. |
| 1215 | static bool isConsumerInterestedIn(Decl *D) { |
Daniel Dunbar | 865c2a7 | 2009-09-17 03:06:44 +0000 | [diff] [blame] | 1216 | if (isa<FileScopeAsmDecl>(D)) |
| 1217 | return true; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1218 | if (VarDecl *Var = dyn_cast<VarDecl>(D)) |
Argyrios Kyrtzidis | 4ba81b2 | 2010-08-05 09:47:59 +0000 | [diff] [blame] | 1219 | return Var->isFileVarDecl() && |
| 1220 | Var->isThisDeclarationADefinition() == VarDecl::Definition; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1221 | if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D)) |
| 1222 | return Func->isThisDeclarationADefinition(); |
Argyrios Kyrtzidis | 13257c5 | 2010-08-09 10:54:20 +0000 | [diff] [blame] | 1223 | return isa<ObjCProtocolDecl>(D) || isa<ObjCImplementationDecl>(D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1224 | } |
| 1225 | |
Sebastian Redl | 3462779 | 2010-07-20 22:46:15 +0000 | [diff] [blame] | 1226 | /// \brief Get the correct cursor and offset for loading a type. |
Sebastian Redl | 2c499f6 | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 1227 | ASTReader::RecordLocation |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1228 | ASTReader::DeclCursorForIndex(unsigned Index, DeclID ID) { |
Sebastian Redl | e7c1fe6 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1229 | // See if there's an override. |
| 1230 | DeclReplacementMap::iterator It = ReplacedDecls.find(ID); |
| 1231 | if (It != ReplacedDecls.end()) |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1232 | return RecordLocation(It->second.first, It->second.second); |
Sebastian Redl | e7c1fe6 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1233 | |
Sebastian Redl | 3462779 | 2010-07-20 22:46:15 +0000 | [diff] [blame] | 1234 | PerFileData *F = 0; |
| 1235 | for (unsigned I = 0, N = Chain.size(); I != N; ++I) { |
| 1236 | F = Chain[N - I - 1]; |
| 1237 | if (Index < F->LocalNumDecls) |
| 1238 | break; |
| 1239 | Index -= F->LocalNumDecls; |
| 1240 | } |
| 1241 | assert(F && F->LocalNumDecls > Index && "Broken chain"); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1242 | return RecordLocation(F, F->DeclOffsets[Index]); |
Sebastian Redl | 3462779 | 2010-07-20 22:46:15 +0000 | [diff] [blame] | 1243 | } |
| 1244 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1245 | /// \brief Read the declaration at the given offset from the AST file. |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1246 | Decl *ASTReader::ReadDeclRecord(unsigned Index, DeclID ID) { |
Sebastian Redl | e7c1fe6 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1247 | RecordLocation Loc = DeclCursorForIndex(Index, ID); |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1248 | llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1249 | // Keep track of where we are in the stream, then jump back there |
| 1250 | // after reading this declaration. |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1251 | SavedStreamPosition SavedPosition(DeclsCursor); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1252 | |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1253 | ReadingKindTracker ReadingKind(Read_Decl, *this); |
| 1254 | |
Douglas Gregor | 1342e84 | 2009-07-06 18:54:52 +0000 | [diff] [blame] | 1255 | // Note that we are loading a declaration record. |
Argyrios Kyrtzidis | b24355a | 2010-07-30 10:03:16 +0000 | [diff] [blame] | 1256 | Deserializing ADecl(this); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1257 | |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1258 | DeclsCursor.JumpToBit(Loc.Offset); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1259 | RecordData Record; |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1260 | unsigned Code = DeclsCursor.ReadCode(); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1261 | unsigned Idx = 0; |
Sebastian Redl | 2c373b9 | 2010-10-05 15:59:54 +0000 | [diff] [blame] | 1262 | ASTDeclReader Reader(*this, *Loc.F, DeclsCursor, ID, Record, Idx); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1263 | |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1264 | Decl *D = 0; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1265 | switch ((DeclCode)DeclsCursor.ReadRecord(Code, Record)) { |
| 1266 | case DECL_ATTR: |
| 1267 | case DECL_CONTEXT_LEXICAL: |
| 1268 | case DECL_CONTEXT_VISIBLE: |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1269 | assert(false && "Record cannot be de-serialized with ReadDeclRecord"); |
| 1270 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1271 | case DECL_TRANSLATION_UNIT: |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1272 | assert(Index == 0 && "Translation unit must be at index 0"); |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1273 | D = Context->getTranslationUnitDecl(); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1274 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1275 | case DECL_TYPEDEF: |
John McCall | 703a3f8 | 2009-10-24 08:00:42 +0000 | [diff] [blame] | 1276 | D = TypedefDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1277 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1278 | case DECL_ENUM: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1279 | D = EnumDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1280 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1281 | case DECL_RECORD: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1282 | D = RecordDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1283 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1284 | case DECL_ENUM_CONSTANT: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1285 | D = EnumConstantDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1286 | 0, llvm::APSInt()); |
| 1287 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1288 | case DECL_FUNCTION: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1289 | D = FunctionDecl::Create(*Context, 0, SourceLocation(), DeclarationName(), |
Argyrios Kyrtzidis | 60ed560 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 1290 | QualType(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1291 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1292 | case DECL_LINKAGE_SPEC: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1293 | D = LinkageSpecDecl::Create(*Context, 0, SourceLocation(), |
| 1294 | (LinkageSpecDecl::LanguageIDs)0, |
| 1295 | false); |
| 1296 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1297 | case DECL_NAMESPACE: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1298 | D = NamespaceDecl::Create(*Context, 0, SourceLocation(), 0); |
| 1299 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1300 | case DECL_NAMESPACE_ALIAS: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1301 | D = NamespaceAliasDecl::Create(*Context, 0, SourceLocation(), |
| 1302 | SourceLocation(), 0, SourceRange(), 0, |
| 1303 | SourceLocation(), 0); |
| 1304 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1305 | case DECL_USING: |
Abramo Bagnara | 8de74e9 | 2010-08-12 11:46:03 +0000 | [diff] [blame] | 1306 | D = UsingDecl::Create(*Context, 0, SourceRange(), SourceLocation(), |
| 1307 | 0, DeclarationNameInfo(), false); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1308 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1309 | case DECL_USING_SHADOW: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1310 | D = UsingShadowDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
| 1311 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1312 | case DECL_USING_DIRECTIVE: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1313 | D = UsingDirectiveDecl::Create(*Context, 0, SourceLocation(), |
| 1314 | SourceLocation(), SourceRange(), 0, |
| 1315 | SourceLocation(), 0, 0); |
| 1316 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1317 | case DECL_UNRESOLVED_USING_VALUE: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1318 | D = UnresolvedUsingValueDecl::Create(*Context, 0, SourceLocation(), |
Abramo Bagnara | 8de74e9 | 2010-08-12 11:46:03 +0000 | [diff] [blame] | 1319 | SourceRange(), 0, |
| 1320 | DeclarationNameInfo()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1321 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1322 | case DECL_UNRESOLVED_USING_TYPENAME: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1323 | D = UnresolvedUsingTypenameDecl::Create(*Context, 0, SourceLocation(), |
| 1324 | SourceLocation(), SourceRange(), |
| 1325 | 0, SourceLocation(), |
| 1326 | DeclarationName()); |
| 1327 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1328 | case DECL_CXX_RECORD: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1329 | D = CXXRecordDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1330 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1331 | case DECL_CXX_METHOD: |
Abramo Bagnara | d6d2f18 | 2010-08-11 22:01:17 +0000 | [diff] [blame] | 1332 | D = CXXMethodDecl::Create(*Context, 0, DeclarationNameInfo(), |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1333 | QualType(), 0); |
| 1334 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1335 | case DECL_CXX_CONSTRUCTOR: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1336 | D = CXXConstructorDecl::Create(*Context, Decl::EmptyShell()); |
| 1337 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1338 | case DECL_CXX_DESTRUCTOR: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1339 | D = CXXDestructorDecl::Create(*Context, Decl::EmptyShell()); |
| 1340 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1341 | case DECL_CXX_CONVERSION: |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1342 | D = CXXConversionDecl::Create(*Context, Decl::EmptyShell()); |
| 1343 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1344 | case DECL_ACCESS_SPEC: |
Argyrios Kyrtzidis | 260b4a8 | 2010-09-08 21:32:35 +0000 | [diff] [blame] | 1345 | D = AccessSpecDecl::Create(*Context, Decl::EmptyShell()); |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1346 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1347 | case DECL_FRIEND: |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1348 | D = FriendDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1349 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1350 | case DECL_FRIEND_TEMPLATE: |
Argyrios Kyrtzidis | 165b581 | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1351 | D = FriendTemplateDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1352 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1353 | case DECL_CLASS_TEMPLATE: |
Argyrios Kyrtzidis | a35c8e4 | 2010-06-21 10:57:41 +0000 | [diff] [blame] | 1354 | D = ClassTemplateDecl::Create(*Context, 0, SourceLocation(), |
| 1355 | DeclarationName(), 0, 0, 0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1356 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1357 | case DECL_CLASS_TEMPLATE_SPECIALIZATION: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1358 | D = ClassTemplateSpecializationDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1359 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1360 | case DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1361 | D = ClassTemplatePartialSpecializationDecl::Create(*Context, |
| 1362 | Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1363 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1364 | case DECL_FUNCTION_TEMPLATE: |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1365 | D = FunctionTemplateDecl::Create(*Context, 0, SourceLocation(), |
| 1366 | DeclarationName(), 0, 0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1367 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1368 | case DECL_TEMPLATE_TYPE_PARM: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1369 | D = TemplateTypeParmDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1370 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1371 | case DECL_NON_TYPE_TEMPLATE_PARM: |
Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1372 | D = NonTypeTemplateParmDecl::Create(*Context, 0, SourceLocation(), 0,0,0, |
| 1373 | QualType(),0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1374 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1375 | case DECL_TEMPLATE_TEMPLATE_PARM: |
Argyrios Kyrtzidis | 9f2d24a | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1376 | D = TemplateTemplateParmDecl::Create(*Context, 0, SourceLocation(),0,0,0,0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1377 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1378 | case DECL_STATIC_ASSERT: |
Argyrios Kyrtzidis | 2d8891c | 2010-07-22 17:28:12 +0000 | [diff] [blame] | 1379 | D = StaticAssertDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1380 | break; |
| 1381 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1382 | case DECL_OBJC_METHOD: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1383 | D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(), |
Douglas Gregor | 12852d9 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 1384 | Selector(), QualType(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1385 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1386 | case DECL_OBJC_INTERFACE: |
Douglas Gregor | 1c28331 | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 1387 | D = ObjCInterfaceDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1388 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1389 | case DECL_OBJC_IVAR: |
Argyrios Kyrtzidis | 60ed560 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 1390 | D = ObjCIvarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1391 | ObjCIvarDecl::None); |
| 1392 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1393 | case DECL_OBJC_PROTOCOL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1394 | D = ObjCProtocolDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1395 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1396 | case DECL_OBJC_AT_DEFS_FIELD: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1397 | D = ObjCAtDefsFieldDecl::Create(*Context, 0, SourceLocation(), 0, |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1398 | QualType(), 0); |
| 1399 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1400 | case DECL_OBJC_CLASS: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1401 | D = ObjCClassDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1402 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1403 | case DECL_OBJC_FORWARD_PROTOCOL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1404 | D = ObjCForwardProtocolDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1405 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1406 | case DECL_OBJC_CATEGORY: |
Douglas Gregor | 071676f | 2010-01-16 16:38:58 +0000 | [diff] [blame] | 1407 | D = ObjCCategoryDecl::Create(*Context, 0, SourceLocation(), |
| 1408 | SourceLocation(), SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1409 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1410 | case DECL_OBJC_CATEGORY_IMPL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1411 | D = ObjCCategoryImplDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1412 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1413 | case DECL_OBJC_IMPLEMENTATION: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1414 | D = ObjCImplementationDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1415 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1416 | case DECL_OBJC_COMPATIBLE_ALIAS: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1417 | D = ObjCCompatibleAliasDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1418 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1419 | case DECL_OBJC_PROPERTY: |
Fariborz Jahanian | da8ec2b | 2010-01-21 17:36:00 +0000 | [diff] [blame] | 1420 | D = ObjCPropertyDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(), |
John McCall | 339bb66 | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 1421 | 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1422 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1423 | case DECL_OBJC_PROPERTY_IMPL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1424 | D = ObjCPropertyImplDecl::Create(*Context, 0, SourceLocation(), |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1425 | SourceLocation(), 0, |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1426 | ObjCPropertyImplDecl::Dynamic, 0); |
| 1427 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1428 | case DECL_FIELD: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1429 | D = FieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, 0, |
Argyrios Kyrtzidis | 6032ef1 | 2009-08-21 00:31:54 +0000 | [diff] [blame] | 1430 | false); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1431 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1432 | case DECL_VAR: |
Argyrios Kyrtzidis | 60ed560 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 1433 | D = VarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, |
John McCall | 8e7d656 | 2010-08-26 03:08:43 +0000 | [diff] [blame] | 1434 | SC_None, SC_None); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1435 | break; |
| 1436 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1437 | case DECL_IMPLICIT_PARAM: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1438 | D = ImplicitParamDecl::Create(*Context, 0, SourceLocation(), 0, QualType()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1439 | break; |
| 1440 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1441 | case DECL_PARM_VAR: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1442 | D = ParmVarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, |
John McCall | 8e7d656 | 2010-08-26 03:08:43 +0000 | [diff] [blame] | 1443 | SC_None, SC_None, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1444 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1445 | case DECL_FILE_SCOPE_ASM: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1446 | D = FileScopeAsmDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1447 | break; |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1448 | case DECL_BLOCK: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1449 | D = BlockDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1450 | break; |
| 1451 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1452 | |
Sebastian Redl | b3298c3 | 2010-08-18 23:56:48 +0000 | [diff] [blame] | 1453 | assert(D && "Unknown declaration reading AST file"); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1454 | LoadedDecl(Index, D); |
| 1455 | Reader.Visit(D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1456 | |
| 1457 | // If this declaration is also a declaration context, get the |
| 1458 | // offsets for its tables of lexical and visible declarations. |
| 1459 | if (DeclContext *DC = dyn_cast<DeclContext>(D)) { |
| 1460 | std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC); |
| 1461 | if (Offsets.first || Offsets.second) { |
| 1462 | DC->setHasExternalLexicalStorage(Offsets.first != 0); |
| 1463 | DC->setHasExternalVisibleStorage(Offsets.second != 0); |
Sebastian Redl | 66c5eef | 2010-07-27 00:17:23 +0000 | [diff] [blame] | 1464 | DeclContextInfo Info; |
| 1465 | if (ReadDeclContextStorage(DeclsCursor, Offsets, Info)) |
| 1466 | return 0; |
Sebastian Redl | 4b1f490 | 2010-07-27 18:24:41 +0000 | [diff] [blame] | 1467 | DeclContextInfos &Infos = DeclContextOffsets[DC]; |
Sebastian Redl | d7dce0a | 2010-08-24 00:50:04 +0000 | [diff] [blame] | 1468 | // Reading the TU will happen after reading its lexical update blocks, |
| 1469 | // so we need to make sure we insert in front. For all other contexts, |
| 1470 | // the vector is empty here anyway, so there's no loss in efficiency. |
Sebastian Redl | 4b1f490 | 2010-07-27 18:24:41 +0000 | [diff] [blame] | 1471 | Infos.insert(Infos.begin(), Info); |
Sebastian Redl | d7dce0a | 2010-08-24 00:50:04 +0000 | [diff] [blame] | 1472 | |
| 1473 | // Now add the pending visible updates for this decl context, if it has |
| 1474 | // any. |
| 1475 | DeclContextVisibleUpdatesPending::iterator I = |
| 1476 | PendingVisibleUpdates.find(ID); |
| 1477 | if (I != PendingVisibleUpdates.end()) { |
| 1478 | DeclContextVisibleUpdates &U = I->second; |
| 1479 | Info.LexicalDecls = 0; |
| 1480 | Info.NumLexicalDecls = 0; |
| 1481 | for (DeclContextVisibleUpdates::iterator UI = U.begin(), UE = U.end(); |
| 1482 | UI != UE; ++UI) { |
| 1483 | Info.NameLookupTableData = *UI; |
| 1484 | Infos.push_back(Info); |
| 1485 | } |
| 1486 | PendingVisibleUpdates.erase(I); |
| 1487 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1488 | } |
| 1489 | } |
Sebastian Redl | aba202b | 2010-08-24 22:50:19 +0000 | [diff] [blame] | 1490 | |
| 1491 | // If this is a template, read additional specializations that may be in a |
| 1492 | // different part of the chain. |
| 1493 | if (isa<RedeclarableTemplateDecl>(D)) { |
| 1494 | AdditionalTemplateSpecializationsMap::iterator F = |
| 1495 | AdditionalTemplateSpecializationsPending.find(ID); |
| 1496 | if (F != AdditionalTemplateSpecializationsPending.end()) { |
| 1497 | for (AdditionalTemplateSpecializations::iterator I = F->second.begin(), |
| 1498 | E = F->second.end(); |
| 1499 | I != E; ++I) |
| 1500 | GetDecl(*I); |
| 1501 | AdditionalTemplateSpecializationsPending.erase(F); |
| 1502 | } |
| 1503 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1504 | assert(Idx == Record.size()); |
| 1505 | |
| 1506 | // If we have deserialized a declaration that has a definition the |
Argyrios Kyrtzidis | 903ccd6 | 2010-07-07 15:46:26 +0000 | [diff] [blame] | 1507 | // AST consumer might need to know about, queue it. |
| 1508 | // We don't pass it to the consumer immediately because we may be in recursive |
| 1509 | // loading, and some declarations may still be initializing. |
| 1510 | if (isConsumerInterestedIn(D)) |
| 1511 | InterestingDecls.push_back(D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1512 | |
| 1513 | return D; |
| 1514 | } |