clang  7.0.0svn
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  Record.AddTypeSourceInfo(DD->getTypeSourceInfo());
269  }
270 
271  // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
272  // have been written. We want it last because we will not read it back when
273  // retrieving it from the AST, we'll just lazily set the offset.
274  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
275  Record.push_back(FD->doesThisDeclarationHaveABody());
276  if (FD->doesThisDeclarationHaveABody())
277  Record.AddFunctionDefinition(FD);
278  }
279 
280  // If this declaration is also a DeclContext, write blocks for the
281  // declarations that lexically stored inside its context and those
282  // declarations that are visible from its context.
283  if (DeclContext *DC = dyn_cast<DeclContext>(D))
284  VisitDeclContext(DC);
285 }
286 
288  Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
289  if (D->getDeclContext() != D->getLexicalDeclContext())
290  Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
291  else
292  Record.push_back(0);
293  Record.push_back(D->isInvalidDecl());
294  Record.push_back(D->hasAttrs());
295  if (D->hasAttrs())
296  Record.AddAttributes(D->getAttrs());
297  Record.push_back(D->isImplicit());
298  Record.push_back(D->isUsed(false));
299  Record.push_back(D->isReferenced());
300  Record.push_back(D->isTopLevelDeclInObjCContainer());
301  Record.push_back(D->getAccess());
302  Record.push_back(D->isModulePrivate());
303  Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
304 
305  // If this declaration injected a name into a context different from its
306  // lexical context, and that context is an imported namespace, we need to
307  // update its visible declarations to include this name.
308  //
309  // This happens when we instantiate a class with a friend declaration or a
310  // function with a local extern declaration, for instance.
311  //
312  // FIXME: Can we handle this in AddedVisibleDecl instead?
313  if (D->isOutOfLine()) {
314  auto *DC = D->getDeclContext();
315  while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
316  if (!NS->isFromASTFile())
317  break;
318  Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
319  if (!NS->isInlineNamespace())
320  break;
321  DC = NS->getParent();
322  }
323  }
324 }
325 
327  StringRef Arg = D->getArg();
328  Record.push_back(Arg.size());
329  VisitDecl(D);
330  Record.AddSourceLocation(D->getLocStart());
331  Record.push_back(D->getCommentKind());
332  Record.AddString(Arg);
334 }
335 
338  StringRef Name = D->getName();
339  StringRef Value = D->getValue();
340  Record.push_back(Name.size() + 1 + Value.size());
341  VisitDecl(D);
342  Record.AddSourceLocation(D->getLocStart());
343  Record.AddString(Name);
344  Record.AddString(Value);
346 }
347 
349  llvm_unreachable("Translation units aren't directly serialized");
350 }
351 
353  VisitDecl(D);
354  Record.AddDeclarationName(D->getDeclName());
355  Record.push_back(needsAnonymousDeclarationNumber(D)
356  ? Writer.getAnonymousDeclarationNumber(D)
357  : 0);
358 }
359 
361  VisitNamedDecl(D);
362  Record.AddSourceLocation(D->getLocStart());
363  Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
364 }
365 
367  VisitRedeclarable(D);
368  VisitTypeDecl(D);
369  Record.AddTypeSourceInfo(D->getTypeSourceInfo());
370  Record.push_back(D->isModed());
371  if (D->isModed())
372  Record.AddTypeRef(D->getUnderlyingType());
373  Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
374 }
375 
377  VisitTypedefNameDecl(D);
378  if (D->getDeclContext() == D->getLexicalDeclContext() &&
379  !D->hasAttrs() &&
380  !D->isImplicit() &&
381  D->getFirstDecl() == D->getMostRecentDecl() &&
382  !D->isInvalidDecl() &&
384  !D->isModulePrivate() &&
387  AbbrevToUse = Writer.getDeclTypedefAbbrev();
388 
390 }
391 
393  VisitTypedefNameDecl(D);
394  Record.AddDeclRef(D->getDescribedAliasTemplate());
396 }
397 
399  VisitRedeclarable(D);
400  VisitTypeDecl(D);
401  Record.push_back(D->getIdentifierNamespace());
402  Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
403  if (!isa<CXXRecordDecl>(D))
404  Record.push_back(D->isCompleteDefinition());
405  Record.push_back(D->isEmbeddedInDeclarator());
406  Record.push_back(D->isFreeStanding());
407  Record.push_back(D->isCompleteDefinitionRequired());
408  Record.AddSourceRange(D->getBraceRange());
409 
410  if (D->hasExtInfo()) {
411  Record.push_back(1);
412  Record.AddQualifierInfo(*D->getExtInfo());
413  } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
414  Record.push_back(2);
415  Record.AddDeclRef(TD);
416  Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
417  } else {
418  Record.push_back(0);
419  }
420 }
421 
423  VisitTagDecl(D);
424  Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
425  if (!D->getIntegerTypeSourceInfo())
426  Record.AddTypeRef(D->getIntegerType());
427  Record.AddTypeRef(D->getPromotionType());
428  Record.push_back(D->getNumPositiveBits());
429  Record.push_back(D->getNumNegativeBits());
430  Record.push_back(D->isScoped());
431  Record.push_back(D->isScopedUsingClassTag());
432  Record.push_back(D->isFixed());
433  if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) {
434  Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
435  Record.push_back(MemberInfo->getTemplateSpecializationKind());
436  Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
437  } else {
438  Record.AddDeclRef(nullptr);
439  }
440 
441  if (D->getDeclContext() == D->getLexicalDeclContext() &&
442  !D->hasAttrs() &&
443  !D->isImplicit() &&
444  !D->isUsed(false) &&
445  !D->hasExtInfo() &&
447  D->getFirstDecl() == D->getMostRecentDecl() &&
448  !D->isInvalidDecl() &&
449  !D->isReferenced() &&
451  D->getAccess() == AS_none &&
452  !D->isModulePrivate() &&
454  !D->getIntegerTypeSourceInfo() &&
458  AbbrevToUse = Writer.getDeclEnumAbbrev();
459 
461 }
462 
464  VisitTagDecl(D);
465  Record.push_back(D->hasFlexibleArrayMember());
466  Record.push_back(D->isAnonymousStructOrUnion());
467  Record.push_back(D->hasObjectMember());
468  Record.push_back(D->hasVolatileMember());
469  Record.push_back(D->isNonTrivialToPrimitiveDefaultInitialize());
470  Record.push_back(D->isNonTrivialToPrimitiveCopy());
471  Record.push_back(D->isNonTrivialToPrimitiveDestroy());
472  Record.push_back(D->isParamDestroyedInCallee());
473  Record.push_back(D->getArgPassingRestrictions());
474 
475  if (D->getDeclContext() == D->getLexicalDeclContext() &&
476  !D->hasAttrs() &&
477  !D->isImplicit() &&
478  !D->isUsed(false) &&
479  !D->hasExtInfo() &&
481  D->getFirstDecl() == D->getMostRecentDecl() &&
482  !D->isInvalidDecl() &&
483  !D->isReferenced() &&
485  D->getAccess() == AS_none &&
486  !D->isModulePrivate() &&
490  AbbrevToUse = Writer.getDeclRecordAbbrev();
491 
493 }
494 
496  VisitNamedDecl(D);
497  Record.AddTypeRef(D->getType());
498 }
499 
501  VisitValueDecl(D);
502  Record.push_back(D->getInitExpr()? 1 : 0);
503  if (D->getInitExpr())
504  Record.AddStmt(D->getInitExpr());
505  Record.AddAPSInt(D->getInitVal());
506 
508 }
509 
511  VisitValueDecl(D);
512  Record.AddSourceLocation(D->getInnerLocStart());
513  Record.push_back(D->hasExtInfo());
514  if (D->hasExtInfo())
515  Record.AddQualifierInfo(*D->getExtInfo());
516 }
517 
519  VisitRedeclarable(D);
520  VisitDeclaratorDecl(D);
521  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
522  Record.push_back(D->getIdentifierNamespace());
523 
524  // FunctionDecl's body is handled last at ASTWriterDecl::Visit,
525  // after everything else is written.
526 
527  Record.push_back((int)D->SClass); // FIXME: stable encoding
528  Record.push_back(D->IsInline);
529  Record.push_back(D->IsInlineSpecified);
530  Record.push_back(D->IsExplicitSpecified);
531  Record.push_back(D->IsVirtualAsWritten);
532  Record.push_back(D->IsPure);
533  Record.push_back(D->HasInheritedPrototype);
534  Record.push_back(D->HasWrittenPrototype);
535  Record.push_back(D->IsDeleted);
536  Record.push_back(D->IsTrivial);
537  Record.push_back(D->IsTrivialForCall);
538  Record.push_back(D->IsDefaulted);
539  Record.push_back(D->IsExplicitlyDefaulted);
540  Record.push_back(D->HasImplicitReturnZero);
541  Record.push_back(D->IsConstexpr);
542  Record.push_back(D->UsesSEHTry);
543  Record.push_back(D->HasSkippedBody);
544  Record.push_back(D->IsMultiVersion);
545  Record.push_back(D->IsLateTemplateParsed);
546  Record.push_back(D->getLinkageInternal());
547  Record.AddSourceLocation(D->getLocEnd());
548 
549  Record.push_back(D->getODRHash());
550 
551  Record.push_back(D->getTemplatedKind());
552  switch (D->getTemplatedKind()) {
554  break;
556  Record.AddDeclRef(D->getDescribedFunctionTemplate());
557  break;
560  Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
561  Record.push_back(MemberInfo->getTemplateSpecializationKind());
562  Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
563  break;
564  }
567  FTSInfo = D->getTemplateSpecializationInfo();
568 
569  RegisterTemplateSpecialization(FTSInfo->getTemplate(), D);
570 
571  Record.AddDeclRef(FTSInfo->getTemplate());
572  Record.push_back(FTSInfo->getTemplateSpecializationKind());
573 
574  // Template arguments.
575  Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
576 
577  // Template args as written.
578  Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
579  if (FTSInfo->TemplateArgumentsAsWritten) {
580  Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs);
581  for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs;
582  i!=e; ++i)
583  Record.AddTemplateArgumentLoc(
584  (*FTSInfo->TemplateArgumentsAsWritten)[i]);
585  Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc);
586  Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc);
587  }
588 
589  Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
590 
591  if (D->isCanonicalDecl()) {
592  // Write the template that contains the specializations set. We will
593  // add a FunctionTemplateSpecializationInfo to it when reading.
594  Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
595  }
596  break;
597  }
600  DFTSInfo = D->getDependentSpecializationInfo();
601 
602  // Templates.
603  Record.push_back(DFTSInfo->getNumTemplates());
604  for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i)
605  Record.AddDeclRef(DFTSInfo->getTemplate(i));
606 
607  // Templates args.
608  Record.push_back(DFTSInfo->getNumTemplateArgs());
609  for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i)
610  Record.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i));
611  Record.AddSourceLocation(DFTSInfo->getLAngleLoc());
612  Record.AddSourceLocation(DFTSInfo->getRAngleLoc());
613  break;
614  }
615  }
616 
617  Record.push_back(D->param_size());
618  for (auto P : D->parameters())
619  Record.AddDeclRef(P);
621 }
622 
624  VisitFunctionDecl(D);
625  Record.push_back(D->IsCopyDeductionCandidate);
627 }
628 
630  VisitNamedDecl(D);
631  // FIXME: convert to LazyStmtPtr?
632  // Unlike C/C++, method bodies will never be in header files.
633  bool HasBodyStuff = D->getBody() != nullptr ||
634  D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr;
635  Record.push_back(HasBodyStuff);
636  if (HasBodyStuff) {
637  Record.AddStmt(D->getBody());
638  Record.AddDeclRef(D->getSelfDecl());
639  Record.AddDeclRef(D->getCmdDecl());
640  }
641  Record.push_back(D->isInstanceMethod());
642  Record.push_back(D->isVariadic());
643  Record.push_back(D->isPropertyAccessor());
644  Record.push_back(D->isDefined());
645  Record.push_back(D->IsOverriding);
646  Record.push_back(D->HasSkippedBody);
647 
648  Record.push_back(D->IsRedeclaration);
649  Record.push_back(D->HasRedeclaration);
650  if (D->HasRedeclaration) {
651  assert(Context.getObjCMethodRedeclaration(D));
652  Record.AddDeclRef(Context.getObjCMethodRedeclaration(D));
653  }
654 
655  // FIXME: stable encoding for @required/@optional
656  Record.push_back(D->getImplementationControl());
657  // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
658  Record.push_back(D->getObjCDeclQualifier());
659  Record.push_back(D->hasRelatedResultType());
660  Record.AddTypeRef(D->getReturnType());
661  Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
662  Record.AddSourceLocation(D->getLocEnd());
663  Record.push_back(D->param_size());
664  for (const auto *P : D->parameters())
665  Record.AddDeclRef(P);
666 
667  Record.push_back(D->SelLocsKind);
668  unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
669  SourceLocation *SelLocs = D->getStoredSelLocs();
670  Record.push_back(NumStoredSelLocs);
671  for (unsigned i = 0; i != NumStoredSelLocs; ++i)
672  Record.AddSourceLocation(SelLocs[i]);
673 
675 }
676 
678  VisitTypedefNameDecl(D);
679  Record.push_back(D->Variance);
680  Record.push_back(D->Index);
681  Record.AddSourceLocation(D->VarianceLoc);
682  Record.AddSourceLocation(D->ColonLoc);
683 
685 }
686 
688  VisitNamedDecl(D);
689  Record.AddSourceLocation(D->getAtStartLoc());
690  Record.AddSourceRange(D->getAtEndRange());
691  // Abstract class (no need to define a stable serialization::DECL code).
692 }
693 
695  VisitRedeclarable(D);
696  VisitObjCContainerDecl(D);
697  Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
698  AddObjCTypeParamList(D->TypeParamList);
699 
700  Record.push_back(D->isThisDeclarationADefinition());
701  if (D->isThisDeclarationADefinition()) {
702  // Write the DefinitionData
703  ObjCInterfaceDecl::DefinitionData &Data = D->data();
704 
705  Record.AddTypeSourceInfo(D->getSuperClassTInfo());
706  Record.AddSourceLocation(D->getEndOfDefinitionLoc());
707  Record.push_back(Data.HasDesignatedInitializers);
708 
709  // Write out the protocols that are directly referenced by the @interface.
710  Record.push_back(Data.ReferencedProtocols.size());
711  for (const auto *P : D->protocols())
712  Record.AddDeclRef(P);
713  for (const auto &PL : D->protocol_locs())
714  Record.AddSourceLocation(PL);
715 
716  // Write out the protocols that are transitively referenced.
717  Record.push_back(Data.AllReferencedProtocols.size());
719  P = Data.AllReferencedProtocols.begin(),
720  PEnd = Data.AllReferencedProtocols.end();
721  P != PEnd; ++P)
722  Record.AddDeclRef(*P);
723 
724 
725  if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
726  // Ensure that we write out the set of categories for this class.
727  Writer.ObjCClassesWithCategories.insert(D);
728 
729  // Make sure that the categories get serialized.
730  for (; Cat; Cat = Cat->getNextClassCategoryRaw())
731  (void)Writer.GetDeclRef(Cat);
732  }
733  }
734 
736 }
737 
739  VisitFieldDecl(D);
740  // FIXME: stable encoding for @public/@private/@protected/@package
741  Record.push_back(D->getAccessControl());
742  Record.push_back(D->getSynthesize());
743 
744  if (D->getDeclContext() == D->getLexicalDeclContext() &&
745  !D->hasAttrs() &&
746  !D->isImplicit() &&
747  !D->isUsed(false) &&
748  !D->isInvalidDecl() &&
749  !D->isReferenced() &&
750  !D->isModulePrivate() &&
751  !D->getBitWidth() &&
752  !D->hasExtInfo() &&
753  D->getDeclName())
754  AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
755 
757 }
758 
760  VisitRedeclarable(D);
761  VisitObjCContainerDecl(D);
762 
763  Record.push_back(D->isThisDeclarationADefinition());
764  if (D->isThisDeclarationADefinition()) {
765  Record.push_back(D->protocol_size());
766  for (const auto *I : D->protocols())
767  Record.AddDeclRef(I);
768  for (const auto &PL : D->protocol_locs())
769  Record.AddSourceLocation(PL);
770  }
771 
773 }
774 
776  VisitFieldDecl(D);
778 }
779 
781  VisitObjCContainerDecl(D);
782  Record.AddSourceLocation(D->getCategoryNameLoc());
783  Record.AddSourceLocation(D->getIvarLBraceLoc());
784  Record.AddSourceLocation(D->getIvarRBraceLoc());
785  Record.AddDeclRef(D->getClassInterface());
786  AddObjCTypeParamList(D->TypeParamList);
787  Record.push_back(D->protocol_size());
788  for (const auto *I : D->protocols())
789  Record.AddDeclRef(I);
790  for (const auto &PL : D->protocol_locs())
791  Record.AddSourceLocation(PL);
793 }
794 
796  VisitNamedDecl(D);
797  Record.AddDeclRef(D->getClassInterface());
799 }
800 
802  VisitNamedDecl(D);
803  Record.AddSourceLocation(D->getAtLoc());
804  Record.AddSourceLocation(D->getLParenLoc());
805  Record.AddTypeRef(D->getType());
806  Record.AddTypeSourceInfo(D->getTypeSourceInfo());
807  // FIXME: stable encoding
808  Record.push_back((unsigned)D->getPropertyAttributes());
809  Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
810  // FIXME: stable encoding
811  Record.push_back((unsigned)D->getPropertyImplementation());
812  Record.AddDeclarationName(D->getGetterName());
813  Record.AddSourceLocation(D->getGetterNameLoc());
814  Record.AddDeclarationName(D->getSetterName());
815  Record.AddSourceLocation(D->getSetterNameLoc());
816  Record.AddDeclRef(D->getGetterMethodDecl());
817  Record.AddDeclRef(D->getSetterMethodDecl());
818  Record.AddDeclRef(D->getPropertyIvarDecl());
820 }
821 
823  VisitObjCContainerDecl(D);
824  Record.AddDeclRef(D->getClassInterface());
825  // Abstract class (no need to define a stable serialization::DECL code).
826 }
827 
829  VisitObjCImplDecl(D);
830  Record.AddSourceLocation(D->getCategoryNameLoc());
832 }
833 
835  VisitObjCImplDecl(D);
836  Record.AddDeclRef(D->getSuperClass());
837  Record.AddSourceLocation(D->getSuperClassLoc());
838  Record.AddSourceLocation(D->getIvarLBraceLoc());
839  Record.AddSourceLocation(D->getIvarRBraceLoc());
840  Record.push_back(D->hasNonZeroConstructors());
841  Record.push_back(D->hasDestructors());
842  Record.push_back(D->NumIvarInitializers);
843  if (D->NumIvarInitializers)
844  Record.AddCXXCtorInitializers(
845  llvm::makeArrayRef(D->init_begin(), D->init_end()));
847 }
848 
850  VisitDecl(D);
851  Record.AddSourceLocation(D->getLocStart());
852  Record.AddDeclRef(D->getPropertyDecl());
853  Record.AddDeclRef(D->getPropertyIvarDecl());
854  Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
855  Record.AddStmt(D->getGetterCXXConstructor());
856  Record.AddStmt(D->getSetterCXXAssignment());
858 }
859 
861  VisitDeclaratorDecl(D);
862  Record.push_back(D->isMutable());
863 
864  FieldDecl::InitStorageKind ISK = D->InitStorage.getInt();
865  Record.push_back(ISK);
866  if (ISK == FieldDecl::ISK_CapturedVLAType)
867  Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
868  else if (ISK)
869  Record.AddStmt(D->getInClassInitializer());
870 
871  Record.AddStmt(D->getBitWidth());
872 
873  if (!D->getDeclName())
874  Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D));
875 
876  if (D->getDeclContext() == D->getLexicalDeclContext() &&
877  !D->hasAttrs() &&
878  !D->isImplicit() &&
879  !D->isUsed(false) &&
880  !D->isInvalidDecl() &&
881  !D->isReferenced() &&
883  !D->isModulePrivate() &&
884  !D->getBitWidth() &&
885  !D->hasInClassInitializer() &&
886  !D->hasCapturedVLAType() &&
887  !D->hasExtInfo() &&
890  D->getDeclName())
891  AbbrevToUse = Writer.getDeclFieldAbbrev();
892 
894 }
895 
897  VisitDeclaratorDecl(D);
898  Record.AddIdentifierRef(D->getGetterId());
899  Record.AddIdentifierRef(D->getSetterId());
901 }
902 
904  VisitValueDecl(D);
905  Record.push_back(D->getChainingSize());
906 
907  for (const auto *P : D->chain())
908  Record.AddDeclRef(P);
910 }
911 
913  VisitRedeclarable(D);
914  VisitDeclaratorDecl(D);
915  Record.push_back(D->getStorageClass());
916  Record.push_back(D->getTSCSpec());
917  Record.push_back(D->getInitStyle());
918  if (!isa<ParmVarDecl>(D)) {
919  Record.push_back(D->isThisDeclarationADemotedDefinition());
920  Record.push_back(D->isExceptionVariable());
921  Record.push_back(D->isNRVOVariable());
922  Record.push_back(D->isCXXForRangeDecl());
923  Record.push_back(D->isObjCForDecl());
924  Record.push_back(D->isARCPseudoStrong());
925  Record.push_back(D->isInline());
926  Record.push_back(D->isInlineSpecified());
927  Record.push_back(D->isConstexpr());
928  Record.push_back(D->isInitCapture());
929  Record.push_back(D->isPreviousDeclInSameBlockScope());
930  if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
931  Record.push_back(static_cast<unsigned>(IPD->getParameterKind()));
932  else
933  Record.push_back(0);
934  }
935  Record.push_back(D->getLinkageInternal());
936 
937  if (D->getInit()) {
938  Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2));
939  Record.AddStmt(D->getInit());
940  } else {
941  Record.push_back(0);
942  }
943 
944  if (D->getStorageDuration() == SD_Static) {
945  bool ModulesCodegen = false;
946  if (Writer.WritingModule &&
948  !isa<VarTemplateSpecializationDecl>(D)) {
949  // When building a C++ Modules TS module interface unit, a strong
950  // definition in the module interface is provided by the compilation of
951  // that module interface unit, not by its users. (Inline variables are
952  // still emitted in module users.)
953  ModulesCodegen =
954  (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit &&
955  Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal);
956  }
957  Record.push_back(ModulesCodegen);
958  if (ModulesCodegen)
959  Writer.ModularCodegenDecls.push_back(Writer.GetDeclRef(D));
960  }
961 
962  enum {
963  VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
964  };
965  if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
966  Record.push_back(VarTemplate);
967  Record.AddDeclRef(TemplD);
968  } else if (MemberSpecializationInfo *SpecInfo
970  Record.push_back(StaticDataMemberSpecialization);
971  Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
972  Record.push_back(SpecInfo->getTemplateSpecializationKind());
973  Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
974  } else {
975  Record.push_back(VarNotTemplate);
976  }
977 
978  if (D->getDeclContext() == D->getLexicalDeclContext() &&
979  !D->hasAttrs() &&
980  !D->isImplicit() &&
981  !D->isUsed(false) &&
982  !D->isInvalidDecl() &&
983  !D->isReferenced() &&
985  D->getAccess() == AS_none &&
986  !D->isModulePrivate() &&
989  !D->hasExtInfo() &&
990  D->getFirstDecl() == D->getMostRecentDecl() &&
991  D->getKind() == Decl::Var &&
992  !D->isInline() &&
993  !D->isConstexpr() &&
994  !D->isInitCapture() &&
996  D->getStorageDuration() != SD_Static &&
998  AbbrevToUse = Writer.getDeclVarAbbrev();
999 
1000  Code = serialization::DECL_VAR;
1001 }
1002 
1004  VisitVarDecl(D);
1006 }
1007 
1009  VisitVarDecl(D);
1010  Record.push_back(D->isObjCMethodParameter());
1011  Record.push_back(D->getFunctionScopeDepth());
1012  Record.push_back(D->getFunctionScopeIndex());
1013  Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding
1014  Record.push_back(D->isKNRPromoted());
1015  Record.push_back(D->hasInheritedDefaultArg());
1016  Record.push_back(D->hasUninstantiatedDefaultArg());
1017  if (D->hasUninstantiatedDefaultArg())
1018  Record.AddStmt(D->getUninstantiatedDefaultArg());
1020 
1021  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
1022 
1023  // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1024  // we dynamically check for the properties that we optimize for, but don't
1025  // know are true of all PARM_VAR_DECLs.
1026  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1027  !D->hasAttrs() &&
1028  !D->hasExtInfo() &&
1029  !D->isImplicit() &&
1030  !D->isUsed(false) &&
1031  !D->isInvalidDecl() &&
1032  !D->isReferenced() &&
1033  D->getAccess() == AS_none &&
1034  !D->isModulePrivate() &&
1035  D->getStorageClass() == 0 &&
1036  D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1037  D->getFunctionScopeDepth() == 0 &&
1038  D->getObjCDeclQualifier() == 0 &&
1039  !D->isKNRPromoted() &&
1040  !D->hasInheritedDefaultArg() &&
1041  D->getInit() == nullptr &&
1042  !D->hasUninstantiatedDefaultArg()) // No default expr.
1043  AbbrevToUse = Writer.getDeclParmVarAbbrev();
1044 
1045  // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1046  // just us assuming it.
1047  assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1049  && "PARM_VAR_DECL can't be demoted definition.");
1050  assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1051  assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1052  assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1053  assert(!D->isStaticDataMember() &&
1054  "PARM_VAR_DECL can't be static data member");
1055 }
1056 
1058  // Record the number of bindings first to simplify deserialization.
1059  Record.push_back(D->bindings().size());
1060 
1061  VisitVarDecl(D);
1062  for (auto *B : D->bindings())
1063  Record.AddDeclRef(B);
1065 }
1066 
1068  VisitValueDecl(D);
1069  Record.AddStmt(D->getBinding());
1071 }
1072 
1074  VisitDecl(D);
1075  Record.AddStmt(D->getAsmString());
1076  Record.AddSourceLocation(D->getRParenLoc());
1078 }
1079 
1081  VisitDecl(D);
1083 }
1084 
1086  VisitDecl(D);
1087  Record.AddStmt(D->getBody());
1088  Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1089  Record.push_back(D->param_size());
1090  for (ParmVarDecl *P : D->parameters())
1091  Record.AddDeclRef(P);
1092  Record.push_back(D->isVariadic());
1093  Record.push_back(D->blockMissingReturnType());
1094  Record.push_back(D->isConversionFromLambda());
1095  Record.push_back(D->capturesCXXThis());
1096  Record.push_back(D->getNumCaptures());
1097  for (const auto &capture : D->captures()) {
1098  Record.AddDeclRef(capture.getVariable());
1099 
1100  unsigned flags = 0;
1101  if (capture.isByRef()) flags |= 1;
1102  if (capture.isNested()) flags |= 2;
1103  if (capture.hasCopyExpr()) flags |= 4;
1104  Record.push_back(flags);
1105 
1106  if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1107  }
1108 
1110 }
1111 
1113  Record.push_back(CD->getNumParams());
1114  VisitDecl(CD);
1115  Record.push_back(CD->getContextParamPosition());
1116  Record.push_back(CD->isNothrow() ? 1 : 0);
1117  // Body is stored by VisitCapturedStmt.
1118  for (unsigned I = 0; I < CD->getNumParams(); ++I)
1119  Record.AddDeclRef(CD->getParam(I));
1121 }
1122 
1124  VisitDecl(D);
1125  Record.push_back(D->getLanguage());
1126  Record.AddSourceLocation(D->getExternLoc());
1127  Record.AddSourceLocation(D->getRBraceLoc());
1129 }
1130 
1132  VisitDecl(D);
1133  Record.AddSourceLocation(D->getRBraceLoc());
1135 }
1136 
1138  VisitNamedDecl(D);
1139  Record.AddSourceLocation(D->getLocStart());
1141 }
1142 
1143 
1145  VisitRedeclarable(D);
1146  VisitNamedDecl(D);
1147  Record.push_back(D->isInline());
1148  Record.AddSourceLocation(D->getLocStart());
1149  Record.AddSourceLocation(D->getRBraceLoc());
1150 
1151  if (D->isOriginalNamespace())
1152  Record.AddDeclRef(D->getAnonymousNamespace());
1154 
1155  if (Writer.hasChain() && D->isAnonymousNamespace() &&
1156  D == D->getMostRecentDecl()) {
1157  // This is a most recent reopening of the anonymous namespace. If its parent
1158  // is in a previous PCH (or is the TU), mark that parent for update, because
1159  // the original namespace always points to the latest re-opening of its
1160  // anonymous namespace.
1161  Decl *Parent = cast<Decl>(
1163  if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1164  Writer.DeclUpdates[Parent].push_back(
1165  ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D));
1166  }
1167  }
1168 }
1169 
1171  VisitRedeclarable(D);
1172  VisitNamedDecl(D);
1173  Record.AddSourceLocation(D->getNamespaceLoc());
1174  Record.AddSourceLocation(D->getTargetNameLoc());
1175  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1176  Record.AddDeclRef(D->getNamespace());
1178 }
1179 
1181  VisitNamedDecl(D);
1182  Record.AddSourceLocation(D->getUsingLoc());
1183  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1184  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1185  Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1186  Record.push_back(D->hasTypename());
1187  Record.AddDeclRef(Context.getInstantiatedFromUsingDecl(D));
1189 }
1190 
1192  Record.push_back(D->NumExpansions);
1193  VisitNamedDecl(D);
1194  Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1195  for (auto *E : D->expansions())
1196  Record.AddDeclRef(E);
1198 }
1199 
1201  VisitRedeclarable(D);
1202  VisitNamedDecl(D);
1203  Record.AddDeclRef(D->getTargetDecl());
1204  Record.push_back(D->getIdentifierNamespace());
1205  Record.AddDeclRef(D->UsingOrNextShadow);
1206  Record.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D));
1208 }
1209 
1212  VisitUsingShadowDecl(D);
1213  Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1214  Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1215  Record.push_back(D->IsVirtual);
1217 }
1218 
1220  VisitNamedDecl(D);
1221  Record.AddSourceLocation(D->getUsingLoc());
1222  Record.AddSourceLocation(D->getNamespaceKeyLocation());
1223  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1224  Record.AddDeclRef(D->getNominatedNamespace());
1225  Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1227 }
1228 
1230  VisitValueDecl(D);
1231  Record.AddSourceLocation(D->getUsingLoc());
1232  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1233  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1234  Record.AddSourceLocation(D->getEllipsisLoc());
1236 }
1237 
1240  VisitTypeDecl(D);
1241  Record.AddSourceLocation(D->getTypenameLoc());
1242  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1243  Record.AddSourceLocation(D->getEllipsisLoc());
1245 }
1246 
1248  VisitRecordDecl(D);
1249 
1250  enum {
1251  CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1252  };
1253  if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1254  Record.push_back(CXXRecTemplate);
1255  Record.AddDeclRef(TemplD);
1256  } else if (MemberSpecializationInfo *MSInfo
1257  = D->getMemberSpecializationInfo()) {
1258  Record.push_back(CXXRecMemberSpecialization);
1259  Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1260  Record.push_back(MSInfo->getTemplateSpecializationKind());
1261  Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1262  } else {
1263  Record.push_back(CXXRecNotTemplate);
1264  }
1265 
1266  Record.push_back(D->isThisDeclarationADefinition());
1268  Record.AddCXXDefinitionData(D);
1269 
1270  // Store (what we currently believe to be) the key function to avoid
1271  // deserializing every method so we can compute it.
1272  if (D->IsCompleteDefinition)
1273  Record.AddDeclRef(Context.getCurrentKeyFunction(D));
1274 
1276 }
1277 
1279  VisitFunctionDecl(D);
1280  if (D->isCanonicalDecl()) {
1281  Record.push_back(D->size_overridden_methods());
1282  for (const CXXMethodDecl *MD : D->overridden_methods())
1283  Record.AddDeclRef(MD);
1284  } else {
1285  // We only need to record overridden methods once for the canonical decl.
1286  Record.push_back(0);
1287  }
1288 
1289  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1290  D->getFirstDecl() == D->getMostRecentDecl() &&
1291  !D->isInvalidDecl() &&
1292  !D->hasAttrs() &&
1295  !D->hasExtInfo() &&
1296  !D->hasInheritedPrototype() &&
1297  D->hasWrittenPrototype())
1298  AbbrevToUse = Writer.getDeclCXXMethodAbbrev();
1299 
1301 }
1302 
1304  if (auto Inherited = D->getInheritedConstructor()) {
1305  Record.AddDeclRef(Inherited.getShadowDecl());
1306  Record.AddDeclRef(Inherited.getConstructor());
1308  } else {
1310  }
1311 
1312  VisitCXXMethodDecl(D);
1313 
1314  Code = D->isInheritingConstructor()
1317 }
1318 
1320  VisitCXXMethodDecl(D);
1321 
1322  Record.AddDeclRef(D->getOperatorDelete());
1323  if (D->getOperatorDelete())
1324  Record.AddStmt(D->getOperatorDeleteThisArg());
1325 
1327 }
1328 
1330  VisitCXXMethodDecl(D);
1332 }
1333 
1335  VisitDecl(D);
1336  Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1337  ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1338  Record.push_back(!IdentifierLocs.empty());
1339  if (IdentifierLocs.empty()) {
1340  Record.AddSourceLocation(D->getLocEnd());
1341  Record.push_back(1);
1342  } else {
1343  for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1344  Record.AddSourceLocation(IdentifierLocs[I]);
1345  Record.push_back(IdentifierLocs.size());
1346  }
1347  // Note: the number of source locations must always be the last element in
1348  // the record.
1350 }
1351 
1353  VisitDecl(D);
1354  Record.AddSourceLocation(D->getColonLoc());
1356 }
1357 
1359  // Record the number of friend type template parameter lists here
1360  // so as to simplify memory allocation during deserialization.
1361  Record.push_back(D->NumTPLists);
1362  VisitDecl(D);
1363  bool hasFriendDecl = D->Friend.is<NamedDecl*>();
1364  Record.push_back(hasFriendDecl);
1365  if (hasFriendDecl)
1366  Record.AddDeclRef(D->getFriendDecl());
1367  else
1368  Record.AddTypeSourceInfo(D->getFriendType());
1369  for (unsigned i = 0; i < D->NumTPLists; ++i)
1370  Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1371  Record.AddDeclRef(D->getNextFriend());
1372  Record.push_back(D->UnsupportedFriend);
1373  Record.AddSourceLocation(D->FriendLoc);
1375 }
1376 
1378  VisitDecl(D);
1379  Record.push_back(D->getNumTemplateParameters());
1380  for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1381  Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1382  Record.push_back(D->getFriendDecl() != nullptr);
1383  if (D->getFriendDecl())
1384  Record.AddDeclRef(D->getFriendDecl());
1385  else
1386  Record.AddTypeSourceInfo(D->getFriendType());
1387  Record.AddSourceLocation(D->getFriendLoc());
1389 }
1390 
1392  VisitNamedDecl(D);
1393 
1394  Record.AddDeclRef(D->getTemplatedDecl());
1395  Record.AddTemplateParameterList(D->getTemplateParameters());
1396 }
1397 
1399  VisitRedeclarable(D);
1400 
1401  // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1402  // getCommonPtr() can be used while this is still initializing.
1403  if (D->isFirstDecl()) {
1404  // This declaration owns the 'common' pointer, so serialize that data now.
1405  Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1407  Record.push_back(D->isMemberSpecialization());
1408  }
1409 
1410  VisitTemplateDecl(D);
1411  Record.push_back(D->getIdentifierNamespace());
1412 }
1413 
1415  VisitRedeclarableTemplateDecl(D);
1416 
1417  if (D->isFirstDecl())
1418  AddTemplateSpecializations(D);
1420 }
1421 
1424  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1425 
1426  VisitCXXRecordDecl(D);
1427 
1428  llvm::PointerUnion<ClassTemplateDecl *,
1431  if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1432  Record.AddDeclRef(InstFromD);
1433  } else {
1434  Record.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>());
1435  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1436  }
1437 
1438  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1439  Record.AddSourceLocation(D->getPointOfInstantiation());
1440  Record.push_back(D->getSpecializationKind());
1441  Record.push_back(D->isCanonicalDecl());
1442 
1443  if (D->isCanonicalDecl()) {
1444  // When reading, we'll add it to the folding set of the following template.
1445  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1446  }
1447 
1448  // Explicit info.
1449  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1450  if (D->getTypeAsWritten()) {
1451  Record.AddSourceLocation(D->getExternLoc());
1452  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1453  }
1454 
1456 }
1457 
1460  VisitClassTemplateSpecializationDecl(D);
1461 
1462  Record.AddTemplateParameterList(D->getTemplateParameters());
1463  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1464 
1465  // These are read/set from/to the first declaration.
1466  if (D->getPreviousDecl() == nullptr) {
1467  Record.AddDeclRef(D->getInstantiatedFromMember());
1468  Record.push_back(D->isMemberSpecialization());
1469  }
1470 
1472 }
1473 
1475  VisitRedeclarableTemplateDecl(D);
1476 
1477  if (D->isFirstDecl())
1478  AddTemplateSpecializations(D);
1480 }
1481 
1484  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1485 
1486  VisitVarDecl(D);
1487 
1488  llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
1489  InstFrom = D->getSpecializedTemplateOrPartial();
1490  if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
1491  Record.AddDeclRef(InstFromD);
1492  } else {
1493  Record.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>());
1494  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1495  }
1496 
1497  // Explicit info.
1498  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1499  if (D->getTypeAsWritten()) {
1500  Record.AddSourceLocation(D->getExternLoc());
1501  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1502  }
1503 
1504  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1505  Record.AddSourceLocation(D->getPointOfInstantiation());
1506  Record.push_back(D->getSpecializationKind());
1507  Record.push_back(D->IsCompleteDefinition);
1508  Record.push_back(D->isCanonicalDecl());
1509 
1510  if (D->isCanonicalDecl()) {
1511  // When reading, we'll add it to the folding set of the following template.
1512  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1513  }
1514 
1516 }
1517 
1520  VisitVarTemplateSpecializationDecl(D);
1521 
1522  Record.AddTemplateParameterList(D->getTemplateParameters());
1523  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1524 
1525  // These are read/set from/to the first declaration.
1526  if (D->getPreviousDecl() == nullptr) {
1527  Record.AddDeclRef(D->getInstantiatedFromMember());
1528  Record.push_back(D->isMemberSpecialization());
1529  }
1530 
1532 }
1533 
1536  VisitDecl(D);
1537  Record.AddDeclRef(D->getSpecialization());
1539 }
1540 
1541 
1543  VisitRedeclarableTemplateDecl(D);
1544 
1545  if (D->isFirstDecl())
1546  AddTemplateSpecializations(D);
1548 }
1549 
1551  VisitTypeDecl(D);
1552 
1553  Record.push_back(D->wasDeclaredWithTypename());
1554 
1555  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1557  Record.push_back(OwnsDefaultArg);
1558  if (OwnsDefaultArg)
1559  Record.AddTypeSourceInfo(D->getDefaultArgumentInfo());
1560 
1562 }
1563 
1565  // For an expanded parameter pack, record the number of expansion types here
1566  // so that it's easier for deserialization to allocate the right amount of
1567  // memory.
1568  if (D->isExpandedParameterPack())
1569  Record.push_back(D->getNumExpansionTypes());
1570 
1571  VisitDeclaratorDecl(D);
1572  // TemplateParmPosition.
1573  Record.push_back(D->getDepth());
1574  Record.push_back(D->getPosition());
1575 
1576  if (D->isExpandedParameterPack()) {
1577  for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
1578  Record.AddTypeRef(D->getExpansionType(I));
1579  Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
1580  }
1581 
1583  } else {
1584  // Rest of NonTypeTemplateParmDecl.
1585  Record.push_back(D->isParameterPack());
1586  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1588  Record.push_back(OwnsDefaultArg);
1589  if (OwnsDefaultArg)
1590  Record.AddStmt(D->getDefaultArgument());
1592  }
1593 }
1594 
1596  // For an expanded parameter pack, record the number of expansion types here
1597  // so that it's easier for deserialization to allocate the right amount of
1598  // memory.
1599  if (D->isExpandedParameterPack())
1600  Record.push_back(D->getNumExpansionTemplateParameters());
1601 
1602  VisitTemplateDecl(D);
1603  // TemplateParmPosition.
1604  Record.push_back(D->getDepth());
1605  Record.push_back(D->getPosition());
1606 
1607  if (D->isExpandedParameterPack()) {
1608  for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
1609  I != N; ++I)
1610  Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
1612  } else {
1613  // Rest of TemplateTemplateParmDecl.
1614  Record.push_back(D->isParameterPack());
1615  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1617  Record.push_back(OwnsDefaultArg);
1618  if (OwnsDefaultArg)
1619  Record.AddTemplateArgumentLoc(D->getDefaultArgument());
1621  }
1622 }
1623 
1625  VisitRedeclarableTemplateDecl(D);
1627 }
1628 
1630  VisitDecl(D);
1631  Record.AddStmt(D->getAssertExpr());
1632  Record.push_back(D->isFailed());
1633  Record.AddStmt(D->getMessage());
1634  Record.AddSourceLocation(D->getRParenLoc());
1636 }
1637 
1638 /// Emit the DeclContext part of a declaration context decl.
1640  Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC));
1641  Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC));
1642 }
1643 
1645  assert(IsLocalDecl(D) && "expected a local declaration");
1646 
1647  const Decl *Canon = D->getCanonicalDecl();
1648  if (IsLocalDecl(Canon))
1649  return Canon;
1650 
1651  const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
1652  if (CacheEntry)
1653  return CacheEntry;
1654 
1655  for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
1656  if (IsLocalDecl(Redecl))
1657  D = Redecl;
1658  return CacheEntry = D;
1659 }
1660 
1661 template <typename T>
1663  T *First = D->getFirstDecl();
1664  T *MostRecent = First->getMostRecentDecl();
1665  T *DAsT = static_cast<T *>(D);
1666  if (MostRecent != First) {
1667  assert(isRedeclarableDeclKind(DAsT->getKind()) &&
1668  "Not considered redeclarable?");
1669 
1670  Record.AddDeclRef(First);
1671 
1672  // Write out a list of local redeclarations of this declaration if it's the
1673  // first local declaration in the chain.
1674  const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
1675  if (DAsT == FirstLocal) {
1676  // Emit a list of all imported first declarations so that we can be sure
1677  // that all redeclarations visible to this module are before D in the
1678  // redecl chain.
1679  unsigned I = Record.size();
1680  Record.push_back(0);
1681  if (Writer.Chain)
1682  AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
1683  // This is the number of imported first declarations + 1.
1684  Record[I] = Record.size() - I;
1685 
1686  // Collect the set of local redeclarations of this declaration, from
1687  // newest to oldest.
1688  ASTWriter::RecordData LocalRedecls;
1689  ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
1690  for (const Decl *Prev = FirstLocal->getMostRecentDecl();
1691  Prev != FirstLocal; Prev = Prev->getPreviousDecl())
1692  if (!Prev->isFromASTFile())
1693  LocalRedeclWriter.AddDeclRef(Prev);
1694 
1695  // If we have any redecls, write them now as a separate record preceding
1696  // the declaration itself.
1697  if (LocalRedecls.empty())
1698  Record.push_back(0);
1699  else
1700  Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
1701  } else {
1702  Record.push_back(0);
1703  Record.AddDeclRef(FirstLocal);
1704  }
1705 
1706  // Make sure that we serialize both the previous and the most-recent
1707  // declarations, which (transitively) ensures that all declarations in the
1708  // chain get serialized.
1709  //
1710  // FIXME: This is not correct; when we reach an imported declaration we
1711  // won't emit its previous declaration.
1712  (void)Writer.GetDeclRef(D->getPreviousDecl());
1713  (void)Writer.GetDeclRef(MostRecent);
1714  } else {
1715  // We use the sentinel value 0 to indicate an only declaration.
1716  Record.push_back(0);
1717  }
1718 }
1719 
1721  Record.push_back(D->varlist_size());
1722  VisitDecl(D);
1723  for (auto *I : D->varlists())
1724  Record.AddStmt(I);
1726 }
1727 
1729  VisitValueDecl(D);
1730  Record.AddSourceLocation(D->getLocStart());
1731  Record.AddStmt(D->getCombiner());
1732  Record.AddStmt(D->getInitializer());
1733  Record.push_back(D->getInitializerKind());
1734  Record.AddDeclRef(D->getPrevDeclInScope());
1736 }
1737 
1739  VisitVarDecl(D);
1741 }
1742 
1743 //===----------------------------------------------------------------------===//
1744 // ASTWriter Implementation
1745 //===----------------------------------------------------------------------===//
1746 
1747 void ASTWriter::WriteDeclAbbrevs() {
1748  using namespace llvm;
1749 
1750  std::shared_ptr<BitCodeAbbrev> Abv;
1751 
1752  // Abbreviation for DECL_FIELD
1753  Abv = std::make_shared<BitCodeAbbrev>();
1754  Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
1755  // Decl
1756  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1757  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1758  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1759  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1760  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1761  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1762  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1763  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1764  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1765  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1766  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1767  // NamedDecl
1768  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1769  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1770  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1771  // ValueDecl
1772  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1773  // DeclaratorDecl
1774  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1775  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1776  // FieldDecl
1777  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1778  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1779  // Type Source Info
1780  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1781  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1782  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1783  DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
1784 
1785  // Abbreviation for DECL_OBJC_IVAR
1786  Abv = std::make_shared<BitCodeAbbrev>();
1787  Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
1788  // Decl
1789  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1790  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1791  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1792  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1793  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1794  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1795  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1796  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1797  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1798  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1799  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1800  // NamedDecl
1801  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1802  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1803  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1804  // ValueDecl
1805  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1806  // DeclaratorDecl
1807  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1808  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1809  // FieldDecl
1810  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1811  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1812  // ObjC Ivar
1813  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
1814  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
1815  // Type Source Info
1816  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1817  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1818  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1819  DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1820 
1821  // Abbreviation for DECL_ENUM
1822  Abv = std::make_shared<BitCodeAbbrev>();
1823  Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
1824  // Redeclarable
1825  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1826  // Decl
1827  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1828  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1829  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1830  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1831  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1832  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1833  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1834  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1835  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1836  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1837  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1838  // NamedDecl
1839  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1840  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1841  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1842  // TypeDecl
1843  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1844  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1845  // TagDecl
1846  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1847  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1848  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1849  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1850  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1851  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1852  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1853  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1854  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1855  // EnumDecl
1856  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
1857  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
1858  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
1859  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumPositiveBits
1860  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumNegativeBits
1861  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScoped
1862  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScopedUsingClassTag
1863  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isFixed
1864  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
1865  // DC
1866  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1867  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1868  DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
1869 
1870  // Abbreviation for DECL_RECORD
1871  Abv = std::make_shared<BitCodeAbbrev>();
1872  Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
1873  // Redeclarable
1874  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1875  // Decl
1876  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1877  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1878  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1879  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1880  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1881  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1882  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1883  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1884  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1885  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1886  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1887  // NamedDecl
1888  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1889  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1890  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1891  // TypeDecl
1892  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1893  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1894  // TagDecl
1895  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1896  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1897  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1898  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1899  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1900  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1901  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1902  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1903  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1904  // RecordDecl
1905  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember
1906  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
1907  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
1908  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
1909 
1910  // isNonTrivialToPrimitiveDefaultInitialize
1911  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1912  // isNonTrivialToPrimitiveCopy
1913  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1914  // isNonTrivialToPrimitiveDestroy
1915  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1916  // isParamDestroyedInCallee
1917  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1918  // getArgPassingRestrictions
1919  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
1920 
1921  // DC
1922  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1923  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1924  DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
1925 
1926  // Abbreviation for DECL_PARM_VAR
1927  Abv = std::make_shared<BitCodeAbbrev>();
1928  Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
1929  // Redeclarable
1930  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1931  // Decl
1932  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1933  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1934  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1935  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1936  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1937  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1938  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1939  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1940  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1941  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1942  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1943  // NamedDecl
1944  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1945  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1946  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1947  // ValueDecl
1948  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1949  // DeclaratorDecl
1950  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1951  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1952  // VarDecl
1953  Abv->Add(BitCodeAbbrevOp(0)); // SClass
1954  Abv->Add(BitCodeAbbrevOp(0)); // TSCSpec
1955  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1956  Abv->Add(BitCodeAbbrevOp(0)); // Linkage
1957  Abv->Add(BitCodeAbbrevOp(0)); // HasInit
1958  Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo
1959  // ParmVarDecl
1960  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsObjCMethodParameter
1961  Abv->Add(BitCodeAbbrevOp(0)); // ScopeDepth
1962  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
1963  Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier
1964  Abv->Add(BitCodeAbbrevOp(0)); // KNRPromoted
1965  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg
1966  Abv->Add(BitCodeAbbrevOp(0)); // HasUninstantiatedDefaultArg
1967  // Type Source Info
1968  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1969  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1970  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1971  DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1972 
1973  // Abbreviation for DECL_TYPEDEF
1974  Abv = std::make_shared<BitCodeAbbrev>();
1975  Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
1976  // Redeclarable
1977  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1978  // Decl
1979  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1980  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1981  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1982  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1983  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1984  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isUsed
1985  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isReferenced
1986  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1987  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // C++ AccessSpecifier
1988  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1989  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1990  // NamedDecl
1991  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1992  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1993  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1994  // TypeDecl
1995  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1996  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1997  // TypedefDecl
1998  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1999  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2000  DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2001 
2002  // Abbreviation for DECL_VAR
2003  Abv = std::make_shared<BitCodeAbbrev>();
2004  Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2005  // Redeclarable
2006  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2007  // Decl
2008  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2009  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
2010  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
2011  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
2012  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
2013  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
2014  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
2015  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
2016  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
2017  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
2018  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2019  // NamedDecl
2020  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2021  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2022  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2023  // ValueDecl
2024  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2025  // DeclaratorDecl
2026  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2027  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2028  // VarDecl
2029  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
2030  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
2031  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
2032  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
2033  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
2034  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
2035  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
2036  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isObjCForDecl
2037  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
2038  Abv->Add(BitCodeAbbrevOp(0)); // isInline
2039  Abv->Add(BitCodeAbbrevOp(0)); // isInlineSpecified
2040  Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
2041  Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
2042  Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
2043  Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind
2044  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
2045  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
2046  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
2047  // Type Source Info
2048  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2049  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2050  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2051  DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2052 
2053  // Abbreviation for DECL_CXX_METHOD
2054  Abv = std::make_shared<BitCodeAbbrev>();
2055  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD));
2056  // RedeclarableDecl
2057  Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2058  // Decl
2059  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2060  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
2061  Abv->Add(BitCodeAbbrevOp(0)); // Invalid
2062  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
2063  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Implicit
2064  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Used
2065  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Referenced
2066  Abv->Add(BitCodeAbbrevOp(0)); // InObjCContainer
2067  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Access
2068  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModulePrivate
2069  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2070  // NamedDecl
2071  Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2072  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2073  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2074  // ValueDecl
2075  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2076  // DeclaratorDecl
2077  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2078  Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2079  // FunctionDecl
2080  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2081  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass
2082  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline
2083  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified
2084  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitSpecified
2085  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten
2086  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure
2087  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto
2088  Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto
2089  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted
2090  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial
2091  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // TrivialForCall
2092  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
2093  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
2094  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
2095  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
2096  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry
2097  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
2098  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // MultiVersion
2099  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed
2100  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
2101  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2102  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2103  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind
2104  // This Array slurps the rest of the record. Fortunately we want to encode
2105  // (nearly) all the remaining (variable number of) fields in the same way.
2106  //
2107  // This is the function template information if any, then
2108  // NumParams and Params[] from FunctionDecl, and
2109  // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2110  //
2111  // Add an AbbrevOp for 'size then elements' and use it here.
2112  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2113  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2114  DeclCXXMethodAbbrev = Stream.EmitAbbrev(std::move(Abv));
2115 
2116  // Abbreviation for EXPR_DECL_REF
2117  Abv = std::make_shared<BitCodeAbbrev>();
2118  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2119  //Stmt
2120  //Expr
2121  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2122  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2123  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2124  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2125  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2126  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2127  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2128  //DeclRefExpr
2129  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HasQualifier
2130  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //GetDeclFound
2131  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ExplicitTemplateArgs
2132  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HadMultipleCandidates
2133  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2134  1)); // RefersToEnclosingVariableOrCapture
2135  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2136  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2137  DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2138 
2139  // Abbreviation for EXPR_INTEGER_LITERAL
2140  Abv = std::make_shared<BitCodeAbbrev>();
2141  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2142  //Stmt
2143  //Expr
2144  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2145  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2146  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2147  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2148  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2149  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2150  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2151  //Integer Literal
2152  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2153  Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2154  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2155  IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2156 
2157  // Abbreviation for EXPR_CHARACTER_LITERAL
2158  Abv = std::make_shared<BitCodeAbbrev>();
2159  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2160  //Stmt
2161  //Expr
2162  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2163  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2164  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2165  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2166  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2167  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2168  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2169  //Character Literal
2170  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2171  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2172  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2173  CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2174 
2175  // Abbreviation for EXPR_IMPLICIT_CAST
2176  Abv = std::make_shared<BitCodeAbbrev>();
2177  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2178  // Stmt
2179  // Expr
2180  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2181  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2182  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2183  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2184  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2185  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2186  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2187  // CastExpr
2188  Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2189  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind
2190  // ImplicitCastExpr
2191  ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2192 
2193  Abv = std::make_shared<BitCodeAbbrev>();
2194  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2195  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2196  DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2197 
2198  Abv = std::make_shared<BitCodeAbbrev>();
2199  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2200  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2201  DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2202 }
2203 
2204 /// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2205 /// consumers of the AST.
2206 ///
2207 /// Such decls will always be deserialized from the AST file, so we would like
2208 /// this to be as restrictive as possible. Currently the predicate is driven by
2209 /// code generation requirements, if other clients have a different notion of
2210 /// what is "required" then we may have to consider an alternate scheme where
2211 /// clients can iterate over the top-level decls and get information on them,
2212 /// without necessary deserializing them. We could explicitly require such
2213 /// clients to use a separate API call to "realize" the decl. This should be
2214 /// relatively painless since they would presumably only do it for top-level
2215 /// decls.
2216 static bool isRequiredDecl(const Decl *D, ASTContext &Context,
2217  bool WritingModule) {
2218  // An ObjCMethodDecl is never considered as "required" because its
2219  // implementation container always is.
2220 
2221  // File scoped assembly or obj-c or OMP declare target implementation must be
2222  // seen.
2223  if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D) ||
2224  D->hasAttr<OMPDeclareTargetDeclAttr>())
2225  return true;
2226 
2227  if (WritingModule && (isa<VarDecl>(D) || isa<ImportDecl>(D))) {
2228  // These declarations are part of the module initializer, and are emitted
2229  // if and when the module is imported, rather than being emitted eagerly.
2230  return false;
2231  }
2232 
2233  return Context.DeclMustBeEmitted(D);
2234 }
2235 
2236 void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
2237  PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
2238  "serializing");
2239 
2240  // Determine the ID for this declaration.
2242  assert(!D->isFromASTFile() && "should not be emitting imported decl");
2243  serialization::DeclID &IDR = DeclIDs[D];
2244  if (IDR == 0)
2245  IDR = NextDeclID++;
2246 
2247  ID = IDR;
2248 
2249  assert(ID >= FirstDeclID && "invalid decl ID");
2250 
2251  RecordData Record;
2252  ASTDeclWriter W(*this, Context, Record);
2253 
2254  // Build a record for this declaration
2255  W.Visit(D);
2256 
2257  // Emit this declaration to the bitstream.
2258  uint64_t Offset = W.Emit(D);
2259 
2260  // Record the offset for this declaration
2261  SourceLocation Loc = D->getLocation();
2262  unsigned Index = ID - FirstDeclID;
2263  if (DeclOffsets.size() == Index)
2264  DeclOffsets.push_back(DeclOffset(Loc, Offset));
2265  else if (DeclOffsets.size() < Index) {
2266  // FIXME: Can/should this happen?
2267  DeclOffsets.resize(Index+1);
2268  DeclOffsets[Index].setLocation(Loc);
2269  DeclOffsets[Index].BitOffset = Offset;
2270  } else {
2271  llvm_unreachable("declarations should be emitted in ID order");
2272  }
2273 
2274  SourceManager &SM = Context.getSourceManager();
2275  if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
2276  associateDeclWithFile(D, ID);
2277 
2278  // Note declarations that should be deserialized eagerly so that we can add
2279  // them to a record in the AST file later.
2280  if (isRequiredDecl(D, Context, WritingModule))
2281  EagerlyDeserializedDecls.push_back(ID);
2282 }
2283 
2285  // Switch case IDs are per function body.
2286  Writer->ClearSwitchCaseIDs();
2287 
2288  assert(FD->doesThisDeclarationHaveABody());
2289  bool ModulesCodegen = false;
2290  if (Writer->WritingModule && !FD->isDependentContext()) {
2292  if (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
2293  // When building a C++ Modules TS module interface unit, a strong
2294  // definition in the module interface is provided by the compilation of
2295  // that module interface unit, not by its users. (Inline functions are
2296  // still emitted in module users.)
2297  Linkage = Writer->Context->GetGVALinkageForFunction(FD);
2298  ModulesCodegen = *Linkage == GVA_StrongExternal;
2299  }
2300  if (Writer->Context->getLangOpts().ModulesCodegen) {
2301  // Under -fmodules-codegen, codegen is performed for all non-internal,
2302  // non-always_inline functions.
2303  if (!FD->hasAttr<AlwaysInlineAttr>()) {
2304  if (!Linkage)
2305  Linkage = Writer->Context->GetGVALinkageForFunction(FD);
2306  ModulesCodegen = *Linkage != GVA_Internal;
2307  }
2308  }
2309  }
2310  Record->push_back(ModulesCodegen);
2311  if (ModulesCodegen)
2312  Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));
2313  if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
2314  Record->push_back(CD->getNumCtorInitializers());
2315  if (CD->getNumCtorInitializers())
2316  AddCXXCtorInitializers(
2317  llvm::makeArrayRef(CD->init_begin(), CD->init_end()));
2318  }
2319  AddStmt(FD->getBody());
2320 }
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition: Decl.cpp:2426
SourceLocation getGetterNameLoc() const
Definition: DeclObjC.h:924
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1379
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1406
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition: Decl.h:2689
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
Definition: DeclTemplate.h:722
const Type * getTypeForDecl() const
Definition: DeclObjC.h:1938
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3179
Represents a function declaration or definition.
Definition: Decl.h:1714
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:1286
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:1385
void VisitStaticAssertDecl(StaticAssertDecl *D)
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:757
void VisitCXXMethodDecl(CXXMethodDecl *D)
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
Definition: ASTCommon.cpp:241
A (possibly-)qualified type.
Definition: Type.h:654
Static storage duration.
Definition: Specifiers.h:278
const char * getDeclKindName() const
Definition: DeclBase.cpp:123
unsigned param_size() const
Definition: DeclObjC.h:379
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2344
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3608
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:1549
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2846
bool isObjCMethodParameter() const
Definition: Decl.h:1576
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:3133
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1442
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:2610
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2728
void VisitCXXRecordDecl(CXXRecordDecl *D)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1017
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:2960
Defines the SourceManager interface.
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1460
bool hasVolatileMember() const
Definition: Decl.h:3661
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:2840
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:3964
An ImplicitCastExpr record.
Definition: ASTBitCodes.h:1596
bool isNothrow() const
Definition: Decl.cpp:4342
IdentifierInfo * getGetterId() const
Definition: DeclCXX.h:3911
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1397
ThreadStorageClassSpecifier getTSCSpec() const
Definition: Decl.h:1026
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:2080
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:958
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
Expr * getSetterCXXAssignment() const
Definition: DeclObjC.h:2876
void VisitTranslationUnitDecl(TranslationUnitDecl *D)
A record that stores the set of declarations that are lexically stored within a given DeclContext...
Definition: ASTBitCodes.h:1304
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:1332
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:4230
ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, ASTWriter::RecordDataImpl &Record)
Expr * getOperatorDeleteThisArg() const
Definition: DeclCXX.h:2707
Declaration of a variable template.
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
Represent a C++ namespace.
Definition: Decl.h:514
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1261
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction...
Definition: DeclObjC.h:2678
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:413
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:797
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2448
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition: Decl.h:2656
size_t param_size() const
Definition: Decl.h:2238
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:808
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition: DeclCXX.h:3090
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3157
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:1382
A PragmaDetectMismatchDecl record.
Definition: ASTBitCodes.h:1457
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1343
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
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
Represents a variable declaration or definition.
Definition: Decl.h:812
Declaration of a redeclarable template.
Definition: DeclTemplate.h:737
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
An OMPCapturedExprDecl record.
Definition: ASTBitCodes.h:1451
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:3484
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1331
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:1659
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:1432
void VisitIndirectFieldDecl(IndirectFieldDecl *D)
bool isInvalidDecl() const
Definition: DeclBase.h:547
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
unsigned getContextParamPosition() const
Definition: Decl.h:4089
protocol_range protocols() const
Definition: DeclObjC.h:2148
unsigned IsExplicitSpecified
Definition: Decl.h:1743
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1409
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:630
Represents a parameter to a function.
Definition: Decl.h:1533
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:1237
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:2708
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition: Decl.h:1354
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
A CXXConstructorDecl record for an inherited constructor.
Definition: ASTBitCodes.h:1364
Represents a struct/union/class.
Definition: Decl.h:3548
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2840
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:87
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
Definition: Decl.h:3438
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:3750
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2715
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2868
CXXRecordDecl * getPreviousDecl()
Definition: DeclCXX.h:736
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:3071
Represents a member of a struct/union/class.
Definition: Decl.h:2521
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
const llvm::APSInt & getInitVal() const
Definition: Decl.h:2749
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1586
StringRef getValue() const
Definition: Decl.h:197
bool isDefined() const
Definition: DeclObjC.h:462
InitKind getInitializerKind() const
Get initializer kind.
Definition: DeclOpenMP.h:157
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:942
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:2644
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:3920
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:1400
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:3924
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1424
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2222
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:3330
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:2717
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:3853
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:2673
void append(InputIterator begin, InputIterator end)
Definition: ASTWriter.h:797
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:986
TagKind getTagKind() const
Definition: Decl.h:3216
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:1373
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:1607
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:4402
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void VisitUsingShadowDecl(UsingShadowDecl *D)
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1334
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.cpp:3279
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:879
ArrayRef< NamedDecl * > chain() const
Definition: Decl.h:2789
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1337
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:857
A DecompositionDecl record.
Definition: ASTBitCodes.h:1282
Represents a declaration of a type.
Definition: Decl.h:2816
SourceLocation RAngleLoc
The source location of the right angle bracket (&#39;>&#39;).
Definition: TemplateBase.h:609
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
Definition: Decl.h:3448
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
Definition: Decl.h:3529
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:1381
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3394
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:1803
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
void VisitBindingDecl(BindingDecl *D)
TemplateParameterList * getTemplateParameterList(unsigned i) const
const Expr * getInitExpr() const
Definition: Decl.h:2747
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2849
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition: DeclFriend.h:132
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1385
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition: Decl.h:3163
SourceLocation getExternLoc() const
Definition: DeclCXX.h:2852
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
Definition: DeclBase.h:826
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:4552
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:950
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4015
Represents an ObjC class declaration.
Definition: DeclObjC.h:1191
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclObjC.cpp:934
Represents a linkage specification.
Definition: DeclCXX.h:2794
QualType getReturnType() const
Definition: DeclObjC.h:361
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
A binding in a decomposition declaration.
Definition: DeclCXX.h:3773
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:3264
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:875
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:1133
ArgPassingKind getArgPassingRestrictions() const
Definition: Decl.h:3703
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Definition: Decl.h:3653
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:4164
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:3755
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition: Decl.h:1078
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:2778
NodeId Parent
Definition: ASTDiff.cpp:192
void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
bool hasAttr() const
Definition: DeclBase.h:536
void VisitObjCContainerDecl(ObjCContainerDecl *D)
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclObjC.h:2834
RecordDecl * getMostRecentDecl()
Definition: Decl.h:3632
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:2980
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1414
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:2843
SourceLocation getTypenameLoc() const
Returns the source location of the &#39;typename&#39; keyword.
Definition: DeclCXX.h:3677
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:688
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
Definition: Decl.h:3414
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1355
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:1366
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition: DeclOpenMP.h:147
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1415
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:2908
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1394
static bool classofKind(Kind K)
Definition: DeclObjC.h:2018
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1448
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:881
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3218
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1580
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3838
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:636
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3370
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1252
unsigned getChainingSize() const
Definition: Decl.h:2795
Selector getSetterName() const
Definition: DeclObjC.h:931
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3478
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1264
const FunctionProtoType * T
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1592
void VisitRecordDecl(RecordDecl *D)
Declaration of a template type parameter.
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D)
TypeSourceInfo * getTypeSourceInfo() const
Definition: DeclObjC.h:844
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:612
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:4060
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2671
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:2240
A CXXConstructorDecl record.
Definition: ASTBitCodes.h:1361
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:1304
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:552
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:973
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:2128
DeclContext * getDeclContext()
Definition: DeclBase.h:426
void VisitUsingDecl(UsingDecl *D)
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1391
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
EnumDecl * getMostRecentDecl()
Definition: Decl.h:3362
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:3452
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1367
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
unsigned IsCopyDeductionCandidate
[C++17] Only used by CXXDeductionGuideDecl.
Definition: Decl.h:1786
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Definition: ASTBitCodes.h:1428
IdentifierInfo * getSetterId() const
Definition: DeclCXX.h:3913
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:1322
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1341
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:905
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:452
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:1567
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:1276
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:1963
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2733
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1228
ImplicitParamDecl * getSelfDecl() const
Definition: DeclObjC.h:444
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1276
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
QualType getType() const
Definition: DeclObjC.h:846
const SourceManager & SM
Definition: Format.cpp:1442
void VisitTagDecl(TagDecl *D)
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1439
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1249
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
CXXMethodDecl * getMostRecentDecl()
Definition: DeclCXX.h:2104
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:220
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2640
void VisitMSPropertyDecl(MSPropertyDecl *D)
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:1258
void VisitVarTemplateDecl(VarTemplateDecl *D)
AttrVec & getAttrs()
Definition: DeclBase.h:478
bool isNonTrivialToPrimitiveDestroy() const
Definition: Decl.h:3688
bool hasAttrs() const
Definition: DeclBase.h:472
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:2389
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition: DeclObjC.h:375
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:795
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition: Decl.h:2084
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclBase.h:409
unsigned protocol_size() const
Definition: DeclObjC.h:2187
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition: DeclCXX.h:2965
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:2122
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:4185
SourceLocation getUsingLoc() const
Returns the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3581
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
Definition: Decl.h:3672
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:1340
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:208
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition: DeclCXX.h:3512
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:2010
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:1313
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:187
SourceLocation getSuperClassLoc() const
Definition: DeclObjC.h:2710
void VisitObjCImplDecl(ObjCImplDecl *D)
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:2969
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:617
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition: Decl.h:2694
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:3006
SourceLocation getUsingLoc() const
Return the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3363
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2546
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition: Decl.h:2997
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:3549
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3591
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2663
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:3821
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2016
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
void VisitUsingPackDecl(UsingPackDecl *D)
C-style initialization with assignment.
Definition: Decl.h:817
bool isConversionFromLambda() const
Definition: Decl.h:3977
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
A TemplateTypeParmDecl record.
Definition: ASTBitCodes.h:1403
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:227
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:2939
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2299
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:3473
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:2649
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:746
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:700
bool isModed() const
Definition: Decl.h:2904
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:70
unsigned getODRHash()
Returns ODRHash of the function.
Definition: Decl.cpp:3661
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1647
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
Definition: ASTWriter.h:847
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:2535
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:1319
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3724
void VisitPragmaCommentDecl(PragmaCommentDecl *D)
SourceLocation getRBraceLoc() const
Definition: DeclCXX.h:2853
bool hasFlexibleArrayMember() const
Definition: Decl.h:3639
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:2436
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:4120
protocol_range protocols() const
Definition: DeclObjC.h:2375
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1240
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: Decl.h:1590
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2858
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1370
void VisitFieldDecl(FieldDecl *D)
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2459
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:2490
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:1262
ArrayRef< Capture > captures() const
Definition: Decl.h:3968
PropertyAttributeKind getPropertyAttributesAsWritten() const
Definition: DeclObjC.h:869
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:399
bool isVariadic() const
Definition: Decl.h:3916
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:587
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:838
void VisitNamedDecl(NamedDecl *D)
Represents a field injected from an anonymous union/struct into the parent scope. ...
Definition: Decl.h:2767
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1388
QualType getUnderlyingType() const
Definition: Decl.h:2913
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:3062
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition: DeclCXX.h:2961
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1214
const Expr * getInit() const
Definition: Decl.h:1217
AccessSpecifier getAccess() const
Definition: DeclBase.h:461
A decomposition declaration.
Definition: DeclCXX.h:3821
bool isEmbeddedInDeclarator() const
Definition: Decl.h:3172
void VisitTypeDecl(TypeDecl *D)
unsigned getNumTemplateParameters() const
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3645
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
Definition: ASTBitCodes.h:1436
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:576
Kind getKind() const
Definition: DeclBase.h:420
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3681
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1346
bool isNonTrivialToPrimitiveCopy() const
Definition: Decl.h:3680
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:3299
SourceLocation LAngleLoc
The source location of the left angle bracket (&#39;<&#39;).
Definition: TemplateBase.h:606
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:1390
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:1050
SourceLocation getSetterNameLoc() const
Definition: DeclObjC.h:932
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2766
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:2703
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1454
void VisitNamespaceDecl(NamespaceDecl *D)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2571
void VisitVarDecl(VarDecl *D)
Expr * getUninstantiatedDefaultArg()
Definition: Decl.cpp:2581
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2169
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C...
Definition: Decl.h:1342
size_t param_size() const
Definition: Decl.h:3943
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:1669
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:4062
bool isParamDestroyedInCallee() const
Definition: Decl.h:3711
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:3385
SourceManager & getSourceManager()
Definition: ASTContext.h:644
bool capturesCXXThis() const
Definition: Decl.h:3973
ImplementationControl getImplementationControl() const
Definition: DeclObjC.h:502
static bool classofKind(Kind K)
Definition: DeclCXX.h:1948
void VisitDecl(Decl *D)
SourceRange getAtEndRange() const
Definition: DeclObjC.h:1137
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1581
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:2051
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:2031
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2432
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:3247
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition: Decl.h:2596
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition: Decl.h:3152
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:4204
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
Definition: Decl.h:1322
An object for streaming information to a record.
Definition: ASTWriter.h:747
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition: Decl.h:3465
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1964
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:962
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:332
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:1255
void VisitEnumConstantDecl(EnumConstantDecl *D)
SourceLocation getFriendLoc() const
Retrieves the location of the &#39;friend&#39; keyword.
bool isFailed() const
Definition: DeclCXX.h:3753
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1246
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:654
ImplicitParamDecl * getCmdDecl() const
Definition: DeclObjC.h:446
void VisitClassScopeFunctionSpecializationDecl(ClassScopeFunctionSpecializationDecl *D)
bool isVariadic() const
Definition: DeclObjC.h:454
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:104
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:1206
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1219
unsigned protocol_size() const
Definition: DeclObjC.h:2384
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3422
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition: Decl.h:2023
An ExportDecl record.
Definition: ASTBitCodes.h:1349
bool blockMissingReturnType() const
Definition: Decl.h:3974
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3698
unsigned varlist_size() const
Definition: DeclOpenMP.h:74
size_t size() const
Definition: ASTWriter.h:801
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:230
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:3927
NamedDecl * getMostRecentDecl()
Definition: Decl.h:445
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2837
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
bool hasObjectMember() const
Definition: Decl.h:3658
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D)
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:3795
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:3241
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1400
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:7132
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1412
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:1132
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:3890
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:3087
QualType getType() const
Definition: Decl.h:647
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
Definition: DeclBase.h:601
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:939
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:2998
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:1363
AccessControl getAccessControl() const
Definition: DeclObjC.h:2003
Declaration of a friend template.
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2438
bool isPropertyAccessor() const
Definition: DeclObjC.h:459
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:3516
Selector getGetterName() const
Definition: DeclObjC.h:923
Represents C++ using-directive.
Definition: DeclCXX.h:2894
SourceLocation getLParenLoc() const
Definition: DeclObjC.h:841
SourceLocation getEndOfDefinitionLoc() const
Definition: DeclObjC.h:1897
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:3179
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:729
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:694
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:2518
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:417
const StringLiteral * getAsmString() const
Definition: Decl.h:3827
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3117
Represents a pack of using declarations that a single using-declarator pack-expanded into...
Definition: DeclCXX.h:3480
SourceLocation getRBraceLoc() const
Definition: Decl.h:618
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:405
void VisitObjCIvarDecl(ObjCIvarDecl *D)
PragmaMSCommentKind getCommentKind() const
Definition: Decl.h:162
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2748
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:2641