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