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 | |
| 30 | namespace { |
| 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 | 1c70e99 | 2010-06-03 19:28:45 +0000 | [diff] [blame] | 41 | CXXBaseSpecifier *ReadCXXBaseSpecifier(); |
| 42 | |
Chris Lattner | 487412d | 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 | e31bbd9 | 2010-02-21 18:22:14 +0000 | [diff] [blame] | 46 | void VisitNamespaceDecl(NamespaceDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 47 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); |
| 48 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 49 | void VisitTypeDecl(TypeDecl *TD); |
| 50 | void VisitTypedefDecl(TypedefDecl *TD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 51 | void VisitUnresolvedUsingTypename(UnresolvedUsingTypenameDecl *D); |
Chris Lattner | 487412d | 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 | ca025db | 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 | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 61 | void VisitValueDecl(ValueDecl *VD); |
| 62 | void VisitEnumConstantDecl(EnumConstantDecl *ECD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 63 | void VisitUnresolvedUsingValue(UnresolvedUsingValueDecl *D); |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 64 | void VisitDeclaratorDecl(DeclaratorDecl *DD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 65 | void VisitFunctionDecl(FunctionDecl *FD); |
Chris Lattner | ca025db | 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 | 487412d | 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 | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 74 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); |
| 75 | void VisitTemplateDecl(TemplateDecl *D); |
| 76 | void VisitClassTemplateDecl(ClassTemplateDecl *D); |
| 77 | void visitFunctionTemplateDecl(FunctionTemplateDecl *D); |
| 78 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); |
| 79 | void VisitUsing(UsingDecl *D); |
| 80 | void VisitUsingShadow(UsingShadowDecl *D); |
| 81 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 82 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 83 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); |
| 84 | void VisitStaticAssertDecl(StaticAssertDecl *D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 85 | void VisitBlockDecl(BlockDecl *BD); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 86 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 87 | std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 88 | |
Alexis Hunt | ed05325 | 2010-05-30 07:21:58 +0000 | [diff] [blame] | 89 | // FIXME: Reorder according to DeclNodes.td? |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 90 | void VisitObjCMethodDecl(ObjCMethodDecl *D); |
| 91 | void VisitObjCContainerDecl(ObjCContainerDecl *D); |
| 92 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); |
| 93 | void VisitObjCIvarDecl(ObjCIvarDecl *D); |
| 94 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); |
| 95 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); |
| 96 | void VisitObjCClassDecl(ObjCClassDecl *D); |
| 97 | void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D); |
| 98 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); |
| 99 | void VisitObjCImplDecl(ObjCImplDecl *D); |
| 100 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); |
| 101 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); |
| 102 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); |
| 103 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
| 104 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
| 105 | }; |
| 106 | } |
| 107 | |
| 108 | void PCHDeclReader::VisitDecl(Decl *D) { |
| 109 | D->setDeclContext(cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++]))); |
| 110 | D->setLexicalDeclContext( |
| 111 | cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++]))); |
| 112 | D->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 113 | D->setInvalidDecl(Record[Idx++]); |
| 114 | if (Record[Idx++]) |
Argyrios Kyrtzidis | b4b64ca | 2009-06-30 02:34:44 +0000 | [diff] [blame] | 115 | D->addAttr(Reader.ReadAttributes()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 116 | D->setImplicit(Record[Idx++]); |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 117 | D->setUsed(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 118 | D->setAccess((AccessSpecifier)Record[Idx++]); |
Douglas Gregor | 16bef85 | 2009-10-16 20:01:17 +0000 | [diff] [blame] | 119 | D->setPCHLevel(Record[Idx++] + 1); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | void PCHDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { |
| 123 | VisitDecl(TU); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 124 | TU->setAnonymousNamespace( |
| 125 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | void PCHDeclReader::VisitNamedDecl(NamedDecl *ND) { |
| 129 | VisitDecl(ND); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 130 | ND->setDeclName(Reader.ReadDeclarationName(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | void PCHDeclReader::VisitTypeDecl(TypeDecl *TD) { |
| 134 | VisitNamedDecl(TD); |
| 135 | TD->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr()); |
| 136 | } |
| 137 | |
| 138 | void PCHDeclReader::VisitTypedefDecl(TypedefDecl *TD) { |
| 139 | // Note that we cannot use VisitTypeDecl here, because we need to |
| 140 | // set the underlying type of the typedef *before* we try to read |
| 141 | // the type associated with the TypedefDecl. |
| 142 | VisitNamedDecl(TD); |
John McCall | 703a3f8 | 2009-10-24 08:00:42 +0000 | [diff] [blame] | 143 | uint64_t TypeData = Record[Idx++]; |
John McCall | bcd0350 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 144 | TD->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
John McCall | 703a3f8 | 2009-10-24 08:00:42 +0000 | [diff] [blame] | 145 | TD->setTypeForDecl(Reader.GetType(TypeData).getTypePtr()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | void PCHDeclReader::VisitTagDecl(TagDecl *TD) { |
| 149 | VisitTypeDecl(TD); |
Douglas Gregor | b6b8f9e | 2009-07-29 23:36:44 +0000 | [diff] [blame] | 150 | TD->setPreviousDeclaration( |
| 151 | cast_or_null<TagDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 152 | TD->setTagKind((TagDecl::TagKind)Record[Idx++]); |
| 153 | TD->setDefinition(Record[Idx++]); |
Douglas Gregor | 5089c76 | 2010-02-12 17:40:34 +0000 | [diff] [blame] | 154 | TD->setEmbeddedInDeclarator(Record[Idx++]); |
Argyrios Kyrtzidis | 664b690 | 2009-07-14 03:18:02 +0000 | [diff] [blame] | 155 | TD->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 82fe3e3 | 2009-07-21 14:46:17 +0000 | [diff] [blame] | 156 | TD->setTagKeywordLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
John McCall | 3e11ebe | 2010-03-15 10:12:16 +0000 | [diff] [blame] | 157 | // FIXME: maybe read optional qualifier and its range. |
| 158 | TD->setTypedefForAnonDecl( |
| 159 | cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | void PCHDeclReader::VisitEnumDecl(EnumDecl *ED) { |
| 163 | VisitTagDecl(ED); |
| 164 | ED->setIntegerType(Reader.GetType(Record[Idx++])); |
John McCall | 5677499 | 2009-12-09 09:09:27 +0000 | [diff] [blame] | 165 | ED->setPromotionType(Reader.GetType(Record[Idx++])); |
John McCall | 9aa35be | 2010-05-06 08:49:23 +0000 | [diff] [blame] | 166 | ED->setNumPositiveBits(Record[Idx++]); |
| 167 | ED->setNumNegativeBits(Record[Idx++]); |
Douglas Gregor | 7a74938 | 2009-05-27 17:20:35 +0000 | [diff] [blame] | 168 | // FIXME: C++ InstantiatedFrom |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | void PCHDeclReader::VisitRecordDecl(RecordDecl *RD) { |
| 172 | VisitTagDecl(RD); |
| 173 | RD->setHasFlexibleArrayMember(Record[Idx++]); |
| 174 | RD->setAnonymousStructOrUnion(Record[Idx++]); |
Fariborz Jahanian | 8e0d042 | 2009-07-08 16:37:44 +0000 | [diff] [blame] | 175 | RD->setHasObjectMember(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void PCHDeclReader::VisitValueDecl(ValueDecl *VD) { |
| 179 | VisitNamedDecl(VD); |
| 180 | VD->setType(Reader.GetType(Record[Idx++])); |
| 181 | } |
| 182 | |
| 183 | void PCHDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { |
| 184 | VisitValueDecl(ECD); |
| 185 | if (Record[Idx++]) |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 186 | ECD->setInitExpr(Reader.ReadDeclExpr()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 187 | ECD->setInitVal(Reader.ReadAPSInt(Record, Idx)); |
| 188 | } |
| 189 | |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 190 | void PCHDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { |
| 191 | VisitValueDecl(DD); |
John McCall | bcd0350 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 192 | TypeSourceInfo *TInfo = Reader.GetTypeSourceInfo(Record, Idx); |
| 193 | if (TInfo) |
| 194 | DD->setTypeSourceInfo(TInfo); |
John McCall | 3e11ebe | 2010-03-15 10:12:16 +0000 | [diff] [blame] | 195 | // FIXME: read optional qualifier and its range. |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 198 | void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 199 | VisitDeclaratorDecl(FD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 200 | if (Record[Idx++]) |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 201 | FD->setLazyBody(Reader.getDeclsCursor().GetCurrentBitNo()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 202 | FD->setPreviousDeclaration( |
| 203 | cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); |
| 204 | FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]); |
Douglas Gregor | c4df407 | 2010-04-19 22:54:31 +0000 | [diff] [blame] | 205 | FD->setStorageClassAsWritten((FunctionDecl::StorageClass)Record[Idx++]); |
Douglas Gregor | 35b5753 | 2009-10-27 21:01:01 +0000 | [diff] [blame] | 206 | FD->setInlineSpecified(Record[Idx++]); |
Anders Carlsson | 0a7c01f | 2009-05-14 22:15:41 +0000 | [diff] [blame] | 207 | FD->setVirtualAsWritten(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 208 | FD->setPure(Record[Idx++]); |
Anders Carlsson | e0dd1d5 | 2009-05-14 21:46:00 +0000 | [diff] [blame] | 209 | FD->setHasInheritedPrototype(Record[Idx++]); |
| 210 | FD->setHasWrittenPrototype(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 211 | FD->setDeleted(Record[Idx++]); |
Daniel Dunbar | b45012d | 2009-09-22 05:38:14 +0000 | [diff] [blame] | 212 | FD->setTrivial(Record[Idx++]); |
| 213 | FD->setCopyAssignment(Record[Idx++]); |
| 214 | FD->setHasImplicitReturnZero(Record[Idx++]); |
Argyrios Kyrtzidis | 1ead0b4 | 2009-06-20 08:09:34 +0000 | [diff] [blame] | 215 | FD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Douglas Gregor | 24c332b | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 216 | // FIXME: C++ TemplateOrInstantiation |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 217 | |
| 218 | // Read in the parameters. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 219 | unsigned NumParams = Record[Idx++]; |
| 220 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 221 | Params.reserve(NumParams); |
| 222 | for (unsigned I = 0; I != NumParams; ++I) |
| 223 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | d505812 | 2010-02-11 01:19:42 +0000 | [diff] [blame] | 224 | FD->setParams(Params.data(), NumParams); |
John McCall | b9467b6 | 2010-04-24 01:30:58 +0000 | [diff] [blame] | 225 | |
| 226 | // FIXME: order this properly w.r.t. friendness |
| 227 | // FIXME: this same thing needs to happen for function templates |
| 228 | if (FD->isOverloadedOperator() && !FD->getDeclContext()->isRecord()) |
| 229 | FD->setNonMemberOperator(); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { |
| 233 | VisitNamedDecl(MD); |
| 234 | if (Record[Idx++]) { |
| 235 | // In practice, this won't be executed (since method definitions |
| 236 | // don't occur in header files). |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 237 | MD->setBody(Reader.ReadDeclStmt()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 238 | MD->setSelfDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); |
| 239 | MD->setCmdDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++]))); |
| 240 | } |
| 241 | MD->setInstanceMethod(Record[Idx++]); |
| 242 | MD->setVariadic(Record[Idx++]); |
| 243 | MD->setSynthesized(Record[Idx++]); |
| 244 | MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]); |
| 245 | MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); |
Fariborz Jahanian | d9235db | 2010-04-08 21:29:11 +0000 | [diff] [blame] | 246 | MD->setNumSelectorArgs(unsigned(Record[Idx++])); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 247 | MD->setResultType(Reader.GetType(Record[Idx++])); |
Douglas Gregor | 12852d9 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 248 | MD->setResultTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 249 | MD->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 250 | unsigned NumParams = Record[Idx++]; |
| 251 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 252 | Params.reserve(NumParams); |
| 253 | for (unsigned I = 0; I != NumParams; ++I) |
| 254 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | cdabb31 | 2010-04-09 15:40:42 +0000 | [diff] [blame] | 255 | MD->setMethodParams(*Reader.getContext(), Params.data(), NumParams, |
| 256 | NumParams); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | void PCHDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { |
| 260 | VisitNamedDecl(CD); |
Ted Kremenek | c7c6431 | 2010-01-07 01:20:12 +0000 | [diff] [blame] | 261 | SourceLocation A = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 262 | SourceLocation B = SourceLocation::getFromRawEncoding(Record[Idx++]); |
| 263 | CD->setAtEndRange(SourceRange(A, B)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { |
| 267 | VisitObjCContainerDecl(ID); |
| 268 | ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr()); |
| 269 | ID->setSuperClass(cast_or_null<ObjCInterfaceDecl> |
| 270 | (Reader.GetDecl(Record[Idx++]))); |
| 271 | unsigned NumProtocols = Record[Idx++]; |
| 272 | llvm::SmallVector<ObjCProtocolDecl *, 16> Protocols; |
| 273 | Protocols.reserve(NumProtocols); |
| 274 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 275 | Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 276 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 277 | ProtoLocs.reserve(NumProtocols); |
| 278 | for (unsigned I = 0; I != NumProtocols; ++I) |
| 279 | ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 280 | ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(), |
| 281 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 282 | unsigned NumIvars = Record[Idx++]; |
| 283 | llvm::SmallVector<ObjCIvarDecl *, 16> IVars; |
| 284 | IVars.reserve(NumIvars); |
| 285 | for (unsigned I = 0; I != NumIvars; ++I) |
| 286 | IVars.push_back(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 287 | ID->setCategoryList( |
| 288 | cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++]))); |
| 289 | ID->setForwardDecl(Record[Idx++]); |
| 290 | ID->setImplicitInterfaceDecl(Record[Idx++]); |
| 291 | ID->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 292 | ID->setSuperClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Argyrios Kyrtzidis | ea72f42 | 2009-07-18 00:33:23 +0000 | [diff] [blame] | 293 | ID->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | void PCHDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) { |
| 297 | VisitFieldDecl(IVD); |
| 298 | IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]); |
| 299 | } |
| 300 | |
| 301 | void PCHDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { |
| 302 | VisitObjCContainerDecl(PD); |
| 303 | PD->setForwardDecl(Record[Idx++]); |
| 304 | PD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 305 | unsigned NumProtoRefs = Record[Idx++]; |
| 306 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 307 | ProtoRefs.reserve(NumProtoRefs); |
| 308 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 309 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 310 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 311 | ProtoLocs.reserve(NumProtoRefs); |
| 312 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 313 | ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 314 | PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 315 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | void PCHDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) { |
| 319 | VisitFieldDecl(FD); |
| 320 | } |
| 321 | |
| 322 | void PCHDeclReader::VisitObjCClassDecl(ObjCClassDecl *CD) { |
| 323 | VisitDecl(CD); |
| 324 | unsigned NumClassRefs = Record[Idx++]; |
| 325 | llvm::SmallVector<ObjCInterfaceDecl *, 16> ClassRefs; |
| 326 | ClassRefs.reserve(NumClassRefs); |
| 327 | for (unsigned I = 0; I != NumClassRefs; ++I) |
| 328 | ClassRefs.push_back(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Ted Kremenek | 9b124e1 | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 329 | llvm::SmallVector<SourceLocation, 16> SLocs; |
| 330 | SLocs.reserve(NumClassRefs); |
| 331 | for (unsigned I = 0; I != NumClassRefs; ++I) |
| 332 | SLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 333 | CD->setClassList(*Reader.getContext(), ClassRefs.data(), SLocs.data(), |
| 334 | NumClassRefs); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | void PCHDeclReader::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *FPD) { |
| 338 | VisitDecl(FPD); |
| 339 | unsigned NumProtoRefs = Record[Idx++]; |
| 340 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 341 | ProtoRefs.reserve(NumProtoRefs); |
| 342 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 343 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 344 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 345 | ProtoLocs.reserve(NumProtoRefs); |
| 346 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 347 | ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 348 | FPD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 349 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | void PCHDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) { |
| 353 | VisitObjCContainerDecl(CD); |
| 354 | CD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 355 | unsigned NumProtoRefs = Record[Idx++]; |
| 356 | llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; |
| 357 | ProtoRefs.reserve(NumProtoRefs); |
| 358 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 359 | ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 002b671 | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 360 | llvm::SmallVector<SourceLocation, 16> ProtoLocs; |
| 361 | ProtoLocs.reserve(NumProtoRefs); |
| 362 | for (unsigned I = 0; I != NumProtoRefs; ++I) |
| 363 | ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 364 | CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), |
| 365 | *Reader.getContext()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 366 | CD->setNextClassCategory(cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | 071676f | 2010-01-16 16:38:58 +0000 | [diff] [blame] | 367 | CD->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 368 | CD->setCategoryNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | void PCHDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { |
| 372 | VisitNamedDecl(CAD); |
| 373 | CAD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 374 | } |
| 375 | |
| 376 | void PCHDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
| 377 | VisitNamedDecl(D); |
Fariborz Jahanian | da8ec2b | 2010-01-21 17:36:00 +0000 | [diff] [blame] | 378 | D->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
John McCall | 339bb66 | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 379 | D->setType(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 380 | // FIXME: stable encoding |
| 381 | D->setPropertyAttributes( |
| 382 | (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); |
| 383 | // FIXME: stable encoding |
| 384 | D->setPropertyImplementation( |
| 385 | (ObjCPropertyDecl::PropertyControl)Record[Idx++]); |
| 386 | D->setGetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector()); |
| 387 | D->setSetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector()); |
| 388 | D->setGetterMethodDecl( |
| 389 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 390 | D->setSetterMethodDecl( |
| 391 | cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++]))); |
| 392 | D->setPropertyIvarDecl( |
| 393 | cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
| 394 | } |
| 395 | |
| 396 | void PCHDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) { |
Argyrios Kyrtzidis | 067c407 | 2009-07-27 19:04:32 +0000 | [diff] [blame] | 397 | VisitObjCContainerDecl(D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 398 | D->setClassInterface( |
| 399 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | void PCHDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { |
| 403 | VisitObjCImplDecl(D); |
| 404 | D->setIdentifier(Reader.GetIdentifierInfo(Record, Idx)); |
| 405 | } |
| 406 | |
| 407 | void PCHDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { |
| 408 | VisitObjCImplDecl(D); |
| 409 | D->setSuperClass( |
| 410 | cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | c83726e | 2010-04-28 16:11:27 +0000 | [diff] [blame] | 411 | // FIXME. Add reading of IvarInitializers and NumIvarInitializers. |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | |
| 415 | void PCHDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
| 416 | VisitDecl(D); |
| 417 | D->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); |
| 418 | D->setPropertyDecl( |
| 419 | cast_or_null<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++]))); |
| 420 | D->setPropertyIvarDecl( |
| 421 | cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++]))); |
Fariborz Jahanian | 25491a2 | 2010-05-05 21:52:17 +0000 | [diff] [blame] | 422 | // FIXME. read GetterCXXConstructor and SetterCXXAssignment |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | void PCHDeclReader::VisitFieldDecl(FieldDecl *FD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 426 | VisitDeclaratorDecl(FD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 427 | FD->setMutable(Record[Idx++]); |
| 428 | if (Record[Idx++]) |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 429 | FD->setBitWidth(Reader.ReadDeclExpr()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | void PCHDeclReader::VisitVarDecl(VarDecl *VD) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 433 | VisitDeclaratorDecl(VD); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 434 | VD->setStorageClass((VarDecl::StorageClass)Record[Idx++]); |
Douglas Gregor | c4df407 | 2010-04-19 22:54:31 +0000 | [diff] [blame] | 435 | VD->setStorageClassAsWritten((VarDecl::StorageClass)Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 436 | VD->setThreadSpecified(Record[Idx++]); |
| 437 | VD->setCXXDirectInitializer(Record[Idx++]); |
| 438 | VD->setDeclaredInCondition(Record[Idx++]); |
Douglas Gregor | 3f324d56 | 2010-05-03 18:51:14 +0000 | [diff] [blame] | 439 | VD->setExceptionVariable(Record[Idx++]); |
Douglas Gregor | 6fd1b18 | 2010-05-15 06:01:05 +0000 | [diff] [blame] | 440 | VD->setNRVOVariable(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 441 | VD->setPreviousDeclaration( |
| 442 | cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 443 | if (Record[Idx++]) |
Douglas Gregor | d505812 | 2010-02-11 01:19:42 +0000 | [diff] [blame] | 444 | VD->setInit(Reader.ReadDeclExpr()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | void PCHDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { |
| 448 | VisitVarDecl(PD); |
| 449 | } |
| 450 | |
| 451 | void PCHDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { |
| 452 | VisitVarDecl(PD); |
| 453 | PD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); |
John McCall | f3cd665 | 2010-03-12 18:31:32 +0000 | [diff] [blame] | 454 | PD->setHasInheritedDefaultArg(Record[Idx++]); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 455 | } |
| 456 | |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 457 | void PCHDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { |
| 458 | VisitDecl(AD); |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 459 | AD->setAsmString(cast<StringLiteral>(Reader.ReadDeclExpr())); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | void PCHDeclReader::VisitBlockDecl(BlockDecl *BD) { |
| 463 | VisitDecl(BD); |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 464 | BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadDeclStmt())); |
John McCall | a3ccba0 | 2010-06-04 11:21:44 +0000 | [diff] [blame] | 465 | BD->setSignatureAsWritten(Reader.GetTypeSourceInfo(Record, Idx)); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 466 | unsigned NumParams = Record[Idx++]; |
| 467 | llvm::SmallVector<ParmVarDecl *, 16> Params; |
| 468 | Params.reserve(NumParams); |
| 469 | for (unsigned I = 0; I != NumParams; ++I) |
| 470 | Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); |
Douglas Gregor | d505812 | 2010-02-11 01:19:42 +0000 | [diff] [blame] | 471 | BD->setParams(Params.data(), NumParams); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 472 | } |
| 473 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 474 | void PCHDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
| 475 | VisitDecl(D); |
| 476 | D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]); |
| 477 | D->setHasBraces(Record[Idx++]); |
| 478 | } |
| 479 | |
| 480 | void PCHDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { |
| 481 | VisitNamedDecl(D); |
| 482 | D->setLBracLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 483 | D->setRBracLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 484 | D->setNextNamespace( |
| 485 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 486 | |
| 487 | // Only read one reference--the original or anonymous namespace. |
| 488 | bool IsOriginal = Record[Idx++]; |
| 489 | if (IsOriginal) |
| 490 | D->setAnonymousNamespace( |
| 491 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 492 | else |
| 493 | D->setOriginalNamespace( |
| 494 | cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++]))); |
| 495 | } |
| 496 | |
| 497 | void PCHDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |
| 498 | VisitNamedDecl(D); |
| 499 | |
| 500 | D->setAliasLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 501 | D->setQualifierRange(Reader.ReadSourceRange(Record, Idx)); |
| 502 | D->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 503 | D->setTargetNameLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 504 | D->setAliasedNamespace(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 505 | } |
| 506 | |
| 507 | void PCHDeclReader::VisitUsing(UsingDecl *D) { |
| 508 | VisitNamedDecl(D); |
| 509 | D->setUsingLocation(Reader.ReadSourceLocation(Record, Idx)); |
| 510 | D->setNestedNameRange(Reader.ReadSourceRange(Record, Idx)); |
| 511 | D->setTargetNestedNameDecl(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 512 | |
| 513 | // FIXME: It would probably be more efficient to read these into a vector |
| 514 | // and then re-cosntruct the shadow decl set over that vector since it |
| 515 | // would avoid existence checks. |
| 516 | unsigned NumShadows = Record[Idx++]; |
| 517 | for(unsigned I = 0; I != NumShadows; ++I) { |
| 518 | D->addShadowDecl(cast<UsingShadowDecl>(Reader.GetDecl(Record[Idx++]))); |
| 519 | } |
| 520 | D->setTypeName(Record[Idx++]); |
| 521 | } |
| 522 | |
| 523 | void PCHDeclReader::VisitUsingShadow(UsingShadowDecl *D) { |
| 524 | VisitNamedDecl(D); |
| 525 | D->setTargetDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 526 | D->setUsingDecl(cast<UsingDecl>(Reader.GetDecl(Record[Idx++]))); |
| 527 | } |
| 528 | |
| 529 | void PCHDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { |
| 530 | VisitNamedDecl(D); |
| 531 | D->setNamespaceKeyLocation(Reader.ReadSourceLocation(Record, Idx)); |
| 532 | D->setQualifierRange(Reader.ReadSourceRange(Record, Idx)); |
| 533 | D->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 534 | D->setIdentLocation(Reader.ReadSourceLocation(Record, Idx)); |
| 535 | D->setNominatedNamespace(cast<NamedDecl>(Reader.GetDecl(Record[Idx++]))); |
| 536 | D->setCommonAncestor(cast_or_null<DeclContext>( |
| 537 | Reader.GetDecl(Record[Idx++]))); |
| 538 | } |
| 539 | |
| 540 | void PCHDeclReader::VisitUnresolvedUsingValue(UnresolvedUsingValueDecl *D) { |
| 541 | VisitValueDecl(D); |
| 542 | D->setTargetNestedNameRange(Reader.ReadSourceRange(Record, Idx)); |
| 543 | D->setUsingLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 544 | D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 545 | } |
| 546 | |
| 547 | void PCHDeclReader::VisitUnresolvedUsingTypename( |
| 548 | UnresolvedUsingTypenameDecl *D) { |
| 549 | VisitTypeDecl(D); |
| 550 | D->setTargetNestedNameRange(Reader.ReadSourceRange(Record, Idx)); |
| 551 | D->setUsingLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 552 | D->setTypenameLoc(Reader.ReadSourceLocation(Record, Idx)); |
| 553 | D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx)); |
| 554 | } |
| 555 | |
John McCall | 1c70e99 | 2010-06-03 19:28:45 +0000 | [diff] [blame] | 556 | CXXBaseSpecifier *PCHDeclReader::ReadCXXBaseSpecifier() { |
| 557 | bool isVirtual = static_cast<bool>(Record[Idx++]); |
| 558 | bool isBaseOfClass = static_cast<bool>(Record[Idx++]); |
| 559 | AccessSpecifier AS = static_cast<AccessSpecifier>(Record[Idx++]); |
| 560 | QualType T = Reader.GetType(Record[Idx++]); |
| 561 | SourceRange Range = Reader.ReadSourceRange(Record, Idx); |
| 562 | return new (*Reader.getContext()) |
| 563 | CXXBaseSpecifier(Range, isVirtual, isBaseOfClass, AS, T); |
| 564 | } |
| 565 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 566 | void PCHDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) { |
| 567 | // assert(false && "cannot read CXXRecordDecl"); |
| 568 | VisitRecordDecl(D); |
John McCall | 1c70e99 | 2010-06-03 19:28:45 +0000 | [diff] [blame] | 569 | |
| 570 | // FIXME: this is far from complete |
| 571 | |
| 572 | if (D->isDefinition()) { |
| 573 | D->setDefinition(false); // make peace with an assertion |
| 574 | D->startDefinition(); |
| 575 | |
| 576 | unsigned NumBases = Record[Idx++]; |
| 577 | |
| 578 | llvm::SmallVector<CXXBaseSpecifier*, 4> Bases; |
| 579 | Bases.reserve(NumBases); |
| 580 | for (unsigned I = 0; I != NumBases; ++I) |
| 581 | Bases.push_back(ReadCXXBaseSpecifier()); |
| 582 | D->setBases(Bases.begin(), NumBases); |
| 583 | |
| 584 | // FIXME: there's a lot of stuff we do here that's kindof sketchy |
| 585 | // if we're leaving the context incomplete. |
| 586 | D->completeDefinition(); |
| 587 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | void PCHDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { |
| 591 | // assert(false && "cannot read CXXMethodDecl"); |
| 592 | VisitFunctionDecl(D); |
| 593 | } |
| 594 | |
| 595 | void PCHDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
| 596 | // assert(false && "cannot read CXXConstructorDecl"); |
| 597 | VisitCXXMethodDecl(D); |
| 598 | } |
| 599 | |
| 600 | void PCHDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
| 601 | // assert(false && "cannot read CXXDestructorDecl"); |
| 602 | VisitCXXMethodDecl(D); |
| 603 | } |
| 604 | |
| 605 | void PCHDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) { |
| 606 | // assert(false && "cannot read CXXConversionDecl"); |
| 607 | VisitCXXMethodDecl(D); |
| 608 | } |
| 609 | |
| 610 | void PCHDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { |
| 611 | assert(false && "cannot read FriendTemplateDecl"); |
| 612 | } |
| 613 | |
| 614 | void PCHDeclReader::VisitTemplateDecl(TemplateDecl *D) { |
| 615 | assert(false && "cannot read TemplateDecl"); |
| 616 | } |
| 617 | |
| 618 | void PCHDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { |
| 619 | assert(false && "cannot read ClassTemplateDecl"); |
| 620 | } |
| 621 | |
| 622 | void PCHDeclReader::VisitClassTemplateSpecializationDecl( |
| 623 | ClassTemplateSpecializationDecl *D) { |
| 624 | assert(false && "cannot read ClassTemplateSpecializationDecl"); |
| 625 | } |
| 626 | |
| 627 | void PCHDeclReader::VisitClassTemplatePartialSpecializationDecl( |
| 628 | ClassTemplatePartialSpecializationDecl *D) { |
| 629 | assert(false && "cannot read ClassTemplatePartialSpecializationDecl"); |
| 630 | } |
| 631 | |
| 632 | void PCHDeclReader::visitFunctionTemplateDecl(FunctionTemplateDecl *D) { |
| 633 | assert(false && "cannot read FunctionTemplateDecl"); |
| 634 | } |
| 635 | |
| 636 | void PCHDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { |
| 637 | assert(false && "cannot read TemplateTypeParmDecl"); |
| 638 | } |
| 639 | |
| 640 | void PCHDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { |
| 641 | assert(false && "cannot read NonTypeTemplateParmDecl"); |
| 642 | } |
| 643 | |
| 644 | void PCHDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { |
| 645 | assert(false && "cannot read TemplateTemplateParmDecl"); |
| 646 | } |
| 647 | |
| 648 | void PCHDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) { |
| 649 | assert(false && "cannot read StaticAssertDecl"); |
| 650 | } |
| 651 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 652 | std::pair<uint64_t, uint64_t> |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 653 | PCHDeclReader::VisitDeclContext(DeclContext *DC) { |
| 654 | uint64_t LexicalOffset = Record[Idx++]; |
| 655 | uint64_t VisibleOffset = Record[Idx++]; |
| 656 | return std::make_pair(LexicalOffset, VisibleOffset); |
| 657 | } |
| 658 | |
| 659 | //===----------------------------------------------------------------------===// |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 660 | // Attribute Reading |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 661 | //===----------------------------------------------------------------------===// |
| 662 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 663 | /// \brief Reads attributes from the current stream position. |
| 664 | Attr *PCHReader::ReadAttributes() { |
| 665 | unsigned Code = DeclsCursor.ReadCode(); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 666 | assert(Code == llvm::bitc::UNABBREV_RECORD && |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 667 | "Expected unabbreviated record"); (void)Code; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 668 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 669 | RecordData Record; |
| 670 | unsigned Idx = 0; |
| 671 | unsigned RecCode = DeclsCursor.ReadRecord(Code, Record); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 672 | assert(RecCode == pch::DECL_ATTR && "Expected attribute record"); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 673 | (void)RecCode; |
| 674 | |
| 675 | #define SIMPLE_ATTR(Name) \ |
| 676 | case Attr::Name: \ |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 677 | New = ::new (*Context) Name##Attr(); \ |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 678 | break |
| 679 | |
| 680 | #define STRING_ATTR(Name) \ |
| 681 | case Attr::Name: \ |
Ted Kremenek | 7f4945a | 2010-02-11 05:28:37 +0000 | [diff] [blame] | 682 | New = ::new (*Context) Name##Attr(*Context, ReadString(Record, Idx)); \ |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 683 | break |
| 684 | |
| 685 | #define UNSIGNED_ATTR(Name) \ |
| 686 | case Attr::Name: \ |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 687 | New = ::new (*Context) Name##Attr(Record[Idx++]); \ |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 688 | break |
| 689 | |
| 690 | Attr *Attrs = 0; |
| 691 | while (Idx < Record.size()) { |
| 692 | Attr *New = 0; |
| 693 | Attr::Kind Kind = (Attr::Kind)Record[Idx++]; |
| 694 | bool IsInherited = Record[Idx++]; |
| 695 | |
| 696 | switch (Kind) { |
Anton Korobeynikov | 55bcea1 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 697 | default: |
| 698 | assert(0 && "Unknown attribute!"); |
| 699 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 700 | STRING_ATTR(Alias); |
Daniel Dunbar | fc6507e | 2010-05-27 02:25:39 +0000 | [diff] [blame] | 701 | SIMPLE_ATTR(AlignMac68k); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 702 | UNSIGNED_ATTR(Aligned); |
| 703 | SIMPLE_ATTR(AlwaysInline); |
| 704 | SIMPLE_ATTR(AnalyzerNoReturn); |
| 705 | STRING_ATTR(Annotate); |
| 706 | STRING_ATTR(AsmLabel); |
Alexis Hunt | 54a0254 | 2009-11-25 04:20:27 +0000 | [diff] [blame] | 707 | SIMPLE_ATTR(BaseCheck); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 708 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 709 | case Attr::Blocks: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 710 | New = ::new (*Context) BlocksAttr( |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 711 | (BlocksAttr::BlocksAttrTypes)Record[Idx++]); |
| 712 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 713 | |
Eli Friedman | e4310c8 | 2009-11-09 18:38:53 +0000 | [diff] [blame] | 714 | SIMPLE_ATTR(CDecl); |
| 715 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 716 | case Attr::Cleanup: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 717 | New = ::new (*Context) CleanupAttr( |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 718 | cast<FunctionDecl>(GetDecl(Record[Idx++]))); |
| 719 | break; |
| 720 | |
| 721 | SIMPLE_ATTR(Const); |
| 722 | UNSIGNED_ATTR(Constructor); |
| 723 | SIMPLE_ATTR(DLLExport); |
| 724 | SIMPLE_ATTR(DLLImport); |
| 725 | SIMPLE_ATTR(Deprecated); |
| 726 | UNSIGNED_ATTR(Destructor); |
| 727 | SIMPLE_ATTR(FastCall); |
Alexis Hunt | 96d5c76 | 2009-11-21 08:43:09 +0000 | [diff] [blame] | 728 | SIMPLE_ATTR(Final); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 729 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 730 | case Attr::Format: { |
| 731 | std::string Type = ReadString(Record, Idx); |
| 732 | unsigned FormatIdx = Record[Idx++]; |
| 733 | unsigned FirstArg = Record[Idx++]; |
Ted Kremenek | 7f4945a | 2010-02-11 05:28:37 +0000 | [diff] [blame] | 734 | New = ::new (*Context) FormatAttr(*Context, Type, FormatIdx, FirstArg); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 735 | break; |
| 736 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 737 | |
Fariborz Jahanian | f1c2502 | 2009-05-20 17:41:43 +0000 | [diff] [blame] | 738 | case Attr::FormatArg: { |
| 739 | unsigned FormatIdx = Record[Idx++]; |
| 740 | New = ::new (*Context) FormatArgAttr(FormatIdx); |
| 741 | break; |
| 742 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 743 | |
Fariborz Jahanian | 027b886 | 2009-05-13 18:09:35 +0000 | [diff] [blame] | 744 | case Attr::Sentinel: { |
| 745 | int sentinel = Record[Idx++]; |
| 746 | int nullPos = Record[Idx++]; |
| 747 | New = ::new (*Context) SentinelAttr(sentinel, nullPos); |
| 748 | break; |
| 749 | } |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 750 | |
| 751 | SIMPLE_ATTR(GNUInline); |
Alexis Hunt | 54a0254 | 2009-11-25 04:20:27 +0000 | [diff] [blame] | 752 | SIMPLE_ATTR(Hiding); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 753 | |
Ted Kremenek | 06be968 | 2010-02-17 02:37:45 +0000 | [diff] [blame] | 754 | case Attr::IBActionKind: |
| 755 | New = ::new (*Context) IBActionAttr(); |
| 756 | break; |
| 757 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 758 | case Attr::IBOutletKind: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 759 | New = ::new (*Context) IBOutletAttr(); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 760 | break; |
| 761 | |
Ted Kremenek | 26bde77 | 2010-05-19 17:38:06 +0000 | [diff] [blame] | 762 | case Attr::IBOutletCollectionKind: { |
| 763 | ObjCInterfaceDecl *D = |
| 764 | cast_or_null<ObjCInterfaceDecl>(GetDecl(Record[Idx++])); |
| 765 | New = ::new (*Context) IBOutletCollectionAttr(D); |
| 766 | break; |
| 767 | } |
| 768 | |
Ryan Flynn | 1f1fdc0 | 2009-08-09 20:07:29 +0000 | [diff] [blame] | 769 | SIMPLE_ATTR(Malloc); |
Mike Stump | 3722f58 | 2009-08-26 22:31:08 +0000 | [diff] [blame] | 770 | SIMPLE_ATTR(NoDebug); |
| 771 | SIMPLE_ATTR(NoInline); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 772 | SIMPLE_ATTR(NoReturn); |
| 773 | SIMPLE_ATTR(NoThrow); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 774 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 775 | case Attr::NonNull: { |
| 776 | unsigned Size = Record[Idx++]; |
| 777 | llvm::SmallVector<unsigned, 16> ArgNums; |
| 778 | ArgNums.insert(ArgNums.end(), &Record[Idx], &Record[Idx] + Size); |
| 779 | Idx += Size; |
Ted Kremenek | 510ee25 | 2010-02-11 07:31:47 +0000 | [diff] [blame] | 780 | New = ::new (*Context) NonNullAttr(*Context, ArgNums.data(), Size); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 781 | break; |
| 782 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 783 | |
Nate Begeman | f275870 | 2009-06-26 06:32:41 +0000 | [diff] [blame] | 784 | case Attr::ReqdWorkGroupSize: { |
| 785 | unsigned X = Record[Idx++]; |
| 786 | unsigned Y = Record[Idx++]; |
| 787 | unsigned Z = Record[Idx++]; |
| 788 | New = ::new (*Context) ReqdWorkGroupSizeAttr(X, Y, Z); |
| 789 | break; |
| 790 | } |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 791 | |
| 792 | SIMPLE_ATTR(ObjCException); |
| 793 | SIMPLE_ATTR(ObjCNSObject); |
Ted Kremenek | d9c6663 | 2010-02-18 00:05:45 +0000 | [diff] [blame] | 794 | SIMPLE_ATTR(CFReturnsNotRetained); |
Ted Kremenek | 9ecdfaf | 2009-05-09 02:44:38 +0000 | [diff] [blame] | 795 | SIMPLE_ATTR(CFReturnsRetained); |
Ted Kremenek | d9c6663 | 2010-02-18 00:05:45 +0000 | [diff] [blame] | 796 | SIMPLE_ATTR(NSReturnsNotRetained); |
Ted Kremenek | 9ecdfaf | 2009-05-09 02:44:38 +0000 | [diff] [blame] | 797 | SIMPLE_ATTR(NSReturnsRetained); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 798 | SIMPLE_ATTR(Overloadable); |
Alexis Hunt | 54a0254 | 2009-11-25 04:20:27 +0000 | [diff] [blame] | 799 | SIMPLE_ATTR(Override); |
Anders Carlsson | 68e0b68 | 2009-08-08 18:23:56 +0000 | [diff] [blame] | 800 | SIMPLE_ATTR(Packed); |
Daniel Dunbar | 4013044 | 2010-05-27 01:12:46 +0000 | [diff] [blame] | 801 | UNSIGNED_ATTR(MaxFieldAlignment); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 802 | SIMPLE_ATTR(Pure); |
| 803 | UNSIGNED_ATTR(Regparm); |
| 804 | STRING_ATTR(Section); |
| 805 | SIMPLE_ATTR(StdCall); |
Douglas Gregor | a941dca | 2010-05-18 16:57:00 +0000 | [diff] [blame] | 806 | SIMPLE_ATTR(ThisCall); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 807 | SIMPLE_ATTR(TransparentUnion); |
| 808 | SIMPLE_ATTR(Unavailable); |
| 809 | SIMPLE_ATTR(Unused); |
| 810 | SIMPLE_ATTR(Used); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 811 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 812 | case Attr::Visibility: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 813 | New = ::new (*Context) VisibilityAttr( |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 814 | (VisibilityAttr::VisibilityTypes)Record[Idx++]); |
| 815 | break; |
| 816 | |
| 817 | SIMPLE_ATTR(WarnUnusedResult); |
| 818 | SIMPLE_ATTR(Weak); |
Rafael Espindola | c18086a | 2010-02-23 22:00:30 +0000 | [diff] [blame] | 819 | SIMPLE_ATTR(WeakRef); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 820 | SIMPLE_ATTR(WeakImport); |
| 821 | } |
| 822 | |
| 823 | assert(New && "Unable to decode attribute?"); |
| 824 | New->setInherited(IsInherited); |
| 825 | New->setNext(Attrs); |
| 826 | Attrs = New; |
| 827 | } |
| 828 | #undef UNSIGNED_ATTR |
| 829 | #undef STRING_ATTR |
| 830 | #undef SIMPLE_ATTR |
| 831 | |
| 832 | // The list of attributes was built backwards. Reverse the list |
| 833 | // before returning it. |
| 834 | Attr *PrevAttr = 0, *NextAttr = 0; |
| 835 | while (Attrs) { |
| 836 | NextAttr = Attrs->getNext(); |
| 837 | Attrs->setNext(PrevAttr); |
| 838 | PrevAttr = Attrs; |
| 839 | Attrs = NextAttr; |
| 840 | } |
| 841 | |
| 842 | return PrevAttr; |
| 843 | } |
| 844 | |
| 845 | //===----------------------------------------------------------------------===// |
| 846 | // PCHReader Implementation |
| 847 | //===----------------------------------------------------------------------===// |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 848 | |
| 849 | /// \brief Note that we have loaded the declaration with the given |
| 850 | /// Index. |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 851 | /// |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 852 | /// This routine notes that this declaration has already been loaded, |
| 853 | /// so that future GetDecl calls will return this declaration rather |
| 854 | /// than trying to load a new declaration. |
| 855 | inline void PCHReader::LoadedDecl(unsigned Index, Decl *D) { |
| 856 | assert(!DeclsLoaded[Index] && "Decl loaded twice?"); |
| 857 | DeclsLoaded[Index] = D; |
| 858 | } |
| 859 | |
| 860 | |
| 861 | /// \brief Determine whether the consumer will be interested in seeing |
| 862 | /// this declaration (via HandleTopLevelDecl). |
| 863 | /// |
| 864 | /// This routine should return true for anything that might affect |
| 865 | /// code generation, e.g., inline function definitions, Objective-C |
| 866 | /// declarations with metadata, etc. |
| 867 | static bool isConsumerInterestedIn(Decl *D) { |
Daniel Dunbar | 865c2a7 | 2009-09-17 03:06:44 +0000 | [diff] [blame] | 868 | if (isa<FileScopeAsmDecl>(D)) |
| 869 | return true; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 870 | if (VarDecl *Var = dyn_cast<VarDecl>(D)) |
| 871 | return Var->isFileVarDecl() && Var->getInit(); |
| 872 | if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D)) |
| 873 | return Func->isThisDeclarationADefinition(); |
| 874 | return isa<ObjCProtocolDecl>(D); |
| 875 | } |
| 876 | |
| 877 | /// \brief Read the declaration at the given offset from the PCH file. |
| 878 | Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) { |
| 879 | // Keep track of where we are in the stream, then jump back there |
| 880 | // after reading this declaration. |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 881 | SavedStreamPosition SavedPosition(DeclsCursor); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 882 | |
Douglas Gregor | 1342e84 | 2009-07-06 18:54:52 +0000 | [diff] [blame] | 883 | // Note that we are loading a declaration record. |
| 884 | LoadingTypeOrDecl Loading(*this); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 885 | |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 886 | DeclsCursor.JumpToBit(Offset); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 887 | RecordData Record; |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 888 | unsigned Code = DeclsCursor.ReadCode(); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 889 | unsigned Idx = 0; |
| 890 | PCHDeclReader Reader(*this, Record, Idx); |
| 891 | |
Chris Lattner | 1de76db | 2009-04-27 05:58:23 +0000 | [diff] [blame] | 892 | Decl *D = 0; |
| 893 | switch ((pch::DeclCode)DeclsCursor.ReadRecord(Code, Record)) { |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 894 | case pch::DECL_ATTR: |
| 895 | case pch::DECL_CONTEXT_LEXICAL: |
| 896 | case pch::DECL_CONTEXT_VISIBLE: |
| 897 | assert(false && "Record cannot be de-serialized with ReadDeclRecord"); |
| 898 | break; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 899 | case pch::DECL_TRANSLATION_UNIT: |
| 900 | assert(Index == 0 && "Translation unit must be at index 0"); |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 901 | D = Context->getTranslationUnitDecl(); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 902 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 903 | case pch::DECL_TYPEDEF: |
John McCall | 703a3f8 | 2009-10-24 08:00:42 +0000 | [diff] [blame] | 904 | D = TypedefDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 905 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 906 | case pch::DECL_ENUM: |
Douglas Gregor | 82fe3e3 | 2009-07-21 14:46:17 +0000 | [diff] [blame] | 907 | D = EnumDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 908 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 909 | case pch::DECL_RECORD: |
Abramo Bagnara | 6150c88 | 2010-05-11 21:36:43 +0000 | [diff] [blame] | 910 | D = RecordDecl::Create(*Context, TTK_Struct, 0, SourceLocation(), |
Douglas Gregor | 82fe3e3 | 2009-07-21 14:46:17 +0000 | [diff] [blame] | 911 | 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 912 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 913 | case pch::DECL_ENUM_CONSTANT: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 914 | D = EnumConstantDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 915 | 0, llvm::APSInt()); |
| 916 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 917 | case pch::DECL_FUNCTION: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 918 | D = FunctionDecl::Create(*Context, 0, SourceLocation(), DeclarationName(), |
Argyrios Kyrtzidis | 60ed560 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 919 | QualType(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 920 | break; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 921 | case pch::DECL_LINKAGE_SPEC: |
| 922 | D = LinkageSpecDecl::Create(*Context, 0, SourceLocation(), |
| 923 | (LinkageSpecDecl::LanguageIDs)0, |
| 924 | false); |
| 925 | break; |
| 926 | case pch::DECL_NAMESPACE: |
| 927 | D = NamespaceDecl::Create(*Context, 0, SourceLocation(), 0); |
| 928 | break; |
| 929 | case pch::DECL_NAMESPACE_ALIAS: |
| 930 | D = NamespaceAliasDecl::Create(*Context, 0, SourceLocation(), |
| 931 | SourceLocation(), 0, SourceRange(), 0, |
| 932 | SourceLocation(), 0); |
| 933 | break; |
| 934 | case pch::DECL_USING: |
| 935 | D = UsingDecl::Create(*Context, 0, SourceLocation(), SourceRange(), |
| 936 | SourceLocation(), 0, DeclarationName(), false); |
| 937 | break; |
| 938 | case pch::DECL_USING_SHADOW: |
| 939 | D = UsingShadowDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
| 940 | break; |
| 941 | case pch::DECL_USING_DIRECTIVE: |
| 942 | D = UsingDirectiveDecl::Create(*Context, 0, SourceLocation(), |
| 943 | SourceLocation(), SourceRange(), 0, |
| 944 | SourceLocation(), 0, 0); |
| 945 | break; |
| 946 | case pch::DECL_UNRESOLVED_USING_VALUE: |
| 947 | D = UnresolvedUsingValueDecl::Create(*Context, 0, SourceLocation(), |
| 948 | SourceRange(), 0, SourceLocation(), |
| 949 | DeclarationName()); |
| 950 | break; |
| 951 | case pch::DECL_UNRESOLVED_USING_TYPENAME: |
| 952 | D = UnresolvedUsingTypenameDecl::Create(*Context, 0, SourceLocation(), |
| 953 | SourceLocation(), SourceRange(), |
| 954 | 0, SourceLocation(), |
| 955 | DeclarationName()); |
| 956 | break; |
| 957 | case pch::DECL_CXX_RECORD: |
Abramo Bagnara | 6150c88 | 2010-05-11 21:36:43 +0000 | [diff] [blame] | 958 | D = CXXRecordDecl::Create(*Context, TTK_Struct, 0, |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 959 | SourceLocation(), 0, SourceLocation(), 0); |
| 960 | break; |
| 961 | case pch::DECL_CXX_METHOD: |
| 962 | D = CXXMethodDecl::Create(*Context, 0, SourceLocation(), DeclarationName(), |
| 963 | QualType(), 0); |
| 964 | break; |
| 965 | case pch::DECL_CXX_CONSTRUCTOR: |
| 966 | D = CXXConstructorDecl::Create(*Context, Decl::EmptyShell()); |
| 967 | break; |
| 968 | case pch::DECL_CXX_DESTRUCTOR: |
| 969 | D = CXXDestructorDecl::Create(*Context, Decl::EmptyShell()); |
| 970 | break; |
| 971 | case pch::DECL_CXX_CONVERSION: |
| 972 | D = CXXConversionDecl::Create(*Context, Decl::EmptyShell()); |
| 973 | break; |
| 974 | case pch::DECL_FRIEND: |
| 975 | assert(false && "cannot read FriendDecl"); |
| 976 | break; |
| 977 | case pch::DECL_FRIEND_TEMPLATE: |
| 978 | assert(false && "cannot read FriendTemplateDecl"); |
| 979 | break; |
| 980 | case pch::DECL_TEMPLATE: |
| 981 | // FIXME: Should TemplateDecl be ABSTRACT_DECL??? |
| 982 | assert(false && "TemplateDecl should be abstract!"); |
| 983 | break; |
| 984 | case pch::DECL_CLASS_TEMPLATE: |
| 985 | assert(false && "cannot read ClassTemplateDecl"); |
| 986 | break; |
| 987 | case pch::DECL_CLASS_TEMPLATE_SPECIALIZATION: |
| 988 | assert(false && "cannot read ClasstemplateSpecializationDecl"); |
| 989 | break; |
| 990 | case pch::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION: |
| 991 | assert(false && "cannot read ClassTemplatePartialSpecializationDecl"); |
| 992 | break; |
| 993 | case pch::DECL_FUNCTION_TEMPLATE: |
| 994 | assert(false && "cannot read FunctionTemplateDecl"); |
| 995 | break; |
| 996 | case pch::DECL_TEMPLATE_TYPE_PARM: |
| 997 | assert(false && "cannot read TemplateTypeParmDecl"); |
| 998 | break; |
| 999 | case pch::DECL_NON_TYPE_TEMPLATE_PARM: |
| 1000 | assert(false && "cannot read NonTypeTemplateParmDecl"); |
| 1001 | break; |
| 1002 | case pch::DECL_TEMPLATE_TEMPLATE_PARM: |
| 1003 | assert(false && "cannot read TemplateTemplateParmDecl"); |
| 1004 | break; |
| 1005 | case pch::DECL_STATIC_ASSERT: |
| 1006 | assert(false && "cannot read StaticAssertDecl"); |
| 1007 | break; |
| 1008 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1009 | case pch::DECL_OBJC_METHOD: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1010 | D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(), |
Douglas Gregor | 12852d9 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 1011 | Selector(), QualType(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1012 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1013 | case pch::DECL_OBJC_INTERFACE: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1014 | D = ObjCInterfaceDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1015 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1016 | case pch::DECL_OBJC_IVAR: |
Argyrios Kyrtzidis | 60ed560 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 1017 | D = ObjCIvarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1018 | ObjCIvarDecl::None); |
| 1019 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1020 | case pch::DECL_OBJC_PROTOCOL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1021 | D = ObjCProtocolDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1022 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1023 | case pch::DECL_OBJC_AT_DEFS_FIELD: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1024 | D = ObjCAtDefsFieldDecl::Create(*Context, 0, SourceLocation(), 0, |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1025 | QualType(), 0); |
| 1026 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1027 | case pch::DECL_OBJC_CLASS: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1028 | D = ObjCClassDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1029 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1030 | case pch::DECL_OBJC_FORWARD_PROTOCOL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1031 | D = ObjCForwardProtocolDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1032 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1033 | case pch::DECL_OBJC_CATEGORY: |
Douglas Gregor | 071676f | 2010-01-16 16:38:58 +0000 | [diff] [blame] | 1034 | D = ObjCCategoryDecl::Create(*Context, 0, SourceLocation(), |
| 1035 | SourceLocation(), SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1036 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1037 | case pch::DECL_OBJC_CATEGORY_IMPL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1038 | D = ObjCCategoryImplDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1039 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1040 | case pch::DECL_OBJC_IMPLEMENTATION: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1041 | D = ObjCImplementationDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1042 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1043 | case pch::DECL_OBJC_COMPATIBLE_ALIAS: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1044 | D = ObjCCompatibleAliasDecl::Create(*Context, 0, SourceLocation(), 0, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1045 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1046 | case pch::DECL_OBJC_PROPERTY: |
Fariborz Jahanian | da8ec2b | 2010-01-21 17:36:00 +0000 | [diff] [blame] | 1047 | D = ObjCPropertyDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(), |
John McCall | 339bb66 | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 1048 | 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1049 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1050 | case pch::DECL_OBJC_PROPERTY_IMPL: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1051 | D = ObjCPropertyImplDecl::Create(*Context, 0, SourceLocation(), |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1052 | SourceLocation(), 0, |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1053 | ObjCPropertyImplDecl::Dynamic, 0); |
| 1054 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1055 | case pch::DECL_FIELD: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1056 | D = FieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, 0, |
Argyrios Kyrtzidis | 6032ef1 | 2009-08-21 00:31:54 +0000 | [diff] [blame] | 1057 | false); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1058 | break; |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1059 | case pch::DECL_VAR: |
Argyrios Kyrtzidis | 60ed560 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 1060 | D = VarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, |
Douglas Gregor | c4df407 | 2010-04-19 22:54:31 +0000 | [diff] [blame] | 1061 | VarDecl::None, VarDecl::None); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1062 | break; |
| 1063 | |
| 1064 | case pch::DECL_IMPLICIT_PARAM: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1065 | D = ImplicitParamDecl::Create(*Context, 0, SourceLocation(), 0, QualType()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1066 | break; |
| 1067 | |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1068 | case pch::DECL_PARM_VAR: |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1069 | D = ParmVarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, |
Douglas Gregor | c4df407 | 2010-04-19 22:54:31 +0000 | [diff] [blame] | 1070 | VarDecl::None, VarDecl::None, 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1071 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1072 | case pch::DECL_FILE_SCOPE_ASM: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1073 | D = FileScopeAsmDecl::Create(*Context, 0, SourceLocation(), 0); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1074 | break; |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1075 | case pch::DECL_BLOCK: |
Chris Lattner | 8575daa | 2009-04-27 21:45:14 +0000 | [diff] [blame] | 1076 | D = BlockDecl::Create(*Context, 0, SourceLocation()); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1077 | break; |
| 1078 | } |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1079 | |
| 1080 | assert(D && "Unknown declaration reading PCH file"); |
Chris Lattner | 8f63ab5 | 2009-04-27 06:01:06 +0000 | [diff] [blame] | 1081 | LoadedDecl(Index, D); |
| 1082 | Reader.Visit(D); |
Chris Lattner | 487412d | 2009-04-27 05:27:42 +0000 | [diff] [blame] | 1083 | |
| 1084 | // If this declaration is also a declaration context, get the |
| 1085 | // offsets for its tables of lexical and visible declarations. |
| 1086 | if (DeclContext *DC = dyn_cast<DeclContext>(D)) { |
| 1087 | std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC); |
| 1088 | if (Offsets.first || Offsets.second) { |
| 1089 | DC->setHasExternalLexicalStorage(Offsets.first != 0); |
| 1090 | DC->setHasExternalVisibleStorage(Offsets.second != 0); |
| 1091 | DeclContextOffsets[DC] = Offsets; |
| 1092 | } |
| 1093 | } |
| 1094 | assert(Idx == Record.size()); |
| 1095 | |
| 1096 | // If we have deserialized a declaration that has a definition the |
| 1097 | // AST consumer might need to know about, notify the consumer |
| 1098 | // about that definition now or queue it for later. |
| 1099 | if (isConsumerInterestedIn(D)) { |
| 1100 | if (Consumer) { |
| 1101 | DeclGroupRef DG(D); |
| 1102 | Consumer->HandleTopLevelDecl(DG); |
| 1103 | } else { |
| 1104 | InterestingDecls.push_back(D); |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | return D; |
| 1109 | } |