clang  5.0.0
ASTWriterDecl.cpp
Go to the documentation of this file.
1 //===--- ASTWriterDecl.cpp - Declaration Serialization --------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements serialization for Declarations.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "ASTCommon.h"
15 #include "clang/AST/DeclCXX.h"
17 #include "clang/AST/DeclTemplate.h"
18 #include "clang/AST/DeclVisitor.h"
19 #include "clang/AST/Expr.h"
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;
36  ASTRecordWriter Record;
37 
39  unsigned AbbrevToUse;
40 
41  public:
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);
616 }
617 
619  VisitNamedDecl(D);
620  // FIXME: convert to LazyStmtPtr?
621  // Unlike C/C++, method bodies will never be in header files.
622  bool HasBodyStuff = D->getBody() != nullptr ||
623  D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr;
624  Record.push_back(HasBodyStuff);
625  if (HasBodyStuff) {
626  Record.AddStmt(D->getBody());
627  Record.AddDeclRef(D->getSelfDecl());
628  Record.AddDeclRef(D->getCmdDecl());
629  }
630  Record.push_back(D->isInstanceMethod());
631  Record.push_back(D->isVariadic());
632  Record.push_back(D->isPropertyAccessor());
633  Record.push_back(D->isDefined());
634  Record.push_back(D->IsOverriding);
635  Record.push_back(D->HasSkippedBody);
636 
637  Record.push_back(D->IsRedeclaration);
638  Record.push_back(D->HasRedeclaration);
639  if (D->HasRedeclaration) {
641  Record.AddDeclRef(Context.getObjCMethodRedeclaration(D));
642  }
643 
644  // FIXME: stable encoding for @required/@optional
645  Record.push_back(D->getImplementationControl());
646  // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
647  Record.push_back(D->getObjCDeclQualifier());
648  Record.push_back(D->hasRelatedResultType());
649  Record.AddTypeRef(D->getReturnType());
650  Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
651  Record.AddSourceLocation(D->getLocEnd());
652  Record.push_back(D->param_size());
653  for (const auto *P : D->parameters())
654  Record.AddDeclRef(P);
655 
656  Record.push_back(D->SelLocsKind);
657  unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
658  SourceLocation *SelLocs = D->getStoredSelLocs();
659  Record.push_back(NumStoredSelLocs);
660  for (unsigned i = 0; i != NumStoredSelLocs; ++i)
661  Record.AddSourceLocation(SelLocs[i]);
662 
664 }
665 
667  VisitTypedefNameDecl(D);
668  Record.push_back(D->Variance);
669  Record.push_back(D->Index);
670  Record.AddSourceLocation(D->VarianceLoc);
671  Record.AddSourceLocation(D->ColonLoc);
672 
674 }
675 
677  VisitNamedDecl(D);
678  Record.AddSourceLocation(D->getAtStartLoc());
679  Record.AddSourceRange(D->getAtEndRange());
680  // Abstract class (no need to define a stable serialization::DECL code).
681 }
682 
684  VisitRedeclarable(D);
685  VisitObjCContainerDecl(D);
686  Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
687  AddObjCTypeParamList(D->TypeParamList);
688 
689  Record.push_back(D->isThisDeclarationADefinition());
690  if (D->isThisDeclarationADefinition()) {
691  // Write the DefinitionData
692  ObjCInterfaceDecl::DefinitionData &Data = D->data();
693 
694  Record.AddTypeSourceInfo(D->getSuperClassTInfo());
695  Record.AddSourceLocation(D->getEndOfDefinitionLoc());
696  Record.push_back(Data.HasDesignatedInitializers);
697 
698  // Write out the protocols that are directly referenced by the @interface.
699  Record.push_back(Data.ReferencedProtocols.size());
700  for (const auto *P : D->protocols())
701  Record.AddDeclRef(P);
702  for (const auto &PL : D->protocol_locs())
703  Record.AddSourceLocation(PL);
704 
705  // Write out the protocols that are transitively referenced.
706  Record.push_back(Data.AllReferencedProtocols.size());
708  P = Data.AllReferencedProtocols.begin(),
709  PEnd = Data.AllReferencedProtocols.end();
710  P != PEnd; ++P)
711  Record.AddDeclRef(*P);
712 
713 
714  if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
715  // Ensure that we write out the set of categories for this class.
716  Writer.ObjCClassesWithCategories.insert(D);
717 
718  // Make sure that the categories get serialized.
719  for (; Cat; Cat = Cat->getNextClassCategoryRaw())
720  (void)Writer.GetDeclRef(Cat);
721  }
722  }
723 
725 }
726 
728  VisitFieldDecl(D);
729  // FIXME: stable encoding for @public/@private/@protected/@package
730  Record.push_back(D->getAccessControl());
731  Record.push_back(D->getSynthesize());
732 
733  if (D->getDeclContext() == D->getLexicalDeclContext() &&
734  !D->hasAttrs() &&
735  !D->isImplicit() &&
736  !D->isUsed(false) &&
737  !D->isInvalidDecl() &&
738  !D->isReferenced() &&
739  !D->isModulePrivate() &&
740  !D->getBitWidth() &&
741  !D->hasExtInfo() &&
742  D->getDeclName())
743  AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
744 
746 }
747 
749  VisitRedeclarable(D);
750  VisitObjCContainerDecl(D);
751 
752  Record.push_back(D->isThisDeclarationADefinition());
753  if (D->isThisDeclarationADefinition()) {
754  Record.push_back(D->protocol_size());
755  for (const auto *I : D->protocols())
756  Record.AddDeclRef(I);
757  for (const auto &PL : D->protocol_locs())
758  Record.AddSourceLocation(PL);
759  }
760 
762 }
763 
765  VisitFieldDecl(D);
767 }
768 
770  VisitObjCContainerDecl(D);
771  Record.AddSourceLocation(D->getCategoryNameLoc());
772  Record.AddSourceLocation(D->getIvarLBraceLoc());
773  Record.AddSourceLocation(D->getIvarRBraceLoc());
774  Record.AddDeclRef(D->getClassInterface());
775  AddObjCTypeParamList(D->TypeParamList);
776  Record.push_back(D->protocol_size());
777  for (const auto *I : D->protocols())
778  Record.AddDeclRef(I);
779  for (const auto &PL : D->protocol_locs())
780  Record.AddSourceLocation(PL);
782 }
783 
785  VisitNamedDecl(D);
786  Record.AddDeclRef(D->getClassInterface());
788 }
789 
791  VisitNamedDecl(D);
792  Record.AddSourceLocation(D->getAtLoc());
793  Record.AddSourceLocation(D->getLParenLoc());
794  Record.AddTypeRef(D->getType());
795  Record.AddTypeSourceInfo(D->getTypeSourceInfo());
796  // FIXME: stable encoding
797  Record.push_back((unsigned)D->getPropertyAttributes());
798  Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
799  // FIXME: stable encoding
800  Record.push_back((unsigned)D->getPropertyImplementation());
801  Record.AddDeclarationName(D->getGetterName());
802  Record.AddSourceLocation(D->getGetterNameLoc());
803  Record.AddDeclarationName(D->getSetterName());
804  Record.AddSourceLocation(D->getSetterNameLoc());
805  Record.AddDeclRef(D->getGetterMethodDecl());
806  Record.AddDeclRef(D->getSetterMethodDecl());
807  Record.AddDeclRef(D->getPropertyIvarDecl());
809 }
810 
812  VisitObjCContainerDecl(D);
813  Record.AddDeclRef(D->getClassInterface());
814  // Abstract class (no need to define a stable serialization::DECL code).
815 }
816 
818  VisitObjCImplDecl(D);
819  Record.AddSourceLocation(D->getCategoryNameLoc());
821 }
822 
824  VisitObjCImplDecl(D);
825  Record.AddDeclRef(D->getSuperClass());
826  Record.AddSourceLocation(D->getSuperClassLoc());
827  Record.AddSourceLocation(D->getIvarLBraceLoc());
828  Record.AddSourceLocation(D->getIvarRBraceLoc());
829  Record.push_back(D->hasNonZeroConstructors());
830  Record.push_back(D->hasDestructors());
831  Record.push_back(D->NumIvarInitializers);
832  if (D->NumIvarInitializers)
833  Record.AddCXXCtorInitializers(
834  llvm::makeArrayRef(D->init_begin(), D->init_end()));
836 }
837 
839  VisitDecl(D);
840  Record.AddSourceLocation(D->getLocStart());
841  Record.AddDeclRef(D->getPropertyDecl());
842  Record.AddDeclRef(D->getPropertyIvarDecl());
843  Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
844  Record.AddStmt(D->getGetterCXXConstructor());
845  Record.AddStmt(D->getSetterCXXAssignment());
847 }
848 
850  VisitDeclaratorDecl(D);
851  Record.push_back(D->isMutable());
852  if (D->InitStorage.getInt() == FieldDecl::ISK_BitWidthOrNothing &&
853  D->InitStorage.getPointer() == nullptr) {
854  Record.push_back(0);
855  } else if (D->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
856  Record.push_back(D->InitStorage.getInt() + 1);
857  Record.AddTypeRef(
858  QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0));
859  } else {
860  Record.push_back(D->InitStorage.getInt() + 1);
861  Record.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer()));
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->hasExtInfo() &&
879  D->getDeclName())
880  AbbrevToUse = Writer.getDeclFieldAbbrev();
881 
883 }
884 
886  VisitDeclaratorDecl(D);
887  Record.AddIdentifierRef(D->getGetterId());
888  Record.AddIdentifierRef(D->getSetterId());
890 }
891 
893  VisitValueDecl(D);
894  Record.push_back(D->getChainingSize());
895 
896  for (const auto *P : D->chain())
897  Record.AddDeclRef(P);
899 }
900 
902  VisitRedeclarable(D);
903  VisitDeclaratorDecl(D);
904  Record.push_back(D->getStorageClass());
905  Record.push_back(D->getTSCSpec());
906  Record.push_back(D->getInitStyle());
907  if (!isa<ParmVarDecl>(D)) {
908  Record.push_back(D->isThisDeclarationADemotedDefinition());
909  Record.push_back(D->isExceptionVariable());
910  Record.push_back(D->isNRVOVariable());
911  Record.push_back(D->isCXXForRangeDecl());
912  Record.push_back(D->isARCPseudoStrong());
913  Record.push_back(D->isInline());
914  Record.push_back(D->isInlineSpecified());
915  Record.push_back(D->isConstexpr());
916  Record.push_back(D->isInitCapture());
917  Record.push_back(D->isPreviousDeclInSameBlockScope());
918  if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
919  Record.push_back(static_cast<unsigned>(IPD->getParameterKind()));
920  else
921  Record.push_back(0);
922  }
923  Record.push_back(D->getLinkageInternal());
924 
925  if (D->getInit()) {
926  Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2));
927  Record.AddStmt(D->getInit());
928  } else {
929  Record.push_back(0);
930  }
931 
932  enum {
933  VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
934  };
935  if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
936  Record.push_back(VarTemplate);
937  Record.AddDeclRef(TemplD);
938  } else if (MemberSpecializationInfo *SpecInfo
940  Record.push_back(StaticDataMemberSpecialization);
941  Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
942  Record.push_back(SpecInfo->getTemplateSpecializationKind());
943  Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
944  } else {
945  Record.push_back(VarNotTemplate);
946  }
947 
948  if (D->getDeclContext() == D->getLexicalDeclContext() &&
949  !D->hasAttrs() &&
950  !D->isImplicit() &&
951  !D->isUsed(false) &&
952  !D->isInvalidDecl() &&
953  !D->isReferenced() &&
955  D->getAccess() == AS_none &&
956  !D->isModulePrivate() &&
959  !D->hasExtInfo() &&
960  D->getFirstDecl() == D->getMostRecentDecl() &&
961  D->getKind() == Decl::Var &&
962  !D->isInline() &&
963  !D->isConstexpr() &&
964  !D->isInitCapture() &&
967  AbbrevToUse = Writer.getDeclVarAbbrev();
968 
970 }
971 
973  VisitVarDecl(D);
975 }
976 
978  VisitVarDecl(D);
979  Record.push_back(D->isObjCMethodParameter());
980  Record.push_back(D->getFunctionScopeDepth());
981  Record.push_back(D->getFunctionScopeIndex());
982  Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding
983  Record.push_back(D->isKNRPromoted());
984  Record.push_back(D->hasInheritedDefaultArg());
985  Record.push_back(D->hasUninstantiatedDefaultArg());
987  Record.AddStmt(D->getUninstantiatedDefaultArg());
989 
990  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
991 
992  // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
993  // we dynamically check for the properties that we optimize for, but don't
994  // know are true of all PARM_VAR_DECLs.
995  if (D->getDeclContext() == D->getLexicalDeclContext() &&
996  !D->hasAttrs() &&
997  !D->hasExtInfo() &&
998  !D->isImplicit() &&
999  !D->isUsed(false) &&
1000  !D->isInvalidDecl() &&
1001  !D->isReferenced() &&
1002  D->getAccess() == AS_none &&
1003  !D->isModulePrivate() &&
1004  D->getStorageClass() == 0 &&
1005  D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1006  D->getFunctionScopeDepth() == 0 &&
1007  D->getObjCDeclQualifier() == 0 &&
1008  !D->isKNRPromoted() &&
1009  !D->hasInheritedDefaultArg() &&
1010  D->getInit() == nullptr &&
1011  !D->hasUninstantiatedDefaultArg()) // No default expr.
1012  AbbrevToUse = Writer.getDeclParmVarAbbrev();
1013 
1014  // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1015  // just us assuming it.
1016  assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1018  && "PARM_VAR_DECL can't be demoted definition.");
1019  assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1020  assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1021  assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1022  assert(!D->isStaticDataMember() &&
1023  "PARM_VAR_DECL can't be static data member");
1024 }
1025 
1027  // Record the number of bindings first to simplify deserialization.
1028  Record.push_back(D->bindings().size());
1029 
1030  VisitVarDecl(D);
1031  for (auto *B : D->bindings())
1032  Record.AddDeclRef(B);
1034 }
1035 
1037  VisitValueDecl(D);
1038  Record.AddStmt(D->getBinding());
1040 }
1041 
1043  VisitDecl(D);
1044  Record.AddStmt(D->getAsmString());
1045  Record.AddSourceLocation(D->getRParenLoc());
1047 }
1048 
1050  VisitDecl(D);
1052 }
1053 
1055  VisitDecl(D);
1056  Record.AddStmt(D->getBody());
1057  Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1058  Record.push_back(D->param_size());
1059  for (ParmVarDecl *P : D->parameters())
1060  Record.AddDeclRef(P);
1061  Record.push_back(D->isVariadic());
1062  Record.push_back(D->blockMissingReturnType());
1063  Record.push_back(D->isConversionFromLambda());
1064  Record.push_back(D->capturesCXXThis());
1065  Record.push_back(D->getNumCaptures());
1066  for (const auto &capture : D->captures()) {
1067  Record.AddDeclRef(capture.getVariable());
1068 
1069  unsigned flags = 0;
1070  if (capture.isByRef()) flags |= 1;
1071  if (capture.isNested()) flags |= 2;
1072  if (capture.hasCopyExpr()) flags |= 4;
1073  Record.push_back(flags);
1074 
1075  if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1076  }
1077 
1079 }
1080 
1082  Record.push_back(CD->getNumParams());
1083  VisitDecl(CD);
1084  Record.push_back(CD->getContextParamPosition());
1085  Record.push_back(CD->isNothrow() ? 1 : 0);
1086  // Body is stored by VisitCapturedStmt.
1087  for (unsigned I = 0; I < CD->getNumParams(); ++I)
1088  Record.AddDeclRef(CD->getParam(I));
1090 }
1091 
1093  VisitDecl(D);
1094  Record.push_back(D->getLanguage());
1095  Record.AddSourceLocation(D->getExternLoc());
1096  Record.AddSourceLocation(D->getRBraceLoc());
1098 }
1099 
1101  VisitDecl(D);
1102  Record.AddSourceLocation(D->getRBraceLoc());
1104 }
1105 
1107  VisitNamedDecl(D);
1108  Record.AddSourceLocation(D->getLocStart());
1110 }
1111 
1112 
1114  VisitRedeclarable(D);
1115  VisitNamedDecl(D);
1116  Record.push_back(D->isInline());
1117  Record.AddSourceLocation(D->getLocStart());
1118  Record.AddSourceLocation(D->getRBraceLoc());
1119 
1120  if (D->isOriginalNamespace())
1121  Record.AddDeclRef(D->getAnonymousNamespace());
1123 
1124  if (Writer.hasChain() && D->isAnonymousNamespace() &&
1125  D == D->getMostRecentDecl()) {
1126  // This is a most recent reopening of the anonymous namespace. If its parent
1127  // is in a previous PCH (or is the TU), mark that parent for update, because
1128  // the original namespace always points to the latest re-opening of its
1129  // anonymous namespace.
1130  Decl *Parent = cast<Decl>(
1132  if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1133  Writer.DeclUpdates[Parent].push_back(
1134  ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D));
1135  }
1136  }
1137 }
1138 
1140  VisitRedeclarable(D);
1141  VisitNamedDecl(D);
1142  Record.AddSourceLocation(D->getNamespaceLoc());
1143  Record.AddSourceLocation(D->getTargetNameLoc());
1144  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1145  Record.AddDeclRef(D->getNamespace());
1147 }
1148 
1150  VisitNamedDecl(D);
1151  Record.AddSourceLocation(D->getUsingLoc());
1152  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1153  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1154  Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1155  Record.push_back(D->hasTypename());
1156  Record.AddDeclRef(Context.getInstantiatedFromUsingDecl(D));
1158 }
1159 
1161  Record.push_back(D->NumExpansions);
1162  VisitNamedDecl(D);
1163  Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1164  for (auto *E : D->expansions())
1165  Record.AddDeclRef(E);
1167 }
1168 
1170  VisitRedeclarable(D);
1171  VisitNamedDecl(D);
1172  Record.AddDeclRef(D->getTargetDecl());
1173  Record.AddDeclRef(D->UsingOrNextShadow);
1174  Record.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D));
1176 }
1177 
1180  VisitUsingShadowDecl(D);
1181  Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1182  Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1183  Record.push_back(D->IsVirtual);
1185 }
1186 
1188  VisitNamedDecl(D);
1189  Record.AddSourceLocation(D->getUsingLoc());
1190  Record.AddSourceLocation(D->getNamespaceKeyLocation());
1191  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1192  Record.AddDeclRef(D->getNominatedNamespace());
1193  Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1195 }
1196 
1198  VisitValueDecl(D);
1199  Record.AddSourceLocation(D->getUsingLoc());
1200  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1201  Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1202  Record.AddSourceLocation(D->getEllipsisLoc());
1204 }
1205 
1208  VisitTypeDecl(D);
1209  Record.AddSourceLocation(D->getTypenameLoc());
1210  Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1211  Record.AddSourceLocation(D->getEllipsisLoc());
1213 }
1214 
1216  VisitRecordDecl(D);
1217 
1218  enum {
1219  CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1220  };
1221  if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1222  Record.push_back(CXXRecTemplate);
1223  Record.AddDeclRef(TemplD);
1224  } else if (MemberSpecializationInfo *MSInfo
1225  = D->getMemberSpecializationInfo()) {
1226  Record.push_back(CXXRecMemberSpecialization);
1227  Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1228  Record.push_back(MSInfo->getTemplateSpecializationKind());
1229  Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1230  } else {
1231  Record.push_back(CXXRecNotTemplate);
1232  }
1233 
1234  Record.push_back(D->isThisDeclarationADefinition());
1236  Record.AddCXXDefinitionData(D);
1237 
1238  // Store (what we currently believe to be) the key function to avoid
1239  // deserializing every method so we can compute it.
1240  if (D->IsCompleteDefinition)
1241  Record.AddDeclRef(Context.getCurrentKeyFunction(D));
1242 
1244 }
1245 
1247  VisitFunctionDecl(D);
1248  if (D->isCanonicalDecl()) {
1249  Record.push_back(D->size_overridden_methods());
1252  I != E; ++I)
1253  Record.AddDeclRef(*I);
1254  } else {
1255  // We only need to record overridden methods once for the canonical decl.
1256  Record.push_back(0);
1257  }
1258 
1259  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1260  D->getFirstDecl() == D->getMostRecentDecl() &&
1261  !D->isInvalidDecl() &&
1262  !D->hasAttrs() &&
1265  !D->hasExtInfo() &&
1266  !D->hasInheritedPrototype() &&
1267  D->hasWrittenPrototype())
1268  AbbrevToUse = Writer.getDeclCXXMethodAbbrev();
1269 
1271 }
1272 
1274  if (auto Inherited = D->getInheritedConstructor()) {
1275  Record.AddDeclRef(Inherited.getShadowDecl());
1276  Record.AddDeclRef(Inherited.getConstructor());
1278  } else {
1280  }
1281 
1282  VisitCXXMethodDecl(D);
1283 
1284  Code = D->isInheritingConstructor()
1287 }
1288 
1290  VisitCXXMethodDecl(D);
1291 
1292  Record.AddDeclRef(D->getOperatorDelete());
1293 
1295 }
1296 
1298  VisitCXXMethodDecl(D);
1300 }
1301 
1303  VisitDecl(D);
1304  Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1305  ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1306  Record.push_back(!IdentifierLocs.empty());
1307  if (IdentifierLocs.empty()) {
1308  Record.AddSourceLocation(D->getLocEnd());
1309  Record.push_back(1);
1310  } else {
1311  for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1312  Record.AddSourceLocation(IdentifierLocs[I]);
1313  Record.push_back(IdentifierLocs.size());
1314  }
1315  // Note: the number of source locations must always be the last element in
1316  // the record.
1318 }
1319 
1321  VisitDecl(D);
1322  Record.AddSourceLocation(D->getColonLoc());
1324 }
1325 
1327  // Record the number of friend type template parameter lists here
1328  // so as to simplify memory allocation during deserialization.
1329  Record.push_back(D->NumTPLists);
1330  VisitDecl(D);
1331  bool hasFriendDecl = D->Friend.is<NamedDecl*>();
1332  Record.push_back(hasFriendDecl);
1333  if (hasFriendDecl)
1334  Record.AddDeclRef(D->getFriendDecl());
1335  else
1336  Record.AddTypeSourceInfo(D->getFriendType());
1337  for (unsigned i = 0; i < D->NumTPLists; ++i)
1338  Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1339  Record.AddDeclRef(D->getNextFriend());
1340  Record.push_back(D->UnsupportedFriend);
1341  Record.AddSourceLocation(D->FriendLoc);
1343 }
1344 
1346  VisitDecl(D);
1347  Record.push_back(D->getNumTemplateParameters());
1348  for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1349  Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1350  Record.push_back(D->getFriendDecl() != nullptr);
1351  if (D->getFriendDecl())
1352  Record.AddDeclRef(D->getFriendDecl());
1353  else
1354  Record.AddTypeSourceInfo(D->getFriendType());
1355  Record.AddSourceLocation(D->getFriendLoc());
1357 }
1358 
1360  VisitNamedDecl(D);
1361 
1362  Record.AddDeclRef(D->getTemplatedDecl());
1363  Record.AddTemplateParameterList(D->getTemplateParameters());
1364 }
1365 
1367  VisitRedeclarable(D);
1368 
1369  // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1370  // getCommonPtr() can be used while this is still initializing.
1371  if (D->isFirstDecl()) {
1372  // This declaration owns the 'common' pointer, so serialize that data now.
1373  Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1375  Record.push_back(D->isMemberSpecialization());
1376  }
1377 
1378  VisitTemplateDecl(D);
1379  Record.push_back(D->getIdentifierNamespace());
1380 }
1381 
1383  VisitRedeclarableTemplateDecl(D);
1384 
1385  if (D->isFirstDecl())
1386  AddTemplateSpecializations(D);
1388 }
1389 
1392  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1393 
1394  VisitCXXRecordDecl(D);
1395 
1396  llvm::PointerUnion<ClassTemplateDecl *,
1399  if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1400  Record.AddDeclRef(InstFromD);
1401  } else {
1402  Record.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>());
1403  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1404  }
1405 
1406  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1407  Record.AddSourceLocation(D->getPointOfInstantiation());
1408  Record.push_back(D->getSpecializationKind());
1409  Record.push_back(D->isCanonicalDecl());
1410 
1411  if (D->isCanonicalDecl()) {
1412  // When reading, we'll add it to the folding set of the following template.
1413  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1414  }
1415 
1416  // Explicit info.
1417  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1418  if (D->getTypeAsWritten()) {
1419  Record.AddSourceLocation(D->getExternLoc());
1420  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1421  }
1422 
1424 }
1425 
1428  VisitClassTemplateSpecializationDecl(D);
1429 
1430  Record.AddTemplateParameterList(D->getTemplateParameters());
1431  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1432 
1433  // These are read/set from/to the first declaration.
1434  if (D->getPreviousDecl() == nullptr) {
1435  Record.AddDeclRef(D->getInstantiatedFromMember());
1436  Record.push_back(D->isMemberSpecialization());
1437  }
1438 
1440 }
1441 
1443  VisitRedeclarableTemplateDecl(D);
1444 
1445  if (D->isFirstDecl())
1446  AddTemplateSpecializations(D);
1448 }
1449 
1452  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1453 
1454  VisitVarDecl(D);
1455 
1456  llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
1457  InstFrom = D->getSpecializedTemplateOrPartial();
1458  if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
1459  Record.AddDeclRef(InstFromD);
1460  } else {
1461  Record.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>());
1462  Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1463  }
1464 
1465  // Explicit info.
1466  Record.AddTypeSourceInfo(D->getTypeAsWritten());
1467  if (D->getTypeAsWritten()) {
1468  Record.AddSourceLocation(D->getExternLoc());
1469  Record.AddSourceLocation(D->getTemplateKeywordLoc());
1470  }
1471 
1472  Record.AddTemplateArgumentList(&D->getTemplateArgs());
1473  Record.AddSourceLocation(D->getPointOfInstantiation());
1474  Record.push_back(D->getSpecializationKind());
1475  Record.push_back(D->isCanonicalDecl());
1476 
1477  if (D->isCanonicalDecl()) {
1478  // When reading, we'll add it to the folding set of the following template.
1479  Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1480  }
1481 
1483 }
1484 
1487  VisitVarTemplateSpecializationDecl(D);
1488 
1489  Record.AddTemplateParameterList(D->getTemplateParameters());
1490  Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
1491 
1492  // These are read/set from/to the first declaration.
1493  if (D->getPreviousDecl() == nullptr) {
1494  Record.AddDeclRef(D->getInstantiatedFromMember());
1495  Record.push_back(D->isMemberSpecialization());
1496  }
1497 
1499 }
1500 
1503  VisitDecl(D);
1504  Record.AddDeclRef(D->getSpecialization());
1506 }
1507 
1508 
1510  VisitRedeclarableTemplateDecl(D);
1511 
1512  if (D->isFirstDecl())
1513  AddTemplateSpecializations(D);
1515 }
1516 
1518  VisitTypeDecl(D);
1519 
1520  Record.push_back(D->wasDeclaredWithTypename());
1521 
1522  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1524  Record.push_back(OwnsDefaultArg);
1525  if (OwnsDefaultArg)
1526  Record.AddTypeSourceInfo(D->getDefaultArgumentInfo());
1527 
1529 }
1530 
1532  // For an expanded parameter pack, record the number of expansion types here
1533  // so that it's easier for deserialization to allocate the right amount of
1534  // memory.
1535  if (D->isExpandedParameterPack())
1536  Record.push_back(D->getNumExpansionTypes());
1537 
1538  VisitDeclaratorDecl(D);
1539  // TemplateParmPosition.
1540  Record.push_back(D->getDepth());
1541  Record.push_back(D->getPosition());
1542 
1543  if (D->isExpandedParameterPack()) {
1544  for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
1545  Record.AddTypeRef(D->getExpansionType(I));
1546  Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
1547  }
1548 
1550  } else {
1551  // Rest of NonTypeTemplateParmDecl.
1552  Record.push_back(D->isParameterPack());
1553  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1555  Record.push_back(OwnsDefaultArg);
1556  if (OwnsDefaultArg)
1557  Record.AddStmt(D->getDefaultArgument());
1559  }
1560 }
1561 
1563  // For an expanded parameter pack, record the number of expansion types here
1564  // so that it's easier for deserialization to allocate the right amount of
1565  // memory.
1566  if (D->isExpandedParameterPack())
1567  Record.push_back(D->getNumExpansionTemplateParameters());
1568 
1569  VisitTemplateDecl(D);
1570  // TemplateParmPosition.
1571  Record.push_back(D->getDepth());
1572  Record.push_back(D->getPosition());
1573 
1574  if (D->isExpandedParameterPack()) {
1575  for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
1576  I != N; ++I)
1577  Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
1579  } else {
1580  // Rest of TemplateTemplateParmDecl.
1581  Record.push_back(D->isParameterPack());
1582  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1584  Record.push_back(OwnsDefaultArg);
1585  if (OwnsDefaultArg)
1586  Record.AddTemplateArgumentLoc(D->getDefaultArgument());
1588  }
1589 }
1590 
1592  VisitRedeclarableTemplateDecl(D);
1594 }
1595 
1597  VisitDecl(D);
1598  Record.AddStmt(D->getAssertExpr());
1599  Record.push_back(D->isFailed());
1600  Record.AddStmt(D->getMessage());
1601  Record.AddSourceLocation(D->getRParenLoc());
1603 }
1604 
1605 /// \brief Emit the DeclContext part of a declaration context decl.
1607  Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC));
1608  Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC));
1609 }
1610 
1612  assert(IsLocalDecl(D) && "expected a local declaration");
1613 
1614  const Decl *Canon = D->getCanonicalDecl();
1615  if (IsLocalDecl(Canon))
1616  return Canon;
1617 
1618  const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
1619  if (CacheEntry)
1620  return CacheEntry;
1621 
1622  for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
1623  if (IsLocalDecl(Redecl))
1624  D = Redecl;
1625  return CacheEntry = D;
1626 }
1627 
1628 template <typename T>
1630  T *First = D->getFirstDecl();
1631  T *MostRecent = First->getMostRecentDecl();
1632  T *DAsT = static_cast<T *>(D);
1633  if (MostRecent != First) {
1634  assert(isRedeclarableDeclKind(DAsT->getKind()) &&
1635  "Not considered redeclarable?");
1636 
1637  Record.AddDeclRef(First);
1638 
1639  // Write out a list of local redeclarations of this declaration if it's the
1640  // first local declaration in the chain.
1641  const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
1642  if (DAsT == FirstLocal) {
1643  // Emit a list of all imported first declarations so that we can be sure
1644  // that all redeclarations visible to this module are before D in the
1645  // redecl chain.
1646  unsigned I = Record.size();
1647  Record.push_back(0);
1648  if (Writer.Chain)
1649  AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
1650  // This is the number of imported first declarations + 1.
1651  Record[I] = Record.size() - I;
1652 
1653  // Collect the set of local redeclarations of this declaration, from
1654  // newest to oldest.
1655  ASTWriter::RecordData LocalRedecls;
1656  ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
1657  for (const Decl *Prev = FirstLocal->getMostRecentDecl();
1658  Prev != FirstLocal; Prev = Prev->getPreviousDecl())
1659  if (!Prev->isFromASTFile())
1660  LocalRedeclWriter.AddDeclRef(Prev);
1661 
1662  // If we have any redecls, write them now as a separate record preceding
1663  // the declaration itself.
1664  if (LocalRedecls.empty())
1665  Record.push_back(0);
1666  else
1667  Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
1668  } else {
1669  Record.push_back(0);
1670  Record.AddDeclRef(FirstLocal);
1671  }
1672 
1673  // Make sure that we serialize both the previous and the most-recent
1674  // declarations, which (transitively) ensures that all declarations in the
1675  // chain get serialized.
1676  //
1677  // FIXME: This is not correct; when we reach an imported declaration we
1678  // won't emit its previous declaration.
1679  (void)Writer.GetDeclRef(D->getPreviousDecl());
1680  (void)Writer.GetDeclRef(MostRecent);
1681  } else {
1682  // We use the sentinel value 0 to indicate an only declaration.
1683  Record.push_back(0);
1684  }
1685 }
1686 
1688  Record.push_back(D->varlist_size());
1689  VisitDecl(D);
1690  for (auto *I : D->varlists())
1691  Record.AddStmt(I);
1693 }
1694 
1696  VisitValueDecl(D);
1697  Record.AddSourceLocation(D->getLocStart());
1698  Record.AddStmt(D->getCombiner());
1699  Record.AddStmt(D->getInitializer());
1700  Record.AddDeclRef(D->getPrevDeclInScope());
1702 }
1703 
1705  VisitVarDecl(D);
1707 }
1708 
1709 //===----------------------------------------------------------------------===//
1710 // ASTWriter Implementation
1711 //===----------------------------------------------------------------------===//
1712 
1713 void ASTWriter::WriteDeclAbbrevs() {
1714  using namespace llvm;
1715 
1716  std::shared_ptr<BitCodeAbbrev> Abv;
1717 
1718  // Abbreviation for DECL_FIELD
1719  Abv = std::make_shared<BitCodeAbbrev>();
1720  Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
1721  // Decl
1722  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1723  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1724  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1725  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1726  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1727  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1728  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1729  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1730  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1731  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1732  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1733  // NamedDecl
1734  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1735  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1736  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1737  // ValueDecl
1738  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1739  // DeclaratorDecl
1740  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1741  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1742  // FieldDecl
1743  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1744  Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth
1745  // Type Source Info
1746  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1747  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1748  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1749  DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
1750 
1751  // Abbreviation for DECL_OBJC_IVAR
1752  Abv = std::make_shared<BitCodeAbbrev>();
1753  Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
1754  // Decl
1755  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1756  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1757  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1758  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1759  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1760  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1761  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1762  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1763  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1764  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1765  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1766  // NamedDecl
1767  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1768  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1769  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1770  // ValueDecl
1771  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1772  // DeclaratorDecl
1773  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1774  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1775  // FieldDecl
1776  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1777  Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth
1778  // ObjC Ivar
1779  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
1780  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
1781  // Type Source Info
1782  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1783  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1784  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1785  DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1786 
1787  // Abbreviation for DECL_ENUM
1788  Abv = std::make_shared<BitCodeAbbrev>();
1789  Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
1790  // Redeclarable
1791  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1792  // Decl
1793  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1794  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1795  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1796  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1797  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1798  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1799  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1800  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1801  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1802  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1803  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1804  // NamedDecl
1805  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1806  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1807  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1808  // TypeDecl
1809  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1810  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1811  // TagDecl
1812  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1813  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1814  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1815  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1816  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1817  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1818  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1819  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1820  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1821  // EnumDecl
1822  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
1823  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
1824  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
1825  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumPositiveBits
1826  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumNegativeBits
1827  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScoped
1828  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScopedUsingClassTag
1829  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isFixed
1830  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
1831  // DC
1832  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1833  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1834  DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
1835 
1836  // Abbreviation for DECL_RECORD
1837  Abv = std::make_shared<BitCodeAbbrev>();
1838  Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
1839  // Redeclarable
1840  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1841  // Decl
1842  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1843  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1844  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1845  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1846  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1847  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1848  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1849  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1850  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1851  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1852  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1853  // NamedDecl
1854  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1855  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1856  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1857  // TypeDecl
1858  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1859  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1860  // TagDecl
1861  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1862  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1863  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1864  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1865  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1866  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1867  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1868  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1869  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1870  // RecordDecl
1871  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember
1872  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
1873  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
1874  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
1875  // DC
1876  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1877  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1878  DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
1879 
1880  // Abbreviation for DECL_PARM_VAR
1881  Abv = std::make_shared<BitCodeAbbrev>();
1882  Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
1883  // Redeclarable
1884  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1885  // Decl
1886  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1887  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1888  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1889  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1890  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1891  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1892  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1893  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1894  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1895  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1896  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1897  // NamedDecl
1898  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1899  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1900  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1901  // ValueDecl
1902  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1903  // DeclaratorDecl
1904  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1905  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1906  // VarDecl
1907  Abv->Add(BitCodeAbbrevOp(0)); // SClass
1908  Abv->Add(BitCodeAbbrevOp(0)); // TSCSpec
1909  Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
1910  Abv->Add(BitCodeAbbrevOp(0)); // Linkage
1911  Abv->Add(BitCodeAbbrevOp(0)); // HasInit
1912  Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo
1913  // ParmVarDecl
1914  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsObjCMethodParameter
1915  Abv->Add(BitCodeAbbrevOp(0)); // ScopeDepth
1916  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
1917  Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier
1918  Abv->Add(BitCodeAbbrevOp(0)); // KNRPromoted
1919  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg
1920  Abv->Add(BitCodeAbbrevOp(0)); // HasUninstantiatedDefaultArg
1921  // Type Source Info
1922  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1923  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1924  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1925  DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
1926 
1927  // Abbreviation for DECL_TYPEDEF
1928  Abv = std::make_shared<BitCodeAbbrev>();
1929  Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
1930  // Redeclarable
1931  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1932  // Decl
1933  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1934  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1935  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1936  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1937  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1938  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isUsed
1939  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isReferenced
1940  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1941  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // C++ AccessSpecifier
1942  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1943  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1944  // NamedDecl
1945  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1946  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1947  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1948  // TypeDecl
1949  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1950  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1951  // TypedefDecl
1952  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1953  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1954  DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
1955 
1956  // Abbreviation for DECL_VAR
1957  Abv = std::make_shared<BitCodeAbbrev>();
1958  Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
1959  // Redeclarable
1960  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1961  // Decl
1962  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1963  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1964  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1965  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1966  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1967  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1968  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1969  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1970  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1971  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1972  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1973  // NamedDecl
1974  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1975  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1976  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1977  // ValueDecl
1978  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1979  // DeclaratorDecl
1980  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1981  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1982  // VarDecl
1983  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
1984  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
1985  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
1986  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
1987  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
1988  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
1989  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
1990  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
1991  Abv->Add(BitCodeAbbrevOp(0)); // isInline
1992  Abv->Add(BitCodeAbbrevOp(0)); // isInlineSpecified
1993  Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
1994  Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
1995  Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
1996  Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind
1997  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
1998  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
1999  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
2000  // Type Source Info
2001  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2002  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2003  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2004  DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2005 
2006  // Abbreviation for DECL_CXX_METHOD
2007  Abv = std::make_shared<BitCodeAbbrev>();
2008  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD));
2009  // RedeclarableDecl
2010  Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2011  // Decl
2012  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2013  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
2014  Abv->Add(BitCodeAbbrevOp(0)); // Invalid
2015  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
2016  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Implicit
2017  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Used
2018  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Referenced
2019  Abv->Add(BitCodeAbbrevOp(0)); // InObjCContainer
2020  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Access
2021  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModulePrivate
2022  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2023  // NamedDecl
2024  Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2025  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2026  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2027  // ValueDecl
2028  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2029  // DeclaratorDecl
2030  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2031  Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2032  // FunctionDecl
2033  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2034  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass
2035  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline
2036  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified
2037  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitSpecified
2038  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten
2039  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure
2040  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto
2041  Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto
2042  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted
2043  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial
2044  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
2045  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
2046  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
2047  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
2048  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry
2049  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
2050  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed
2051  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
2052  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2053  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind
2054  // This Array slurps the rest of the record. Fortunately we want to encode
2055  // (nearly) all the remaining (variable number of) fields in the same way.
2056  //
2057  // This is the function template information if any, then
2058  // NumParams and Params[] from FunctionDecl, and
2059  // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2060  //
2061  // Add an AbbrevOp for 'size then elements' and use it here.
2062  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2063  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2064  DeclCXXMethodAbbrev = Stream.EmitAbbrev(std::move(Abv));
2065 
2066  // Abbreviation for EXPR_DECL_REF
2067  Abv = std::make_shared<BitCodeAbbrev>();
2068  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2069  //Stmt
2070  //Expr
2071  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2072  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2073  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2074  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2075  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2076  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2077  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2078  //DeclRefExpr
2079  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HasQualifier
2080  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //GetDeclFound
2081  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ExplicitTemplateArgs
2082  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HadMultipleCandidates
2083  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2084  1)); // RefersToEnclosingVariableOrCapture
2085  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2086  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2087  DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2088 
2089  // Abbreviation for EXPR_INTEGER_LITERAL
2090  Abv = std::make_shared<BitCodeAbbrev>();
2091  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2092  //Stmt
2093  //Expr
2094  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2095  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2096  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2097  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2098  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2099  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2100  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2101  //Integer Literal
2102  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2103  Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2104  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2105  IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2106 
2107  // Abbreviation for EXPR_CHARACTER_LITERAL
2108  Abv = std::make_shared<BitCodeAbbrev>();
2109  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2110  //Stmt
2111  //Expr
2112  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2113  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2114  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2115  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2116  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2117  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2118  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2119  //Character Literal
2120  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2121  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2122  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2123  CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2124 
2125  // Abbreviation for EXPR_IMPLICIT_CAST
2126  Abv = std::make_shared<BitCodeAbbrev>();
2127  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2128  // Stmt
2129  // Expr
2130  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2131  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2132  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2133  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2134  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2135  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2136  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2137  // CastExpr
2138  Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2139  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind
2140  // ImplicitCastExpr
2141  ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2142 
2143  Abv = std::make_shared<BitCodeAbbrev>();
2144  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2145  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2146  DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2147 
2148  Abv = std::make_shared<BitCodeAbbrev>();
2149  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2150  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2151  DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2152 }
2153 
2154 /// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2155 /// consumers of the AST.
2156 ///
2157 /// Such decls will always be deserialized from the AST file, so we would like
2158 /// this to be as restrictive as possible. Currently the predicate is driven by
2159 /// code generation requirements, if other clients have a different notion of
2160 /// what is "required" then we may have to consider an alternate scheme where
2161 /// clients can iterate over the top-level decls and get information on them,
2162 /// without necessary deserializing them. We could explicitly require such
2163 /// clients to use a separate API call to "realize" the decl. This should be
2164 /// relatively painless since they would presumably only do it for top-level
2165 /// decls.
2166 static bool isRequiredDecl(const Decl *D, ASTContext &Context,
2167  bool WritingModule) {
2168  // An ObjCMethodDecl is never considered as "required" because its
2169  // implementation container always is.
2170 
2171  // File scoped assembly or obj-c or OMP declare target implementation must be
2172  // seen.
2173  if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D) ||
2174  D->hasAttr<OMPDeclareTargetDeclAttr>())
2175  return true;
2176 
2177  if (WritingModule && (isa<VarDecl>(D) || isa<ImportDecl>(D))) {
2178  // These declarations are part of the module initializer, and are emitted
2179  // if and when the module is imported, rather than being emitted eagerly.
2180  return false;
2181  }
2182 
2183  return Context.DeclMustBeEmitted(D);
2184 }
2185 
2186 void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
2187  // Determine the ID for this declaration.
2189  assert(!D->isFromASTFile() && "should not be emitting imported decl");
2190  serialization::DeclID &IDR = DeclIDs[D];
2191  if (IDR == 0)
2192  IDR = NextDeclID++;
2193 
2194  ID = IDR;
2195 
2196  assert(ID >= FirstDeclID && "invalid decl ID");
2197 
2198  RecordData Record;
2199  ASTDeclWriter W(*this, Context, Record);
2200 
2201  // Build a record for this declaration
2202  W.Visit(D);
2203 
2204  // Emit this declaration to the bitstream.
2205  uint64_t Offset = W.Emit(D);
2206 
2207  // Record the offset for this declaration
2208  SourceLocation Loc = D->getLocation();
2209  unsigned Index = ID - FirstDeclID;
2210  if (DeclOffsets.size() == Index)
2211  DeclOffsets.push_back(DeclOffset(Loc, Offset));
2212  else if (DeclOffsets.size() < Index) {
2213  // FIXME: Can/should this happen?
2214  DeclOffsets.resize(Index+1);
2215  DeclOffsets[Index].setLocation(Loc);
2216  DeclOffsets[Index].BitOffset = Offset;
2217  } else {
2218  llvm_unreachable("declarations should be emitted in ID order");
2219  }
2220 
2221  SourceManager &SM = Context.getSourceManager();
2222  if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
2223  associateDeclWithFile(D, ID);
2224 
2225  // Note declarations that should be deserialized eagerly so that we can add
2226  // them to a record in the AST file later.
2227  if (isRequiredDecl(D, Context, WritingModule))
2228  EagerlyDeserializedDecls.push_back(ID);
2229 }
2230 
2232  // Switch case IDs are per function body.
2233  Writer->ClearSwitchCaseIDs();
2234 
2235  assert(FD->doesThisDeclarationHaveABody());
2236  bool ModulesCodegen = false;
2237  if (Writer->WritingModule && !FD->isDependentContext()) {
2238  // Under -fmodules-codegen, codegen is performed for all defined functions.
2239  // When building a C++ Modules TS module interface unit, a strong definition
2240  // in the module interface is provided by the compilation of that module
2241  // interface unit, not by its users. (Inline functions are still emitted
2242  // in module users.)
2243  ModulesCodegen =
2244  Writer->Context->getLangOpts().ModulesCodegen ||
2245  (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit &&
2246  Writer->Context->GetGVALinkageForFunction(FD) == GVA_StrongExternal);
2247  }
2248  Record->push_back(ModulesCodegen);
2249  if (ModulesCodegen)
2250  Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));
2251  if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
2252  Record->push_back(CD->getNumCtorInitializers());
2253  if (CD->getNumCtorInitializers())
2254  AddCXXCtorInitializers(
2255  llvm::makeArrayRef(CD->init_begin(), CD->init_end()));
2256  }
2257  AddStmt(FD->getBody());
2258 }
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1163
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1181
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
Definition: DeclTemplate.h:568
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition: DeclFriend.h:114
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1618
void VisitAccessSpecDecl(AccessSpecDecl *D)
protocol_range protocols() const
Definition: DeclObjC.h:2042
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
void VisitStaticAssertDecl(StaticAssertDecl *D)
void VisitCXXMethodDecl(CXXMethodDecl *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:1343
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
Definition: ASTCommon.cpp:235
A (possibly-)qualified type.
Definition: Type.h:616
ArrayRef< Capture > captures() const
Definition: Decl.h:3682
ImplementationControl getImplementationControl() const
Definition: DeclObjC.h:465
unsigned getNumTemplates() const
Returns the number of function templates that this might be a specialization of.
Definition: DeclTemplate.h:690
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2232
bool isVariadic() const
Definition: Decl.h:3633
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void VisitRedeclarable(Redeclarable< T > *D)
void VisitEmptyDecl(EmptyDecl *D)
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)
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1206
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:885
void VisitExportDecl(ExportDecl *D)
CXXMethodDecl * getSpecialization() const
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Definition: DeclCXX.h:3363
bool isMemberSpecialization()
Determines whether this class template partial specialization template was a specialization of a memb...
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition: Decl.h:3288
bool isDefined() const
Definition: DeclObjC.h:426
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:2261
const Expr * getInitExpr() const
Definition: Decl.h:2571
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1452
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Definition: Decl.h:2554
void VisitCXXRecordDecl(CXXRecordDecl *D)
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Definition: Decl.h:2770
Defines the SourceManager interface.
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1218
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1487
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
QualType getUnderlyingType() const
Definition: Decl.h:2727
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:3178
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
An ImplicitCastExpr record.
Definition: ASTBitCodes.h:1313
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1175
Defines the C++ template declaration subclasses.
StringRef P
bool hasFlexibleArrayMember() const
Definition: Decl.h:3406
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:922
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
Definition: Decl.h:3331
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
void VisitTranslationUnitDecl(TranslationUnitDecl *D)
A record that stores the set of declarations that are lexically stored within a given DeclContext...
Definition: ASTBitCodes.h:1110
Represents an empty-declaration.
Definition: Decl.h:3938
ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, ASTWriter::RecordDataImpl &Record)
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1009
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:63
Declaration of a variable template.
const Expr * getInit() const
Definition: Decl.h:1146
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:461
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1079
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: Decl.h:1491
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field)
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
Definition: Decl.h:3242
protocol_range protocols() const
Definition: DeclObjC.h:2263
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:3644
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclBase.h:403
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2329
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
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:780
FunctionTemplateDecl * getTemplate(unsigned I) const
Returns the i'th template candidate.
Definition: DeclTemplate.h:693
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
Represents a #pragma comment line.
Definition: Decl.h:109
A ClassTemplateDecl record.
Definition: ASTBitCodes.h:1165
A PragmaDetectMismatchDecl record.
Definition: ASTBitCodes.h:1216
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1138
void VisitBlockDecl(BlockDecl *D)
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void VisitImplicitParamDecl(ImplicitParamDecl *D)
const Type * getTypeForDecl() const
Definition: DeclObjC.h:1836
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:40
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:758
Expr * getSetterCXXAssignment() const
Definition: DeclObjC.h:2740
Declaration of a redeclarable template.
Definition: DeclTemplate.h:724
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
bool capturesCXXThis() const
Definition: Decl.h:3687
bool isInlineSpecified() const
Definition: Decl.h:1284
An OMPCapturedExprDecl record.
Definition: ASTBitCodes.h:1212
void AddFunctionDefinition(const FunctionDecl *FD)
Add a definition for the given function to the queue of statements to emit.
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:3604
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1130
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2317
AccessSpecifier getAccess() const
Definition: DeclBase.h:451
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1495
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:113
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
Definition: ASTBitCodes.h:1199
void VisitIndirectFieldDecl(IndirectFieldDecl *D)
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition: Decl.cpp:3366
unsigned param_size() const
Definition: DeclObjC.h:348
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:653
unsigned IsExplicitSpecified
Definition: Decl.h:1646
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1183
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1434
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:1063
Provides information about a dependent function-template specialization declaration.
Definition: DeclTemplate.h:659
SourceLocation getSetterNameLoc() const
Definition: DeclObjC.h:869
QualType getType() const
Definition: DeclObjC.h:788
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3032
TypeSourceInfo * getTypeSourceInfo() const
Definition: DeclObjC.h:786
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:108
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
A CXXConstructorDecl record for an inherited constructor.
Definition: ASTBitCodes.h:1152
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3354
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1549
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:80
Represents a class template specialization, which refers to a class template with a given set of temp...
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3282
method_iterator end_overridden_methods() const
Definition: DeclCXX.cpp:1828
StringLiteral * getMessage()
Definition: DeclCXX.h:3599
bool hasAttr() const
Definition: DeclBase.h:521
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:4286
CXXRecordDecl * getPreviousDecl()
Definition: DeclCXX.h:678
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition: DeclCXX.h:2932
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2274
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2366
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Definition: Decl.h:2960
ImplicitParamDecl * getCmdDecl() const
Definition: DeclObjC.h:410
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
StringRef getArg() const
Definition: Decl.h:134
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:392
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition: Decl.h:511
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:770
SourceLocation getGetterNameLoc() const
Definition: DeclObjC.h:862
TagKind getTagKind() const
Definition: Decl.h:3019
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
Definition: Decl.h:1318
void VisitDecompositionDecl(DecompositionDecl *D)
TypeSourceInfo * getFriendType() const
If this friend declaration names a templated type (or a dependent member type of a templated type)...
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:2827
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:3637
void VisitParmVarDecl(ParmVarDecl *D)
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:103
Declaration of a function specialization at template class scope.
unsigned getNumCaptures() const
getNumCaptures - Returns the number of captured variables.
Definition: Decl.h:3678
bool isThisDeclarationADefinition() const
isThisDeclarationADefinition() - Return true if this declaration is a completion definition of the ty...
Definition: Decl.h:2954
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2311
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:947
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1193
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:494
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Represents a C++ using-declaration.
Definition: DeclCXX.h:3183
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:3767
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Definition: DeclTemplate.h:527
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
void VisitLabelDecl(LabelDecl *LD)
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Definition: DeclOpenMP.h:143
bool isInheritingConstructor() const
Determine whether this is an implicit constructor synthesized to model a call to a constructor inheri...
Definition: DeclCXX.h:2517
void VisitObjCProtocolDecl(ObjCProtocolDecl *D)
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
void VisitClassTemplateDecl(ClassTemplateDecl *D)
IdentifierInfo * getSetterId() const
Definition: DeclCXX.h:3762
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:919
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2060
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:537
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:516
void VisitTypedefDecl(TypedefDecl *D)
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1158
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2315
void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D)
SourceLocation getRBraceLoc() const
Definition: Decl.h:559
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
uint32_t Offset
Definition: CacheTokens.cpp:43
void VisitUsingShadowDecl(UsingShadowDecl *D)
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1132
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1134
A DecompositionDecl record.
Definition: ASTBitCodes.h:1093
TypeDecl - Represents a declaration of a type.
Definition: Decl.h:2642
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
Definition: Decl.cpp:2254
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2733
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:587
unsigned getNumTemplateParameters() const
Selector getSetterName() const
Definition: DeclObjC.h:868
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
void VisitBindingDecl(BindingDecl *D)
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition: DeclCXX.h:3359
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1167
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:1985
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
Definition: DeclBase.h:796
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
Definition: Decl.h:1214
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:3701
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.cpp:3193
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3726
Represents an ObjC class declaration.
Definition: DeclObjC.h:1108
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclObjC.cpp:925
Represents a linkage specification.
Definition: DeclCXX.h:2666
detail::InMemoryDirectory::const_iterator I
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:799
A binding in a decomposition declaration.
Definition: DeclCXX.h:3624
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3457
size_t param_size() const
Definition: Decl.h:3659
QualType getType() const
Definition: Decl.h:589
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:841
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2584
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:1053
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition: DeclCXX.h:3213
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
SourceLocation getAtLoc() const
Definition: DeclObjC.h:780
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion: ...
Definition: Decl.h:1508
unsigned getNumParams() const
Definition: Decl.h:3765
SourceRange getAtEndRange() const
Definition: DeclObjC.h:1057
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2645
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3308
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:2126
void VisitObjCContainerDecl(ObjCContainerDecl *D)
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclObjC.h:2699
RecordDecl * getMostRecentDecl()
Definition: Decl.h:3399
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2790
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
bool isConversionFromLambda() const
Definition: Decl.h:3691
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:2666
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:2923
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:636
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1146
unsigned getChainingSize() const
Definition: Decl.h:2619
uint64_t Emit(Decl *D)
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
ASTContext * Context
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclObjC.h:269
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:2392
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition: DeclOpenMP.h:136
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1187
SourceLocation getSuperClassLoc() const
Definition: DeclObjC.h:2579
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1173
const CXXMethodDecl *const * method_iterator
Definition: DeclCXX.h:2008
static bool classofKind(Kind K)
Definition: DeclObjC.h:1920
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1210
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition: DeclCXX.h:2520
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction...
Definition: DeclObjC.h:2547
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition: Decl.cpp:2383
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:4442
const Type * getTypeForDecl() const
Definition: Decl.h:2663
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1703
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3070
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3557
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:580
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1073
bool isModed() const
Definition: Decl.h:2720
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1081
void VisitRecordDecl(RecordDecl *D)
Declaration of a template type parameter.
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
NamedDecl * getFriendDecl() const
If this friend declaration names a templated function (or a member function of a templated type)...
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2711
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:590
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name...
Definition: DeclOpenMP.cpp:76
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Expr * getBitWidth() const
Definition: Decl.h:2448
ArrayRef< NamedDecl * > chain() const
Definition: Decl.h:2613
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:572
void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal)
Add to the record the first declaration from each module file that provides a declaration of D...
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2551
A CXXConstructorDecl record.
Definition: ASTBitCodes.h:1150
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:937
Kind getKind() const
Definition: DeclBase.h:410
void VisitClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl *D)
void VisitTemplateDecl(TemplateDecl *D)
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:216
DeclContext * getDeclContext()
Definition: DeclBase.h:416
void VisitUsingDecl(UsingDecl *D)
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
const char * getDeclKindName() const
Definition: DeclBase.cpp:102
bool isFailed() const
Definition: DeclCXX.h:3602
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1171
ImplicitParamDecl * getSelfDecl() const
Definition: DeclObjC.h:408
unsigned getContextParamPosition() const
Definition: Decl.h:3794
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
EnumDecl * getMostRecentDecl()
Definition: Decl.h:3164
bool isObjCMethodParameter() const
Definition: Decl.h:1477
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1154
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Definition: ASTBitCodes.h:1196
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:849
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3277
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type...
Definition: DeclObjC.h:276
SourceLocation getRParenLoc() const
Definition: Decl.h:3539
bool isInstanceMethod() const
Definition: DeclObjC.h:416
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition: Decl.h:1232
A NamespaceAliasDecl record.
Definition: ASTBitCodes.h:1124
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1294
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:681
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
Definition: ASTWriter.h:877
void AddObjCTypeParamList(ObjCTypeParamList *typeParams)
Add an Objective-C type parameter list to the given record.
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:3644
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:258
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1322
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1089
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition: Decl.h:2807
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition: Decl.cpp:1076
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:1857
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2605
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1057
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition: Decl.h:1940
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Definition: DeclTemplate.h:537
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
const SourceManager & SM
Definition: Format.cpp:1293
void VisitTagDecl(TagDecl *D)
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1204
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1071
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:3050
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
CXXMethodDecl * getMostRecentDecl()
Definition: DeclCXX.h:1991
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition: DeclObjC.h:344
static DeclType * getDecl(EntryType *D)
Definition: DeclTemplate.h:742
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:209
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2512
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
void VisitMSPropertyDecl(MSPropertyDecl *D)
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:1077
void VisitVarTemplateDecl(VarTemplateDecl *D)
AttrVec & getAttrs()
Definition: DeclBase.h:466
void VisitTypeAliasDecl(TypeAliasDecl *D)
void VisitDeclContext(DeclContext *DC)
Emit the DeclContext part of a declaration context decl.
bool isEmbeddedInDeclarator() const
Definition: Decl.h:2975
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:371
Stmt * getBody(const FunctionDecl *&Definition) const
getBody - Retrieve the body (definition) of the function.
Definition: Decl.cpp:2597
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclBase.h:400
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:3894
bool doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
Definition: Decl.h:1882
StringRef getValue() const
Definition: Decl.h:167
const Decl * getFirstLocalDecl(const Decl *D)
Find the first local declaration of a given local redeclarable decl.
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Definition: DeclTemplate.h:614
An UnresolvedUsingValueDecl record.
Definition: ASTBitCodes.h:1136
SourceLocation getExternLoc() const
Definition: DeclCXX.h:2718
IdentifierInfo * getGetterId() const
Definition: DeclCXX.h:3760
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:197
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Definition: DeclTemplate.h:530
Encodes a location in the source.
unsigned protocol_size() const
Definition: DeclObjC.h:2270
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:102
A record that stores the set of declarations that are visible from a given DeclContext.
Definition: ASTBitCodes.h:1118
method_iterator begin_overridden_methods() const
Definition: DeclCXX.cpp:1823
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists...
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:171
void VisitObjCImplDecl(ObjCImplDecl *D)
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2632
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:558
SourceRange getBraceRange() const
Definition: Decl.h:2935
bool isValid() const
Return true if this is a valid SourceLocation object.
const std::string ID
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2816
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:1833
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition: DeclCXX.h:2951
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:58
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:414
bool isVariadic() const
Definition: DeclObjC.h:418
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3400
RedeclarableTemplateDecl::SpecEntryTraits< EntryType >::DeclType * getSpecializationDecl(EntryType &T)
Get the specialization decl from an entry in the specialization list.
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or NULL if this template was ...
Definition: DeclTemplate.h:896
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:793
bool getSynthesize() const
Definition: DeclObjC.h:1912
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1903
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
void VisitUsingPackDecl(UsingPackDecl *D)
bool blockMissingReturnType() const
Definition: Decl.h:3688
C-style initialization with assignment.
Definition: Decl.h:768
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2066
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
A TemplateTypeParmDecl record.
Definition: ASTBitCodes.h:1179
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:943
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2189
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:3873
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2341
bool isPropertyAccessor() const
Definition: DeclObjC.h:423
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition: DeclCXX.h:3430
bool hasVolatileMember() const
Definition: Decl.h:3429
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void VisitCapturedDecl(CapturedDecl *D)
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Definition: DeclObjC.h:2520
ThreadStorageClassSpecifier getTSCSpec() const
Definition: Decl.h:956
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:704
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:67
QualType getReturnType() const
Definition: DeclObjC.h:330
void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D)
A NamespaceDecl record.
Definition: ASTBitCodes.h:1122
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3576
bool hasObjectMember() const
Definition: Decl.h:3426
void VisitPragmaCommentDecl(PragmaCommentDecl *D)
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2420
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
Definition: DeclTemplate.h:707
unsigned varlist_size() const
Definition: DeclOpenMP.h:74
SourceLocation getLParenLoc() const
Definition: DeclObjC.h:783
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:3829
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition: DeclCXX.h:2823
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1357
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1065
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition: Decl.h:1308
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2682
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
Definition: Decl.h:3421
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1156
void VisitFieldDecl(FieldDecl *D)
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
Definition: DeclCXX.h:122
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:2209
void AddTemplateSpecializations(DeclTy *D)
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition: DeclCXX.h:3235
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition: Decl.cpp:3155
void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1215
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
StringRef Name
Definition: USRFinder.cpp:123
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:378
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:847
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:895
QualType getPromotionType() const
getPromotionType - Return the integer type that enumerators should promote to.
Definition: Decl.h:3218
PragmaMSCommentKind getCommentKind() const
Definition: Decl.h:132
bool isInvalidDecl() const
Definition: DeclBase.h:532
void VisitNamedDecl(NamedDecl *D)
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Definition: Decl.h:2594
bool isFreeStanding() const
Definition: Decl.h:2982
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1169
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition: DeclCXX.h:2819
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1047
const llvm::APSInt & getInitVal() const
Definition: Decl.h:2573
A decomposition declaration.
Definition: DeclCXX.h:3672
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
void VisitTypeDecl(TypeDecl *D)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:617
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2707
bool hasWrittenPrototype() const
Definition: Decl.h:1936
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2714
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3497
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
Definition: ASTBitCodes.h:1202
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:537
Selector getGetterName() const
Definition: DeclObjC.h:861
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
Definition: DeclBase.cpp:367
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1140
decltype(T::PartialSpecializations)& getPartialSpecializations(T *Common)
Get the list of partial specializations from a template's common ptr.
size_t param_size() const
Definition: Decl.h:2081
EnumDecl - Represents an enum.
Definition: Decl.h:3102
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Definition: TemplateBase.h:584
bool hasAttrs() const
Definition: DeclBase.h:462
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1481
detail::InMemoryDirectory::const_iterator E
SourceLocation getEndOfDefinitionLoc() const
Definition: DeclObjC.h:1796
void VisitDeclaratorDecl(DeclaratorDecl *D)
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
void VisitEnumDecl(EnumDecl *D)
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition: Decl.h:2966
StringRef getName() const
Definition: Decl.h:166
bool hasInheritedDefaultArg() const
Definition: Decl.h:1562
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1214
void VisitNamespaceDecl(NamespaceDecl *D)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2448
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:875
bool hasNonZeroConstructors() const
Do any of the ivars of this class (not counting its base classes) require construction other than zer...
Definition: DeclObjC.h:2542
void VisitVarDecl(VarDecl *D)
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition: Decl.h:3269
Expr * getUninstantiatedDefaultArg()
Definition: Decl.cpp:2515
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition: DeclFriend.h:121
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
Definition: DeclTemplate.h:635
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:878
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
bool isNothrow() const
Definition: Decl.cpp:4226
Module * getOwningModule() const
Get the module that owns this declaration.
Definition: DeclBase.h:737
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
Definition: Decl.h:3226
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
unsigned getNumTemplateArgs() const
Returns the number of explicit template arguments that were given.
Definition: DeclTemplate.h:704
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1634
SourceLocation getRBraceLoc() const
Definition: DeclCXX.h:2719
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3220
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
Definition: Decl.h:1250
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2255
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1205
unsigned protocol_size() const
Definition: DeclObjC.h:2075
protocol_range protocols() const
Definition: DeclObjC.h:1295
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
void VisitFunctionDecl(FunctionDecl *D)
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition: Decl.h:1065
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition: DeclCXX.h:3529
SourceManager & getSourceManager()
Definition: ASTContext.h:616
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement...
Definition: Decl.h:1260
static bool classofKind(Kind K)
Definition: DeclCXX.h:1836
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
void VisitDecl(Decl *D)
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2702
AccessControl getAccessControl() const
Definition: DeclObjC.h:1905
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:1952
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:1933
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:431
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition: Decl.h:1272
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
Definition: Decl.h:3252
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or NULL if there isn't one...
Represents a C++ struct/union/class.
Definition: DeclCXX.h:267
TypeSourceInfo * getSignatureAsWritten() const
Definition: Decl.h:3641
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:540
An object for streaming information to a record.
Definition: ASTWriter.h:719
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
Definition: Decl.cpp:44
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3533
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1866
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:326
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:595
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:1075
void VisitEnumConstantDecl(EnumConstantDecl *D)
bool isInline() const
Whether this variable is (C++1z) inline.
Definition: Decl.h:1281
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1069
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:615
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1299
void VisitClassScopeFunctionSpecializationDecl(ClassScopeFunctionSpecializationDecl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:410
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:82
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:1039
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1051
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3550
const FunctionDecl * getOperatorDelete() const
Definition: DeclCXX.h:2576
TemplateParameterList * getTemplateParameterList(unsigned i) const
PropertyAttributeKind getPropertyAttributesAsWritten() const
Definition: DeclObjC.h:809
An ExportDecl record.
Definition: ASTBitCodes.h:1142
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2586
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:219
void VisitFriendDecl(FriendDecl *D)
TranslationUnitDecl - The top declaration context.
Definition: Decl.h:80
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:2797
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)
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
Definition: Decl.h:538
NamedDecl * getMostRecentDecl()
Definition: Decl.h:391
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D)
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1090
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1177
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3440
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
Definition: Decl.h:675
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1185
void VisitImportDecl(ImportDecl *D)
varlist_range varlists()
Definition: DeclOpenMP.h:77
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3741
SourceLocation getLocation() const
Definition: DeclBase.h:407
SourceLocation getRBraceLoc() const
Definition: Decl.h:3912
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
Represents a C++ namespace alias.
Definition: DeclCXX.h:2861
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
void VisitFriendTemplateDecl(FriendTemplateDecl *D)
Declaration of a friend template.
Represents C++ using-directive.
Definition: DeclCXX.h:2758
Represents a #pragma detect_mismatch line.
Definition: Decl.h:143
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:2722
void VisitObjCMethodDecl(ObjCMethodDecl *D)
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:39
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2396
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
Definition: DeclBase.h:586
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:939
Source range/offset of a preprocessed entity.
Definition: ASTBitCodes.h:187
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:2978
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:2948
Represents a pack of using declarations that a single using-declarator pack-expanded into...
Definition: DeclCXX.h:3331
void VisitObjCIvarDecl(ObjCIvarDecl *D)
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2616
This is a C++ Modules TS module interface unit.
Definition: Module.h:71
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2431
bool hasInClassInitializer() const
hasInClassInitializer - Determine whether this member has a C++11 in-class initializer.
Definition: Decl.h:2481
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2577
const StringLiteral * getAsmString() const
Definition: Decl.h:3545