clang  7.0.0
ASTWriterDecl.cpp
Go to the documentation of this file.
1 //===--- ASTWriterDecl.cpp - Declaration Serialization --------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements serialization for Declarations.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "ASTCommon.h"
15 #include "clang/AST/DeclCXX.h"
17 #include "clang/AST/DeclTemplate.h"
18 #include "clang/AST/DeclVisitor.h"
19 #include "clang/AST/Expr.h"
24 #include "llvm/Bitcode/BitstreamWriter.h"
25 #include "llvm/Support/ErrorHandling.h"
26 using namespace clang;
27 using namespace serialization;
28 
29 //===----------------------------------------------------------------------===//
30 // Declaration serialization
31 //===----------------------------------------------------------------------===//
32 
33 namespace clang {
34  class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> {
35  ASTWriter &Writer;
36  ASTContext &Context;
37  ASTRecordWriter Record;
38 
40  unsigned AbbrevToUse;
41 
42  public:
43  ASTDeclWriter(ASTWriter &Writer, ASTContext &Context,
45  : Writer(Writer), Context(Context), Record(Writer, Record),
46  Code((serialization::DeclCode)0), AbbrevToUse(0) {}
47 
48  uint64_t Emit(Decl *D) {
49  if (!Code)
50  llvm::report_fatal_error(StringRef("unexpected declaration kind '") +
51  D->getDeclKindName() + "'");
52  return Record.Emit(Code, AbbrevToUse);
53  }
54 
55  void Visit(Decl *D);
56 
57  void VisitDecl(Decl *D);
58  void VisitPragmaCommentDecl(PragmaCommentDecl *D);
59  void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D);
60  void VisitTranslationUnitDecl(TranslationUnitDecl *D);
61  void VisitNamedDecl(NamedDecl *D);
62  void VisitLabelDecl(LabelDecl *LD);
63  void VisitNamespaceDecl(NamespaceDecl *D);
64  void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
65  void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
66  void VisitTypeDecl(TypeDecl *D);
67  void VisitTypedefNameDecl(TypedefNameDecl *D);
68  void VisitTypedefDecl(TypedefDecl *D);
69  void VisitTypeAliasDecl(TypeAliasDecl *D);
70  void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
71  void VisitTagDecl(TagDecl *D);
72  void VisitEnumDecl(EnumDecl *D);
73  void VisitRecordDecl(RecordDecl *D);
74  void VisitCXXRecordDecl(CXXRecordDecl *D);
75  void VisitClassTemplateSpecializationDecl(
77  void VisitClassTemplatePartialSpecializationDecl(
79  void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D);
80  void VisitVarTemplatePartialSpecializationDecl(
82  void VisitClassScopeFunctionSpecializationDecl(
84  void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
85  void VisitValueDecl(ValueDecl *D);
86  void VisitEnumConstantDecl(EnumConstantDecl *D);
87  void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
88  void VisitDeclaratorDecl(DeclaratorDecl *D);
89  void VisitFunctionDecl(FunctionDecl *D);
90  void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D);
91  void VisitCXXMethodDecl(CXXMethodDecl *D);
92  void VisitCXXConstructorDecl(CXXConstructorDecl *D);
93  void VisitCXXDestructorDecl(CXXDestructorDecl *D);
94  void VisitCXXConversionDecl(CXXConversionDecl *D);
95  void VisitFieldDecl(FieldDecl *D);
96  void VisitMSPropertyDecl(MSPropertyDecl *D);
97  void VisitIndirectFieldDecl(IndirectFieldDecl *D);
98  void VisitVarDecl(VarDecl *D);
99  void VisitImplicitParamDecl(ImplicitParamDecl *D);
100  void VisitParmVarDecl(ParmVarDecl *D);
101  void VisitDecompositionDecl(DecompositionDecl *D);
102  void VisitBindingDecl(BindingDecl *D);
103  void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
104  void VisitTemplateDecl(TemplateDecl *D);
105  void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
106  void VisitClassTemplateDecl(ClassTemplateDecl *D);
107  void VisitVarTemplateDecl(VarTemplateDecl *D);
108  void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
109  void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
110  void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
111  void VisitUsingDecl(UsingDecl *D);
112  void VisitUsingPackDecl(UsingPackDecl *D);
113  void VisitUsingShadowDecl(UsingShadowDecl *D);
114  void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D);
115  void VisitLinkageSpecDecl(LinkageSpecDecl *D);
116  void VisitExportDecl(ExportDecl *D);
117  void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
118  void VisitImportDecl(ImportDecl *D);
119  void VisitAccessSpecDecl(AccessSpecDecl *D);
120  void VisitFriendDecl(FriendDecl *D);
121  void VisitFriendTemplateDecl(FriendTemplateDecl *D);
122  void VisitStaticAssertDecl(StaticAssertDecl *D);
123  void VisitBlockDecl(BlockDecl *D);
124  void VisitCapturedDecl(CapturedDecl *D);
125  void VisitEmptyDecl(EmptyDecl *D);
126 
127  void VisitDeclContext(DeclContext *DC);
128  template <typename T> void VisitRedeclarable(Redeclarable<T> *D);
129 
130 
131  // FIXME: Put in the same order is DeclNodes.td?
132  void VisitObjCMethodDecl(ObjCMethodDecl *D);
133  void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D);
134  void VisitObjCContainerDecl(ObjCContainerDecl *D);
135  void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
136  void VisitObjCIvarDecl(ObjCIvarDecl *D);
137  void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
138  void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D);
139  void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
140  void VisitObjCImplDecl(ObjCImplDecl *D);
141  void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
142  void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
143  void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
144  void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
145  void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
146  void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
147  void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
148  void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
149 
150  /// Add an Objective-C type parameter list to the given record.
152  // Empty type parameter list.
153  if (!typeParams) {
154  Record.push_back(0);
155  return;
156  }
157 
158  Record.push_back(typeParams->size());
159  for (auto typeParam : *typeParams) {
160  Record.AddDeclRef(typeParam);
161  }
162  Record.AddSourceLocation(typeParams->getLAngleLoc());
163  Record.AddSourceLocation(typeParams->getRAngleLoc());
164  }
165 
166  /// Add to the record the first declaration from each module file that
167  /// provides a declaration of D. The intent is to provide a sufficient
168  /// set such that reloading this set will load all current redeclarations.
169  void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
170  llvm::MapVector<ModuleFile*, const Decl*> Firsts;
171  // FIXME: We can skip entries that we know are implied by others.
172  for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) {
173  if (R->isFromASTFile())
174  Firsts[Writer.Chain->getOwningModuleFile(R)] = R;
175  else if (IncludeLocal)
176  Firsts[nullptr] = R;
177  }
178  for (const auto &F : Firsts)
179  Record.AddDeclRef(F.second);
180  }
181 
182  /// Get the specialization decl from an entry in the specialization list.
183  template <typename EntryType>
185  getSpecializationDecl(EntryType &T) {
187  }
188 
189  /// Get the list of partial specializations from a template's common ptr.
190  template<typename T>
191  decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) {
192  return Common->PartialSpecializations;
193  }
195  return None;
196  }
197 
198  template<typename DeclTy>
199  void AddTemplateSpecializations(DeclTy *D) {
200  auto *Common = D->getCommonPtr();
201 
202  // If we have any lazy specializations, and the external AST source is
203  // our chained AST reader, we can just write out the DeclIDs. Otherwise,
204  // we need to resolve them to actual declarations.
205  if (Writer.Chain != Writer.Context->getExternalSource() &&
206  Common->LazySpecializations) {
207  D->LoadLazySpecializations();
208  assert(!Common->LazySpecializations);
209  }
210 
211  ArrayRef<DeclID> LazySpecializations;
212  if (auto *LS = Common->LazySpecializations)
213  LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]);
214 
215  // Add a slot to the record for the number of specializations.
216  unsigned I = Record.size();
217  Record.push_back(0);
218 
219  // AddFirstDeclFromEachModule might trigger deserialization, invalidating
220  // *Specializations iterators.
222  for (auto &Entry : Common->Specializations)
223  Specs.push_back(getSpecializationDecl(Entry));
224  for (auto &Entry : getPartialSpecializations(Common))
225  Specs.push_back(getSpecializationDecl(Entry));
226 
227  for (auto *D : Specs) {
228  assert(D->isCanonicalDecl() && "non-canonical decl in set");
229  AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
230  }
231  Record.append(LazySpecializations.begin(), LazySpecializations.end());
232 
233  // Update the size entry we added earlier.
234  Record[I] = Record.size() - I - 1;
235  }
236 
237  /// Ensure that this template specialization is associated with the specified
238  /// template on reload.
239  void RegisterTemplateSpecialization(const Decl *Template,
240  const Decl *Specialization) {
241  Template = Template->getCanonicalDecl();
242 
243  // If the canonical template is local, we'll write out this specialization
244  // when we emit it.
245  // FIXME: We can do the same thing if there is any local declaration of
246  // the template, to avoid emitting an update record.
247  if (!Template->isFromASTFile())
248  return;
249 
250  // We only need to associate the first local declaration of the
251  // specialization. The other declarations will get pulled in by it.
252  if (Writer.getFirstLocalDecl(Specialization) != Specialization)
253  return;
254 
255  Writer.DeclUpdates[Template].push_back(ASTWriter::DeclUpdate(
256  UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION, Specialization));
257  }
258  };
259 }
260 
263 
264  // Source locations require array (variable-length) abbreviations. The
265  // abbreviation infrastructure requires that arrays are encoded last, so
266  // we handle it here in the case of those classes derived from DeclaratorDecl
267  if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
268  if (auto *TInfo = DD->getTypeSourceInfo())
269  Record.AddTypeLoc(TInfo->getTypeLoc());
270  }
271 
272  // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
273  // have been written. We want it last because we will not read it back when
274  // retrieving it from the AST, we'll just lazily set the offset.
275  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
276  Record.push_back(FD->doesThisDeclarationHaveABody());
277  if (FD->doesThisDeclarationHaveABody())
278  Record.AddFunctionDefinition(FD);
279  }
280 
281  // If this declaration is also a DeclContext, write blocks for the
282  // declarations that lexically stored inside its context and those
283  // declarations that are visible from its context.
284  if (DeclContext *DC = dyn_cast<DeclContext>(D))
285  VisitDeclContext(DC);
286 }
287 
289  Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
290  if (D->getDeclContext() != D->getLexicalDeclContext())
291  Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
292  else
293  Record.push_back(0);
294  Record.push_back(D->isInvalidDecl());
295  Record.push_back(D->hasAttrs());
296  if (D->hasAttrs())
297  Record.AddAttributes(D->getAttrs());
298  Record.push_back(D->isImplicit());
299  Record.push_back(D->isUsed(false));
300  Record.push_back(D->isReferenced());
301  Record.push_back(D->isTopLevelDeclInObjCContainer());
302  Record.push_back(D->getAccess());
303  Record.push_back(D->isModulePrivate());
304  Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
305 
306  // If this declaration injected a name into a context different from its
307  // lexical context, and that context is an imported namespace, we need to
308  // update its visible declarations to include this name.
309  //
310  // This happens when we instantiate a class with a friend declaration or a
311  // function with a local extern declaration, for instance.
312  //
313  // FIXME: Can we handle this in AddedVisibleDecl instead?
314  if (D->isOutOfLine()) {
315  auto *DC = D->getDeclContext();
316  while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
317  if (!NS->isFromASTFile())
318  break;
319  Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
320  if (!NS->isInlineNamespace())
321  break;
322  DC = NS->getParent();
323  }
324  }
325 }
326 
328  StringRef Arg = D->getArg();
329  Record.push_back(Arg.size());
330  VisitDecl(D);
331  Record.AddSourceLocation(D->getLocStart());
332  Record.push_back(D->getCommentKind());
333  Record.AddString(Arg);
335 }
336 
339  StringRef Name = D->getName();
340  StringRef Value = D->getValue();
341  Record.push_back(Name.size() + 1 + Value.size());
342  VisitDecl(D);
343  Record.AddSourceLocation(D->getLocStart());
344  Record.AddString(Name);
345  Record.AddString(Value);
347 }
348 
350  llvm_unreachable("Translation units aren't directly serialized");
351 }
352 
354  VisitDecl(D);
355  Record.AddDeclarationName(D->getDeclName());
356  Record.push_back(needsAnonymousDeclarationNumber(D)
357  ? Writer.getAnonymousDeclarationNumber(D)
358  : 0);
359 }
360 
362  VisitNamedDecl(D);
363  Record.AddSourceLocation(D->getLocStart());
364  Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
365 }
366 
368  VisitRedeclarable(D);
369  VisitTypeDecl(D);
370  Record.AddTypeSourceInfo(D->getTypeSourceInfo());
371  Record.push_back(D->isModed());
372  if (D->isModed())
373  Record.AddTypeRef(D->getUnderlyingType());
374  Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
375 }
376 
378  VisitTypedefNameDecl(D);
379  if (D->getDeclContext() == D->getLexicalDeclContext() &&
380  !D->hasAttrs() &&
381  !D->isImplicit() &&
382  D->getFirstDecl() == D->getMostRecentDecl() &&
383  !D->isInvalidDecl() &&
385  !D->isModulePrivate() &&
388  AbbrevToUse = Writer.getDeclTypedefAbbrev();
389 
391 }
392 
394  VisitTypedefNameDecl(D);
395  Record.AddDeclRef(D->getDescribedAliasTemplate());
397 }
398 
400  VisitRedeclarable(D);
401  VisitTypeDecl(D);
402  Record.push_back(D->getIdentifierNamespace());
403  Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
404  if (!isa<CXXRecordDecl>(D))
405  Record.push_back(D->isCompleteDefinition());
406  Record.push_back(D->isEmbeddedInDeclarator());
407  Record.push_back(D->isFreeStanding());
408  Record.push_back(D->isCompleteDefinitionRequired());
409  Record.AddSourceRange(D->getBraceRange());
410 
411  if (D->hasExtInfo()) {
412  Record.push_back(1);
413  Record.AddQualifierInfo(*D->getExtInfo());
414  } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
415  Record.push_back(2);
416  Record.AddDeclRef(TD);
417  Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
418  } else {
419  Record.push_back(0);
420  }
421 }
422 
424  VisitTagDecl(D);
425  Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
426  if (!D->getIntegerTypeSourceInfo())
427  Record.AddTypeRef(D->getIntegerType());
428  Record.AddTypeRef(D->getPromotionType());
429  Record.push_back(D->getNumPositiveBits());
430  Record.push_back(D->getNumNegativeBits());
431  Record.push_back(D->isScoped());
432  Record.push_back(D->isScopedUsingClassTag());
433  Record.push_back(D->isFixed());
434  Record.push_back(D->getODRHash());
435 
436  if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) {
437  Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
438  Record.push_back(MemberInfo->getTemplateSpecializationKind());
439  Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
440  } else {
441  Record.AddDeclRef(nullptr);
442  }
443 
444  if (D->getDeclContext() == D->getLexicalDeclContext() &&
445  !D->hasAttrs() &&
446  !D->isImplicit() &&
447  !D->isUsed(false) &&
448  !D->hasExtInfo() &&
450  D->getFirstDecl() == D->getMostRecentDecl() &&
451  !D->isInvalidDecl() &&
452  !D->isReferenced() &&
454  D->getAccess() == AS_none &&
455  !D->isModulePrivate() &&
457  !D->getIntegerTypeSourceInfo() &&
461  AbbrevToUse = Writer.getDeclEnumAbbrev();
462 
464 }
465 
467  VisitTagDecl(D);
468  Record.push_back(D->hasFlexibleArrayMember());
469  Record.push_back(D->isAnonymousStructOrUnion());
470  Record.push_back(D->hasObjectMember());
471  Record.push_back(D->hasVolatileMember());
472  Record.push_back(D->isNonTrivialToPrimitiveDefaultInitialize());
473  Record.push_back(D->isNonTrivialToPrimitiveCopy());
474  Record.push_back(D->isNonTrivialToPrimitiveDestroy());
475  Record.push_back(D->isParamDestroyedInCallee());
476  Record.push_back(D->getArgPassingRestrictions());
477 
478  if (D->getDeclContext() == D->getLexicalDeclContext() &&
479  !D->hasAttrs() &&
480  !D->isImplicit() &&
481  !D->isUsed(false) &&
482  !D->hasExtInfo() &&
484  D->getFirstDecl() == D->getMostRecentDecl() &&
485  !D->isInvalidDecl() &&
486  !D->isReferenced() &&
488  D->getAccess() == AS_none &&
489  !D->isModulePrivate() &&
493  AbbrevToUse = Writer.getDeclRecordAbbrev();
494 
496 }
497 
499  VisitNamedDecl(D);
500  Record.AddTypeRef(D->getType());
501 }
502 
504  VisitValueDecl(D);
505  Record.push_back(D->getInitExpr()? 1 : 0);
506  if (D->getInitExpr())
507  Record.AddStmt(D->getInitExpr());
508  Record.AddAPSInt(D->getInitVal());
509 
511 }
512 
514  VisitValueDecl(D);
515  Record.AddSourceLocation(D->getInnerLocStart());
516  Record.push_back(D->hasExtInfo());
517  if (D->hasExtInfo())
518  Record.AddQualifierInfo(*D->getExtInfo());
519  // The location information is deferred until the end of the record.
520  Record.AddTypeRef(D->getTypeSourceInfo() ? D->getTypeSourceInfo()->getType()
521  : QualType());
522 }
523 
525  VisitRedeclarable(D);
526  VisitDeclaratorDecl(D);
527  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
528  Record.push_back(D->getIdentifierNamespace());
529 
530  // FunctionDecl's body is handled last at ASTWriterDecl::Visit,
531  // after everything else is written.
532 
533  Record.push_back((int)D->SClass); // FIXME: stable encoding
534  Record.push_back(D->IsInline);
535  Record.push_back(D->IsInlineSpecified);
536  Record.push_back(D->IsExplicitSpecified);
537  Record.push_back(D->IsVirtualAsWritten);
538  Record.push_back(D->IsPure);
539  Record.push_back(D->HasInheritedPrototype);
540  Record.push_back(D->HasWrittenPrototype);
541  Record.push_back(D->IsDeleted);
542  Record.push_back(D->IsTrivial);
543  Record.push_back(D->IsTrivialForCall);
544  Record.push_back(D->IsDefaulted);
545  Record.push_back(D->IsExplicitlyDefaulted);
546  Record.push_back(D->HasImplicitReturnZero);
547  Record.push_back(D->IsConstexpr);
548  Record.push_back(D->UsesSEHTry);
549  Record.push_back(D->HasSkippedBody);
550  Record.push_back(D->IsMultiVersion);
551  Record.push_back(D->IsLateTemplateParsed);
552  Record.push_back(D->getLinkageInternal());
553  Record.AddSourceLocation(D->getLocEnd());
554 
555  Record.push_back(D->getODRHash());
556 
557  Record.push_back(D->getTemplatedKind());
558  switch (D->getTemplatedKind()) {
560  break;
562  Record.AddDeclRef(D->getDescribedFunctionTemplate());
563  break;
566  Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
567  Record.push_back(MemberInfo->getTemplateSpecializationKind());
568  Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
569  break;
570  }
573  FTSInfo = D->getTemplateSpecializationInfo();
574 
575  RegisterTemplateSpecialization(FTSInfo->getTemplate(), D);
576 
577  Record.AddDeclRef(FTSInfo->getTemplate());
578  Record.push_back(FTSInfo->getTemplateSpecializationKind());
579 
580  // Template arguments.
581  Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
582 
583  // Template args as written.
584  Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
585  if (FTSInfo->TemplateArgumentsAsWritten) {
586  Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs);
587  for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs;
588  i!=e; ++i)
589  Record.AddTemplateArgumentLoc(
590  (*FTSInfo->TemplateArgumentsAsWritten)[i]);
591  Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc);
592  Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc);
593  }
594 
595  Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
596 
597  if (D->isCanonicalDecl()) {
598  // Write the template that contains the specializations set. We will
599  // add a FunctionTemplateSpecializationInfo to it when reading.
600  Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
601  }
602  break;
603  }
606  DFTSInfo = D->getDependentSpecializationInfo();
607 
608  // Templates.
609  Record.push_back(DFTSInfo->getNumTemplates());
610  for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i)
611  Record.AddDeclRef(DFTSInfo->getTemplate(i));
612 
613  // Templates args.
614  Record.push_back(DFTSInfo->getNumTemplateArgs());
615  for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i)
616  Record.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i));
617  Record.AddSourceLocation(DFTSInfo->getLAngleLoc());
618  Record.AddSourceLocation(DFTSInfo->getRAngleLoc());
619  break;
620  }
621  }
622 
623  Record.push_back(D->param_size());
624  for (auto P : D->parameters())
625  Record.AddDeclRef(P);
627 }
628 
630  VisitFunctionDecl(D);
631  Record.push_back(D->IsCopyDeductionCandidate);
633 }
634 
636  VisitNamedDecl(D);
637  // FIXME: convert to LazyStmtPtr?
638  // Unlike C/C++, method bodies will never be in header files.
639  bool HasBodyStuff = D->getBody() != nullptr ||
640  D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr;
641  Record.push_back(HasBodyStuff);
642  if (HasBodyStuff) {
643  Record.AddStmt(D->getBody());
644  Record.AddDeclRef(D->getSelfDecl());
645  Record.AddDeclRef(D->getCmdDecl());
646  }
647  Record.push_back(D->isInstanceMethod());
648  Record.push_back(D->isVariadic());
649  Record.push_back(D->isPropertyAccessor());
650  Record.push_back(D->isDefined());
651  Record.push_back(D->IsOverriding);
652  Record.push_back(D->HasSkippedBody);
653 
654  Record.push_back(D->IsRedeclaration);
655  Record.push_back(D->HasRedeclaration);
656  if (D->HasRedeclaration) {
657  assert(Context.getObjCMethodRedeclaration(D));
658  Record.AddDeclRef(Context.getObjCMethodRedeclaration(D));
659  }
660 
661  // FIXME: stable encoding for @required/@optional
662  Record.push_back(D->getImplementationControl());
663  // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
664  Record.push_back(D->getObjCDeclQualifier());
665  Record.push_back(D->hasRelatedResultType());
666  Record.AddTypeRef(D->getReturnType());
667  Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
668  Record.AddSourceLocation(D->getLocEnd());
669  Record.push_back(D->param_size());
670  for (const auto *P : D->parameters())
671  Record.AddDeclRef(P);
672 
673  Record.push_back(D->SelLocsKind);
674  unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
675  SourceLocation *SelLocs = D->getStoredSelLocs();
676  Record.push_back(NumStoredSelLocs);
677  for (unsigned i = 0; i != NumStoredSelLocs; ++i)
678  Record.AddSourceLocation(SelLocs[i]);
679 
681 }
682 
684  VisitTypedefNameDecl(D);
685  Record.push_back(D->Variance);
686  Record.push_back(D->Index);
687  Record.AddSourceLocation(D->VarianceLoc);
688  Record.AddSourceLocation(D->ColonLoc);
689 
691 }
692 
694  VisitNamedDecl(D);
695  Record.AddSourceLocation(D->getAtStartLoc());
696  Record.AddSourceRange(D->getAtEndRange());
697  // Abstract class (no need to define a stable serialization::DECL code).
698 }
699 
701  VisitRedeclarable(D);
702  VisitObjCContainerDecl(D);
703  Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
704  AddObjCTypeParamList(D->TypeParamList);
705 
706  Record.push_back(D->isThisDeclarationADefinition());
707  if (D->isThisDeclarationADefinition()) {
708  // Write the DefinitionData
709  ObjCInterfaceDecl::DefinitionData &Data = D->data();
710 
711  Record.AddTypeSourceInfo(D->getSuperClassTInfo());
712  Record.AddSourceLocation(D->getEndOfDefinitionLoc());
713  Record.push_back(Data.HasDesignatedInitializers);
714 
715  // Write out the protocols that are directly referenced by the @interface.
716  Record.push_back(Data.ReferencedProtocols.size());
717  for (const auto *P : D->protocols())
718  Record.AddDeclRef(P);
719  for (const auto &PL : D->protocol_locs())
720  Record.AddSourceLocation(PL);
721 
722  // Write out the protocols that are transitively referenced.
723  Record.push_back(Data.AllReferencedProtocols.size());
725  P = Data.AllReferencedProtocols.begin(),
726  PEnd = Data.AllReferencedProtocols.end();
727  P != PEnd; ++P)
728  Record.AddDeclRef(*P);
729 
730 
731  if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
732  // Ensure that we write out the set of categories for this class.
733  Writer.ObjCClassesWithCategories.insert(D);
734 
735  // Make sure that the categories get serialized.
736  for (; Cat; Cat = Cat->getNextClassCategoryRaw())
737  (void)Writer.GetDeclRef(Cat);
738  }
739  }
740 
742 }
743 
745  VisitFieldDecl(D);
746  // FIXME: stable encoding for @public/@private/@protected/@package
747  Record.push_back(D->getAccessControl());
748  Record.push_back(D->getSynthesize());
749 
750  if (D->getDeclContext() == D->getLexicalDeclContext() &&
751  !D->hasAttrs() &&
752  !D->isImplicit() &&
753  !D->isUsed(false) &&
754  !D->isInvalidDecl() &&
755  !D->isReferenced() &&
756  !D->isModulePrivate() &&
757  !D->getBitWidth() &&
758  !D->hasExtInfo() &&
759  D->getDeclName())
760  AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
761 
763 }
764 
766  VisitRedeclarable(D);
767  VisitObjCContainerDecl(D);
768 
769  Record.push_back(D->isThisDeclarationADefinition());
770  if (D->isThisDeclarationADefinition()) {
771  Record.push_back(D->protocol_size());
772  for (const auto *I : D->protocols())
773  Record.AddDeclRef(I);
774  for (const auto &PL : D->protocol_locs())
775  Record.AddSourceLocation(PL);
776  }
777 
779 }
780 
782  VisitFieldDecl(D);
784 }
785 
787  VisitObjCContainerDecl(D);
788  Record.AddSourceLocation(D->getCategoryNameLoc());
789  Record.AddSourceLocation(D->getIvarLBraceLoc());
790  Record.AddSourceLocation(D->getIvarRBraceLoc());
791  Record.AddDeclRef(D->getClassInterface());
792  AddObjCTypeParamList(D->TypeParamList);
793  Record.push_back(D->protocol_size());
794  for (const auto *I : D->protocols())
795  Record.AddDeclRef(I);
796  for (const auto &PL : D->protocol_locs())
797  Record.AddSourceLocation(PL);
799 }
800 
802  VisitNamedDecl(D);
803  Record.AddDeclRef(D->getClassInterface());
805 }
806 
808  VisitNamedDecl(D);
809  Record.AddSourceLocation(D->getAtLoc());
810  Record.AddSourceLocation(D->getLParenLoc());
811  Record.AddTypeRef(D->getType());
812  Record.AddTypeSourceInfo(D->getTypeSourceInfo());
813  // FIXME: stable encoding
814  Record.push_back((unsigned)D->getPropertyAttributes());
815  Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
816  // FIXME: stable encoding
817  Record.push_back((unsigned)D->getPropertyImplementation());
818  Record.AddDeclarationName(D->getGetterName());
819  Record.AddSourceLocation(D->getGetterNameLoc());
820  Record.AddDeclarationName(D->getSetterName());
821  Record.AddSourceLocation(D->getSetterNameLoc());
822  Record.AddDeclRef(D->getGetterMethodDecl());
823  Record.AddDeclRef(D->getSetterMethodDecl());
824  Record.AddDeclRef(D->getPropertyIvarDecl());
826 }
827 
829  VisitObjCContainerDecl(D);
830  Record.AddDeclRef(D->getClassInterface());
831  // Abstract class (no need to define a stable serialization::DECL code).
832 }
833 
835  VisitObjCImplDecl(D);
836  Record.AddSourceLocation(D->getCategoryNameLoc());
838 }
839 
841  VisitObjCImplDecl(D);
842  Record.AddDeclRef(D->getSuperClass());
843  Record.AddSourceLocation(D->getSuperClassLoc());
844  Record.AddSourceLocation(D->getIvarLBraceLoc());
845  Record.AddSourceLocation(D->getIvarRBraceLoc());
846  Record.push_back(D->hasNonZeroConstructors());
847  Record.push_back(D->hasDestructors());
848  Record.push_back(D->NumIvarInitializers);
849  if (D->NumIvarInitializers)
850  Record.AddCXXCtorInitializers(
851  llvm::makeArrayRef(D->init_begin(), D->init_end()));
853 }
854 
856  VisitDecl(D);
857  Record.AddSourceLocation(D->getLocStart());
858  Record.AddDeclRef(D->getPropertyDecl());
859  Record.AddDeclRef(D->getPropertyIvarDecl());
860  Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
861  Record.AddStmt(D->getGetterCXXConstructor());
862  Record.AddStmt(D->getSetterCXXAssignment());
864 }
865 
867  VisitDeclaratorDecl(D);
868  Record.push_back(D->isMutable());
869 
870  FieldDecl::InitStorageKind ISK = D->InitStorage.getInt();
871  Record.push_back(ISK);
872  if (ISK == FieldDecl::ISK_CapturedVLAType)
873  Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
874  else if (ISK)
875  Record.AddStmt(D->getInClassInitializer());
876 
877  Record.AddStmt(D->getBitWidth());
878 
879  if (!D->getDeclName())
880  Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D));
881 
882  if (D->getDeclContext() == D->getLexicalDeclContext() &&
883  !D->hasAttrs() &&
884  !D->isImplicit() &&
885  !D->isUsed(false) &&
886  !D->isInvalidDecl() &&
887  !D->isReferenced() &&
889  !D->isModulePrivate() &&
890  !D->getBitWidth() &&
891  !D->hasInClassInitializer() &&
892  !D->hasCapturedVLAType() &&
893  !D->hasExtInfo() &&
896  D->getDeclName())
897  AbbrevToUse = Writer.getDeclFieldAbbrev();
898 
900 }
901 
903  VisitDeclaratorDecl(D);
904  Record.AddIdentifierRef(D->getGetterId());
905  Record.AddIdentifierRef(D->getSetterId());
907 }
908 
910  VisitValueDecl(D);
911  Record.push_back(D->getChainingSize());
912 
913  for (const auto *P : D->chain())
914  Record.AddDeclRef(P);
916 }
917 
919  VisitRedeclarable(D);
920  VisitDeclaratorDecl(D);
921  Record.push_back(D->getStorageClass());
922  Record.push_back(D->getTSCSpec());
923  Record.push_back(D->getInitStyle());
924  if (!isa<ParmVarDecl>(D)) {
925  Record.push_back(D->isThisDeclarationADemotedDefinition());
926  Record.push_back(D->isExceptionVariable());
927  Record.push_back(D->isNRVOVariable());
928  Record.push_back(D->isCXXForRangeDecl());
929  Record.push_back(D->isObjCForDecl());
930  Record.push_back(D->isARCPseudoStrong());
931  Record.push_back(D->isInline());
932  Record.push_back(D->isInlineSpecified());
933  Record.push_back(D->isConstexpr());
934  Record.push_back(D->isInitCapture());
935  Record.push_back(D->isPreviousDeclInSameBlockScope());
936  if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
937  Record.push_back(static_cast<unsigned>(IPD->getParameterKind()));
938  else
939  Record.push_back(0);
940  }
941  Record.push_back(D->getLinkageInternal());
942 
943  if (D->getInit()) {
944  Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2));
945  Record.AddStmt(D->getInit());
946  } else {
947  Record.push_back(0);
948  }
949 
950  if (D->getStorageDuration() == SD_Static) {
951  bool ModulesCodegen = false;
952  if (Writer.WritingModule &&
954  !isa<VarTemplateSpecializationDecl>(D)) {
955  // When building a C++ Modules TS module interface unit, a strong
956  // definition in the module interface is provided by the compilation of
957  // that module interface unit, not by its users. (Inline variables are
958  // still emitted in module users.)
959  ModulesCodegen =
960  (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit &&
961  Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal);
962  }
963  Record.push_back(ModulesCodegen);
964  if (ModulesCodegen)
965  Writer.ModularCodegenDecls.push_back(Writer.GetDeclRef(D));
966  }
967 
968  enum {
969  VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
970  };
971  if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
972  Record.push_back(VarTemplate);
973  Record.AddDeclRef(TemplD);
974  } else if (MemberSpecializationInfo *SpecInfo
976  Record.push_back(StaticDataMemberSpecialization);
977  Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
978  Record.push_back(SpecInfo->getTemplateSpecializationKind());
979  Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
980  } else {
981  Record.push_back(VarNotTemplate);
982  }
983 
984  if (D->getDeclContext() == D->getLexicalDeclContext() &&
985  !D->hasAttrs() &&
986  !D->isImplicit() &&
987  !D->isUsed(false) &&
988  !D->isInvalidDecl() &&
989  !D->isReferenced() &&
991  D->getAccess() == AS_none &&
992  !D->isModulePrivate() &&
995  !D->hasExtInfo() &&
996  D->getFirstDecl() == D->getMostRecentDecl() &&
997  D->getKind() == Decl::Var &&
998  !D->isInline() &&
999  !D->isConstexpr() &&
1000  !D->isInitCapture() &&
1002  D->getStorageDuration() != SD_Static &&
1004  AbbrevToUse = Writer.getDeclVarAbbrev();
1005 
1006  Code = serialization::DECL_VAR;
1007 }
1008 
1010  VisitVarDecl(D);
1012 }
1013 
1015  VisitVarDecl(D);
1016  Record.push_back(D->isObjCMethodParameter());
1017  Record.push_back(D->getFunctionScopeDepth());
1018  Record.push_back(D->getFunctionScopeIndex());
1019  Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding
1020  Record.push_back(D->isKNRPromoted());
1021  Record.push_back(D->hasInheritedDefaultArg());
1022  Record.push_back(D->hasUninstantiatedDefaultArg());
1023  if (D->hasUninstantiatedDefaultArg())
1024  Record.AddStmt(D->getUninstantiatedDefaultArg());
1026 
1027  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
1028 
1029  // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1030  // we dynamically check for the properties that we optimize for, but don't
1031  // know are true of all PARM_VAR_DECLs.
1032  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1033  !D->hasAttrs() &&
1034  !D->hasExtInfo() &&
1035  !D->isImplicit() &&
1036  !D->isUsed(false) &&
1037  !D->isInvalidDecl() &&
1038  !D->isReferenced() &&
1039  D->getAccess() == AS_none &&
1040  !D->isModulePrivate() &&
1041  D->getStorageClass() == 0 &&
1042  D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1043  D->getFunctionScopeDepth() == 0 &&
1044  D->getObjCDeclQualifier() == 0 &&
1045  !D->isKNRPromoted() &&
1046  !D->hasInheritedDefaultArg() &&
1047  D->getInit() == nullptr &&
1048  !D->hasUninstantiatedDefaultArg()) // No default expr.
1049  AbbrevToUse = Writer.getDeclParmVarAbbrev();
1050 
1051  // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1052  // just us assuming it.
1053  assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1055  && "PARM_VAR_DECL can't be demoted definition.");
1056  assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1057  assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1058  assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1059  assert(!D->isStaticDataMember() &&
1060  "PARM_VAR_DECL can't be static data member");
1061 }
1062 
1064  // Record the number of bindings first to simplify deserialization.
1065  Record.push_back(D->bindings().size());
1066 
1067  VisitVarDecl(D);
1068  for (auto *B : D->bindings())
1069  Record.AddDeclRef(B);
1071 }
1072 
1074  VisitValueDecl(D);
1075  Record.AddStmt(D->getBinding());
1077 }
1078 
1080  VisitDecl(D);
1081  Record.AddStmt(D->getAsmString());
1082  Record.AddSourceLocation(D->getRParenLoc());
1084 }
1085 
1087  VisitDecl(D);
1089 }
1090 
1092  VisitDecl(D);
1093  Record.AddStmt(D->getBody());
1094  Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1095  Record.push_back(D->param_size());
1096  for (ParmVarDecl *P : D->parameters())
1097  Record.AddDeclRef(P);
1098  Record.push_back(D->isVariadic());
1099  Record.push_back(D->blockMissingReturnType());
1100  Record.push_back(D->isConversionFromLambda());
1101  Record.push_back(D->capturesCXXThis());
1102  Record.push_back(D->getNumCaptures());
1103  for (const auto &capture : D->captures()) {
1104  Record.AddDeclRef(capture.getVariable());
1105 
1106  unsigned flags = 0;
1107  if (capture.isByRef()) flags |= 1;
1108  if (capture.isNested()) flags |= 2;
1109  if (capture.hasCopyExpr()) flags |= 4;
1110  Record.push_back(flags);
1111 
1112  if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1113  }
1114 
1116 }
1117 
1119  Record.push_back(CD->getNumParams());
1120  VisitDecl(CD);
1121  Record.push_back(CD->getContextParamPosition());
1122  Record.push_back(CD->isNothrow() ? 1 : 0);
1123  // Body is stored by VisitCapturedStmt.
1124  for (unsigned I = 0; I < CD->getNumParams(); ++I)
1125  Record.AddDeclRef(CD->getParam(I));
1127 }
1128 
1130  VisitDecl(D);
1131  Record.push_back(D->getLanguage());
1132  Record.AddSourceLocation(D->getExternLoc());
1133  Record.AddSourceLocation(D->getRBraceLoc());
1135 }
1136 
1138  VisitDecl(D);
1139  Record.AddSourceLocation(D->getRBraceLoc());
1141 }
1142 
1144  VisitNamedDecl(D);
1145  Record.AddSourceLocation(D->getLocStart());
1147 }
1148 
1149 
1151  VisitRedeclarable(D);
1152  VisitNamedDecl(D);
1153  Record.push_back(D->isInline());
1154  Record.AddSourceLocation(D->getLocStart());
1155  Record.AddSourceLocation(D->getRBraceLoc());
1156 
1157  if (D->isOriginalNamespace())
1158  Record.AddDeclRef(D->getAnonymousNamespace());
1160 
1161  if (Writer.hasChain() && D->isAnonymousNamespace() &&
1162  D == D->getMostRecentDecl()) {
1163  // This is a most recent reopening of the anonymous namespace. If its parent
1164  // is in a previous PCH (or is the TU), mark that parent for update, because
1165  // the original namespace always points to the latest re-opening of its
1166  // anonymous namespace.
1167  Decl *Parent = cast<Decl>(
1169  if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1170  Writer.DeclUpdates[Parent].push_back(
1171  ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D));
1172  }
1173  }
1174 }
1175 
1177  VisitRedeclarable(D);
1178  VisitNamedDecl(D);
1179  Record.AddSourceLocation(D->getNamespaceLoc());
1180  Record.AddSourceLocation(D->getTargetNameLoc());
1181  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1182  Record.AddDeclRef(D->getNamespace());
1184 }
1185 
1187  VisitNamedDecl(D);
1188  Record.AddSourceLocation(D->getUsingLoc());
1189  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1190  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1191  Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1192  Record.push_back(D->hasTypename());
1193  Record.AddDeclRef(Context.getInstantiatedFromUsingDecl(D));
1195 }
1196 
1198  Record.push_back(D->NumExpansions);
1199  VisitNamedDecl(D);
1200  Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1201  for (auto *E : D->expansions())
1202  Record.AddDeclRef(E);
1204 }
1205 
1207  VisitRedeclarable(D);
1208  VisitNamedDecl(D);
1209  Record.AddDeclRef(D->getTargetDecl());
1210  Record.push_back(D->getIdentifierNamespace());
1211  Record.AddDeclRef(D->UsingOrNextShadow);
1212  Record.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D));
1214 }
1215 
1218  VisitUsingShadowDecl(D);
1219  Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1220  Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1221  Record.push_back(D->IsVirtual);
1223 }
1224 
1226  VisitNamedDecl(D);
1227  Record.AddSourceLocation(D->getUsingLoc());
1228  Record.AddSourceLocation(D->getNamespaceKeyLocation());
1229  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1230  Record.AddDeclRef(D->getNominatedNamespace());
1231  Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1233 }
1234 
1236  VisitValueDecl(D);
1237  Record.AddSourceLocation(D->getUsingLoc());
1238  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1239  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1240  Record.AddSourceLocation(D->getEllipsisLoc());
1242 }
1243 
1246  VisitTypeDecl(D);
1247  Record.AddSourceLocation(D->getTypenameLoc());
1248  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1249  Record.AddSourceLocation(D->getEllipsisLoc());
1251 }
1252 
1254  VisitRecordDecl(D);
1255 
1256  enum {
1257  CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1258  };
1259  if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1260  Record.push_back(CXXRecTemplate);
1261  Record.AddDeclRef(TemplD);
1262  } else if (MemberSpecializationInfo *MSInfo
1263  = D->getMemberSpecializationInfo()) {
1264  Record.push_back(CXXRecMemberSpecialization);
1265  Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1266  Record.push_back(MSInfo->getTemplateSpecializationKind());
1267  Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1268  } else {
1269  Record.push_back(CXXRecNotTemplate);
1270  }
1271 
1272  Record.push_back(D->isThisDeclarationADefinition());
1274  Record.AddCXXDefinitionData(D);
1275 
1276  // Store (what we currently believe to be) the key function to avoid
1277  // deserializing every method so we can compute it.
1278  if (D->IsCompleteDefinition)
1279  Record.AddDeclRef(Context.getCurrentKeyFunction(D));
1280 
1282 }
1283 
1285  VisitFunctionDecl(D);
1286  if (D->isCanonicalDecl()) {
1287  Record.push_back(D->size_overridden_methods());
1288  for (const CXXMethodDecl *MD : D->overridden_methods())
1289  Record.AddDeclRef(MD);
1290  } else {
1291  // We only need to record overridden methods once for the canonical decl.
1292  Record.push_back(0);
1293  }
1294 
1295  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1296  D->getFirstDecl() == D->getMostRecentDecl() &&
1297  !D->isInvalidDecl() &&
1298  !D->hasAttrs() &&
1301  !D->hasExtInfo() &&
1302  !D->hasInheritedPrototype() &&
1303  D->hasWrittenPrototype())
1304  AbbrevToUse = Writer.getDeclCXXMethodAbbrev();
1305 
1307 }
1308 
1310  if (auto Inherited = D->getInheritedConstructor()) {
1311  Record.AddDeclRef(Inherited.getShadowDecl());
1312  Record.AddDeclRef(Inherited.getConstructor());
1314  } else {
1316  }
1317 
1318  VisitCXXMethodDecl(D);
1319 
1320  Code = D->isInheritingConstructor()
1323 }
1324 
1326  VisitCXXMethodDecl(D);
1327 
1328  Record.AddDeclRef(D->getOperatorDelete());
1329  if (D->getOperatorDelete())
1330  Record.AddStmt(D->getOperatorDeleteThisArg());
1331 
1333 }
1334 
1336  VisitCXXMethodDecl(D);
1338 }
1339 
1341  VisitDecl(D);
1342  Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1343  ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1344  Record.push_back(!IdentifierLocs.empty());
1345  if (IdentifierLocs.empty()) {
1346  Record.AddSourceLocation(D->getLocEnd());
1347  Record.push_back(1);
1348  } else {
1349  for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1350  Record.AddSourceLocation(IdentifierLocs[I]);
1351  Record.push_back(IdentifierLocs.size());
1352  }
1353  // Note: the number of source locations must always be the last element in
1354  // the record.
1356 }
1357 
1359  VisitDecl(D);
1360  Record.AddSourceLocation(D->getColonLoc());
1362 }
1363 
1365  // Record the number of friend type template parameter lists here
1366  // so as to simplify memory allocation during deserialization.
1367  Record.push_back(D->NumTPLists);
1368  VisitDecl(D);
1369  bool hasFriendDecl = D->Friend.is<NamedDecl*>();
1370  Record.push_back(hasFriendDecl);
1371  if (hasFriendDecl)
1372  Record.AddDeclRef(D->getFriendDecl());
1373  else
1374  Record.AddTypeSourceInfo(D->getFriendType());
1375  for (unsigned i = 0; i < D->NumTPLists; ++i)
1376  Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1377  Record.AddDeclRef(D->getNextFriend());
1378  Record.push_back(D->UnsupportedFriend);
1379  Record.AddSourceLocation(D->FriendLoc);
1381 }
1382 
1384  VisitDecl(D);
1385  Record.push_back(D->getNumTemplateParameters());
1386  for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1387  Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1388  Record.push_back(D->getFriendDecl() != nullptr);
1389  if (D->getFriendDecl())
1390  Record.AddDeclRef(D->getFriendDecl());
1391  else
1392  Record.AddTypeSourceInfo(D->getFriendType());
1393  Record.AddSourceLocation(D->getFriendLoc());
1395 }
1396 
1398  VisitNamedDecl(D);
1399 
1400  Record.AddDeclRef(D->getTemplatedDecl());
1401  Record.AddTemplateParameterList(D->getTemplateParameters());
1402 }
1403 
1405  VisitRedeclarable(D);
1406 
1407  // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1408  // getCommonPtr() can be used while this is still initializing.
1409  if (D->isFirstDecl()) {
1410  // This declaration owns the 'common' pointer, so serialize that data now.
1411  Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1413  Record.push_back(D->isMemberSpecialization());
1414  }
1415 
1416  VisitTemplateDecl(D);
1417  Record.push_back(D->getIdentifierNamespace());
1418 }
1419 
1421  VisitRedeclarableTemplateDecl(D);
1422 
1423  if (D->isFirstDecl())
1424  AddTemplateSpecializations(D);
1426 }
1427 
1430  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1431 
1432  VisitCXXRecordDecl(D);
1433 
1434  llvm::PointerUnion<ClassTemplateDecl *,
1437  if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1438  Record.AddDeclRef(InstFromD);
1439  } else {
1440  Record.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>());
1441  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1442  }
1443 
1444  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1445  Record.AddSourceLocation(D->getPointOfInstantiation());
1446  Record.push_back(D->getSpecializationKind());
1447  Record.push_back(D->isCanonicalDecl());
1448 
1449  if (D->isCanonicalDecl()) {
1450  // When reading, we'll add it to the folding set of the following template.
1451  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1452  }
1453 
1454  // Explicit info.
1455  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1456  if (D->getTypeAsWritten()) {
1457  Record.AddSourceLocation(D->getExternLoc());
1458  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1459  }
1460 
1462 }
1463 
1466  VisitClassTemplateSpecializationDecl(D);
1467 
1468  Record.AddTemplateParameterList(D->getTemplateParameters());
1469  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1470 
1471  // These are read/set from/to the first declaration.
1472  if (D->getPreviousDecl() == nullptr) {
1473  Record.AddDeclRef(D->getInstantiatedFromMember());
1474  Record.push_back(D->isMemberSpecialization());
1475  }
1476 
1478 }
1479 
1481  VisitRedeclarableTemplateDecl(D);
1482 
1483  if (D->isFirstDecl())
1484  AddTemplateSpecializations(D);
1486 }
1487 
1490  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1491 
1492  VisitVarDecl(D);
1493 
1494  llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
1495  InstFrom = D->getSpecializedTemplateOrPartial();
1496  if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
1497  Record.AddDeclRef(InstFromD);
1498  } else {
1499  Record.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>());
1500  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1501  }
1502 
1503  // Explicit info.
1504  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1505  if (D->getTypeAsWritten()) {
1506  Record.AddSourceLocation(D->getExternLoc());
1507  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1508  }
1509 
1510  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1511  Record.AddSourceLocation(D->getPointOfInstantiation());
1512  Record.push_back(D->getSpecializationKind());
1513  Record.push_back(D->IsCompleteDefinition);
1514  Record.push_back(D->isCanonicalDecl());
1515 
1516  if (D->isCanonicalDecl()) {
1517  // When reading, we'll add it to the folding set of the following template.
1518  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1519  }
1520 
1522 }
1523 
1526  VisitVarTemplateSpecializationDecl(D);
1527 
1528  Record.AddTemplateParameterList(D->getTemplateParameters());
1529  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1530 
1531  // These are read/set from/to the first declaration.
1532  if (D->getPreviousDecl() == nullptr) {
1533  Record.AddDeclRef(D->getInstantiatedFromMember());
1534  Record.push_back(D->isMemberSpecialization());
1535  }
1536 
1538 }
1539 
1542  VisitDecl(D);
1543  Record.AddDeclRef(D->getSpecialization());
1545 }
1546 
1547 
1549  VisitRedeclarableTemplateDecl(D);
1550 
1551  if (D->isFirstDecl())
1552  AddTemplateSpecializations(D);
1554 }
1555 
1557  VisitTypeDecl(D);
1558 
1559  Record.push_back(D->wasDeclaredWithTypename());
1560 
1561  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1563  Record.push_back(OwnsDefaultArg);
1564  if (OwnsDefaultArg)
1565  Record.AddTypeSourceInfo(D->getDefaultArgumentInfo());
1566 
1568 }
1569 
1571  // For an expanded parameter pack, record the number of expansion types here
1572  // so that it's easier for deserialization to allocate the right amount of
1573  // memory.
1574  if (D->isExpandedParameterPack())
1575  Record.push_back(D->getNumExpansionTypes());
1576 
1577  VisitDeclaratorDecl(D);
1578  // TemplateParmPosition.
1579  Record.push_back(D->getDepth());
1580  Record.push_back(D->getPosition());
1581 
1582  if (D->isExpandedParameterPack()) {
1583  for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
1584  Record.AddTypeRef(D->getExpansionType(I));
1585  Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
1586  }
1587 
1589  } else {
1590  // Rest of NonTypeTemplateParmDecl.
1591  Record.push_back(D->isParameterPack());
1592  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1594  Record.push_back(OwnsDefaultArg);
1595  if (OwnsDefaultArg)
1596  Record.AddStmt(D->getDefaultArgument());
1598  }
1599 }
1600 
1602  // For an expanded parameter pack, record the number of expansion types here
1603  // so that it's easier for deserialization to allocate the right amount of
1604  // memory.
1605  if (D->isExpandedParameterPack())
1606  Record.push_back(D->getNumExpansionTemplateParameters());
1607 
1608  VisitTemplateDecl(D);
1609  // TemplateParmPosition.
1610  Record.push_back(D->getDepth());
1611  Record.push_back(D->getPosition());
1612 
1613  if (D->isExpandedParameterPack()) {
1614  for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
1615  I != N; ++I)
1616  Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
1618  } else {
1619  // Rest of TemplateTemplateParmDecl.
1620  Record.push_back(D->isParameterPack());
1621  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1623  Record.push_back(OwnsDefaultArg);
1624  if (OwnsDefaultArg)
1625  Record.AddTemplateArgumentLoc(D->getDefaultArgument());
1627  }
1628 }
1629 
1631  VisitRedeclarableTemplateDecl(D);
1633 }
1634 
1636  VisitDecl(D);
1637  Record.AddStmt(D->getAssertExpr());
1638  Record.push_back(D->isFailed());
1639  Record.AddStmt(D->getMessage());
1640  Record.AddSourceLocation(D->getRParenLoc());
1642 }
1643 
1644 /// Emit the DeclContext part of a declaration context decl.
1646  Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC));
1647  Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC));
1648 }
1649 
1651  assert(IsLocalDecl(D) && "expected a local declaration");
1652 
1653  const Decl *Canon = D->getCanonicalDecl();
1654  if (IsLocalDecl(Canon))
1655  return Canon;
1656 
1657  const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
1658  if (CacheEntry)
1659  return CacheEntry;
1660 
1661  for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
1662  if (IsLocalDecl(Redecl))
1663  D = Redecl;
1664  return CacheEntry = D;
1665 }
1666 
1667 template <typename T>
1669  T *First = D->getFirstDecl();
1670  T *MostRecent = First->getMostRecentDecl();
1671  T *DAsT = static_cast<T *>(D);
1672  if (MostRecent != First) {
1673  assert(isRedeclarableDeclKind(DAsT->getKind()) &&
1674  "Not considered redeclarable?");
1675 
1676  Record.AddDeclRef(First);
1677 
1678  // Write out a list of local redeclarations of this declaration if it's the
1679  // first local declaration in the chain.
1680  const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
1681  if (DAsT == FirstLocal) {
1682  // Emit a list of all imported first declarations so that we can be sure
1683  // that all redeclarations visible to this module are before D in the
1684  // redecl chain.
1685  unsigned I = Record.size();
1686  Record.push_back(0);
1687  if (Writer.Chain)
1688  AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
1689  // This is the number of imported first declarations + 1.
1690  Record[I] = Record.size() - I;
1691 
1692  // Collect the set of local redeclarations of this declaration, from
1693  // newest to oldest.
1694  ASTWriter::RecordData LocalRedecls;
1695  ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
1696  for (const Decl *Prev = FirstLocal->getMostRecentDecl();
1697  Prev != FirstLocal; Prev = Prev->getPreviousDecl())
1698  if (!Prev->isFromASTFile())
1699  LocalRedeclWriter.AddDeclRef(Prev);
1700 
1701  // If we have any redecls, write them now as a separate record preceding
1702  // the declaration itself.
1703  if (LocalRedecls.empty())
1704  Record.push_back(0);
1705  else
1706  Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
1707  } else {
1708  Record.push_back(0);
1709  Record.AddDeclRef(FirstLocal);
1710  }
1711 
1712  // Make sure that we serialize both the previous and the most-recent
1713  // declarations, which (transitively) ensures that all declarations in the
1714  // chain get serialized.
1715  //
1716  // FIXME: This is not correct; when we reach an imported declaration we
1717  // won't emit its previous declaration.
1718  (void)Writer.GetDeclRef(D->getPreviousDecl());
1719  (void)Writer.GetDeclRef(MostRecent);
1720  } else {
1721  // We use the sentinel value 0 to indicate an only declaration.
1722  Record.push_back(0);
1723  }
1724 }
1725 
1727  Record.push_back(D->varlist_size());
1728  VisitDecl(D);
1729  for (auto *I : D->varlists())
1730  Record.AddStmt(I);
1732 }
1733 
1735  VisitValueDecl(D);
1736  Record.AddSourceLocation(D->getLocStart());
1737  Record.AddStmt(D->getCombiner());
1738  Record.AddStmt(D->getInitializer());
1739  Record.push_back(D->getInitializerKind());
1740  Record.AddDeclRef(D->getPrevDeclInScope());
1742 }
1743 
1745  VisitVarDecl(D);
1747 }
1748 
1749 //===----------------------------------------------------------------------===//
1750 // ASTWriter Implementation
1751 //===----------------------------------------------------------------------===//
1752 
1753 void ASTWriter::WriteDeclAbbrevs() {
1754  using namespace llvm;
1755 
1756  std::shared_ptr<BitCodeAbbrev> Abv;
1757 
1758  // Abbreviation for DECL_FIELD
1759  Abv = std::make_shared<BitCodeAbbrev>();
1760  Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
1761  // Decl
1762  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1763  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1764  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1765  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1766  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1767  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1768  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1769  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1770  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1771  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1772  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1773  // NamedDecl
1774  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1775  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1776  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1777  // ValueDecl
1778  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1779  // DeclaratorDecl
1780  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1781  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1782  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
1783  // FieldDecl
1784  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1785  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1786  // Type Source Info
1787  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1788  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1789  DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
1790 
1791  // Abbreviation for DECL_OBJC_IVAR
1792  Abv = std::make_shared<BitCodeAbbrev>();
1793  Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
1794  // Decl
1795  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1796  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1797  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1798  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1799  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1800  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1801  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1802  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1803  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1804  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1805  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1806  // NamedDecl
1807  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1808  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1809  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1810  // ValueDecl
1811  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1812  // DeclaratorDecl
1813  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1814  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1815  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
1816  // FieldDecl
1817  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1818  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1819  // ObjC Ivar
1820  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
1821  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
1822  // Type Source Info
1823  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1824  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1825  DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1826 
1827  // Abbreviation for DECL_ENUM
1828  Abv = std::make_shared<BitCodeAbbrev>();
1829  Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
1830  // Redeclarable
1831  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1832  // Decl
1833  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1834  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1835  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1836  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1837  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1838  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1839  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1840  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1841  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1842  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1843  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1844  // NamedDecl
1845  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1846  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1847  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1848  // TypeDecl
1849  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1850  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1851  // TagDecl
1852  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1853  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1854  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1855  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1856  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1857  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1858  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1859  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1860  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1861  // EnumDecl
1862  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
1863  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
1864  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
1865  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumPositiveBits
1866  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumNegativeBits
1867  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScoped
1868  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScopedUsingClassTag
1869  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isFixed
1870  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));// ODRHash
1871  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
1872  // DC
1873  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1874  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1875  DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
1876 
1877  // Abbreviation for DECL_RECORD
1878  Abv = std::make_shared<BitCodeAbbrev>();
1879  Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
1880  // Redeclarable
1881  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1882  // Decl
1883  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1884  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1885  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1886  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1887  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1888  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1889  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1890  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1891  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1892  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1893  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1894  // NamedDecl
1895  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1896  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1897  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1898  // TypeDecl
1899  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1900  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1901  // TagDecl
1902  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1903  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1904  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1905  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1906  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1907  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1908  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1909  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1910  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1911  // RecordDecl
1912  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember
1913  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
1914  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
1915  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
1916 
1917  // isNonTrivialToPrimitiveDefaultInitialize
1918  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1919  // isNonTrivialToPrimitiveCopy
1920  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1921  // isNonTrivialToPrimitiveDestroy
1922  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1923  // isParamDestroyedInCallee
1924  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1925  // getArgPassingRestrictions
1926  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
1927 
1928  // DC
1929  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1930  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1931  DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
1932 
1933  // Abbreviation for DECL_PARM_VAR
1934  Abv = std::make_shared<BitCodeAbbrev>();
1935  Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
1936  // Redeclarable
1937  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1938  // Decl
1939  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1940  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1941  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1942  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1943  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1944  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1945  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1946  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1947  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1948  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1949  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1950  // NamedDecl
1951  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1952  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1953  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1954  // ValueDecl
1955  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1956  // DeclaratorDecl
1957  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1958  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1959  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
1960  // VarDecl
1961  Abv->Add(BitCodeAbbrevOp(0)); // SClass
1962  Abv->Add(BitCodeAbbrevOp(0)); // TSCSpec
1963  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1964  Abv->Add(BitCodeAbbrevOp(0)); // Linkage
1965  Abv->Add(BitCodeAbbrevOp(0)); // HasInit
1966  Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo
1967  // ParmVarDecl
1968  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsObjCMethodParameter
1969  Abv->Add(BitCodeAbbrevOp(0)); // ScopeDepth
1970  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
1971  Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier
1972  Abv->Add(BitCodeAbbrevOp(0)); // KNRPromoted
1973  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg
1974  Abv->Add(BitCodeAbbrevOp(0)); // HasUninstantiatedDefaultArg
1975  // Type Source Info
1976  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1977  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1978  DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1979 
1980  // Abbreviation for DECL_TYPEDEF
1981  Abv = std::make_shared<BitCodeAbbrev>();
1982  Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
1983  // Redeclarable
1984  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1985  // Decl
1986  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1987  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1988  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1989  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1990  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1991  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isUsed
1992  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isReferenced
1993  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1994  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // C++ AccessSpecifier
1995  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1996  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1997  // NamedDecl
1998  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1999  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2000  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2001  // TypeDecl
2002  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2003  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2004  // TypedefDecl
2005  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2006  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2007  DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2008 
2009  // Abbreviation for DECL_VAR
2010  Abv = std::make_shared<BitCodeAbbrev>();
2011  Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2012  // Redeclarable
2013  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2014  // Decl
2015  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2016  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
2017  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
2018  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
2019  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
2020  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
2021  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
2022  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
2023  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
2024  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
2025  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2026  // NamedDecl
2027  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2028  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2029  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2030  // ValueDecl
2031  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2032  // DeclaratorDecl
2033  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2034  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2035  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2036  // VarDecl
2037  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
2038  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
2039  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
2040  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
2041  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
2042  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
2043  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
2044  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isObjCForDecl
2045  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
2046  Abv->Add(BitCodeAbbrevOp(0)); // isInline
2047  Abv->Add(BitCodeAbbrevOp(0)); // isInlineSpecified
2048  Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
2049  Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
2050  Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
2051  Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind
2052  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
2053  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
2054  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
2055  // Type Source Info
2056  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2057  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2058  DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2059 
2060  // Abbreviation for DECL_CXX_METHOD
2061  Abv = std::make_shared<BitCodeAbbrev>();
2062  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD));
2063  // RedeclarableDecl
2064  Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2065  // Decl
2066  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2067  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
2068  Abv->Add(BitCodeAbbrevOp(0)); // Invalid
2069  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
2070  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Implicit
2071  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Used
2072  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Referenced
2073  Abv->Add(BitCodeAbbrevOp(0)); // InObjCContainer
2074  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Access
2075  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModulePrivate
2076  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2077  // NamedDecl
2078  Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2079  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2080  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2081  // ValueDecl
2082  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2083  // DeclaratorDecl
2084  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2085  Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2086  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2087  // FunctionDecl
2088  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2089  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass
2090  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline
2091  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified
2092  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitSpecified
2093  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten
2094  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure
2095  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto
2096  Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto
2097  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted
2098  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial
2099  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // TrivialForCall
2100  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
2101  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
2102  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
2103  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
2104  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry
2105  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
2106  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // MultiVersion
2107  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed
2108  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
2109  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2110  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2111  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind
2112  // This Array slurps the rest of the record. Fortunately we want to encode
2113  // (nearly) all the remaining (variable number of) fields in the same way.
2114  //
2115  // This is the function template information if any, then
2116  // NumParams and Params[] from FunctionDecl, and
2117  // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2118  //
2119  // Add an AbbrevOp for 'size then elements' and use it here.
2120  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2121  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2122  DeclCXXMethodAbbrev = Stream.EmitAbbrev(std::move(Abv));
2123 
2124  // Abbreviation for EXPR_DECL_REF
2125  Abv = std::make_shared<BitCodeAbbrev>();
2126  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2127  //Stmt
2128  //Expr
2129  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2130  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2131  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2132  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2133  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2134  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2135  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2136  //DeclRefExpr
2137  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HasQualifier
2138  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //GetDeclFound
2139  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ExplicitTemplateArgs
2140  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HadMultipleCandidates
2141  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2142  1)); // RefersToEnclosingVariableOrCapture
2143  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2144  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2145  DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2146 
2147  // Abbreviation for EXPR_INTEGER_LITERAL
2148  Abv = std::make_shared<BitCodeAbbrev>();
2149  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2150  //Stmt
2151  //Expr
2152  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2153  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2154  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2155  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2156  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2157  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2158  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2159  //Integer Literal
2160  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2161  Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2162  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2163  IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2164 
2165  // Abbreviation for EXPR_CHARACTER_LITERAL
2166  Abv = std::make_shared<BitCodeAbbrev>();
2167  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2168  //Stmt
2169  //Expr
2170  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2171  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2172  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2173  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2174  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2175  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2176  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2177  //Character Literal
2178  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2179  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2180  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2181  CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2182 
2183  // Abbreviation for EXPR_IMPLICIT_CAST
2184  Abv = std::make_shared<BitCodeAbbrev>();
2185  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2186  // Stmt
2187  // Expr
2188  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2189  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2190  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2191  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2192  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2193  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2194  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2195  // CastExpr
2196  Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2197  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind
2198  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // PartOfExplicitCast
2199  // ImplicitCastExpr
2200  ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2201 
2202  Abv = std::make_shared<BitCodeAbbrev>();
2203  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2204  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2205  DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2206 
2207  Abv = std::make_shared<BitCodeAbbrev>();
2208  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2209  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2210  DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2211 }
2212 
2213 /// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2214 /// consumers of the AST.
2215 ///
2216 /// Such decls will always be deserialized from the AST file, so we would like
2217 /// this to be as restrictive as possible. Currently the predicate is driven by
2218 /// code generation requirements, if other clients have a different notion of
2219 /// what is "required" then we may have to consider an alternate scheme where
2220 /// clients can iterate over the top-level decls and get information on them,
2221 /// without necessary deserializing them. We could explicitly require such
2222 /// clients to use a separate API call to "realize" the decl. This should be
2223 /// relatively painless since they would presumably only do it for top-level
2224 /// decls.
2225 static bool isRequiredDecl(const Decl *D, ASTContext &Context,
2226  bool WritingModule) {
2227  // An ObjCMethodDecl is never considered as "required" because its
2228  // implementation container always is.
2229 
2230  // File scoped assembly or obj-c or OMP declare target implementation must be
2231  // seen.
2232  if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D) ||
2233  D->hasAttr<OMPDeclareTargetDeclAttr>())
2234  return true;
2235 
2236  if (WritingModule && (isa<VarDecl>(D) || isa<ImportDecl>(D))) {
2237  // These declarations are part of the module initializer, and are emitted
2238  // if and when the module is imported, rather than being emitted eagerly.
2239  return false;
2240  }
2241 
2242  return Context.DeclMustBeEmitted(D);
2243 }
2244 
2245 void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
2246  PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
2247  "serializing");
2248 
2249  // Determine the ID for this declaration.
2251  assert(!D->isFromASTFile() && "should not be emitting imported decl");
2252  serialization::DeclID &IDR = DeclIDs[D];
2253  if (IDR == 0)
2254  IDR = NextDeclID++;
2255 
2256  ID = IDR;
2257 
2258  assert(ID >= FirstDeclID && "invalid decl ID");
2259 
2260  RecordData Record;
2261  ASTDeclWriter W(*this, Context, Record);
2262 
2263  // Build a record for this declaration
2264  W.Visit(D);
2265 
2266  // Emit this declaration to the bitstream.
2267  uint64_t Offset = W.Emit(D);
2268 
2269  // Record the offset for this declaration
2270  SourceLocation Loc = D->getLocation();
2271  unsigned Index = ID - FirstDeclID;
2272  if (DeclOffsets.size() == Index)
2273  DeclOffsets.push_back(DeclOffset(Loc, Offset));
2274  else if (DeclOffsets.size() < Index) {
2275  // FIXME: Can/should this happen?
2276  DeclOffsets.resize(Index+1);
2277  DeclOffsets[Index].setLocation(Loc);
2278  DeclOffsets[Index].BitOffset = Offset;
2279  } else {
2280  llvm_unreachable("declarations should be emitted in ID order");
2281  }
2282 
2283  SourceManager &SM = Context.getSourceManager();
2284  if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
2285  associateDeclWithFile(D, ID);
2286 
2287  // Note declarations that should be deserialized eagerly so that we can add
2288  // them to a record in the AST file later.
2289  if (isRequiredDecl(D, Context, WritingModule))
2290  EagerlyDeserializedDecls.push_back(ID);
2291 }
2292 
2294  // Switch case IDs are per function body.
2295  Writer->ClearSwitchCaseIDs();
2296 
2297  assert(FD->doesThisDeclarationHaveABody());
2298  bool ModulesCodegen = false;
2299  if (Writer->WritingModule && !FD->isDependentContext()) {
2301  if (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
2302  // When building a C++ Modules TS module interface unit, a strong
2303  // definition in the module interface is provided by the compilation of
2304  // that module interface unit, not by its users. (Inline functions are
2305  // still emitted in module users.)
2306  Linkage = Writer->Context->GetGVALinkageForFunction(FD);
2307  ModulesCodegen = *Linkage == GVA_StrongExternal;
2308  }
2309  if (Writer->Context->getLangOpts().ModulesCodegen) {
2310  // Under -fmodules-codegen, codegen is performed for all non-internal,
2311  // non-always_inline functions.
2312  if (!FD->hasAttr<AlwaysInlineAttr>()) {
2313  if (!Linkage)
2314  Linkage = Writer->Context->GetGVALinkageForFunction(FD);
2315  ModulesCodegen = *Linkage != GVA_Internal;
2316  }
2317  }
2318  }
2319  Record->push_back(ModulesCodegen);
2320  if (ModulesCodegen)
2321  Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));
2322  if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
2323  Record->push_back(CD->getNumCtorInitializers());
2324  if (CD->getNumCtorInitializers())
2325  AddCXXCtorInitializers(
2326  llvm::makeArrayRef(CD->init_begin(), CD->init_end()));
2327  }
2328  AddStmt(FD->getBody());
2329 }
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition: Decl.cpp:2426
SourceLocation getGetterNameLoc() const
Definition: DeclObjC.h:926
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1454
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1481
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition: Decl.h:2702
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
Definition: DeclTemplate.h:722
const Type * getTypeForDecl() const
Definition: DeclObjC.h:1940
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3209
Represents a function declaration or definition.
Definition: Decl.h:1716
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Definition: DeclTemplate.h:550
void VisitAccessSpecDecl(AccessSpecDecl *D)
unsigned getNumTemplateArgs() const
Returns the number of explicit template arguments that were given.
Definition: DeclTemplate.h:719
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
Definition: Decl.h:1288
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
Definition: DeclTemplate.h:581
protocol_range protocols() const
Definition: DeclObjC.h:1387
void VisitStaticAssertDecl(StaticAssertDecl *D)
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:759
void VisitCXXMethodDecl(CXXMethodDecl *D)
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
Definition: ASTCommon.cpp:313
A (possibly-)qualified type.
Definition: Type.h:655
Static storage duration.
Definition: Specifiers.h:280
const char * getDeclKindName() const
Definition: DeclBase.cpp:123
unsigned param_size() const
Definition: DeclObjC.h:381
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2346
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3638
void VisitRedeclarable(Redeclarable< T > *D)
void VisitEmptyDecl(EmptyDecl *D)
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1551
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2849
bool isObjCMethodParameter() const
Definition: Decl.h:1578
void RegisterTemplateSpecialization(const Decl *Template, const Decl *Specialization)
Ensure that this template specialization is associated with the specified template on reload...
void VisitTypedefNameDecl(TypedefNameDecl *D)
SourceRange getBraceRange() const
Definition: Decl.h:3147
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1517
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
void VisitExportDecl(ExportDecl *D)
bool isMemberSpecialization()
Determines whether this class template partial specialization template was a specialization of a memb...
Expr * getBitWidth() const
Definition: Decl.h:2623
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2741
void VisitCXXRecordDecl(CXXRecordDecl *D)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1019
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:2974
Defines the SourceManager interface.
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1535
bool hasVolatileMember() const
Definition: Decl.h:3683
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
Definition: Decl.cpp:2304
const Type * getTypeForDecl() const
Definition: Decl.h:2853
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
unsigned getNumCaptures() const
Returns the number of captured variables.
Definition: Decl.h:3986
An ImplicitCastExpr record.
Definition: ASTBitCodes.h:1671
bool isNothrow() const
Definition: Decl.cpp:4355
IdentifierInfo * getGetterId() const
Definition: DeclCXX.h:3941
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1472
ThreadStorageClassSpecifier getTSCSpec() const
Definition: Decl.h:1028
Defines the C++ template declaration subclasses.
StringRef P
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:453
bool hasWrittenPrototype() const
Definition: Decl.h:2082
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Definition: DeclBase.h:960
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
Expr * getSetterCXXAssignment() const
Definition: DeclObjC.h:2879
void VisitTranslationUnitDecl(TranslationUnitDecl *D)
A record that stores the set of declarations that are lexically stored within a given DeclContext...
Definition: ASTBitCodes.h:1379
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
Definition: DeclCXX.h:154
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement...
Definition: Decl.h:1334
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
Represents an empty-declaration.
Definition: Decl.h:4253
ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, ASTWriter::RecordDataImpl &Record)
Expr * getOperatorDeleteThisArg() const
Definition: DeclCXX.h:2736
Declaration of a variable template.
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
Represent a C++ namespace.
Definition: Decl.h:514
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1336
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction...
Definition: DeclObjC.h:2680
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field)
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument&#39;s source information, if any.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclBase.h:414
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:799
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2477
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition: Decl.h:2669
size_t param_size() const
Definition: Decl.h:2247
ArrayRef< Decl > getPartialSpecializations(FunctionTemplateDecl::Common *)
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
Definition: ASTWriter.h:807
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition: DeclCXX.h:3120
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3171
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a #pragma comment line.
Definition: Decl.h:139
A ClassTemplateDecl record.
Definition: ASTBitCodes.h:1457
A PragmaDetectMismatchDecl record.
Definition: ASTBitCodes.h:1532
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1418
void VisitBlockDecl(BlockDecl *D)
void VisitImplicitParamDecl(ImplicitParamDecl *D)
unsigned getDepth() const
Get the nesting depth of the template parameter.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:54
unsigned getODRHash()
Definition: Decl.cpp:3973
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
Represents a variable declaration or definition.
Definition: Decl.h:814
Declaration of a redeclarable template.
Definition: DeclTemplate.h:737
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
An OMPCapturedExprDecl record.
Definition: ASTBitCodes.h:1526
void AddFunctionDefinition(const FunctionDecl *FD)
Add a definition for the given function to the queue of statements to emit.
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition: Decl.h:3504
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1406
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:553
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
bool hasInheritedDefaultArg() const
Definition: Decl.h:1661
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
Definition: ASTBitCodes.h:1507
void VisitIndirectFieldDecl(IndirectFieldDecl *D)
bool isInvalidDecl() const
Definition: DeclBase.h:549
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
unsigned getContextParamPosition() const
Definition: Decl.h:4111
protocol_range protocols() const
Definition: DeclObjC.h:2150
unsigned IsExplicitSpecified
Definition: Decl.h:1745
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1484
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:630
Represents a parameter to a function.
Definition: Decl.h:1535
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Definition: Linkage.h:24
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:1312
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
Provides information about a dependent function-template specialization declaration.
Definition: DeclTemplate.h:672
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2710
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition: Decl.h:1356
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
A CXXConstructorDecl record for an inherited constructor.
Definition: ASTBitCodes.h:1439
Represents a struct/union/class.
Definition: Decl.h:3570
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2869
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:297
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:85
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
Definition: Decl.h:3458
Represents a class template specialization, which refers to a class template with a given set of temp...
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:124
StringLiteral * getMessage()
Definition: DeclCXX.h:3780
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2717
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2871
CXXRecordDecl * getPreviousDecl()
Definition: DeclCXX.h:738
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:150
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:575
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition: DeclCXX.h:3101
Represents a member of a struct/union/class.
Definition: Decl.h:2534
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
const llvm::APSInt & getInitVal() const
Definition: Decl.h:2762
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1588
StringRef getValue() const
Definition: Decl.h:197
bool isDefined() const
Definition: DeclObjC.h:464
InitKind getInitializerKind() const
Get initializer kind.
Definition: DeclOpenMP.h:157
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:944
NamedDecl * getFriendDecl() const
If this friend declaration doesn&#39;t name a type, return the inner declaration.
Definition: DeclFriend.h:139
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition: DeclCXX.h:2673
void VisitDecompositionDecl(DecompositionDecl *D)
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.h:3942
void VisitParmVarDecl(ParmVarDecl *D)
Represents an access specifier followed by colon &#39;:&#39;.
Definition: DeclCXX.h:132
Declaration of a function specialization at template class scope.
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration&#39;s previous declaration was declared in the same block ...
Definition: Decl.h:1402
TypeSourceInfo * getFriendType() const
If this friend declaration names a templated type (or a dependent member type of a templated type)...
TypeSourceInfo * getSignatureAsWritten() const
Definition: Decl.h:3946
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1499
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2231
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:508
Represents a C++ using-declaration.
Definition: DeclCXX.h:3360
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Definition: DeclTemplate.h:540
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2719
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:3883
void VisitLabelDecl(LabelDecl *LD)
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Definition: DeclOpenMP.h:154
void VisitObjCProtocolDecl(ObjCProtocolDecl *D)
bool hasNonZeroConstructors() const
Do any of the ivars of this class (not counting its base classes) require construction other than zer...
Definition: DeclObjC.h:2675
void append(InputIterator begin, InputIterator end)
Definition: ASTWriter.h:796
void VisitClassTemplateDecl(ClassTemplateDecl *D)
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:2662
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:988
TagKind getTagKind() const
Definition: Decl.h:3230
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:422
void VisitTypedefDecl(TypedefDecl *D)
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1448
void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D)
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion: ...
Definition: Decl.h:1609
uint32_t Offset
Definition: CacheTokens.cpp:43
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes, if any.
Definition: Decl.cpp:4415
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void VisitUsingShadowDecl(UsingShadowDecl *D)
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1409
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.cpp:3284
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:879
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclObjC.h:323
ArrayRef< NamedDecl * > chain() const
Definition: Decl.h:2802
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1412
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:859
A DecompositionDecl record.
Definition: ASTBitCodes.h:1357
Represents a declaration of a type.
Definition: Decl.h:2829
SourceLocation RAngleLoc
The source location of the right angle bracket (&#39;>&#39;).
Definition: TemplateBase.h:615
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
Definition: Decl.h:3468
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
Definition: Decl.h:3551
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or nullptr if this template w...
Definition: DeclTemplate.h:926
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1383
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3399
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1805
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
void VisitBindingDecl(BindingDecl *D)
TemplateParameterList * getTemplateParameterList(unsigned i) const
const Expr * getInitExpr() const
Definition: Decl.h:2760
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2852
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition: DeclFriend.h:132
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1460
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition: Decl.h:3177
SourceLocation getExternLoc() const
Definition: DeclCXX.h:2881
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2085
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
Definition: DeclBase.h:828
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
ArrayRef< SourceLocation > getIdentifierLocs() const
Retrieves the locations of each of the identifiers that make up the complete module name in the impor...
Definition: Decl.cpp:4565
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:952
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4037
Represents an ObjC class declaration.
Definition: DeclObjC.h:1193
Represents a linkage specification.
Definition: DeclCXX.h:2823
QualType getReturnType() const
Definition: DeclObjC.h:363
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
A binding in a decomposition declaration.
Definition: DeclCXX.h:3803
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
Definition: Decl.cpp:3269
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:877
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:1135
ArgPassingKind getArgPassingRestrictions() const
Definition: Decl.h:3725
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Definition: Decl.h:3675
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:4186
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:3785
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition: Decl.h:1080
StringRef getArg() const
Definition: Decl.h:164
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2780
NodeId Parent
Definition: ASTDiff.cpp:192
void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
bool hasAttr() const
Definition: DeclBase.h:538
void VisitObjCContainerDecl(ObjCContainerDecl *D)
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclObjC.h:2836
RecordDecl * getMostRecentDecl()
Definition: Decl.h:3654
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:2994
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1416
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:2856
SourceLocation getTypenameLoc() const
Returns the source location of the &#39;typename&#39; keyword.
Definition: DeclCXX.h:3707
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:689
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
Definition: Decl.h:3434
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1430
uint64_t Emit(Decl *D)
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
bool isInlineSpecified() const
Definition: Decl.h:1368
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition: DeclOpenMP.h:147
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1490
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:2922
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1469
static bool classofKind(Kind K)
Definition: DeclObjC.h:2020
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1523
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:432
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:883
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3248
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1582
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3860
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:637
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3400
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1327
unsigned getChainingSize() const
Definition: Decl.h:2808
Selector getSetterName() const
Definition: DeclObjC.h:933
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3498
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1339
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1594
void VisitRecordDecl(RecordDecl *D)
Declaration of a template type parameter.
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D)
TypeSourceInfo * getTypeSourceInfo() const
Definition: DeclObjC.h:846
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:618
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name...
Definition: DeclOpenMP.cpp:76
void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal)
Add to the record the first declaration from each module file that provides a declaration of D...
unsigned getNumParams() const
Definition: Decl.h:4082
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2700
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver&#39;s type...
Definition: DeclObjC.h:306
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:2242
A CXXConstructorDecl record.
Definition: ASTBitCodes.h:1436
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition: Decl.h:570
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition: Decl.h:1306
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:554
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:975
void VisitClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl *D)
void VisitTemplateDecl(TemplateDecl *D)
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
overridden_method_range overridden_methods() const
Definition: DeclCXX.cpp:2132
DeclContext * getDeclContext()
Definition: DeclBase.h:428
void VisitUsingDecl(UsingDecl *D)
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1466
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
EnumDecl * getMostRecentDecl()
Definition: Decl.h:3382
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition: Decl.cpp:3457
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1442
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
unsigned IsCopyDeductionCandidate
[C++17] Only used by CXXDeductionGuideDecl.
Definition: Decl.h:1788
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Definition: ASTBitCodes.h:1503
IdentifierInfo * getSetterId() const
Definition: DeclCXX.h:3943
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists...
A NamespaceAliasDecl record.
Definition: ASTBitCodes.h:1397
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1343
FunctionTemplateDecl * getTemplate(unsigned I) const
Returns the i&#39;th template candidate.
Definition: DeclTemplate.h:708
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
Definition: ASTWriter.h:904
void AddObjCTypeParamList(ObjCTypeParamList *typeParams)
Add an Objective-C type parameter list to the given record.
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
bool isInstanceMethod() const
Definition: DeclObjC.h:454
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
Definition: DeclCXX.cpp:1571
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1040
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1351
StringRef getName() const
Definition: Decl.h:196
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of a (possibly unresolved) using decl from a templat...
Represents a C++ deduction guide declaration.
Definition: DeclCXX.h:1992
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2762
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1303
ImplicitParamDecl * getSelfDecl() const
Definition: DeclObjC.h:446
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1278
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
QualType getType() const
Definition: DeclObjC.h:848
const SourceManager & SM
Definition: Format.cpp:1475
void VisitTagDecl(TagDecl *D)
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1514
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1324
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
CXXMethodDecl * getMostRecentDecl()
Definition: DeclCXX.h:2133
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
static DeclType * getDecl(EntryType *D)
Definition: DeclTemplate.h:758
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:216
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2642
void VisitMSPropertyDecl(MSPropertyDecl *D)
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:1333
void VisitVarTemplateDecl(VarTemplateDecl *D)
AttrVec & getAttrs()
Definition: DeclBase.h:480
bool isNonTrivialToPrimitiveDestroy() const
Definition: Decl.h:3710
bool hasAttrs() const
Definition: DeclBase.h:474
void VisitTypeAliasDecl(TypeAliasDecl *D)
void VisitDeclContext(DeclContext *DC)
Emit the DeclContext part of a declaration context decl.
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2391
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition: DeclObjC.h:377
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
void push_back(uint64_t N)
Minimal vector-like interface.
Definition: ASTWriter.h:794
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition: Decl.h:2086
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclBase.h:409
unsigned protocol_size() const
Definition: DeclObjC.h:2189
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition: DeclCXX.h:2995
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:2126
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:4207
SourceLocation getUsingLoc() const
Returns the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3611
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
Definition: Decl.h:3694
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Definition: DeclTemplate.h:627
const Decl * getFirstLocalDecl(const Decl *D)
Find the first local declaration of a given local redeclarable decl.
An UnresolvedUsingValueDecl record.
Definition: ASTBitCodes.h:1415
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:204
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition: DeclCXX.h:3542
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Definition: DeclTemplate.h:543
Encodes a location in the source.
bool getSynthesize() const
Definition: DeclObjC.h:2012
This represents &#39;#pragma omp declare reduction ...&#39; directive.
Definition: DeclOpenMP.h:102
A record that stores the set of declarations that are visible from a given DeclContext.
Definition: ASTBitCodes.h:1388
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:187
SourceLocation getSuperClassLoc() const
Definition: DeclObjC.h:2712
void VisitObjCImplDecl(ObjCImplDecl *D)
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:2999
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:617
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition: Decl.h:2707
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the &#39;typename&#39; keyword.
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3020
SourceLocation getUsingLoc() const
Return the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3393
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2548
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition: Decl.h:3011
ObjCList - This is a simple template class used to hold various lists of decls etc, which is heavily used by the ObjC front-end.
Definition: DeclObjC.h:83
Represents the declaration of a label.
Definition: Decl.h:468
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3579
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3621
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2676
RedeclarableTemplateDecl::SpecEntryTraits< EntryType >::DeclType * getSpecializationDecl(EntryType &T)
Get the specialization decl from an entry in the specialization list.
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:806
SourceLocation getRParenLoc() const
Definition: Decl.h:3843
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2045
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
void VisitUsingPackDecl(UsingPackDecl *D)
C-style initialization with assignment.
Definition: Decl.h:819
bool isConversionFromLambda() const
Definition: Decl.h:3999
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
A TemplateTypeParmDecl record.
Definition: ASTBitCodes.h:1478
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:223
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:974
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:2969
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2301
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3493
unsigned getNumTemplates() const
Returns the number of function templates that this might be a specialization of.
Definition: DeclTemplate.h:705
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
void VisitCapturedDecl(CapturedDecl *D)
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Definition: DeclObjC.h:2651
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:748
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:702
bool isModed() const
Definition: Decl.h:2918
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:70
unsigned getODRHash()
Returns ODRHash of the function.
Definition: Decl.cpp:3671
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1649
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
Definition: ASTWriter.h:846
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
Definition: DeclBase.cpp:397
void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D)
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2539
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclObjC.h:299
A NamespaceDecl record.
Definition: ASTBitCodes.h:1394
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3754
void VisitPragmaCommentDecl(PragmaCommentDecl *D)
SourceLocation getRBraceLoc() const
Definition: DeclCXX.h:2882
bool hasFlexibleArrayMember() const
Definition: Decl.h:3661
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
Definition: Decl.cpp:99
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2438
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition: Decl.cpp:1062
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4142
protocol_range protocols() const
Definition: DeclObjC.h:2377
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1315
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: Decl.h:1592
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2872
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1445
void VisitFieldDecl(FieldDecl *D)
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2461
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:2494
Dataflow Directional Tag Classes.
void AddTemplateSpecializations(DeclTy *D)
bool isValid() const
Return true if this is a valid SourceLocation object.
void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
Definition: Decl.cpp:2452
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1264
ArrayRef< Capture > captures() const
Definition: Decl.h:3990
PropertyAttributeKind getPropertyAttributesAsWritten() const
Definition: DeclObjC.h:871
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:399
bool isVariadic() const
Definition: Decl.h:3938
void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc.) that is lexically inside an objc container definition.
Definition: DeclBase.h:589
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
Definition: Decl.cpp:2297
SourceLocation getAtLoc() const
Definition: DeclObjC.h:840
void VisitNamedDecl(NamedDecl *D)
Represents a field injected from an anonymous union/struct into the parent scope. ...
Definition: Decl.h:2780
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1463
QualType getUnderlyingType() const
Definition: Decl.h:2927
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:3092
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition: DeclCXX.h:2991
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1289
const Expr * getInit() const
Definition: Decl.h:1219
AccessSpecifier getAccess() const
Definition: DeclBase.h:463
A decomposition declaration.
Definition: DeclCXX.h:3851
bool isEmbeddedInDeclarator() const
Definition: Decl.h:3186
void VisitTypeDecl(TypeDecl *D)
unsigned getNumTemplateParameters() const
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3675
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
Definition: ASTBitCodes.h:1511
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:578
Kind getKind() const
Definition: DeclBase.h:422
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3711
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1421
bool isNonTrivialToPrimitiveCopy() const
Definition: Decl.h:3702
decltype(T::PartialSpecializations) & getPartialSpecializations(T *Common)
Get the list of partial specializations from a template&#39;s common ptr.
Represents an enum.
Definition: Decl.h:3313
SourceLocation LAngleLoc
The source location of the left angle bracket (&#39;<&#39;).
Definition: TemplateBase.h:612
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition: Decl.h:1392
void VisitDeclaratorDecl(DeclaratorDecl *D)
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
Definition: ASTContext.h:1068
SourceLocation getSetterNameLoc() const
Definition: DeclObjC.h:934
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2768
void VisitEnumDecl(EnumDecl *D)
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:69
const FunctionDecl * getOperatorDelete() const
Definition: DeclCXX.h:2732
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1529
void VisitNamespaceDecl(NamespaceDecl *D)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2573
void VisitVarDecl(VarDecl *D)
Expr * getUninstantiatedDefaultArg()
Definition: Decl.cpp:2581
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2171
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C...
Definition: Decl.h:1344
size_t param_size() const
Definition: Decl.h:3965
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:716
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1675
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:4084
bool isParamDestroyedInCallee() const
Definition: Decl.h:3733
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
void VisitFunctionDecl(FunctionDecl *D)
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool hasTypename() const
Return true if the using declaration has &#39;typename&#39;.
Definition: DeclCXX.h:3415
SourceManager & getSourceManager()
Definition: ASTContext.h:651
bool capturesCXXThis() const
Definition: Decl.h:3995
ImplementationControl getImplementationControl() const
Definition: DeclObjC.h:504
static bool classofKind(Kind K)
Definition: DeclCXX.h:1977
void VisitDecl(Decl *D)
SourceRange getAtEndRange() const
Definition: DeclObjC.h:1139
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1585
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
static bool classofKind(Kind K)
Definition: DeclObjC.h:2053
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:2033
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2434
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:3261
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition: Decl.h:2609
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition: Decl.h:3166
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn&#39;t on...
SourceLocation getRBraceLoc() const
Definition: Decl.h:4226
Represents a C++ struct/union/class.
Definition: DeclCXX.h:302
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
Definition: Decl.h:1324
An object for streaming information to a record.
Definition: ASTWriter.h:746
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition: Decl.h:3485
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1966
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:964
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:404
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:608
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:1330
void VisitEnumConstantDecl(EnumConstantDecl *D)
SourceLocation getFriendLoc() const
Retrieves the location of the &#39;friend&#39; keyword.
bool isFailed() const
Definition: DeclCXX.h:3783
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1321
Declaration of a class template.
void VisitCXXConversionDecl(CXXConversionDecl *D)
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:656
ImplicitParamDecl * getCmdDecl() const
Definition: DeclObjC.h:448
void VisitClassScopeFunctionSpecializationDecl(ClassScopeFunctionSpecializationDecl *D)
bool isVariadic() const
Definition: DeclObjC.h:456
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:103
VarTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
Definition: ASTBitCodes.h:1281
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1294
unsigned protocol_size() const
Definition: DeclObjC.h:2386
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3442
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition: Decl.h:2025
An ExportDecl record.
Definition: ASTBitCodes.h:1424
bool blockMissingReturnType() const
Definition: Decl.h:3996
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3728
unsigned varlist_size() const
Definition: DeclOpenMP.h:74
size_t size() const
Definition: ASTWriter.h:800
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:226
void VisitFriendDecl(FriendDecl *D)
The top declaration context.
Definition: Decl.h:107
static bool isRequiredDecl(const Decl *D, ASTContext &Context, bool WritingModule)
isRequiredDecl - Check if this is a "required" Decl, which must be seen by consumers of the AST...
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:3949
NamedDecl * getMostRecentDecl()
Definition: Decl.h:445
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2840
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
bool hasObjectMember() const
Definition: Decl.h:3680
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D)
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:3825
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1120
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition: Decl.cpp:3246
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1475
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Definition: ASTReader.cpp:7246
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1487
void VisitImportDecl(ImportDecl *D)
varlist_range varlists()
Definition: DeclOpenMP.h:77
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition: Decl.h:1134
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
Definition: Decl.h:597
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3920
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:3117
QualType getType() const
Definition: Decl.h:648
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
Definition: DeclBase.h:603
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:941
This represents a decl that may have a name.
Definition: Decl.h:248
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
Represents a C++ namespace alias.
Definition: DeclCXX.h:3028
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen&#39;ed or deserialized from PCH lazily, only when used; this is onl...
void VisitFriendTemplateDecl(FriendTemplateDecl *D)
bool isInline() const
Whether this variable is (C++1z) inline.
Definition: Decl.h:1365
AccessControl getAccessControl() const
Definition: DeclObjC.h:2005
Declaration of a friend template.
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2440
bool isPropertyAccessor() const
Definition: DeclObjC.h:461
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Definition: DeclCXX.h:3546
Selector getGetterName() const
Definition: DeclObjC.h:925
Represents C++ using-directive.
Definition: DeclCXX.h:2924
SourceLocation getLParenLoc() const
Definition: DeclObjC.h:843
SourceLocation getEndOfDefinitionLoc() const
Definition: DeclObjC.h:1899
Represents a #pragma detect_mismatch line.
Definition: Decl.h:173
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
Definition: DeclTemplate.h:648
NamedDecl * getFriendDecl() const
If this friend declaration names a templated function (or a member function of a templated type)...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void VisitObjCMethodDecl(ObjCMethodDecl *D)
bool isFreeStanding() const
Definition: Decl.h:3193
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition: Decl.h:730
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:696
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:39
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2520
This class handles loading and caching of source files into memory.
void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D)
void VisitValueDecl(ValueDecl *D)
Declaration of a template function.
Definition: DeclTemplate.h:968
Source range/offset of a preprocessed entity.
Definition: ASTBitCodes.h:221
SourceLocation getLocation() const
Definition: DeclBase.h:419
const StringLiteral * getAsmString() const
Definition: Decl.h:3849
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3147
Represents a pack of using declarations that a single using-declarator pack-expanded into...
Definition: DeclCXX.h:3510
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:97
SourceLocation getRBraceLoc() const
Definition: Decl.h:619
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:407
void VisitObjCIvarDecl(ObjCIvarDecl *D)
PragmaMSCommentKind getCommentKind() const
Definition: Decl.h:162
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2750
This is a C++ Modules TS module interface unit.
Definition: Module.h:79
bool isInheritingConstructor() const
Determine whether this is an implicit constructor synthesized to model a call to a constructor inheri...
Definition: DeclCXX.h:2670