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