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