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