Sebastian Redl | d6522cf | 2010-08-18 23:56:31 +0000 | [diff] [blame] | 1 | //===--- ASTWriterDecl.cpp - Declaration Serialization --------------------===// |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 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 serialization for Declarations. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Sebastian Redl | fa1f370 | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 14 | #include "ASTCommon.h" |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 15 | #include "clang/AST/DeclCXX.h" |
Argyrios Kyrtzidis | 3317d98 | 2010-10-20 16:22:56 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclContextInternals.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclTemplate.h" |
| 18 | #include "clang/AST/DeclVisitor.h" |
| 19 | #include "clang/AST/Expr.h" |
Argyrios Kyrtzidis | 5fc727a | 2011-10-28 22:54:21 +0000 | [diff] [blame] | 20 | #include "clang/Basic/SourceManager.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 21 | #include "clang/Serialization/ASTReader.h" |
Mehdi Amini | 9670f84 | 2016-07-18 19:02:11 +0000 | [diff] [blame] | 22 | #include "clang/Serialization/ASTWriter.h" |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 23 | #include "llvm/Bitcode/BitstreamWriter.h" |
Daniel Dunbar | f5bda7b | 2009-12-03 09:13:36 +0000 | [diff] [blame] | 24 | #include "llvm/Support/ErrorHandling.h" |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 25 | using namespace clang; |
Sebastian Redl | fa1f370 | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 26 | using namespace serialization; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 27 | |
| 28 | //===----------------------------------------------------------------------===// |
| 29 | // Declaration serialization |
| 30 | //===----------------------------------------------------------------------===// |
| 31 | |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 32 | namespace clang { |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 33 | class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> { |
Sebastian Redl | 55c0ad5 | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 34 | ASTWriter &Writer; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 35 | ASTContext &Context; |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 36 | ASTRecordWriter Record; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 37 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 38 | serialization::DeclCode Code; |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 39 | unsigned AbbrevToUse; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 40 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 41 | public: |
| 42 | ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, |
| 43 | ASTWriter::RecordDataImpl &Record) |
| 44 | : Writer(Writer), Context(Context), Record(Writer, Record), |
| 45 | Code((serialization::DeclCode)0), AbbrevToUse(0) {} |
| 46 | |
| 47 | uint64_t Emit(Decl *D) { |
| 48 | if (!Code) |
| 49 | llvm::report_fatal_error(StringRef("unexpected declaration kind '") + |
| 50 | D->getDeclKindName() + "'"); |
Richard Smith | 645d2cf | 2016-04-14 00:29:55 +0000 | [diff] [blame] | 51 | return Record.Emit(Code, AbbrevToUse); |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 52 | } |
Argyrios Kyrtzidis | 8b200a5 | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 53 | |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 54 | void Visit(Decl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 55 | |
| 56 | void VisitDecl(Decl *D); |
Nico Weber | 6622029 | 2016-03-02 17:28:48 +0000 | [diff] [blame] | 57 | void VisitPragmaCommentDecl(PragmaCommentDecl *D); |
Nico Weber | cbbaeb1 | 2016-03-02 19:28:54 +0000 | [diff] [blame] | 58 | void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 59 | void VisitTranslationUnitDecl(TranslationUnitDecl *D); |
| 60 | void VisitNamedDecl(NamedDecl *D); |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 61 | void VisitLabelDecl(LabelDecl *LD); |
Douglas Gregor | e31bbd9 | 2010-02-21 18:22:14 +0000 | [diff] [blame] | 62 | void VisitNamespaceDecl(NamespaceDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 63 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); |
| 64 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 65 | void VisitTypeDecl(TypeDecl *D); |
Douglas Gregor | 1f17906 | 2011-12-19 14:40:25 +0000 | [diff] [blame] | 66 | void VisitTypedefNameDecl(TypedefNameDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 67 | void VisitTypedefDecl(TypedefDecl *D); |
Richard Smith | dda56e4 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 68 | void VisitTypeAliasDecl(TypeAliasDecl *D); |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 69 | void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 70 | void VisitTagDecl(TagDecl *D); |
| 71 | void VisitEnumDecl(EnumDecl *D); |
| 72 | void VisitRecordDecl(RecordDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 73 | void VisitCXXRecordDecl(CXXRecordDecl *D); |
| 74 | void VisitClassTemplateSpecializationDecl( |
| 75 | ClassTemplateSpecializationDecl *D); |
| 76 | void VisitClassTemplatePartialSpecializationDecl( |
| 77 | ClassTemplatePartialSpecializationDecl *D); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 78 | void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D); |
| 79 | void VisitVarTemplatePartialSpecializationDecl( |
| 80 | VarTemplatePartialSpecializationDecl *D); |
Fariborz Jahanian | 3a039e3 | 2011-08-27 20:50:59 +0000 | [diff] [blame] | 81 | void VisitClassScopeFunctionSpecializationDecl( |
| 82 | ClassScopeFunctionSpecializationDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 83 | void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 84 | void VisitValueDecl(ValueDecl *D); |
| 85 | void VisitEnumConstantDecl(EnumConstantDecl *D); |
Argyrios Kyrtzidis | bd8ac8c | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 86 | void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 87 | void VisitDeclaratorDecl(DeclaratorDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 88 | void VisitFunctionDecl(FunctionDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 89 | void VisitCXXMethodDecl(CXXMethodDecl *D); |
| 90 | void VisitCXXConstructorDecl(CXXConstructorDecl *D); |
| 91 | void VisitCXXDestructorDecl(CXXDestructorDecl *D); |
| 92 | void VisitCXXConversionDecl(CXXConversionDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 93 | void VisitFieldDecl(FieldDecl *D); |
John McCall | 5e77d76 | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 94 | void VisitMSPropertyDecl(MSPropertyDecl *D); |
Francois Pichet | 783dd6e | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 95 | void VisitIndirectFieldDecl(IndirectFieldDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 96 | void VisitVarDecl(VarDecl *D); |
| 97 | void VisitImplicitParamDecl(ImplicitParamDecl *D); |
| 98 | void VisitParmVarDecl(ParmVarDecl *D); |
Richard Smith | 7b76d81 | 2016-08-12 02:21:25 +0000 | [diff] [blame] | 99 | void VisitDecompositionDecl(DecompositionDecl *D); |
| 100 | void VisitBindingDecl(BindingDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 101 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); |
| 102 | void VisitTemplateDecl(TemplateDecl *D); |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 103 | void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 104 | void VisitClassTemplateDecl(ClassTemplateDecl *D); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 105 | void VisitVarTemplateDecl(VarTemplateDecl *D); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 106 | void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 107 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); |
Richard Smith | 3f1b5d0 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 108 | void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D); |
Argyrios Kyrtzidis | 41d4562 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 109 | void VisitUsingDecl(UsingDecl *D); |
Richard Smith | 151c456 | 2016-12-20 21:35:28 +0000 | [diff] [blame^] | 110 | void VisitUsingPackDecl(UsingPackDecl *D); |
Argyrios Kyrtzidis | 41d4562 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 111 | void VisitUsingShadowDecl(UsingShadowDecl *D); |
Richard Smith | 5179eb7 | 2016-06-28 19:03:57 +0000 | [diff] [blame] | 112 | void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 113 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); |
Richard Smith | 8df390f | 2016-09-08 23:14:54 +0000 | [diff] [blame] | 114 | void VisitExportDecl(ExportDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 115 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *D); |
Douglas Gregor | ba34552 | 2011-12-02 23:23:56 +0000 | [diff] [blame] | 116 | void VisitImportDecl(ImportDecl *D); |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 117 | void VisitAccessSpecDecl(AccessSpecDecl *D); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 118 | void VisitFriendDecl(FriendDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 119 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); |
| 120 | void VisitStaticAssertDecl(StaticAssertDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 121 | void VisitBlockDecl(BlockDecl *D); |
Tareq A. Siraj | 6dfa25a | 2013-04-16 19:37:38 +0000 | [diff] [blame] | 122 | void VisitCapturedDecl(CapturedDecl *D); |
Michael Han | 8432435 | 2013-02-22 17:15:32 +0000 | [diff] [blame] | 123 | void VisitEmptyDecl(EmptyDecl *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 124 | |
Richard Smith | f1c23dc | 2016-04-13 02:12:03 +0000 | [diff] [blame] | 125 | void VisitDeclContext(DeclContext *DC); |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 126 | template <typename T> void VisitRedeclarable(Redeclarable<T> *D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 127 | |
| 128 | |
Alexis Hunt | ed05325 | 2010-05-30 07:21:58 +0000 | [diff] [blame] | 129 | // FIXME: Put in the same order is DeclNodes.td? |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 130 | void VisitObjCMethodDecl(ObjCMethodDecl *D); |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 131 | void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 132 | void VisitObjCContainerDecl(ObjCContainerDecl *D); |
| 133 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); |
| 134 | void VisitObjCIvarDecl(ObjCIvarDecl *D); |
| 135 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); |
| 136 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 137 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); |
| 138 | void VisitObjCImplDecl(ObjCImplDecl *D); |
| 139 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); |
| 140 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); |
| 141 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); |
| 142 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
| 143 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 144 | void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D); |
Alexey Bataev | 94a4f0c | 2016-03-03 05:21:39 +0000 | [diff] [blame] | 145 | void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D); |
Alexey Bataev | 4244be2 | 2016-02-11 05:35:55 +0000 | [diff] [blame] | 146 | void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D); |
Richard Smith | d28ac5b | 2014-03-22 23:33:22 +0000 | [diff] [blame] | 147 | |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 148 | /// Add an Objective-C type parameter list to the given record. |
| 149 | void AddObjCTypeParamList(ObjCTypeParamList *typeParams) { |
| 150 | // Empty type parameter list. |
| 151 | if (!typeParams) { |
| 152 | Record.push_back(0); |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | Record.push_back(typeParams->size()); |
| 157 | for (auto typeParam : *typeParams) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 158 | Record.AddDeclRef(typeParam); |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 159 | } |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 160 | Record.AddSourceLocation(typeParams->getLAngleLoc()); |
| 161 | Record.AddSourceLocation(typeParams->getRAngleLoc()); |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 164 | /// Add to the record the first declaration from each module file that |
| 165 | /// provides a declaration of D. The intent is to provide a sufficient |
| 166 | /// set such that reloading this set will load all current redeclarations. |
| 167 | void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) { |
| 168 | llvm::MapVector<ModuleFile*, const Decl*> Firsts; |
| 169 | // FIXME: We can skip entries that we know are implied by others. |
Richard Smith | 5f55d93 | 2015-08-27 21:38:25 +0000 | [diff] [blame] | 170 | for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) { |
| 171 | if (R->isFromASTFile()) |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 172 | Firsts[Writer.Chain->getOwningModuleFile(R)] = R; |
Richard Smith | 5f55d93 | 2015-08-27 21:38:25 +0000 | [diff] [blame] | 173 | else if (IncludeLocal) |
| 174 | Firsts[nullptr] = R; |
| 175 | } |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 176 | for (const auto &F : Firsts) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 177 | Record.AddDeclRef(F.second); |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 180 | /// Get the specialization decl from an entry in the specialization list. |
| 181 | template <typename EntryType> |
| 182 | typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType * |
| 183 | getSpecializationDecl(EntryType &T) { |
| 184 | return RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::getDecl(&T); |
| 185 | } |
| 186 | |
| 187 | /// Get the list of partial specializations from a template's common ptr. |
| 188 | template<typename T> |
| 189 | decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) { |
| 190 | return Common->PartialSpecializations; |
| 191 | } |
| 192 | ArrayRef<Decl> getPartialSpecializations(FunctionTemplateDecl::Common *) { |
| 193 | return None; |
| 194 | } |
| 195 | |
Richard Smith | 8ab0cfd | 2016-02-24 21:59:10 +0000 | [diff] [blame] | 196 | template<typename DeclTy> |
| 197 | void AddTemplateSpecializations(DeclTy *D) { |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 198 | auto *Common = D->getCommonPtr(); |
| 199 | |
| 200 | // If we have any lazy specializations, and the external AST source is |
| 201 | // our chained AST reader, we can just write out the DeclIDs. Otherwise, |
| 202 | // we need to resolve them to actual declarations. |
| 203 | if (Writer.Chain != Writer.Context->getExternalSource() && |
| 204 | Common->LazySpecializations) { |
| 205 | D->LoadLazySpecializations(); |
| 206 | assert(!Common->LazySpecializations); |
| 207 | } |
| 208 | |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 209 | ArrayRef<DeclID> LazySpecializations; |
| 210 | if (auto *LS = Common->LazySpecializations) |
Craig Topper | 55e39a7 | 2015-09-29 04:53:28 +0000 | [diff] [blame] | 211 | LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]); |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 212 | |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 213 | // Add a slot to the record for the number of specializations. |
| 214 | unsigned I = Record.size(); |
| 215 | Record.push_back(0); |
| 216 | |
Richard Smith | 8ab0cfd | 2016-02-24 21:59:10 +0000 | [diff] [blame] | 217 | // AddFirstDeclFromEachModule might trigger deserialization, invalidating |
| 218 | // *Specializations iterators. |
| 219 | llvm::SmallVector<const Decl*, 16> Specs; |
| 220 | for (auto &Entry : Common->Specializations) |
| 221 | Specs.push_back(getSpecializationDecl(Entry)); |
| 222 | for (auto &Entry : getPartialSpecializations(Common)) |
| 223 | Specs.push_back(getSpecializationDecl(Entry)); |
| 224 | |
| 225 | for (auto *D : Specs) { |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 226 | assert(D->isCanonicalDecl() && "non-canonical decl in set"); |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 227 | AddFirstDeclFromEachModule(D, /*IncludeLocal*/true); |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 228 | } |
Benjamin Kramer | f367dd9 | 2015-06-12 15:31:50 +0000 | [diff] [blame] | 229 | Record.append(LazySpecializations.begin(), LazySpecializations.end()); |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 230 | |
| 231 | // Update the size entry we added earlier. |
| 232 | Record[I] = Record.size() - I - 1; |
| 233 | } |
| 234 | |
| 235 | /// Ensure that this template specialization is associated with the specified |
| 236 | /// template on reload. |
| 237 | void RegisterTemplateSpecialization(const Decl *Template, |
| 238 | const Decl *Specialization) { |
| 239 | Template = Template->getCanonicalDecl(); |
| 240 | |
| 241 | // If the canonical template is local, we'll write out this specialization |
| 242 | // when we emit it. |
| 243 | // FIXME: We can do the same thing if there is any local declaration of |
| 244 | // the template, to avoid emitting an update record. |
| 245 | if (!Template->isFromASTFile()) |
| 246 | return; |
| 247 | |
| 248 | // We only need to associate the first local declaration of the |
| 249 | // specialization. The other declarations will get pulled in by it. |
| 250 | if (Writer.getFirstLocalDecl(Specialization) != Specialization) |
| 251 | return; |
| 252 | |
| 253 | Writer.DeclUpdates[Template].push_back(ASTWriter::DeclUpdate( |
| 254 | UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION, Specialization)); |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 255 | } |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 256 | }; |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 257 | } |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 258 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 259 | void ASTDeclWriter::Visit(Decl *D) { |
| 260 | DeclVisitor<ASTDeclWriter>::Visit(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 261 | |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 262 | // Source locations require array (variable-length) abbreviations. The |
| 263 | // abbreviation infrastructure requires that arrays are encoded last, so |
| 264 | // we handle it here in the case of those classes derived from DeclaratorDecl |
Nick Lewycky | 4b81fc87 | 2015-10-18 20:32:12 +0000 | [diff] [blame] | 265 | if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 266 | Record.AddTypeSourceInfo(DD->getTypeSourceInfo()); |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 267 | } |
| 268 | |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 269 | // Handle FunctionDecl's body here and write it after all other Stmts/Exprs |
| 270 | // have been written. We want it last because we will not read it back when |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 271 | // retrieving it from the AST, we'll just lazily set the offset. |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 272 | if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
Alexis Hunt | 4a8ea10 | 2011-05-06 20:44:56 +0000 | [diff] [blame] | 273 | Record.push_back(FD->doesThisDeclarationHaveABody()); |
| 274 | if (FD->doesThisDeclarationHaveABody()) |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 275 | Record.AddFunctionDefinition(FD); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 276 | } |
Richard Smith | f1c23dc | 2016-04-13 02:12:03 +0000 | [diff] [blame] | 277 | |
| 278 | // If this declaration is also a DeclContext, write blocks for the |
| 279 | // declarations that lexically stored inside its context and those |
| 280 | // declarations that are visible from its context. |
| 281 | if (DeclContext *DC = dyn_cast<DeclContext>(D)) |
| 282 | VisitDeclContext(DC); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 283 | } |
| 284 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 285 | void ASTDeclWriter::VisitDecl(Decl *D) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 286 | Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext())); |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 287 | if (D->getDeclContext() != D->getLexicalDeclContext()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 288 | Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext())); |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 289 | else |
| 290 | Record.push_back(0); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 291 | Record.push_back(D->isInvalidDecl()); |
| 292 | Record.push_back(D->hasAttrs()); |
Argyrios Kyrtzidis | 9beef8e | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 293 | if (D->hasAttrs()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 294 | Record.AddAttributes(D->getAttrs()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 295 | Record.push_back(D->isImplicit()); |
Douglas Gregor | ebada077 | 2010-06-17 23:14:26 +0000 | [diff] [blame] | 296 | Record.push_back(D->isUsed(false)); |
Argyrios Kyrtzidis | 1618023 | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 297 | Record.push_back(D->isReferenced()); |
Douglas Gregor | 781f713 | 2012-01-06 16:59:53 +0000 | [diff] [blame] | 298 | Record.push_back(D->isTopLevelDeclInObjCContainer()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 299 | Record.push_back(D->getAccess()); |
Douglas Gregor | 781f713 | 2012-01-06 16:59:53 +0000 | [diff] [blame] | 300 | Record.push_back(D->isModulePrivate()); |
Douglas Gregor | a28bcdd | 2011-12-01 02:07:58 +0000 | [diff] [blame] | 301 | Record.push_back(Writer.inferSubmoduleIDFromLocation(D->getLocation())); |
Richard Smith | c264d35 | 2014-03-23 02:30:01 +0000 | [diff] [blame] | 302 | |
| 303 | // If this declaration injected a name into a context different from its |
| 304 | // lexical context, and that context is an imported namespace, we need to |
| 305 | // update its visible declarations to include this name. |
| 306 | // |
| 307 | // This happens when we instantiate a class with a friend declaration or a |
| 308 | // function with a local extern declaration, for instance. |
Richard Smith | 5fc18a9 | 2015-07-12 23:43:21 +0000 | [diff] [blame] | 309 | // |
| 310 | // FIXME: Can we handle this in AddedVisibleDecl instead? |
Richard Smith | c264d35 | 2014-03-23 02:30:01 +0000 | [diff] [blame] | 311 | if (D->isOutOfLine()) { |
Richard Smith | e3a9702 | 2014-03-23 20:41:56 +0000 | [diff] [blame] | 312 | auto *DC = D->getDeclContext(); |
| 313 | while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) { |
| 314 | if (!NS->isFromASTFile()) |
| 315 | break; |
Chandler Carruth | 8a3d24d | 2015-03-26 04:27:10 +0000 | [diff] [blame] | 316 | Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext()); |
Richard Smith | e3a9702 | 2014-03-23 20:41:56 +0000 | [diff] [blame] | 317 | if (!NS->isInlineNamespace()) |
| 318 | break; |
| 319 | DC = NS->getParent(); |
| 320 | } |
Richard Smith | c264d35 | 2014-03-23 02:30:01 +0000 | [diff] [blame] | 321 | } |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 322 | } |
| 323 | |
Nico Weber | 6622029 | 2016-03-02 17:28:48 +0000 | [diff] [blame] | 324 | void ASTDeclWriter::VisitPragmaCommentDecl(PragmaCommentDecl *D) { |
| 325 | StringRef Arg = D->getArg(); |
| 326 | Record.push_back(Arg.size()); |
| 327 | VisitDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 328 | Record.AddSourceLocation(D->getLocStart()); |
Nico Weber | 6622029 | 2016-03-02 17:28:48 +0000 | [diff] [blame] | 329 | Record.push_back(D->getCommentKind()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 330 | Record.AddString(Arg); |
Nico Weber | 6622029 | 2016-03-02 17:28:48 +0000 | [diff] [blame] | 331 | Code = serialization::DECL_PRAGMA_COMMENT; |
| 332 | } |
| 333 | |
Nico Weber | cbbaeb1 | 2016-03-02 19:28:54 +0000 | [diff] [blame] | 334 | void ASTDeclWriter::VisitPragmaDetectMismatchDecl( |
| 335 | PragmaDetectMismatchDecl *D) { |
| 336 | StringRef Name = D->getName(); |
| 337 | StringRef Value = D->getValue(); |
| 338 | Record.push_back(Name.size() + 1 + Value.size()); |
| 339 | VisitDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 340 | Record.AddSourceLocation(D->getLocStart()); |
| 341 | Record.AddString(Name); |
| 342 | Record.AddString(Value); |
Nico Weber | cbbaeb1 | 2016-03-02 19:28:54 +0000 | [diff] [blame] | 343 | Code = serialization::DECL_PRAGMA_DETECT_MISMATCH; |
| 344 | } |
| 345 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 346 | void ASTDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) { |
Douglas Gregor | dab4243 | 2011-08-12 00:15:20 +0000 | [diff] [blame] | 347 | llvm_unreachable("Translation units aren't directly serialized"); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 348 | } |
| 349 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 350 | void ASTDeclWriter::VisitNamedDecl(NamedDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 351 | VisitDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 352 | Record.AddDeclarationName(D->getDeclName()); |
Richard Smith | 2b56057 | 2015-02-07 03:11:11 +0000 | [diff] [blame] | 353 | Record.push_back(needsAnonymousDeclarationNumber(D) |
| 354 | ? Writer.getAnonymousDeclarationNumber(D) |
| 355 | : 0); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 356 | } |
| 357 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 358 | void ASTDeclWriter::VisitTypeDecl(TypeDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 359 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 360 | Record.AddSourceLocation(D->getLocStart()); |
| 361 | Record.AddTypeRef(QualType(D->getTypeForDecl(), 0)); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 362 | } |
| 363 | |
Douglas Gregor | 1f17906 | 2011-12-19 14:40:25 +0000 | [diff] [blame] | 364 | void ASTDeclWriter::VisitTypedefNameDecl(TypedefNameDecl *D) { |
Douglas Gregor | 05f1035 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 365 | VisitRedeclarable(D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 366 | VisitTypeDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 367 | Record.AddTypeSourceInfo(D->getTypeSourceInfo()); |
Enea Zaffanella | a86d88c | 2013-06-20 12:46:19 +0000 | [diff] [blame] | 368 | Record.push_back(D->isModed()); |
| 369 | if (D->isModed()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 370 | Record.AddTypeRef(D->getUnderlyingType()); |
Douglas Gregor | 1f17906 | 2011-12-19 14:40:25 +0000 | [diff] [blame] | 371 | } |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 372 | |
Douglas Gregor | 1f17906 | 2011-12-19 14:40:25 +0000 | [diff] [blame] | 373 | void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) { |
| 374 | VisitTypedefNameDecl(D); |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 375 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
| 376 | !D->hasAttrs() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 377 | !D->isImplicit() && |
Rafael Espindola | 8db352d | 2013-10-17 15:37:26 +0000 | [diff] [blame] | 378 | D->getFirstDecl() == D->getMostRecentDecl() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 379 | !D->isInvalidDecl() && |
Argyrios Kyrtzidis | a724500 | 2011-11-23 21:11:23 +0000 | [diff] [blame] | 380 | !D->isTopLevelDeclInObjCContainer() && |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 381 | !D->isModulePrivate() && |
Richard Smith | d08aeb6 | 2014-08-28 01:33:39 +0000 | [diff] [blame] | 382 | !needsAnonymousDeclarationNumber(D) && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 383 | D->getDeclName().getNameKind() == DeclarationName::Identifier) |
| 384 | AbbrevToUse = Writer.getDeclTypedefAbbrev(); |
| 385 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 386 | Code = serialization::DECL_TYPEDEF; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 387 | } |
| 388 | |
Richard Smith | dda56e4 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 389 | void ASTDeclWriter::VisitTypeAliasDecl(TypeAliasDecl *D) { |
Douglas Gregor | 1f17906 | 2011-12-19 14:40:25 +0000 | [diff] [blame] | 390 | VisitTypedefNameDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 391 | Record.AddDeclRef(D->getDescribedAliasTemplate()); |
Richard Smith | dda56e4 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 392 | Code = serialization::DECL_TYPEALIAS; |
| 393 | } |
| 394 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 395 | void ASTDeclWriter::VisitTagDecl(TagDecl *D) { |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 396 | VisitRedeclarable(D); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 397 | VisitTypeDecl(D); |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 398 | Record.push_back(D->getIdentifierNamespace()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 399 | Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding |
Richard Smith | 2c38164 | 2014-08-27 23:11:59 +0000 | [diff] [blame] | 400 | if (!isa<CXXRecordDecl>(D)) |
| 401 | Record.push_back(D->isCompleteDefinition()); |
Douglas Gregor | 5089c76 | 2010-02-12 17:40:34 +0000 | [diff] [blame] | 402 | Record.push_back(D->isEmbeddedInDeclarator()); |
Argyrios Kyrtzidis | 201d377 | 2011-09-30 22:11:31 +0000 | [diff] [blame] | 403 | Record.push_back(D->isFreeStanding()); |
David Blaikie | a8d23ce | 2013-07-14 01:07:41 +0000 | [diff] [blame] | 404 | Record.push_back(D->isCompleteDefinitionRequired()); |
Argyrios Kyrtzidis | d798c05 | 2016-07-15 18:11:33 +0000 | [diff] [blame] | 405 | Record.AddSourceRange(D->getBraceRange()); |
Richard Smith | 70d5850 | 2014-08-30 00:04:23 +0000 | [diff] [blame] | 406 | |
| 407 | if (D->hasExtInfo()) { |
| 408 | Record.push_back(1); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 409 | Record.AddQualifierInfo(*D->getExtInfo()); |
Richard Smith | 70d5850 | 2014-08-30 00:04:23 +0000 | [diff] [blame] | 410 | } else if (auto *TD = D->getTypedefNameForAnonDecl()) { |
| 411 | Record.push_back(2); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 412 | Record.AddDeclRef(TD); |
| 413 | Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo()); |
Richard Smith | 70d5850 | 2014-08-30 00:04:23 +0000 | [diff] [blame] | 414 | } else { |
| 415 | Record.push_back(0); |
| 416 | } |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 417 | } |
| 418 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 419 | void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 420 | VisitTagDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 421 | Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo()); |
Douglas Gregor | 0bf3140 | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 422 | if (!D->getIntegerTypeSourceInfo()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 423 | Record.AddTypeRef(D->getIntegerType()); |
| 424 | Record.AddTypeRef(D->getPromotionType()); |
John McCall | 9aa35be | 2010-05-06 08:49:23 +0000 | [diff] [blame] | 425 | Record.push_back(D->getNumPositiveBits()); |
| 426 | Record.push_back(D->getNumNegativeBits()); |
Douglas Gregor | 0bf3140 | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 427 | Record.push_back(D->isScoped()); |
Abramo Bagnara | 0e05e24 | 2010-12-03 18:54:17 +0000 | [diff] [blame] | 428 | Record.push_back(D->isScopedUsingClassTag()); |
Douglas Gregor | 0bf3140 | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 429 | Record.push_back(D->isFixed()); |
Richard Smith | 4b38ded | 2012-03-14 23:13:10 +0000 | [diff] [blame] | 430 | if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 431 | Record.AddDeclRef(MemberInfo->getInstantiatedFrom()); |
Richard Smith | 4b38ded | 2012-03-14 23:13:10 +0000 | [diff] [blame] | 432 | Record.push_back(MemberInfo->getTemplateSpecializationKind()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 433 | Record.AddSourceLocation(MemberInfo->getPointOfInstantiation()); |
Richard Smith | 4b38ded | 2012-03-14 23:13:10 +0000 | [diff] [blame] | 434 | } else { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 435 | Record.AddDeclRef(nullptr); |
Richard Smith | 4b38ded | 2012-03-14 23:13:10 +0000 | [diff] [blame] | 436 | } |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 437 | |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 438 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
| 439 | !D->hasAttrs() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 440 | !D->isImplicit() && |
| 441 | !D->isUsed(false) && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 442 | !D->hasExtInfo() && |
Richard Smith | 70d5850 | 2014-08-30 00:04:23 +0000 | [diff] [blame] | 443 | !D->getTypedefNameForAnonDecl() && |
Rafael Espindola | 8db352d | 2013-10-17 15:37:26 +0000 | [diff] [blame] | 444 | D->getFirstDecl() == D->getMostRecentDecl() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 445 | !D->isInvalidDecl() && |
| 446 | !D->isReferenced() && |
Argyrios Kyrtzidis | a724500 | 2011-11-23 21:11:23 +0000 | [diff] [blame] | 447 | !D->isTopLevelDeclInObjCContainer() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 448 | D->getAccess() == AS_none && |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 449 | !D->isModulePrivate() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 450 | !CXXRecordDecl::classofKind(D->getKind()) && |
| 451 | !D->getIntegerTypeSourceInfo() && |
Argyrios Kyrtzidis | ca370b0d | 2013-03-18 22:23:49 +0000 | [diff] [blame] | 452 | !D->getMemberSpecializationInfo() && |
Richard Smith | d08aeb6 | 2014-08-28 01:33:39 +0000 | [diff] [blame] | 453 | !needsAnonymousDeclarationNumber(D) && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 454 | D->getDeclName().getNameKind() == DeclarationName::Identifier) |
| 455 | AbbrevToUse = Writer.getDeclEnumAbbrev(); |
| 456 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 457 | Code = serialization::DECL_ENUM; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 458 | } |
| 459 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 460 | void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 461 | VisitTagDecl(D); |
| 462 | Record.push_back(D->hasFlexibleArrayMember()); |
| 463 | Record.push_back(D->isAnonymousStructOrUnion()); |
Fariborz Jahanian | 8e0d042 | 2009-07-08 16:37:44 +0000 | [diff] [blame] | 464 | Record.push_back(D->hasObjectMember()); |
Fariborz Jahanian | 7865220 | 2013-01-25 23:57:05 +0000 | [diff] [blame] | 465 | Record.push_back(D->hasVolatileMember()); |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 466 | |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 467 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
| 468 | !D->hasAttrs() && |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 469 | !D->isImplicit() && |
| 470 | !D->isUsed(false) && |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 471 | !D->hasExtInfo() && |
Richard Smith | 70d5850 | 2014-08-30 00:04:23 +0000 | [diff] [blame] | 472 | !D->getTypedefNameForAnonDecl() && |
Rafael Espindola | 8db352d | 2013-10-17 15:37:26 +0000 | [diff] [blame] | 473 | D->getFirstDecl() == D->getMostRecentDecl() && |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 474 | !D->isInvalidDecl() && |
| 475 | !D->isReferenced() && |
Argyrios Kyrtzidis | a724500 | 2011-11-23 21:11:23 +0000 | [diff] [blame] | 476 | !D->isTopLevelDeclInObjCContainer() && |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 477 | D->getAccess() == AS_none && |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 478 | !D->isModulePrivate() && |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 479 | !CXXRecordDecl::classofKind(D->getKind()) && |
Richard Smith | d08aeb6 | 2014-08-28 01:33:39 +0000 | [diff] [blame] | 480 | !needsAnonymousDeclarationNumber(D) && |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 481 | D->getDeclName().getNameKind() == DeclarationName::Identifier) |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 482 | AbbrevToUse = Writer.getDeclRecordAbbrev(); |
| 483 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 484 | Code = serialization::DECL_RECORD; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 485 | } |
| 486 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 487 | void ASTDeclWriter::VisitValueDecl(ValueDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 488 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 489 | Record.AddTypeRef(D->getType()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 490 | } |
| 491 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 492 | void ASTDeclWriter::VisitEnumConstantDecl(EnumConstantDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 493 | VisitValueDecl(D); |
| 494 | Record.push_back(D->getInitExpr()? 1 : 0); |
| 495 | if (D->getInitExpr()) |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 496 | Record.AddStmt(D->getInitExpr()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 497 | Record.AddAPSInt(D->getInitVal()); |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 498 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 499 | Code = serialization::DECL_ENUM_CONSTANT; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 500 | } |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 501 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 502 | void ASTDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 503 | VisitValueDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 504 | Record.AddSourceLocation(D->getInnerLocStart()); |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 505 | Record.push_back(D->hasExtInfo()); |
| 506 | if (D->hasExtInfo()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 507 | Record.AddQualifierInfo(*D->getExtInfo()); |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 508 | } |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 509 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 510 | void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 511 | VisitRedeclarable(D); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 512 | VisitDeclaratorDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 513 | Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName()); |
Argyrios Kyrtzidis | a95d019 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 514 | Record.push_back(D->getIdentifierNamespace()); |
Douglas Gregor | b258569 | 2012-01-04 17:13:46 +0000 | [diff] [blame] | 515 | |
| 516 | // FunctionDecl's body is handled last at ASTWriterDecl::Visit, |
| 517 | // after everything else is written. |
| 518 | |
Richard Smith | 72625c2 | 2015-02-06 23:20:21 +0000 | [diff] [blame] | 519 | Record.push_back((int)D->SClass); // FIXME: stable encoding |
Douglas Gregor | b258569 | 2012-01-04 17:13:46 +0000 | [diff] [blame] | 520 | Record.push_back(D->IsInline); |
Richard Smith | 72625c2 | 2015-02-06 23:20:21 +0000 | [diff] [blame] | 521 | Record.push_back(D->IsInlineSpecified); |
| 522 | Record.push_back(D->IsVirtualAsWritten); |
| 523 | Record.push_back(D->IsPure); |
| 524 | Record.push_back(D->HasInheritedPrototype); |
| 525 | Record.push_back(D->HasWrittenPrototype); |
| 526 | Record.push_back(D->IsDeleted); |
| 527 | Record.push_back(D->IsTrivial); |
| 528 | Record.push_back(D->IsDefaulted); |
| 529 | Record.push_back(D->IsExplicitlyDefaulted); |
| 530 | Record.push_back(D->HasImplicitReturnZero); |
| 531 | Record.push_back(D->IsConstexpr); |
Argyrios Kyrtzidis | 1eb71a1 | 2012-12-06 18:59:10 +0000 | [diff] [blame] | 532 | Record.push_back(D->HasSkippedBody); |
Richard Smith | 72625c2 | 2015-02-06 23:20:21 +0000 | [diff] [blame] | 533 | Record.push_back(D->IsLateTemplateParsed); |
Rafael Espindola | 3ae0005 | 2013-05-13 00:12:11 +0000 | [diff] [blame] | 534 | Record.push_back(D->getLinkageInternal()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 535 | Record.AddSourceLocation(D->getLocEnd()); |
Douglas Gregor | b258569 | 2012-01-04 17:13:46 +0000 | [diff] [blame] | 536 | |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 537 | Record.push_back(D->getTemplatedKind()); |
| 538 | switch (D->getTemplatedKind()) { |
| 539 | case FunctionDecl::TK_NonTemplate: |
| 540 | break; |
| 541 | case FunctionDecl::TK_FunctionTemplate: |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 542 | Record.AddDeclRef(D->getDescribedFunctionTemplate()); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 543 | break; |
| 544 | case FunctionDecl::TK_MemberSpecialization: { |
| 545 | MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo(); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 546 | Record.AddDeclRef(MemberInfo->getInstantiatedFrom()); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 547 | Record.push_back(MemberInfo->getTemplateSpecializationKind()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 548 | Record.AddSourceLocation(MemberInfo->getPointOfInstantiation()); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 549 | break; |
| 550 | } |
| 551 | case FunctionDecl::TK_FunctionTemplateSpecialization: { |
| 552 | FunctionTemplateSpecializationInfo * |
| 553 | FTSInfo = D->getTemplateSpecializationInfo(); |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 554 | |
| 555 | RegisterTemplateSpecialization(FTSInfo->getTemplate(), D); |
| 556 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 557 | Record.AddDeclRef(FTSInfo->getTemplate()); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 558 | Record.push_back(FTSInfo->getTemplateSpecializationKind()); |
| 559 | |
| 560 | // Template arguments. |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 561 | Record.AddTemplateArgumentList(FTSInfo->TemplateArguments); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 562 | |
| 563 | // Template args as written. |
Craig Topper | a13603a | 2014-05-22 05:54:18 +0000 | [diff] [blame] | 564 | Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 565 | if (FTSInfo->TemplateArgumentsAsWritten) { |
Argyrios Kyrtzidis | e9a2443 | 2011-09-22 20:07:09 +0000 | [diff] [blame] | 566 | Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs); |
| 567 | for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs; |
| 568 | i!=e; ++i) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 569 | Record.AddTemplateArgumentLoc( |
| 570 | (*FTSInfo->TemplateArgumentsAsWritten)[i]); |
| 571 | Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc); |
| 572 | Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 573 | } |
Argyrios Kyrtzidis | 927d8e0 | 2010-07-05 10:37:55 +0000 | [diff] [blame] | 574 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 575 | Record.AddSourceLocation(FTSInfo->getPointOfInstantiation()); |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 576 | |
| 577 | if (D->isCanonicalDecl()) { |
| 578 | // Write the template that contains the specializations set. We will |
| 579 | // add a FunctionTemplateSpecializationInfo to it when reading. |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 580 | Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl()); |
Argyrios Kyrtzidis | f24d569 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 581 | } |
Argyrios Kyrtzidis | dc9ca0a | 2010-06-25 16:24:51 +0000 | [diff] [blame] | 582 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 583 | } |
| 584 | case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { |
| 585 | DependentFunctionTemplateSpecializationInfo * |
| 586 | DFTSInfo = D->getDependentSpecializationInfo(); |
| 587 | |
| 588 | // Templates. |
| 589 | Record.push_back(DFTSInfo->getNumTemplates()); |
| 590 | for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 591 | Record.AddDeclRef(DFTSInfo->getTemplate(i)); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 592 | |
| 593 | // Templates args. |
| 594 | Record.push_back(DFTSInfo->getNumTemplateArgs()); |
| 595 | for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 596 | Record.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i)); |
| 597 | Record.AddSourceLocation(DFTSInfo->getLAngleLoc()); |
| 598 | Record.AddSourceLocation(DFTSInfo->getRAngleLoc()); |
Argyrios Kyrtzidis | dc9ca0a | 2010-06-25 16:24:51 +0000 | [diff] [blame] | 599 | break; |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 600 | } |
| 601 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 602 | |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 603 | Record.push_back(D->param_size()); |
David Majnemer | 59f7792 | 2016-06-24 04:05:48 +0000 | [diff] [blame] | 604 | for (auto P : D->parameters()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 605 | Record.AddDeclRef(P); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 606 | Code = serialization::DECL_FUNCTION; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 607 | } |
| 608 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 609 | void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 610 | VisitNamedDecl(D); |
| 611 | // FIXME: convert to LazyStmtPtr? |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 612 | // Unlike C/C++, method bodies will never be in header files. |
Craig Topper | a13603a | 2014-05-22 05:54:18 +0000 | [diff] [blame] | 613 | bool HasBodyStuff = D->getBody() != nullptr || |
| 614 | D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr; |
Argyrios Kyrtzidis | a860777 | 2010-08-09 10:54:37 +0000 | [diff] [blame] | 615 | Record.push_back(HasBodyStuff); |
| 616 | if (HasBodyStuff) { |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 617 | Record.AddStmt(D->getBody()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 618 | Record.AddDeclRef(D->getSelfDecl()); |
| 619 | Record.AddDeclRef(D->getCmdDecl()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 620 | } |
| 621 | Record.push_back(D->isInstanceMethod()); |
| 622 | Record.push_back(D->isVariadic()); |
Jordan Rose | d01e83a | 2012-10-10 16:42:25 +0000 | [diff] [blame] | 623 | Record.push_back(D->isPropertyAccessor()); |
Fariborz Jahanian | 6e7e8cc | 2010-07-22 18:24:20 +0000 | [diff] [blame] | 624 | Record.push_back(D->isDefined()); |
Argyrios Kyrtzidis | 08f96a9 | 2012-05-09 16:12:57 +0000 | [diff] [blame] | 625 | Record.push_back(D->IsOverriding); |
Argyrios Kyrtzidis | 1eb71a1 | 2012-12-06 18:59:10 +0000 | [diff] [blame] | 626 | Record.push_back(D->HasSkippedBody); |
Argyrios Kyrtzidis | db21596 | 2011-10-14 17:41:52 +0000 | [diff] [blame] | 627 | |
| 628 | Record.push_back(D->IsRedeclaration); |
| 629 | Record.push_back(D->HasRedeclaration); |
| 630 | if (D->HasRedeclaration) { |
| 631 | assert(Context.getObjCMethodRedeclaration(D)); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 632 | Record.AddDeclRef(Context.getObjCMethodRedeclaration(D)); |
Argyrios Kyrtzidis | db21596 | 2011-10-14 17:41:52 +0000 | [diff] [blame] | 633 | } |
| 634 | |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 635 | // FIXME: stable encoding for @required/@optional |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 636 | Record.push_back(D->getImplementationControl()); |
Douglas Gregor | 813a066 | 2015-06-19 18:14:38 +0000 | [diff] [blame] | 637 | // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 638 | Record.push_back(D->getObjCDeclQualifier()); |
Douglas Gregor | 3382372 | 2011-06-11 01:09:30 +0000 | [diff] [blame] | 639 | Record.push_back(D->hasRelatedResultType()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 640 | Record.AddTypeRef(D->getReturnType()); |
| 641 | Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo()); |
| 642 | Record.AddSourceLocation(D->getLocEnd()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 643 | Record.push_back(D->param_size()); |
David Majnemer | 59f7792 | 2016-06-24 04:05:48 +0000 | [diff] [blame] | 644 | for (const auto *P : D->parameters()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 645 | Record.AddDeclRef(P); |
Argyrios Kyrtzidis | b8c3aaf | 2011-10-03 06:37:04 +0000 | [diff] [blame] | 646 | |
| 647 | Record.push_back(D->SelLocsKind); |
| 648 | unsigned NumStoredSelLocs = D->getNumStoredSelLocs(); |
| 649 | SourceLocation *SelLocs = D->getStoredSelLocs(); |
| 650 | Record.push_back(NumStoredSelLocs); |
| 651 | for (unsigned i = 0; i != NumStoredSelLocs; ++i) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 652 | Record.AddSourceLocation(SelLocs[i]); |
Argyrios Kyrtzidis | b8c3aaf | 2011-10-03 06:37:04 +0000 | [diff] [blame] | 653 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 654 | Code = serialization::DECL_OBJC_METHOD; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 655 | } |
| 656 | |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 657 | void ASTDeclWriter::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) { |
| 658 | VisitTypedefNameDecl(D); |
Douglas Gregor | 1ac1b63 | 2015-07-07 03:58:54 +0000 | [diff] [blame] | 659 | Record.push_back(D->Variance); |
Douglas Gregor | e83b956 | 2015-07-07 03:57:53 +0000 | [diff] [blame] | 660 | Record.push_back(D->Index); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 661 | Record.AddSourceLocation(D->VarianceLoc); |
| 662 | Record.AddSourceLocation(D->ColonLoc); |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 663 | |
| 664 | Code = serialization::DECL_OBJC_TYPE_PARAM; |
| 665 | } |
| 666 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 667 | void ASTDeclWriter::VisitObjCContainerDecl(ObjCContainerDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 668 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 669 | Record.AddSourceLocation(D->getAtStartLoc()); |
| 670 | Record.AddSourceRange(D->getAtEndRange()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 671 | // Abstract class (no need to define a stable serialization::DECL code). |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 672 | } |
| 673 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 674 | void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { |
Douglas Gregor | 66b310c | 2011-12-15 18:03:09 +0000 | [diff] [blame] | 675 | VisitRedeclarable(D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 676 | VisitObjCContainerDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 677 | Record.AddTypeRef(QualType(D->getTypeForDecl(), 0)); |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 678 | AddObjCTypeParamList(D->TypeParamList); |
Ted Kremenek | 0ef508d | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 679 | |
Douglas Gregor | 3a5ae56 | 2012-01-15 18:17:48 +0000 | [diff] [blame] | 680 | Record.push_back(D->isThisDeclarationADefinition()); |
| 681 | if (D->isThisDeclarationADefinition()) { |
Douglas Gregor | c0ac7d6 | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 682 | // Write the DefinitionData |
| 683 | ObjCInterfaceDecl::DefinitionData &Data = D->data(); |
| 684 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 685 | Record.AddTypeSourceInfo(D->getSuperClassTInfo()); |
| 686 | Record.AddSourceLocation(D->getEndOfDefinitionLoc()); |
Argyrios Kyrtzidis | 9ed9e5f | 2013-12-03 21:11:30 +0000 | [diff] [blame] | 687 | Record.push_back(Data.HasDesignatedInitializers); |
Douglas Gregor | 1640832 | 2011-12-15 22:34:59 +0000 | [diff] [blame] | 688 | |
Douglas Gregor | c0ac7d6 | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 689 | // Write out the protocols that are directly referenced by the @interface. |
| 690 | Record.push_back(Data.ReferencedProtocols.size()); |
Aaron Ballman | a49c506 | 2014-03-13 20:29:09 +0000 | [diff] [blame] | 691 | for (const auto *P : D->protocols()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 692 | Record.AddDeclRef(P); |
Aaron Ballman | e937888 | 2014-03-13 20:34:24 +0000 | [diff] [blame] | 693 | for (const auto &PL : D->protocol_locs()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 694 | Record.AddSourceLocation(PL); |
Douglas Gregor | c0ac7d6 | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 695 | |
| 696 | // Write out the protocols that are transitively referenced. |
| 697 | Record.push_back(Data.AllReferencedProtocols.size()); |
| 698 | for (ObjCList<ObjCProtocolDecl>::iterator |
| 699 | P = Data.AllReferencedProtocols.begin(), |
| 700 | PEnd = Data.AllReferencedProtocols.end(); |
| 701 | P != PEnd; ++P) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 702 | Record.AddDeclRef(*P); |
Douglas Gregor | 048fbfa | 2013-01-16 23:00:23 +0000 | [diff] [blame] | 703 | |
Douglas Gregor | c0ac7d6 | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 704 | |
Douglas Gregor | 048fbfa | 2013-01-16 23:00:23 +0000 | [diff] [blame] | 705 | if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) { |
Douglas Gregor | 404cdde | 2012-01-27 01:47:08 +0000 | [diff] [blame] | 706 | // Ensure that we write out the set of categories for this class. |
| 707 | Writer.ObjCClassesWithCategories.insert(D); |
| 708 | |
| 709 | // Make sure that the categories get serialized. |
Douglas Gregor | 048fbfa | 2013-01-16 23:00:23 +0000 | [diff] [blame] | 710 | for (; Cat; Cat = Cat->getNextClassCategoryRaw()) |
Douglas Gregor | 404cdde | 2012-01-27 01:47:08 +0000 | [diff] [blame] | 711 | (void)Writer.GetDeclRef(Cat); |
| 712 | } |
Douglas Gregor | c0ac7d6 | 2011-12-15 05:27:12 +0000 | [diff] [blame] | 713 | } |
| 714 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 715 | Code = serialization::DECL_OBJC_INTERFACE; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 716 | } |
| 717 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 718 | void ASTDeclWriter::VisitObjCIvarDecl(ObjCIvarDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 719 | VisitFieldDecl(D); |
| 720 | // FIXME: stable encoding for @public/@private/@protected/@package |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 721 | Record.push_back(D->getAccessControl()); |
Fariborz Jahanian | aea8e1e | 2010-07-17 18:35:47 +0000 | [diff] [blame] | 722 | Record.push_back(D->getSynthesize()); |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 723 | |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 724 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
| 725 | !D->hasAttrs() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 726 | !D->isImplicit() && |
| 727 | !D->isUsed(false) && |
| 728 | !D->isInvalidDecl() && |
| 729 | !D->isReferenced() && |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 730 | !D->isModulePrivate() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 731 | !D->getBitWidth() && |
| 732 | !D->hasExtInfo() && |
| 733 | D->getDeclName()) |
| 734 | AbbrevToUse = Writer.getDeclObjCIvarAbbrev(); |
| 735 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 736 | Code = serialization::DECL_OBJC_IVAR; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 737 | } |
| 738 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 739 | void ASTDeclWriter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { |
Douglas Gregor | a715bff | 2012-01-01 19:51:50 +0000 | [diff] [blame] | 740 | VisitRedeclarable(D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 741 | VisitObjCContainerDecl(D); |
Douglas Gregor | e6e48b1 | 2012-01-01 19:29:29 +0000 | [diff] [blame] | 742 | |
Douglas Gregor | 3a5ae56 | 2012-01-15 18:17:48 +0000 | [diff] [blame] | 743 | Record.push_back(D->isThisDeclarationADefinition()); |
| 744 | if (D->isThisDeclarationADefinition()) { |
Douglas Gregor | e6e48b1 | 2012-01-01 19:29:29 +0000 | [diff] [blame] | 745 | Record.push_back(D->protocol_size()); |
Aaron Ballman | 0f6e64d | 2014-03-13 22:58:06 +0000 | [diff] [blame] | 746 | for (const auto *I : D->protocols()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 747 | Record.AddDeclRef(I); |
Aaron Ballman | a964ec1 | 2014-03-14 12:38:50 +0000 | [diff] [blame] | 748 | for (const auto &PL : D->protocol_locs()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 749 | Record.AddSourceLocation(PL); |
Douglas Gregor | e6e48b1 | 2012-01-01 19:29:29 +0000 | [diff] [blame] | 750 | } |
| 751 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 752 | Code = serialization::DECL_OBJC_PROTOCOL; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 753 | } |
| 754 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 755 | void ASTDeclWriter::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 756 | VisitFieldDecl(D); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 757 | Code = serialization::DECL_OBJC_AT_DEFS_FIELD; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 758 | } |
| 759 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 760 | void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 761 | VisitObjCContainerDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 762 | Record.AddSourceLocation(D->getCategoryNameLoc()); |
| 763 | Record.AddSourceLocation(D->getIvarLBraceLoc()); |
| 764 | Record.AddSourceLocation(D->getIvarRBraceLoc()); |
| 765 | Record.AddDeclRef(D->getClassInterface()); |
Douglas Gregor | 85f3f95 | 2015-07-07 03:57:15 +0000 | [diff] [blame] | 766 | AddObjCTypeParamList(D->TypeParamList); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 767 | Record.push_back(D->protocol_size()); |
Aaron Ballman | 19a4176 | 2014-03-14 12:55:57 +0000 | [diff] [blame] | 768 | for (const auto *I : D->protocols()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 769 | Record.AddDeclRef(I); |
Aaron Ballman | a73c857 | 2014-03-14 13:03:32 +0000 | [diff] [blame] | 770 | for (const auto &PL : D->protocol_locs()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 771 | Record.AddSourceLocation(PL); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 772 | Code = serialization::DECL_OBJC_CATEGORY; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 773 | } |
| 774 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 775 | void ASTDeclWriter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 776 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 777 | Record.AddDeclRef(D->getClassInterface()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 778 | Code = serialization::DECL_OBJC_COMPATIBLE_ALIAS; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 779 | } |
| 780 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 781 | void ASTDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 782 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 783 | Record.AddSourceLocation(D->getAtLoc()); |
| 784 | Record.AddSourceLocation(D->getLParenLoc()); |
| 785 | Record.AddTypeRef(D->getType()); |
| 786 | Record.AddTypeSourceInfo(D->getTypeSourceInfo()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 787 | // FIXME: stable encoding |
| 788 | Record.push_back((unsigned)D->getPropertyAttributes()); |
Fariborz Jahanian | 3bf0ded | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 789 | Record.push_back((unsigned)D->getPropertyAttributesAsWritten()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 790 | // FIXME: stable encoding |
| 791 | Record.push_back((unsigned)D->getPropertyImplementation()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 792 | Record.AddDeclarationName(D->getGetterName()); |
| 793 | Record.AddDeclarationName(D->getSetterName()); |
| 794 | Record.AddDeclRef(D->getGetterMethodDecl()); |
| 795 | Record.AddDeclRef(D->getSetterMethodDecl()); |
| 796 | Record.AddDeclRef(D->getPropertyIvarDecl()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 797 | Code = serialization::DECL_OBJC_PROPERTY; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 798 | } |
| 799 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 800 | void ASTDeclWriter::VisitObjCImplDecl(ObjCImplDecl *D) { |
Argyrios Kyrtzidis | 067c407 | 2009-07-27 19:04:32 +0000 | [diff] [blame] | 801 | VisitObjCContainerDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 802 | Record.AddDeclRef(D->getClassInterface()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 803 | // Abstract class (no need to define a stable serialization::DECL code). |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 804 | } |
| 805 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 806 | void ASTDeclWriter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 807 | VisitObjCImplDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 808 | Record.AddIdentifierRef(D->getIdentifier()); |
| 809 | Record.AddSourceLocation(D->getCategoryNameLoc()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 810 | Code = serialization::DECL_OBJC_CATEGORY_IMPL; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 811 | } |
| 812 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 813 | void ASTDeclWriter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 814 | VisitObjCImplDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 815 | Record.AddDeclRef(D->getSuperClass()); |
| 816 | Record.AddSourceLocation(D->getSuperClassLoc()); |
| 817 | Record.AddSourceLocation(D->getIvarLBraceLoc()); |
| 818 | Record.AddSourceLocation(D->getIvarRBraceLoc()); |
John McCall | 0d54a17 | 2012-10-17 04:53:31 +0000 | [diff] [blame] | 819 | Record.push_back(D->hasNonZeroConstructors()); |
| 820 | Record.push_back(D->hasDestructors()); |
Richard Smith | c2bb818 | 2015-03-24 06:36:48 +0000 | [diff] [blame] | 821 | Record.push_back(D->NumIvarInitializers); |
| 822 | if (D->NumIvarInitializers) |
Richard Smith | aa165cf | 2016-04-13 21:57:08 +0000 | [diff] [blame] | 823 | Record.AddCXXCtorInitializers( |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 824 | llvm::makeArrayRef(D->init_begin(), D->init_end())); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 825 | Code = serialization::DECL_OBJC_IMPLEMENTATION; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 826 | } |
| 827 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 828 | void ASTDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 829 | VisitDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 830 | Record.AddSourceLocation(D->getLocStart()); |
| 831 | Record.AddDeclRef(D->getPropertyDecl()); |
| 832 | Record.AddDeclRef(D->getPropertyIvarDecl()); |
| 833 | Record.AddSourceLocation(D->getPropertyIvarDeclLoc()); |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 834 | Record.AddStmt(D->getGetterCXXConstructor()); |
| 835 | Record.AddStmt(D->getSetterCXXAssignment()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 836 | Code = serialization::DECL_OBJC_PROPERTY_IMPL; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 837 | } |
| 838 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 839 | void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) { |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 840 | VisitDeclaratorDecl(D); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 841 | Record.push_back(D->isMutable()); |
John McCall | c90c149 | 2014-10-10 18:44:34 +0000 | [diff] [blame] | 842 | if (D->InitStorage.getInt() == FieldDecl::ISK_BitWidthOrNothing && |
| 843 | D->InitStorage.getPointer() == nullptr) { |
| 844 | Record.push_back(0); |
| 845 | } else if (D->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) { |
| 846 | Record.push_back(D->InitStorage.getInt() + 1); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 847 | Record.AddTypeRef( |
| 848 | QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0)); |
Richard Smith | 2b01318 | 2012-06-10 03:12:00 +0000 | [diff] [blame] | 849 | } else { |
John McCall | c90c149 | 2014-10-10 18:44:34 +0000 | [diff] [blame] | 850 | Record.push_back(D->InitStorage.getInt() + 1); |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 851 | Record.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer())); |
Richard Smith | 2b01318 | 2012-06-10 03:12:00 +0000 | [diff] [blame] | 852 | } |
Argyrios Kyrtzidis | 6685e8a | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 853 | if (!D->getDeclName()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 854 | Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D)); |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 855 | |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 856 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
| 857 | !D->hasAttrs() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 858 | !D->isImplicit() && |
| 859 | !D->isUsed(false) && |
| 860 | !D->isInvalidDecl() && |
| 861 | !D->isReferenced() && |
Argyrios Kyrtzidis | a724500 | 2011-11-23 21:11:23 +0000 | [diff] [blame] | 862 | !D->isTopLevelDeclInObjCContainer() && |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 863 | !D->isModulePrivate() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 864 | !D->getBitWidth() && |
Richard Smith | 938f40b | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 865 | !D->hasInClassInitializer() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 866 | !D->hasExtInfo() && |
| 867 | !ObjCIvarDecl::classofKind(D->getKind()) && |
| 868 | !ObjCAtDefsFieldDecl::classofKind(D->getKind()) && |
| 869 | D->getDeclName()) |
| 870 | AbbrevToUse = Writer.getDeclFieldAbbrev(); |
| 871 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 872 | Code = serialization::DECL_FIELD; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 873 | } |
| 874 | |
John McCall | 5e77d76 | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 875 | void ASTDeclWriter::VisitMSPropertyDecl(MSPropertyDecl *D) { |
| 876 | VisitDeclaratorDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 877 | Record.AddIdentifierRef(D->getGetterId()); |
| 878 | Record.AddIdentifierRef(D->getSetterId()); |
John McCall | 5e77d76 | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 879 | Code = serialization::DECL_MS_PROPERTY; |
| 880 | } |
| 881 | |
Francois Pichet | 783dd6e | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 882 | void ASTDeclWriter::VisitIndirectFieldDecl(IndirectFieldDecl *D) { |
| 883 | VisitValueDecl(D); |
| 884 | Record.push_back(D->getChainingSize()); |
| 885 | |
Aaron Ballman | 29c9460 | 2014-03-07 18:36:15 +0000 | [diff] [blame] | 886 | for (const auto *P : D->chain()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 887 | Record.AddDeclRef(P); |
Francois Pichet | 783dd6e | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 888 | Code = serialization::DECL_INDIRECTFIELD; |
| 889 | } |
| 890 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 891 | void ASTDeclWriter::VisitVarDecl(VarDecl *D) { |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 892 | VisitRedeclarable(D); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 893 | VisitDeclaratorDecl(D); |
Rafael Espindola | 6ae7e50 | 2013-04-03 19:27:57 +0000 | [diff] [blame] | 894 | Record.push_back(D->getStorageClass()); |
Enea Zaffanella | acb8ecd | 2013-05-04 08:27:07 +0000 | [diff] [blame] | 895 | Record.push_back(D->getTSCSpec()); |
Sebastian Redl | a935179 | 2012-02-11 23:51:47 +0000 | [diff] [blame] | 896 | Record.push_back(D->getInitStyle()); |
David Majnemer | fa7bc78 | 2015-05-19 00:57:16 +0000 | [diff] [blame] | 897 | if (!isa<ParmVarDecl>(D)) { |
Richard Smith | edbc6e9 | 2016-10-14 21:41:24 +0000 | [diff] [blame] | 898 | Record.push_back(D->isThisDeclarationADemotedDefinition()); |
David Majnemer | fa7bc78 | 2015-05-19 00:57:16 +0000 | [diff] [blame] | 899 | Record.push_back(D->isExceptionVariable()); |
| 900 | Record.push_back(D->isNRVOVariable()); |
| 901 | Record.push_back(D->isCXXForRangeDecl()); |
| 902 | Record.push_back(D->isARCPseudoStrong()); |
Richard Smith | 62f19e7 | 2016-06-25 00:15:56 +0000 | [diff] [blame] | 903 | Record.push_back(D->isInline()); |
| 904 | Record.push_back(D->isInlineSpecified()); |
David Majnemer | fa7bc78 | 2015-05-19 00:57:16 +0000 | [diff] [blame] | 905 | Record.push_back(D->isConstexpr()); |
| 906 | Record.push_back(D->isInitCapture()); |
| 907 | Record.push_back(D->isPreviousDeclInSameBlockScope()); |
| 908 | } |
Rafael Espindola | 3ae0005 | 2013-05-13 00:12:11 +0000 | [diff] [blame] | 909 | Record.push_back(D->getLinkageInternal()); |
Douglas Gregor | 12cda63 | 2012-09-20 23:43:29 +0000 | [diff] [blame] | 910 | |
Richard Smith | d0b4dd6 | 2011-12-19 06:19:21 +0000 | [diff] [blame] | 911 | if (D->getInit()) { |
| 912 | Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2)); |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 913 | Record.AddStmt(D->getInit()); |
Richard Smith | d0b4dd6 | 2011-12-19 06:19:21 +0000 | [diff] [blame] | 914 | } else { |
| 915 | Record.push_back(0); |
| 916 | } |
Larisse Voufo | d8dd97c | 2013-08-14 03:09:19 +0000 | [diff] [blame] | 917 | |
| 918 | enum { |
| 919 | VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization |
| 920 | }; |
| 921 | if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) { |
| 922 | Record.push_back(VarTemplate); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 923 | Record.AddDeclRef(TemplD); |
Larisse Voufo | d8dd97c | 2013-08-14 03:09:19 +0000 | [diff] [blame] | 924 | } else if (MemberSpecializationInfo *SpecInfo |
| 925 | = D->getMemberSpecializationInfo()) { |
| 926 | Record.push_back(StaticDataMemberSpecialization); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 927 | Record.AddDeclRef(SpecInfo->getInstantiatedFrom()); |
Argyrios Kyrtzidis | cdb8b3f | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 928 | Record.push_back(SpecInfo->getTemplateSpecializationKind()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 929 | Record.AddSourceLocation(SpecInfo->getPointOfInstantiation()); |
Larisse Voufo | d8dd97c | 2013-08-14 03:09:19 +0000 | [diff] [blame] | 930 | } else { |
| 931 | Record.push_back(VarNotTemplate); |
Argyrios Kyrtzidis | cdb8b3f | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 932 | } |
| 933 | |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 934 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
| 935 | !D->hasAttrs() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 936 | !D->isImplicit() && |
| 937 | !D->isUsed(false) && |
| 938 | !D->isInvalidDecl() && |
| 939 | !D->isReferenced() && |
Argyrios Kyrtzidis | a724500 | 2011-11-23 21:11:23 +0000 | [diff] [blame] | 940 | !D->isTopLevelDeclInObjCContainer() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 941 | D->getAccess() == AS_none && |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 942 | !D->isModulePrivate() && |
Richard Smith | d08aeb6 | 2014-08-28 01:33:39 +0000 | [diff] [blame] | 943 | !needsAnonymousDeclarationNumber(D) && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 944 | D->getDeclName().getNameKind() == DeclarationName::Identifier && |
| 945 | !D->hasExtInfo() && |
Rafael Espindola | 8db352d | 2013-10-17 15:37:26 +0000 | [diff] [blame] | 946 | D->getFirstDecl() == D->getMostRecentDecl() && |
Richard Smith | 7b76d81 | 2016-08-12 02:21:25 +0000 | [diff] [blame] | 947 | D->getKind() == Decl::Var && |
Richard Smith | 62f19e7 | 2016-06-25 00:15:56 +0000 | [diff] [blame] | 948 | !D->isInline() && |
Douglas Gregor | 12cda63 | 2012-09-20 23:43:29 +0000 | [diff] [blame] | 949 | !D->isConstexpr() && |
Richard Smith | bb13c9a | 2013-09-28 04:02:39 +0000 | [diff] [blame] | 950 | !D->isInitCapture() && |
Richard Smith | 1c34fb7 | 2013-08-13 18:18:50 +0000 | [diff] [blame] | 951 | !D->isPreviousDeclInSameBlockScope() && |
Larisse Voufo | d8dd97c | 2013-08-14 03:09:19 +0000 | [diff] [blame] | 952 | !D->getMemberSpecializationInfo()) |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 953 | AbbrevToUse = Writer.getDeclVarAbbrev(); |
| 954 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 955 | Code = serialization::DECL_VAR; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 956 | } |
| 957 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 958 | void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 959 | VisitVarDecl(D); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 960 | Code = serialization::DECL_IMPLICIT_PARAM; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 961 | } |
| 962 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 963 | void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 964 | VisitVarDecl(D); |
John McCall | 8249083 | 2011-05-02 00:30:12 +0000 | [diff] [blame] | 965 | Record.push_back(D->isObjCMethodParameter()); |
John McCall | 8fb0d9d | 2011-05-01 22:35:37 +0000 | [diff] [blame] | 966 | Record.push_back(D->getFunctionScopeDepth()); |
| 967 | Record.push_back(D->getFunctionScopeIndex()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 968 | Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding |
John McCall | 6a014d5 | 2011-03-09 04:22:44 +0000 | [diff] [blame] | 969 | Record.push_back(D->isKNRPromoted()); |
John McCall | f3cd665 | 2010-03-12 18:31:32 +0000 | [diff] [blame] | 970 | Record.push_back(D->hasInheritedDefaultArg()); |
Argyrios Kyrtzidis | ccde6a0 | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 971 | Record.push_back(D->hasUninstantiatedDefaultArg()); |
| 972 | if (D->hasUninstantiatedDefaultArg()) |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 973 | Record.AddStmt(D->getUninstantiatedDefaultArg()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 974 | Code = serialization::DECL_PARM_VAR; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 975 | |
John McCall | d463132 | 2011-06-17 06:42:21 +0000 | [diff] [blame] | 976 | assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl |
| 977 | |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 978 | // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here |
| 979 | // we dynamically check for the properties that we optimize for, but don't |
| 980 | // know are true of all PARM_VAR_DECLs. |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 981 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
| 982 | !D->hasAttrs() && |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 983 | !D->hasExtInfo() && |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 984 | !D->isImplicit() && |
Douglas Gregor | ebada077 | 2010-06-17 23:14:26 +0000 | [diff] [blame] | 985 | !D->isUsed(false) && |
Argyrios Kyrtzidis | b7d1ca2 | 2012-03-09 21:09:04 +0000 | [diff] [blame] | 986 | !D->isInvalidDecl() && |
Eli Friedman | c09e055 | 2012-01-13 23:41:25 +0000 | [diff] [blame] | 987 | !D->isReferenced() && |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 988 | D->getAccess() == AS_none && |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 989 | !D->isModulePrivate() && |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 990 | D->getStorageClass() == 0 && |
Sebastian Redl | a935179 | 2012-02-11 23:51:47 +0000 | [diff] [blame] | 991 | D->getInitStyle() == VarDecl::CInit && // Can params have anything else? |
John McCall | 8249083 | 2011-05-02 00:30:12 +0000 | [diff] [blame] | 992 | D->getFunctionScopeDepth() == 0 && |
John McCall | f3cd665 | 2010-03-12 18:31:32 +0000 | [diff] [blame] | 993 | D->getObjCDeclQualifier() == 0 && |
John McCall | 6a014d5 | 2011-03-09 04:22:44 +0000 | [diff] [blame] | 994 | !D->isKNRPromoted() && |
Chris Lattner | e2437f4 | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 995 | !D->hasInheritedDefaultArg() && |
Craig Topper | a13603a | 2014-05-22 05:54:18 +0000 | [diff] [blame] | 996 | D->getInit() == nullptr && |
Argyrios Kyrtzidis | ccde6a0 | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 997 | !D->hasUninstantiatedDefaultArg()) // No default expr. |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 998 | AbbrevToUse = Writer.getDeclParmVarAbbrev(); |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 999 | |
| 1000 | // Check things we know are true of *every* PARM_VAR_DECL, which is more than |
| 1001 | // just us assuming it. |
Enea Zaffanella | acb8ecd | 2013-05-04 08:27:07 +0000 | [diff] [blame] | 1002 | assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS"); |
Richard Smith | edbc6e9 | 2016-10-14 21:41:24 +0000 | [diff] [blame] | 1003 | assert(!D->isThisDeclarationADemotedDefinition() |
| 1004 | && "PARM_VAR_DECL can't be demoted definition."); |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1005 | assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private"); |
Douglas Gregor | 3f324d56 | 2010-05-03 18:51:14 +0000 | [diff] [blame] | 1006 | assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var"); |
Craig Topper | a13603a | 2014-05-22 05:54:18 +0000 | [diff] [blame] | 1007 | assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl"); |
Argyrios Kyrtzidis | cdb8b3f | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 1008 | assert(!D->isStaticDataMember() && |
| 1009 | "PARM_VAR_DECL can't be static data member"); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
Richard Smith | 7b76d81 | 2016-08-12 02:21:25 +0000 | [diff] [blame] | 1012 | void ASTDeclWriter::VisitDecompositionDecl(DecompositionDecl *D) { |
| 1013 | // Record the number of bindings first to simplify deserialization. |
| 1014 | Record.push_back(D->bindings().size()); |
| 1015 | |
| 1016 | VisitVarDecl(D); |
| 1017 | for (auto *B : D->bindings()) |
| 1018 | Record.AddDeclRef(B); |
| 1019 | Code = serialization::DECL_DECOMPOSITION; |
| 1020 | } |
| 1021 | |
| 1022 | void ASTDeclWriter::VisitBindingDecl(BindingDecl *D) { |
| 1023 | VisitValueDecl(D); |
| 1024 | Record.AddStmt(D->getBinding()); |
| 1025 | Code = serialization::DECL_BINDING; |
| 1026 | } |
| 1027 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1028 | void ASTDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1029 | VisitDecl(D); |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 1030 | Record.AddStmt(D->getAsmString()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1031 | Record.AddSourceLocation(D->getRParenLoc()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1032 | Code = serialization::DECL_FILE_SCOPE_ASM; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1033 | } |
| 1034 | |
Michael Han | 8432435 | 2013-02-22 17:15:32 +0000 | [diff] [blame] | 1035 | void ASTDeclWriter::VisitEmptyDecl(EmptyDecl *D) { |
| 1036 | VisitDecl(D); |
| 1037 | Code = serialization::DECL_EMPTY; |
| 1038 | } |
| 1039 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1040 | void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) { |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1041 | VisitDecl(D); |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 1042 | Record.AddStmt(D->getBody()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1043 | Record.AddTypeSourceInfo(D->getSignatureAsWritten()); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1044 | Record.push_back(D->param_size()); |
David Majnemer | a3debed | 2016-06-24 05:33:44 +0000 | [diff] [blame] | 1045 | for (ParmVarDecl *P : D->parameters()) |
| 1046 | Record.AddDeclRef(P); |
John McCall | cf6ce28 | 2012-04-13 17:33:29 +0000 | [diff] [blame] | 1047 | Record.push_back(D->isVariadic()); |
| 1048 | Record.push_back(D->blockMissingReturnType()); |
| 1049 | Record.push_back(D->isConversionFromLambda()); |
John McCall | c63de66 | 2011-02-02 13:00:07 +0000 | [diff] [blame] | 1050 | Record.push_back(D->capturesCXXThis()); |
John McCall | 351762c | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 1051 | Record.push_back(D->getNumCaptures()); |
Aaron Ballman | 9371dd2 | 2014-03-14 18:34:04 +0000 | [diff] [blame] | 1052 | for (const auto &capture : D->captures()) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1053 | Record.AddDeclRef(capture.getVariable()); |
John McCall | 351762c | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 1054 | |
| 1055 | unsigned flags = 0; |
| 1056 | if (capture.isByRef()) flags |= 1; |
| 1057 | if (capture.isNested()) flags |= 2; |
| 1058 | if (capture.hasCopyExpr()) flags |= 4; |
| 1059 | Record.push_back(flags); |
| 1060 | |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 1061 | if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr()); |
John McCall | 351762c | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 1062 | } |
John McCall | c63de66 | 2011-02-02 13:00:07 +0000 | [diff] [blame] | 1063 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1064 | Code = serialization::DECL_BLOCK; |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1065 | } |
| 1066 | |
Ben Langmuir | ce914fc | 2013-05-03 19:20:19 +0000 | [diff] [blame] | 1067 | void ASTDeclWriter::VisitCapturedDecl(CapturedDecl *CD) { |
| 1068 | Record.push_back(CD->getNumParams()); |
| 1069 | VisitDecl(CD); |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 1070 | Record.push_back(CD->getContextParamPosition()); |
| 1071 | Record.push_back(CD->isNothrow() ? 1 : 0); |
Ben Langmuir | ce914fc | 2013-05-03 19:20:19 +0000 | [diff] [blame] | 1072 | // Body is stored by VisitCapturedStmt. |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 1073 | for (unsigned I = 0; I < CD->getNumParams(); ++I) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1074 | Record.AddDeclRef(CD->getParam(I)); |
Ben Langmuir | ce914fc | 2013-05-03 19:20:19 +0000 | [diff] [blame] | 1075 | Code = serialization::DECL_CAPTURED; |
Tareq A. Siraj | 6dfa25a | 2013-04-16 19:37:38 +0000 | [diff] [blame] | 1076 | } |
| 1077 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1078 | void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1079 | VisitDecl(D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1080 | Record.push_back(D->getLanguage()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1081 | Record.AddSourceLocation(D->getExternLoc()); |
| 1082 | Record.AddSourceLocation(D->getRBraceLoc()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1083 | Code = serialization::DECL_LINKAGE_SPEC; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1084 | } |
| 1085 | |
Richard Smith | 8df390f | 2016-09-08 23:14:54 +0000 | [diff] [blame] | 1086 | void ASTDeclWriter::VisitExportDecl(ExportDecl *D) { |
| 1087 | VisitDecl(D); |
| 1088 | Record.AddSourceLocation(D->getRBraceLoc()); |
| 1089 | Code = serialization::DECL_EXPORT; |
| 1090 | } |
| 1091 | |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 1092 | void ASTDeclWriter::VisitLabelDecl(LabelDecl *D) { |
| 1093 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1094 | Record.AddSourceLocation(D->getLocStart()); |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 1095 | Code = serialization::DECL_LABEL; |
| 1096 | } |
| 1097 | |
| 1098 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1099 | void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) { |
Douglas Gregor | e57e752 | 2012-01-07 09:11:48 +0000 | [diff] [blame] | 1100 | VisitRedeclarable(D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1101 | VisitNamedDecl(D); |
Douglas Gregor | 44e5c1f | 2010-10-05 20:41:58 +0000 | [diff] [blame] | 1102 | Record.push_back(D->isInline()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1103 | Record.AddSourceLocation(D->getLocStart()); |
| 1104 | Record.AddSourceLocation(D->getRBraceLoc()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1105 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1106 | if (D->isOriginalNamespace()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1107 | Record.AddDeclRef(D->getAnonymousNamespace()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1108 | Code = serialization::DECL_NAMESPACE; |
Sebastian Redl | f03cdc5 | 2010-08-05 21:22:19 +0000 | [diff] [blame] | 1109 | |
Douglas Gregor | e57e752 | 2012-01-07 09:11:48 +0000 | [diff] [blame] | 1110 | if (Writer.hasChain() && D->isAnonymousNamespace() && |
Douglas Gregor | ec9fd13 | 2012-01-14 16:38:05 +0000 | [diff] [blame] | 1111 | D == D->getMostRecentDecl()) { |
Sebastian Redl | 010288f | 2011-04-24 16:28:21 +0000 | [diff] [blame] | 1112 | // This is a most recent reopening of the anonymous namespace. If its parent |
| 1113 | // is in a previous PCH (or is the TU), mark that parent for update, because |
| 1114 | // the original namespace always points to the latest re-opening of its |
| 1115 | // anonymous namespace. |
| 1116 | Decl *Parent = cast<Decl>( |
| 1117 | D->getParent()->getRedeclContext()->getPrimaryContext()); |
Douglas Gregor | b3722e2 | 2011-09-09 23:01:35 +0000 | [diff] [blame] | 1118 | if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) { |
Richard Smith | 6ef4293 | 2014-03-20 21:02:00 +0000 | [diff] [blame] | 1119 | Writer.DeclUpdates[Parent].push_back( |
Aaron Ballman | 4f45b71 | 2014-03-21 15:22:56 +0000 | [diff] [blame] | 1120 | ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D)); |
Sebastian Redl | fa1f370 | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 1121 | } |
| 1122 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1123 | } |
| 1124 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1125 | void ASTDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |
Richard Smith | f463436 | 2014-09-03 23:11:22 +0000 | [diff] [blame] | 1126 | VisitRedeclarable(D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1127 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1128 | Record.AddSourceLocation(D->getNamespaceLoc()); |
| 1129 | Record.AddSourceLocation(D->getTargetNameLoc()); |
| 1130 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
| 1131 | Record.AddDeclRef(D->getNamespace()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1132 | Code = serialization::DECL_NAMESPACE_ALIAS; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1133 | } |
| 1134 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1135 | void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1136 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1137 | Record.AddSourceLocation(D->getUsingLoc()); |
| 1138 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
| 1139 | Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName()); |
| 1140 | Record.AddDeclRef(D->FirstUsingShadow.getPointer()); |
Enea Zaffanella | e05a3cf | 2013-07-22 10:54:09 +0000 | [diff] [blame] | 1141 | Record.push_back(D->hasTypename()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1142 | Record.AddDeclRef(Context.getInstantiatedFromUsingDecl(D)); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1143 | Code = serialization::DECL_USING; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1144 | } |
| 1145 | |
Richard Smith | 151c456 | 2016-12-20 21:35:28 +0000 | [diff] [blame^] | 1146 | void ASTDeclWriter::VisitUsingPackDecl(UsingPackDecl *D) { |
| 1147 | Record.push_back(D->NumExpansions); |
| 1148 | VisitNamedDecl(D); |
| 1149 | Record.AddDeclRef(D->getInstantiatedFromUsingDecl()); |
| 1150 | for (auto *E : D->expansions()) |
| 1151 | Record.AddDeclRef(E); |
| 1152 | Code = serialization::DECL_USING_PACK; |
| 1153 | } |
| 1154 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1155 | void ASTDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) { |
Richard Smith | fd8634a | 2013-10-23 02:17:46 +0000 | [diff] [blame] | 1156 | VisitRedeclarable(D); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1157 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1158 | Record.AddDeclRef(D->getTargetDecl()); |
| 1159 | Record.AddDeclRef(D->UsingOrNextShadow); |
| 1160 | Record.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D)); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1161 | Code = serialization::DECL_USING_SHADOW; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1162 | } |
| 1163 | |
Richard Smith | 5179eb7 | 2016-06-28 19:03:57 +0000 | [diff] [blame] | 1164 | void ASTDeclWriter::VisitConstructorUsingShadowDecl( |
| 1165 | ConstructorUsingShadowDecl *D) { |
| 1166 | VisitUsingShadowDecl(D); |
| 1167 | Record.AddDeclRef(D->NominatedBaseClassShadowDecl); |
| 1168 | Record.AddDeclRef(D->ConstructedBaseClassShadowDecl); |
| 1169 | Record.push_back(D->IsVirtual); |
| 1170 | Code = serialization::DECL_CONSTRUCTOR_USING_SHADOW; |
| 1171 | } |
| 1172 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1173 | void ASTDeclWriter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1174 | VisitNamedDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1175 | Record.AddSourceLocation(D->getUsingLoc()); |
| 1176 | Record.AddSourceLocation(D->getNamespaceKeyLocation()); |
| 1177 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
| 1178 | Record.AddDeclRef(D->getNominatedNamespace()); |
| 1179 | Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor())); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1180 | Code = serialization::DECL_USING_DIRECTIVE; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1181 | } |
| 1182 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1183 | void ASTDeclWriter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1184 | VisitValueDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1185 | Record.AddSourceLocation(D->getUsingLoc()); |
| 1186 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
| 1187 | Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName()); |
Richard Smith | 151c456 | 2016-12-20 21:35:28 +0000 | [diff] [blame^] | 1188 | Record.AddSourceLocation(D->getEllipsisLoc()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1189 | Code = serialization::DECL_UNRESOLVED_USING_VALUE; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1190 | } |
| 1191 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1192 | void ASTDeclWriter::VisitUnresolvedUsingTypenameDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1193 | UnresolvedUsingTypenameDecl *D) { |
| 1194 | VisitTypeDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1195 | Record.AddSourceLocation(D->getTypenameLoc()); |
| 1196 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
Richard Smith | 151c456 | 2016-12-20 21:35:28 +0000 | [diff] [blame^] | 1197 | Record.AddSourceLocation(D->getEllipsisLoc()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1198 | Code = serialization::DECL_UNRESOLVED_USING_TYPENAME; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1199 | } |
| 1200 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1201 | void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1202 | VisitRecordDecl(D); |
Argyrios Kyrtzidis | 2c2167a | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 1203 | |
Argyrios Kyrtzidis | 106caf92 | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 1204 | enum { |
| 1205 | CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization |
| 1206 | }; |
| 1207 | if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) { |
| 1208 | Record.push_back(CXXRecTemplate); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1209 | Record.AddDeclRef(TemplD); |
Argyrios Kyrtzidis | 106caf92 | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 1210 | } else if (MemberSpecializationInfo *MSInfo |
| 1211 | = D->getMemberSpecializationInfo()) { |
| 1212 | Record.push_back(CXXRecMemberSpecialization); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1213 | Record.AddDeclRef(MSInfo->getInstantiatedFrom()); |
Argyrios Kyrtzidis | 106caf92 | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 1214 | Record.push_back(MSInfo->getTemplateSpecializationKind()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1215 | Record.AddSourceLocation(MSInfo->getPointOfInstantiation()); |
Argyrios Kyrtzidis | 106caf92 | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 1216 | } else { |
| 1217 | Record.push_back(CXXRecNotTemplate); |
| 1218 | } |
| 1219 | |
Richard Smith | cd45dbc | 2014-04-19 03:48:30 +0000 | [diff] [blame] | 1220 | Record.push_back(D->isThisDeclarationADefinition()); |
| 1221 | if (D->isThisDeclarationADefinition()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1222 | Record.AddCXXDefinitionData(D); |
Richard Smith | cd45dbc | 2014-04-19 03:48:30 +0000 | [diff] [blame] | 1223 | |
John McCall | 6bd2a89 | 2013-01-25 22:31:03 +0000 | [diff] [blame] | 1224 | // Store (what we currently believe to be) the key function to avoid |
| 1225 | // deserializing every method so we can compute it. |
John McCall | f937c02 | 2011-10-07 06:10:15 +0000 | [diff] [blame] | 1226 | if (D->IsCompleteDefinition) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1227 | Record.AddDeclRef(Context.getCurrentKeyFunction(D)); |
Argyrios Kyrtzidis | 6843141 | 2010-10-14 20:14:38 +0000 | [diff] [blame] | 1228 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1229 | Code = serialization::DECL_CXX_RECORD; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1230 | } |
| 1231 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1232 | void ASTDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1233 | VisitFunctionDecl(D); |
Argyrios Kyrtzidis | 3b1a779 | 2012-10-12 05:31:40 +0000 | [diff] [blame] | 1234 | if (D->isCanonicalDecl()) { |
| 1235 | Record.push_back(D->size_overridden_methods()); |
| 1236 | for (CXXMethodDecl::method_iterator |
| 1237 | I = D->begin_overridden_methods(), E = D->end_overridden_methods(); |
| 1238 | I != E; ++I) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1239 | Record.AddDeclRef(*I); |
Argyrios Kyrtzidis | 3b1a779 | 2012-10-12 05:31:40 +0000 | [diff] [blame] | 1240 | } else { |
| 1241 | // We only need to record overridden methods once for the canonical decl. |
| 1242 | Record.push_back(0); |
| 1243 | } |
Richard Smith | 01b2cb4 | 2014-07-26 06:37:51 +0000 | [diff] [blame] | 1244 | |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 1245 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
| 1246 | D->getFirstDecl() == D->getMostRecentDecl() && |
Richard Smith | 01b2cb4 | 2014-07-26 06:37:51 +0000 | [diff] [blame] | 1247 | !D->isInvalidDecl() && |
| 1248 | !D->hasAttrs() && |
| 1249 | !D->isTopLevelDeclInObjCContainer() && |
| 1250 | D->getDeclName().getNameKind() == DeclarationName::Identifier && |
| 1251 | !D->hasExtInfo() && |
| 1252 | !D->hasInheritedPrototype() && |
| 1253 | D->hasWrittenPrototype()) |
| 1254 | AbbrevToUse = Writer.getDeclCXXMethodAbbrev(); |
| 1255 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1256 | Code = serialization::DECL_CXX_METHOD; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1259 | void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
Richard Smith | 5179eb7 | 2016-06-28 19:03:57 +0000 | [diff] [blame] | 1260 | if (auto Inherited = D->getInheritedConstructor()) { |
| 1261 | Record.AddDeclRef(Inherited.getShadowDecl()); |
| 1262 | Record.AddDeclRef(Inherited.getConstructor()); |
| 1263 | Code = serialization::DECL_CXX_INHERITED_CONSTRUCTOR; |
| 1264 | } else { |
| 1265 | Code = serialization::DECL_CXX_CONSTRUCTOR; |
| 1266 | } |
| 1267 | |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1268 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1269 | |
| 1270 | Record.push_back(D->IsExplicitSpecified); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1271 | |
Richard Smith | 5179eb7 | 2016-06-28 19:03:57 +0000 | [diff] [blame] | 1272 | Code = D->isInheritingConstructor() |
| 1273 | ? serialization::DECL_CXX_INHERITED_CONSTRUCTOR |
| 1274 | : serialization::DECL_CXX_CONSTRUCTOR; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1277 | void ASTDeclWriter::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1278 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1279 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1280 | Record.AddDeclRef(D->getOperatorDelete()); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1281 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1282 | Code = serialization::DECL_CXX_DESTRUCTOR; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1283 | } |
| 1284 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1285 | void ASTDeclWriter::VisitCXXConversionDecl(CXXConversionDecl *D) { |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1286 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 3357516 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 1287 | Record.push_back(D->IsExplicitSpecified); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1288 | Code = serialization::DECL_CXX_CONVERSION; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1289 | } |
| 1290 | |
Douglas Gregor | ba34552 | 2011-12-02 23:23:56 +0000 | [diff] [blame] | 1291 | void ASTDeclWriter::VisitImportDecl(ImportDecl *D) { |
| 1292 | VisitDecl(D); |
Argyrios Kyrtzidis | 7b8e555 | 2012-10-03 01:58:45 +0000 | [diff] [blame] | 1293 | Record.push_back(Writer.getSubmoduleID(D->getImportedModule())); |
Douglas Gregor | ba34552 | 2011-12-02 23:23:56 +0000 | [diff] [blame] | 1294 | ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs(); |
| 1295 | Record.push_back(!IdentifierLocs.empty()); |
| 1296 | if (IdentifierLocs.empty()) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1297 | Record.AddSourceLocation(D->getLocEnd()); |
Douglas Gregor | ba34552 | 2011-12-02 23:23:56 +0000 | [diff] [blame] | 1298 | Record.push_back(1); |
| 1299 | } else { |
| 1300 | for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1301 | Record.AddSourceLocation(IdentifierLocs[I]); |
Douglas Gregor | ba34552 | 2011-12-02 23:23:56 +0000 | [diff] [blame] | 1302 | Record.push_back(IdentifierLocs.size()); |
| 1303 | } |
| 1304 | // Note: the number of source locations must always be the last element in |
| 1305 | // the record. |
| 1306 | Code = serialization::DECL_IMPORT; |
| 1307 | } |
| 1308 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1309 | void ASTDeclWriter::VisitAccessSpecDecl(AccessSpecDecl *D) { |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1310 | VisitDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1311 | Record.AddSourceLocation(D->getColonLoc()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1312 | Code = serialization::DECL_ACCESS_SPEC; |
Abramo Bagnara | d734058 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 1313 | } |
| 1314 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1315 | void ASTDeclWriter::VisitFriendDecl(FriendDecl *D) { |
Enea Zaffanella | eb22c87 | 2013-01-31 09:54:08 +0000 | [diff] [blame] | 1316 | // Record the number of friend type template parameter lists here |
| 1317 | // so as to simplify memory allocation during deserialization. |
| 1318 | Record.push_back(D->NumTPLists); |
Argyrios Kyrtzidis | a95d019 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 1319 | VisitDecl(D); |
Enea Zaffanella | eb22c87 | 2013-01-31 09:54:08 +0000 | [diff] [blame] | 1320 | bool hasFriendDecl = D->Friend.is<NamedDecl*>(); |
| 1321 | Record.push_back(hasFriendDecl); |
| 1322 | if (hasFriendDecl) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1323 | Record.AddDeclRef(D->getFriendDecl()); |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1324 | else |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1325 | Record.AddTypeSourceInfo(D->getFriendType()); |
Enea Zaffanella | eb22c87 | 2013-01-31 09:54:08 +0000 | [diff] [blame] | 1326 | for (unsigned i = 0; i < D->NumTPLists; ++i) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1327 | Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i)); |
| 1328 | Record.AddDeclRef(D->getNextFriend()); |
John McCall | 2c2eb12 | 2010-10-16 06:59:13 +0000 | [diff] [blame] | 1329 | Record.push_back(D->UnsupportedFriend); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1330 | Record.AddSourceLocation(D->FriendLoc); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1331 | Code = serialization::DECL_FRIEND; |
Argyrios Kyrtzidis | 74d28bd | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 1332 | } |
| 1333 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1334 | void ASTDeclWriter::VisitFriendTemplateDecl(FriendTemplateDecl *D) { |
Argyrios Kyrtzidis | 165b581 | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1335 | VisitDecl(D); |
| 1336 | Record.push_back(D->getNumTemplateParameters()); |
| 1337 | for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1338 | Record.AddTemplateParameterList(D->getTemplateParameterList(i)); |
Craig Topper | a13603a | 2014-05-22 05:54:18 +0000 | [diff] [blame] | 1339 | Record.push_back(D->getFriendDecl() != nullptr); |
Argyrios Kyrtzidis | 165b581 | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1340 | if (D->getFriendDecl()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1341 | Record.AddDeclRef(D->getFriendDecl()); |
Argyrios Kyrtzidis | 165b581 | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 1342 | else |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1343 | Record.AddTypeSourceInfo(D->getFriendType()); |
| 1344 | Record.AddSourceLocation(D->getFriendLoc()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1345 | Code = serialization::DECL_FRIEND_TEMPLATE; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1346 | } |
| 1347 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1348 | void ASTDeclWriter::VisitTemplateDecl(TemplateDecl *D) { |
Argyrios Kyrtzidis | 106caf92 | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 1349 | VisitNamedDecl(D); |
| 1350 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1351 | Record.AddDeclRef(D->getTemplatedDecl()); |
| 1352 | Record.AddTemplateParameterList(D->getTemplateParameters()); |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1353 | } |
| 1354 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1355 | void ASTDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { |
Douglas Gregor | 68444de | 2012-01-14 15:13:49 +0000 | [diff] [blame] | 1356 | VisitRedeclarable(D); |
| 1357 | |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1358 | // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that |
| 1359 | // getCommonPtr() can be used while this is still initializing. |
Rafael Espindola | 8db352d | 2013-10-17 15:37:26 +0000 | [diff] [blame] | 1360 | if (D->isFirstDecl()) { |
Douglas Gregor | 074a409 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1361 | // This declaration owns the 'common' pointer, so serialize that data now. |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1362 | Record.AddDeclRef(D->getInstantiatedFromMemberTemplate()); |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1363 | if (D->getInstantiatedFromMemberTemplate()) |
| 1364 | Record.push_back(D->isMemberSpecialization()); |
Douglas Gregor | 074a409 | 2011-12-19 18:19:24 +0000 | [diff] [blame] | 1365 | } |
| 1366 | |
Argyrios Kyrtzidis | f4bc0d8 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 1367 | VisitTemplateDecl(D); |
| 1368 | Record.push_back(D->getIdentifierNamespace()); |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1369 | } |
| 1370 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1371 | void ASTDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) { |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1372 | VisitRedeclarableTemplateDecl(D); |
| 1373 | |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 1374 | if (D->isFirstDecl()) |
| 1375 | AddTemplateSpecializations(D); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1376 | Code = serialization::DECL_CLASS_TEMPLATE; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1377 | } |
| 1378 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1379 | void ASTDeclWriter::VisitClassTemplateSpecializationDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1380 | ClassTemplateSpecializationDecl *D) { |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1381 | RegisterTemplateSpecialization(D->getSpecializedTemplate(), D); |
| 1382 | |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1383 | VisitCXXRecordDecl(D); |
| 1384 | |
| 1385 | llvm::PointerUnion<ClassTemplateDecl *, |
| 1386 | ClassTemplatePartialSpecializationDecl *> InstFrom |
| 1387 | = D->getSpecializedTemplateOrPartial(); |
Argyrios Kyrtzidis | d5553f1 | 2011-08-17 21:35:28 +0000 | [diff] [blame] | 1388 | if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1389 | Record.AddDeclRef(InstFromD); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1390 | } else { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1391 | Record.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>()); |
| 1392 | Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs()); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1393 | } |
| 1394 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1395 | Record.AddTemplateArgumentList(&D->getTemplateArgs()); |
| 1396 | Record.AddSourceLocation(D->getPointOfInstantiation()); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1397 | Record.push_back(D->getSpecializationKind()); |
Axel Naumann | a31dee2 | 2012-10-01 07:34:47 +0000 | [diff] [blame] | 1398 | Record.push_back(D->isCanonicalDecl()); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1399 | |
Argyrios Kyrtzidis | c1624e9 | 2010-07-20 13:59:40 +0000 | [diff] [blame] | 1400 | if (D->isCanonicalDecl()) { |
| 1401 | // When reading, we'll add it to the folding set of the following template. |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1402 | Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl()); |
Argyrios Kyrtzidis | 8704057 | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 1403 | } |
| 1404 | |
Richard Smith | d55889a | 2013-09-09 16:55:27 +0000 | [diff] [blame] | 1405 | // Explicit info. |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1406 | Record.AddTypeSourceInfo(D->getTypeAsWritten()); |
Richard Smith | d55889a | 2013-09-09 16:55:27 +0000 | [diff] [blame] | 1407 | if (D->getTypeAsWritten()) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1408 | Record.AddSourceLocation(D->getExternLoc()); |
| 1409 | Record.AddSourceLocation(D->getTemplateKeywordLoc()); |
Richard Smith | d55889a | 2013-09-09 16:55:27 +0000 | [diff] [blame] | 1410 | } |
| 1411 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1412 | Code = serialization::DECL_CLASS_TEMPLATE_SPECIALIZATION; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1413 | } |
| 1414 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1415 | void ASTDeclWriter::VisitClassTemplatePartialSpecializationDecl( |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1416 | ClassTemplatePartialSpecializationDecl *D) { |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1417 | VisitClassTemplateSpecializationDecl(D); |
| 1418 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1419 | Record.AddTemplateParameterList(D->getTemplateParameters()); |
| 1420 | Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten()); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1421 | |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1422 | // These are read/set from/to the first declaration. |
Craig Topper | a13603a | 2014-05-22 05:54:18 +0000 | [diff] [blame] | 1423 | if (D->getPreviousDecl() == nullptr) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1424 | Record.AddDeclRef(D->getInstantiatedFromMember()); |
Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1425 | Record.push_back(D->isMemberSpecialization()); |
| 1426 | } |
| 1427 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1428 | Code = serialization::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1429 | } |
| 1430 | |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1431 | void ASTDeclWriter::VisitVarTemplateDecl(VarTemplateDecl *D) { |
| 1432 | VisitRedeclarableTemplateDecl(D); |
| 1433 | |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 1434 | if (D->isFirstDecl()) |
| 1435 | AddTemplateSpecializations(D); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1436 | Code = serialization::DECL_VAR_TEMPLATE; |
| 1437 | } |
| 1438 | |
| 1439 | void ASTDeclWriter::VisitVarTemplateSpecializationDecl( |
| 1440 | VarTemplateSpecializationDecl *D) { |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1441 | RegisterTemplateSpecialization(D->getSpecializedTemplate(), D); |
| 1442 | |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1443 | VisitVarDecl(D); |
| 1444 | |
| 1445 | llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *> |
| 1446 | InstFrom = D->getSpecializedTemplateOrPartial(); |
| 1447 | if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1448 | Record.AddDeclRef(InstFromD); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1449 | } else { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1450 | Record.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>()); |
| 1451 | Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs()); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1452 | } |
| 1453 | |
| 1454 | // Explicit info. |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1455 | Record.AddTypeSourceInfo(D->getTypeAsWritten()); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1456 | if (D->getTypeAsWritten()) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1457 | Record.AddSourceLocation(D->getExternLoc()); |
| 1458 | Record.AddSourceLocation(D->getTemplateKeywordLoc()); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1459 | } |
| 1460 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1461 | Record.AddTemplateArgumentList(&D->getTemplateArgs()); |
| 1462 | Record.AddSourceLocation(D->getPointOfInstantiation()); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1463 | Record.push_back(D->getSpecializationKind()); |
| 1464 | Record.push_back(D->isCanonicalDecl()); |
| 1465 | |
| 1466 | if (D->isCanonicalDecl()) { |
| 1467 | // When reading, we'll add it to the folding set of the following template. |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1468 | Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl()); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1469 | } |
| 1470 | |
| 1471 | Code = serialization::DECL_VAR_TEMPLATE_SPECIALIZATION; |
| 1472 | } |
| 1473 | |
| 1474 | void ASTDeclWriter::VisitVarTemplatePartialSpecializationDecl( |
| 1475 | VarTemplatePartialSpecializationDecl *D) { |
| 1476 | VisitVarTemplateSpecializationDecl(D); |
| 1477 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1478 | Record.AddTemplateParameterList(D->getTemplateParameters()); |
| 1479 | Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten()); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1480 | |
| 1481 | // These are read/set from/to the first declaration. |
Craig Topper | a13603a | 2014-05-22 05:54:18 +0000 | [diff] [blame] | 1482 | if (D->getPreviousDecl() == nullptr) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1483 | Record.AddDeclRef(D->getInstantiatedFromMember()); |
Larisse Voufo | 39a1e50 | 2013-08-06 01:03:05 +0000 | [diff] [blame] | 1484 | Record.push_back(D->isMemberSpecialization()); |
| 1485 | } |
| 1486 | |
| 1487 | Code = serialization::DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION; |
| 1488 | } |
| 1489 | |
Fariborz Jahanian | 3a039e3 | 2011-08-27 20:50:59 +0000 | [diff] [blame] | 1490 | void ASTDeclWriter::VisitClassScopeFunctionSpecializationDecl( |
| 1491 | ClassScopeFunctionSpecializationDecl *D) { |
Francois Pichet | 09af8c3 | 2011-08-17 01:06:54 +0000 | [diff] [blame] | 1492 | VisitDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1493 | Record.AddDeclRef(D->getSpecialization()); |
Francois Pichet | 09af8c3 | 2011-08-17 01:06:54 +0000 | [diff] [blame] | 1494 | Code = serialization::DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION; |
| 1495 | } |
| 1496 | |
| 1497 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1498 | void ASTDeclWriter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { |
Peter Collingbourne | 91b25b7 | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1499 | VisitRedeclarableTemplateDecl(D); |
Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1500 | |
Richard Smith | 509fc85 | 2015-02-27 23:05:10 +0000 | [diff] [blame] | 1501 | if (D->isFirstDecl()) |
| 1502 | AddTemplateSpecializations(D); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1503 | Code = serialization::DECL_FUNCTION_TEMPLATE; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1504 | } |
| 1505 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1506 | void ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { |
Argyrios Kyrtzidis | 106caf92 | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 1507 | VisitTypeDecl(D); |
| 1508 | |
| 1509 | Record.push_back(D->wasDeclaredWithTypename()); |
Richard Smith | 8346e52 | 2015-06-10 01:47:58 +0000 | [diff] [blame] | 1510 | |
| 1511 | bool OwnsDefaultArg = D->hasDefaultArgument() && |
| 1512 | !D->defaultArgumentWasInherited(); |
| 1513 | Record.push_back(OwnsDefaultArg); |
| 1514 | if (OwnsDefaultArg) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1515 | Record.AddTypeSourceInfo(D->getDefaultArgumentInfo()); |
Argyrios Kyrtzidis | 106caf92 | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 1516 | |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1517 | Code = serialization::DECL_TEMPLATE_TYPE_PARM; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1518 | } |
| 1519 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1520 | void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { |
Douglas Gregor | 0231d8d | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1521 | // For an expanded parameter pack, record the number of expansion types here |
Richard Smith | 1fde8ec | 2012-09-07 02:06:42 +0000 | [diff] [blame] | 1522 | // so that it's easier for deserialization to allocate the right amount of |
| 1523 | // memory. |
Douglas Gregor | 0231d8d | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1524 | if (D->isExpandedParameterPack()) |
| 1525 | Record.push_back(D->getNumExpansionTypes()); |
| 1526 | |
John McCall | f4cd4f9 | 2011-02-09 01:13:10 +0000 | [diff] [blame] | 1527 | VisitDeclaratorDecl(D); |
Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1528 | // TemplateParmPosition. |
| 1529 | Record.push_back(D->getDepth()); |
| 1530 | Record.push_back(D->getPosition()); |
Douglas Gregor | 0231d8d | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1531 | |
| 1532 | if (D->isExpandedParameterPack()) { |
| 1533 | for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1534 | Record.AddTypeRef(D->getExpansionType(I)); |
| 1535 | Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I)); |
Douglas Gregor | 0231d8d | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1536 | } |
| 1537 | |
| 1538 | Code = serialization::DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK; |
| 1539 | } else { |
| 1540 | // Rest of NonTypeTemplateParmDecl. |
| 1541 | Record.push_back(D->isParameterPack()); |
Richard Smith | 8346e52 | 2015-06-10 01:47:58 +0000 | [diff] [blame] | 1542 | bool OwnsDefaultArg = D->hasDefaultArgument() && |
| 1543 | !D->defaultArgumentWasInherited(); |
| 1544 | Record.push_back(OwnsDefaultArg); |
| 1545 | if (OwnsDefaultArg) |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 1546 | Record.AddStmt(D->getDefaultArgument()); |
Douglas Gregor | 0231d8d | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1547 | Code = serialization::DECL_NON_TYPE_TEMPLATE_PARM; |
Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1548 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1549 | } |
| 1550 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1551 | void ASTDeclWriter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { |
Richard Smith | 1fde8ec | 2012-09-07 02:06:42 +0000 | [diff] [blame] | 1552 | // For an expanded parameter pack, record the number of expansion types here |
| 1553 | // so that it's easier for deserialization to allocate the right amount of |
| 1554 | // memory. |
| 1555 | if (D->isExpandedParameterPack()) |
| 1556 | Record.push_back(D->getNumExpansionTemplateParameters()); |
| 1557 | |
Argyrios Kyrtzidis | 9f2d24a | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1558 | VisitTemplateDecl(D); |
| 1559 | // TemplateParmPosition. |
| 1560 | Record.push_back(D->getDepth()); |
| 1561 | Record.push_back(D->getPosition()); |
Richard Smith | 1fde8ec | 2012-09-07 02:06:42 +0000 | [diff] [blame] | 1562 | |
| 1563 | if (D->isExpandedParameterPack()) { |
| 1564 | for (unsigned I = 0, N = D->getNumExpansionTemplateParameters(); |
| 1565 | I != N; ++I) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1566 | Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I)); |
Richard Smith | 1fde8ec | 2012-09-07 02:06:42 +0000 | [diff] [blame] | 1567 | Code = serialization::DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK; |
| 1568 | } else { |
| 1569 | // Rest of TemplateTemplateParmDecl. |
Richard Smith | 1fde8ec | 2012-09-07 02:06:42 +0000 | [diff] [blame] | 1570 | Record.push_back(D->isParameterPack()); |
Richard Smith | 8346e52 | 2015-06-10 01:47:58 +0000 | [diff] [blame] | 1571 | bool OwnsDefaultArg = D->hasDefaultArgument() && |
| 1572 | !D->defaultArgumentWasInherited(); |
| 1573 | Record.push_back(OwnsDefaultArg); |
| 1574 | if (OwnsDefaultArg) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1575 | Record.AddTemplateArgumentLoc(D->getDefaultArgument()); |
Richard Smith | 1fde8ec | 2012-09-07 02:06:42 +0000 | [diff] [blame] | 1576 | Code = serialization::DECL_TEMPLATE_TEMPLATE_PARM; |
| 1577 | } |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1578 | } |
| 1579 | |
Richard Smith | 3f1b5d0 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1580 | void ASTDeclWriter::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { |
| 1581 | VisitRedeclarableTemplateDecl(D); |
| 1582 | Code = serialization::DECL_TYPE_ALIAS_TEMPLATE; |
| 1583 | } |
| 1584 | |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1585 | void ASTDeclWriter::VisitStaticAssertDecl(StaticAssertDecl *D) { |
Argyrios Kyrtzidis | 2d8891c | 2010-07-22 17:28:12 +0000 | [diff] [blame] | 1586 | VisitDecl(D); |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 1587 | Record.AddStmt(D->getAssertExpr()); |
Richard Smith | ded9c2e | 2012-07-11 22:37:56 +0000 | [diff] [blame] | 1588 | Record.push_back(D->isFailed()); |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 1589 | Record.AddStmt(D->getMessage()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1590 | Record.AddSourceLocation(D->getRParenLoc()); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1591 | Code = serialization::DECL_STATIC_ASSERT; |
Chris Lattner | ca025db | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1592 | } |
| 1593 | |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1594 | /// \brief Emit the DeclContext part of a declaration context decl. |
Richard Smith | f1c23dc | 2016-04-13 02:12:03 +0000 | [diff] [blame] | 1595 | void ASTDeclWriter::VisitDeclContext(DeclContext *DC) { |
| 1596 | Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC)); |
| 1597 | Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC)); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1598 | } |
| 1599 | |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1600 | const Decl *ASTWriter::getFirstLocalDecl(const Decl *D) { |
Richard Smith | 3864be7 | 2015-09-11 02:22:03 +0000 | [diff] [blame] | 1601 | assert(IsLocalDecl(D) && "expected a local declaration"); |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1602 | |
| 1603 | const Decl *Canon = D->getCanonicalDecl(); |
Richard Smith | 3864be7 | 2015-09-11 02:22:03 +0000 | [diff] [blame] | 1604 | if (IsLocalDecl(Canon)) |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1605 | return Canon; |
| 1606 | |
| 1607 | const Decl *&CacheEntry = FirstLocalDeclCache[Canon]; |
| 1608 | if (CacheEntry) |
| 1609 | return CacheEntry; |
| 1610 | |
| 1611 | for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl()) |
Richard Smith | 3864be7 | 2015-09-11 02:22:03 +0000 | [diff] [blame] | 1612 | if (IsLocalDecl(Redecl)) |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1613 | D = Redecl; |
| 1614 | return CacheEntry = D; |
Richard Smith | 5fc18a9 | 2015-07-12 23:43:21 +0000 | [diff] [blame] | 1615 | } |
| 1616 | |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1617 | template <typename T> |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1618 | void ASTDeclWriter::VisitRedeclarable(Redeclarable<T> *D) { |
Rafael Espindola | 8db352d | 2013-10-17 15:37:26 +0000 | [diff] [blame] | 1619 | T *First = D->getFirstDecl(); |
Richard Smith | 5a4737c | 2015-02-06 02:42:59 +0000 | [diff] [blame] | 1620 | T *MostRecent = First->getMostRecentDecl(); |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1621 | T *DAsT = static_cast<T *>(D); |
Richard Smith | 5a4737c | 2015-02-06 02:42:59 +0000 | [diff] [blame] | 1622 | if (MostRecent != First) { |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1623 | assert(isRedeclarableDeclKind(DAsT->getKind()) && |
Douglas Gregor | fe732d5 | 2013-01-21 16:16:40 +0000 | [diff] [blame] | 1624 | "Not considered redeclarable?"); |
Richard Smith | 5a4737c | 2015-02-06 02:42:59 +0000 | [diff] [blame] | 1625 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1626 | Record.AddDeclRef(First); |
Richard Smith | fe620d2 | 2015-03-05 23:24:12 +0000 | [diff] [blame] | 1627 | |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1628 | // Write out a list of local redeclarations of this declaration if it's the |
| 1629 | // first local declaration in the chain. |
| 1630 | const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT); |
| 1631 | if (DAsT == FirstLocal) { |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1632 | // Emit a list of all imported first declarations so that we can be sure |
| 1633 | // that all redeclarations visible to this module are before D in the |
| 1634 | // redecl chain. |
| 1635 | unsigned I = Record.size(); |
| 1636 | Record.push_back(0); |
| 1637 | if (Writer.Chain) |
| 1638 | AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false); |
| 1639 | // This is the number of imported first declarations + 1. |
| 1640 | Record[I] = Record.size() - I; |
Richard Smith | d61d4ac | 2015-08-22 20:13:39 +0000 | [diff] [blame] | 1641 | |
| 1642 | // Collect the set of local redeclarations of this declaration, from |
| 1643 | // newest to oldest. |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1644 | ASTWriter::RecordData LocalRedecls; |
| 1645 | ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls); |
Richard Smith | d61d4ac | 2015-08-22 20:13:39 +0000 | [diff] [blame] | 1646 | for (const Decl *Prev = FirstLocal->getMostRecentDecl(); |
| 1647 | Prev != FirstLocal; Prev = Prev->getPreviousDecl()) |
| 1648 | if (!Prev->isFromASTFile()) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1649 | LocalRedeclWriter.AddDeclRef(Prev); |
Richard Smith | d61d4ac | 2015-08-22 20:13:39 +0000 | [diff] [blame] | 1650 | |
| 1651 | // If we have any redecls, write them now as a separate record preceding |
| 1652 | // the declaration itself. |
| 1653 | if (LocalRedecls.empty()) |
| 1654 | Record.push_back(0); |
Richard Smith | f1c23dc | 2016-04-13 02:12:03 +0000 | [diff] [blame] | 1655 | else |
| 1656 | Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS)); |
Richard Smith | d8a8371 | 2015-08-22 01:47:18 +0000 | [diff] [blame] | 1657 | } else { |
| 1658 | Record.push_back(0); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1659 | Record.AddDeclRef(FirstLocal); |
Richard Smith | fe620d2 | 2015-03-05 23:24:12 +0000 | [diff] [blame] | 1660 | } |
Douglas Gregor | 358cd44 | 2012-01-15 16:58:34 +0000 | [diff] [blame] | 1661 | |
| 1662 | // Make sure that we serialize both the previous and the most-recent |
| 1663 | // declarations, which (transitively) ensures that all declarations in the |
| 1664 | // chain get serialized. |
Richard Smith | 5a4737c | 2015-02-06 02:42:59 +0000 | [diff] [blame] | 1665 | // |
| 1666 | // FIXME: This is not correct; when we reach an imported declaration we |
| 1667 | // won't emit its previous declaration. |
Richard Smith | 5fc18a9 | 2015-07-12 23:43:21 +0000 | [diff] [blame] | 1668 | (void)Writer.GetDeclRef(D->getPreviousDecl()); |
Richard Smith | 5a4737c | 2015-02-06 02:42:59 +0000 | [diff] [blame] | 1669 | (void)Writer.GetDeclRef(MostRecent); |
Douglas Gregor | 358cd44 | 2012-01-15 16:58:34 +0000 | [diff] [blame] | 1670 | } else { |
| 1671 | // We use the sentinel value 0 to indicate an only declaration. |
| 1672 | Record.push_back(0); |
Douglas Gregor | 9f562c8 | 2011-12-19 15:27:36 +0000 | [diff] [blame] | 1673 | } |
Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1674 | } |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1675 | |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 1676 | void ASTDeclWriter::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) { |
| 1677 | Record.push_back(D->varlist_size()); |
| 1678 | VisitDecl(D); |
Aaron Ballman | 2205d2a | 2014-03-14 15:55:35 +0000 | [diff] [blame] | 1679 | for (auto *I : D->varlists()) |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 1680 | Record.AddStmt(I); |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 1681 | Code = serialization::DECL_OMP_THREADPRIVATE; |
| 1682 | } |
| 1683 | |
Alexey Bataev | 94a4f0c | 2016-03-03 05:21:39 +0000 | [diff] [blame] | 1684 | void ASTDeclWriter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { |
Alexey Bataev | c5b1d32 | 2016-03-04 09:22:22 +0000 | [diff] [blame] | 1685 | VisitValueDecl(D); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1686 | Record.AddSourceLocation(D->getLocStart()); |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 1687 | Record.AddStmt(D->getCombiner()); |
| 1688 | Record.AddStmt(D->getInitializer()); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 1689 | Record.AddDeclRef(D->getPrevDeclInScope()); |
Alexey Bataev | 94a4f0c | 2016-03-03 05:21:39 +0000 | [diff] [blame] | 1690 | Code = serialization::DECL_OMP_DECLARE_REDUCTION; |
| 1691 | } |
| 1692 | |
Alexey Bataev | 4244be2 | 2016-02-11 05:35:55 +0000 | [diff] [blame] | 1693 | void ASTDeclWriter::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) { |
Alexey Bataev | 90c228f | 2016-02-08 09:29:13 +0000 | [diff] [blame] | 1694 | VisitVarDecl(D); |
Alexey Bataev | 4244be2 | 2016-02-11 05:35:55 +0000 | [diff] [blame] | 1695 | Code = serialization::DECL_OMP_CAPTUREDEXPR; |
Alexey Bataev | 90c228f | 2016-02-08 09:29:13 +0000 | [diff] [blame] | 1696 | } |
| 1697 | |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1698 | //===----------------------------------------------------------------------===// |
Sebastian Redl | 55c0ad5 | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1699 | // ASTWriter Implementation |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1700 | //===----------------------------------------------------------------------===// |
| 1701 | |
Richard Smith | 01b2cb4 | 2014-07-26 06:37:51 +0000 | [diff] [blame] | 1702 | void ASTWriter::WriteDeclAbbrevs() { |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1703 | using namespace llvm; |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1704 | |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1705 | BitCodeAbbrev *Abv; |
| 1706 | |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1707 | // Abbreviation for DECL_FIELD |
| 1708 | Abv = new BitCodeAbbrev(); |
| 1709 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD)); |
| 1710 | // Decl |
| 1711 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 1712 | Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext |
Argyrios Kyrtzidis | b7d1ca2 | 2012-03-09 21:09:04 +0000 | [diff] [blame] | 1713 | Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1714 | Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs |
| 1715 | Abv->Add(BitCodeAbbrevOp(0)); // isImplicit |
| 1716 | Abv->Add(BitCodeAbbrevOp(0)); // isUsed |
| 1717 | Abv->Add(BitCodeAbbrevOp(0)); // isReferenced |
Argyrios Kyrtzidis | 8ad3bab | 2011-11-23 20:27:36 +0000 | [diff] [blame] | 1718 | Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1719 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 1720 | Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate |
Douglas Gregor | a28bcdd | 2011-12-01 02:07:58 +0000 | [diff] [blame] | 1721 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1722 | // NamedDecl |
| 1723 | Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier |
| 1724 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name |
Richard Smith | 2b56057 | 2015-02-07 03:11:11 +0000 | [diff] [blame] | 1725 | Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1726 | // ValueDecl |
| 1727 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
| 1728 | // DeclaratorDecl |
| 1729 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc |
| 1730 | Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo |
| 1731 | // FieldDecl |
| 1732 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable |
| 1733 | Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth |
| 1734 | // Type Source Info |
| 1735 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
| 1736 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
| 1737 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc |
| 1738 | DeclFieldAbbrev = Stream.EmitAbbrev(Abv); |
| 1739 | |
| 1740 | // Abbreviation for DECL_OBJC_IVAR |
| 1741 | Abv = new BitCodeAbbrev(); |
| 1742 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR)); |
| 1743 | // Decl |
| 1744 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 1745 | Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext |
Argyrios Kyrtzidis | b7d1ca2 | 2012-03-09 21:09:04 +0000 | [diff] [blame] | 1746 | Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1747 | Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs |
| 1748 | Abv->Add(BitCodeAbbrevOp(0)); // isImplicit |
| 1749 | Abv->Add(BitCodeAbbrevOp(0)); // isUsed |
| 1750 | Abv->Add(BitCodeAbbrevOp(0)); // isReferenced |
Argyrios Kyrtzidis | 8ad3bab | 2011-11-23 20:27:36 +0000 | [diff] [blame] | 1751 | Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1752 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 1753 | Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate |
Douglas Gregor | a28bcdd | 2011-12-01 02:07:58 +0000 | [diff] [blame] | 1754 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1755 | // NamedDecl |
| 1756 | Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier |
| 1757 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name |
Richard Smith | 2b56057 | 2015-02-07 03:11:11 +0000 | [diff] [blame] | 1758 | Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1759 | // ValueDecl |
| 1760 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
| 1761 | // DeclaratorDecl |
| 1762 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc |
| 1763 | Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo |
| 1764 | // FieldDecl |
| 1765 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable |
| 1766 | Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth |
| 1767 | // ObjC Ivar |
| 1768 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl |
| 1769 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize |
| 1770 | // Type Source Info |
| 1771 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
| 1772 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
| 1773 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc |
| 1774 | DeclObjCIvarAbbrev = Stream.EmitAbbrev(Abv); |
| 1775 | |
| 1776 | // Abbreviation for DECL_ENUM |
| 1777 | Abv = new BitCodeAbbrev(); |
| 1778 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM)); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1779 | // Redeclarable |
Douglas Gregor | 9f562c8 | 2011-12-19 15:27:36 +0000 | [diff] [blame] | 1780 | Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1781 | // Decl |
| 1782 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 1783 | Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext |
Argyrios Kyrtzidis | b7d1ca2 | 2012-03-09 21:09:04 +0000 | [diff] [blame] | 1784 | Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1785 | Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs |
| 1786 | Abv->Add(BitCodeAbbrevOp(0)); // isImplicit |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 1787 | Abv->Add(BitCodeAbbrevOp(0)); // isUsed |
Argyrios Kyrtzidis | 1618023 | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 1788 | Abv->Add(BitCodeAbbrevOp(0)); // isReferenced |
Argyrios Kyrtzidis | 8ad3bab | 2011-11-23 20:27:36 +0000 | [diff] [blame] | 1789 | Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1790 | Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 1791 | Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate |
Douglas Gregor | a28bcdd | 2011-12-01 02:07:58 +0000 | [diff] [blame] | 1792 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1793 | // NamedDecl |
| 1794 | Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier |
| 1795 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name |
Richard Smith | 2b56057 | 2015-02-07 03:11:11 +0000 | [diff] [blame] | 1796 | Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1797 | // TypeDecl |
| 1798 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location |
| 1799 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1800 | // TagDecl |
| 1801 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace |
| 1802 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind |
John McCall | f937c02 | 2011-10-07 06:10:15 +0000 | [diff] [blame] | 1803 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1804 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator |
Argyrios Kyrtzidis | 201d377 | 2011-09-30 22:11:31 +0000 | [diff] [blame] | 1805 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding |
David Blaikie | a8d23ce | 2013-07-14 01:07:41 +0000 | [diff] [blame] | 1806 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1807 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation |
Argyrios Kyrtzidis | d798c05 | 2016-07-15 18:11:33 +0000 | [diff] [blame] | 1808 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation |
Richard Smith | 70d5850 | 2014-08-30 00:04:23 +0000 | [diff] [blame] | 1809 | Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1810 | // EnumDecl |
| 1811 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef |
| 1812 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType |
| 1813 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType |
| 1814 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumPositiveBits |
| 1815 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumNegativeBits |
| 1816 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScoped |
| 1817 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScopedUsingClassTag |
| 1818 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isFixed |
| 1819 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum |
| 1820 | // DC |
| 1821 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset |
| 1822 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset |
| 1823 | DeclEnumAbbrev = Stream.EmitAbbrev(Abv); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1824 | |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1825 | // Abbreviation for DECL_RECORD |
| 1826 | Abv = new BitCodeAbbrev(); |
| 1827 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD)); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1828 | // Redeclarable |
Douglas Gregor | 9f562c8 | 2011-12-19 15:27:36 +0000 | [diff] [blame] | 1829 | Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1830 | // Decl |
| 1831 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 1832 | Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext |
Argyrios Kyrtzidis | b7d1ca2 | 2012-03-09 21:09:04 +0000 | [diff] [blame] | 1833 | Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1834 | Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs |
| 1835 | Abv->Add(BitCodeAbbrevOp(0)); // isImplicit |
| 1836 | Abv->Add(BitCodeAbbrevOp(0)); // isUsed |
| 1837 | Abv->Add(BitCodeAbbrevOp(0)); // isReferenced |
Argyrios Kyrtzidis | 8ad3bab | 2011-11-23 20:27:36 +0000 | [diff] [blame] | 1838 | Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1839 | Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 1840 | Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate |
Douglas Gregor | a28bcdd | 2011-12-01 02:07:58 +0000 | [diff] [blame] | 1841 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1842 | // NamedDecl |
| 1843 | Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier |
| 1844 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name |
Richard Smith | 2b56057 | 2015-02-07 03:11:11 +0000 | [diff] [blame] | 1845 | Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1846 | // TypeDecl |
| 1847 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location |
| 1848 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1849 | // TagDecl |
| 1850 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace |
| 1851 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind |
John McCall | f937c02 | 2011-10-07 06:10:15 +0000 | [diff] [blame] | 1852 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1853 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator |
Argyrios Kyrtzidis | 201d377 | 2011-09-30 22:11:31 +0000 | [diff] [blame] | 1854 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding |
David Blaikie | a8d23ce | 2013-07-14 01:07:41 +0000 | [diff] [blame] | 1855 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1856 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation |
Argyrios Kyrtzidis | d798c05 | 2016-07-15 18:11:33 +0000 | [diff] [blame] | 1857 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation |
Richard Smith | 70d5850 | 2014-08-30 00:04:23 +0000 | [diff] [blame] | 1858 | Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1859 | // RecordDecl |
| 1860 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember |
| 1861 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion |
| 1862 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember |
Fariborz Jahanian | 7865220 | 2013-01-25 23:57:05 +0000 | [diff] [blame] | 1863 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1864 | // DC |
| 1865 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset |
| 1866 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset |
| 1867 | DeclRecordAbbrev = Stream.EmitAbbrev(Abv); |
| 1868 | |
| 1869 | // Abbreviation for DECL_PARM_VAR |
| 1870 | Abv = new BitCodeAbbrev(); |
| 1871 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR)); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1872 | // Redeclarable |
Douglas Gregor | 9f562c8 | 2011-12-19 15:27:36 +0000 | [diff] [blame] | 1873 | Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1874 | // Decl |
| 1875 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 1876 | Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext |
Argyrios Kyrtzidis | b7d1ca2 | 2012-03-09 21:09:04 +0000 | [diff] [blame] | 1877 | Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1878 | Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs |
| 1879 | Abv->Add(BitCodeAbbrevOp(0)); // isImplicit |
| 1880 | Abv->Add(BitCodeAbbrevOp(0)); // isUsed |
| 1881 | Abv->Add(BitCodeAbbrevOp(0)); // isReferenced |
Argyrios Kyrtzidis | 8ad3bab | 2011-11-23 20:27:36 +0000 | [diff] [blame] | 1882 | Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1883 | Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 1884 | Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate |
Douglas Gregor | a28bcdd | 2011-12-01 02:07:58 +0000 | [diff] [blame] | 1885 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1886 | // NamedDecl |
| 1887 | Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier |
| 1888 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name |
Richard Smith | 2b56057 | 2015-02-07 03:11:11 +0000 | [diff] [blame] | 1889 | Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1890 | // ValueDecl |
| 1891 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
Argyrios Kyrtzidis | 560ac97 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 1892 | // DeclaratorDecl |
Abramo Bagnara | dff1930 | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1893 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc |
Argyrios Kyrtzidis | 434383d | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1894 | Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1895 | // VarDecl |
Vassil Vassilev | d1a8813 | 2016-10-06 13:04:54 +0000 | [diff] [blame] | 1896 | Abv->Add(BitCodeAbbrevOp(0)); // SClass |
| 1897 | Abv->Add(BitCodeAbbrevOp(0)); // TSCSpec |
| 1898 | Abv->Add(BitCodeAbbrevOp(0)); // InitStyle |
Richard Smith | 8858159 | 2013-02-12 05:48:23 +0000 | [diff] [blame] | 1899 | Abv->Add(BitCodeAbbrevOp(0)); // Linkage |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1900 | Abv->Add(BitCodeAbbrevOp(0)); // HasInit |
Argyrios Kyrtzidis | cdb8b3f | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 1901 | Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1902 | // ParmVarDecl |
John McCall | 8249083 | 2011-05-02 00:30:12 +0000 | [diff] [blame] | 1903 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsObjCMethodParameter |
John McCall | 8fb0d9d | 2011-05-01 22:35:37 +0000 | [diff] [blame] | 1904 | Abv->Add(BitCodeAbbrevOp(0)); // ScopeDepth |
| 1905 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1906 | Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier |
John McCall | 6a014d5 | 2011-03-09 04:22:44 +0000 | [diff] [blame] | 1907 | Abv->Add(BitCodeAbbrevOp(0)); // KNRPromoted |
John McCall | f3cd665 | 2010-03-12 18:31:32 +0000 | [diff] [blame] | 1908 | Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg |
Argyrios Kyrtzidis | ccde6a0 | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 1909 | Abv->Add(BitCodeAbbrevOp(0)); // HasUninstantiatedDefaultArg |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1910 | // Type Source Info |
| 1911 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
| 1912 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
| 1913 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc |
| 1914 | DeclParmVarAbbrev = Stream.EmitAbbrev(Abv); |
Sebastian Redl | 66c5eef | 2010-07-27 00:17:23 +0000 | [diff] [blame] | 1915 | |
Jonathan D. Turner | 780a6bf | 2011-06-06 16:22:39 +0000 | [diff] [blame] | 1916 | // Abbreviation for DECL_TYPEDEF |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 1917 | Abv = new BitCodeAbbrev(); |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1918 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF)); |
Douglas Gregor | 05f1035 | 2011-12-17 23:38:30 +0000 | [diff] [blame] | 1919 | // Redeclarable |
Douglas Gregor | 9f562c8 | 2011-12-19 15:27:36 +0000 | [diff] [blame] | 1920 | Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1921 | // Decl |
| 1922 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 1923 | Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext |
Argyrios Kyrtzidis | b7d1ca2 | 2012-03-09 21:09:04 +0000 | [diff] [blame] | 1924 | Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1925 | Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs |
| 1926 | Abv->Add(BitCodeAbbrevOp(0)); // isImplicit |
Richard Smith | 01b2cb4 | 2014-07-26 06:37:51 +0000 | [diff] [blame] | 1927 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isUsed |
| 1928 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isReferenced |
Argyrios Kyrtzidis | 8ad3bab | 2011-11-23 20:27:36 +0000 | [diff] [blame] | 1929 | Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer |
Richard Smith | 01b2cb4 | 2014-07-26 06:37:51 +0000 | [diff] [blame] | 1930 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // C++ AccessSpecifier |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 1931 | Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate |
Douglas Gregor | a28bcdd | 2011-12-01 02:07:58 +0000 | [diff] [blame] | 1932 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1933 | // NamedDecl |
| 1934 | Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier |
| 1935 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name |
Richard Smith | 2b56057 | 2015-02-07 03:11:11 +0000 | [diff] [blame] | 1936 | Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1937 | // TypeDecl |
| 1938 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location |
| 1939 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref |
| 1940 | // TypedefDecl |
| 1941 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
| 1942 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc |
| 1943 | DeclTypedefAbbrev = Stream.EmitAbbrev(Abv); |
| 1944 | |
Jonathan D. Turner | 780a6bf | 2011-06-06 16:22:39 +0000 | [diff] [blame] | 1945 | // Abbreviation for DECL_VAR |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1946 | Abv = new BitCodeAbbrev(); |
| 1947 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR)); |
Douglas Gregor | 3e30010 | 2011-10-26 17:53:41 +0000 | [diff] [blame] | 1948 | // Redeclarable |
Douglas Gregor | 9f562c8 | 2011-12-19 15:27:36 +0000 | [diff] [blame] | 1949 | Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1950 | // Decl |
| 1951 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 1952 | Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext |
Argyrios Kyrtzidis | b7d1ca2 | 2012-03-09 21:09:04 +0000 | [diff] [blame] | 1953 | Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1954 | Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs |
| 1955 | Abv->Add(BitCodeAbbrevOp(0)); // isImplicit |
| 1956 | Abv->Add(BitCodeAbbrevOp(0)); // isUsed |
| 1957 | Abv->Add(BitCodeAbbrevOp(0)); // isReferenced |
Argyrios Kyrtzidis | 8ad3bab | 2011-11-23 20:27:36 +0000 | [diff] [blame] | 1958 | Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1959 | Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier |
Douglas Gregor | 26701a4 | 2011-09-09 02:06:17 +0000 | [diff] [blame] | 1960 | Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate |
Douglas Gregor | a28bcdd | 2011-12-01 02:07:58 +0000 | [diff] [blame] | 1961 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1962 | // NamedDecl |
| 1963 | Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier |
| 1964 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name |
Richard Smith | 2b56057 | 2015-02-07 03:11:11 +0000 | [diff] [blame] | 1965 | Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1966 | // ValueDecl |
| 1967 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
| 1968 | // DeclaratorDecl |
| 1969 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc |
| 1970 | Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo |
| 1971 | // VarDecl |
Vassil Vassilev | d1a8813 | 2016-10-06 13:04:54 +0000 | [diff] [blame] | 1972 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass |
| 1973 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec |
| 1974 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle |
Richard Smith | edbc6e9 | 2016-10-14 21:41:24 +0000 | [diff] [blame] | 1975 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1976 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable |
| 1977 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable |
| 1978 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl |
John McCall | d463132 | 2011-06-17 06:42:21 +0000 | [diff] [blame] | 1979 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong |
Richard Smith | 62f19e7 | 2016-06-25 00:15:56 +0000 | [diff] [blame] | 1980 | Abv->Add(BitCodeAbbrevOp(0)); // isInline |
| 1981 | Abv->Add(BitCodeAbbrevOp(0)); // isInlineSpecified |
Douglas Gregor | 12cda63 | 2012-09-20 23:43:29 +0000 | [diff] [blame] | 1982 | Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr |
Richard Smith | bb13c9a | 2013-09-28 04:02:39 +0000 | [diff] [blame] | 1983 | Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture |
Richard Smith | 1c34fb7 | 2013-08-13 18:18:50 +0000 | [diff] [blame] | 1984 | Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope |
Rafael Espindola | 50df3a0 | 2013-05-25 17:16:20 +0000 | [diff] [blame] | 1985 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage |
Vassil Vassilev | d1a8813 | 2016-10-06 13:04:54 +0000 | [diff] [blame] | 1986 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local) |
| 1987 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum) |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 1988 | // Type Source Info |
| 1989 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
| 1990 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
| 1991 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc |
| 1992 | DeclVarAbbrev = Stream.EmitAbbrev(Abv); |
| 1993 | |
Richard Smith | 01b2cb4 | 2014-07-26 06:37:51 +0000 | [diff] [blame] | 1994 | // Abbreviation for DECL_CXX_METHOD |
| 1995 | Abv = new BitCodeAbbrev(); |
| 1996 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD)); |
| 1997 | // RedeclarableDecl |
| 1998 | Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl |
| 1999 | // Decl |
| 2000 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext |
Richard Smith | 8aed422 | 2015-12-11 22:41:00 +0000 | [diff] [blame] | 2001 | Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext |
Richard Smith | 01b2cb4 | 2014-07-26 06:37:51 +0000 | [diff] [blame] | 2002 | Abv->Add(BitCodeAbbrevOp(0)); // Invalid |
| 2003 | Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs |
| 2004 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Implicit |
| 2005 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Used |
| 2006 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Referenced |
| 2007 | Abv->Add(BitCodeAbbrevOp(0)); // InObjCContainer |
| 2008 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Access |
| 2009 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModulePrivate |
| 2010 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID |
| 2011 | // NamedDecl |
| 2012 | Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind |
| 2013 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier |
Richard Smith | 2b56057 | 2015-02-07 03:11:11 +0000 | [diff] [blame] | 2014 | Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber |
Richard Smith | 01b2cb4 | 2014-07-26 06:37:51 +0000 | [diff] [blame] | 2015 | // ValueDecl |
| 2016 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
| 2017 | // DeclaratorDecl |
| 2018 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart |
| 2019 | Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo |
| 2020 | // FunctionDecl |
| 2021 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS |
| 2022 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass |
| 2023 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline |
| 2024 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified |
| 2025 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten |
| 2026 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure |
| 2027 | Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto |
| 2028 | Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto |
Richard Smith | 72625c2 | 2015-02-06 23:20:21 +0000 | [diff] [blame] | 2029 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted |
Richard Smith | 01b2cb4 | 2014-07-26 06:37:51 +0000 | [diff] [blame] | 2030 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial |
| 2031 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted |
| 2032 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted |
| 2033 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero |
| 2034 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr |
| 2035 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody |
| 2036 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed |
| 2037 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage |
| 2038 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd |
| 2039 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind |
| 2040 | // This Array slurps the rest of the record. Fortunately we want to encode |
| 2041 | // (nearly) all the remaining (variable number of) fields in the same way. |
| 2042 | // |
| 2043 | // This is the function template information if any, then |
| 2044 | // NumParams and Params[] from FunctionDecl, and |
| 2045 | // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl. |
| 2046 | // |
| 2047 | // Add an AbbrevOp for 'size then elements' and use it here. |
| 2048 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
| 2049 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
| 2050 | DeclCXXMethodAbbrev = Stream.EmitAbbrev(Abv); |
| 2051 | |
Jonathan D. Turner | 780a6bf | 2011-06-06 16:22:39 +0000 | [diff] [blame] | 2052 | // Abbreviation for EXPR_DECL_REF |
Jonathan D. Turner | 205c7d5 | 2011-06-03 23:11:16 +0000 | [diff] [blame] | 2053 | Abv = new BitCodeAbbrev(); |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 2054 | Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF)); |
| 2055 | //Stmt |
| 2056 | //Expr |
| 2057 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
Douglas Gregor | 678d76c | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 2058 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent |
| 2059 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent |
| 2060 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 2061 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack |
| 2062 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind |
| 2063 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind |
| 2064 | //DeclRefExpr |
| 2065 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HasQualifier |
| 2066 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //GetDeclFound |
| 2067 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ExplicitTemplateArgs |
Abramo Bagnara | 635ed24e | 2011-10-05 07:56:41 +0000 | [diff] [blame] | 2068 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HadMultipleCandidates |
Alexey Bataev | 19acc3d | 2015-01-12 10:17:46 +0000 | [diff] [blame] | 2069 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, |
| 2070 | 1)); // RefersToEnclosingVariableOrCapture |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 2071 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef |
| 2072 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location |
| 2073 | DeclRefExprAbbrev = Stream.EmitAbbrev(Abv); |
| 2074 | |
| 2075 | // Abbreviation for EXPR_INTEGER_LITERAL |
| 2076 | Abv = new BitCodeAbbrev(); |
| 2077 | Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL)); |
| 2078 | //Stmt |
| 2079 | //Expr |
| 2080 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
Douglas Gregor | 678d76c | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 2081 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent |
| 2082 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent |
| 2083 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 2084 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack |
| 2085 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind |
| 2086 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind |
| 2087 | //Integer Literal |
| 2088 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location |
| 2089 | Abv->Add(BitCodeAbbrevOp(32)); // Bit Width |
| 2090 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value |
| 2091 | IntegerLiteralAbbrev = Stream.EmitAbbrev(Abv); |
| 2092 | |
| 2093 | // Abbreviation for EXPR_CHARACTER_LITERAL |
| 2094 | Abv = new BitCodeAbbrev(); |
| 2095 | Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL)); |
| 2096 | //Stmt |
| 2097 | //Expr |
| 2098 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
Douglas Gregor | 678d76c | 2011-07-01 01:22:09 +0000 | [diff] [blame] | 2099 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent |
| 2100 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent |
| 2101 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 2102 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack |
| 2103 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind |
| 2104 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind |
Jonathan D. Turner | d09655f | 2011-06-03 21:46:44 +0000 | [diff] [blame] | 2105 | //Character Literal |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 2106 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue |
| 2107 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location |
Aaron Ballman | 9a17c85 | 2016-01-07 20:59:26 +0000 | [diff] [blame] | 2108 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind |
Douglas Gregor | 03412ba | 2011-06-03 02:27:19 +0000 | [diff] [blame] | 2109 | CharacterLiteralAbbrev = Stream.EmitAbbrev(Abv); |
| 2110 | |
Richard Smith | a27c26e | 2014-07-27 04:19:32 +0000 | [diff] [blame] | 2111 | // Abbreviation for EXPR_IMPLICIT_CAST |
| 2112 | Abv = new BitCodeAbbrev(); |
| 2113 | Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST)); |
| 2114 | // Stmt |
| 2115 | // Expr |
| 2116 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
| 2117 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent |
| 2118 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent |
| 2119 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent |
| 2120 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack |
| 2121 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind |
| 2122 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind |
| 2123 | // CastExpr |
| 2124 | Abv->Add(BitCodeAbbrevOp(0)); // PathSize |
| 2125 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind |
| 2126 | // ImplicitCastExpr |
| 2127 | ExprImplicitCastAbbrev = Stream.EmitAbbrev(Abv); |
| 2128 | |
Sebastian Redl | 66c5eef | 2010-07-27 00:17:23 +0000 | [diff] [blame] | 2129 | Abv = new BitCodeAbbrev(); |
Sebastian Redl | 539c506 | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 2130 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL)); |
Sebastian Redl | 66c5eef | 2010-07-27 00:17:23 +0000 | [diff] [blame] | 2131 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); |
| 2132 | DeclContextLexicalAbbrev = Stream.EmitAbbrev(Abv); |
Argyrios Kyrtzidis | ba88bfa | 2010-08-20 16:04:35 +0000 | [diff] [blame] | 2133 | |
| 2134 | Abv = new BitCodeAbbrev(); |
| 2135 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE)); |
Argyrios Kyrtzidis | ba88bfa | 2010-08-20 16:04:35 +0000 | [diff] [blame] | 2136 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); |
| 2137 | DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(Abv); |
Chris Lattner | 258172e | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 2138 | } |
| 2139 | |
Daniel Dunbar | 5bb5ec5 | 2009-09-17 03:06:51 +0000 | [diff] [blame] | 2140 | /// isRequiredDecl - Check if this is a "required" Decl, which must be seen by |
| 2141 | /// consumers of the AST. |
| 2142 | /// |
Sebastian Redl | 42a0f6a | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 2143 | /// Such decls will always be deserialized from the AST file, so we would like |
Daniel Dunbar | 5bb5ec5 | 2009-09-17 03:06:51 +0000 | [diff] [blame] | 2144 | /// this to be as restrictive as possible. Currently the predicate is driven by |
| 2145 | /// code generation requirements, if other clients have a different notion of |
| 2146 | /// what is "required" then we may have to consider an alternate scheme where |
| 2147 | /// clients can iterate over the top-level decls and get information on them, |
| 2148 | /// without necessary deserializing them. We could explicitly require such |
| 2149 | /// clients to use a separate API call to "realize" the decl. This should be |
| 2150 | /// relatively painless since they would presumably only do it for top-level |
| 2151 | /// decls. |
Richard Smith | c52efa7 | 2015-08-19 02:30:28 +0000 | [diff] [blame] | 2152 | static bool isRequiredDecl(const Decl *D, ASTContext &Context, |
| 2153 | bool WritingModule) { |
Argyrios Kyrtzidis | a98e861 | 2011-09-13 21:35:00 +0000 | [diff] [blame] | 2154 | // An ObjCMethodDecl is never considered as "required" because its |
| 2155 | // implementation container always is. |
| 2156 | |
Dmitry Polukhin | 0b0da29 | 2016-04-06 11:38:59 +0000 | [diff] [blame] | 2157 | // File scoped assembly or obj-c or OMP declare target implementation must be |
| 2158 | // seen. |
| 2159 | if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D) || |
| 2160 | D->hasAttr<OMPDeclareTargetDeclAttr>()) |
Richard Smith | c52efa7 | 2015-08-19 02:30:28 +0000 | [diff] [blame] | 2161 | return true; |
| 2162 | |
Richard Smith | dc1f042 | 2016-07-20 19:10:16 +0000 | [diff] [blame] | 2163 | if (WritingModule && (isa<VarDecl>(D) || isa<ImportDecl>(D))) { |
| 2164 | // These declarations are part of the module initializer, and are emitted |
| 2165 | // if and when the module is imported, rather than being emitted eagerly. |
| 2166 | return false; |
| 2167 | } |
Daniel Dunbar | 5bb5ec5 | 2009-09-17 03:06:51 +0000 | [diff] [blame] | 2168 | |
Argyrios Kyrtzidis | c904933 | 2010-07-29 20:08:05 +0000 | [diff] [blame] | 2169 | return Context.DeclMustBeEmitted(D); |
Daniel Dunbar | 5bb5ec5 | 2009-09-17 03:06:51 +0000 | [diff] [blame] | 2170 | } |
| 2171 | |
Sebastian Redl | 55c0ad5 | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 2172 | void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) { |
Douglas Gregor | b3163e5 | 2012-01-05 22:33:30 +0000 | [diff] [blame] | 2173 | // Determine the ID for this declaration. |
| 2174 | serialization::DeclID ID; |
Douglas Gregor | 7dd37e5 | 2015-11-03 01:20:54 +0000 | [diff] [blame] | 2175 | assert(!D->isFromASTFile() && "should not be emitting imported decl"); |
| 2176 | serialization::DeclID &IDR = DeclIDs[D]; |
| 2177 | if (IDR == 0) |
| 2178 | IDR = NextDeclID++; |
Douglas Gregor | b3163e5 | 2012-01-05 22:33:30 +0000 | [diff] [blame] | 2179 | |
Douglas Gregor | 7dd37e5 | 2015-11-03 01:20:54 +0000 | [diff] [blame] | 2180 | ID = IDR; |
Argyrios Kyrtzidis | bf6c339 | 2012-03-22 16:08:04 +0000 | [diff] [blame] | 2181 | |
Richard Smith | 34da751 | 2016-03-27 05:52:25 +0000 | [diff] [blame] | 2182 | assert(ID >= FirstDeclID && "invalid decl ID"); |
Douglas Gregor | b3163e5 | 2012-01-05 22:33:30 +0000 | [diff] [blame] | 2183 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 2184 | RecordData Record; |
| 2185 | ASTDeclWriter W(*this, Context, Record); |
| 2186 | |
Richard Smith | d61d4ac | 2015-08-22 20:13:39 +0000 | [diff] [blame] | 2187 | // Build a record for this declaration |
Richard Smith | d61d4ac | 2015-08-22 20:13:39 +0000 | [diff] [blame] | 2188 | W.Visit(D); |
Richard Smith | d61d4ac | 2015-08-22 20:13:39 +0000 | [diff] [blame] | 2189 | |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 2190 | // Emit this declaration to the bitstream. |
| 2191 | uint64_t Offset = W.Emit(D); |
Douglas Gregor | 12bfa38 | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 2192 | |
Richard Smith | 34da751 | 2016-03-27 05:52:25 +0000 | [diff] [blame] | 2193 | // Record the offset for this declaration |
| 2194 | SourceLocation Loc = D->getLocation(); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 2195 | unsigned Index = ID - FirstDeclID; |
Richard Smith | 34da751 | 2016-03-27 05:52:25 +0000 | [diff] [blame] | 2196 | if (DeclOffsets.size() == Index) |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 2197 | DeclOffsets.push_back(DeclOffset(Loc, Offset)); |
Richard Smith | 34da751 | 2016-03-27 05:52:25 +0000 | [diff] [blame] | 2198 | else if (DeclOffsets.size() < Index) { |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 2199 | // FIXME: Can/should this happen? |
Richard Smith | 34da751 | 2016-03-27 05:52:25 +0000 | [diff] [blame] | 2200 | DeclOffsets.resize(Index+1); |
| 2201 | DeclOffsets[Index].setLocation(Loc); |
Richard Smith | 69c82bf | 2016-04-01 22:52:03 +0000 | [diff] [blame] | 2202 | DeclOffsets[Index].BitOffset = Offset; |
| 2203 | } else { |
| 2204 | llvm_unreachable("declarations should be emitted in ID order"); |
Douglas Gregor | 12bfa38 | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 2205 | } |
| 2206 | |
Richard Smith | 34da751 | 2016-03-27 05:52:25 +0000 | [diff] [blame] | 2207 | SourceManager &SM = Context.getSourceManager(); |
| 2208 | if (Loc.isValid() && SM.isLocalSourceLocation(Loc)) |
| 2209 | associateDeclWithFile(D, ID); |
| 2210 | |
Ben Langmuir | 332aafe | 2014-01-31 01:06:56 +0000 | [diff] [blame] | 2211 | // Note declarations that should be deserialized eagerly so that we can add |
| 2212 | // them to a record in the AST file later. |
Richard Smith | c52efa7 | 2015-08-19 02:30:28 +0000 | [diff] [blame] | 2213 | if (isRequiredDecl(D, Context, WritingModule)) |
Ben Langmuir | 332aafe | 2014-01-31 01:06:56 +0000 | [diff] [blame] | 2214 | EagerlyDeserializedDecls.push_back(ID); |
Chris Lattner | 7099dbc | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 2215 | } |
Richard Smith | d28ac5b | 2014-03-22 23:33:22 +0000 | [diff] [blame] | 2216 | |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 2217 | void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) { |
| 2218 | // Switch case IDs are per function body. |
| 2219 | Writer->ClearSwitchCaseIDs(); |
Richard Smith | d28ac5b | 2014-03-22 23:33:22 +0000 | [diff] [blame] | 2220 | |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 2221 | assert(FD->doesThisDeclarationHaveABody()); |
| 2222 | if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) { |
| 2223 | Record->push_back(CD->getNumCtorInitializers()); |
| 2224 | if (CD->getNumCtorInitializers()) |
Richard Smith | aa165cf | 2016-04-13 21:57:08 +0000 | [diff] [blame] | 2225 | AddCXXCtorInitializers( |
Richard Smith | 290d801 | 2016-04-06 17:06:00 +0000 | [diff] [blame] | 2226 | llvm::makeArrayRef(CD->init_begin(), CD->init_end())); |
| 2227 | } |
| 2228 | AddStmt(FD->getBody()); |
Richard Smith | d28ac5b | 2014-03-22 23:33:22 +0000 | [diff] [blame] | 2229 | } |