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"
23 #include "llvm/Bitcode/BitstreamWriter.h"
24 #include "llvm/Support/ErrorHandling.h"
25 using namespace clang;
26 using namespace serialization;
27 
28 //===----------------------------------------------------------------------===//
29 // Declaration serialization
30 //===----------------------------------------------------------------------===//
31 
32 namespace clang {
33  class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> {
34  ASTWriter &Writer;
35  ASTContext &Context;
36  ASTRecordWriter Record;
37 
39  unsigned AbbrevToUse;
40 
41  public:
42  ASTDeclWriter(ASTWriter &Writer, ASTContext &Context,
44  : Writer(Writer), Context(Context), Record(Writer, Record),
45  Code((serialization::DeclCode)0), AbbrevToUse(0) {}
46 
47  uint64_t Emit(Decl *D) {
48  if (!Code)
49  llvm::report_fatal_error(StringRef("unexpected declaration kind '") +
50  D->getDeclKindName() + "'");
51  return Record.Emit(Code, AbbrevToUse);
52  }
53 
54  void Visit(Decl *D);
55 
56  void VisitDecl(Decl *D);
57  void VisitPragmaCommentDecl(PragmaCommentDecl *D);
58  void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D);
59  void VisitTranslationUnitDecl(TranslationUnitDecl *D);
60  void VisitNamedDecl(NamedDecl *D);
61  void VisitLabelDecl(LabelDecl *LD);
62  void VisitNamespaceDecl(NamespaceDecl *D);
63  void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
64  void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
65  void VisitTypeDecl(TypeDecl *D);
66  void VisitTypedefNameDecl(TypedefNameDecl *D);
67  void VisitTypedefDecl(TypedefDecl *D);
68  void VisitTypeAliasDecl(TypeAliasDecl *D);
69  void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
70  void VisitTagDecl(TagDecl *D);
71  void VisitEnumDecl(EnumDecl *D);
72  void VisitRecordDecl(RecordDecl *D);
73  void VisitCXXRecordDecl(CXXRecordDecl *D);
74  void VisitClassTemplateSpecializationDecl(
76  void VisitClassTemplatePartialSpecializationDecl(
78  void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D);
79  void VisitVarTemplatePartialSpecializationDecl(
81  void VisitClassScopeFunctionSpecializationDecl(
83  void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
84  void VisitValueDecl(ValueDecl *D);
85  void VisitEnumConstantDecl(EnumConstantDecl *D);
86  void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
87  void VisitDeclaratorDecl(DeclaratorDecl *D);
88  void VisitFunctionDecl(FunctionDecl *D);
89  void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D);
90  void VisitCXXMethodDecl(CXXMethodDecl *D);
91  void VisitCXXConstructorDecl(CXXConstructorDecl *D);
92  void VisitCXXDestructorDecl(CXXDestructorDecl *D);
93  void VisitCXXConversionDecl(CXXConversionDecl *D);
94  void VisitFieldDecl(FieldDecl *D);
95  void VisitMSPropertyDecl(MSPropertyDecl *D);
96  void VisitIndirectFieldDecl(IndirectFieldDecl *D);
97  void VisitVarDecl(VarDecl *D);
98  void VisitImplicitParamDecl(ImplicitParamDecl *D);
99  void VisitParmVarDecl(ParmVarDecl *D);
100  void VisitDecompositionDecl(DecompositionDecl *D);
101  void VisitBindingDecl(BindingDecl *D);
102  void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
103  void VisitTemplateDecl(TemplateDecl *D);
104  void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
105  void VisitClassTemplateDecl(ClassTemplateDecl *D);
106  void VisitVarTemplateDecl(VarTemplateDecl *D);
107  void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
108  void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
109  void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
110  void VisitUsingDecl(UsingDecl *D);
111  void VisitUsingPackDecl(UsingPackDecl *D);
112  void VisitUsingShadowDecl(UsingShadowDecl *D);
113  void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D);
114  void VisitLinkageSpecDecl(LinkageSpecDecl *D);
115  void VisitExportDecl(ExportDecl *D);
116  void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
117  void VisitImportDecl(ImportDecl *D);
118  void VisitAccessSpecDecl(AccessSpecDecl *D);
119  void VisitFriendDecl(FriendDecl *D);
120  void VisitFriendTemplateDecl(FriendTemplateDecl *D);
121  void VisitStaticAssertDecl(StaticAssertDecl *D);
122  void VisitBlockDecl(BlockDecl *D);
123  void VisitCapturedDecl(CapturedDecl *D);
124  void VisitEmptyDecl(EmptyDecl *D);
125 
126  void VisitDeclContext(DeclContext *DC);
127  template <typename T> void VisitRedeclarable(Redeclarable<T> *D);
128 
129 
130  // FIXME: Put in the same order is DeclNodes.td?
131  void VisitObjCMethodDecl(ObjCMethodDecl *D);
132  void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D);
133  void VisitObjCContainerDecl(ObjCContainerDecl *D);
134  void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
135  void VisitObjCIvarDecl(ObjCIvarDecl *D);
136  void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
137  void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D);
138  void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
139  void VisitObjCImplDecl(ObjCImplDecl *D);
140  void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
141  void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
142  void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
143  void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
144  void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
145  void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
146  void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
147  void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
148 
149  /// Add an Objective-C type parameter list to the given record.
151  // Empty type parameter list.
152  if (!typeParams) {
153  Record.push_back(0);
154  return;
155  }
156 
157  Record.push_back(typeParams->size());
158  for (auto typeParam : *typeParams) {
159  Record.AddDeclRef(typeParam);
160  }
161  Record.AddSourceLocation(typeParams->getLAngleLoc());
162  Record.AddSourceLocation(typeParams->getRAngleLoc());
163  }
164 
165  /// Add to the record the first declaration from each module file that
166  /// provides a declaration of D. The intent is to provide a sufficient
167  /// set such that reloading this set will load all current redeclarations.
168  void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
169  llvm::MapVector<ModuleFile*, const Decl*> Firsts;
170  // FIXME: We can skip entries that we know are implied by others.
171  for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) {
172  if (R->isFromASTFile())
173  Firsts[Writer.Chain->getOwningModuleFile(R)] = R;
174  else if (IncludeLocal)
175  Firsts[nullptr] = R;
176  }
177  for (const auto &F : Firsts)
178  Record.AddDeclRef(F.second);
179  }
180 
181  /// Get the specialization decl from an entry in the specialization list.
182  template <typename EntryType>
184  getSpecializationDecl(EntryType &T) {
186  }
187 
188  /// Get the list of partial specializations from a template's common ptr.
189  template<typename T>
190  decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) {
191  return Common->PartialSpecializations;
192  }
194  return None;
195  }
196 
197  template<typename DeclTy>
198  void AddTemplateSpecializations(DeclTy *D) {
199  auto *Common = D->getCommonPtr();
200 
201  // If we have any lazy specializations, and the external AST source is
202  // our chained AST reader, we can just write out the DeclIDs. Otherwise,
203  // we need to resolve them to actual declarations.
204  if (Writer.Chain != Writer.Context->getExternalSource() &&
205  Common->LazySpecializations) {
206  D->LoadLazySpecializations();
207  assert(!Common->LazySpecializations);
208  }
209 
210  ArrayRef<DeclID> LazySpecializations;
211  if (auto *LS = Common->LazySpecializations)
212  LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]);
213 
214  // Add a slot to the record for the number of specializations.
215  unsigned I = Record.size();
216  Record.push_back(0);
217 
218  // AddFirstDeclFromEachModule might trigger deserialization, invalidating
219  // *Specializations iterators.
221  for (auto &Entry : Common->Specializations)
222  Specs.push_back(getSpecializationDecl(Entry));
223  for (auto &Entry : getPartialSpecializations(Common))
224  Specs.push_back(getSpecializationDecl(Entry));
225 
226  for (auto *D : Specs) {
227  assert(D->isCanonicalDecl() && "non-canonical decl in set");
228  AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
229  }
230  Record.append(LazySpecializations.begin(), LazySpecializations.end());
231 
232  // Update the size entry we added earlier.
233  Record[I] = Record.size() - I - 1;
234  }
235 
236  /// Ensure that this template specialization is associated with the specified
237  /// template on reload.
238  void RegisterTemplateSpecialization(const Decl *Template,
239  const Decl *Specialization) {
240  Template = Template->getCanonicalDecl();
241 
242  // If the canonical template is local, we'll write out this specialization
243  // when we emit it.
244  // FIXME: We can do the same thing if there is any local declaration of
245  // the template, to avoid emitting an update record.
246  if (!Template->isFromASTFile())
247  return;
248 
249  // We only need to associate the first local declaration of the
250  // specialization. The other declarations will get pulled in by it.
251  if (Writer.getFirstLocalDecl(Specialization) != Specialization)
252  return;
253 
254  Writer.DeclUpdates[Template].push_back(ASTWriter::DeclUpdate(
255  UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION, Specialization));
256  }
257  };
258 }
259 
262 
263  // Source locations require array (variable-length) abbreviations. The
264  // abbreviation infrastructure requires that arrays are encoded last, so
265  // we handle it here in the case of those classes derived from DeclaratorDecl
266  if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
267  Record.AddTypeSourceInfo(DD->getTypeSourceInfo());
268  }
269 
270  // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
271  // have been written. We want it last because we will not read it back when
272  // retrieving it from the AST, we'll just lazily set the offset.
273  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
274  Record.push_back(FD->doesThisDeclarationHaveABody());
275  if (FD->doesThisDeclarationHaveABody())
276  Record.AddFunctionDefinition(FD);
277  }
278 
279  // If this declaration is also a DeclContext, write blocks for the
280  // declarations that lexically stored inside its context and those
281  // declarations that are visible from its context.
282  if (DeclContext *DC = dyn_cast<DeclContext>(D))
283  VisitDeclContext(DC);
284 }
285 
287  Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
288  if (D->getDeclContext() != D->getLexicalDeclContext())
289  Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
290  else
291  Record.push_back(0);
292  Record.push_back(D->isInvalidDecl());
293  Record.push_back(D->hasAttrs());
294  if (D->hasAttrs())
295  Record.AddAttributes(D->getAttrs());
296  Record.push_back(D->isImplicit());
297  Record.push_back(D->isUsed(false));
298  Record.push_back(D->isReferenced());
299  Record.push_back(D->isTopLevelDeclInObjCContainer());
300  Record.push_back(D->getAccess());
301  Record.push_back(D->isModulePrivate());
302  Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
303 
304  // If this declaration injected a name into a context different from its
305  // lexical context, and that context is an imported namespace, we need to
306  // update its visible declarations to include this name.
307  //
308  // This happens when we instantiate a class with a friend declaration or a
309  // function with a local extern declaration, for instance.
310  //
311  // FIXME: Can we handle this in AddedVisibleDecl instead?
312  if (D->isOutOfLine()) {
313  auto *DC = D->getDeclContext();
314  while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
315  if (!NS->isFromASTFile())
316  break;
317  Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
318  if (!NS->isInlineNamespace())
319  break;
320  DC = NS->getParent();
321  }
322  }
323 }
324 
326  StringRef Arg = D->getArg();
327  Record.push_back(Arg.size());
328  VisitDecl(D);
329  Record.AddSourceLocation(D->getLocStart());
330  Record.push_back(D->getCommentKind());
331  Record.AddString(Arg);
333 }
334 
337  StringRef Name = D->getName();
338  StringRef Value = D->getValue();
339  Record.push_back(Name.size() + 1 + Value.size());
340  VisitDecl(D);
341  Record.AddSourceLocation(D->getLocStart());
342  Record.AddString(Name);
343  Record.AddString(Value);
345 }
346 
348  llvm_unreachable("Translation units aren't directly serialized");
349 }
350 
352  VisitDecl(D);
353  Record.AddDeclarationName(D->getDeclName());
354  Record.push_back(needsAnonymousDeclarationNumber(D)
355  ? Writer.getAnonymousDeclarationNumber(D)
356  : 0);
357 }
358 
360  VisitNamedDecl(D);
361  Record.AddSourceLocation(D->getLocStart());
362  Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
363 }
364 
366  VisitRedeclarable(D);
367  VisitTypeDecl(D);
368  Record.AddTypeSourceInfo(D->getTypeSourceInfo());
369  Record.push_back(D->isModed());
370  if (D->isModed())
371  Record.AddTypeRef(D->getUnderlyingType());
372  Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
373 }
374 
376  VisitTypedefNameDecl(D);
377  if (D->getDeclContext() == D->getLexicalDeclContext() &&
378  !D->hasAttrs() &&
379  !D->isImplicit() &&
380  D->getFirstDecl() == D->getMostRecentDecl() &&
381  !D->isInvalidDecl() &&
383  !D->isModulePrivate() &&
386  AbbrevToUse = Writer.getDeclTypedefAbbrev();
387 
389 }
390 
392  VisitTypedefNameDecl(D);
393  Record.AddDeclRef(D->getDescribedAliasTemplate());
395 }
396 
398  VisitRedeclarable(D);
399  VisitTypeDecl(D);
400  Record.push_back(D->getIdentifierNamespace());
401  Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
402  if (!isa<CXXRecordDecl>(D))
403  Record.push_back(D->isCompleteDefinition());
404  Record.push_back(D->isEmbeddedInDeclarator());
405  Record.push_back(D->isFreeStanding());
406  Record.push_back(D->isCompleteDefinitionRequired());
407  Record.AddSourceRange(D->getBraceRange());
408 
409  if (D->hasExtInfo()) {
410  Record.push_back(1);
411  Record.AddQualifierInfo(*D->getExtInfo());
412  } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
413  Record.push_back(2);
414  Record.AddDeclRef(TD);
415  Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
416  } else {
417  Record.push_back(0);
418  }
419 }
420 
422  VisitTagDecl(D);
423  Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
424  if (!D->getIntegerTypeSourceInfo())
425  Record.AddTypeRef(D->getIntegerType());
426  Record.AddTypeRef(D->getPromotionType());
427  Record.push_back(D->getNumPositiveBits());
428  Record.push_back(D->getNumNegativeBits());
429  Record.push_back(D->isScoped());
430  Record.push_back(D->isScopedUsingClassTag());
431  Record.push_back(D->isFixed());
432  if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) {
433  Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
434  Record.push_back(MemberInfo->getTemplateSpecializationKind());
435  Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
436  } else {
437  Record.AddDeclRef(nullptr);
438  }
439 
440  if (D->getDeclContext() == D->getLexicalDeclContext() &&
441  !D->hasAttrs() &&
442  !D->isImplicit() &&
443  !D->isUsed(false) &&
444  !D->hasExtInfo() &&
446  D->getFirstDecl() == D->getMostRecentDecl() &&
447  !D->isInvalidDecl() &&
448  !D->isReferenced() &&
450  D->getAccess() == AS_none &&
451  !D->isModulePrivate() &&
453  !D->getIntegerTypeSourceInfo() &&
457  AbbrevToUse = Writer.getDeclEnumAbbrev();
458 
460 }
461 
463  VisitTagDecl(D);
464  Record.push_back(D->hasFlexibleArrayMember());
465  Record.push_back(D->isAnonymousStructOrUnion());
466  Record.push_back(D->hasObjectMember());
467  Record.push_back(D->hasVolatileMember());
468 
469  if (D->getDeclContext() == D->getLexicalDeclContext() &&
470  !D->hasAttrs() &&
471  !D->isImplicit() &&
472  !D->isUsed(false) &&
473  !D->hasExtInfo() &&
475  D->getFirstDecl() == D->getMostRecentDecl() &&
476  !D->isInvalidDecl() &&
477  !D->isReferenced() &&
479  D->getAccess() == AS_none &&
480  !D->isModulePrivate() &&
484  AbbrevToUse = Writer.getDeclRecordAbbrev();
485 
487 }
488 
490  VisitNamedDecl(D);
491  Record.AddTypeRef(D->getType());
492 }
493 
495  VisitValueDecl(D);
496  Record.push_back(D->getInitExpr()? 1 : 0);
497  if (D->getInitExpr())
498  Record.AddStmt(D->getInitExpr());
499  Record.AddAPSInt(D->getInitVal());
500 
502 }
503 
505  VisitValueDecl(D);
506  Record.AddSourceLocation(D->getInnerLocStart());
507  Record.push_back(D->hasExtInfo());
508  if (D->hasExtInfo())
509  Record.AddQualifierInfo(*D->getExtInfo());
510 }
511 
513  VisitRedeclarable(D);
514  VisitDeclaratorDecl(D);
515  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
516  Record.push_back(D->getIdentifierNamespace());
517 
518  // FunctionDecl's body is handled last at ASTWriterDecl::Visit,
519  // after everything else is written.
520 
521  Record.push_back((int)D->SClass); // FIXME: stable encoding
522  Record.push_back(D->IsInline);
523  Record.push_back(D->IsInlineSpecified);
524  Record.push_back(D->IsExplicitSpecified);
525  Record.push_back(D->IsVirtualAsWritten);
526  Record.push_back(D->IsPure);
527  Record.push_back(D->HasInheritedPrototype);
528  Record.push_back(D->HasWrittenPrototype);
529  Record.push_back(D->IsDeleted);
530  Record.push_back(D->IsTrivial);
531  Record.push_back(D->IsTrivialForCall);
532  Record.push_back(D->IsDefaulted);
533  Record.push_back(D->IsExplicitlyDefaulted);
534  Record.push_back(D->HasImplicitReturnZero);
535  Record.push_back(D->IsConstexpr);
536  Record.push_back(D->UsesSEHTry);
537  Record.push_back(D->HasSkippedBody);
538  Record.push_back(D->IsMultiVersion);
539  Record.push_back(D->IsLateTemplateParsed);
540  Record.push_back(D->getLinkageInternal());
541  Record.AddSourceLocation(D->getLocEnd());
542 
543  Record.push_back(D->getODRHash());
544 
545  Record.push_back(D->getTemplatedKind());
546  switch (D->getTemplatedKind()) {
548  break;
550  Record.AddDeclRef(D->getDescribedFunctionTemplate());
551  break;
554  Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
555  Record.push_back(MemberInfo->getTemplateSpecializationKind());
556  Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
557  break;
558  }
561  FTSInfo = D->getTemplateSpecializationInfo();
562 
563  RegisterTemplateSpecialization(FTSInfo->getTemplate(), D);
564 
565  Record.AddDeclRef(FTSInfo->getTemplate());
566  Record.push_back(FTSInfo->getTemplateSpecializationKind());
567 
568  // Template arguments.
569  Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
570 
571  // Template args as written.
572  Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
573  if (FTSInfo->TemplateArgumentsAsWritten) {
574  Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs);
575  for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs;
576  i!=e; ++i)
577  Record.AddTemplateArgumentLoc(
578  (*FTSInfo->TemplateArgumentsAsWritten)[i]);
579  Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc);
580  Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc);
581  }
582 
583  Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
584 
585  if (D->isCanonicalDecl()) {
586  // Write the template that contains the specializations set. We will
587  // add a FunctionTemplateSpecializationInfo to it when reading.
588  Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
589  }
590  break;
591  }
594  DFTSInfo = D->getDependentSpecializationInfo();
595 
596  // Templates.
597  Record.push_back(DFTSInfo->getNumTemplates());
598  for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i)
599  Record.AddDeclRef(DFTSInfo->getTemplate(i));
600 
601  // Templates args.
602  Record.push_back(DFTSInfo->getNumTemplateArgs());
603  for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i)
604  Record.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i));
605  Record.AddSourceLocation(DFTSInfo->getLAngleLoc());
606  Record.AddSourceLocation(DFTSInfo->getRAngleLoc());
607  break;
608  }
609  }
610 
611  Record.push_back(D->param_size());
612  for (auto P : D->parameters())
613  Record.AddDeclRef(P);
615 }
616 
618  VisitFunctionDecl(D);
619  Record.push_back(D->IsCopyDeductionCandidate);
621 }
622 
624  VisitNamedDecl(D);
625  // FIXME: convert to LazyStmtPtr?
626  // Unlike C/C++, method bodies will never be in header files.
627  bool HasBodyStuff = D->getBody() != nullptr ||
628  D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr;
629  Record.push_back(HasBodyStuff);
630  if (HasBodyStuff) {
631  Record.AddStmt(D->getBody());
632  Record.AddDeclRef(D->getSelfDecl());
633  Record.AddDeclRef(D->getCmdDecl());
634  }
635  Record.push_back(D->isInstanceMethod());
636  Record.push_back(D->isVariadic());
637  Record.push_back(D->isPropertyAccessor());
638  Record.push_back(D->isDefined());
639  Record.push_back(D->IsOverriding);
640  Record.push_back(D->HasSkippedBody);
641 
642  Record.push_back(D->IsRedeclaration);
643  Record.push_back(D->HasRedeclaration);
644  if (D->HasRedeclaration) {
645  assert(Context.getObjCMethodRedeclaration(D));
646  Record.AddDeclRef(Context.getObjCMethodRedeclaration(D));
647  }
648 
649  // FIXME: stable encoding for @required/@optional
650  Record.push_back(D->getImplementationControl());
651  // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
652  Record.push_back(D->getObjCDeclQualifier());
653  Record.push_back(D->hasRelatedResultType());
654  Record.AddTypeRef(D->getReturnType());
655  Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
656  Record.AddSourceLocation(D->getLocEnd());
657  Record.push_back(D->param_size());
658  for (const auto *P : D->parameters())
659  Record.AddDeclRef(P);
660 
661  Record.push_back(D->SelLocsKind);
662  unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
663  SourceLocation *SelLocs = D->getStoredSelLocs();
664  Record.push_back(NumStoredSelLocs);
665  for (unsigned i = 0; i != NumStoredSelLocs; ++i)
666  Record.AddSourceLocation(SelLocs[i]);
667 
669 }
670 
672  VisitTypedefNameDecl(D);
673  Record.push_back(D->Variance);
674  Record.push_back(D->Index);
675  Record.AddSourceLocation(D->VarianceLoc);
676  Record.AddSourceLocation(D->ColonLoc);
677 
679 }
680 
682  VisitNamedDecl(D);
683  Record.AddSourceLocation(D->getAtStartLoc());
684  Record.AddSourceRange(D->getAtEndRange());
685  // Abstract class (no need to define a stable serialization::DECL code).
686 }
687 
689  VisitRedeclarable(D);
690  VisitObjCContainerDecl(D);
691  Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
692  AddObjCTypeParamList(D->TypeParamList);
693 
694  Record.push_back(D->isThisDeclarationADefinition());
695  if (D->isThisDeclarationADefinition()) {
696  // Write the DefinitionData
697  ObjCInterfaceDecl::DefinitionData &Data = D->data();
698 
699  Record.AddTypeSourceInfo(D->getSuperClassTInfo());
700  Record.AddSourceLocation(D->getEndOfDefinitionLoc());
701  Record.push_back(Data.HasDesignatedInitializers);
702 
703  // Write out the protocols that are directly referenced by the @interface.
704  Record.push_back(Data.ReferencedProtocols.size());
705  for (const auto *P : D->protocols())
706  Record.AddDeclRef(P);
707  for (const auto &PL : D->protocol_locs())
708  Record.AddSourceLocation(PL);
709 
710  // Write out the protocols that are transitively referenced.
711  Record.push_back(Data.AllReferencedProtocols.size());
713  P = Data.AllReferencedProtocols.begin(),
714  PEnd = Data.AllReferencedProtocols.end();
715  P != PEnd; ++P)
716  Record.AddDeclRef(*P);
717 
718 
719  if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
720  // Ensure that we write out the set of categories for this class.
721  Writer.ObjCClassesWithCategories.insert(D);
722 
723  // Make sure that the categories get serialized.
724  for (; Cat; Cat = Cat->getNextClassCategoryRaw())
725  (void)Writer.GetDeclRef(Cat);
726  }
727  }
728 
730 }
731 
733  VisitFieldDecl(D);
734  // FIXME: stable encoding for @public/@private/@protected/@package
735  Record.push_back(D->getAccessControl());
736  Record.push_back(D->getSynthesize());
737 
738  if (D->getDeclContext() == D->getLexicalDeclContext() &&
739  !D->hasAttrs() &&
740  !D->isImplicit() &&
741  !D->isUsed(false) &&
742  !D->isInvalidDecl() &&
743  !D->isReferenced() &&
744  !D->isModulePrivate() &&
745  !D->getBitWidth() &&
746  !D->hasExtInfo() &&
747  D->getDeclName())
748  AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
749 
751 }
752 
754  VisitRedeclarable(D);
755  VisitObjCContainerDecl(D);
756 
757  Record.push_back(D->isThisDeclarationADefinition());
758  if (D->isThisDeclarationADefinition()) {
759  Record.push_back(D->protocol_size());
760  for (const auto *I : D->protocols())
761  Record.AddDeclRef(I);
762  for (const auto &PL : D->protocol_locs())
763  Record.AddSourceLocation(PL);
764  }
765 
767 }
768 
770  VisitFieldDecl(D);
772 }
773 
775  VisitObjCContainerDecl(D);
776  Record.AddSourceLocation(D->getCategoryNameLoc());
777  Record.AddSourceLocation(D->getIvarLBraceLoc());
778  Record.AddSourceLocation(D->getIvarRBraceLoc());
779  Record.AddDeclRef(D->getClassInterface());
780  AddObjCTypeParamList(D->TypeParamList);
781  Record.push_back(D->protocol_size());
782  for (const auto *I : D->protocols())
783  Record.AddDeclRef(I);
784  for (const auto &PL : D->protocol_locs())
785  Record.AddSourceLocation(PL);
787 }
788 
790  VisitNamedDecl(D);
791  Record.AddDeclRef(D->getClassInterface());
793 }
794 
796  VisitNamedDecl(D);
797  Record.AddSourceLocation(D->getAtLoc());
798  Record.AddSourceLocation(D->getLParenLoc());
799  Record.AddTypeRef(D->getType());
800  Record.AddTypeSourceInfo(D->getTypeSourceInfo());
801  // FIXME: stable encoding
802  Record.push_back((unsigned)D->getPropertyAttributes());
803  Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
804  // FIXME: stable encoding
805  Record.push_back((unsigned)D->getPropertyImplementation());
806  Record.AddDeclarationName(D->getGetterName());
807  Record.AddSourceLocation(D->getGetterNameLoc());
808  Record.AddDeclarationName(D->getSetterName());
809  Record.AddSourceLocation(D->getSetterNameLoc());
810  Record.AddDeclRef(D->getGetterMethodDecl());
811  Record.AddDeclRef(D->getSetterMethodDecl());
812  Record.AddDeclRef(D->getPropertyIvarDecl());
814 }
815 
817  VisitObjCContainerDecl(D);
818  Record.AddDeclRef(D->getClassInterface());
819  // Abstract class (no need to define a stable serialization::DECL code).
820 }
821 
823  VisitObjCImplDecl(D);
824  Record.AddSourceLocation(D->getCategoryNameLoc());
826 }
827 
829  VisitObjCImplDecl(D);
830  Record.AddDeclRef(D->getSuperClass());
831  Record.AddSourceLocation(D->getSuperClassLoc());
832  Record.AddSourceLocation(D->getIvarLBraceLoc());
833  Record.AddSourceLocation(D->getIvarRBraceLoc());
834  Record.push_back(D->hasNonZeroConstructors());
835  Record.push_back(D->hasDestructors());
836  Record.push_back(D->NumIvarInitializers);
837  if (D->NumIvarInitializers)
838  Record.AddCXXCtorInitializers(
839  llvm::makeArrayRef(D->init_begin(), D->init_end()));
841 }
842 
844  VisitDecl(D);
845  Record.AddSourceLocation(D->getLocStart());
846  Record.AddDeclRef(D->getPropertyDecl());
847  Record.AddDeclRef(D->getPropertyIvarDecl());
848  Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
849  Record.AddStmt(D->getGetterCXXConstructor());
850  Record.AddStmt(D->getSetterCXXAssignment());
852 }
853 
855  VisitDeclaratorDecl(D);
856  Record.push_back(D->isMutable());
857 
858  FieldDecl::InitStorageKind ISK = D->InitStorage.getInt();
859  Record.push_back(ISK);
860  if (ISK == FieldDecl::ISK_CapturedVLAType)
861  Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
862  else if (ISK)
863  Record.AddStmt(D->getInClassInitializer());
864 
865  Record.AddStmt(D->getBitWidth());
866 
867  if (!D->getDeclName())
868  Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D));
869 
870  if (D->getDeclContext() == D->getLexicalDeclContext() &&
871  !D->hasAttrs() &&
872  !D->isImplicit() &&
873  !D->isUsed(false) &&
874  !D->isInvalidDecl() &&
875  !D->isReferenced() &&
877  !D->isModulePrivate() &&
878  !D->getBitWidth() &&
879  !D->hasInClassInitializer() &&
880  !D->hasCapturedVLAType() &&
881  !D->hasExtInfo() &&
884  D->getDeclName())
885  AbbrevToUse = Writer.getDeclFieldAbbrev();
886 
888 }
889 
891  VisitDeclaratorDecl(D);
892  Record.AddIdentifierRef(D->getGetterId());
893  Record.AddIdentifierRef(D->getSetterId());
895 }
896 
898  VisitValueDecl(D);
899  Record.push_back(D->getChainingSize());
900 
901  for (const auto *P : D->chain())
902  Record.AddDeclRef(P);
904 }
905 
907  VisitRedeclarable(D);
908  VisitDeclaratorDecl(D);
909  Record.push_back(D->getStorageClass());
910  Record.push_back(D->getTSCSpec());
911  Record.push_back(D->getInitStyle());
912  if (!isa<ParmVarDecl>(D)) {
913  Record.push_back(D->isThisDeclarationADemotedDefinition());
914  Record.push_back(D->isExceptionVariable());
915  Record.push_back(D->isNRVOVariable());
916  Record.push_back(D->isCXXForRangeDecl());
917  Record.push_back(D->isARCPseudoStrong());
918  Record.push_back(D->isInline());
919  Record.push_back(D->isInlineSpecified());
920  Record.push_back(D->isConstexpr());
921  Record.push_back(D->isInitCapture());
922  Record.push_back(D->isPreviousDeclInSameBlockScope());
923  if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
924  Record.push_back(static_cast<unsigned>(IPD->getParameterKind()));
925  else
926  Record.push_back(0);
927  }
928  Record.push_back(D->getLinkageInternal());
929 
930  if (D->getInit()) {
931  Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2));
932  Record.AddStmt(D->getInit());
933  } else {
934  Record.push_back(0);
935  }
936 
937  if (D->getStorageDuration() == SD_Static) {
938  bool ModulesCodegen = false;
939  if (Writer.WritingModule &&
941  !isa<VarTemplateSpecializationDecl>(D)) {
942  // When building a C++ Modules TS module interface unit, a strong
943  // definition in the module interface is provided by the compilation of
944  // that module interface unit, not by its users. (Inline variables are
945  // still emitted in module users.)
946  ModulesCodegen =
947  (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit &&
948  Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal);
949  }
950  Record.push_back(ModulesCodegen);
951  if (ModulesCodegen)
952  Writer.ModularCodegenDecls.push_back(Writer.GetDeclRef(D));
953  }
954 
955  enum {
956  VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
957  };
958  if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
959  Record.push_back(VarTemplate);
960  Record.AddDeclRef(TemplD);
961  } else if (MemberSpecializationInfo *SpecInfo
963  Record.push_back(StaticDataMemberSpecialization);
964  Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
965  Record.push_back(SpecInfo->getTemplateSpecializationKind());
966  Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
967  } else {
968  Record.push_back(VarNotTemplate);
969  }
970 
971  if (D->getDeclContext() == D->getLexicalDeclContext() &&
972  !D->hasAttrs() &&
973  !D->isImplicit() &&
974  !D->isUsed(false) &&
975  !D->isInvalidDecl() &&
976  !D->isReferenced() &&
978  D->getAccess() == AS_none &&
979  !D->isModulePrivate() &&
982  !D->hasExtInfo() &&
983  D->getFirstDecl() == D->getMostRecentDecl() &&
984  D->getKind() == Decl::Var &&
985  !D->isInline() &&
986  !D->isConstexpr() &&
987  !D->isInitCapture() &&
989  D->getStorageDuration() != SD_Static &&
991  AbbrevToUse = Writer.getDeclVarAbbrev();
992 
994 }
995 
997  VisitVarDecl(D);
999 }
1000 
1002  VisitVarDecl(D);
1003  Record.push_back(D->isObjCMethodParameter());
1004  Record.push_back(D->getFunctionScopeDepth());
1005  Record.push_back(D->getFunctionScopeIndex());
1006  Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding
1007  Record.push_back(D->isKNRPromoted());
1008  Record.push_back(D->hasInheritedDefaultArg());
1009  Record.push_back(D->hasUninstantiatedDefaultArg());
1010  if (D->hasUninstantiatedDefaultArg())
1011  Record.AddStmt(D->getUninstantiatedDefaultArg());
1013 
1014  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
1015 
1016  // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1017  // we dynamically check for the properties that we optimize for, but don't
1018  // know are true of all PARM_VAR_DECLs.
1019  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1020  !D->hasAttrs() &&
1021  !D->hasExtInfo() &&
1022  !D->isImplicit() &&
1023  !D->isUsed(false) &&
1024  !D->isInvalidDecl() &&
1025  !D->isReferenced() &&
1026  D->getAccess() == AS_none &&
1027  !D->isModulePrivate() &&
1028  D->getStorageClass() == 0 &&
1029  D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1030  D->getFunctionScopeDepth() == 0 &&
1031  D->getObjCDeclQualifier() == 0 &&
1032  !D->isKNRPromoted() &&
1033  !D->hasInheritedDefaultArg() &&
1034  D->getInit() == nullptr &&
1035  !D->hasUninstantiatedDefaultArg()) // No default expr.
1036  AbbrevToUse = Writer.getDeclParmVarAbbrev();
1037 
1038  // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1039  // just us assuming it.
1040  assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1042  && "PARM_VAR_DECL can't be demoted definition.");
1043  assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1044  assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1045  assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1046  assert(!D->isStaticDataMember() &&
1047  "PARM_VAR_DECL can't be static data member");
1048 }
1049 
1051  // Record the number of bindings first to simplify deserialization.
1052  Record.push_back(D->bindings().size());
1053 
1054  VisitVarDecl(D);
1055  for (auto *B : D->bindings())
1056  Record.AddDeclRef(B);
1058 }
1059 
1061  VisitValueDecl(D);
1062  Record.AddStmt(D->getBinding());
1064 }
1065 
1067  VisitDecl(D);
1068  Record.AddStmt(D->getAsmString());
1069  Record.AddSourceLocation(D->getRParenLoc());
1071 }
1072 
1074  VisitDecl(D);
1076 }
1077 
1079  VisitDecl(D);
1080  Record.AddStmt(D->getBody());
1081  Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1082  Record.push_back(D->param_size());
1083  for (ParmVarDecl *P : D->parameters())
1084  Record.AddDeclRef(P);
1085  Record.push_back(D->isVariadic());
1086  Record.push_back(D->blockMissingReturnType());
1087  Record.push_back(D->isConversionFromLambda());
1088  Record.push_back(D->capturesCXXThis());
1089  Record.push_back(D->getNumCaptures());
1090  for (const auto &capture : D->captures()) {
1091  Record.AddDeclRef(capture.getVariable());
1092 
1093  unsigned flags = 0;
1094  if (capture.isByRef()) flags |= 1;
1095  if (capture.isNested()) flags |= 2;
1096  if (capture.hasCopyExpr()) flags |= 4;
1097  Record.push_back(flags);
1098 
1099  if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1100  }
1101 
1103 }
1104 
1106  Record.push_back(CD->getNumParams());
1107  VisitDecl(CD);
1108  Record.push_back(CD->getContextParamPosition());
1109  Record.push_back(CD->isNothrow() ? 1 : 0);
1110  // Body is stored by VisitCapturedStmt.
1111  for (unsigned I = 0; I < CD->getNumParams(); ++I)
1112  Record.AddDeclRef(CD->getParam(I));
1114 }
1115 
1117  VisitDecl(D);
1118  Record.push_back(D->getLanguage());
1119  Record.AddSourceLocation(D->getExternLoc());
1120  Record.AddSourceLocation(D->getRBraceLoc());
1122 }
1123 
1125  VisitDecl(D);
1126  Record.AddSourceLocation(D->getRBraceLoc());
1128 }
1129 
1131  VisitNamedDecl(D);
1132  Record.AddSourceLocation(D->getLocStart());
1134 }
1135 
1136 
1138  VisitRedeclarable(D);
1139  VisitNamedDecl(D);
1140  Record.push_back(D->isInline());
1141  Record.AddSourceLocation(D->getLocStart());
1142  Record.AddSourceLocation(D->getRBraceLoc());
1143 
1144  if (D->isOriginalNamespace())
1145  Record.AddDeclRef(D->getAnonymousNamespace());
1147 
1148  if (Writer.hasChain() && D->isAnonymousNamespace() &&
1149  D == D->getMostRecentDecl()) {
1150  // This is a most recent reopening of the anonymous namespace. If its parent
1151  // is in a previous PCH (or is the TU), mark that parent for update, because
1152  // the original namespace always points to the latest re-opening of its
1153  // anonymous namespace.
1154  Decl *Parent = cast<Decl>(
1156  if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1157  Writer.DeclUpdates[Parent].push_back(
1158  ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D));
1159  }
1160  }
1161 }
1162 
1164  VisitRedeclarable(D);
1165  VisitNamedDecl(D);
1166  Record.AddSourceLocation(D->getNamespaceLoc());
1167  Record.AddSourceLocation(D->getTargetNameLoc());
1168  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1169  Record.AddDeclRef(D->getNamespace());
1171 }
1172 
1174  VisitNamedDecl(D);
1175  Record.AddSourceLocation(D->getUsingLoc());
1176  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1177  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1178  Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1179  Record.push_back(D->hasTypename());
1180  Record.AddDeclRef(Context.getInstantiatedFromUsingDecl(D));
1182 }
1183 
1185  Record.push_back(D->NumExpansions);
1186  VisitNamedDecl(D);
1187  Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1188  for (auto *E : D->expansions())
1189  Record.AddDeclRef(E);
1191 }
1192 
1194  VisitRedeclarable(D);
1195  VisitNamedDecl(D);
1196  Record.AddDeclRef(D->getTargetDecl());
1197  Record.push_back(D->getIdentifierNamespace());
1198  Record.AddDeclRef(D->UsingOrNextShadow);
1199  Record.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D));
1201 }
1202 
1205  VisitUsingShadowDecl(D);
1206  Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1207  Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1208  Record.push_back(D->IsVirtual);
1210 }
1211 
1213  VisitNamedDecl(D);
1214  Record.AddSourceLocation(D->getUsingLoc());
1215  Record.AddSourceLocation(D->getNamespaceKeyLocation());
1216  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1217  Record.AddDeclRef(D->getNominatedNamespace());
1218  Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1220 }
1221 
1223  VisitValueDecl(D);
1224  Record.AddSourceLocation(D->getUsingLoc());
1225  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1226  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1227  Record.AddSourceLocation(D->getEllipsisLoc());
1229 }
1230 
1233  VisitTypeDecl(D);
1234  Record.AddSourceLocation(D->getTypenameLoc());
1235  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1236  Record.AddSourceLocation(D->getEllipsisLoc());
1238 }
1239 
1241  VisitRecordDecl(D);
1242 
1243  enum {
1244  CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1245  };
1246  if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1247  Record.push_back(CXXRecTemplate);
1248  Record.AddDeclRef(TemplD);
1249  } else if (MemberSpecializationInfo *MSInfo
1250  = D->getMemberSpecializationInfo()) {
1251  Record.push_back(CXXRecMemberSpecialization);
1252  Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1253  Record.push_back(MSInfo->getTemplateSpecializationKind());
1254  Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1255  } else {
1256  Record.push_back(CXXRecNotTemplate);
1257  }
1258 
1259  Record.push_back(D->isThisDeclarationADefinition());
1261  Record.AddCXXDefinitionData(D);
1262 
1263  // Store (what we currently believe to be) the key function to avoid
1264  // deserializing every method so we can compute it.
1265  if (D->IsCompleteDefinition)
1266  Record.AddDeclRef(Context.getCurrentKeyFunction(D));
1267 
1269 }
1270 
1272  VisitFunctionDecl(D);
1273  if (D->isCanonicalDecl()) {
1274  Record.push_back(D->size_overridden_methods());
1275  for (const CXXMethodDecl *MD : D->overridden_methods())
1276  Record.AddDeclRef(MD);
1277  } else {
1278  // We only need to record overridden methods once for the canonical decl.
1279  Record.push_back(0);
1280  }
1281 
1282  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1283  D->getFirstDecl() == D->getMostRecentDecl() &&
1284  !D->isInvalidDecl() &&
1285  !D->hasAttrs() &&
1288  !D->hasExtInfo() &&
1289  !D->hasInheritedPrototype() &&
1290  D->hasWrittenPrototype())
1291  AbbrevToUse = Writer.getDeclCXXMethodAbbrev();
1292 
1294 }
1295 
1297  if (auto Inherited = D->getInheritedConstructor()) {
1298  Record.AddDeclRef(Inherited.getShadowDecl());
1299  Record.AddDeclRef(Inherited.getConstructor());
1301  } else {
1303  }
1304 
1305  VisitCXXMethodDecl(D);
1306 
1307  Code = D->isInheritingConstructor()
1310 }
1311 
1313  VisitCXXMethodDecl(D);
1314 
1315  Record.AddDeclRef(D->getOperatorDelete());
1316  if (D->getOperatorDelete())
1317  Record.AddStmt(D->getOperatorDeleteThisArg());
1318 
1320 }
1321 
1323  VisitCXXMethodDecl(D);
1325 }
1326 
1328  VisitDecl(D);
1329  Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1330  ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1331  Record.push_back(!IdentifierLocs.empty());
1332  if (IdentifierLocs.empty()) {
1333  Record.AddSourceLocation(D->getLocEnd());
1334  Record.push_back(1);
1335  } else {
1336  for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1337  Record.AddSourceLocation(IdentifierLocs[I]);
1338  Record.push_back(IdentifierLocs.size());
1339  }
1340  // Note: the number of source locations must always be the last element in
1341  // the record.
1343 }
1344 
1346  VisitDecl(D);
1347  Record.AddSourceLocation(D->getColonLoc());
1349 }
1350 
1352  // Record the number of friend type template parameter lists here
1353  // so as to simplify memory allocation during deserialization.
1354  Record.push_back(D->NumTPLists);
1355  VisitDecl(D);
1356  bool hasFriendDecl = D->Friend.is<NamedDecl*>();
1357  Record.push_back(hasFriendDecl);
1358  if (hasFriendDecl)
1359  Record.AddDeclRef(D->getFriendDecl());
1360  else
1361  Record.AddTypeSourceInfo(D->getFriendType());
1362  for (unsigned i = 0; i < D->NumTPLists; ++i)
1363  Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1364  Record.AddDeclRef(D->getNextFriend());
1365  Record.push_back(D->UnsupportedFriend);
1366  Record.AddSourceLocation(D->FriendLoc);
1368 }
1369 
1371  VisitDecl(D);
1372  Record.push_back(D->getNumTemplateParameters());
1373  for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1374  Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1375  Record.push_back(D->getFriendDecl() != nullptr);
1376  if (D->getFriendDecl())
1377  Record.AddDeclRef(D->getFriendDecl());
1378  else
1379  Record.AddTypeSourceInfo(D->getFriendType());
1380  Record.AddSourceLocation(D->getFriendLoc());
1382 }
1383 
1385  VisitNamedDecl(D);
1386 
1387  Record.AddDeclRef(D->getTemplatedDecl());
1388  Record.AddTemplateParameterList(D->getTemplateParameters());
1389 }
1390 
1392  VisitRedeclarable(D);
1393 
1394  // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1395  // getCommonPtr() can be used while this is still initializing.
1396  if (D->isFirstDecl()) {
1397  // This declaration owns the 'common' pointer, so serialize that data now.
1398  Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1400  Record.push_back(D->isMemberSpecialization());
1401  }
1402 
1403  VisitTemplateDecl(D);
1404  Record.push_back(D->getIdentifierNamespace());
1405 }
1406 
1408  VisitRedeclarableTemplateDecl(D);
1409 
1410  if (D->isFirstDecl())
1411  AddTemplateSpecializations(D);
1413 }
1414 
1417  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1418 
1419  VisitCXXRecordDecl(D);
1420 
1421  llvm::PointerUnion<ClassTemplateDecl *,
1424  if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1425  Record.AddDeclRef(InstFromD);
1426  } else {
1427  Record.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>());
1428  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1429  }
1430 
1431  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1432  Record.AddSourceLocation(D->getPointOfInstantiation());
1433  Record.push_back(D->getSpecializationKind());
1434  Record.push_back(D->isCanonicalDecl());
1435 
1436  if (D->isCanonicalDecl()) {
1437  // When reading, we'll add it to the folding set of the following template.
1438  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1439  }
1440 
1441  // Explicit info.
1442  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1443  if (D->getTypeAsWritten()) {
1444  Record.AddSourceLocation(D->getExternLoc());
1445  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1446  }
1447 
1449 }
1450 
1453  VisitClassTemplateSpecializationDecl(D);
1454 
1455  Record.AddTemplateParameterList(D->getTemplateParameters());
1456  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1457 
1458  // These are read/set from/to the first declaration.
1459  if (D->getPreviousDecl() == nullptr) {
1460  Record.AddDeclRef(D->getInstantiatedFromMember());
1461  Record.push_back(D->isMemberSpecialization());
1462  }
1463 
1465 }
1466 
1468  VisitRedeclarableTemplateDecl(D);
1469 
1470  if (D->isFirstDecl())
1471  AddTemplateSpecializations(D);
1473 }
1474 
1477  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1478 
1479  VisitVarDecl(D);
1480 
1481  llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
1482  InstFrom = D->getSpecializedTemplateOrPartial();
1483  if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
1484  Record.AddDeclRef(InstFromD);
1485  } else {
1486  Record.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>());
1487  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1488  }
1489 
1490  // Explicit info.
1491  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1492  if (D->getTypeAsWritten()) {
1493  Record.AddSourceLocation(D->getExternLoc());
1494  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1495  }
1496 
1497  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1498  Record.AddSourceLocation(D->getPointOfInstantiation());
1499  Record.push_back(D->getSpecializationKind());
1500  Record.push_back(D->IsCompleteDefinition);
1501  Record.push_back(D->isCanonicalDecl());
1502 
1503  if (D->isCanonicalDecl()) {
1504  // When reading, we'll add it to the folding set of the following template.
1505  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1506  }
1507 
1509 }
1510 
1513  VisitVarTemplateSpecializationDecl(D);
1514 
1515  Record.AddTemplateParameterList(D->getTemplateParameters());
1516  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1517 
1518  // These are read/set from/to the first declaration.
1519  if (D->getPreviousDecl() == nullptr) {
1520  Record.AddDeclRef(D->getInstantiatedFromMember());
1521  Record.push_back(D->isMemberSpecialization());
1522  }
1523 
1525 }
1526 
1529  VisitDecl(D);
1530  Record.AddDeclRef(D->getSpecialization());
1532 }
1533 
1534 
1536  VisitRedeclarableTemplateDecl(D);
1537 
1538  if (D->isFirstDecl())
1539  AddTemplateSpecializations(D);
1541 }
1542 
1544  VisitTypeDecl(D);
1545 
1546  Record.push_back(D->wasDeclaredWithTypename());
1547 
1548  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1550  Record.push_back(OwnsDefaultArg);
1551  if (OwnsDefaultArg)
1552  Record.AddTypeSourceInfo(D->getDefaultArgumentInfo());
1553 
1555 }
1556 
1558  // For an expanded parameter pack, record the number of expansion types here
1559  // so that it's easier for deserialization to allocate the right amount of
1560  // memory.
1561  if (D->isExpandedParameterPack())
1562  Record.push_back(D->getNumExpansionTypes());
1563 
1564  VisitDeclaratorDecl(D);
1565  // TemplateParmPosition.
1566  Record.push_back(D->getDepth());
1567  Record.push_back(D->getPosition());
1568 
1569  if (D->isExpandedParameterPack()) {
1570  for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
1571  Record.AddTypeRef(D->getExpansionType(I));
1572  Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
1573  }
1574 
1576  } else {
1577  // Rest of NonTypeTemplateParmDecl.
1578  Record.push_back(D->isParameterPack());
1579  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1581  Record.push_back(OwnsDefaultArg);
1582  if (OwnsDefaultArg)
1583  Record.AddStmt(D->getDefaultArgument());
1585  }
1586 }
1587 
1589  // For an expanded parameter pack, record the number of expansion types here
1590  // so that it's easier for deserialization to allocate the right amount of
1591  // memory.
1592  if (D->isExpandedParameterPack())
1593  Record.push_back(D->getNumExpansionTemplateParameters());
1594 
1595  VisitTemplateDecl(D);
1596  // TemplateParmPosition.
1597  Record.push_back(D->getDepth());
1598  Record.push_back(D->getPosition());
1599 
1600  if (D->isExpandedParameterPack()) {
1601  for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
1602  I != N; ++I)
1603  Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
1605  } else {
1606  // Rest of TemplateTemplateParmDecl.
1607  Record.push_back(D->isParameterPack());
1608  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1610  Record.push_back(OwnsDefaultArg);
1611  if (OwnsDefaultArg)
1612  Record.AddTemplateArgumentLoc(D->getDefaultArgument());
1614  }
1615 }
1616 
1618  VisitRedeclarableTemplateDecl(D);
1620 }
1621 
1623  VisitDecl(D);
1624  Record.AddStmt(D->getAssertExpr());
1625  Record.push_back(D->isFailed());
1626  Record.AddStmt(D->getMessage());
1627  Record.AddSourceLocation(D->getRParenLoc());
1629 }
1630 
1631 /// \brief Emit the DeclContext part of a declaration context decl.
1633  Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC));
1634  Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC));
1635 }
1636 
1638  assert(IsLocalDecl(D) && "expected a local declaration");
1639 
1640  const Decl *Canon = D->getCanonicalDecl();
1641  if (IsLocalDecl(Canon))
1642  return Canon;
1643 
1644  const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
1645  if (CacheEntry)
1646  return CacheEntry;
1647 
1648  for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
1649  if (IsLocalDecl(Redecl))
1650  D = Redecl;
1651  return CacheEntry = D;
1652 }
1653 
1654 template <typename T>
1656  T *First = D->getFirstDecl();
1657  T *MostRecent = First->getMostRecentDecl();
1658  T *DAsT = static_cast<T *>(D);
1659  if (MostRecent != First) {
1660  assert(isRedeclarableDeclKind(DAsT->getKind()) &&
1661  "Not considered redeclarable?");
1662 
1663  Record.AddDeclRef(First);
1664 
1665  // Write out a list of local redeclarations of this declaration if it's the
1666  // first local declaration in the chain.
1667  const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
1668  if (DAsT == FirstLocal) {
1669  // Emit a list of all imported first declarations so that we can be sure
1670  // that all redeclarations visible to this module are before D in the
1671  // redecl chain.
1672  unsigned I = Record.size();
1673  Record.push_back(0);
1674  if (Writer.Chain)
1675  AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
1676  // This is the number of imported first declarations + 1.
1677  Record[I] = Record.size() - I;
1678 
1679  // Collect the set of local redeclarations of this declaration, from
1680  // newest to oldest.
1681  ASTWriter::RecordData LocalRedecls;
1682  ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
1683  for (const Decl *Prev = FirstLocal->getMostRecentDecl();
1684  Prev != FirstLocal; Prev = Prev->getPreviousDecl())
1685  if (!Prev->isFromASTFile())
1686  LocalRedeclWriter.AddDeclRef(Prev);
1687 
1688  // If we have any redecls, write them now as a separate record preceding
1689  // the declaration itself.
1690  if (LocalRedecls.empty())
1691  Record.push_back(0);
1692  else
1693  Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
1694  } else {
1695  Record.push_back(0);
1696  Record.AddDeclRef(FirstLocal);
1697  }
1698 
1699  // Make sure that we serialize both the previous and the most-recent
1700  // declarations, which (transitively) ensures that all declarations in the
1701  // chain get serialized.
1702  //
1703  // FIXME: This is not correct; when we reach an imported declaration we
1704  // won't emit its previous declaration.
1705  (void)Writer.GetDeclRef(D->getPreviousDecl());
1706  (void)Writer.GetDeclRef(MostRecent);
1707  } else {
1708  // We use the sentinel value 0 to indicate an only declaration.
1709  Record.push_back(0);
1710  }
1711 }
1712 
1714  Record.push_back(D->varlist_size());
1715  VisitDecl(D);
1716  for (auto *I : D->varlists())
1717  Record.AddStmt(I);
1719 }
1720 
1722  VisitValueDecl(D);
1723  Record.AddSourceLocation(D->getLocStart());
1724  Record.AddStmt(D->getCombiner());
1725  Record.AddStmt(D->getInitializer());
1726  Record.push_back(D->getInitializerKind());
1727  Record.AddDeclRef(D->getPrevDeclInScope());
1729 }
1730 
1732  VisitVarDecl(D);
1734 }
1735 
1736 //===----------------------------------------------------------------------===//
1737 // ASTWriter Implementation
1738 //===----------------------------------------------------------------------===//
1739 
1740 void ASTWriter::WriteDeclAbbrevs() {
1741  using namespace llvm;
1742 
1743  std::shared_ptr<BitCodeAbbrev> Abv;
1744 
1745  // Abbreviation for DECL_FIELD
1746  Abv = std::make_shared<BitCodeAbbrev>();
1747  Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
1748  // Decl
1749  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1750  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1751  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1752  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1753  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1754  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1755  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1756  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1757  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1758  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1759  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1760  // NamedDecl
1761  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1762  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1763  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1764  // ValueDecl
1765  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1766  // DeclaratorDecl
1767  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1768  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1769  // FieldDecl
1770  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1771  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1772  // Type Source Info
1773  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1774  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1775  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1776  DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
1777 
1778  // Abbreviation for DECL_OBJC_IVAR
1779  Abv = std::make_shared<BitCodeAbbrev>();
1780  Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
1781  // Decl
1782  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1783  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1784  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1785  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1786  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1787  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1788  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1789  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1790  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1791  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1792  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1793  // NamedDecl
1794  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1795  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1796  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1797  // ValueDecl
1798  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1799  // DeclaratorDecl
1800  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1801  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1802  // FieldDecl
1803  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1804  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1805  // ObjC Ivar
1806  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
1807  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
1808  // Type Source Info
1809  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1810  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1811  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1812  DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1813 
1814  // Abbreviation for DECL_ENUM
1815  Abv = std::make_shared<BitCodeAbbrev>();
1816  Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
1817  // Redeclarable
1818  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1819  // Decl
1820  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1821  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1822  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1823  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1824  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1825  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1826  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1827  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1828  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1829  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1830  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1831  // NamedDecl
1832  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1833  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1834  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1835  // TypeDecl
1836  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1837  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1838  // TagDecl
1839  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1840  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1841  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1842  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1843  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1844  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1845  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1846  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1847  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1848  // EnumDecl
1849  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
1850  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
1851  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
1852  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumPositiveBits
1853  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumNegativeBits
1854  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScoped
1855  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScopedUsingClassTag
1856  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isFixed
1857  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
1858  // DC
1859  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1860  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1861  DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
1862 
1863  // Abbreviation for DECL_RECORD
1864  Abv = std::make_shared<BitCodeAbbrev>();
1865  Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
1866  // Redeclarable
1867  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1868  // Decl
1869  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1870  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1871  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1872  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1873  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1874  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1875  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1876  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1877  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1878  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1879  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1880  // NamedDecl
1881  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1882  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1883  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1884  // TypeDecl
1885  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1886  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1887  // TagDecl
1888  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1889  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1890  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1891  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1892  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1893  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1894  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1895  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1896  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1897  // RecordDecl
1898  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember
1899  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
1900  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
1901  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
1902  // DC
1903  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1904  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1905  DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
1906 
1907  // Abbreviation for DECL_PARM_VAR
1908  Abv = std::make_shared<BitCodeAbbrev>();
1909  Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
1910  // Redeclarable
1911  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1912  // Decl
1913  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1914  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1915  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1916  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1917  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1918  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1919  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1920  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1921  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1922  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1923  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1924  // NamedDecl
1925  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1926  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1927  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1928  // ValueDecl
1929  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1930  // DeclaratorDecl
1931  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1932  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1933  // VarDecl
1934  Abv->Add(BitCodeAbbrevOp(0)); // SClass
1935  Abv->Add(BitCodeAbbrevOp(0)); // TSCSpec
1936  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1937  Abv->Add(BitCodeAbbrevOp(0)); // Linkage
1938  Abv->Add(BitCodeAbbrevOp(0)); // HasInit
1939  Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo
1940  // ParmVarDecl
1941  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsObjCMethodParameter
1942  Abv->Add(BitCodeAbbrevOp(0)); // ScopeDepth
1943  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
1944  Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier
1945  Abv->Add(BitCodeAbbrevOp(0)); // KNRPromoted
1946  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg
1947  Abv->Add(BitCodeAbbrevOp(0)); // HasUninstantiatedDefaultArg
1948  // Type Source Info
1949  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1950  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1951  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1952  DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1953 
1954  // Abbreviation for DECL_TYPEDEF
1955  Abv = std::make_shared<BitCodeAbbrev>();
1956  Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
1957  // Redeclarable
1958  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1959  // Decl
1960  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1961  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1962  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1963  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1964  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1965  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isUsed
1966  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isReferenced
1967  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1968  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // C++ AccessSpecifier
1969  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1970  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1971  // NamedDecl
1972  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1973  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1974  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1975  // TypeDecl
1976  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1977  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1978  // TypedefDecl
1979  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1980  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1981  DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
1982 
1983  // Abbreviation for DECL_VAR
1984  Abv = std::make_shared<BitCodeAbbrev>();
1985  Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
1986  // Redeclarable
1987  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1988  // Decl
1989  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1990  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1991  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1992  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1993  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1994  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1995  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1996  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1997  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1998  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1999  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2000  // NamedDecl
2001  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2002  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2003  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2004  // ValueDecl
2005  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2006  // DeclaratorDecl
2007  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2008  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2009  // VarDecl
2010  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
2011  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
2012  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
2013  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
2014  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
2015  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
2016  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
2017  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
2018  Abv->Add(BitCodeAbbrevOp(0)); // isInline
2019  Abv->Add(BitCodeAbbrevOp(0)); // isInlineSpecified
2020  Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
2021  Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
2022  Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
2023  Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind
2024  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
2025  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
2026  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
2027  // Type Source Info
2028  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2029  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2030  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2031  DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2032 
2033  // Abbreviation for DECL_CXX_METHOD
2034  Abv = std::make_shared<BitCodeAbbrev>();
2035  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD));
2036  // RedeclarableDecl
2037  Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2038  // Decl
2039  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2040  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
2041  Abv->Add(BitCodeAbbrevOp(0)); // Invalid
2042  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
2043  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Implicit
2044  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Used
2045  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Referenced
2046  Abv->Add(BitCodeAbbrevOp(0)); // InObjCContainer
2047  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Access
2048  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModulePrivate
2049  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2050  // NamedDecl
2051  Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2052  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2053  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2054  // ValueDecl
2055  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2056  // DeclaratorDecl
2057  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2058  Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2059  // FunctionDecl
2060  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2061  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass
2062  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline
2063  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified
2064  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitSpecified
2065  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten
2066  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure
2067  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto
2068  Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto
2069  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted
2070  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial
2071  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // TrivialForCall
2072  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
2073  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
2074  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
2075  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
2076  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry
2077  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
2078  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // MultiVersion
2079  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed
2080  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
2081  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2082  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2083  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind
2084  // This Array slurps the rest of the record. Fortunately we want to encode
2085  // (nearly) all the remaining (variable number of) fields in the same way.
2086  //
2087  // This is the function template information if any, then
2088  // NumParams and Params[] from FunctionDecl, and
2089  // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2090  //
2091  // Add an AbbrevOp for 'size then elements' and use it here.
2092  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2093  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2094  DeclCXXMethodAbbrev = Stream.EmitAbbrev(std::move(Abv));
2095 
2096  // Abbreviation for EXPR_DECL_REF
2097  Abv = std::make_shared<BitCodeAbbrev>();
2098  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2099  //Stmt
2100  //Expr
2101  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2102  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2103  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2104  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2105  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2106  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2107  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2108  //DeclRefExpr
2109  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HasQualifier
2110  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //GetDeclFound
2111  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ExplicitTemplateArgs
2112  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HadMultipleCandidates
2113  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2114  1)); // RefersToEnclosingVariableOrCapture
2115  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2116  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2117  DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2118 
2119  // Abbreviation for EXPR_INTEGER_LITERAL
2120  Abv = std::make_shared<BitCodeAbbrev>();
2121  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2122  //Stmt
2123  //Expr
2124  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2125  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2126  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2127  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2128  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2129  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2130  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2131  //Integer Literal
2132  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2133  Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2134  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2135  IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2136 
2137  // Abbreviation for EXPR_CHARACTER_LITERAL
2138  Abv = std::make_shared<BitCodeAbbrev>();
2139  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2140  //Stmt
2141  //Expr
2142  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2143  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2144  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2145  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2146  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2147  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2148  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2149  //Character Literal
2150  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2151  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2152  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2153  CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2154 
2155  // Abbreviation for EXPR_IMPLICIT_CAST
2156  Abv = std::make_shared<BitCodeAbbrev>();
2157  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2158  // Stmt
2159  // Expr
2160  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2161  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2162  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2163  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2164  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2165  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2166  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2167  // CastExpr
2168  Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2169  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind
2170  // ImplicitCastExpr
2171  ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2172 
2173  Abv = std::make_shared<BitCodeAbbrev>();
2174  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2175  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2176  DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2177 
2178  Abv = std::make_shared<BitCodeAbbrev>();
2179  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2180  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2181  DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2182 }
2183 
2184 /// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2185 /// consumers of the AST.
2186 ///
2187 /// Such decls will always be deserialized from the AST file, so we would like
2188 /// this to be as restrictive as possible. Currently the predicate is driven by
2189 /// code generation requirements, if other clients have a different notion of
2190 /// what is "required" then we may have to consider an alternate scheme where
2191 /// clients can iterate over the top-level decls and get information on them,
2192 /// without necessary deserializing them. We could explicitly require such
2193 /// clients to use a separate API call to "realize" the decl. This should be
2194 /// relatively painless since they would presumably only do it for top-level
2195 /// decls.
2196 static bool isRequiredDecl(const Decl *D, ASTContext &Context,
2197  bool WritingModule) {
2198  // An ObjCMethodDecl is never considered as "required" because its
2199  // implementation container always is.
2200 
2201  // File scoped assembly or obj-c or OMP declare target implementation must be
2202  // seen.
2203  if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D) ||
2204  D->hasAttr<OMPDeclareTargetDeclAttr>())
2205  return true;
2206 
2207  if (WritingModule && (isa<VarDecl>(D) || isa<ImportDecl>(D))) {
2208  // These declarations are part of the module initializer, and are emitted
2209  // if and when the module is imported, rather than being emitted eagerly.
2210  return false;
2211  }
2212 
2213  return Context.DeclMustBeEmitted(D);
2214 }
2215 
2216 void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
2217  // Determine the ID for this declaration.
2219  assert(!D->isFromASTFile() && "should not be emitting imported decl");
2220  serialization::DeclID &IDR = DeclIDs[D];
2221  if (IDR == 0)
2222  IDR = NextDeclID++;
2223 
2224  ID = IDR;
2225 
2226  assert(ID >= FirstDeclID && "invalid decl ID");
2227 
2228  RecordData Record;
2229  ASTDeclWriter W(*this, Context, Record);
2230 
2231  // Build a record for this declaration
2232  W.Visit(D);
2233 
2234  // Emit this declaration to the bitstream.
2235  uint64_t Offset = W.Emit(D);
2236 
2237  // Record the offset for this declaration
2238  SourceLocation Loc = D->getLocation();
2239  unsigned Index = ID - FirstDeclID;
2240  if (DeclOffsets.size() == Index)
2241  DeclOffsets.push_back(DeclOffset(Loc, Offset));
2242  else if (DeclOffsets.size() < Index) {
2243  // FIXME: Can/should this happen?
2244  DeclOffsets.resize(Index+1);
2245  DeclOffsets[Index].setLocation(Loc);
2246  DeclOffsets[Index].BitOffset = Offset;
2247  } else {
2248  llvm_unreachable("declarations should be emitted in ID order");
2249  }
2250 
2251  SourceManager &SM = Context.getSourceManager();
2252  if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
2253  associateDeclWithFile(D, ID);
2254 
2255  // Note declarations that should be deserialized eagerly so that we can add
2256  // them to a record in the AST file later.
2257  if (isRequiredDecl(D, Context, WritingModule))
2258  EagerlyDeserializedDecls.push_back(ID);
2259 }
2260 
2262  // Switch case IDs are per function body.
2263  Writer->ClearSwitchCaseIDs();
2264 
2265  assert(FD->doesThisDeclarationHaveABody());
2266  bool ModulesCodegen = false;
2267  if (Writer->WritingModule && !FD->isDependentContext()) {
2269  if (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
2270  // When building a C++ Modules TS module interface unit, a strong
2271  // definition in the module interface is provided by the compilation of
2272  // that module interface unit, not by its users. (Inline functions are
2273  // still emitted in module users.)
2274  Linkage = Writer->Context->GetGVALinkageForFunction(FD);
2275  ModulesCodegen = *Linkage == GVA_StrongExternal;
2276  }
2277  if (Writer->Context->getLangOpts().ModulesCodegen) {
2278  // Under -fmodules-codegen, codegen is performed for all non-internal,
2279  // non-always_inline functions.
2280  if (!FD->hasAttr<AlwaysInlineAttr>()) {
2281  if (!Linkage)
2282  Linkage = Writer->Context->GetGVALinkageForFunction(FD);
2283  ModulesCodegen = *Linkage != GVA_Internal;
2284  }
2285  }
2286  }
2287  Record->push_back(ModulesCodegen);
2288  if (ModulesCodegen)
2289  Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));
2290  if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
2291  Record->push_back(CD->getNumCtorInitializers());
2292  if (CD->getNumCtorInitializers())
2293  AddCXXCtorInitializers(
2294  llvm::makeArrayRef(CD->init_begin(), CD->init_end()));
2295  }
2296  AddStmt(FD->getBody());
2297 }
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition: Decl.cpp:2398
SourceLocation getGetterNameLoc() const
Definition: DeclObjC.h:924
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1376
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1403
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition: Decl.h:2651
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
Definition: DeclTemplate.h:721
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:3183
Represents a function declaration or definition.
Definition: Decl.h:1696
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Definition: DeclTemplate.h:549
void VisitAccessSpecDecl(AccessSpecDecl *D)
unsigned getNumTemplateArgs() const
Returns the number of explicit template arguments that were given.
Definition: DeclTemplate.h:718
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
Definition: Decl.h:1283
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
Definition: DeclTemplate.h:580
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:751
void VisitCXXMethodDecl(CXXMethodDecl *D)
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
Definition: ASTCommon.cpp:238
A (possibly-)qualified type.
Definition: Type.h:653
Static storage duration.
Definition: Specifiers.h:277
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:3612
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:1558
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:3095
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1439
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:26
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:2577
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2690
void VisitCXXRecordDecl(CXXRecordDecl *D)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1014
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:2922
Defines the SourceManager interface.
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1457
bool hasVolatileMember() const
Definition: Decl.h:3584
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:2276
const Type * getTypeForDecl() const
Definition: Decl.h:2802
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:3835
An ImplicitCastExpr record.
Definition: ASTBitCodes.h:1593
bool isNothrow() const
Definition: Decl.cpp:4289
IdentifierInfo * getGetterId() const
Definition: DeclCXX.h:3915
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1394
ThreadStorageClassSpecifier getTSCSpec() const
Definition: Decl.h:1023
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:2047
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:952
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:1301
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
Definition: DeclCXX.h:153
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement...
Definition: Decl.h:1329
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:4098
ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, ASTWriter::RecordDataImpl &Record)
Expr * getOperatorDeleteThisArg() const
Definition: DeclCXX.h:2711
Declaration of a variable template.
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
Represent a C++ namespace.
Definition: Decl.h:514
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1258
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:412
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:791
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2452
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition: Decl.h:2618
size_t param_size() const
Definition: Decl.h:2205
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:3094
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3119
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:1379
A PragmaDetectMismatchDecl record.
Definition: ASTBitCodes.h:1454
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1340
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:736
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
An OMPCapturedExprDecl record.
Definition: ASTBitCodes.h:1448
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:3446
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1328
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:552
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
bool hasInheritedDefaultArg() const
Definition: Decl.h:1641
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:1429
void VisitIndirectFieldDecl(IndirectFieldDecl *D)
bool isInvalidDecl() const
Definition: DeclBase.h:546
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
unsigned getContextParamPosition() const
Definition: Decl.h:3957
protocol_range protocols() const
Definition: DeclObjC.h:2148
unsigned IsExplicitSpecified
Definition: Decl.h:1725
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1406
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:629
Represents a parameter to a function.
Definition: Decl.h:1515
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Definition: Linkage.h:25
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:1234
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:671
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2708
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition: Decl.h:1341
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
A CXXConstructorDecl record for an inherited constructor.
Definition: ASTBitCodes.h:1361
Represents a struct/union/class.
Definition: Decl.h:3510
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2844
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:3400
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:3754
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2715
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2868
CXXRecordDecl * getPreviousDecl()
Definition: DeclCXX.h:724
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:149
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:3075
Represents a member of a struct/union/class.
Definition: Decl.h:2488
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
const llvm::APSInt & getInitVal() const
Definition: Decl.h:2711
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1568
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:2648
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:3791
void VisitParmVarDecl(ParmVarDecl *D)
Represents an access specifier followed by colon &#39;:&#39;.
Definition: DeclCXX.h:131
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:1387
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:3795
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1421
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2189
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:507
Represents a C++ using-declaration.
Definition: DeclCXX.h:3334
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Definition: DeclTemplate.h:539
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2717
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:3857
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:2617
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:986
TagKind getTagKind() const
Definition: Decl.h:3178
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:424
void VisitTypedefDecl(TypedefDecl *D)
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1370
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:1589
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:4349
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void VisitUsingShadowDecl(UsingShadowDecl *D)
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1331
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.cpp:3234
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:878
ArrayRef< NamedDecl * > chain() const
Definition: Decl.h:2751
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1334
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:857
A DecompositionDecl record.
Definition: ASTBitCodes.h:1279
Represents a declaration of a type.
Definition: Decl.h:2778
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:3410
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
Definition: Decl.h:3491
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or nullptr if this template w...
Definition: DeclTemplate.h:925
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1368
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3349
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:2709
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2849
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition: DeclFriend.h:132
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1382
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition: Decl.h:3125
SourceLocation getExternLoc() const
Definition: DeclCXX.h:2856
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:820
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:4499
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:950
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3883
Represents an ObjC class declaration.
Definition: DeclObjC.h:1191
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclObjC.cpp:937
Represents a linkage specification.
Definition: DeclCXX.h:2798
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:3777
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:3219
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:869
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:1133
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Definition: Decl.h:3576
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:4032
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:3759
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition: Decl.h:1075
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:535
void VisitObjCContainerDecl(ObjCContainerDecl *D)
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclObjC.h:2834
RecordDecl * getMostRecentDecl()
Definition: Decl.h:3555
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:2942
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1414
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:2805
SourceLocation getTypenameLoc() const
Returns the source location of the &#39;typename&#39; keyword.
Definition: DeclCXX.h:3681
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:3376
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1352
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:1353
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition: DeclOpenMP.h:147
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1412
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:2870
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1391
static bool classofKind(Kind K)
Definition: DeclObjC.h:2018
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1445
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:875
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3222
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1562
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3713
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:3374
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1249
unsigned getChainingSize() const
Definition: Decl.h:2757
Selector getSetterName() const
Definition: DeclObjC.h:931
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3440
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1261
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:3928
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2675
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:1358
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:1301
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:551
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:967
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:1983
DeclContext * getDeclContext()
Definition: DeclBase.h:425
void VisitUsingDecl(UsingDecl *D)
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1388
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
EnumDecl * getMostRecentDecl()
Definition: Decl.h:3324
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:3407
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1364
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
unsigned IsCopyDeductionCandidate
[C++17] Only used by CXXDeductionGuideDecl.
Definition: Decl.h:1768
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Definition: ASTBitCodes.h:1425
IdentifierInfo * getSetterId() const
Definition: DeclCXX.h:3917
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:1319
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1335
FunctionTemplateDecl * getTemplate(unsigned I) const
Returns the i&#39;th template candidate.
Definition: DeclTemplate.h:707
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:1421
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:1041
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1273
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:1966
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2737
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1225
ImplicitParamDecl * getSelfDecl() const
Definition: DeclObjC.h:444
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1273
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
QualType getType() const
Definition: DeclObjC.h:846
const SourceManager & SM
Definition: Format.cpp:1412
void VisitTagDecl(TagDecl *D)
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1436
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1246
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
CXXMethodDecl * getMostRecentDecl()
Definition: DeclCXX.h:2108
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:757
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:1255
void VisitVarTemplateDecl(VarTemplateDecl *D)
AttrVec & getAttrs()
Definition: DeclBase.h:477
bool hasAttrs() const
Definition: DeclBase.h:471
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:2051
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclBase.h:408
unsigned protocol_size() const
Definition: DeclObjC.h:2187
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition: DeclCXX.h:2969
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:1977
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:4053
SourceLocation getUsingLoc() const
Returns the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3585
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Definition: DeclTemplate.h:626
const Decl * getFirstLocalDecl(const Decl *D)
Find the first local declaration of a given local redeclarable decl.
An UnresolvedUsingValueDecl record.
Definition: ASTBitCodes.h:1337
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:3516
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Definition: DeclTemplate.h:542
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:1310
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:2973
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:617
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition: Decl.h:2656
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:2968
SourceLocation getUsingLoc() const
Return the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3367
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2546
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition: Decl.h:2959
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:3553
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3595
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2625
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:3696
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2019
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
void VisitUsingPackDecl(UsingPackDecl *D)
C-style initialization with assignment.
Definition: Decl.h:817
bool isConversionFromLambda() const
Definition: Decl.h:3848
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
A TemplateTypeParmDecl record.
Definition: ASTBitCodes.h:1400
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:973
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:2943
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:3435
unsigned getNumTemplates() const
Returns the number of function templates that this might be a specialization of.
Definition: DeclTemplate.h:704
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:694
bool isModed() const
Definition: Decl.h:2866
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:70
unsigned getODRHash()
Returns ODRHash of the function.
Definition: Decl.cpp:3616
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1629
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:399
void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D)
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2391
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:1316
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3728
void VisitPragmaCommentDecl(PragmaCommentDecl *D)
SourceLocation getRBraceLoc() const
Definition: DeclCXX.h:2857
bool hasFlexibleArrayMember() const
Definition: Decl.h:3562
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:80
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2436
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition: Decl.cpp:1043
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:3988
protocol_range protocols() const
Definition: DeclObjC.h:2375
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1237
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: Decl.h:1572
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2820
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1367
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:2345
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:2407
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1256
ArrayRef< Capture > captures() const
Definition: Decl.h:3839
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:3787
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:586
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
Definition: Decl.cpp:2269
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:2729
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1385
QualType getUnderlyingType() const
Definition: Decl.h:2875
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:3066
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition: DeclCXX.h:2965
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1211
const Expr * getInit() const
Definition: Decl.h:1214
AccessSpecifier getAccess() const
Definition: DeclBase.h:460
A decomposition declaration.
Definition: DeclCXX.h:3825
bool isEmbeddedInDeclarator() const
Definition: Decl.h:3134
void VisitTypeDecl(TypeDecl *D)
unsigned getNumTemplateParameters() const
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3649
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
Definition: ASTBitCodes.h:1433
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:576
Kind getKind() const
Definition: DeclBase.h:419
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3685
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1343
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:3261
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:1377
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:1048
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:2707
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1451
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:2536
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2169
size_t param_size() const
Definition: Decl.h:3814
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:1666
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:3930
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:3389
SourceManager & getSourceManager()
Definition: ASTContext.h:643
bool capturesCXXThis() const
Definition: Decl.h:3844
ImplementationControl getImplementationControl() const
Definition: DeclObjC.h:502
static bool classofKind(Kind K)
Definition: DeclCXX.h:1951
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:1435
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:3209
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition: Decl.h:2563
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition: Decl.h:3114
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:4072
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
Definition: Decl.h:1319
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:3427
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:329
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:607
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:1252
void VisitEnumConstantDecl(EnumConstantDecl *D)
SourceLocation getFriendLoc() const
Retrieves the location of the &#39;friend&#39; keyword.
bool isFailed() const
Definition: DeclCXX.h:3757
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1243
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:1203
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1216
unsigned protocol_size() const
Definition: DeclObjC.h:2384
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3384
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body - that is, if it is a non-delete...
Definition: Decl.h:1990
An ExportDecl record.
Definition: ASTBitCodes.h:1346
bool blockMissingReturnType() const
Definition: Decl.h:3845
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3702
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:3798
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:3581
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D)
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:3799
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1121
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition: Decl.cpp:3196
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1397
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:7120
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1409
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:1129
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:3894
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:3091
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:600
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:3002
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:1350
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:3520
Selector getGetterName() const
Definition: DeclObjC.h:923
Represents C++ using-directive.
Definition: DeclCXX.h:2898
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:647
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:3141
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:967
Source range/offset of a preprocessed entity.
Definition: ASTBitCodes.h:221
SourceLocation getLocation() const
Definition: DeclBase.h:416
const StringLiteral * getAsmString() const
Definition: Decl.h:3702
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3121
Represents a pack of using declarations that a single using-declarator pack-expanded into...
Definition: DeclCXX.h:3484
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:2645