clang  6.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->IsDefaulted);
532  Record.push_back(D->IsExplicitlyDefaulted);
533  Record.push_back(D->HasImplicitReturnZero);
534  Record.push_back(D->IsConstexpr);
535  Record.push_back(D->UsesSEHTry);
536  Record.push_back(D->HasSkippedBody);
537  Record.push_back(D->IsLateTemplateParsed);
538  Record.push_back(D->getLinkageInternal());
539  Record.AddSourceLocation(D->getLocEnd());
540 
541  Record.push_back(D->getTemplatedKind());
542  switch (D->getTemplatedKind()) {
544  break;
546  Record.AddDeclRef(D->getDescribedFunctionTemplate());
547  break;
550  Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
551  Record.push_back(MemberInfo->getTemplateSpecializationKind());
552  Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
553  break;
554  }
557  FTSInfo = D->getTemplateSpecializationInfo();
558 
559  RegisterTemplateSpecialization(FTSInfo->getTemplate(), D);
560 
561  Record.AddDeclRef(FTSInfo->getTemplate());
562  Record.push_back(FTSInfo->getTemplateSpecializationKind());
563 
564  // Template arguments.
565  Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
566 
567  // Template args as written.
568  Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
569  if (FTSInfo->TemplateArgumentsAsWritten) {
570  Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs);
571  for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs;
572  i!=e; ++i)
573  Record.AddTemplateArgumentLoc(
574  (*FTSInfo->TemplateArgumentsAsWritten)[i]);
575  Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc);
576  Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc);
577  }
578 
579  Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
580 
581  if (D->isCanonicalDecl()) {
582  // Write the template that contains the specializations set. We will
583  // add a FunctionTemplateSpecializationInfo to it when reading.
584  Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
585  }
586  break;
587  }
590  DFTSInfo = D->getDependentSpecializationInfo();
591 
592  // Templates.
593  Record.push_back(DFTSInfo->getNumTemplates());
594  for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i)
595  Record.AddDeclRef(DFTSInfo->getTemplate(i));
596 
597  // Templates args.
598  Record.push_back(DFTSInfo->getNumTemplateArgs());
599  for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i)
600  Record.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i));
601  Record.AddSourceLocation(DFTSInfo->getLAngleLoc());
602  Record.AddSourceLocation(DFTSInfo->getRAngleLoc());
603  break;
604  }
605  }
606 
607  Record.push_back(D->param_size());
608  for (auto P : D->parameters())
609  Record.AddDeclRef(P);
611 }
612 
614  VisitFunctionDecl(D);
615  Record.push_back(D->IsCopyDeductionCandidate);
617 }
618 
620  VisitNamedDecl(D);
621  // FIXME: convert to LazyStmtPtr?
622  // Unlike C/C++, method bodies will never be in header files.
623  bool HasBodyStuff = D->getBody() != nullptr ||
624  D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr;
625  Record.push_back(HasBodyStuff);
626  if (HasBodyStuff) {
627  Record.AddStmt(D->getBody());
628  Record.AddDeclRef(D->getSelfDecl());
629  Record.AddDeclRef(D->getCmdDecl());
630  }
631  Record.push_back(D->isInstanceMethod());
632  Record.push_back(D->isVariadic());
633  Record.push_back(D->isPropertyAccessor());
634  Record.push_back(D->isDefined());
635  Record.push_back(D->IsOverriding);
636  Record.push_back(D->HasSkippedBody);
637 
638  Record.push_back(D->IsRedeclaration);
639  Record.push_back(D->HasRedeclaration);
640  if (D->HasRedeclaration) {
641  assert(Context.getObjCMethodRedeclaration(D));
642  Record.AddDeclRef(Context.getObjCMethodRedeclaration(D));
643  }
644 
645  // FIXME: stable encoding for @required/@optional
646  Record.push_back(D->getImplementationControl());
647  // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
648  Record.push_back(D->getObjCDeclQualifier());
649  Record.push_back(D->hasRelatedResultType());
650  Record.AddTypeRef(D->getReturnType());
651  Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
652  Record.AddSourceLocation(D->getLocEnd());
653  Record.push_back(D->param_size());
654  for (const auto *P : D->parameters())
655  Record.AddDeclRef(P);
656 
657  Record.push_back(D->SelLocsKind);
658  unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
659  SourceLocation *SelLocs = D->getStoredSelLocs();
660  Record.push_back(NumStoredSelLocs);
661  for (unsigned i = 0; i != NumStoredSelLocs; ++i)
662  Record.AddSourceLocation(SelLocs[i]);
663 
665 }
666 
668  VisitTypedefNameDecl(D);
669  Record.push_back(D->Variance);
670  Record.push_back(D->Index);
671  Record.AddSourceLocation(D->VarianceLoc);
672  Record.AddSourceLocation(D->ColonLoc);
673 
675 }
676 
678  VisitNamedDecl(D);
679  Record.AddSourceLocation(D->getAtStartLoc());
680  Record.AddSourceRange(D->getAtEndRange());
681  // Abstract class (no need to define a stable serialization::DECL code).
682 }
683 
685  VisitRedeclarable(D);
686  VisitObjCContainerDecl(D);
687  Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
688  AddObjCTypeParamList(D->TypeParamList);
689 
690  Record.push_back(D->isThisDeclarationADefinition());
691  if (D->isThisDeclarationADefinition()) {
692  // Write the DefinitionData
693  ObjCInterfaceDecl::DefinitionData &Data = D->data();
694 
695  Record.AddTypeSourceInfo(D->getSuperClassTInfo());
696  Record.AddSourceLocation(D->getEndOfDefinitionLoc());
697  Record.push_back(Data.HasDesignatedInitializers);
698 
699  // Write out the protocols that are directly referenced by the @interface.
700  Record.push_back(Data.ReferencedProtocols.size());
701  for (const auto *P : D->protocols())
702  Record.AddDeclRef(P);
703  for (const auto &PL : D->protocol_locs())
704  Record.AddSourceLocation(PL);
705 
706  // Write out the protocols that are transitively referenced.
707  Record.push_back(Data.AllReferencedProtocols.size());
709  P = Data.AllReferencedProtocols.begin(),
710  PEnd = Data.AllReferencedProtocols.end();
711  P != PEnd; ++P)
712  Record.AddDeclRef(*P);
713 
714 
715  if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
716  // Ensure that we write out the set of categories for this class.
717  Writer.ObjCClassesWithCategories.insert(D);
718 
719  // Make sure that the categories get serialized.
720  for (; Cat; Cat = Cat->getNextClassCategoryRaw())
721  (void)Writer.GetDeclRef(Cat);
722  }
723  }
724 
726 }
727 
729  VisitFieldDecl(D);
730  // FIXME: stable encoding for @public/@private/@protected/@package
731  Record.push_back(D->getAccessControl());
732  Record.push_back(D->getSynthesize());
733 
734  if (D->getDeclContext() == D->getLexicalDeclContext() &&
735  !D->hasAttrs() &&
736  !D->isImplicit() &&
737  !D->isUsed(false) &&
738  !D->isInvalidDecl() &&
739  !D->isReferenced() &&
740  !D->isModulePrivate() &&
741  !D->getBitWidth() &&
742  !D->hasExtInfo() &&
743  D->getDeclName())
744  AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
745 
747 }
748 
750  VisitRedeclarable(D);
751  VisitObjCContainerDecl(D);
752 
753  Record.push_back(D->isThisDeclarationADefinition());
754  if (D->isThisDeclarationADefinition()) {
755  Record.push_back(D->protocol_size());
756  for (const auto *I : D->protocols())
757  Record.AddDeclRef(I);
758  for (const auto &PL : D->protocol_locs())
759  Record.AddSourceLocation(PL);
760  }
761 
763 }
764 
766  VisitFieldDecl(D);
768 }
769 
771  VisitObjCContainerDecl(D);
772  Record.AddSourceLocation(D->getCategoryNameLoc());
773  Record.AddSourceLocation(D->getIvarLBraceLoc());
774  Record.AddSourceLocation(D->getIvarRBraceLoc());
775  Record.AddDeclRef(D->getClassInterface());
776  AddObjCTypeParamList(D->TypeParamList);
777  Record.push_back(D->protocol_size());
778  for (const auto *I : D->protocols())
779  Record.AddDeclRef(I);
780  for (const auto &PL : D->protocol_locs())
781  Record.AddSourceLocation(PL);
783 }
784 
786  VisitNamedDecl(D);
787  Record.AddDeclRef(D->getClassInterface());
789 }
790 
792  VisitNamedDecl(D);
793  Record.AddSourceLocation(D->getAtLoc());
794  Record.AddSourceLocation(D->getLParenLoc());
795  Record.AddTypeRef(D->getType());
796  Record.AddTypeSourceInfo(D->getTypeSourceInfo());
797  // FIXME: stable encoding
798  Record.push_back((unsigned)D->getPropertyAttributes());
799  Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
800  // FIXME: stable encoding
801  Record.push_back((unsigned)D->getPropertyImplementation());
802  Record.AddDeclarationName(D->getGetterName());
803  Record.AddSourceLocation(D->getGetterNameLoc());
804  Record.AddDeclarationName(D->getSetterName());
805  Record.AddSourceLocation(D->getSetterNameLoc());
806  Record.AddDeclRef(D->getGetterMethodDecl());
807  Record.AddDeclRef(D->getSetterMethodDecl());
808  Record.AddDeclRef(D->getPropertyIvarDecl());
810 }
811 
813  VisitObjCContainerDecl(D);
814  Record.AddDeclRef(D->getClassInterface());
815  // Abstract class (no need to define a stable serialization::DECL code).
816 }
817 
819  VisitObjCImplDecl(D);
820  Record.AddSourceLocation(D->getCategoryNameLoc());
822 }
823 
825  VisitObjCImplDecl(D);
826  Record.AddDeclRef(D->getSuperClass());
827  Record.AddSourceLocation(D->getSuperClassLoc());
828  Record.AddSourceLocation(D->getIvarLBraceLoc());
829  Record.AddSourceLocation(D->getIvarRBraceLoc());
830  Record.push_back(D->hasNonZeroConstructors());
831  Record.push_back(D->hasDestructors());
832  Record.push_back(D->NumIvarInitializers);
833  if (D->NumIvarInitializers)
834  Record.AddCXXCtorInitializers(
835  llvm::makeArrayRef(D->init_begin(), D->init_end()));
837 }
838 
840  VisitDecl(D);
841  Record.AddSourceLocation(D->getLocStart());
842  Record.AddDeclRef(D->getPropertyDecl());
843  Record.AddDeclRef(D->getPropertyIvarDecl());
844  Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
845  Record.AddStmt(D->getGetterCXXConstructor());
846  Record.AddStmt(D->getSetterCXXAssignment());
848 }
849 
851  VisitDeclaratorDecl(D);
852  Record.push_back(D->isMutable());
853 
854  FieldDecl::InitStorageKind ISK = D->InitStorage.getInt();
855  Record.push_back(ISK);
856  if (ISK == FieldDecl::ISK_CapturedVLAType)
857  Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
858  else if (ISK)
859  Record.AddStmt(D->getInClassInitializer());
860 
861  Record.AddStmt(D->getBitWidth());
862 
863  if (!D->getDeclName())
864  Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D));
865 
866  if (D->getDeclContext() == D->getLexicalDeclContext() &&
867  !D->hasAttrs() &&
868  !D->isImplicit() &&
869  !D->isUsed(false) &&
870  !D->isInvalidDecl() &&
871  !D->isReferenced() &&
873  !D->isModulePrivate() &&
874  !D->getBitWidth() &&
875  !D->hasInClassInitializer() &&
876  !D->hasCapturedVLAType() &&
877  !D->hasExtInfo() &&
880  D->getDeclName())
881  AbbrevToUse = Writer.getDeclFieldAbbrev();
882 
884 }
885 
887  VisitDeclaratorDecl(D);
888  Record.AddIdentifierRef(D->getGetterId());
889  Record.AddIdentifierRef(D->getSetterId());
891 }
892 
894  VisitValueDecl(D);
895  Record.push_back(D->getChainingSize());
896 
897  for (const auto *P : D->chain())
898  Record.AddDeclRef(P);
900 }
901 
903  VisitRedeclarable(D);
904  VisitDeclaratorDecl(D);
905  Record.push_back(D->getStorageClass());
906  Record.push_back(D->getTSCSpec());
907  Record.push_back(D->getInitStyle());
908  if (!isa<ParmVarDecl>(D)) {
909  Record.push_back(D->isThisDeclarationADemotedDefinition());
910  Record.push_back(D->isExceptionVariable());
911  Record.push_back(D->isNRVOVariable());
912  Record.push_back(D->isCXXForRangeDecl());
913  Record.push_back(D->isARCPseudoStrong());
914  Record.push_back(D->isInline());
915  Record.push_back(D->isInlineSpecified());
916  Record.push_back(D->isConstexpr());
917  Record.push_back(D->isInitCapture());
918  Record.push_back(D->isPreviousDeclInSameBlockScope());
919  if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
920  Record.push_back(static_cast<unsigned>(IPD->getParameterKind()));
921  else
922  Record.push_back(0);
923  }
924  Record.push_back(D->getLinkageInternal());
925 
926  if (D->getInit()) {
927  Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2));
928  Record.AddStmt(D->getInit());
929  } else {
930  Record.push_back(0);
931  }
932 
933  if (D->getStorageDuration() == SD_Static) {
934  bool ModulesCodegen = false;
935  if (Writer.WritingModule &&
937  !isa<VarTemplateSpecializationDecl>(D)) {
938  // When building a C++ Modules TS module interface unit, a strong
939  // definition in the module interface is provided by the compilation of
940  // that module interface unit, not by its users. (Inline variables are
941  // still emitted in module users.)
942  ModulesCodegen =
943  (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit &&
944  Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal);
945  }
946  Record.push_back(ModulesCodegen);
947  if (ModulesCodegen)
948  Writer.ModularCodegenDecls.push_back(Writer.GetDeclRef(D));
949  }
950 
951  enum {
952  VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
953  };
954  if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
955  Record.push_back(VarTemplate);
956  Record.AddDeclRef(TemplD);
957  } else if (MemberSpecializationInfo *SpecInfo
959  Record.push_back(StaticDataMemberSpecialization);
960  Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
961  Record.push_back(SpecInfo->getTemplateSpecializationKind());
962  Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
963  } else {
964  Record.push_back(VarNotTemplate);
965  }
966 
967  if (D->getDeclContext() == D->getLexicalDeclContext() &&
968  !D->hasAttrs() &&
969  !D->isImplicit() &&
970  !D->isUsed(false) &&
971  !D->isInvalidDecl() &&
972  !D->isReferenced() &&
974  D->getAccess() == AS_none &&
975  !D->isModulePrivate() &&
978  !D->hasExtInfo() &&
979  D->getFirstDecl() == D->getMostRecentDecl() &&
980  D->getKind() == Decl::Var &&
981  !D->isInline() &&
982  !D->isConstexpr() &&
983  !D->isInitCapture() &&
985  D->getStorageDuration() != SD_Static &&
987  AbbrevToUse = Writer.getDeclVarAbbrev();
988 
990 }
991 
993  VisitVarDecl(D);
995 }
996 
998  VisitVarDecl(D);
999  Record.push_back(D->isObjCMethodParameter());
1000  Record.push_back(D->getFunctionScopeDepth());
1001  Record.push_back(D->getFunctionScopeIndex());
1002  Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding
1003  Record.push_back(D->isKNRPromoted());
1004  Record.push_back(D->hasInheritedDefaultArg());
1005  Record.push_back(D->hasUninstantiatedDefaultArg());
1006  if (D->hasUninstantiatedDefaultArg())
1007  Record.AddStmt(D->getUninstantiatedDefaultArg());
1009 
1010  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
1011 
1012  // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1013  // we dynamically check for the properties that we optimize for, but don't
1014  // know are true of all PARM_VAR_DECLs.
1015  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1016  !D->hasAttrs() &&
1017  !D->hasExtInfo() &&
1018  !D->isImplicit() &&
1019  !D->isUsed(false) &&
1020  !D->isInvalidDecl() &&
1021  !D->isReferenced() &&
1022  D->getAccess() == AS_none &&
1023  !D->isModulePrivate() &&
1024  D->getStorageClass() == 0 &&
1025  D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1026  D->getFunctionScopeDepth() == 0 &&
1027  D->getObjCDeclQualifier() == 0 &&
1028  !D->isKNRPromoted() &&
1029  !D->hasInheritedDefaultArg() &&
1030  D->getInit() == nullptr &&
1031  !D->hasUninstantiatedDefaultArg()) // No default expr.
1032  AbbrevToUse = Writer.getDeclParmVarAbbrev();
1033 
1034  // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1035  // just us assuming it.
1036  assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1038  && "PARM_VAR_DECL can't be demoted definition.");
1039  assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1040  assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1041  assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1042  assert(!D->isStaticDataMember() &&
1043  "PARM_VAR_DECL can't be static data member");
1044 }
1045 
1047  // Record the number of bindings first to simplify deserialization.
1048  Record.push_back(D->bindings().size());
1049 
1050  VisitVarDecl(D);
1051  for (auto *B : D->bindings())
1052  Record.AddDeclRef(B);
1054 }
1055 
1057  VisitValueDecl(D);
1058  Record.AddStmt(D->getBinding());
1060 }
1061 
1063  VisitDecl(D);
1064  Record.AddStmt(D->getAsmString());
1065  Record.AddSourceLocation(D->getRParenLoc());
1067 }
1068 
1070  VisitDecl(D);
1072 }
1073 
1075  VisitDecl(D);
1076  Record.AddStmt(D->getBody());
1077  Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1078  Record.push_back(D->param_size());
1079  for (ParmVarDecl *P : D->parameters())
1080  Record.AddDeclRef(P);
1081  Record.push_back(D->isVariadic());
1082  Record.push_back(D->blockMissingReturnType());
1083  Record.push_back(D->isConversionFromLambda());
1084  Record.push_back(D->capturesCXXThis());
1085  Record.push_back(D->getNumCaptures());
1086  for (const auto &capture : D->captures()) {
1087  Record.AddDeclRef(capture.getVariable());
1088 
1089  unsigned flags = 0;
1090  if (capture.isByRef()) flags |= 1;
1091  if (capture.isNested()) flags |= 2;
1092  if (capture.hasCopyExpr()) flags |= 4;
1093  Record.push_back(flags);
1094 
1095  if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1096  }
1097 
1099 }
1100 
1102  Record.push_back(CD->getNumParams());
1103  VisitDecl(CD);
1104  Record.push_back(CD->getContextParamPosition());
1105  Record.push_back(CD->isNothrow() ? 1 : 0);
1106  // Body is stored by VisitCapturedStmt.
1107  for (unsigned I = 0; I < CD->getNumParams(); ++I)
1108  Record.AddDeclRef(CD->getParam(I));
1110 }
1111 
1113  VisitDecl(D);
1114  Record.push_back(D->getLanguage());
1115  Record.AddSourceLocation(D->getExternLoc());
1116  Record.AddSourceLocation(D->getRBraceLoc());
1118 }
1119 
1121  VisitDecl(D);
1122  Record.AddSourceLocation(D->getRBraceLoc());
1124 }
1125 
1127  VisitNamedDecl(D);
1128  Record.AddSourceLocation(D->getLocStart());
1130 }
1131 
1132 
1134  VisitRedeclarable(D);
1135  VisitNamedDecl(D);
1136  Record.push_back(D->isInline());
1137  Record.AddSourceLocation(D->getLocStart());
1138  Record.AddSourceLocation(D->getRBraceLoc());
1139 
1140  if (D->isOriginalNamespace())
1141  Record.AddDeclRef(D->getAnonymousNamespace());
1143 
1144  if (Writer.hasChain() && D->isAnonymousNamespace() &&
1145  D == D->getMostRecentDecl()) {
1146  // This is a most recent reopening of the anonymous namespace. If its parent
1147  // is in a previous PCH (or is the TU), mark that parent for update, because
1148  // the original namespace always points to the latest re-opening of its
1149  // anonymous namespace.
1150  Decl *Parent = cast<Decl>(
1152  if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1153  Writer.DeclUpdates[Parent].push_back(
1154  ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D));
1155  }
1156  }
1157 }
1158 
1160  VisitRedeclarable(D);
1161  VisitNamedDecl(D);
1162  Record.AddSourceLocation(D->getNamespaceLoc());
1163  Record.AddSourceLocation(D->getTargetNameLoc());
1164  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1165  Record.AddDeclRef(D->getNamespace());
1167 }
1168 
1170  VisitNamedDecl(D);
1171  Record.AddSourceLocation(D->getUsingLoc());
1172  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1173  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1174  Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1175  Record.push_back(D->hasTypename());
1176  Record.AddDeclRef(Context.getInstantiatedFromUsingDecl(D));
1178 }
1179 
1181  Record.push_back(D->NumExpansions);
1182  VisitNamedDecl(D);
1183  Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1184  for (auto *E : D->expansions())
1185  Record.AddDeclRef(E);
1187 }
1188 
1190  VisitRedeclarable(D);
1191  VisitNamedDecl(D);
1192  Record.AddDeclRef(D->getTargetDecl());
1193  Record.AddDeclRef(D->UsingOrNextShadow);
1194  Record.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D));
1196 }
1197 
1200  VisitUsingShadowDecl(D);
1201  Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1202  Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1203  Record.push_back(D->IsVirtual);
1205 }
1206 
1208  VisitNamedDecl(D);
1209  Record.AddSourceLocation(D->getUsingLoc());
1210  Record.AddSourceLocation(D->getNamespaceKeyLocation());
1211  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1212  Record.AddDeclRef(D->getNominatedNamespace());
1213  Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1215 }
1216 
1218  VisitValueDecl(D);
1219  Record.AddSourceLocation(D->getUsingLoc());
1220  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1221  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1222  Record.AddSourceLocation(D->getEllipsisLoc());
1224 }
1225 
1228  VisitTypeDecl(D);
1229  Record.AddSourceLocation(D->getTypenameLoc());
1230  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1231  Record.AddSourceLocation(D->getEllipsisLoc());
1233 }
1234 
1236  VisitRecordDecl(D);
1237 
1238  enum {
1239  CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1240  };
1241  if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1242  Record.push_back(CXXRecTemplate);
1243  Record.AddDeclRef(TemplD);
1244  } else if (MemberSpecializationInfo *MSInfo
1245  = D->getMemberSpecializationInfo()) {
1246  Record.push_back(CXXRecMemberSpecialization);
1247  Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1248  Record.push_back(MSInfo->getTemplateSpecializationKind());
1249  Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1250  } else {
1251  Record.push_back(CXXRecNotTemplate);
1252  }
1253 
1254  Record.push_back(D->isThisDeclarationADefinition());
1256  Record.AddCXXDefinitionData(D);
1257 
1258  // Store (what we currently believe to be) the key function to avoid
1259  // deserializing every method so we can compute it.
1260  if (D->IsCompleteDefinition)
1261  Record.AddDeclRef(Context.getCurrentKeyFunction(D));
1262 
1264 }
1265 
1267  VisitFunctionDecl(D);
1268  if (D->isCanonicalDecl()) {
1269  Record.push_back(D->size_overridden_methods());
1272  I != E; ++I)
1273  Record.AddDeclRef(*I);
1274  } else {
1275  // We only need to record overridden methods once for the canonical decl.
1276  Record.push_back(0);
1277  }
1278 
1279  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1280  D->getFirstDecl() == D->getMostRecentDecl() &&
1281  !D->isInvalidDecl() &&
1282  !D->hasAttrs() &&
1285  !D->hasExtInfo() &&
1286  !D->hasInheritedPrototype() &&
1287  D->hasWrittenPrototype())
1288  AbbrevToUse = Writer.getDeclCXXMethodAbbrev();
1289 
1291 }
1292 
1294  if (auto Inherited = D->getInheritedConstructor()) {
1295  Record.AddDeclRef(Inherited.getShadowDecl());
1296  Record.AddDeclRef(Inherited.getConstructor());
1298  } else {
1300  }
1301 
1302  VisitCXXMethodDecl(D);
1303 
1304  Code = D->isInheritingConstructor()
1307 }
1308 
1310  VisitCXXMethodDecl(D);
1311 
1312  Record.AddDeclRef(D->getOperatorDelete());
1313  if (D->getOperatorDelete())
1314  Record.AddStmt(D->getOperatorDeleteThisArg());
1315 
1317 }
1318 
1320  VisitCXXMethodDecl(D);
1322 }
1323 
1325  VisitDecl(D);
1326  Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1327  ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1328  Record.push_back(!IdentifierLocs.empty());
1329  if (IdentifierLocs.empty()) {
1330  Record.AddSourceLocation(D->getLocEnd());
1331  Record.push_back(1);
1332  } else {
1333  for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1334  Record.AddSourceLocation(IdentifierLocs[I]);
1335  Record.push_back(IdentifierLocs.size());
1336  }
1337  // Note: the number of source locations must always be the last element in
1338  // the record.
1340 }
1341 
1343  VisitDecl(D);
1344  Record.AddSourceLocation(D->getColonLoc());
1346 }
1347 
1349  // Record the number of friend type template parameter lists here
1350  // so as to simplify memory allocation during deserialization.
1351  Record.push_back(D->NumTPLists);
1352  VisitDecl(D);
1353  bool hasFriendDecl = D->Friend.is<NamedDecl*>();
1354  Record.push_back(hasFriendDecl);
1355  if (hasFriendDecl)
1356  Record.AddDeclRef(D->getFriendDecl());
1357  else
1358  Record.AddTypeSourceInfo(D->getFriendType());
1359  for (unsigned i = 0; i < D->NumTPLists; ++i)
1360  Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1361  Record.AddDeclRef(D->getNextFriend());
1362  Record.push_back(D->UnsupportedFriend);
1363  Record.AddSourceLocation(D->FriendLoc);
1365 }
1366 
1368  VisitDecl(D);
1369  Record.push_back(D->getNumTemplateParameters());
1370  for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1371  Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1372  Record.push_back(D->getFriendDecl() != nullptr);
1373  if (D->getFriendDecl())
1374  Record.AddDeclRef(D->getFriendDecl());
1375  else
1376  Record.AddTypeSourceInfo(D->getFriendType());
1377  Record.AddSourceLocation(D->getFriendLoc());
1379 }
1380 
1382  VisitNamedDecl(D);
1383 
1384  Record.AddDeclRef(D->getTemplatedDecl());
1385  Record.AddTemplateParameterList(D->getTemplateParameters());
1386 }
1387 
1389  VisitRedeclarable(D);
1390 
1391  // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1392  // getCommonPtr() can be used while this is still initializing.
1393  if (D->isFirstDecl()) {
1394  // This declaration owns the 'common' pointer, so serialize that data now.
1395  Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1397  Record.push_back(D->isMemberSpecialization());
1398  }
1399 
1400  VisitTemplateDecl(D);
1401  Record.push_back(D->getIdentifierNamespace());
1402 }
1403 
1405  VisitRedeclarableTemplateDecl(D);
1406 
1407  if (D->isFirstDecl())
1408  AddTemplateSpecializations(D);
1410 }
1411 
1414  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1415 
1416  VisitCXXRecordDecl(D);
1417 
1418  llvm::PointerUnion<ClassTemplateDecl *,
1421  if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1422  Record.AddDeclRef(InstFromD);
1423  } else {
1424  Record.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>());
1425  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1426  }
1427 
1428  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1429  Record.AddSourceLocation(D->getPointOfInstantiation());
1430  Record.push_back(D->getSpecializationKind());
1431  Record.push_back(D->isCanonicalDecl());
1432 
1433  if (D->isCanonicalDecl()) {
1434  // When reading, we'll add it to the folding set of the following template.
1435  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1436  }
1437 
1438  // Explicit info.
1439  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1440  if (D->getTypeAsWritten()) {
1441  Record.AddSourceLocation(D->getExternLoc());
1442  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1443  }
1444 
1446 }
1447 
1450  VisitClassTemplateSpecializationDecl(D);
1451 
1452  Record.AddTemplateParameterList(D->getTemplateParameters());
1453  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1454 
1455  // These are read/set from/to the first declaration.
1456  if (D->getPreviousDecl() == nullptr) {
1457  Record.AddDeclRef(D->getInstantiatedFromMember());
1458  Record.push_back(D->isMemberSpecialization());
1459  }
1460 
1462 }
1463 
1465  VisitRedeclarableTemplateDecl(D);
1466 
1467  if (D->isFirstDecl())
1468  AddTemplateSpecializations(D);
1470 }
1471 
1474  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1475 
1476  VisitVarDecl(D);
1477 
1478  llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
1479  InstFrom = D->getSpecializedTemplateOrPartial();
1480  if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
1481  Record.AddDeclRef(InstFromD);
1482  } else {
1483  Record.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>());
1484  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1485  }
1486 
1487  // Explicit info.
1488  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1489  if (D->getTypeAsWritten()) {
1490  Record.AddSourceLocation(D->getExternLoc());
1491  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1492  }
1493 
1494  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1495  Record.AddSourceLocation(D->getPointOfInstantiation());
1496  Record.push_back(D->getSpecializationKind());
1497  Record.push_back(D->IsCompleteDefinition);
1498  Record.push_back(D->isCanonicalDecl());
1499 
1500  if (D->isCanonicalDecl()) {
1501  // When reading, we'll add it to the folding set of the following template.
1502  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1503  }
1504 
1506 }
1507 
1510  VisitVarTemplateSpecializationDecl(D);
1511 
1512  Record.AddTemplateParameterList(D->getTemplateParameters());
1513  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1514 
1515  // These are read/set from/to the first declaration.
1516  if (D->getPreviousDecl() == nullptr) {
1517  Record.AddDeclRef(D->getInstantiatedFromMember());
1518  Record.push_back(D->isMemberSpecialization());
1519  }
1520 
1522 }
1523 
1526  VisitDecl(D);
1527  Record.AddDeclRef(D->getSpecialization());
1529 }
1530 
1531 
1533  VisitRedeclarableTemplateDecl(D);
1534 
1535  if (D->isFirstDecl())
1536  AddTemplateSpecializations(D);
1538 }
1539 
1541  VisitTypeDecl(D);
1542 
1543  Record.push_back(D->wasDeclaredWithTypename());
1544 
1545  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1547  Record.push_back(OwnsDefaultArg);
1548  if (OwnsDefaultArg)
1549  Record.AddTypeSourceInfo(D->getDefaultArgumentInfo());
1550 
1552 }
1553 
1555  // For an expanded parameter pack, record the number of expansion types here
1556  // so that it's easier for deserialization to allocate the right amount of
1557  // memory.
1558  if (D->isExpandedParameterPack())
1559  Record.push_back(D->getNumExpansionTypes());
1560 
1561  VisitDeclaratorDecl(D);
1562  // TemplateParmPosition.
1563  Record.push_back(D->getDepth());
1564  Record.push_back(D->getPosition());
1565 
1566  if (D->isExpandedParameterPack()) {
1567  for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
1568  Record.AddTypeRef(D->getExpansionType(I));
1569  Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
1570  }
1571 
1573  } else {
1574  // Rest of NonTypeTemplateParmDecl.
1575  Record.push_back(D->isParameterPack());
1576  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1578  Record.push_back(OwnsDefaultArg);
1579  if (OwnsDefaultArg)
1580  Record.AddStmt(D->getDefaultArgument());
1582  }
1583 }
1584 
1586  // For an expanded parameter pack, record the number of expansion types here
1587  // so that it's easier for deserialization to allocate the right amount of
1588  // memory.
1589  if (D->isExpandedParameterPack())
1590  Record.push_back(D->getNumExpansionTemplateParameters());
1591 
1592  VisitTemplateDecl(D);
1593  // TemplateParmPosition.
1594  Record.push_back(D->getDepth());
1595  Record.push_back(D->getPosition());
1596 
1597  if (D->isExpandedParameterPack()) {
1598  for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
1599  I != N; ++I)
1600  Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
1602  } else {
1603  // Rest of TemplateTemplateParmDecl.
1604  Record.push_back(D->isParameterPack());
1605  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1607  Record.push_back(OwnsDefaultArg);
1608  if (OwnsDefaultArg)
1609  Record.AddTemplateArgumentLoc(D->getDefaultArgument());
1611  }
1612 }
1613 
1615  VisitRedeclarableTemplateDecl(D);
1617 }
1618 
1620  VisitDecl(D);
1621  Record.AddStmt(D->getAssertExpr());
1622  Record.push_back(D->isFailed());
1623  Record.AddStmt(D->getMessage());
1624  Record.AddSourceLocation(D->getRParenLoc());
1626 }
1627 
1628 /// \brief Emit the DeclContext part of a declaration context decl.
1630  Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC));
1631  Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC));
1632 }
1633 
1635  assert(IsLocalDecl(D) && "expected a local declaration");
1636 
1637  const Decl *Canon = D->getCanonicalDecl();
1638  if (IsLocalDecl(Canon))
1639  return Canon;
1640 
1641  const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
1642  if (CacheEntry)
1643  return CacheEntry;
1644 
1645  for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
1646  if (IsLocalDecl(Redecl))
1647  D = Redecl;
1648  return CacheEntry = D;
1649 }
1650 
1651 template <typename T>
1653  T *First = D->getFirstDecl();
1654  T *MostRecent = First->getMostRecentDecl();
1655  T *DAsT = static_cast<T *>(D);
1656  if (MostRecent != First) {
1657  assert(isRedeclarableDeclKind(DAsT->getKind()) &&
1658  "Not considered redeclarable?");
1659 
1660  Record.AddDeclRef(First);
1661 
1662  // Write out a list of local redeclarations of this declaration if it's the
1663  // first local declaration in the chain.
1664  const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
1665  if (DAsT == FirstLocal) {
1666  // Emit a list of all imported first declarations so that we can be sure
1667  // that all redeclarations visible to this module are before D in the
1668  // redecl chain.
1669  unsigned I = Record.size();
1670  Record.push_back(0);
1671  if (Writer.Chain)
1672  AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
1673  // This is the number of imported first declarations + 1.
1674  Record[I] = Record.size() - I;
1675 
1676  // Collect the set of local redeclarations of this declaration, from
1677  // newest to oldest.
1678  ASTWriter::RecordData LocalRedecls;
1679  ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
1680  for (const Decl *Prev = FirstLocal->getMostRecentDecl();
1681  Prev != FirstLocal; Prev = Prev->getPreviousDecl())
1682  if (!Prev->isFromASTFile())
1683  LocalRedeclWriter.AddDeclRef(Prev);
1684 
1685  // If we have any redecls, write them now as a separate record preceding
1686  // the declaration itself.
1687  if (LocalRedecls.empty())
1688  Record.push_back(0);
1689  else
1690  Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
1691  } else {
1692  Record.push_back(0);
1693  Record.AddDeclRef(FirstLocal);
1694  }
1695 
1696  // Make sure that we serialize both the previous and the most-recent
1697  // declarations, which (transitively) ensures that all declarations in the
1698  // chain get serialized.
1699  //
1700  // FIXME: This is not correct; when we reach an imported declaration we
1701  // won't emit its previous declaration.
1702  (void)Writer.GetDeclRef(D->getPreviousDecl());
1703  (void)Writer.GetDeclRef(MostRecent);
1704  } else {
1705  // We use the sentinel value 0 to indicate an only declaration.
1706  Record.push_back(0);
1707  }
1708 }
1709 
1711  Record.push_back(D->varlist_size());
1712  VisitDecl(D);
1713  for (auto *I : D->varlists())
1714  Record.AddStmt(I);
1716 }
1717 
1719  VisitValueDecl(D);
1720  Record.AddSourceLocation(D->getLocStart());
1721  Record.AddStmt(D->getCombiner());
1722  Record.AddStmt(D->getInitializer());
1723  Record.push_back(D->getInitializerKind());
1724  Record.AddDeclRef(D->getPrevDeclInScope());
1726 }
1727 
1729  VisitVarDecl(D);
1731 }
1732 
1733 //===----------------------------------------------------------------------===//
1734 // ASTWriter Implementation
1735 //===----------------------------------------------------------------------===//
1736 
1737 void ASTWriter::WriteDeclAbbrevs() {
1738  using namespace llvm;
1739 
1740  std::shared_ptr<BitCodeAbbrev> Abv;
1741 
1742  // Abbreviation for DECL_FIELD
1743  Abv = std::make_shared<BitCodeAbbrev>();
1744  Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
1745  // Decl
1746  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1747  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1748  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1749  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1750  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1751  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1752  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1753  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1754  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1755  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1756  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1757  // NamedDecl
1758  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1759  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1760  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1761  // ValueDecl
1762  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1763  // DeclaratorDecl
1764  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1765  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1766  // FieldDecl
1767  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1768  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1769  // Type Source Info
1770  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1771  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1772  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1773  DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
1774 
1775  // Abbreviation for DECL_OBJC_IVAR
1776  Abv = std::make_shared<BitCodeAbbrev>();
1777  Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
1778  // Decl
1779  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1780  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1781  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1782  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1783  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1784  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1785  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1786  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1787  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1788  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1789  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1790  // NamedDecl
1791  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1792  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1793  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1794  // ValueDecl
1795  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1796  // DeclaratorDecl
1797  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1798  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1799  // FieldDecl
1800  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1801  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1802  // ObjC Ivar
1803  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
1804  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
1805  // Type Source Info
1806  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1807  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1808  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1809  DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1810 
1811  // Abbreviation for DECL_ENUM
1812  Abv = std::make_shared<BitCodeAbbrev>();
1813  Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
1814  // Redeclarable
1815  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1816  // Decl
1817  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1818  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1819  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1820  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1821  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1822  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1823  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1824  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1825  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1826  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1827  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1828  // NamedDecl
1829  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1830  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1831  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1832  // TypeDecl
1833  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1834  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1835  // TagDecl
1836  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1837  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1838  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1839  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1840  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1841  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1842  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1843  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1844  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1845  // EnumDecl
1846  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
1847  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
1848  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
1849  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumPositiveBits
1850  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumNegativeBits
1851  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScoped
1852  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScopedUsingClassTag
1853  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isFixed
1854  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
1855  // DC
1856  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1857  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1858  DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
1859 
1860  // Abbreviation for DECL_RECORD
1861  Abv = std::make_shared<BitCodeAbbrev>();
1862  Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
1863  // Redeclarable
1864  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1865  // Decl
1866  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1867  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1868  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1869  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1870  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1871  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1872  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1873  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1874  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1875  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1876  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1877  // NamedDecl
1878  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1879  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1880  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1881  // TypeDecl
1882  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1883  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1884  // TagDecl
1885  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1886  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1887  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1888  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1889  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1890  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1891  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1892  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1893  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1894  // RecordDecl
1895  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember
1896  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
1897  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
1898  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
1899  // DC
1900  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1901  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1902  DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
1903 
1904  // Abbreviation for DECL_PARM_VAR
1905  Abv = std::make_shared<BitCodeAbbrev>();
1906  Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
1907  // Redeclarable
1908  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1909  // Decl
1910  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1911  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1912  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1913  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1914  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1915  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1916  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1917  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1918  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1919  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1920  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1921  // NamedDecl
1922  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1923  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1924  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1925  // ValueDecl
1926  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1927  // DeclaratorDecl
1928  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1929  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1930  // VarDecl
1931  Abv->Add(BitCodeAbbrevOp(0)); // SClass
1932  Abv->Add(BitCodeAbbrevOp(0)); // TSCSpec
1933  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1934  Abv->Add(BitCodeAbbrevOp(0)); // Linkage
1935  Abv->Add(BitCodeAbbrevOp(0)); // HasInit
1936  Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo
1937  // ParmVarDecl
1938  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsObjCMethodParameter
1939  Abv->Add(BitCodeAbbrevOp(0)); // ScopeDepth
1940  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
1941  Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier
1942  Abv->Add(BitCodeAbbrevOp(0)); // KNRPromoted
1943  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg
1944  Abv->Add(BitCodeAbbrevOp(0)); // HasUninstantiatedDefaultArg
1945  // Type Source Info
1946  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1947  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1948  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1949  DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1950 
1951  // Abbreviation for DECL_TYPEDEF
1952  Abv = std::make_shared<BitCodeAbbrev>();
1953  Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
1954  // Redeclarable
1955  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1956  // Decl
1957  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1958  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1959  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1960  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1961  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1962  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isUsed
1963  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isReferenced
1964  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1965  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // C++ AccessSpecifier
1966  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1967  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1968  // NamedDecl
1969  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1970  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1971  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1972  // TypeDecl
1973  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1974  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1975  // TypedefDecl
1976  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1977  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1978  DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
1979 
1980  // Abbreviation for DECL_VAR
1981  Abv = std::make_shared<BitCodeAbbrev>();
1982  Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
1983  // Redeclarable
1984  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1985  // Decl
1986  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1987  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1988  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1989  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1990  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1991  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1992  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1993  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1994  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1995  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1996  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1997  // NamedDecl
1998  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1999  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2000  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2001  // ValueDecl
2002  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2003  // DeclaratorDecl
2004  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2005  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2006  // VarDecl
2007  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
2008  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
2009  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
2010  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
2011  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
2012  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
2013  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
2014  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
2015  Abv->Add(BitCodeAbbrevOp(0)); // isInline
2016  Abv->Add(BitCodeAbbrevOp(0)); // isInlineSpecified
2017  Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
2018  Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
2019  Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
2020  Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind
2021  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
2022  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
2023  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
2024  // Type Source Info
2025  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2026  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2027  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2028  DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2029 
2030  // Abbreviation for DECL_CXX_METHOD
2031  Abv = std::make_shared<BitCodeAbbrev>();
2032  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD));
2033  // RedeclarableDecl
2034  Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2035  // Decl
2036  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2037  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
2038  Abv->Add(BitCodeAbbrevOp(0)); // Invalid
2039  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
2040  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Implicit
2041  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Used
2042  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Referenced
2043  Abv->Add(BitCodeAbbrevOp(0)); // InObjCContainer
2044  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Access
2045  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModulePrivate
2046  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2047  // NamedDecl
2048  Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2049  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2050  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2051  // ValueDecl
2052  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2053  // DeclaratorDecl
2054  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2055  Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2056  // FunctionDecl
2057  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2058  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass
2059  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline
2060  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified
2061  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitSpecified
2062  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten
2063  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure
2064  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto
2065  Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto
2066  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted
2067  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial
2068  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
2069  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
2070  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
2071  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
2072  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry
2073  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
2074  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed
2075  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
2076  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2077  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind
2078  // This Array slurps the rest of the record. Fortunately we want to encode
2079  // (nearly) all the remaining (variable number of) fields in the same way.
2080  //
2081  // This is the function template information if any, then
2082  // NumParams and Params[] from FunctionDecl, and
2083  // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2084  //
2085  // Add an AbbrevOp for 'size then elements' and use it here.
2086  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2087  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2088  DeclCXXMethodAbbrev = Stream.EmitAbbrev(std::move(Abv));
2089 
2090  // Abbreviation for EXPR_DECL_REF
2091  Abv = std::make_shared<BitCodeAbbrev>();
2092  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2093  //Stmt
2094  //Expr
2095  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2096  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2097  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2098  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2099  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2100  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2101  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2102  //DeclRefExpr
2103  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HasQualifier
2104  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //GetDeclFound
2105  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ExplicitTemplateArgs
2106  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HadMultipleCandidates
2107  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2108  1)); // RefersToEnclosingVariableOrCapture
2109  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2110  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2111  DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2112 
2113  // Abbreviation for EXPR_INTEGER_LITERAL
2114  Abv = std::make_shared<BitCodeAbbrev>();
2115  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2116  //Stmt
2117  //Expr
2118  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2119  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2120  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2121  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2122  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2123  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2124  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2125  //Integer Literal
2126  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2127  Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2128  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2129  IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2130 
2131  // Abbreviation for EXPR_CHARACTER_LITERAL
2132  Abv = std::make_shared<BitCodeAbbrev>();
2133  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2134  //Stmt
2135  //Expr
2136  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2137  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2138  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2139  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2140  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2141  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2142  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2143  //Character Literal
2144  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2145  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2146  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2147  CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2148 
2149  // Abbreviation for EXPR_IMPLICIT_CAST
2150  Abv = std::make_shared<BitCodeAbbrev>();
2151  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2152  // Stmt
2153  // Expr
2154  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2155  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2156  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2157  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2158  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2159  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2160  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2161  // CastExpr
2162  Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2163  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind
2164  // ImplicitCastExpr
2165  ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2166 
2167  Abv = std::make_shared<BitCodeAbbrev>();
2168  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2169  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2170  DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2171 
2172  Abv = std::make_shared<BitCodeAbbrev>();
2173  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2174  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2175  DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2176 }
2177 
2178 /// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2179 /// consumers of the AST.
2180 ///
2181 /// Such decls will always be deserialized from the AST file, so we would like
2182 /// this to be as restrictive as possible. Currently the predicate is driven by
2183 /// code generation requirements, if other clients have a different notion of
2184 /// what is "required" then we may have to consider an alternate scheme where
2185 /// clients can iterate over the top-level decls and get information on them,
2186 /// without necessary deserializing them. We could explicitly require such
2187 /// clients to use a separate API call to "realize" the decl. This should be
2188 /// relatively painless since they would presumably only do it for top-level
2189 /// decls.
2190 static bool isRequiredDecl(const Decl *D, ASTContext &Context,
2191  bool WritingModule) {
2192  // An ObjCMethodDecl is never considered as "required" because its
2193  // implementation container always is.
2194 
2195  // File scoped assembly or obj-c or OMP declare target implementation must be
2196  // seen.
2197  if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D) ||
2198  D->hasAttr<OMPDeclareTargetDeclAttr>())
2199  return true;
2200 
2201  if (WritingModule && (isa<VarDecl>(D) || isa<ImportDecl>(D))) {
2202  // These declarations are part of the module initializer, and are emitted
2203  // if and when the module is imported, rather than being emitted eagerly.
2204  return false;
2205  }
2206 
2207  return Context.DeclMustBeEmitted(D);
2208 }
2209 
2210 void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
2211  // Determine the ID for this declaration.
2213  assert(!D->isFromASTFile() && "should not be emitting imported decl");
2214  serialization::DeclID &IDR = DeclIDs[D];
2215  if (IDR == 0)
2216  IDR = NextDeclID++;
2217 
2218  ID = IDR;
2219 
2220  assert(ID >= FirstDeclID && "invalid decl ID");
2221 
2222  RecordData Record;
2223  ASTDeclWriter W(*this, Context, Record);
2224 
2225  // Build a record for this declaration
2226  W.Visit(D);
2227 
2228  // Emit this declaration to the bitstream.
2229  uint64_t Offset = W.Emit(D);
2230 
2231  // Record the offset for this declaration
2232  SourceLocation Loc = D->getLocation();
2233  unsigned Index = ID - FirstDeclID;
2234  if (DeclOffsets.size() == Index)
2235  DeclOffsets.push_back(DeclOffset(Loc, Offset));
2236  else if (DeclOffsets.size() < Index) {
2237  // FIXME: Can/should this happen?
2238  DeclOffsets.resize(Index+1);
2239  DeclOffsets[Index].setLocation(Loc);
2240  DeclOffsets[Index].BitOffset = Offset;
2241  } else {
2242  llvm_unreachable("declarations should be emitted in ID order");
2243  }
2244 
2245  SourceManager &SM = Context.getSourceManager();
2246  if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
2247  associateDeclWithFile(D, ID);
2248 
2249  // Note declarations that should be deserialized eagerly so that we can add
2250  // them to a record in the AST file later.
2251  if (isRequiredDecl(D, Context, WritingModule))
2252  EagerlyDeserializedDecls.push_back(ID);
2253 }
2254 
2256  // Switch case IDs are per function body.
2257  Writer->ClearSwitchCaseIDs();
2258 
2259  assert(FD->doesThisDeclarationHaveABody());
2260  bool ModulesCodegen = false;
2261  if (Writer->WritingModule && !FD->isDependentContext()) {
2263  if (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
2264  // When building a C++ Modules TS module interface unit, a strong
2265  // definition in the module interface is provided by the compilation of
2266  // that module interface unit, not by its users. (Inline functions are
2267  // still emitted in module users.)
2268  Linkage = Writer->Context->GetGVALinkageForFunction(FD);
2269  ModulesCodegen = *Linkage == GVA_StrongExternal;
2270  }
2271  if (Writer->Context->getLangOpts().ModulesCodegen) {
2272  // Under -fmodules-codegen, codegen is performed for all non-internal,
2273  // non-always_inline functions.
2274  if (!FD->hasAttr<AlwaysInlineAttr>()) {
2275  if (!Linkage)
2276  Linkage = Writer->Context->GetGVALinkageForFunction(FD);
2277  ModulesCodegen = *Linkage != GVA_Internal;
2278  }
2279  }
2280  }
2281  Record->push_back(ModulesCodegen);
2282  if (ModulesCodegen)
2283  Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));
2284  if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
2285  Record->push_back(CD->getNumCtorInitializers());
2286  if (CD->getNumCtorInitializers())
2287  AddCXXCtorInitializers(
2288  llvm::makeArrayRef(CD->init_begin(), CD->init_end()));
2289  }
2290  AddStmt(FD->getBody());
2291 }
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition: Decl.cpp:2393
SourceLocation getGetterNameLoc() const
Definition: DeclObjC.h:924
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1354
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1381
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition: Decl.h:2626
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:3128
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1698
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:1282
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
const CXXMethodDecl *const * method_iterator
Definition: DeclCXX.h:2073
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:3553
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:1557
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:3066
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1417
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:2550
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Definition: Decl.h:2665
void VisitCXXRecordDecl(CXXRecordDecl *D)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1010
TypedefDecl - Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier...
Definition: Decl.h:2892
Defines the SourceManager interface.
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1435
bool hasVolatileMember() const
Definition: Decl.h:3558
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:2271
const Type * getTypeForDecl() const
Definition: Decl.h:2778
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
getNumCaptures - Returns the number of captured variables.
Definition: Decl.h:3811
An ImplicitCastExpr record.
Definition: ASTBitCodes.h:1571
bool isNothrow() const
Definition: Decl.cpp:4252
IdentifierInfo * getGetterId() const
Definition: DeclCXX.h:3856
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1372
ThreadStorageClassSpecifier getTSCSpec() const
Definition: Decl.h:1019
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:2031
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:948
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:1279
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:1328
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:4075
ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, ASTWriter::RecordDataImpl &Record)
Expr * getOperatorDeleteThisArg() const
Definition: DeclCXX.h:2656
Declaration of a variable template.
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:506
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1236
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:2397
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition: Decl.h:2591
size_t param_size() const
Definition: Decl.h:2180
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:3039
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Definition: Decl.h:3091
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:1357
A PragmaDetectMismatchDecl record.
Definition: ASTBitCodes.h:1432
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1318
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.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:807
Declaration of a redeclarable template.
Definition: DeclTemplate.h:736
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
An OMPCapturedExprDecl record.
Definition: ASTBitCodes.h:1426
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:3420
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1306
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:1642
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:1407
void VisitIndirectFieldDecl(IndirectFieldDecl *D)
bool isInvalidDecl() const
Definition: DeclBase.h:546
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
unsigned getContextParamPosition() const
Definition: Decl.h:3934
protocol_range protocols() const
Definition: DeclObjC.h:2148
unsigned IsExplicitSpecified
Definition: Decl.h:1727
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1384
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:629
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1514
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:1212
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:1340
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
A CXXConstructorDecl record for an inherited constructor.
Definition: ASTBitCodes.h:1339
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3482
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2789
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
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:291
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:3374
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:3695
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2715
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2868
CXXRecordDecl * getPreviousDecl()
Definition: DeclCXX.h:713
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:567
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:3020
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2461
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
const llvm::APSInt & getInitVal() const
Definition: Decl.h:2686
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1567
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:2593
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:3767
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:1386
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:3771
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1399
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2164
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:3275
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:3798
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
getBody - Retrieve the body (definition) of the function.
Definition: Decl.cpp:2612
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:986
TagKind getTagKind() const
Definition: Decl.h:3150
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:411
void VisitTypedefDecl(TypedefDecl *D)
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1348
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:1588
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:4312
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void VisitUsingShadowDecl(UsingShadowDecl *D)
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1309
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.cpp:3222
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:869
ArrayRef< NamedDecl * > chain() const
Definition: Decl.h:2727
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1312
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:857
A DecompositionDecl record.
Definition: ASTBitCodes.h:1257
TypeDecl - Represents a declaration of a type.
Definition: Decl.h:2754
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:3384
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
Definition: Decl.h:3463
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or nullptr if this template w...
Definition: DeclTemplate.h:916
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1367
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3337
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:2684
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2849
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition: DeclFriend.h:132
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1360
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition: Decl.h:3097
SourceLocation getExternLoc() const
Definition: DeclCXX.h:2801
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:4464
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:950
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3860
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:2743
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:3718
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:3207
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:865
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:1133
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
Definition: Decl.h:3550
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:4009
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:3700
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition: Decl.h:1071
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:3528
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2912
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1414
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:2781
SourceLocation getTypenameLoc() const
Returns the source location of the &#39;typename&#39; keyword.
Definition: DeclCXX.h:3622
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:681
QualType getPromotionType() const
getPromotionType - Return the integer type that enumerators should promote to.
Definition: Decl.h:3350
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1330
method_iterator end_overridden_methods() const
Definition: DeclCXX.cpp:1917
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:1352
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition: DeclOpenMP.h:147
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1390
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:2841
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1369
static bool classofKind(Kind K)
Definition: DeclObjC.h:2018
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1423
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:871
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3163
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1561
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3689
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:628
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3315
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1227
unsigned getChainingSize() const
Definition: Decl.h:2733
Selector getSetterName() const
Definition: DeclObjC.h:931
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3414
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1239
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:3905
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2620
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:1336
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition: Decl.h:562
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition: Decl.h:1300
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:963
void VisitClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl *D)
void VisitTemplateDecl(TemplateDecl *D)
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
DeclContext * getDeclContext()
Definition: DeclBase.h:425
void VisitUsingDecl(UsingDecl *D)
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1366
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
EnumDecl * getMostRecentDecl()
Definition: Decl.h:3296
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:3395
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1342
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
unsigned IsCopyDeductionCandidate
[C++17] Only used by CXXDeductionGuideDecl.
Definition: Decl.h:1760
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Definition: ASTBitCodes.h:1403
IdentifierInfo * getSetterId() const
Definition: DeclCXX.h:3858
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:1297
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1331
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:1364
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:1026
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1251
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:1911
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2682
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1203
ImplicitParamDecl * getSelfDecl() const
Definition: DeclObjC.h:444
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1272
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
QualType getType() const
Definition: DeclObjC.h:846
const SourceManager & SM
Definition: Format.cpp:1337
void VisitTagDecl(TagDecl *D)
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1414
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1224
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
CXXMethodDecl * getMostRecentDecl()
Definition: DeclCXX.h:2053
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:1233
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:2035
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:2914
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:1922
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:4030
SourceLocation getUsingLoc() const
Returns the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3526
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:1315
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:3457
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:1288
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:2918
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:609
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition: Decl.h:2631
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the &#39;typename&#39; keyword.
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2938
SourceLocation getUsingLoc() const
Return the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3308
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2546
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition: Decl.h:2929
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
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:460
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3494
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3536
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2598
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:3672
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1964
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
void VisitUsingPackDecl(UsingPackDecl *D)
C-style initialization with assignment.
Definition: Decl.h:812
bool isConversionFromLambda() const
Definition: Decl.h:3824
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
A TemplateTypeParmDecl record.
Definition: ASTBitCodes.h:1378
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:964
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:2888
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:3409
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:2839
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:70
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:386
void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D)
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2336
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:1294
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3669
void VisitPragmaCommentDecl(PragmaCommentDecl *D)
SourceLocation getRBraceLoc() const
Definition: DeclCXX.h:2802
bool hasFlexibleArrayMember() const
Definition: Decl.h:3535
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:79
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2436
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition: Decl.cpp:1042
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:3965
protocol_range protocols() const
Definition: DeclObjC.h:2375
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1215
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: Decl.h:1571
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2796
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1345
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:2290
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:2402
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1252
ArrayRef< Capture > captures() const
Definition: Decl.h:3815
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
method_iterator begin_overridden_methods() const
Definition: DeclCXX.cpp:1912
bool isVariadic() const
Definition: Decl.h:3763
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:2264
SourceLocation getAtLoc() const
Definition: DeclObjC.h:838
void VisitNamedDecl(NamedDecl *D)
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Definition: Decl.h:2705
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1363
QualType getUnderlyingType() const
Definition: Decl.h:2847
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:3011
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition: DeclCXX.h:2910
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1189
const Expr * getInit() const
Definition: Decl.h:1213
AccessSpecifier getAccess() const
Definition: DeclBase.h:460
A decomposition declaration.
Definition: DeclCXX.h:3766
bool isEmbeddedInDeclarator() const
Definition: Decl.h:3106
void VisitTypeDecl(TypeDecl *D)
unsigned getNumTemplateParameters() const
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3590
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
Definition: ASTBitCodes.h:1411
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:3626
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1321
decltype(T::PartialSpecializations) & getPartialSpecializations(T *Common)
Get the list of partial specializations from a template&#39;s common ptr.
EnumDecl - Represents an enum.
Definition: Decl.h:3233
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:1376
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:2652
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1429
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:2531
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2169
size_t param_size() const
Definition: Decl.h:3790
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:1648
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:3907
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:3330
SourceManager & getSourceManager()
Definition: ASTContext.h:643
bool capturesCXXThis() const
Definition: Decl.h:3820
ImplementationControl getImplementationControl() const
Definition: DeclObjC.h:502
static bool classofKind(Kind K)
Definition: DeclCXX.h:1896
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:1378
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:3181
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2536
bool isThisDeclarationADefinition() const
isThisDeclarationADefinition() - Return true if this declaration is a completion definition of the ty...
Definition: Decl.h:3085
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:4049
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:1318
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:3401
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:1230
void VisitEnumConstantDecl(EnumConstantDecl *D)
SourceLocation getFriendLoc() const
Retrieves the location of the &#39;friend&#39; keyword.
bool isFailed() const
Definition: DeclCXX.h:3698
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1221
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:1181
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1194
unsigned protocol_size() const
Definition: DeclObjC.h:2384
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
Definition: Decl.h:3358
bool doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
Definition: Decl.h:1977
An ExportDecl record.
Definition: ASTBitCodes.h:1324
bool blockMissingReturnType() const
Definition: Decl.h:3821
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3643
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)
TranslationUnitDecl - 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:3774
NamedDecl * getMostRecentDecl()
Definition: Decl.h:437
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:3555
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D)
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:3740
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1106
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition: Decl.cpp:3184
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1375
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:7085
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1387
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:1127
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
Definition: Decl.h:589
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3835
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:3036
QualType getType() const
Definition: Decl.h:639
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
NamedDecl - This represents a decl with a name.
Definition: Decl.h:245
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:2947
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:1349
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:3461
Selector getGetterName() const
Definition: DeclObjC.h:923
Represents C++ using-directive.
Definition: DeclCXX.h:2843
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:3113
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
Definition: Decl.h:723
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:958
Source range/offset of a preprocessed entity.
Definition: ASTBitCodes.h:202
SourceLocation getLocation() const
Definition: DeclBase.h:416
const StringLiteral * getAsmString() const
Definition: Decl.h:3678
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3066
Represents a pack of using declarations that a single using-declarator pack-expanded into...
Definition: DeclCXX.h:3425
SourceLocation getRBraceLoc() const
Definition: Decl.h:610
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:2590