Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1 | //===--- PCHReaderDecl.cpp - Decl Deserialization ---------------*- C++ -*-===// |
| 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 | // |
| 10 | // This file implements the PCHReader::ReadDeclRecord method, which is the |
| 11 | // entrypoint for loading a decl. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang/Frontend/PCHReader.h" |
| 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; |
| 24 | |
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 { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 31 | class PCHDeclReader : public DeclVisitor<PCHDeclReader, void> { |
| 32 | PCHReader &Reader; |
| 33 | const PCHReader::RecordData &Record; |
| 34 | unsigned &Idx; |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 35 | pch::TypeID TypeIDForTypeDecl; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 36 | |
| 37 | public: |
| 38 | PCHDeclReader(PCHReader &Reader, const PCHReader::RecordData &Record, |
| 39 | unsigned &Idx) |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 40 | : Reader(Reader), Record(Record), Idx(Idx), TypeIDForTypeDecl(0) { } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 41 | |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 42 | CXXBaseSpecifier ReadCXXBaseSpecifier(); |
John McCall | 1c70e99 | 2010-06-03 19:28:45 +0000 | [diff] [blame] | 43 | |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 44 | void Visit(Decl *D); |
| 45 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 46 | void VisitDecl(Decl *D); |
| 47 | void VisitTranslationUnitDecl(TranslationUnitDecl *TU); |
| 48 | void VisitNamedDecl(NamedDecl *ND); |
Douglas Gregor | e31bbd9 | 2010-02-21 18:22:14 +0000 | [diff] [blame] | 49 | void VisitNamespaceDecl(NamespaceDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 50 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); |
| 51 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 52 | void VisitTypeDecl(TypeDecl *TD); |
| 53 | void VisitTypedefDecl(TypedefDecl *TD); |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 54 | void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 55 | void VisitTagDecl(TagDecl *TD); |
| 56 | void VisitEnumDecl(EnumDecl *ED); |
| 57 | void VisitRecordDecl(RecordDecl *RD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 58 | void VisitCXXRecordDecl(CXXRecordDecl *D); |
| 59 | void VisitClassTemplateSpecializationDecl( |
| 60 | ClassTemplateSpecializationDecl *D); |
| 61 | void VisitClassTemplatePartialSpecializationDecl( |
| 62 | ClassTemplatePartialSpecializationDecl *D); |
| 63 | void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 64 | void VisitValueDecl(ValueDecl *VD); |
| 65 | void VisitEnumConstantDecl(EnumConstantDecl *ECD); |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 66 | void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 67 | void VisitDeclaratorDecl(DeclaratorDecl *DD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 68 | void VisitFunctionDecl(FunctionDecl *FD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 69 | void VisitCXXMethodDecl(CXXMethodDecl *D); |
| 70 | void VisitCXXConstructorDecl(CXXConstructorDecl *D); |
| 71 | void VisitCXXDestructorDecl(CXXDestructorDecl *D); |
| 72 | void VisitCXXConversionDecl(CXXConversionDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 73 | void VisitFieldDecl(FieldDecl *FD); |
| 74 | void VisitVarDecl(VarDecl *VD); |
| 75 | void VisitImplicitParamDecl(ImplicitParamDecl *PD); |
| 76 | void VisitParmVarDecl(ParmVarDecl *PD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 77 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); |
| 78 | void VisitTemplateDecl(TemplateDecl *D); |
| 79 | void VisitClassTemplateDecl(ClassTemplateDecl *D); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 80 | void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 81 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); |
Argyrios Kyrtzidis | 41d4562 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 82 | void VisitUsingDecl(UsingDecl *D); |
| 83 | void VisitUsingShadowDecl(UsingShadowDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 84 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 85 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD); |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 86 | void VisitAccessSpecDecl(AccessSpecDecl *D); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 87 | void VisitFriendDecl(FriendDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 88 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); |
| 89 | void VisitStaticAssertDecl(StaticAssertDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 90 | void VisitBlockDecl(BlockDecl *BD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 91 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 92 | std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 93 | |
Alexis Hunt | ed05325 | 2010-05-30 07:21:58 +0000 | [diff] [blame] | 94 | // FIXME: Reorder according to DeclNodes.td? |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 95 | void VisitObjCMethodDecl(ObjCMethodDecl *D); |
| 96 | void VisitObjCContainerDecl(ObjCContainerDecl *D); |
| 97 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); |
| 98 | void VisitObjCIvarDecl(ObjCIvarDecl *D); |
| 99 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); |
| 100 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); |
| 101 | void VisitObjCClassDecl(ObjCClassDecl *D); |
| 102 | void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D); |
| 103 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); |
| 104 | void VisitObjCImplDecl(ObjCImplDecl *D); |
| 105 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); |
| 106 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); |
| 107 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); |
| 108 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
| 109 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
| 110 | }; |
| 111 | } |
| 112 | |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 113 | void PCHDeclReader::Visit(Decl *D) { |
| 114 | DeclVisitor<PCHDeclReader, void>::Visit(D); |
| 115 | |
| 116 | // if we have a fully initialized TypeDecl, we can safely read its type now. |
| 117 | if (TypeDecl *TD = dyn_cast<TypeDecl>(D)) |
| 118 | TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtr()); |
| 119 | } |
| 120 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 121 | void PCHDeclReader::VisitDecl(Decl *D) { |
| 122 | D->setDeclContext(cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++]))); |
| 123 | D->setLexicalDeclContext( |
| 124 | cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++]))); |
| 125 | D->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 126 | D->setInvalidDecl(Record[Idx++]); |
| 127 | if (Record[Idx++]) |
Argyrios Kyrtzidis | 9116717 | 2010-06-11 23:09:25 +0000 | [diff] [blame] | 128 | D->initAttrs(Reader.ReadAttributes()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 129 | D->setImplicit(Record[Idx++]); |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 130 | D->setUsed(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 131 | D->setAccess((AccessSpecifier)Record[Idx++]); |
Douglas Gregor | 16bef85 | 2009-10-16 20:01:17 +0000 | [diff] [blame] | 132 | D->setPCHLevel(Record[Idx++] + 1); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | void PCHDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { |
| 136 | VisitDecl(TU); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 137 | TU->setAnonymousNamespace( |
| 138 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | void PCHDeclReader::VisitNamedDecl(NamedDecl *ND) { |
| 142 | VisitDecl(ND); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 143 | ND->setDeclName(Reader.ReadDeclarationName(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | void PCHDeclReader::VisitTypeDecl(TypeDecl *TD) { |
| 147 | VisitNamedDecl(TD); |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 148 | // Delay type reading until after we have fully initialized the decl. |
| 149 | TypeIDForTypeDecl = Record[Idx++]; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | void PCHDeclReader::VisitTypedefDecl(TypedefDecl *TD) { |
Argyrios Kyrtzidis | 318b0e7 | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 153 | VisitTypeDecl(TD); |
John McCall | bcd0350 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 154 | TD->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | void PCHDeclReader::VisitTagDecl(TagDecl *TD) { |
| 158 | VisitTypeDecl(TD); |
Douglas Gregor | b6b8f9e | 2009-07-29 23:36:44 +0000 | [diff] [blame] | 159 | TD->setPreviousDeclaration( |
| 160 | cast_or_null<TagDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 161 | TD->setTagKind((TagDecl::TagKind)Record[Idx++]); |
| 162 | TD->setDefinition(Record[Idx++]); |
Douglas Gregor | 5089c76 | 2010-02-12 17:40:34 +0000 | [diff] [blame] | 163 | TD->setEmbeddedInDeclarator(Record[Idx++]); |
Argyrios Kyrtzidis | 664b690 | 2009-07-14 03:18:02 +0000 | [diff] [blame] | 164 | TD->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 82fe3e3 | 2009-07-21 14:46:17 +0000 | [diff] [blame] | 165 | TD->setTagKeywordLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
John McCall | 3e11ebe | 2010-03-15 10:12:16 +0000 | [diff] [blame] | 166 | // FIXME: maybe read optional qualifier and its range. |
| 167 | TD->setTypedefForAnonDecl( |
| 168 | cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | void PCHDeclReader::VisitEnumDecl(EnumDecl *ED) { |
| 172 | VisitTagDecl(ED); |
| 173 | ED->setIntegerType(Reader.GetType(Record[Idx++])); |
John McCall | 5677499 | 2009-12-09 09:09:27 +0000 | [diff] [blame] | 174 | ED->setPromotionType(Reader.GetType(Record[Idx++])); |
John McCall | 9aa35be | 2010-05-06 08:49:23 +0000 | [diff] [blame] | 175 | ED->setNumPositiveBits(Record[Idx++]); |
| 176 | ED->setNumNegativeBits(Record[Idx++]); |
Douglas Gregor | 7a74938 | 2009-05-27 17:20:35 +0000 | [diff] [blame] | 177 | // FIXME: C++ InstantiatedFrom |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | void PCHDeclReader::VisitRecordDecl(RecordDecl *RD) { |
| 181 | VisitTagDecl(RD); |
| 182 | RD->setHasFlexibleArrayMember(Record[Idx++]); |
| 183 | RD->setAnonymousStructOrUnion(Record[Idx++]); |
Fariborz Jahanian | 8e0d042 | 2009-07-08 16:37:44 +0000 | [diff] [blame] | 184 | RD->setHasObjectMember(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | void PCHDeclReader::VisitValueDecl(ValueDecl *VD) { |
| 188 | VisitNamedDecl(VD); |
| 189 | VD->setType(Reader.GetType(Record[Idx++])); |
| 190 | } |
| 191 | |
| 192 | void PCHDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { |
| 193 | VisitValueDecl(ECD); |
| 194 | if (Record[Idx++]) |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 195 | ECD->setInitExpr(Reader.ReadExpr()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 196 | ECD->setInitVal(Reader.ReadAPSInt(Record, Idx)); |
| 197 | } |
| 198 | |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 199 | void PCHDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { |
| 200 | VisitValueDecl(DD); |
John McCall | bcd0350 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 201 | TypeSourceInfo *TInfo = Reader.GetTypeSourceInfo(Record, Idx); |
| 202 | if (TInfo) |
| 203 | DD->setTypeSourceInfo(TInfo); |
John McCall | 3e11ebe | 2010-03-15 10:12:16 +0000 | [diff] [blame] | 204 | // FIXME: read optional qualifier and its range. |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 205 | } |
| 206 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 207 | void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 208 | VisitDeclaratorDecl(FD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 209 | |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 210 | switch ((FunctionDecl::TemplatedKind)Record[Idx++]) { |
Argyrios Kyrtzidis | 0b0369a | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 211 | default: assert(false && "Unhandled TemplatedKind!"); |
| 212 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 213 | case FunctionDecl::TK_NonTemplate: |
| 214 | break; |
| 215 | case FunctionDecl::TK_FunctionTemplate: |
| 216 | FD->setDescribedFunctionTemplate( |
| 217 | cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]))); |
| 218 | break; |
| 219 | case FunctionDecl::TK_MemberSpecialization: { |
| 220 | FunctionDecl *InstFD = cast<FunctionDecl>(Reader.GetDecl(Record[Idx++])); |
| 221 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
| 222 | SourceLocation POI = Reader.ReadSourceLocation(Record, Idx); |
| 223 | FD->setInstantiationOfMemberFunction(InstFD, TSK); |
| 224 | FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI); |
| 225 | break; |
| 226 | } |
| 227 | case FunctionDecl::TK_FunctionTemplateSpecialization: { |
| 228 | FunctionTemplateDecl *Template |
| 229 | = cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
| 230 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
| 231 | |
| 232 | // Template arguments. |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 233 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 234 | Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 235 | |
| 236 | // Template args as written. |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 237 | llvm::SmallVector<TemplateArgumentLoc, 8> TemplArgLocs; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 238 | SourceLocation LAngleLoc, RAngleLoc; |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 239 | if (Record[Idx++]) { // TemplateArgumentsAsWritten != 0 |
| 240 | unsigned NumTemplateArgLocs = Record[Idx++]; |
| 241 | TemplArgLocs.reserve(NumTemplateArgLocs); |
| 242 | for (unsigned i=0; i != NumTemplateArgLocs; ++i) |
| 243 | TemplArgLocs.push_back(Reader.ReadTemplateArgumentLoc(Record, Idx)); |
| 244 | |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 245 | LAngleLoc = Reader.ReadSourceLocation(Record, Idx); |
| 246 | RAngleLoc = Reader.ReadSourceLocation(Record, Idx); |
| 247 | } |
| 248 | |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 249 | FD->setFunctionTemplateSpecialization(Template, TemplArgs.size(), |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 250 | TemplArgs.data(), TSK, |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 251 | TemplArgLocs.size(), |
| 252 | TemplArgLocs.data(), |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 253 | LAngleLoc, RAngleLoc); |
Argyrios Kyrtzidis | 0b0369a | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 254 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 255 | } |
| 256 | case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { |
| 257 | // Templates. |
| 258 | UnresolvedSet<8> TemplDecls; |
| 259 | unsigned NumTemplates = Record[Idx++]; |
| 260 | while (NumTemplates--) |
| 261 | TemplDecls.addDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 262 | |
| 263 | // Templates args. |
| 264 | TemplateArgumentListInfo TemplArgs; |
| 265 | unsigned NumArgs = Record[Idx++]; |
| 266 | while (NumArgs--) |
| 267 | TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(Record, Idx)); |
| 268 | |
| 269 | FD->setDependentTemplateSpecialization(*Reader.getContext(), |
| 270 | TemplDecls, TemplArgs); |
Argyrios Kyrtzidis | 0b0369a | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 271 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 272 | } |
| 273 | } |
Argyrios Kyrtzidis | 373a83a | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 274 | |
| 275 | if (Record[Idx++]) |
| 276 | FD->setLazyBody(Reader.getDeclsCursor().GetCurrentBitNo()); |
| 277 | FD->setPreviousDeclaration( |
| 278 | cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); |
| 279 | FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]); |
| 280 | FD->setStorageClassAsWritten((FunctionDecl::StorageClass)Record[Idx++]); |
| 281 | FD->setInlineSpecified(Record[Idx++]); |
| 282 | FD->setVirtualAsWritten(Record[Idx++]); |
| 283 | FD->setPure(Record[Idx++]); |
| 284 | FD->setHasInheritedPrototype(Record[Idx++]); |
| 285 | FD->setHasWrittenPrototype(Record[Idx++]); |
| 286 | FD->setDeleted(Record[Idx++]); |
| 287 | FD->setTrivial(Record[Idx++]); |
| 288 | FD->setCopyAssignment(Record[Idx++]); |
| 289 | FD->setHasImplicitReturnZero(Record[Idx++]); |
| 290 | FD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 291 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 292 | // Read in the parameters. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 293 | unsigned NumParams = Record[Idx++]; |
| 294 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 295 | Params.reserve(NumParams); |
| 296 | for (unsigned I = 0; I != NumParams; ++I) |
| 297 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | d505812 | 2010-02-11 01:19:42 +0000 | [diff] [blame] | 298 | FD->setParams(Params.data(), NumParams); |
John McCall | b9467b6 | 2010-04-24 01:30:58 +0000 | [diff] [blame] | 299 | |
| 300 | // FIXME: order this properly w.r.t. friendness |
| 301 | // FIXME: this same thing needs to happen for function templates |
| 302 | if (FD->isOverloadedOperator() && !FD->getDeclContext()->isRecord()) |
| 303 | FD->setNonMemberOperator(); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { |
| 307 | VisitNamedDecl(MD); |
| 308 | if (Record[Idx++]) { |
| 309 | // In practice, this won't be executed (since method definitions |
| 310 | // don't occur in header files). |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 311 | MD->setBody(Reader.ReadStmt()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 312 | MD->setSelfDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); |
| 313 | MD->setCmdDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); |
| 314 | } |
| 315 | MD->setInstanceMethod(Record[Idx++]); |
| 316 | MD->setVariadic(Record[Idx++]); |
| 317 | MD->setSynthesized(Record[Idx++]); |
| 318 | MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]); |
| 319 | MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); |
Fariborz Jahanian | d9235db | 2010-04-08 21:29:11 +0000 | [diff] [blame] | 320 | MD->setNumSelectorArgs(unsigned(Record[Idx++])); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 321 | MD->setResultType(Reader.GetType(Record[Idx++])); |
Douglas Gregor | 12852d9 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 322 | MD->setResultTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 323 | MD->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 324 | unsigned NumParams = Record[Idx++]; |
| 325 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 326 | Params.reserve(NumParams); |
| 327 | for (unsigned I = 0; I != NumParams; ++I) |
| 328 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | cdabb31 | 2010-04-09 15:40:42 +0000 | [diff] [blame] | 329 | MD->setMethodParams(*Reader.getContext(), Params.data(), NumParams, |
| 330 | NumParams); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | void PCHDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { |
| 334 | VisitNamedDecl(CD); |
Ted Kremenek | c7c6431 | 2010-01-07 01:20:12 +0000 | [diff] [blame] | 335 | SourceLocation A = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 336 | SourceLocation B = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 337 | CD->setAtEndRange(SourceRange(A, B)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { |
| 341 | VisitObjCContainerDecl(ID); |
| 342 | ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr()); |
| 343 | ID->setSuperClass(cast_or_null<ObjCInterfaceDecl> |
| 344 | (Reader.GetDecl(Record[Idx++]))); |
| 345 | unsigned NumProtocols = Record[Idx++]; |
| 346 | llvm::SmallVector<ObjCProtocolDecl *, 16> Protocols; |
| 347 | Protocols.reserve(NumProtocols); |
| 348 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 349 | Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 350 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 351 | ProtoLocs.reserve(NumProtocols); |
| 352 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 353 | ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 354 | ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(), |
| 355 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 356 | unsigned NumIvars = Record[Idx++]; |
| 357 | llvm::SmallVector<ObjCIvarDecl *, 16> IVars; |
| 358 | IVars.reserve(NumIvars); |
| 359 | for (unsigned I = 0; I != NumIvars; ++I) |
| 360 | IVars.push_back(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 361 | ID->setCategoryList( |
| 362 | cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++]))); |
| 363 | ID->setForwardDecl(Record[Idx++]); |
| 364 | ID->setImplicitInterfaceDecl(Record[Idx++]); |
| 365 | ID->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 366 | ID->setSuperClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Argyrios Kyrtzidis | ea72f42 | 2009-07-18 00:33:23 +0000 | [diff] [blame] | 367 | ID->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | void PCHDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) { |
| 371 | VisitFieldDecl(IVD); |
| 372 | IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]); |
| 373 | } |
| 374 | |
| 375 | void PCHDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { |
| 376 | VisitObjCContainerDecl(PD); |
| 377 | PD->setForwardDecl(Record[Idx++]); |
| 378 | PD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 379 | unsigned NumProtoRefs = Record[Idx++]; |
| 380 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 381 | ProtoRefs.reserve(NumProtoRefs); |
| 382 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 383 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 384 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 385 | ProtoLocs.reserve(NumProtoRefs); |
| 386 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 387 | ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 388 | PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 389 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | void PCHDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) { |
| 393 | VisitFieldDecl(FD); |
| 394 | } |
| 395 | |
| 396 | void PCHDeclReader::VisitObjCClassDecl(ObjCClassDecl *CD) { |
| 397 | VisitDecl(CD); |
| 398 | unsigned NumClassRefs = Record[Idx++]; |
| 399 | llvm::SmallVector<ObjCInterfaceDecl *, 16> ClassRefs; |
| 400 | ClassRefs.reserve(NumClassRefs); |
| 401 | for (unsigned I = 0; I != NumClassRefs; ++I) |
| 402 | ClassRefs.push_back(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Ted Kremenek | 9b124e1 | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 403 | llvm::SmallVector<SourceLocation, 16> SLocs; |
| 404 | SLocs.reserve(NumClassRefs); |
| 405 | for (unsigned I = 0; I != NumClassRefs; ++I) |
| 406 | SLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 407 | CD->setClassList(*Reader.getContext(), ClassRefs.data(), SLocs.data(), |
| 408 | NumClassRefs); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | void PCHDeclReader::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *FPD) { |
| 412 | VisitDecl(FPD); |
| 413 | unsigned NumProtoRefs = Record[Idx++]; |
| 414 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 415 | ProtoRefs.reserve(NumProtoRefs); |
| 416 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 417 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 418 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 419 | ProtoLocs.reserve(NumProtoRefs); |
| 420 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 421 | ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 422 | FPD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 423 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | void PCHDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) { |
| 427 | VisitObjCContainerDecl(CD); |
| 428 | CD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 429 | unsigned NumProtoRefs = Record[Idx++]; |
| 430 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 431 | ProtoRefs.reserve(NumProtoRefs); |
| 432 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 433 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 434 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 435 | ProtoLocs.reserve(NumProtoRefs); |
| 436 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 437 | ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 438 | CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 439 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 440 | CD->setNextClassCategory(cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 071676f | 2010-01-16 16:38:58 +0000 | [diff] [blame] | 441 | CD->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 442 | CD->setCategoryNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | void PCHDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { |
| 446 | VisitNamedDecl(CAD); |
| 447 | CAD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 448 | } |
| 449 | |
| 450 | void PCHDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
| 451 | VisitNamedDecl(D); |
Fariborz Jahanian | da8ec2b | 2010-01-21 17:36:00 +0000 | [diff] [blame] | 452 | D->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
John McCall | 339bb66 | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 453 | D->setType(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 454 | // FIXME: stable encoding |
| 455 | D->setPropertyAttributes( |
| 456 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Fariborz Jahanian | 3bf0ded | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 457 | D->setPropertyAttributesAsWritten( |
| 458 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 459 | // FIXME: stable encoding |
| 460 | D->setPropertyImplementation( |
| 461 | (ObjCPropertyDecl::PropertyControl)Record[Idx++]); |
| 462 | D->setGetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector()); |
| 463 | D->setSetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector()); |
| 464 | D->setGetterMethodDecl( |
| 465 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 466 | D->setSetterMethodDecl( |
| 467 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 468 | D->setPropertyIvarDecl( |
| 469 | cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
| 470 | } |
| 471 | |
| 472 | void PCHDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) { |
Argyrios Kyrtzidis | 067c407 | 2009-07-27 19:04:32 +0000 | [diff] [blame] | 473 | VisitObjCContainerDecl(D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 474 | D->setClassInterface( |
| 475 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | void PCHDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { |
| 479 | VisitObjCImplDecl(D); |
| 480 | D->setIdentifier(Reader.GetIdentifierInfo(Record, Idx)); |
| 481 | } |
| 482 | |
| 483 | void PCHDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { |
| 484 | VisitObjCImplDecl(D); |
| 485 | D->setSuperClass( |
| 486 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | c83726e | 2010-04-28 16:11:27 +0000 | [diff] [blame] | 487 | // FIXME. Add reading of IvarInitializers and NumIvarInitializers. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | |
| 491 | void PCHDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
| 492 | VisitDecl(D); |
| 493 | D->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 494 | D->setPropertyDecl( |
| 495 | cast_or_null<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++]))); |
| 496 | D->setPropertyIvarDecl( |
| 497 | cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | 25491a2 | 2010-05-05 21:52:17 +0000 | [diff] [blame] | 498 | // FIXME. read GetterCXXConstructor and SetterCXXAssignment |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | void PCHDeclReader::VisitFieldDecl(FieldDecl *FD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 502 | VisitDeclaratorDecl(FD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 503 | FD->setMutable(Record[Idx++]); |
| 504 | if (Record[Idx++]) |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 505 | FD->setBitWidth(Reader.ReadExpr()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | void PCHDeclReader::VisitVarDecl(VarDecl *VD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 509 | VisitDeclaratorDecl(VD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 510 | VD->setStorageClass((VarDecl::StorageClass)Record[Idx++]); |
Douglas Gregor | c4df407 | 2010-04-19 22:54:31 +0000 | [diff] [blame] | 511 | VD->setStorageClassAsWritten((VarDecl::StorageClass)Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 512 | VD->setThreadSpecified(Record[Idx++]); |
| 513 | VD->setCXXDirectInitializer(Record[Idx++]); |
| 514 | VD->setDeclaredInCondition(Record[Idx++]); |
Douglas Gregor | 3f324d56 | 2010-05-03 18:51:14 +0000 | [diff] [blame] | 515 | VD->setExceptionVariable(Record[Idx++]); |
Douglas Gregor | 6fd1b18 | 2010-05-15 06:01:05 +0000 | [diff] [blame] | 516 | VD->setNRVOVariable(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 517 | VD->setPreviousDeclaration( |
| 518 | cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 519 | if (Record[Idx++]) |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 520 | VD->setInit(Reader.ReadExpr()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | void PCHDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { |
| 524 | VisitVarDecl(PD); |
| 525 | } |
| 526 | |
| 527 | void PCHDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { |
| 528 | VisitVarDecl(PD); |
| 529 | PD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); |
John McCall | f3cd665 | 2010-03-12 18:31:32 +0000 | [diff] [blame] | 530 | PD->setHasInheritedDefaultArg(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 531 | } |
| 532 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 533 | void PCHDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { |
| 534 | VisitDecl(AD); |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 535 | AD->setAsmString(cast<StringLiteral>(Reader.ReadExpr())); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | void PCHDeclReader::VisitBlockDecl(BlockDecl *BD) { |
| 539 | VisitDecl(BD); |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 540 | BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt())); |
John McCall | a3ccba0 | 2010-06-04 11:21:44 +0000 | [diff] [blame] | 541 | BD->setSignatureAsWritten(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 542 | unsigned NumParams = Record[Idx++]; |
| 543 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 544 | Params.reserve(NumParams); |
| 545 | for (unsigned I = 0; I != NumParams; ++I) |
| 546 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | d505812 | 2010-02-11 01:19:42 +0000 | [diff] [blame] | 547 | BD->setParams(Params.data(), NumParams); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 550 | void PCHDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
| 551 | VisitDecl(D); |
| 552 | D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]); |
| 553 | D->setHasBraces(Record[Idx++]); |
| 554 | } |
| 555 | |
| 556 | void PCHDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { |
| 557 | VisitNamedDecl(D); |
| 558 | D->setLBracLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 559 | D->setRBracLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 560 | D->setNextNamespace( |
| 561 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 562 | |
| 563 | // Only read one reference--the original or anonymous namespace. |
| 564 | bool IsOriginal = Record[Idx++]; |
| 565 | if (IsOriginal) |
| 566 | D->setAnonymousNamespace( |
| 567 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 568 | else |
| 569 | D->setOriginalNamespace( |
| 570 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 571 | } |
| 572 | |
| 573 | void PCHDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |
| 574 | VisitNamedDecl(D); |
| 575 | |
| 576 | D->setAliasLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 577 | D->setQualifierRange(Reader.ReadSourceRange(Record, Idx)); |
| 578 | D->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 579 | D->setTargetNameLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 580 | D->setAliasedNamespace(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 581 | } |
| 582 | |
Argyrios Kyrtzidis | 41d4562 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 583 | void PCHDeclReader::VisitUsingDecl(UsingDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 584 | VisitNamedDecl(D); |
| 585 | D->setUsingLocation(Reader.ReadSourceLocation(Record, Idx)); |
| 586 | D->setNestedNameRange(Reader.ReadSourceRange(Record, Idx)); |
| 587 | D->setTargetNestedNameDecl(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 588 | |
| 589 | // FIXME: It would probably be more efficient to read these into a vector |
| 590 | // and then re-cosntruct the shadow decl set over that vector since it |
| 591 | // would avoid existence checks. |
| 592 | unsigned NumShadows = Record[Idx++]; |
| 593 | for(unsigned I = 0; I != NumShadows; ++I) { |
| 594 | D->addShadowDecl(cast<UsingShadowDecl>(Reader.GetDecl(Record[Idx++]))); |
| 595 | } |
| 596 | D->setTypeName(Record[Idx++]); |
| 597 | } |
| 598 | |
Argyrios Kyrtzidis | 41d4562 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 599 | void PCHDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 600 | VisitNamedDecl(D); |
| 601 | D->setTargetDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 602 | D->setUsingDecl(cast<UsingDecl>(Reader.GetDecl(Record[Idx++]))); |
| 603 | } |
| 604 | |
| 605 | void PCHDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { |
| 606 | VisitNamedDecl(D); |
| 607 | D->setNamespaceKeyLocation(Reader.ReadSourceLocation(Record, Idx)); |
| 608 | D->setQualifierRange(Reader.ReadSourceRange(Record, Idx)); |
| 609 | D->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 610 | D->setIdentLocation(Reader.ReadSourceLocation(Record, Idx)); |
| 611 | D->setNominatedNamespace(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 612 | D->setCommonAncestor(cast_or_null<DeclContext>( |
| 613 | Reader.GetDecl(Record[Idx++]))); |
| 614 | } |
| 615 | |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 616 | void PCHDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 617 | VisitValueDecl(D); |
| 618 | D->setTargetNestedNameRange(Reader.ReadSourceRange(Record, Idx)); |
| 619 | D->setUsingLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 620 | D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 621 | } |
| 622 | |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 623 | void PCHDeclReader::VisitUnresolvedUsingTypenameDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 624 | UnresolvedUsingTypenameDecl *D) { |
| 625 | VisitTypeDecl(D); |
| 626 | D->setTargetNestedNameRange(Reader.ReadSourceRange(Record, Idx)); |
| 627 | D->setUsingLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 628 | D->setTypenameLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 629 | D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 630 | } |
| 631 | |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 632 | CXXBaseSpecifier PCHDeclReader::ReadCXXBaseSpecifier() { |
John McCall | 1c70e99 | 2010-06-03 19:28:45 +0000 | [diff] [blame] | 633 | bool isVirtual = static_cast<bool>(Record[Idx++]); |
| 634 | bool isBaseOfClass = static_cast<bool>(Record[Idx++]); |
| 635 | AccessSpecifier AS = static_cast<AccessSpecifier>(Record[Idx++]); |
| 636 | QualType T = Reader.GetType(Record[Idx++]); |
| 637 | SourceRange Range = Reader.ReadSourceRange(Record, Idx); |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 638 | return CXXBaseSpecifier(Range, isVirtual, isBaseOfClass, AS, T); |
John McCall | 1c70e99 | 2010-06-03 19:28:45 +0000 | [diff] [blame] | 639 | } |
| 640 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 641 | void PCHDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 642 | VisitRecordDecl(D); |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 643 | |
| 644 | ASTContext &C = *Reader.getContext(); |
| 645 | |
| 646 | if (D->isFirstDeclaration()) { |
| 647 | if (Record[Idx++]) { // DefinitionData != 0 |
| 648 | D->DefinitionData = new (C) struct CXXRecordDecl::DefinitionData(0); |
| 649 | struct CXXRecordDecl::DefinitionData &Data = *D->DefinitionData; |
| 650 | |
| 651 | Data.UserDeclaredConstructor = Record[Idx++]; |
| 652 | Data.UserDeclaredCopyConstructor = Record[Idx++]; |
| 653 | Data.UserDeclaredCopyAssignment = Record[Idx++]; |
| 654 | Data.UserDeclaredDestructor = Record[Idx++]; |
| 655 | Data.Aggregate = Record[Idx++]; |
| 656 | Data.PlainOldData = Record[Idx++]; |
| 657 | Data.Empty = Record[Idx++]; |
| 658 | Data.Polymorphic = Record[Idx++]; |
| 659 | Data.Abstract = Record[Idx++]; |
| 660 | Data.HasTrivialConstructor = Record[Idx++]; |
| 661 | Data.HasTrivialCopyConstructor = Record[Idx++]; |
| 662 | Data.HasTrivialCopyAssignment = Record[Idx++]; |
| 663 | Data.HasTrivialDestructor = Record[Idx++]; |
| 664 | Data.ComputedVisibleConversions = Record[Idx++]; |
| 665 | |
| 666 | // setBases() is unsuitable since it may try to iterate the bases of an |
| 667 | // unitialized base. |
| 668 | Data.NumBases = Record[Idx++]; |
| 669 | Data.Bases = new(C) CXXBaseSpecifier [Data.NumBases]; |
| 670 | for (unsigned i = 0; i != Data.NumBases; ++i) |
| 671 | Data.Bases[i] = ReadCXXBaseSpecifier(); |
| 672 | |
| 673 | // FIXME: Make VBases lazily computed when needed to avoid storing them. |
| 674 | Data.NumVBases = Record[Idx++]; |
| 675 | Data.VBases = new(C) CXXBaseSpecifier [Data.NumVBases]; |
| 676 | for (unsigned i = 0; i != Data.NumVBases; ++i) |
| 677 | Data.VBases[i] = ReadCXXBaseSpecifier(); |
| 678 | |
| 679 | Reader.ReadUnresolvedSet(Data.Conversions, Record, Idx); |
| 680 | Reader.ReadUnresolvedSet(Data.VisibleConversions, Record, Idx); |
| 681 | Data.Definition = cast<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])); |
| 682 | Data.FirstFriend |
| 683 | = cast_or_null<FriendDecl>(Reader.GetDecl(Record[Idx++])); |
| 684 | } |
| 685 | } else { |
| 686 | D->DefinitionData = D->getPreviousDeclaration()->DefinitionData; |
| 687 | } |
| 688 | |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 689 | enum CXXRecKind { |
| 690 | CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization |
| 691 | }; |
| 692 | switch ((CXXRecKind)Record[Idx++]) { |
| 693 | default: |
| 694 | assert(false && "Out of sync with PCHDeclWriter::VisitCXXRecordDecl?"); |
| 695 | case CXXRecNotTemplate: |
| 696 | break; |
| 697 | case CXXRecTemplate: |
| 698 | D->setDescribedClassTemplate( |
| 699 | cast<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++]))); |
| 700 | break; |
| 701 | case CXXRecMemberSpecialization: { |
| 702 | CXXRecordDecl *RD = cast<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])); |
| 703 | TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; |
| 704 | SourceLocation POI = Reader.ReadSourceLocation(Record, Idx); |
| 705 | D->setInstantiationOfMemberClass(RD, TSK); |
| 706 | D->getMemberSpecializationInfo()->setPointOfInstantiation(POI); |
| 707 | break; |
| 708 | } |
| 709 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | void PCHDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { |
| 713 | // assert(false && "cannot read CXXMethodDecl"); |
| 714 | VisitFunctionDecl(D); |
| 715 | } |
| 716 | |
| 717 | void PCHDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
| 718 | // assert(false && "cannot read CXXConstructorDecl"); |
| 719 | VisitCXXMethodDecl(D); |
| 720 | } |
| 721 | |
| 722 | void PCHDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
| 723 | // assert(false && "cannot read CXXDestructorDecl"); |
| 724 | VisitCXXMethodDecl(D); |
| 725 | } |
| 726 | |
| 727 | void PCHDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) { |
| 728 | // assert(false && "cannot read CXXConversionDecl"); |
| 729 | VisitCXXMethodDecl(D); |
| 730 | } |
| 731 | |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 732 | void PCHDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) { |
| 733 | VisitDecl(D); |
| 734 | D->setColonLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 735 | } |
| 736 | |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 737 | void PCHDeclReader::VisitFriendDecl(FriendDecl *D) { |
| 738 | if (Record[Idx++]) |
| 739 | D->Friend = Reader.GetTypeSourceInfo(Record, Idx); |
| 740 | else |
| 741 | D->Friend = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
| 742 | D->NextFriend = cast_or_null<FriendDecl>(Reader.GetDecl(Record[Idx++])); |
| 743 | D->FriendLoc = Reader.ReadSourceLocation(Record, Idx); |
| 744 | } |
| 745 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 746 | void PCHDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { |
| 747 | assert(false && "cannot read FriendTemplateDecl"); |
| 748 | } |
| 749 | |
| 750 | void PCHDeclReader::VisitTemplateDecl(TemplateDecl *D) { |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 751 | VisitNamedDecl(D); |
| 752 | |
| 753 | NamedDecl *TemplatedDecl = cast<NamedDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 754 | TemplateParameterList* TemplateParams |
| 755 | = Reader.ReadTemplateParameterList(Record, Idx); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 756 | D->init(TemplatedDecl, TemplateParams); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | void PCHDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 760 | VisitTemplateDecl(D); |
| 761 | |
| 762 | ClassTemplateDecl *PrevDecl = |
| 763 | cast_or_null<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | a35c8e4 | 2010-06-21 10:57:41 +0000 | [diff] [blame] | 764 | D->setPreviousDeclaration(PrevDecl); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 765 | if (PrevDecl == 0) { |
| 766 | // This ClassTemplateDecl owns a CommonPtr; read it. |
| 767 | |
| 768 | unsigned size = Record[Idx++]; |
| 769 | while (size--) { |
| 770 | ClassTemplateSpecializationDecl *CTSD |
| 771 | = cast<ClassTemplateSpecializationDecl>(Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | e23371e | 2010-07-02 11:55:37 +0000 | [diff] [blame] | 772 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
| 773 | Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 774 | llvm::FoldingSetNodeID ID; |
| 775 | void *InsertPos = 0; |
Argyrios Kyrtzidis | e23371e | 2010-07-02 11:55:37 +0000 | [diff] [blame] | 776 | ClassTemplateSpecializationDecl::Profile(ID, TemplArgs.data(), |
| 777 | TemplArgs.size(), |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 778 | *Reader.getContext()); |
| 779 | D->getSpecializations().FindNodeOrInsertPos(ID, InsertPos); |
| 780 | D->getSpecializations().InsertNode(CTSD, InsertPos); |
| 781 | } |
| 782 | |
| 783 | size = Record[Idx++]; |
| 784 | while (size--) { |
| 785 | ClassTemplatePartialSpecializationDecl *CTSD |
| 786 | = cast<ClassTemplatePartialSpecializationDecl>( |
| 787 | Reader.GetDecl(Record[Idx++])); |
Argyrios Kyrtzidis | e23371e | 2010-07-02 11:55:37 +0000 | [diff] [blame] | 788 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
| 789 | Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 790 | llvm::FoldingSetNodeID ID; |
| 791 | void *InsertPos = 0; |
Argyrios Kyrtzidis | e23371e | 2010-07-02 11:55:37 +0000 | [diff] [blame] | 792 | ClassTemplatePartialSpecializationDecl::Profile(ID, TemplArgs.data(), |
| 793 | TemplArgs.size(), |
| 794 | *Reader.getContext()); |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 795 | D->getPartialSpecializations().FindNodeOrInsertPos(ID, InsertPos); |
| 796 | D->getPartialSpecializations().InsertNode(CTSD, InsertPos); |
| 797 | } |
| 798 | |
| 799 | // InjectedClassNameType is computed. |
| 800 | |
| 801 | if (ClassTemplateDecl *CTD |
| 802 | = cast_or_null<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++]))) { |
| 803 | D->setInstantiatedFromMemberTemplate(CTD); |
| 804 | if (Record[Idx++]) |
| 805 | D->setMemberSpecialization(); |
| 806 | } |
| 807 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | void PCHDeclReader::VisitClassTemplateSpecializationDecl( |
| 811 | ClassTemplateSpecializationDecl *D) { |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 812 | VisitCXXRecordDecl(D); |
| 813 | |
| 814 | if (Decl *InstD = Reader.GetDecl(Record[Idx++])) { |
| 815 | if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) { |
| 816 | D->setInstantiationOf(CTD); |
| 817 | } else { |
| 818 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
| 819 | Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx); |
| 820 | D->setInstantiationOf(cast<ClassTemplatePartialSpecializationDecl>(InstD), |
| 821 | TemplArgs.data(), TemplArgs.size()); |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | // Explicit info. |
| 826 | if (TypeSourceInfo *TyInfo = Reader.GetTypeSourceInfo(Record, Idx)) { |
| 827 | D->setTypeAsWritten(TyInfo); |
| 828 | D->setExternLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 829 | D->setTemplateKeywordLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 830 | } |
| 831 | |
| 832 | llvm::SmallVector<TemplateArgument, 8> TemplArgs; |
| 833 | Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx); |
| 834 | D->initTemplateArgs(TemplArgs.data(), TemplArgs.size()); |
| 835 | SourceLocation POI = Reader.ReadSourceLocation(Record, Idx); |
| 836 | if (POI.isValid()) |
| 837 | D->setPointOfInstantiation(POI); |
| 838 | D->setSpecializationKind((TemplateSpecializationKind)Record[Idx++]); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 839 | } |
| 840 | |
| 841 | void PCHDeclReader::VisitClassTemplatePartialSpecializationDecl( |
| 842 | ClassTemplatePartialSpecializationDecl *D) { |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 843 | VisitClassTemplateSpecializationDecl(D); |
| 844 | |
| 845 | D->initTemplateParameters(Reader.ReadTemplateParameterList(Record, Idx)); |
| 846 | |
| 847 | TemplateArgumentListInfo ArgInfos; |
| 848 | unsigned NumArgs = Record[Idx++]; |
| 849 | while (NumArgs--) |
| 850 | ArgInfos.addArgument(Reader.ReadTemplateArgumentLoc(Record, Idx)); |
| 851 | D->initTemplateArgsAsWritten(ArgInfos); |
| 852 | |
| 853 | D->setSequenceNumber(Record[Idx++]); |
| 854 | |
| 855 | // These are read/set from/to the first declaration. |
| 856 | if (D->getPreviousDeclaration() == 0) { |
| 857 | D->setInstantiatedFromMember( |
| 858 | cast_or_null<ClassTemplatePartialSpecializationDecl>( |
| 859 | Reader.GetDecl(Record[Idx++]))); |
| 860 | if (Record[Idx++]) |
| 861 | D->isMemberSpecialization(); |
| 862 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 863 | } |
| 864 | |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 865 | void PCHDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { |
| 866 | VisitTemplateDecl(D); |
| 867 | |
| 868 | FunctionTemplateDecl *PrevDecl = |
| 869 | cast_or_null<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++])); |
| 870 | D->setPreviousDeclaration(PrevDecl); |
| 871 | if (PrevDecl == 0) { |
| 872 | // This FunctionTemplateDecl owns a CommonPtr; read it. |
| 873 | |
| 874 | // FunctionTemplateSpecializationInfos are filled through the |
| 875 | // templated FunctionDecl's setFunctionTemplateSpecialization, no need to |
| 876 | // read them here. |
| 877 | |
| 878 | if (FunctionTemplateDecl *CTD |
| 879 | = cast_or_null<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]))) { |
| 880 | D->setInstantiatedFromMemberTemplate(CTD); |
| 881 | if (Record[Idx++]) |
| 882 | D->setMemberSpecialization(); |
| 883 | } |
| 884 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | void PCHDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { |
Argyrios Kyrtzidis | 95c04ca | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 888 | VisitTypeDecl(D); |
| 889 | |
| 890 | D->setDeclaredWithTypename(Record[Idx++]); |
| 891 | D->setParameterPack(Record[Idx++]); |
| 892 | |
| 893 | bool Inherited = Record[Idx++]; |
| 894 | TypeSourceInfo *DefArg = Reader.GetTypeSourceInfo(Record, Idx); |
| 895 | D->setDefaultArgument(DefArg, Inherited); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | void PCHDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { |
Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 899 | VisitVarDecl(D); |
| 900 | // TemplateParmPosition. |
| 901 | D->setDepth(Record[Idx++]); |
| 902 | D->setPosition(Record[Idx++]); |
| 903 | // Rest of NonTypeTemplateParmDecl. |
| 904 | if (Record[Idx++]) { |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 905 | Expr *DefArg = Reader.ReadExpr(); |
Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 906 | bool Inherited = Record[Idx++]; |
| 907 | D->setDefaultArgument(DefArg, Inherited); |
| 908 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | void PCHDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { |
| 912 | assert(false && "cannot read TemplateTemplateParmDecl"); |
| 913 | } |
| 914 | |
| 915 | void PCHDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) { |
| 916 | assert(false && "cannot read StaticAssertDecl"); |
| 917 | } |
| 918 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 919 | std::pair<uint64_t, uint64_t> |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 920 | PCHDeclReader::VisitDeclContext(DeclContext *DC) { |
| 921 | uint64_t LexicalOffset = Record[Idx++]; |
| 922 | uint64_t VisibleOffset = Record[Idx++]; |
| 923 | return std::make_pair(LexicalOffset, VisibleOffset); |
| 924 | } |
| 925 | |
| 926 | //===----------------------------------------------------------------------===// |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 927 | // Attribute Reading |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 928 | //===----------------------------------------------------------------------===// |
| 929 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 930 | /// \brief Reads attributes from the current stream position. |
| 931 | Attr *PCHReader::ReadAttributes() { |
| 932 | unsigned Code = DeclsCursor.ReadCode(); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 933 | assert(Code == llvm::bitc::UNABBREV_RECORD && |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 934 | "Expected unabbreviated record"); (void)Code; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 935 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 936 | RecordData Record; |
| 937 | unsigned Idx = 0; |
| 938 | unsigned RecCode = DeclsCursor.ReadRecord(Code, Record); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 939 | assert(RecCode == pch::DECL_ATTR && "Expected attribute record"); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 940 | (void)RecCode; |
| 941 | |
| 942 | #define SIMPLE_ATTR(Name) \ |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 943 | case attr::Name: \ |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 944 | New = ::new (*Context) Name##Attr(); \ |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 945 | break |
| 946 | |
| 947 | #define STRING_ATTR(Name) \ |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 948 | case attr::Name: \ |
Ted Kremenek | 7f4945a | 2010-02-11 05:28:37 +0000 | [diff] [blame] | 949 | New = ::new (*Context) Name##Attr(*Context, ReadString(Record, Idx)); \ |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 950 | break |
| 951 | |
| 952 | #define UNSIGNED_ATTR(Name) \ |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 953 | case attr::Name: \ |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 954 | New = ::new (*Context) Name##Attr(Record[Idx++]); \ |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 955 | break |
| 956 | |
| 957 | Attr *Attrs = 0; |
| 958 | while (Idx < Record.size()) { |
| 959 | Attr *New = 0; |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 960 | attr::Kind Kind = (attr::Kind)Record[Idx++]; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 961 | bool IsInherited = Record[Idx++]; |
| 962 | |
| 963 | switch (Kind) { |
Anton Korobeynikov | 55bcea1 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 964 | default: |
| 965 | assert(0 && "Unknown attribute!"); |
| 966 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 967 | STRING_ATTR(Alias); |
Daniel Dunbar | fc6507e | 2010-05-27 02:25:39 +0000 | [diff] [blame] | 968 | SIMPLE_ATTR(AlignMac68k); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 969 | UNSIGNED_ATTR(Aligned); |
| 970 | SIMPLE_ATTR(AlwaysInline); |
| 971 | SIMPLE_ATTR(AnalyzerNoReturn); |
| 972 | STRING_ATTR(Annotate); |
| 973 | STRING_ATTR(AsmLabel); |
Alexis Hunt | 54a0254 | 2009-11-25 04:20:27 +0000 | [diff] [blame] | 974 | SIMPLE_ATTR(BaseCheck); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 975 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 976 | case attr::Blocks: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 977 | New = ::new (*Context) BlocksAttr( |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 978 | (BlocksAttr::BlocksAttrTypes)Record[Idx++]); |
| 979 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 980 | |
Eli Friedman | e4310c8 | 2009-11-09 18:38:53 +0000 | [diff] [blame] | 981 | SIMPLE_ATTR(CDecl); |
| 982 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 983 | case attr::Cleanup: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 984 | New = ::new (*Context) CleanupAttr( |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 985 | cast<FunctionDecl>(GetDecl(Record[Idx++]))); |
| 986 | break; |
| 987 | |
| 988 | SIMPLE_ATTR(Const); |
| 989 | UNSIGNED_ATTR(Constructor); |
| 990 | SIMPLE_ATTR(DLLExport); |
| 991 | SIMPLE_ATTR(DLLImport); |
| 992 | SIMPLE_ATTR(Deprecated); |
| 993 | UNSIGNED_ATTR(Destructor); |
| 994 | SIMPLE_ATTR(FastCall); |
Alexis Hunt | 96d5c76 | 2009-11-21 08:43:09 +0000 | [diff] [blame] | 995 | SIMPLE_ATTR(Final); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 996 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 997 | case attr::Format: { |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 998 | std::string Type = ReadString(Record, Idx); |
| 999 | unsigned FormatIdx = Record[Idx++]; |
| 1000 | unsigned FirstArg = Record[Idx++]; |
Ted Kremenek | 7f4945a | 2010-02-11 05:28:37 +0000 | [diff] [blame] | 1001 | New = ::new (*Context) FormatAttr(*Context, Type, FormatIdx, FirstArg); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1002 | break; |
| 1003 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1004 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1005 | case attr::FormatArg: { |
Fariborz Jahanian | f1c2502 | 2009-05-20 17:41:43 +0000 | [diff] [blame] | 1006 | unsigned FormatIdx = Record[Idx++]; |
| 1007 | New = ::new (*Context) FormatArgAttr(FormatIdx); |
| 1008 | break; |
| 1009 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1010 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1011 | case attr::Sentinel: { |
Fariborz Jahanian | 027b886 | 2009-05-13 18:09:35 +0000 | [diff] [blame] | 1012 | int sentinel = Record[Idx++]; |
| 1013 | int nullPos = Record[Idx++]; |
| 1014 | New = ::new (*Context) SentinelAttr(sentinel, nullPos); |
| 1015 | break; |
| 1016 | } |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1017 | |
| 1018 | SIMPLE_ATTR(GNUInline); |
Alexis Hunt | 54a0254 | 2009-11-25 04:20:27 +0000 | [diff] [blame] | 1019 | SIMPLE_ATTR(Hiding); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1020 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1021 | case attr::IBAction: |
Ted Kremenek | 06be968 | 2010-02-17 02:37:45 +0000 | [diff] [blame] | 1022 | New = ::new (*Context) IBActionAttr(); |
| 1023 | break; |
| 1024 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1025 | case attr::IBOutlet: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1026 | New = ::new (*Context) IBOutletAttr(); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1027 | break; |
| 1028 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1029 | case attr::IBOutletCollection: { |
Ted Kremenek | 26bde77 | 2010-05-19 17:38:06 +0000 | [diff] [blame] | 1030 | ObjCInterfaceDecl *D = |
| 1031 | cast_or_null<ObjCInterfaceDecl>(GetDecl(Record[Idx++])); |
| 1032 | New = ::new (*Context) IBOutletCollectionAttr(D); |
| 1033 | break; |
| 1034 | } |
| 1035 | |
Ryan Flynn | 1f1fdc0 | 2009-08-09 20:07:29 +0000 | [diff] [blame] | 1036 | SIMPLE_ATTR(Malloc); |
Mike Stump | 3722f58 | 2009-08-26 22:31:08 +0000 | [diff] [blame] | 1037 | SIMPLE_ATTR(NoDebug); |
| 1038 | SIMPLE_ATTR(NoInline); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1039 | SIMPLE_ATTR(NoReturn); |
| 1040 | SIMPLE_ATTR(NoThrow); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1041 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1042 | case attr::NonNull: { |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1043 | unsigned Size = Record[Idx++]; |
| 1044 | llvm::SmallVector<unsigned, 16> ArgNums; |
| 1045 | ArgNums.insert(ArgNums.end(), &Record[Idx], &Record[Idx] + Size); |
| 1046 | Idx += Size; |
Ted Kremenek | 510ee25 | 2010-02-11 07:31:47 +0000 | [diff] [blame] | 1047 | New = ::new (*Context) NonNullAttr(*Context, ArgNums.data(), Size); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1048 | break; |
| 1049 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1050 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1051 | case attr::ReqdWorkGroupSize: { |
Nate Begeman | f275870 | 2009-06-26 06:32:41 +0000 | [diff] [blame] | 1052 | unsigned X = Record[Idx++]; |
| 1053 | unsigned Y = Record[Idx++]; |
| 1054 | unsigned Z = Record[Idx++]; |
| 1055 | New = ::new (*Context) ReqdWorkGroupSizeAttr(X, Y, Z); |
| 1056 | break; |
| 1057 | } |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1058 | |
| 1059 | SIMPLE_ATTR(ObjCException); |
| 1060 | SIMPLE_ATTR(ObjCNSObject); |
Ted Kremenek | d9c6663 | 2010-02-18 00:05:45 +0000 | [diff] [blame] | 1061 | SIMPLE_ATTR(CFReturnsNotRetained); |
Ted Kremenek | 9ecdfaf | 2009-05-09 02:44:38 +0000 | [diff] [blame] | 1062 | SIMPLE_ATTR(CFReturnsRetained); |
Ted Kremenek | d9c6663 | 2010-02-18 00:05:45 +0000 | [diff] [blame] | 1063 | SIMPLE_ATTR(NSReturnsNotRetained); |
Ted Kremenek | 9ecdfaf | 2009-05-09 02:44:38 +0000 | [diff] [blame] | 1064 | SIMPLE_ATTR(NSReturnsRetained); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1065 | SIMPLE_ATTR(Overloadable); |
Alexis Hunt | 54a0254 | 2009-11-25 04:20:27 +0000 | [diff] [blame] | 1066 | SIMPLE_ATTR(Override); |
Anders Carlsson | 68e0b68 | 2009-08-08 18:23:56 +0000 | [diff] [blame] | 1067 | SIMPLE_ATTR(Packed); |
Daniel Dunbar | 4013044 | 2010-05-27 01:12:46 +0000 | [diff] [blame] | 1068 | UNSIGNED_ATTR(MaxFieldAlignment); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1069 | SIMPLE_ATTR(Pure); |
| 1070 | UNSIGNED_ATTR(Regparm); |
| 1071 | STRING_ATTR(Section); |
| 1072 | SIMPLE_ATTR(StdCall); |
Douglas Gregor | a941dca | 2010-05-18 16:57:00 +0000 | [diff] [blame] | 1073 | SIMPLE_ATTR(ThisCall); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1074 | SIMPLE_ATTR(TransparentUnion); |
| 1075 | SIMPLE_ATTR(Unavailable); |
| 1076 | SIMPLE_ATTR(Unused); |
| 1077 | SIMPLE_ATTR(Used); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1078 | |
Alexis Hunt | 344393e | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 1079 | case attr::Visibility: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1080 | New = ::new (*Context) VisibilityAttr( |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1081 | (VisibilityAttr::VisibilityTypes)Record[Idx++]); |
| 1082 | break; |
| 1083 | |
| 1084 | SIMPLE_ATTR(WarnUnusedResult); |
| 1085 | SIMPLE_ATTR(Weak); |
Rafael Espindola | c18086a | 2010-02-23 22:00:30 +0000 | [diff] [blame] | 1086 | SIMPLE_ATTR(WeakRef); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1087 | SIMPLE_ATTR(WeakImport); |
| 1088 | } |
| 1089 | |
| 1090 | assert(New && "Unable to decode attribute?"); |
| 1091 | New->setInherited(IsInherited); |
| 1092 | New->setNext(Attrs); |
| 1093 | Attrs = New; |
| 1094 | } |
| 1095 | #undef UNSIGNED_ATTR |
| 1096 | #undef STRING_ATTR |
| 1097 | #undef SIMPLE_ATTR |
| 1098 | |
| 1099 | // The list of attributes was built backwards. Reverse the list |
| 1100 | // before returning it. |
| 1101 | Attr *PrevAttr = 0, *NextAttr = 0; |
| 1102 | while (Attrs) { |
| 1103 | NextAttr = Attrs->getNext(); |
| 1104 | Attrs->setNext(PrevAttr); |
| 1105 | PrevAttr = Attrs; |
| 1106 | Attrs = NextAttr; |
| 1107 | } |
| 1108 | |
| 1109 | return PrevAttr; |
| 1110 | } |
| 1111 | |
| 1112 | //===----------------------------------------------------------------------===// |
| 1113 | // PCHReader Implementation |
| 1114 | //===----------------------------------------------------------------------===// |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1115 | |
| 1116 | /// \brief Note that we have loaded the declaration with the given |
| 1117 | /// Index. |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1118 | /// |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1119 | /// This routine notes that this declaration has already been loaded, |
| 1120 | /// so that future GetDecl calls will return this declaration rather |
| 1121 | /// than trying to load a new declaration. |
| 1122 | inline void PCHReader::LoadedDecl(unsigned Index, Decl *D) { |
| 1123 | assert(!DeclsLoaded[Index] && "Decl loaded twice?"); |
| 1124 | DeclsLoaded[Index] = D; |
| 1125 | } |
| 1126 | |
| 1127 | |
| 1128 | /// \brief Determine whether the consumer will be interested in seeing |
| 1129 | /// this declaration (via HandleTopLevelDecl). |
| 1130 | /// |
| 1131 | /// This routine should return true for anything that might affect |
| 1132 | /// code generation, e.g., inline function definitions, Objective-C |
| 1133 | /// declarations with metadata, etc. |
| 1134 | static bool isConsumerInterestedIn(Decl *D) { |
Daniel Dunbar | 865c2a7 | 2009-09-17 03:06:44 +0000 | [diff] [blame] | 1135 | if (isa<FileScopeAsmDecl>(D)) |
| 1136 | return true; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1137 | if (VarDecl *Var = dyn_cast<VarDecl>(D)) |
| 1138 | return Var->isFileVarDecl() && Var->getInit(); |
| 1139 | if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D)) |
| 1140 | return Func->isThisDeclarationADefinition(); |
| 1141 | return isa<ObjCProtocolDecl>(D); |
| 1142 | } |
| 1143 | |
| 1144 | /// \brief Read the declaration at the given offset from the PCH file. |
| 1145 | Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) { |
| 1146 | // Keep track of where we are in the stream, then jump back there |
| 1147 | // after reading this declaration. |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1148 | SavedStreamPosition SavedPosition(DeclsCursor); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1149 | |
Argyrios Kyrtzidis | d0795b2 | 2010-06-28 22:28:35 +0000 | [diff] [blame] | 1150 | ReadingKindTracker ReadingKind(Read_Decl, *this); |
| 1151 | |
Douglas Gregor | 1342e84 | 2009-07-06 18:54:52 +0000 | [diff] [blame] | 1152 | // Note that we are loading a declaration record. |
| 1153 | LoadingTypeOrDecl Loading(*this); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1154 | |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1155 | DeclsCursor.JumpToBit(Offset); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1156 | RecordData Record; |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1157 | unsigned Code = DeclsCursor.ReadCode(); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1158 | unsigned Idx = 0; |
| 1159 | PCHDeclReader Reader(*this, Record, Idx); |
| 1160 | |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 1161 | Decl *D = 0; |
| 1162 | switch ((pch::DeclCode)DeclsCursor.ReadRecord(Code, Record)) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1163 | case pch::DECL_ATTR: |
| 1164 | case pch::DECL_CONTEXT_LEXICAL: |
| 1165 | case pch::DECL_CONTEXT_VISIBLE: |
| 1166 | assert(false && "Record cannot be de-serialized with ReadDeclRecord"); |
| 1167 | break; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1168 | case pch::DECL_TRANSLATION_UNIT: |
| 1169 | assert(Index == 0 && "Translation unit must be at index 0"); |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1170 | D = Context->getTranslationUnitDecl(); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1171 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1172 | case pch::DECL_TYPEDEF: |
John McCall | 703a3f8 | 2009-10-24 08:00:42 +0000 | [diff] [blame] | 1173 | D = TypedefDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1174 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1175 | case pch::DECL_ENUM: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1176 | D = EnumDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1177 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1178 | case pch::DECL_RECORD: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1179 | D = RecordDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1180 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1181 | case pch::DECL_ENUM_CONSTANT: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1182 | D = EnumConstantDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1183 | 0, llvm::APSInt()); |
| 1184 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1185 | case pch::DECL_FUNCTION: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1186 | D = FunctionDecl::Create(*Context, 0, SourceLocation(), DeclarationName(), |
Argyrios Kyrtzidis | 60ed560 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 1187 | QualType(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1188 | break; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1189 | case pch::DECL_LINKAGE_SPEC: |
| 1190 | D = LinkageSpecDecl::Create(*Context, 0, SourceLocation(), |
| 1191 | (LinkageSpecDecl::LanguageIDs)0, |
| 1192 | false); |
| 1193 | break; |
| 1194 | case pch::DECL_NAMESPACE: |
| 1195 | D = NamespaceDecl::Create(*Context, 0, SourceLocation(), 0); |
| 1196 | break; |
| 1197 | case pch::DECL_NAMESPACE_ALIAS: |
| 1198 | D = NamespaceAliasDecl::Create(*Context, 0, SourceLocation(), |
| 1199 | SourceLocation(), 0, SourceRange(), 0, |
| 1200 | SourceLocation(), 0); |
| 1201 | break; |
| 1202 | case pch::DECL_USING: |
| 1203 | D = UsingDecl::Create(*Context, 0, SourceLocation(), SourceRange(), |
| 1204 | SourceLocation(), 0, DeclarationName(), false); |
| 1205 | break; |
| 1206 | case pch::DECL_USING_SHADOW: |
| 1207 | D = UsingShadowDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
| 1208 | break; |
| 1209 | case pch::DECL_USING_DIRECTIVE: |
| 1210 | D = UsingDirectiveDecl::Create(*Context, 0, SourceLocation(), |
| 1211 | SourceLocation(), SourceRange(), 0, |
| 1212 | SourceLocation(), 0, 0); |
| 1213 | break; |
| 1214 | case pch::DECL_UNRESOLVED_USING_VALUE: |
| 1215 | D = UnresolvedUsingValueDecl::Create(*Context, 0, SourceLocation(), |
| 1216 | SourceRange(), 0, SourceLocation(), |
| 1217 | DeclarationName()); |
| 1218 | break; |
| 1219 | case pch::DECL_UNRESOLVED_USING_TYPENAME: |
| 1220 | D = UnresolvedUsingTypenameDecl::Create(*Context, 0, SourceLocation(), |
| 1221 | SourceLocation(), SourceRange(), |
| 1222 | 0, SourceLocation(), |
| 1223 | DeclarationName()); |
| 1224 | break; |
| 1225 | case pch::DECL_CXX_RECORD: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1226 | D = CXXRecordDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1227 | break; |
| 1228 | case pch::DECL_CXX_METHOD: |
| 1229 | D = CXXMethodDecl::Create(*Context, 0, SourceLocation(), DeclarationName(), |
| 1230 | QualType(), 0); |
| 1231 | break; |
| 1232 | case pch::DECL_CXX_CONSTRUCTOR: |
| 1233 | D = CXXConstructorDecl::Create(*Context, Decl::EmptyShell()); |
| 1234 | break; |
| 1235 | case pch::DECL_CXX_DESTRUCTOR: |
| 1236 | D = CXXDestructorDecl::Create(*Context, Decl::EmptyShell()); |
| 1237 | break; |
| 1238 | case pch::DECL_CXX_CONVERSION: |
| 1239 | D = CXXConversionDecl::Create(*Context, Decl::EmptyShell()); |
| 1240 | break; |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1241 | case pch::DECL_ACCESS_SPEC: |
| 1242 | D = AccessSpecDecl::Create(*Context, AS_none, 0, SourceLocation(), |
| 1243 | SourceLocation()); |
| 1244 | break; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1245 | case pch::DECL_FRIEND: |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1246 | D = FriendDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1247 | break; |
| 1248 | case pch::DECL_FRIEND_TEMPLATE: |
| 1249 | assert(false && "cannot read FriendTemplateDecl"); |
| 1250 | break; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1251 | case pch::DECL_CLASS_TEMPLATE: |
Argyrios Kyrtzidis | a35c8e4 | 2010-06-21 10:57:41 +0000 | [diff] [blame] | 1252 | D = ClassTemplateDecl::Create(*Context, 0, SourceLocation(), |
| 1253 | DeclarationName(), 0, 0, 0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1254 | break; |
| 1255 | case pch::DECL_CLASS_TEMPLATE_SPECIALIZATION: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1256 | D = ClassTemplateSpecializationDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1257 | break; |
| 1258 | case pch::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1259 | D = ClassTemplatePartialSpecializationDecl::Create(*Context, |
| 1260 | Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1261 | break; |
| 1262 | case pch::DECL_FUNCTION_TEMPLATE: |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1263 | D = FunctionTemplateDecl::Create(*Context, 0, SourceLocation(), |
| 1264 | DeclarationName(), 0, 0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1265 | break; |
| 1266 | case pch::DECL_TEMPLATE_TYPE_PARM: |
Argyrios Kyrtzidis | 39f0e30 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 1267 | D = TemplateTypeParmDecl::Create(*Context, Decl::EmptyShell()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1268 | break; |
| 1269 | case pch::DECL_NON_TYPE_TEMPLATE_PARM: |
Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1270 | D = NonTypeTemplateParmDecl::Create(*Context, 0, SourceLocation(), 0,0,0, |
| 1271 | QualType(),0); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1272 | break; |
| 1273 | case pch::DECL_TEMPLATE_TEMPLATE_PARM: |
| 1274 | assert(false && "cannot read TemplateTemplateParmDecl"); |
| 1275 | break; |
| 1276 | case pch::DECL_STATIC_ASSERT: |
| 1277 | assert(false && "cannot read StaticAssertDecl"); |
| 1278 | break; |
| 1279 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1280 | case pch::DECL_OBJC_METHOD: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1281 | D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(), |
Douglas Gregor | 12852d9 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 1282 | Selector(), QualType(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1283 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1284 | case pch::DECL_OBJC_INTERFACE: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1285 | D = ObjCInterfaceDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1286 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1287 | case pch::DECL_OBJC_IVAR: |
Argyrios Kyrtzidis | 60ed560 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 1288 | D = ObjCIvarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1289 | ObjCIvarDecl::None); |
| 1290 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1291 | case pch::DECL_OBJC_PROTOCOL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1292 | D = ObjCProtocolDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1293 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1294 | case pch::DECL_OBJC_AT_DEFS_FIELD: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1295 | D = ObjCAtDefsFieldDecl::Create(*Context, 0, SourceLocation(), 0, |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1296 | QualType(), 0); |
| 1297 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1298 | case pch::DECL_OBJC_CLASS: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1299 | D = ObjCClassDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1300 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1301 | case pch::DECL_OBJC_FORWARD_PROTOCOL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1302 | D = ObjCForwardProtocolDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1303 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1304 | case pch::DECL_OBJC_CATEGORY: |
Douglas Gregor | 071676f | 2010-01-16 16:38:58 +0000 | [diff] [blame] | 1305 | D = ObjCCategoryDecl::Create(*Context, 0, SourceLocation(), |
| 1306 | SourceLocation(), SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1307 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1308 | case pch::DECL_OBJC_CATEGORY_IMPL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1309 | D = ObjCCategoryImplDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1310 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1311 | case pch::DECL_OBJC_IMPLEMENTATION: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1312 | D = ObjCImplementationDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1313 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1314 | case pch::DECL_OBJC_COMPATIBLE_ALIAS: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1315 | D = ObjCCompatibleAliasDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1316 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1317 | case pch::DECL_OBJC_PROPERTY: |
Fariborz Jahanian | da8ec2b | 2010-01-21 17:36:00 +0000 | [diff] [blame] | 1318 | D = ObjCPropertyDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(), |
John McCall | 339bb66 | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 1319 | 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1320 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1321 | case pch::DECL_OBJC_PROPERTY_IMPL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1322 | D = ObjCPropertyImplDecl::Create(*Context, 0, SourceLocation(), |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1323 | SourceLocation(), 0, |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1324 | ObjCPropertyImplDecl::Dynamic, 0); |
| 1325 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1326 | case pch::DECL_FIELD: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1327 | D = FieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, 0, |
Argyrios Kyrtzidis | 6032ef1 | 2009-08-21 00:31:54 +0000 | [diff] [blame] | 1328 | false); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1329 | break; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1330 | case pch::DECL_VAR: |
Argyrios Kyrtzidis | 60ed560 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 1331 | D = VarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, |
Douglas Gregor | c4df407 | 2010-04-19 22:54:31 +0000 | [diff] [blame] | 1332 | VarDecl::None, VarDecl::None); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1333 | break; |
| 1334 | |
| 1335 | case pch::DECL_IMPLICIT_PARAM: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1336 | D = ImplicitParamDecl::Create(*Context, 0, SourceLocation(), 0, QualType()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1337 | break; |
| 1338 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1339 | case pch::DECL_PARM_VAR: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1340 | D = ParmVarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, |
Douglas Gregor | c4df407 | 2010-04-19 22:54:31 +0000 | [diff] [blame] | 1341 | VarDecl::None, VarDecl::None, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1342 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1343 | case pch::DECL_FILE_SCOPE_ASM: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1344 | D = FileScopeAsmDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1345 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1346 | case pch::DECL_BLOCK: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1347 | D = BlockDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1348 | break; |
| 1349 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1350 | |
| 1351 | assert(D && "Unknown declaration reading PCH file"); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1352 | LoadedDecl(Index, D); |
| 1353 | Reader.Visit(D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1354 | |
| 1355 | // If this declaration is also a declaration context, get the |
| 1356 | // offsets for its tables of lexical and visible declarations. |
| 1357 | if (DeclContext *DC = dyn_cast<DeclContext>(D)) { |
| 1358 | std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC); |
| 1359 | if (Offsets.first || Offsets.second) { |
| 1360 | DC->setHasExternalLexicalStorage(Offsets.first != 0); |
| 1361 | DC->setHasExternalVisibleStorage(Offsets.second != 0); |
| 1362 | DeclContextOffsets[DC] = Offsets; |
| 1363 | } |
| 1364 | } |
| 1365 | assert(Idx == Record.size()); |
| 1366 | |
| 1367 | // If we have deserialized a declaration that has a definition the |
| 1368 | // AST consumer might need to know about, notify the consumer |
| 1369 | // about that definition now or queue it for later. |
| 1370 | if (isConsumerInterestedIn(D)) { |
| 1371 | if (Consumer) { |
| 1372 | DeclGroupRef DG(D); |
| 1373 | Consumer->HandleTopLevelDecl(DG); |
| 1374 | } else { |
| 1375 | InterestingDecls.push_back(D); |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | return D; |
| 1380 | } |