clang  3.7.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 
15 #include "ASTCommon.h"
16 #include "clang/AST/DeclCXX.h"
18 #include "clang/AST/DeclTemplate.h"
19 #include "clang/AST/DeclVisitor.h"
20 #include "clang/AST/Expr.h"
23 #include "llvm/ADT/Twine.h"
24 #include "llvm/Bitcode/BitstreamWriter.h"
25 #include "llvm/Support/ErrorHandling.h"
26 using namespace clang;
27 using namespace serialization;
28 
29 //===----------------------------------------------------------------------===//
30 // Declaration serialization
31 //===----------------------------------------------------------------------===//
32 
33 namespace clang {
34  class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> {
35 
36  ASTWriter &Writer;
39  RecordData &Record;
40 
41  public:
43  unsigned AbbrevToUse;
44 
46  : Writer(Writer), Context(Context), Record(Record) {
47  }
48 
49  void Visit(Decl *D);
50 
51  void VisitDecl(Decl *D);
52  void VisitTranslationUnitDecl(TranslationUnitDecl *D);
53  void VisitNamedDecl(NamedDecl *D);
54  void VisitLabelDecl(LabelDecl *LD);
55  void VisitNamespaceDecl(NamespaceDecl *D);
56  void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
57  void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
58  void VisitTypeDecl(TypeDecl *D);
59  void VisitTypedefNameDecl(TypedefNameDecl *D);
60  void VisitTypedefDecl(TypedefDecl *D);
61  void VisitTypeAliasDecl(TypeAliasDecl *D);
62  void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
63  void VisitTagDecl(TagDecl *D);
64  void VisitEnumDecl(EnumDecl *D);
65  void VisitRecordDecl(RecordDecl *D);
66  void VisitCXXRecordDecl(CXXRecordDecl *D);
67  void VisitClassTemplateSpecializationDecl(
69  void VisitClassTemplatePartialSpecializationDecl(
71  void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D);
72  void VisitVarTemplatePartialSpecializationDecl(
74  void VisitClassScopeFunctionSpecializationDecl(
76  void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
77  void VisitValueDecl(ValueDecl *D);
78  void VisitEnumConstantDecl(EnumConstantDecl *D);
79  void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
80  void VisitDeclaratorDecl(DeclaratorDecl *D);
81  void VisitFunctionDecl(FunctionDecl *D);
82  void VisitCXXMethodDecl(CXXMethodDecl *D);
83  void VisitCXXConstructorDecl(CXXConstructorDecl *D);
84  void VisitCXXDestructorDecl(CXXDestructorDecl *D);
85  void VisitCXXConversionDecl(CXXConversionDecl *D);
86  void VisitFieldDecl(FieldDecl *D);
87  void VisitMSPropertyDecl(MSPropertyDecl *D);
88  void VisitIndirectFieldDecl(IndirectFieldDecl *D);
89  void VisitVarDecl(VarDecl *D);
90  void VisitImplicitParamDecl(ImplicitParamDecl *D);
91  void VisitParmVarDecl(ParmVarDecl *D);
92  void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
93  void VisitTemplateDecl(TemplateDecl *D);
94  void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
95  void VisitClassTemplateDecl(ClassTemplateDecl *D);
96  void VisitVarTemplateDecl(VarTemplateDecl *D);
97  void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
98  void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
99  void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
100  void VisitUsingDecl(UsingDecl *D);
101  void VisitUsingShadowDecl(UsingShadowDecl *D);
102  void VisitLinkageSpecDecl(LinkageSpecDecl *D);
103  void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
104  void VisitImportDecl(ImportDecl *D);
105  void VisitAccessSpecDecl(AccessSpecDecl *D);
106  void VisitFriendDecl(FriendDecl *D);
107  void VisitFriendTemplateDecl(FriendTemplateDecl *D);
108  void VisitStaticAssertDecl(StaticAssertDecl *D);
109  void VisitBlockDecl(BlockDecl *D);
110  void VisitCapturedDecl(CapturedDecl *D);
111  void VisitEmptyDecl(EmptyDecl *D);
112 
113  void VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
114  uint64_t VisibleOffset);
115  template <typename T> void VisitRedeclarable(Redeclarable<T> *D);
116 
117 
118  // FIXME: Put in the same order is DeclNodes.td?
119  void VisitObjCMethodDecl(ObjCMethodDecl *D);
120  void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D);
121  void VisitObjCContainerDecl(ObjCContainerDecl *D);
122  void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
123  void VisitObjCIvarDecl(ObjCIvarDecl *D);
124  void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
125  void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D);
126  void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
127  void VisitObjCImplDecl(ObjCImplDecl *D);
128  void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
129  void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
130  void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
131  void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
132  void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
133  void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
134 
135  /// Add an Objective-C type parameter list to the given record.
137  // Empty type parameter list.
138  if (!typeParams) {
139  Record.push_back(0);
140  return;
141  }
142 
143  Record.push_back(typeParams->size());
144  for (auto typeParam : *typeParams) {
145  Writer.AddDeclRef(typeParam, Record);
146  }
147  Writer.AddSourceLocation(typeParams->getLAngleLoc(), Record);
148  Writer.AddSourceLocation(typeParams->getRAngleLoc(), Record);
149  }
150 
152  assert(FD->doesThisDeclarationHaveABody());
153  if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
154  Record.push_back(CD->NumCtorInitializers);
155  if (CD->NumCtorInitializers)
156  Writer.AddCXXCtorInitializersRef(
157  llvm::makeArrayRef(CD->init_begin(), CD->init_end()), Record);
158  }
159  Writer.AddStmt(FD->getBody());
160  }
161 
162  /// Get the specialization decl from an entry in the specialization list.
163  template <typename EntryType>
165  getSpecializationDecl(EntryType &T) {
167  }
168 
169  /// Get the list of partial specializations from a template's common ptr.
170  template<typename T>
171  decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) {
172  return Common->PartialSpecializations;
173  }
175  return None;
176  }
177 
178  template<typename Decl>
180  auto *Common = D->getCommonPtr();
181 
182  // If we have any lazy specializations, and the external AST source is
183  // our chained AST reader, we can just write out the DeclIDs. Otherwise,
184  // we need to resolve them to actual declarations.
185  if (Writer.Chain != Writer.Context->getExternalSource() &&
186  Common->LazySpecializations) {
187  D->LoadLazySpecializations();
188  assert(!Common->LazySpecializations);
189  }
190 
191  auto &Specializations = Common->Specializations;
192  auto &&PartialSpecializations = getPartialSpecializations(Common);
193  ArrayRef<DeclID> LazySpecializations;
194  if (auto *LS = Common->LazySpecializations)
195  LazySpecializations = ArrayRef<DeclID>(LS + 1, LS + 1 + LS[0]);
196 
197  Record.push_back(Specializations.size() +
198  PartialSpecializations.size() +
199  LazySpecializations.size());
200  for (auto &Entry : Specializations) {
201  auto *D = getSpecializationDecl(Entry);
202  assert(D->isCanonicalDecl() && "non-canonical decl in set");
203  Writer.AddDeclRef(D, Record);
204  }
205  for (auto &Entry : PartialSpecializations) {
206  auto *D = getSpecializationDecl(Entry);
207  assert(D->isCanonicalDecl() && "non-canonical decl in set");
208  Writer.AddDeclRef(D, Record);
209  }
210  Record.append(LazySpecializations.begin(), LazySpecializations.end());
211  }
212  };
213 }
214 
217 
218  // Source locations require array (variable-length) abbreviations. The
219  // abbreviation infrastructure requires that arrays are encoded last, so
220  // we handle it here in the case of those classes derived from DeclaratorDecl
221  if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)){
222  Writer.AddTypeSourceInfo(DD->getTypeSourceInfo(), Record);
223  }
224 
225  // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
226  // have been written. We want it last because we will not read it back when
227  // retrieving it from the AST, we'll just lazily set the offset.
228  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
229  Record.push_back(FD->doesThisDeclarationHaveABody());
230  if (FD->doesThisDeclarationHaveABody())
231  AddFunctionDefinition(FD);
232  }
233 }
234 
236  Writer.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()), Record);
237  Writer.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()), Record);
238  Record.push_back(D->isInvalidDecl());
239  Record.push_back(D->hasAttrs());
240  if (D->hasAttrs())
241  Writer.WriteAttributes(llvm::makeArrayRef(D->getAttrs().begin(),
242  D->getAttrs().size()), Record);
243  Record.push_back(D->isImplicit());
244  Record.push_back(D->isUsed(false));
245  Record.push_back(D->isReferenced());
246  Record.push_back(D->isTopLevelDeclInObjCContainer());
247  Record.push_back(D->getAccess());
248  Record.push_back(D->isModulePrivate());
249  Record.push_back(Writer.inferSubmoduleIDFromLocation(D->getLocation()));
250 
251  // If this declaration injected a name into a context different from its
252  // lexical context, and that context is an imported namespace, we need to
253  // update its visible declarations to include this name.
254  //
255  // This happens when we instantiate a class with a friend declaration or a
256  // function with a local extern declaration, for instance.
257  //
258  // FIXME: Can we handle this in AddedVisibleDecl instead?
259  if (D->isOutOfLine()) {
260  auto *DC = D->getDeclContext();
261  while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
262  if (!NS->isFromASTFile())
263  break;
264  Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
265  if (!NS->isInlineNamespace())
266  break;
267  DC = NS->getParent();
268  }
269  }
270 }
271 
273  llvm_unreachable("Translation units aren't directly serialized");
274 }
275 
277  VisitDecl(D);
278  Writer.AddDeclarationName(D->getDeclName(), Record);
279  Record.push_back(needsAnonymousDeclarationNumber(D)
280  ? Writer.getAnonymousDeclarationNumber(D)
281  : 0);
282 }
283 
285  VisitNamedDecl(D);
286  Writer.AddSourceLocation(D->getLocStart(), Record);
287  Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);
288 }
289 
291  VisitRedeclarable(D);
292  VisitTypeDecl(D);
293  Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);
294  Record.push_back(D->isModed());
295  if (D->isModed())
296  Writer.AddTypeRef(D->getUnderlyingType(), Record);
297 }
298 
300  VisitTypedefNameDecl(D);
301  if (!D->hasAttrs() &&
302  !D->isImplicit() &&
303  D->getFirstDecl() == D->getMostRecentDecl() &&
304  !D->isInvalidDecl() &&
306  !D->isModulePrivate() &&
309  AbbrevToUse = Writer.getDeclTypedefAbbrev();
310 
312 }
313 
315  VisitTypedefNameDecl(D);
316  Writer.AddDeclRef(D->getDescribedAliasTemplate(), Record);
318 }
319 
321  VisitRedeclarable(D);
322  VisitTypeDecl(D);
323  Record.push_back(D->getIdentifierNamespace());
324  Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
325  if (!isa<CXXRecordDecl>(D))
326  Record.push_back(D->isCompleteDefinition());
327  Record.push_back(D->isEmbeddedInDeclarator());
328  Record.push_back(D->isFreeStanding());
329  Record.push_back(D->isCompleteDefinitionRequired());
330  Writer.AddSourceLocation(D->getRBraceLoc(), Record);
331 
332  if (D->hasExtInfo()) {
333  Record.push_back(1);
334  Writer.AddQualifierInfo(*D->getExtInfo(), Record);
335  } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
336  Record.push_back(2);
337  Writer.AddDeclRef(TD, Record);
338  Writer.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo(), Record);
339  } else if (auto *DD = D->getDeclaratorForAnonDecl()) {
340  Record.push_back(3);
341  Writer.AddDeclRef(DD, Record);
342  } else {
343  Record.push_back(0);
344  }
345 }
346 
348  VisitTagDecl(D);
349  Writer.AddTypeSourceInfo(D->getIntegerTypeSourceInfo(), Record);
350  if (!D->getIntegerTypeSourceInfo())
351  Writer.AddTypeRef(D->getIntegerType(), Record);
352  Writer.AddTypeRef(D->getPromotionType(), Record);
353  Record.push_back(D->getNumPositiveBits());
354  Record.push_back(D->getNumNegativeBits());
355  Record.push_back(D->isScoped());
356  Record.push_back(D->isScopedUsingClassTag());
357  Record.push_back(D->isFixed());
358  if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) {
359  Writer.AddDeclRef(MemberInfo->getInstantiatedFrom(), Record);
360  Record.push_back(MemberInfo->getTemplateSpecializationKind());
361  Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record);
362  } else {
363  Writer.AddDeclRef(nullptr, Record);
364  }
365 
366  if (!D->hasAttrs() &&
367  !D->isImplicit() &&
368  !D->isUsed(false) &&
369  !D->hasExtInfo() &&
371  !D->getDeclaratorForAnonDecl() &&
372  D->getFirstDecl() == D->getMostRecentDecl() &&
373  !D->isInvalidDecl() &&
374  !D->isReferenced() &&
376  D->getAccess() == AS_none &&
377  !D->isModulePrivate() &&
379  !D->getIntegerTypeSourceInfo() &&
383  AbbrevToUse = Writer.getDeclEnumAbbrev();
384 
386 }
387 
389  VisitTagDecl(D);
390  Record.push_back(D->hasFlexibleArrayMember());
391  Record.push_back(D->isAnonymousStructOrUnion());
392  Record.push_back(D->hasObjectMember());
393  Record.push_back(D->hasVolatileMember());
394 
395  if (!D->hasAttrs() &&
396  !D->isImplicit() &&
397  !D->isUsed(false) &&
398  !D->hasExtInfo() &&
400  !D->getDeclaratorForAnonDecl() &&
401  D->getFirstDecl() == D->getMostRecentDecl() &&
402  !D->isInvalidDecl() &&
403  !D->isReferenced() &&
405  D->getAccess() == AS_none &&
406  !D->isModulePrivate() &&
410  AbbrevToUse = Writer.getDeclRecordAbbrev();
411 
413 }
414 
416  VisitNamedDecl(D);
417  Writer.AddTypeRef(D->getType(), Record);
418 }
419 
421  VisitValueDecl(D);
422  Record.push_back(D->getInitExpr()? 1 : 0);
423  if (D->getInitExpr())
424  Writer.AddStmt(D->getInitExpr());
425  Writer.AddAPSInt(D->getInitVal(), Record);
426 
428 }
429 
431  VisitValueDecl(D);
432  Writer.AddSourceLocation(D->getInnerLocStart(), Record);
433  Record.push_back(D->hasExtInfo());
434  if (D->hasExtInfo())
435  Writer.AddQualifierInfo(*D->getExtInfo(), Record);
436 }
437 
439  VisitRedeclarable(D);
440  VisitDeclaratorDecl(D);
441  Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
442  Record.push_back(D->getIdentifierNamespace());
443 
444  // FunctionDecl's body is handled last at ASTWriterDecl::Visit,
445  // after everything else is written.
446 
447  Record.push_back((int)D->SClass); // FIXME: stable encoding
448  Record.push_back(D->IsInline);
449  Record.push_back(D->IsInlineSpecified);
450  Record.push_back(D->IsVirtualAsWritten);
451  Record.push_back(D->IsPure);
452  Record.push_back(D->HasInheritedPrototype);
453  Record.push_back(D->HasWrittenPrototype);
454  Record.push_back(D->IsDeleted);
455  Record.push_back(D->IsTrivial);
456  Record.push_back(D->IsDefaulted);
457  Record.push_back(D->IsExplicitlyDefaulted);
458  Record.push_back(D->HasImplicitReturnZero);
459  Record.push_back(D->IsConstexpr);
460  Record.push_back(D->HasSkippedBody);
461  Record.push_back(D->IsLateTemplateParsed);
462  Record.push_back(D->getLinkageInternal());
463  Writer.AddSourceLocation(D->getLocEnd(), Record);
464 
465  Record.push_back(D->getTemplatedKind());
466  switch (D->getTemplatedKind()) {
468  break;
470  Writer.AddDeclRef(D->getDescribedFunctionTemplate(), Record);
471  break;
474  Writer.AddDeclRef(MemberInfo->getInstantiatedFrom(), Record);
475  Record.push_back(MemberInfo->getTemplateSpecializationKind());
476  Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record);
477  break;
478  }
481  FTSInfo = D->getTemplateSpecializationInfo();
482  Writer.AddDeclRef(FTSInfo->getTemplate(), Record);
483  Record.push_back(FTSInfo->getTemplateSpecializationKind());
484 
485  // Template arguments.
486  Writer.AddTemplateArgumentList(FTSInfo->TemplateArguments, Record);
487 
488  // Template args as written.
489  Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
490  if (FTSInfo->TemplateArgumentsAsWritten) {
491  Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs);
492  for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs;
493  i!=e; ++i)
494  Writer.AddTemplateArgumentLoc((*FTSInfo->TemplateArgumentsAsWritten)[i],
495  Record);
496  Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc,
497  Record);
498  Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc,
499  Record);
500  }
501 
502  Writer.AddSourceLocation(FTSInfo->getPointOfInstantiation(), Record);
503 
504  if (D->isCanonicalDecl()) {
505  // Write the template that contains the specializations set. We will
506  // add a FunctionTemplateSpecializationInfo to it when reading.
507  Writer.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl(), Record);
508  }
509  break;
510  }
513  DFTSInfo = D->getDependentSpecializationInfo();
514 
515  // Templates.
516  Record.push_back(DFTSInfo->getNumTemplates());
517  for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i)
518  Writer.AddDeclRef(DFTSInfo->getTemplate(i), Record);
519 
520  // Templates args.
521  Record.push_back(DFTSInfo->getNumTemplateArgs());
522  for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i)
523  Writer.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i), Record);
524  Writer.AddSourceLocation(DFTSInfo->getLAngleLoc(), Record);
525  Writer.AddSourceLocation(DFTSInfo->getRAngleLoc(), Record);
526  break;
527  }
528  }
529 
530  Record.push_back(D->param_size());
531  for (auto P : D->params())
532  Writer.AddDeclRef(P, Record);
534 }
535 
537  VisitNamedDecl(D);
538  // FIXME: convert to LazyStmtPtr?
539  // Unlike C/C++, method bodies will never be in header files.
540  bool HasBodyStuff = D->getBody() != nullptr ||
541  D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr;
542  Record.push_back(HasBodyStuff);
543  if (HasBodyStuff) {
544  Writer.AddStmt(D->getBody());
545  Writer.AddDeclRef(D->getSelfDecl(), Record);
546  Writer.AddDeclRef(D->getCmdDecl(), Record);
547  }
548  Record.push_back(D->isInstanceMethod());
549  Record.push_back(D->isVariadic());
550  Record.push_back(D->isPropertyAccessor());
551  Record.push_back(D->isDefined());
552  Record.push_back(D->IsOverriding);
553  Record.push_back(D->HasSkippedBody);
554 
555  Record.push_back(D->IsRedeclaration);
556  Record.push_back(D->HasRedeclaration);
557  if (D->HasRedeclaration) {
559  Writer.AddDeclRef(Context.getObjCMethodRedeclaration(D), Record);
560  }
561 
562  // FIXME: stable encoding for @required/@optional
563  Record.push_back(D->getImplementationControl());
564  // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
565  Record.push_back(D->getObjCDeclQualifier());
566  Record.push_back(D->hasRelatedResultType());
567  Writer.AddTypeRef(D->getReturnType(), Record);
568  Writer.AddTypeSourceInfo(D->getReturnTypeSourceInfo(), Record);
569  Writer.AddSourceLocation(D->getLocEnd(), Record);
570  Record.push_back(D->param_size());
571  for (const auto *P : D->params())
572  Writer.AddDeclRef(P, Record);
573 
574  Record.push_back(D->SelLocsKind);
575  unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
576  SourceLocation *SelLocs = D->getStoredSelLocs();
577  Record.push_back(NumStoredSelLocs);
578  for (unsigned i = 0; i != NumStoredSelLocs; ++i)
579  Writer.AddSourceLocation(SelLocs[i], Record);
580 
582 }
583 
585  VisitTypedefNameDecl(D);
586  Record.push_back(D->Variance);
587  Record.push_back(D->Index);
588  Writer.AddSourceLocation(D->VarianceLoc, Record);
589  Writer.AddSourceLocation(D->ColonLoc, Record);
590 
592 }
593 
595  VisitNamedDecl(D);
596  Writer.AddSourceLocation(D->getAtStartLoc(), Record);
597  Writer.AddSourceRange(D->getAtEndRange(), Record);
598  // Abstract class (no need to define a stable serialization::DECL code).
599 }
600 
602  VisitRedeclarable(D);
603  VisitObjCContainerDecl(D);
604  Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);
605  AddObjCTypeParamList(D->TypeParamList);
606 
607  Record.push_back(D->isThisDeclarationADefinition());
608  if (D->isThisDeclarationADefinition()) {
609  // Write the DefinitionData
610  ObjCInterfaceDecl::DefinitionData &Data = D->data();
611 
612  Writer.AddTypeSourceInfo(D->getSuperClassTInfo(), Record);
613  Writer.AddSourceLocation(D->getEndOfDefinitionLoc(), Record);
614  Record.push_back(Data.HasDesignatedInitializers);
615 
616  // Write out the protocols that are directly referenced by the @interface.
617  Record.push_back(Data.ReferencedProtocols.size());
618  for (const auto *P : D->protocols())
619  Writer.AddDeclRef(P, Record);
620  for (const auto &PL : D->protocol_locs())
621  Writer.AddSourceLocation(PL, Record);
622 
623  // Write out the protocols that are transitively referenced.
624  Record.push_back(Data.AllReferencedProtocols.size());
626  P = Data.AllReferencedProtocols.begin(),
627  PEnd = Data.AllReferencedProtocols.end();
628  P != PEnd; ++P)
629  Writer.AddDeclRef(*P, Record);
630 
631 
632  if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
633  // Ensure that we write out the set of categories for this class.
634  Writer.ObjCClassesWithCategories.insert(D);
635 
636  // Make sure that the categories get serialized.
637  for (; Cat; Cat = Cat->getNextClassCategoryRaw())
638  (void)Writer.GetDeclRef(Cat);
639  }
640  }
641 
643 }
644 
646  VisitFieldDecl(D);
647  // FIXME: stable encoding for @public/@private/@protected/@package
648  Record.push_back(D->getAccessControl());
649  Record.push_back(D->getSynthesize());
650 
651  if (!D->hasAttrs() &&
652  !D->isImplicit() &&
653  !D->isUsed(false) &&
654  !D->isInvalidDecl() &&
655  !D->isReferenced() &&
656  !D->isModulePrivate() &&
657  !D->getBitWidth() &&
658  !D->hasExtInfo() &&
659  D->getDeclName())
660  AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
661 
663 }
664 
666  VisitRedeclarable(D);
667  VisitObjCContainerDecl(D);
668 
669  Record.push_back(D->isThisDeclarationADefinition());
670  if (D->isThisDeclarationADefinition()) {
671  Record.push_back(D->protocol_size());
672  for (const auto *I : D->protocols())
673  Writer.AddDeclRef(I, Record);
674  for (const auto &PL : D->protocol_locs())
675  Writer.AddSourceLocation(PL, Record);
676  }
677 
679 }
680 
682  VisitFieldDecl(D);
684 }
685 
687  VisitObjCContainerDecl(D);
688  Writer.AddSourceLocation(D->getCategoryNameLoc(), Record);
689  Writer.AddSourceLocation(D->getIvarLBraceLoc(), Record);
690  Writer.AddSourceLocation(D->getIvarRBraceLoc(), Record);
691  Writer.AddDeclRef(D->getClassInterface(), Record);
692  AddObjCTypeParamList(D->TypeParamList);
693  Record.push_back(D->protocol_size());
694  for (const auto *I : D->protocols())
695  Writer.AddDeclRef(I, Record);
696  for (const auto &PL : D->protocol_locs())
697  Writer.AddSourceLocation(PL, Record);
699 }
700 
702  VisitNamedDecl(D);
703  Writer.AddDeclRef(D->getClassInterface(), Record);
705 }
706 
708  VisitNamedDecl(D);
709  Writer.AddSourceLocation(D->getAtLoc(), Record);
710  Writer.AddSourceLocation(D->getLParenLoc(), Record);
711  Writer.AddTypeRef(D->getType(), Record);
712  Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);
713  // FIXME: stable encoding
714  Record.push_back((unsigned)D->getPropertyAttributes());
715  Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
716  // FIXME: stable encoding
717  Record.push_back((unsigned)D->getPropertyImplementation());
718  Writer.AddDeclarationName(D->getGetterName(), Record);
719  Writer.AddDeclarationName(D->getSetterName(), Record);
720  Writer.AddDeclRef(D->getGetterMethodDecl(), Record);
721  Writer.AddDeclRef(D->getSetterMethodDecl(), Record);
722  Writer.AddDeclRef(D->getPropertyIvarDecl(), Record);
724 }
725 
727  VisitObjCContainerDecl(D);
728  Writer.AddDeclRef(D->getClassInterface(), Record);
729  // Abstract class (no need to define a stable serialization::DECL code).
730 }
731 
733  VisitObjCImplDecl(D);
734  Writer.AddIdentifierRef(D->getIdentifier(), Record);
735  Writer.AddSourceLocation(D->getCategoryNameLoc(), Record);
737 }
738 
740  VisitObjCImplDecl(D);
741  Writer.AddDeclRef(D->getSuperClass(), Record);
742  Writer.AddSourceLocation(D->getSuperClassLoc(), Record);
743  Writer.AddSourceLocation(D->getIvarLBraceLoc(), Record);
744  Writer.AddSourceLocation(D->getIvarRBraceLoc(), Record);
745  Record.push_back(D->hasNonZeroConstructors());
746  Record.push_back(D->hasDestructors());
747  Record.push_back(D->NumIvarInitializers);
748  if (D->NumIvarInitializers)
749  Writer.AddCXXCtorInitializersRef(
750  llvm::makeArrayRef(D->init_begin(), D->init_end()), Record);
752 }
753 
755  VisitDecl(D);
756  Writer.AddSourceLocation(D->getLocStart(), Record);
757  Writer.AddDeclRef(D->getPropertyDecl(), Record);
758  Writer.AddDeclRef(D->getPropertyIvarDecl(), Record);
759  Writer.AddSourceLocation(D->getPropertyIvarDeclLoc(), Record);
760  Writer.AddStmt(D->getGetterCXXConstructor());
761  Writer.AddStmt(D->getSetterCXXAssignment());
763 }
764 
766  VisitDeclaratorDecl(D);
767  Record.push_back(D->isMutable());
768  if (D->InitStorage.getInt() == FieldDecl::ISK_BitWidthOrNothing &&
769  D->InitStorage.getPointer() == nullptr) {
770  Record.push_back(0);
771  } else if (D->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
772  Record.push_back(D->InitStorage.getInt() + 1);
773  Writer.AddTypeRef(
774  QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0),
775  Record);
776  } else {
777  Record.push_back(D->InitStorage.getInt() + 1);
778  Writer.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer()));
779  }
780  if (!D->getDeclName())
781  Writer.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D), Record);
782 
783  if (!D->hasAttrs() &&
784  !D->isImplicit() &&
785  !D->isUsed(false) &&
786  !D->isInvalidDecl() &&
787  !D->isReferenced() &&
789  !D->isModulePrivate() &&
790  !D->getBitWidth() &&
791  !D->hasInClassInitializer() &&
792  !D->hasExtInfo() &&
795  D->getDeclName())
796  AbbrevToUse = Writer.getDeclFieldAbbrev();
797 
799 }
800 
802  VisitDeclaratorDecl(D);
803  Writer.AddIdentifierRef(D->getGetterId(), Record);
804  Writer.AddIdentifierRef(D->getSetterId(), Record);
806 }
807 
809  VisitValueDecl(D);
810  Record.push_back(D->getChainingSize());
811 
812  for (const auto *P : D->chain())
813  Writer.AddDeclRef(P, Record);
815 }
816 
818  VisitRedeclarable(D);
819  VisitDeclaratorDecl(D);
820  Record.push_back(D->getStorageClass());
821  Record.push_back(D->getTSCSpec());
822  Record.push_back(D->getInitStyle());
823  if (!isa<ParmVarDecl>(D)) {
824  Record.push_back(D->isExceptionVariable());
825  Record.push_back(D->isNRVOVariable());
826  Record.push_back(D->isCXXForRangeDecl());
827  Record.push_back(D->isARCPseudoStrong());
828  Record.push_back(D->isConstexpr());
829  Record.push_back(D->isInitCapture());
830  Record.push_back(D->isPreviousDeclInSameBlockScope());
831  }
832  Record.push_back(D->getLinkageInternal());
833 
834  if (D->getInit()) {
835  Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2));
836  Writer.AddStmt(D->getInit());
837  } else {
838  Record.push_back(0);
839  }
840 
841  enum {
842  VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
843  };
844  if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
845  Record.push_back(VarTemplate);
846  Writer.AddDeclRef(TemplD, Record);
847  } else if (MemberSpecializationInfo *SpecInfo
849  Record.push_back(StaticDataMemberSpecialization);
850  Writer.AddDeclRef(SpecInfo->getInstantiatedFrom(), Record);
851  Record.push_back(SpecInfo->getTemplateSpecializationKind());
852  Writer.AddSourceLocation(SpecInfo->getPointOfInstantiation(), Record);
853  } else {
854  Record.push_back(VarNotTemplate);
855  }
856 
857  if (!D->hasAttrs() &&
858  !D->isImplicit() &&
859  !D->isUsed(false) &&
860  !D->isInvalidDecl() &&
861  !D->isReferenced() &&
863  D->getAccess() == AS_none &&
864  !D->isModulePrivate() &&
867  !D->hasExtInfo() &&
868  D->getFirstDecl() == D->getMostRecentDecl() &&
869  D->getInitStyle() == VarDecl::CInit &&
870  D->getInit() == nullptr &&
871  !isa<ParmVarDecl>(D) &&
872  !isa<VarTemplateSpecializationDecl>(D) &&
873  !D->isConstexpr() &&
874  !D->isInitCapture() &&
877  AbbrevToUse = Writer.getDeclVarAbbrev();
878 
880 }
881 
883  VisitVarDecl(D);
885 }
886 
888  VisitVarDecl(D);
889  Record.push_back(D->isObjCMethodParameter());
890  Record.push_back(D->getFunctionScopeDepth());
891  Record.push_back(D->getFunctionScopeIndex());
892  Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding
893  Record.push_back(D->isKNRPromoted());
894  Record.push_back(D->hasInheritedDefaultArg());
895  Record.push_back(D->hasUninstantiatedDefaultArg());
897  Writer.AddStmt(D->getUninstantiatedDefaultArg());
899 
900  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
901 
902  // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
903  // we dynamically check for the properties that we optimize for, but don't
904  // know are true of all PARM_VAR_DECLs.
905  if (!D->hasAttrs() &&
906  !D->hasExtInfo() &&
907  !D->isImplicit() &&
908  !D->isUsed(false) &&
909  !D->isInvalidDecl() &&
910  !D->isReferenced() &&
911  D->getAccess() == AS_none &&
912  !D->isModulePrivate() &&
913  D->getStorageClass() == 0 &&
914  D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
915  D->getFunctionScopeDepth() == 0 &&
916  D->getObjCDeclQualifier() == 0 &&
917  !D->isKNRPromoted() &&
918  !D->hasInheritedDefaultArg() &&
919  D->getInit() == nullptr &&
920  !D->hasUninstantiatedDefaultArg()) // No default expr.
921  AbbrevToUse = Writer.getDeclParmVarAbbrev();
922 
923  // Check things we know are true of *every* PARM_VAR_DECL, which is more than
924  // just us assuming it.
925  assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
926  assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
927  assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
928  assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
929  assert(!D->isStaticDataMember() &&
930  "PARM_VAR_DECL can't be static data member");
931 }
932 
934  VisitDecl(D);
935  Writer.AddStmt(D->getAsmString());
936  Writer.AddSourceLocation(D->getRParenLoc(), Record);
938 }
939 
941  VisitDecl(D);
943 }
944 
946  VisitDecl(D);
947  Writer.AddStmt(D->getBody());
948  Writer.AddTypeSourceInfo(D->getSignatureAsWritten(), Record);
949  Record.push_back(D->param_size());
950  for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end();
951  P != PEnd; ++P)
952  Writer.AddDeclRef(*P, Record);
953  Record.push_back(D->isVariadic());
954  Record.push_back(D->blockMissingReturnType());
955  Record.push_back(D->isConversionFromLambda());
956  Record.push_back(D->capturesCXXThis());
957  Record.push_back(D->getNumCaptures());
958  for (const auto &capture : D->captures()) {
959  Writer.AddDeclRef(capture.getVariable(), Record);
960 
961  unsigned flags = 0;
962  if (capture.isByRef()) flags |= 1;
963  if (capture.isNested()) flags |= 2;
964  if (capture.hasCopyExpr()) flags |= 4;
965  Record.push_back(flags);
966 
967  if (capture.hasCopyExpr()) Writer.AddStmt(capture.getCopyExpr());
968  }
969 
971 }
972 
974  Record.push_back(CD->getNumParams());
975  VisitDecl(CD);
976  Record.push_back(CD->getContextParamPosition());
977  Record.push_back(CD->isNothrow() ? 1 : 0);
978  // Body is stored by VisitCapturedStmt.
979  for (unsigned I = 0; I < CD->getNumParams(); ++I)
980  Writer.AddDeclRef(CD->getParam(I), Record);
982 }
983 
985  VisitDecl(D);
986  Record.push_back(D->getLanguage());
987  Writer.AddSourceLocation(D->getExternLoc(), Record);
988  Writer.AddSourceLocation(D->getRBraceLoc(), Record);
990 }
991 
993  VisitNamedDecl(D);
994  Writer.AddSourceLocation(D->getLocStart(), Record);
996 }
997 
998 
1000  VisitRedeclarable(D);
1001  VisitNamedDecl(D);
1002  Record.push_back(D->isInline());
1003  Writer.AddSourceLocation(D->getLocStart(), Record);
1004  Writer.AddSourceLocation(D->getRBraceLoc(), Record);
1005 
1006  if (D->isOriginalNamespace())
1007  Writer.AddDeclRef(D->getAnonymousNamespace(), Record);
1009 
1010  if (Writer.hasChain() && D->isAnonymousNamespace() &&
1011  D == D->getMostRecentDecl()) {
1012  // This is a most recent reopening of the anonymous namespace. If its parent
1013  // is in a previous PCH (or is the TU), mark that parent for update, because
1014  // the original namespace always points to the latest re-opening of its
1015  // anonymous namespace.
1016  Decl *Parent = cast<Decl>(
1018  if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1019  Writer.DeclUpdates[Parent].push_back(
1020  ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D));
1021  }
1022  }
1023 }
1024 
1026  VisitRedeclarable(D);
1027  VisitNamedDecl(D);
1028  Writer.AddSourceLocation(D->getNamespaceLoc(), Record);
1029  Writer.AddSourceLocation(D->getTargetNameLoc(), Record);
1030  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1031  Writer.AddDeclRef(D->getNamespace(), Record);
1033 }
1034 
1036  VisitNamedDecl(D);
1037  Writer.AddSourceLocation(D->getUsingLoc(), Record);
1038  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1039  Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
1040  Writer.AddDeclRef(D->FirstUsingShadow.getPointer(), Record);
1041  Record.push_back(D->hasTypename());
1042  Writer.AddDeclRef(Context.getInstantiatedFromUsingDecl(D), Record);
1044 }
1045 
1047  VisitRedeclarable(D);
1048  VisitNamedDecl(D);
1049  Writer.AddDeclRef(D->getTargetDecl(), Record);
1050  Writer.AddDeclRef(D->UsingOrNextShadow, Record);
1051  Writer.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D), Record);
1053 }
1054 
1056  VisitNamedDecl(D);
1057  Writer.AddSourceLocation(D->getUsingLoc(), Record);
1058  Writer.AddSourceLocation(D->getNamespaceKeyLocation(), Record);
1059  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1060  Writer.AddDeclRef(D->getNominatedNamespace(), Record);
1061  Writer.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()), Record);
1063 }
1064 
1066  VisitValueDecl(D);
1067  Writer.AddSourceLocation(D->getUsingLoc(), Record);
1068  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1069  Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
1071 }
1072 
1075  VisitTypeDecl(D);
1076  Writer.AddSourceLocation(D->getTypenameLoc(), Record);
1077  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1079 }
1080 
1082  VisitRecordDecl(D);
1083 
1084  enum {
1085  CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1086  };
1087  if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1088  Record.push_back(CXXRecTemplate);
1089  Writer.AddDeclRef(TemplD, Record);
1090  } else if (MemberSpecializationInfo *MSInfo
1091  = D->getMemberSpecializationInfo()) {
1092  Record.push_back(CXXRecMemberSpecialization);
1093  Writer.AddDeclRef(MSInfo->getInstantiatedFrom(), Record);
1094  Record.push_back(MSInfo->getTemplateSpecializationKind());
1095  Writer.AddSourceLocation(MSInfo->getPointOfInstantiation(), Record);
1096  } else {
1097  Record.push_back(CXXRecNotTemplate);
1098  }
1099 
1100  Record.push_back(D->isThisDeclarationADefinition());
1102  Writer.AddCXXDefinitionData(D, Record);
1103 
1104  // Store (what we currently believe to be) the key function to avoid
1105  // deserializing every method so we can compute it.
1106  if (D->IsCompleteDefinition)
1107  Writer.AddDeclRef(Context.getCurrentKeyFunction(D), Record);
1108 
1110 }
1111 
1113  VisitFunctionDecl(D);
1114  if (D->isCanonicalDecl()) {
1115  Record.push_back(D->size_overridden_methods());
1118  I != E; ++I)
1119  Writer.AddDeclRef(*I, Record);
1120  } else {
1121  // We only need to record overridden methods once for the canonical decl.
1122  Record.push_back(0);
1123  }
1124 
1125  if (D->getFirstDecl() == D->getMostRecentDecl() &&
1126  !D->isInvalidDecl() &&
1127  !D->hasAttrs() &&
1130  !D->hasExtInfo() &&
1131  !D->hasInheritedPrototype() &&
1132  D->hasWrittenPrototype())
1133  AbbrevToUse = Writer.getDeclCXXMethodAbbrev();
1134 
1136 }
1137 
1139  VisitCXXMethodDecl(D);
1140 
1141  Writer.AddDeclRef(D->getInheritedConstructor(), Record);
1142  Record.push_back(D->IsExplicitSpecified);
1143 
1145 }
1146 
1148  VisitCXXMethodDecl(D);
1149 
1150  Writer.AddDeclRef(D->getOperatorDelete(), Record);
1151 
1153 }
1154 
1156  VisitCXXMethodDecl(D);
1157  Record.push_back(D->IsExplicitSpecified);
1159 }
1160 
1162  VisitDecl(D);
1163  Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1164  ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1165  Record.push_back(!IdentifierLocs.empty());
1166  if (IdentifierLocs.empty()) {
1167  Writer.AddSourceLocation(D->getLocEnd(), Record);
1168  Record.push_back(1);
1169  } else {
1170  for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1171  Writer.AddSourceLocation(IdentifierLocs[I], Record);
1172  Record.push_back(IdentifierLocs.size());
1173  }
1174  // Note: the number of source locations must always be the last element in
1175  // the record.
1177 }
1178 
1180  VisitDecl(D);
1181  Writer.AddSourceLocation(D->getColonLoc(), Record);
1183 }
1184 
1186  // Record the number of friend type template parameter lists here
1187  // so as to simplify memory allocation during deserialization.
1188  Record.push_back(D->NumTPLists);
1189  VisitDecl(D);
1190  bool hasFriendDecl = D->Friend.is<NamedDecl*>();
1191  Record.push_back(hasFriendDecl);
1192  if (hasFriendDecl)
1193  Writer.AddDeclRef(D->getFriendDecl(), Record);
1194  else
1195  Writer.AddTypeSourceInfo(D->getFriendType(), Record);
1196  for (unsigned i = 0; i < D->NumTPLists; ++i)
1197  Writer.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i),
1198  Record);
1199  Writer.AddDeclRef(D->getNextFriend(), Record);
1200  Record.push_back(D->UnsupportedFriend);
1201  Writer.AddSourceLocation(D->FriendLoc, Record);
1203 }
1204 
1206  VisitDecl(D);
1207  Record.push_back(D->getNumTemplateParameters());
1208  for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1209  Writer.AddTemplateParameterList(D->getTemplateParameterList(i), Record);
1210  Record.push_back(D->getFriendDecl() != nullptr);
1211  if (D->getFriendDecl())
1212  Writer.AddDeclRef(D->getFriendDecl(), Record);
1213  else
1214  Writer.AddTypeSourceInfo(D->getFriendType(), Record);
1215  Writer.AddSourceLocation(D->getFriendLoc(), Record);
1217 }
1218 
1220  VisitNamedDecl(D);
1221 
1222  Writer.AddDeclRef(D->getTemplatedDecl(), Record);
1223  Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
1224 }
1225 
1227  VisitRedeclarable(D);
1228 
1229  // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1230  // getCommonPtr() can be used while this is still initializing.
1231  if (D->isFirstDecl()) {
1232  // This declaration owns the 'common' pointer, so serialize that data now.
1233  Writer.AddDeclRef(D->getInstantiatedFromMemberTemplate(), Record);
1235  Record.push_back(D->isMemberSpecialization());
1236  }
1237 
1238  VisitTemplateDecl(D);
1239  Record.push_back(D->getIdentifierNamespace());
1240 }
1241 
1243  VisitRedeclarableTemplateDecl(D);
1244 
1245  if (D->isFirstDecl())
1246  AddTemplateSpecializations(D);
1248 }
1249 
1252  VisitCXXRecordDecl(D);
1253 
1254  llvm::PointerUnion<ClassTemplateDecl *,
1257  if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1258  Writer.AddDeclRef(InstFromD, Record);
1259  } else {
1260  Writer.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>(),
1261  Record);
1262  Writer.AddTemplateArgumentList(&D->getTemplateInstantiationArgs(), Record);
1263  }
1264 
1265  Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record);
1266  Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);
1267  Record.push_back(D->getSpecializationKind());
1268  Record.push_back(D->isCanonicalDecl());
1269 
1270  if (D->isCanonicalDecl()) {
1271  // When reading, we'll add it to the folding set of the following template.
1272  Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record);
1273  }
1274 
1275  // Explicit info.
1276  Writer.AddTypeSourceInfo(D->getTypeAsWritten(), Record);
1277  if (D->getTypeAsWritten()) {
1278  Writer.AddSourceLocation(D->getExternLoc(), Record);
1279  Writer.AddSourceLocation(D->getTemplateKeywordLoc(), Record);
1280  }
1281 
1283 }
1284 
1287  VisitClassTemplateSpecializationDecl(D);
1288 
1289  Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
1290  Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);
1291 
1292  // These are read/set from/to the first declaration.
1293  if (D->getPreviousDecl() == nullptr) {
1294  Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);
1295  Record.push_back(D->isMemberSpecialization());
1296  }
1297 
1299 }
1300 
1302  VisitRedeclarableTemplateDecl(D);
1303 
1304  if (D->isFirstDecl())
1305  AddTemplateSpecializations(D);
1307 }
1308 
1311  VisitVarDecl(D);
1312 
1313  llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
1314  InstFrom = D->getSpecializedTemplateOrPartial();
1315  if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
1316  Writer.AddDeclRef(InstFromD, Record);
1317  } else {
1318  Writer.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>(),
1319  Record);
1320  Writer.AddTemplateArgumentList(&D->getTemplateInstantiationArgs(), Record);
1321  }
1322 
1323  // Explicit info.
1324  Writer.AddTypeSourceInfo(D->getTypeAsWritten(), Record);
1325  if (D->getTypeAsWritten()) {
1326  Writer.AddSourceLocation(D->getExternLoc(), Record);
1327  Writer.AddSourceLocation(D->getTemplateKeywordLoc(), Record);
1328  }
1329 
1330  Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record);
1331  Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);
1332  Record.push_back(D->getSpecializationKind());
1333  Record.push_back(D->isCanonicalDecl());
1334 
1335  if (D->isCanonicalDecl()) {
1336  // When reading, we'll add it to the folding set of the following template.
1337  Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record);
1338  }
1339 
1341 }
1342 
1345  VisitVarTemplateSpecializationDecl(D);
1346 
1347  Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
1348  Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);
1349 
1350  // These are read/set from/to the first declaration.
1351  if (D->getPreviousDecl() == nullptr) {
1352  Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);
1353  Record.push_back(D->isMemberSpecialization());
1354  }
1355 
1357 }
1358 
1361  VisitDecl(D);
1362  Writer.AddDeclRef(D->getSpecialization(), Record);
1364 }
1365 
1366 
1368  VisitRedeclarableTemplateDecl(D);
1369 
1370  if (D->isFirstDecl())
1371  AddTemplateSpecializations(D);
1373 }
1374 
1376  VisitTypeDecl(D);
1377 
1378  Record.push_back(D->wasDeclaredWithTypename());
1379 
1380  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1382  Record.push_back(OwnsDefaultArg);
1383  if (OwnsDefaultArg)
1384  Writer.AddTypeSourceInfo(D->getDefaultArgumentInfo(), Record);
1385 
1387 }
1388 
1390  // For an expanded parameter pack, record the number of expansion types here
1391  // so that it's easier for deserialization to allocate the right amount of
1392  // memory.
1393  if (D->isExpandedParameterPack())
1394  Record.push_back(D->getNumExpansionTypes());
1395 
1396  VisitDeclaratorDecl(D);
1397  // TemplateParmPosition.
1398  Record.push_back(D->getDepth());
1399  Record.push_back(D->getPosition());
1400 
1401  if (D->isExpandedParameterPack()) {
1402  for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
1403  Writer.AddTypeRef(D->getExpansionType(I), Record);
1404  Writer.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I), Record);
1405  }
1406 
1408  } else {
1409  // Rest of NonTypeTemplateParmDecl.
1410  Record.push_back(D->isParameterPack());
1411  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1413  Record.push_back(OwnsDefaultArg);
1414  if (OwnsDefaultArg)
1415  Writer.AddStmt(D->getDefaultArgument());
1417  }
1418 }
1419 
1421  // For an expanded parameter pack, record the number of expansion types here
1422  // so that it's easier for deserialization to allocate the right amount of
1423  // memory.
1424  if (D->isExpandedParameterPack())
1425  Record.push_back(D->getNumExpansionTemplateParameters());
1426 
1427  VisitTemplateDecl(D);
1428  // TemplateParmPosition.
1429  Record.push_back(D->getDepth());
1430  Record.push_back(D->getPosition());
1431 
1432  if (D->isExpandedParameterPack()) {
1433  for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
1434  I != N; ++I)
1435  Writer.AddTemplateParameterList(D->getExpansionTemplateParameters(I),
1436  Record);
1438  } else {
1439  // Rest of TemplateTemplateParmDecl.
1440  Record.push_back(D->isParameterPack());
1441  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1443  Record.push_back(OwnsDefaultArg);
1444  if (OwnsDefaultArg)
1445  Writer.AddTemplateArgumentLoc(D->getDefaultArgument(), Record);
1447  }
1448 }
1449 
1451  VisitRedeclarableTemplateDecl(D);
1453 }
1454 
1456  VisitDecl(D);
1457  Writer.AddStmt(D->getAssertExpr());
1458  Record.push_back(D->isFailed());
1459  Writer.AddStmt(D->getMessage());
1460  Writer.AddSourceLocation(D->getRParenLoc(), Record);
1462 }
1463 
1464 /// \brief Emit the DeclContext part of a declaration context decl.
1465 ///
1466 /// \param LexicalOffset the offset at which the DECL_CONTEXT_LEXICAL
1467 /// block for this declaration context is stored. May be 0 to indicate
1468 /// that there are no declarations stored within this context.
1469 ///
1470 /// \param VisibleOffset the offset at which the DECL_CONTEXT_VISIBLE
1471 /// block for this declaration context is stored. May be 0 to indicate
1472 /// that there are no declarations visible from this context. Note
1473 /// that this value will not be emitted for non-primary declaration
1474 /// contexts.
1475 void ASTDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
1476  uint64_t VisibleOffset) {
1477  Record.push_back(LexicalOffset);
1478  Record.push_back(VisibleOffset);
1479 }
1480 
1481 /// Determine whether D is the first declaration in its redeclaration chain that
1482 /// is not from an AST file.
1483 template <typename T>
1485  assert(D && !static_cast<T*>(D)->isFromASTFile());
1486  do
1487  D = D->getPreviousDecl();
1488  while (D && static_cast<T*>(D)->isFromASTFile());
1489  return !D;
1490 }
1491 
1492 template <typename T>
1494  T *First = D->getFirstDecl();
1495  T *MostRecent = First->getMostRecentDecl();
1496  if (MostRecent != First) {
1497  assert(isRedeclarableDeclKind(static_cast<T *>(D)->getKind()) &&
1498  "Not considered redeclarable?");
1499 
1500  Writer.AddDeclRef(First, Record);
1501 
1502  // In a modules build, emit a list of all imported key declarations
1503  // (excluding First, if it was imported), so that we can be sure that all
1504  // redeclarations visible to this module are before D in the redecl chain.
1505  unsigned I = Record.size();
1506  Record.push_back(0);
1507  if (Context.getLangOpts().Modules && Writer.Chain) {
1508  if (isFirstLocalDecl(D)) {
1509  Writer.Chain->forEachImportedKeyDecl(First, [&](const Decl *D) {
1510  if (D != First)
1511  Writer.AddDeclRef(D, Record);
1512  });
1513  Record[I] = Record.size() - I - 1;
1514 
1515  // Write a redeclaration chain, attached to the first key decl.
1516  Writer.Redeclarations.push_back(Writer.Chain->getKeyDeclaration(First));
1517  }
1518  } else if (D == First || D->getPreviousDecl()->isFromASTFile()) {
1519  assert(isFirstLocalDecl(D) && "imported decl after local decl");
1520 
1521  // Write a redeclaration chain attached to the first decl.
1522  Writer.Redeclarations.push_back(First);
1523  }
1524 
1525  // Make sure that we serialize both the previous and the most-recent
1526  // declarations, which (transitively) ensures that all declarations in the
1527  // chain get serialized.
1528  //
1529  // FIXME: This is not correct; when we reach an imported declaration we
1530  // won't emit its previous declaration.
1531  (void)Writer.GetDeclRef(D->getPreviousDecl());
1532  (void)Writer.GetDeclRef(MostRecent);
1533  } else {
1534  // We use the sentinel value 0 to indicate an only declaration.
1535  Record.push_back(0);
1536  }
1537 }
1538 
1540  Record.push_back(D->varlist_size());
1541  VisitDecl(D);
1542  for (auto *I : D->varlists())
1543  Writer.AddStmt(I);
1545 }
1546 
1547 //===----------------------------------------------------------------------===//
1548 // ASTWriter Implementation
1549 //===----------------------------------------------------------------------===//
1550 
1551 void ASTWriter::WriteDeclAbbrevs() {
1552  using namespace llvm;
1553 
1554  BitCodeAbbrev *Abv;
1555 
1556  // Abbreviation for DECL_FIELD
1557  Abv = new BitCodeAbbrev();
1558  Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
1559  // Decl
1560  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1561  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalDeclContext
1562  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1563  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1564  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1565  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1566  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1567  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1568  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1569  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1570  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1571  // NamedDecl
1572  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1573  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1574  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1575  // ValueDecl
1576  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1577  // DeclaratorDecl
1578  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1579  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1580  // FieldDecl
1581  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1582  Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth
1583  // Type Source Info
1584  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1585  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1586  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1587  DeclFieldAbbrev = Stream.EmitAbbrev(Abv);
1588 
1589  // Abbreviation for DECL_OBJC_IVAR
1590  Abv = new BitCodeAbbrev();
1591  Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
1592  // Decl
1593  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1594  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalDeclContext
1595  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1596  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1597  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1598  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1599  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1600  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1601  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1602  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1603  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1604  // NamedDecl
1605  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1606  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1607  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1608  // ValueDecl
1609  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1610  // DeclaratorDecl
1611  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1612  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1613  // FieldDecl
1614  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1615  Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth
1616  // ObjC Ivar
1617  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
1618  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
1619  // Type Source Info
1620  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1621  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1622  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1623  DeclObjCIvarAbbrev = Stream.EmitAbbrev(Abv);
1624 
1625  // Abbreviation for DECL_ENUM
1626  Abv = new BitCodeAbbrev();
1627  Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
1628  // Redeclarable
1629  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1630  // Decl
1631  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1632  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalDeclContext
1633  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1634  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1635  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1636  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1637  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1638  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1639  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1640  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1641  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1642  // NamedDecl
1643  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1644  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1645  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1646  // TypeDecl
1647  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1648  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1649  // TagDecl
1650  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1651  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1652  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1653  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1654  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1655  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1656  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1657  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1658  // EnumDecl
1659  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
1660  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
1661  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
1662  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumPositiveBits
1663  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumNegativeBits
1664  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScoped
1665  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScopedUsingClassTag
1666  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isFixed
1667  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
1668  // DC
1669  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1670  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1671  DeclEnumAbbrev = Stream.EmitAbbrev(Abv);
1672 
1673  // Abbreviation for DECL_RECORD
1674  Abv = new BitCodeAbbrev();
1675  Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
1676  // Redeclarable
1677  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1678  // Decl
1679  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1680  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalDeclContext
1681  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1682  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1683  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1684  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1685  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1686  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1687  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1688  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1689  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1690  // NamedDecl
1691  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1692  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1693  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1694  // TypeDecl
1695  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1696  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1697  // TagDecl
1698  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1699  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1700  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1701  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1702  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1703  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1704  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1705  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1706  // RecordDecl
1707  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember
1708  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
1709  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
1710  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
1711  // DC
1712  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1713  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1714  DeclRecordAbbrev = Stream.EmitAbbrev(Abv);
1715 
1716  // Abbreviation for DECL_PARM_VAR
1717  Abv = new BitCodeAbbrev();
1718  Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
1719  // Redeclarable
1720  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1721  // Decl
1722  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1723  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // 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(AS_none)); // C++ 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  // VarDecl
1743  Abv->Add(BitCodeAbbrevOp(0)); // StorageClass
1744  Abv->Add(BitCodeAbbrevOp(0)); // getTSCSpec
1745  Abv->Add(BitCodeAbbrevOp(0)); // hasCXXDirectInitializer
1746  Abv->Add(BitCodeAbbrevOp(0)); // Linkage
1747  Abv->Add(BitCodeAbbrevOp(0)); // HasInit
1748  Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo
1749  // ParmVarDecl
1750  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsObjCMethodParameter
1751  Abv->Add(BitCodeAbbrevOp(0)); // ScopeDepth
1752  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
1753  Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier
1754  Abv->Add(BitCodeAbbrevOp(0)); // KNRPromoted
1755  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg
1756  Abv->Add(BitCodeAbbrevOp(0)); // HasUninstantiatedDefaultArg
1757  // Type Source Info
1758  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1759  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1760  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1761  DeclParmVarAbbrev = Stream.EmitAbbrev(Abv);
1762 
1763  // Abbreviation for DECL_TYPEDEF
1764  Abv = new BitCodeAbbrev();
1765  Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
1766  // Redeclarable
1767  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1768  // Decl
1769  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1770  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalDeclContext
1771  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1772  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1773  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1774  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isUsed
1775  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isReferenced
1776  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1777  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // C++ AccessSpecifier
1778  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1779  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1780  // NamedDecl
1781  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1782  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1783  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1784  // TypeDecl
1785  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1786  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1787  // TypedefDecl
1788  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1789  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1790  DeclTypedefAbbrev = Stream.EmitAbbrev(Abv);
1791 
1792  // Abbreviation for DECL_VAR
1793  Abv = new BitCodeAbbrev();
1794  Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
1795  // Redeclarable
1796  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1797  // Decl
1798  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1799  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalDeclContext
1800  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1801  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1802  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1803  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1804  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1805  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1806  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1807  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1808  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1809  // NamedDecl
1810  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1811  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1812  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1813  // ValueDecl
1814  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1815  // DeclaratorDecl
1816  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1817  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1818  // VarDecl
1819  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // StorageClass
1820  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // getTSCSpec
1821  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // CXXDirectInitializer
1822  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
1823  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
1824  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
1825  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
1826  Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
1827  Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
1828  Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
1829  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
1830  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasInit
1831  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasMemberSpecInfo
1832  // Type Source Info
1833  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1834  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1835  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1836  DeclVarAbbrev = Stream.EmitAbbrev(Abv);
1837 
1838  // Abbreviation for DECL_CXX_METHOD
1839  Abv = new BitCodeAbbrev();
1840  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD));
1841  // RedeclarableDecl
1842  Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
1843  // Decl
1844  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1845  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalDeclContext
1846  Abv->Add(BitCodeAbbrevOp(0)); // Invalid
1847  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1848  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Implicit
1849  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Used
1850  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Referenced
1851  Abv->Add(BitCodeAbbrevOp(0)); // InObjCContainer
1852  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Access
1853  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModulePrivate
1854  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1855  // NamedDecl
1856  Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
1857  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
1858  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1859  // ValueDecl
1860  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1861  // DeclaratorDecl
1862  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
1863  Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
1864  // FunctionDecl
1865  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
1866  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass
1867  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline
1868  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified
1869  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten
1870  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure
1871  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto
1872  Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto
1873  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted
1874  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial
1875  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
1876  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
1877  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
1878  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
1879  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
1880  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed
1881  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
1882  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
1883  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind
1884  // This Array slurps the rest of the record. Fortunately we want to encode
1885  // (nearly) all the remaining (variable number of) fields in the same way.
1886  //
1887  // This is the function template information if any, then
1888  // NumParams and Params[] from FunctionDecl, and
1889  // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
1890  //
1891  // Add an AbbrevOp for 'size then elements' and use it here.
1892  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1893  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1894  DeclCXXMethodAbbrev = Stream.EmitAbbrev(Abv);
1895 
1896  // Abbreviation for EXPR_DECL_REF
1897  Abv = new BitCodeAbbrev();
1898  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
1899  //Stmt
1900  //Expr
1901  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1902  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
1903  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
1904  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
1905  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
1906  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
1907  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
1908  //DeclRefExpr
1909  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HasQualifier
1910  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //GetDeclFound
1911  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ExplicitTemplateArgs
1912  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HadMultipleCandidates
1913  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
1914  1)); // RefersToEnclosingVariableOrCapture
1915  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
1916  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
1917  DeclRefExprAbbrev = Stream.EmitAbbrev(Abv);
1918 
1919  // Abbreviation for EXPR_INTEGER_LITERAL
1920  Abv = new BitCodeAbbrev();
1921  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
1922  //Stmt
1923  //Expr
1924  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1925  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
1926  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
1927  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
1928  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
1929  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
1930  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
1931  //Integer Literal
1932  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
1933  Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
1934  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
1935  IntegerLiteralAbbrev = Stream.EmitAbbrev(Abv);
1936 
1937  // Abbreviation for EXPR_CHARACTER_LITERAL
1938  Abv = new BitCodeAbbrev();
1939  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
1940  //Stmt
1941  //Expr
1942  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1943  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
1944  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
1945  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
1946  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
1947  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
1948  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
1949  //Character Literal
1950  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
1951  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
1952  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // getKind
1953  CharacterLiteralAbbrev = Stream.EmitAbbrev(Abv);
1954 
1955  // Abbreviation for EXPR_IMPLICIT_CAST
1956  Abv = new BitCodeAbbrev();
1957  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
1958  // Stmt
1959  // Expr
1960  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1961  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
1962  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
1963  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
1964  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
1965  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
1966  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
1967  // CastExpr
1968  Abv->Add(BitCodeAbbrevOp(0)); // PathSize
1969  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind
1970  // ImplicitCastExpr
1971  ExprImplicitCastAbbrev = Stream.EmitAbbrev(Abv);
1972 
1973  Abv = new BitCodeAbbrev();
1974  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
1975  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1976  DeclContextLexicalAbbrev = Stream.EmitAbbrev(Abv);
1977 
1978  Abv = new BitCodeAbbrev();
1979  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
1980  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
1981  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
1982  DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(Abv);
1983 }
1984 
1985 /// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
1986 /// consumers of the AST.
1987 ///
1988 /// Such decls will always be deserialized from the AST file, so we would like
1989 /// this to be as restrictive as possible. Currently the predicate is driven by
1990 /// code generation requirements, if other clients have a different notion of
1991 /// what is "required" then we may have to consider an alternate scheme where
1992 /// clients can iterate over the top-level decls and get information on them,
1993 /// without necessary deserializing them. We could explicitly require such
1994 /// clients to use a separate API call to "realize" the decl. This should be
1995 /// relatively painless since they would presumably only do it for top-level
1996 /// decls.
1997 static bool isRequiredDecl(const Decl *D, ASTContext &Context) {
1998  // An ObjCMethodDecl is never considered as "required" because its
1999  // implementation container always is.
2000 
2001  // File scoped assembly or obj-c implementation must be seen. ImportDecl is
2002  // used by codegen to determine the set of imported modules to search for
2003  // inputs for automatic linking.
2004  if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D) || isa<ImportDecl>(D))
2005  return true;
2006 
2007  return Context.DeclMustBeEmitted(D);
2008 }
2009 
2010 void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
2011  // Switch case IDs are per Decl.
2012  ClearSwitchCaseIDs();
2013 
2014  RecordData Record;
2015  ASTDeclWriter W(*this, Context, Record);
2016 
2017  // Determine the ID for this declaration.
2019  if (D->isFromASTFile()) {
2020  assert(isRewritten(D) && "should not be emitting imported decl");
2021  ID = getDeclID(D);
2022  } else {
2023  serialization::DeclID &IDR = DeclIDs[D];
2024  if (IDR == 0)
2025  IDR = NextDeclID++;
2026 
2027  ID= IDR;
2028  }
2029 
2030  bool isReplacingADecl = ID < FirstDeclID;
2031 
2032  // If this declaration is also a DeclContext, write blocks for the
2033  // declarations that lexically stored inside its context and those
2034  // declarations that are visible from its context. These blocks
2035  // are written before the declaration itself so that we can put
2036  // their offsets into the record for the declaration.
2037  uint64_t LexicalOffset = 0;
2038  uint64_t VisibleOffset = 0;
2039  DeclContext *DC = dyn_cast<DeclContext>(D);
2040  if (DC) {
2041  if (isReplacingADecl) {
2042  // It is replacing a decl from a chained PCH; make sure that the
2043  // DeclContext is fully loaded.
2044  if (DC->hasExternalLexicalStorage())
2045  DC->LoadLexicalDeclsFromExternalStorage();
2046  if (DC->hasExternalVisibleStorage())
2047  Chain->completeVisibleDeclsMap(DC);
2048  }
2049  LexicalOffset = WriteDeclContextLexicalBlock(Context, DC);
2050  VisibleOffset = WriteDeclContextVisibleBlock(Context, DC);
2051  }
2052 
2053  if (isReplacingADecl) {
2054  // We're replacing a decl in a previous file.
2055  ReplacedDecls.push_back(ReplacedDeclInfo(ID, Stream.GetCurrentBitNo(),
2056  D->getLocation()));
2057  } else {
2058  unsigned Index = ID - FirstDeclID;
2059 
2060  // Record the offset for this declaration
2061  SourceLocation Loc = D->getLocation();
2062  if (DeclOffsets.size() == Index)
2063  DeclOffsets.push_back(DeclOffset(Loc, Stream.GetCurrentBitNo()));
2064  else if (DeclOffsets.size() < Index) {
2065  DeclOffsets.resize(Index+1);
2066  DeclOffsets[Index].setLocation(Loc);
2067  DeclOffsets[Index].BitOffset = Stream.GetCurrentBitNo();
2068  }
2069 
2070  SourceManager &SM = Context.getSourceManager();
2071  if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
2072  associateDeclWithFile(D, ID);
2073  }
2074 
2075  // Build and emit a record for this declaration
2076  Record.clear();
2077  W.Code = (serialization::DeclCode)0;
2078  W.AbbrevToUse = 0;
2079  W.Visit(D);
2080  if (DC) W.VisitDeclContext(DC, LexicalOffset, VisibleOffset);
2081 
2082  if (!W.Code)
2083  llvm::report_fatal_error(StringRef("unexpected declaration kind '") +
2084  D->getDeclKindName() + "'");
2085  Stream.EmitRecord(W.Code, Record, W.AbbrevToUse);
2086 
2087  // Flush any expressions, base specifiers, and ctor initializers that
2088  // were written as part of this declaration.
2089  FlushPendingAfterDecl();
2090 
2091  // Note declarations that should be deserialized eagerly so that we can add
2092  // them to a record in the AST file later.
2093  if (isRequiredDecl(D, Context))
2094  EagerlyDeserializedDecls.push_back(ID);
2095 }
2096 
2097 void ASTWriter::AddFunctionDefinition(const FunctionDecl *FD,
2098  RecordData &Record) {
2099  ClearSwitchCaseIDs();
2100 
2101  ASTDeclWriter W(*this, FD->getASTContext(), Record);
2102  W.AddFunctionDefinition(FD);
2103 }
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.h:2087
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1063
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1081
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
Definition: DeclTemplate.h:454
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition: DeclFriend.h:119
void VisitAccessSpecDecl(AccessSpecDecl *D)
protocol_range protocols() const
Definition: DeclObjC.h:1788
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
void VisitStaticAssertDecl(StaticAssertDecl *D)
void VisitCXXMethodDecl(CXXMethodDecl *D)
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
Definition: ASTCommon.cpp:151
ImplementationControl getImplementationControl() const
Definition: DeclObjC.h:468
unsigned getNumTemplates() const
Returns the number of function templates that this might be a specialization of.
Definition: DeclTemplate.h:575
A TypedefDecl record.
Definition: ASTBitCodes.h:963
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:1982
bool isVariadic() const
Definition: Decl.h:3499
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
unsigned param_size() const
Definition: Decl.h:3510
void VisitRedeclarable(Redeclarable< T > *D)
void VisitEmptyDecl(EmptyDecl *D)
void VisitTypedefNameDecl(TypedefNameDecl *D)
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1106
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:2591
CXXMethodDecl * getSpecialization() const
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:3177
bool isDefined() const
Definition: DeclObjC.h:429
const Expr * getInitExpr() const
Definition: Decl.h:2467
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1195
void VisitCXXRecordDecl(CXXRecordDecl *D)
Defines the SourceManager interface.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1386
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
QualType getUnderlyingType() const
Definition: Decl.h:2616
An ImplicitCastExpr record.
Definition: ASTBitCodes.h:1205
chain_range chain() const
Definition: Decl.h:2510
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1075
param_iterator param_end()
Definition: Decl.h:3525
Defines the C++ template declaration subclasses.
bool hasFlexibleArrayMember() const
Definition: Decl.h:3279
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
Definition: Decl.h:3204
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:1020
Represents an empty-declaration.
Definition: Decl.h:3762
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:62
Declaration of a variable template.
const Expr * getInit() const
Definition: Decl.h:1068
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:400
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:993
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: Decl.h:1390
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:3131
protocol_range protocols() const
Definition: DeclObjC.h:2013
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclBase.h:368
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2147
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
ArrayRef< Decl > getPartialSpecializations(FunctionTemplateDecl::Common *)
FunctionTemplateDecl * getTemplate(unsigned I) const
Returns the i'th template candidate.
Definition: DeclTemplate.h:580
void AddTemplateSpecializations(Decl *D)
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
A ClassTemplateDecl record.
Definition: ASTBitCodes.h:1065
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1044
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:1582
Expr * getSetterCXXAssignment() const
Definition: DeclObjC.h:2716
Declaration of a redeclarable template.
Definition: DeclTemplate.h:612
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
bool capturesCXXThis() const
Definition: Decl.h:3575
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:3187
static bool isRequiredDecl(const Decl *D, ASTContext &Context)
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1038
void VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset, uint64_t VisibleOffset)
Emit the DeclContext part of a declaration context decl.
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2067
AccessSpecifier getAccess() const
Definition: DeclBase.h:416
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1243
Represents a variable template specialization, which refers to a variable template with a given set o...
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
Definition: ASTBitCodes.h:1099
void VisitIndirectFieldDecl(IndirectFieldDecl *D)
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
capture_range captures()
Definition: Decl.h:3563
unsigned param_size() const
Definition: DeclObjC.h:348
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:652
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1083
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1334
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:977
Provides information about a dependent function-template specialization declaration.
Definition: DeclTemplate.h:545
IdentifierInfo * getIdentifier() const
Definition: DeclObjC.h:2179
QualType getType() const
Definition: DeclObjC.h:2505
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:2839
TypeSourceInfo * getTypeSourceInfo() const
Definition: DeclObjC.h:2503
TypeSourceInfo * getFriendType() const
Definition: DeclFriend.h:113
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists...
Definition: ASTContext.h:2236
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1457
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:26
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:3171
method_iterator end_overridden_methods() const
Definition: DeclCXX.cpp:1582
StringLiteral * getMessage()
Definition: DeclCXX.h:3182
CXXRecordDecl * getPreviousDecl()
Definition: DeclCXX.h:658
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:89
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition: DeclBase.h:1716
ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, RecordData &Record)
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition: DeclCXX.h:2733
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2024
bool isCompleteDefinition() const
Definition: Decl.h:2838
ImplicitParamDecl * getCmdDecl() const
Definition: DeclObjC.h:413
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:326
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition: Decl.h:450
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:671
TagKind getTagKind() const
Definition: Decl.h:2897
bool isPreviousDeclInSameBlockScope() const
Definition: Decl.h:1252
param_range params()
Definition: DeclObjC.h:354
TypeSourceInfo * getFriendType() const
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:2628
Stmt * getBody() const override
Definition: Decl.h:3503
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:101
Declaration of a function specialization at template class scope.
unsigned getNumCaptures() const
Definition: Decl.h:3556
bool isThisDeclarationADefinition() const
Definition: Decl.h:2832
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2061
StorageClass getStorageClass() const
Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
Definition: Decl.h:871
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1093
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:371
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Represents a C++ using-declaration.
Definition: DeclCXX.h:2871
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:3648
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Definition: DeclTemplate.h:404
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:897
void VisitLabelDecl(LabelDecl *LD)
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:3247
const LangOptions & getLangOpts() const
Definition: ASTContext.h:533
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1806
bool isImplicit() const
Definition: DeclBase.h:503
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:455
void VisitTypedefDecl(TypedefDecl *D)
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1058
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2065
SourceLocation getRBraceLoc() const
Definition: Decl.h:508
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
void VisitUsingShadowDecl(UsingShadowDecl *D)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1040
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2709
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:569
unsigned getNumTemplateParameters() const
Selector getSetterName() const
Definition: DeclObjC.h:2578
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
SourceLocation getRBraceLoc() const
Definition: Decl.h:2813
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1067
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:1731
DeclContext * getLexicalDeclContext()
Definition: DeclBase.h:697
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember()
Retrieve the member class template partial specialization from which this particular class template p...
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:3616
Represents an ObjC class declaration.
Definition: DeclObjC.h:851
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclObjC.cpp:850
Represents a linkage specification.
Definition: DeclCXX.h:2467
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:2516
QualType getType() const
Definition: Decl.h:538
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2361
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:796
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition: DeclCXX.h:2901
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
SourceLocation getAtLoc() const
Definition: DeclObjC.h:2497
bool isKNRPromoted() const
Definition: Decl.h:1407
unsigned getNumParams() const
Definition: Decl.h:3646
SourceRange getAtEndRange() const
Definition: DeclObjC.h:800
AnnotatingParser & P
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)
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:1877
void VisitObjCContainerDecl(ObjCContainerDecl *D)
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclObjC.h:2675
RecordDecl * getMostRecentDecl()
Definition: Decl.h:3272
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:3579
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:2560
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:2724
Represents a ValueDecl that came out of a declarator. Contains type source information through TypeSo...
Definition: Decl.h:586
unsigned getChainingSize() const
Definition: Decl.h:2516
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
ASTContext * Context
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclObjC.h:269
An EnumDecl record.
Definition: ASTBitCodes.h:967
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:2233
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1087
SourceLocation getSuperClassLoc() const
Definition: DeclObjC.h:2356
ID
Defines the set of possible language-specific address spaces.
Definition: AddressSpaces.h:27
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1073
const CXXMethodDecl *const * method_iterator
Definition: DeclCXX.h:1809
SourceManager & SM
static bool classofKind(Kind K)
Definition: DeclObjC.h:1666
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition: Decl.h:2211
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1110
bool hasDestructors() const
Definition: DeclObjC.h:2324
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:2224
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:4082
const Type * getTypeForDecl() const
Definition: Decl.h:2557
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1451
unsigned param_size() const
Definition: Decl.h:1941
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:987
bool isModed() const
Definition: Decl.h:2609
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:995
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
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2687
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs. The actual template arguments (if any) are stored a...
Definition: TemplateBase.h:575
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Expr * getBitWidth() const
Definition: Decl.h:2344
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:537
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2358
A CXXConstructorDecl record.
Definition: ASTBitCodes.h:1052
Kind getKind() const
Definition: DeclBase.h:375
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:155
DeclContext * getDeclContext()
Definition: DeclBase.h:381
void VisitUsingDecl(UsingDecl *D)
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
const char * getDeclKindName() const
Definition: DeclBase.cpp:87
bool isFailed() const
Definition: DeclCXX.h:3185
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1071
ImplicitParamDecl * getSelfDecl() const
Definition: DeclObjC.h:411
unsigned getContextParamPosition() const
Definition: Decl.h:3667
EnumDecl * getMostRecentDecl()
Definition: Decl.h:3053
bool isObjCMethodParameter() const
Definition: Decl.h:1376
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1054
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:1096
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:731
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3166
Expr * getUninstantiatedDefaultArg()
Definition: Decl.h:1429
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:3405
bool isInstanceMethod() const
Definition: DeclObjC.h:419
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition: Decl.h:1184
A NamespaceAliasDecl record.
Definition: ASTBitCodes.h:1034
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1174
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:624
void AddObjCTypeParamList(ObjCTypeParamList *typeParams)
Add an Objective-C type parameter list to the given record.
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
NamedDecl * getInstantiatedFromUsingDecl(UsingDecl *Inst)
If the given using decl Inst is an instantiation of a (possibly unresolved) using decl from a templat...
DeclarationName getDeclName() const
Definition: Decl.h:189
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1065
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1003
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition: Decl.h:2685
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has. This is not the linkage as defined by the standard or...
Definition: Decl.cpp:1027
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2405
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
An EnumConstantDecl record.
Definition: ASTBitCodes.h:971
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition: Decl.h:1831
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Definition: DeclTemplate.h:414
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
void VisitTagDecl(TagDecl *D)
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace. This is false for non-original (subsequent) namespace declarations and anonymous namespaces.
Definition: Decl.h:483
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1104
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:985
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:2937
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
CXXMethodDecl * getMostRecentDecl()
Definition: DeclCXX.h:1792
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition: DeclObjC.h:344
static DeclType * getDecl(EntryType *D)
Definition: DeclTemplate.h:630
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:148
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2289
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
void VisitMSPropertyDecl(MSPropertyDecl *D)
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:991
void VisitVarTemplateDecl(VarTemplateDecl *D)
AttrVec & getAttrs()
Definition: DeclBase.h:431
void VisitTypeAliasDecl(TypeAliasDecl *D)
param_iterator param_begin()
Definition: Decl.h:3524
bool isEmbeddedInDeclarator() const
Definition: Decl.h:2853
bool isNothrow() const
Definition: Decl.h:3643
Stmt * getBody(const FunctionDecl *&Definition) const
Definition: Decl.cpp:2405
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclBase.h:365
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.h:1367
bool doesThisDeclarationHaveABody() const
Definition: Decl.h:1773
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Definition: DeclTemplate.h:500
An UnresolvedUsingValueDecl record.
Definition: ASTBitCodes.h:1042
SourceLocation getExternLoc() const
Definition: DeclCXX.h:2519
IdentifierInfo * getGetterId() const
Definition: DeclCXX.h:3245
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:136
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:407
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.h:2110
unsigned protocol_size() const
Definition: DeclObjC.h:2020
A record that stores the set of declarations that are visible from a given DeclContext.
Definition: ASTBitCodes.h:1028
method_iterator begin_overridden_methods() const
Definition: DeclCXX.cpp:1577
void VisitObjCImplDecl(ObjCImplDecl *D)
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2409
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:507
bool isValid() const
Return true if this is a valid SourceLocation object.
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2694
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:284
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:1587
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition: DeclCXX.h:2752
bool isVariadic() const
Definition: DeclObjC.h:421
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3017
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:778
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:731
bool getSynthesize() const
Definition: DeclObjC.h:1658
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1717
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
bool blockMissingReturnType() const
Definition: Decl.h:3576
C-style initialization with assignment.
Definition: Decl.h:718
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:1079
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:827
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:3746
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2093
A ObjCMethodDecl record.
Definition: ASTBitCodes.h:975
bool isPropertyAccessor() const
Definition: DeclObjC.h:426
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition: DeclCXX.h:3043
bool hasVolatileMember() const
Definition: Decl.h:3302
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:2297
ThreadStorageClassSpecifier getTSCSpec() const
Definition: Decl.h:880
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:2424
void AddFunctionDefinition(const FunctionDecl *FD)
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:67
QualType getReturnType() const
Definition: DeclObjC.h:330
A NamespaceDecl record.
Definition: ASTBitCodes.h:1032
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3159
bool hasObjectMember() const
Definition: Decl.h:3299
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2186
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
Definition: DeclTemplate.h:597
unsigned varlist_size() const
Definition: DeclOpenMP.h:70
SourceLocation getLParenLoc() const
Definition: DeclObjC.h:2500
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:3704
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition: DeclCXX.h:2624
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:979
param_range params()
Definition: Decl.h:1951
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition: Decl.h:1242
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2576
bool isAnonymousStructOrUnion() const
Definition: Decl.h:3294
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1056
void VisitFieldDecl(FieldDecl *D)
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
Definition: DeclCXX.h:120
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:1994
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition: DeclCXX.h:2923
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition: Decl.cpp:2932
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:311
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:739
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2598
QualType getPromotionType() const
Definition: Decl.h:3107
bool isInvalidDecl() const
Definition: DeclBase.h:498
void VisitNamedDecl(NamedDecl *D)
bool isFreeStanding() const
Definition: Decl.h:2860
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1069
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition: DeclCXX.h:2620
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:961
const llvm::APSInt & getInitVal() const
Definition: Decl.h:2469
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:503
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2508
bool hasWrittenPrototype() const
Definition: Decl.h:1827
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2690
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3100
A ClassScopeFunctionSpecializationDecl record a class scope function specialization. (Microsoft extension).
Definition: ASTBitCodes.h:1102
A MSPropertyDecl record.
Definition: ASTBitCodes.h:999
Selector getGetterName() const
Definition: DeclObjC.h:2575
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
Definition: DeclBase.cpp:305
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1046
decltype(T::PartialSpecializations)& getPartialSpecializations(T *Common)
Get the list of partial specializations from a template's common ptr.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Definition: TemplateBase.h:566
bool hasAttrs() const
Definition: DeclBase.h:427
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1380
SourceLocation getEndOfDefinitionLoc() const
Definition: DeclObjC.h:1542
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:2844
serialization::DeclCode Code
bool hasInheritedDefaultArg() const
Definition: Decl.h:1468
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember()
Retrieve the member variable template partial specialization from which this particular variable temp...
void VisitNamespaceDecl(NamespaceDecl *D)
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:2581
bool hasNonZeroConstructors() const
Definition: DeclObjC.h:2319
void VisitVarDecl(VarDecl *D)
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum. These widths include the rightmost leading 1; that is:
Definition: Decl.h:3158
A FunctionDecl record.
Definition: ASTBitCodes.h:973
NamedDecl * getFriendDecl() const
Definition: DeclFriend.h:126
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member. If the point of instantiation is an invalid...
Definition: DeclTemplate.h:521
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:2584
QualType getIntegerType() const
Definition: Decl.h:3115
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:592
DeclContext * getRedeclContext()
Definition: DeclBase.cpp:1466
SourceLocation getRBraceLoc() const
Definition: DeclCXX.h:2520
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:2908
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
Definition: Decl.h:1202
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1173
unsigned protocol_size() const
Definition: DeclObjC.h:1821
protocol_range protocols() const
Definition: DeclObjC.h:1038
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
void VisitFunctionDecl(FunctionDecl *D)
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition: Decl.h:982
const CXXConstructorDecl * getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition: DeclCXX.cpp:1876
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition: DeclCXX.h:3127
SourceManager & getSourceManager()
Definition: ASTContext.h:494
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement...
Definition: Decl.h:1212
static bool classofKind(Kind K)
Definition: DeclCXX.h:1703
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
void VisitDecl(Decl *D)
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2678
AccessControl getAccessControl() const
Definition: DeclObjC.h:1651
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:1698
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.h:2131
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:1679
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:340
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable. A pseudo-__strong variable has a ...
Definition: Decl.h:1224
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:3141
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:285
TypeSourceInfo * getSignatureAsWritten() const
Definition: Decl.h:3507
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:417
virtual bool isOutOfLine() const
Definition: Decl.cpp:43
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3131
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:231
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:481
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:989
void VisitEnumConstantDecl(EnumConstantDecl *D)
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:983
Declaration of a class template.
void VisitCXXConversionDecl(CXXConversionDecl *D)
DeclaratorDecl * getDeclaratorForAnonDecl() const
Definition: Decl.h:2932
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1233
void VisitClassScopeFunctionSpecializationDecl(ClassScopeFunctionSpecializationDecl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:335
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.
A TypeAliasDecl record.
Definition: ASTBitCodes.h:965
const FunctionDecl * getOperatorDelete() const
Definition: DeclCXX.h:2383
TemplateParameterList * getTemplateParameterList(unsigned i) const
PropertyAttributeKind getPropertyAttributesAsWritten() const
Definition: DeclObjC.h:2523
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:739
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2363
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:158
void VisitFriendDecl(FriendDecl *D)
TranslationUnitDecl - The top declaration context.
Definition: Decl.h:78
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:2598
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
Definition: Decl.h:487
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.h:1347
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
Definition: Decl.h:1137
NamedDecl * getMostRecentDecl()
Definition: Decl.h:330
DeclContext * getPrimaryContext()
Definition: DeclBase.cpp:920
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1077
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3053
SourceLocation getInnerLocStart() const
Definition: Decl.h:625
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1085
void VisitImportDecl(ImportDecl *D)
varlist_range varlists()
Definition: DeclOpenMP.h:73
static bool isFirstLocalDecl(Redeclarable< T > *D)
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.h:1149
SourceLocation getLocation() const
Definition: DeclBase.h:372
Represents a C++ namespace alias.
Definition: DeclCXX.h:2662
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:2559
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:2611
void VisitObjCMethodDecl(ObjCMethodDecl *D)
This represents '#pragma omp threadprivate ...' directive. For example, in the following, both 'a' and 'A::b' are threadprivate:
Definition: DeclOpenMP.h:36
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
Definition: DeclBase.h:552
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:821
Source range/offset of a preprocessed entity.
Definition: ASTBitCodes.h:183
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:2779
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:2749
void VisitObjCIvarDecl(ObjCIvarDecl *D)
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2327
bool hasInClassInitializer() const
Definition: Decl.h:2377
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
Definition: DeclBase.h:1726
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2354
const StringLiteral * getAsmString() const
Definition: Decl.h:3411