clang  3.8.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  /// Add to the record the first declaration from each module file that
163  /// provides a declaration of D. The intent is to provide a sufficient
164  /// set such that reloading this set will load all current redeclarations.
165  void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
166  llvm::MapVector<ModuleFile*, const Decl*> Firsts;
167  // FIXME: We can skip entries that we know are implied by others.
168  for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) {
169  if (R->isFromASTFile())
170  Firsts[Writer.Chain->getOwningModuleFile(R)] = R;
171  else if (IncludeLocal)
172  Firsts[nullptr] = R;
173  }
174  for (const auto &F : Firsts)
175  Writer.AddDeclRef(F.second, Record);
176  }
177 
178  /// Get the specialization decl from an entry in the specialization list.
179  template <typename EntryType>
181  getSpecializationDecl(EntryType &T) {
183  }
184 
185  /// Get the list of partial specializations from a template's common ptr.
186  template<typename T>
187  decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) {
188  return Common->PartialSpecializations;
189  }
191  return None;
192  }
193 
194  template<typename Decl>
196  auto *Common = D->getCommonPtr();
197 
198  // If we have any lazy specializations, and the external AST source is
199  // our chained AST reader, we can just write out the DeclIDs. Otherwise,
200  // we need to resolve them to actual declarations.
201  if (Writer.Chain != Writer.Context->getExternalSource() &&
202  Common->LazySpecializations) {
203  D->LoadLazySpecializations();
204  assert(!Common->LazySpecializations);
205  }
206 
207  auto &Specializations = Common->Specializations;
208  auto &&PartialSpecializations = getPartialSpecializations(Common);
209  ArrayRef<DeclID> LazySpecializations;
210  if (auto *LS = Common->LazySpecializations)
211  LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]);
212 
213  // Add a slot to the record for the number of specializations.
214  unsigned I = Record.size();
215  Record.push_back(0);
216 
217  for (auto &Entry : Specializations) {
218  auto *D = getSpecializationDecl(Entry);
219  assert(D->isCanonicalDecl() && "non-canonical decl in set");
220  AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
221  }
222  for (auto &Entry : PartialSpecializations) {
223  auto *D = getSpecializationDecl(Entry);
224  assert(D->isCanonicalDecl() && "non-canonical decl in set");
225  AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
226  }
227  Record.append(LazySpecializations.begin(), LazySpecializations.end());
228 
229  // Update the size entry we added earlier.
230  Record[I] = Record.size() - I - 1;
231  }
232 
233  /// Ensure that this template specialization is associated with the specified
234  /// template on reload.
235  void RegisterTemplateSpecialization(const Decl *Template,
236  const Decl *Specialization) {
237  Template = Template->getCanonicalDecl();
238 
239  // If the canonical template is local, we'll write out this specialization
240  // when we emit it.
241  // FIXME: We can do the same thing if there is any local declaration of
242  // the template, to avoid emitting an update record.
243  if (!Template->isFromASTFile())
244  return;
245 
246  // We only need to associate the first local declaration of the
247  // specialization. The other declarations will get pulled in by it.
248  if (Writer.getFirstLocalDecl(Specialization) != Specialization)
249  return;
250 
251  Writer.DeclUpdates[Template].push_back(ASTWriter::DeclUpdate(
252  UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION, Specialization));
253  }
254  };
255 }
256 
259 
260  // Source locations require array (variable-length) abbreviations. The
261  // abbreviation infrastructure requires that arrays are encoded last, so
262  // we handle it here in the case of those classes derived from DeclaratorDecl
263  if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
264  Writer.AddTypeSourceInfo(DD->getTypeSourceInfo(), Record);
265  }
266 
267  // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
268  // have been written. We want it last because we will not read it back when
269  // retrieving it from the AST, we'll just lazily set the offset.
270  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
271  Record.push_back(FD->doesThisDeclarationHaveABody());
272  if (FD->doesThisDeclarationHaveABody())
273  AddFunctionDefinition(FD);
274  }
275 }
276 
278  Writer.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()), Record);
279  if (D->getDeclContext() != D->getLexicalDeclContext())
280  Writer.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()), Record);
281  else
282  Record.push_back(0);
283  Record.push_back(D->isInvalidDecl());
284  Record.push_back(D->hasAttrs());
285  if (D->hasAttrs())
286  Writer.WriteAttributes(llvm::makeArrayRef(D->getAttrs().begin(),
287  D->getAttrs().size()), Record);
288  Record.push_back(D->isImplicit());
289  Record.push_back(D->isUsed(false));
290  Record.push_back(D->isReferenced());
291  Record.push_back(D->isTopLevelDeclInObjCContainer());
292  Record.push_back(D->getAccess());
293  Record.push_back(D->isModulePrivate());
294  Record.push_back(Writer.inferSubmoduleIDFromLocation(D->getLocation()));
295 
296  // If this declaration injected a name into a context different from its
297  // lexical context, and that context is an imported namespace, we need to
298  // update its visible declarations to include this name.
299  //
300  // This happens when we instantiate a class with a friend declaration or a
301  // function with a local extern declaration, for instance.
302  //
303  // FIXME: Can we handle this in AddedVisibleDecl instead?
304  if (D->isOutOfLine()) {
305  auto *DC = D->getDeclContext();
306  while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
307  if (!NS->isFromASTFile())
308  break;
309  Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
310  if (!NS->isInlineNamespace())
311  break;
312  DC = NS->getParent();
313  }
314  }
315 }
316 
318  llvm_unreachable("Translation units aren't directly serialized");
319 }
320 
322  VisitDecl(D);
323  Writer.AddDeclarationName(D->getDeclName(), Record);
324  Record.push_back(needsAnonymousDeclarationNumber(D)
325  ? Writer.getAnonymousDeclarationNumber(D)
326  : 0);
327 }
328 
330  VisitNamedDecl(D);
331  Writer.AddSourceLocation(D->getLocStart(), Record);
332  Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);
333 }
334 
336  VisitRedeclarable(D);
337  VisitTypeDecl(D);
338  Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);
339  Record.push_back(D->isModed());
340  if (D->isModed())
341  Writer.AddTypeRef(D->getUnderlyingType(), Record);
342 }
343 
345  VisitTypedefNameDecl(D);
346  if (D->getDeclContext() == D->getLexicalDeclContext() &&
347  !D->hasAttrs() &&
348  !D->isImplicit() &&
349  D->getFirstDecl() == D->getMostRecentDecl() &&
350  !D->isInvalidDecl() &&
352  !D->isModulePrivate() &&
355  AbbrevToUse = Writer.getDeclTypedefAbbrev();
356 
358 }
359 
361  VisitTypedefNameDecl(D);
362  Writer.AddDeclRef(D->getDescribedAliasTemplate(), Record);
364 }
365 
367  VisitRedeclarable(D);
368  VisitTypeDecl(D);
369  Record.push_back(D->getIdentifierNamespace());
370  Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
371  if (!isa<CXXRecordDecl>(D))
372  Record.push_back(D->isCompleteDefinition());
373  Record.push_back(D->isEmbeddedInDeclarator());
374  Record.push_back(D->isFreeStanding());
375  Record.push_back(D->isCompleteDefinitionRequired());
376  Writer.AddSourceLocation(D->getRBraceLoc(), Record);
377 
378  if (D->hasExtInfo()) {
379  Record.push_back(1);
380  Writer.AddQualifierInfo(*D->getExtInfo(), Record);
381  } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
382  Record.push_back(2);
383  Writer.AddDeclRef(TD, Record);
384  Writer.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo(), Record);
385  } else {
386  Record.push_back(0);
387  }
388 }
389 
391  VisitTagDecl(D);
392  Writer.AddTypeSourceInfo(D->getIntegerTypeSourceInfo(), Record);
393  if (!D->getIntegerTypeSourceInfo())
394  Writer.AddTypeRef(D->getIntegerType(), Record);
395  Writer.AddTypeRef(D->getPromotionType(), Record);
396  Record.push_back(D->getNumPositiveBits());
397  Record.push_back(D->getNumNegativeBits());
398  Record.push_back(D->isScoped());
399  Record.push_back(D->isScopedUsingClassTag());
400  Record.push_back(D->isFixed());
401  if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) {
402  Writer.AddDeclRef(MemberInfo->getInstantiatedFrom(), Record);
403  Record.push_back(MemberInfo->getTemplateSpecializationKind());
404  Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record);
405  } else {
406  Writer.AddDeclRef(nullptr, Record);
407  }
408 
409  if (D->getDeclContext() == D->getLexicalDeclContext() &&
410  !D->hasAttrs() &&
411  !D->isImplicit() &&
412  !D->isUsed(false) &&
413  !D->hasExtInfo() &&
415  D->getFirstDecl() == D->getMostRecentDecl() &&
416  !D->isInvalidDecl() &&
417  !D->isReferenced() &&
419  D->getAccess() == AS_none &&
420  !D->isModulePrivate() &&
422  !D->getIntegerTypeSourceInfo() &&
426  AbbrevToUse = Writer.getDeclEnumAbbrev();
427 
429 }
430 
432  VisitTagDecl(D);
433  Record.push_back(D->hasFlexibleArrayMember());
434  Record.push_back(D->isAnonymousStructOrUnion());
435  Record.push_back(D->hasObjectMember());
436  Record.push_back(D->hasVolatileMember());
437 
438  if (D->getDeclContext() == D->getLexicalDeclContext() &&
439  !D->hasAttrs() &&
440  !D->isImplicit() &&
441  !D->isUsed(false) &&
442  !D->hasExtInfo() &&
444  D->getFirstDecl() == D->getMostRecentDecl() &&
445  !D->isInvalidDecl() &&
446  !D->isReferenced() &&
448  D->getAccess() == AS_none &&
449  !D->isModulePrivate() &&
453  AbbrevToUse = Writer.getDeclRecordAbbrev();
454 
456 }
457 
459  VisitNamedDecl(D);
460  Writer.AddTypeRef(D->getType(), Record);
461 }
462 
464  VisitValueDecl(D);
465  Record.push_back(D->getInitExpr()? 1 : 0);
466  if (D->getInitExpr())
467  Writer.AddStmt(D->getInitExpr());
468  Writer.AddAPSInt(D->getInitVal(), Record);
469 
471 }
472 
474  VisitValueDecl(D);
475  Writer.AddSourceLocation(D->getInnerLocStart(), Record);
476  Record.push_back(D->hasExtInfo());
477  if (D->hasExtInfo())
478  Writer.AddQualifierInfo(*D->getExtInfo(), Record);
479 }
480 
482  VisitRedeclarable(D);
483  VisitDeclaratorDecl(D);
484  Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
485  Record.push_back(D->getIdentifierNamespace());
486 
487  // FunctionDecl's body is handled last at ASTWriterDecl::Visit,
488  // after everything else is written.
489 
490  Record.push_back((int)D->SClass); // FIXME: stable encoding
491  Record.push_back(D->IsInline);
492  Record.push_back(D->IsInlineSpecified);
493  Record.push_back(D->IsVirtualAsWritten);
494  Record.push_back(D->IsPure);
495  Record.push_back(D->HasInheritedPrototype);
496  Record.push_back(D->HasWrittenPrototype);
497  Record.push_back(D->IsDeleted);
498  Record.push_back(D->IsTrivial);
499  Record.push_back(D->IsDefaulted);
500  Record.push_back(D->IsExplicitlyDefaulted);
501  Record.push_back(D->HasImplicitReturnZero);
502  Record.push_back(D->IsConstexpr);
503  Record.push_back(D->HasSkippedBody);
504  Record.push_back(D->IsLateTemplateParsed);
505  Record.push_back(D->getLinkageInternal());
506  Writer.AddSourceLocation(D->getLocEnd(), Record);
507 
508  Record.push_back(D->getTemplatedKind());
509  switch (D->getTemplatedKind()) {
511  break;
513  Writer.AddDeclRef(D->getDescribedFunctionTemplate(), Record);
514  break;
517  Writer.AddDeclRef(MemberInfo->getInstantiatedFrom(), Record);
518  Record.push_back(MemberInfo->getTemplateSpecializationKind());
519  Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record);
520  break;
521  }
524  FTSInfo = D->getTemplateSpecializationInfo();
525 
526  RegisterTemplateSpecialization(FTSInfo->getTemplate(), D);
527 
528  Writer.AddDeclRef(FTSInfo->getTemplate(), Record);
529  Record.push_back(FTSInfo->getTemplateSpecializationKind());
530 
531  // Template arguments.
532  Writer.AddTemplateArgumentList(FTSInfo->TemplateArguments, Record);
533 
534  // Template args as written.
535  Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
536  if (FTSInfo->TemplateArgumentsAsWritten) {
537  Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs);
538  for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs;
539  i!=e; ++i)
540  Writer.AddTemplateArgumentLoc((*FTSInfo->TemplateArgumentsAsWritten)[i],
541  Record);
542  Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc,
543  Record);
544  Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc,
545  Record);
546  }
547 
548  Writer.AddSourceLocation(FTSInfo->getPointOfInstantiation(), Record);
549 
550  if (D->isCanonicalDecl()) {
551  // Write the template that contains the specializations set. We will
552  // add a FunctionTemplateSpecializationInfo to it when reading.
553  Writer.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl(), Record);
554  }
555  break;
556  }
559  DFTSInfo = D->getDependentSpecializationInfo();
560 
561  // Templates.
562  Record.push_back(DFTSInfo->getNumTemplates());
563  for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i)
564  Writer.AddDeclRef(DFTSInfo->getTemplate(i), Record);
565 
566  // Templates args.
567  Record.push_back(DFTSInfo->getNumTemplateArgs());
568  for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i)
569  Writer.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i), Record);
570  Writer.AddSourceLocation(DFTSInfo->getLAngleLoc(), Record);
571  Writer.AddSourceLocation(DFTSInfo->getRAngleLoc(), Record);
572  break;
573  }
574  }
575 
576  Record.push_back(D->param_size());
577  for (auto P : D->params())
578  Writer.AddDeclRef(P, Record);
580 }
581 
583  VisitNamedDecl(D);
584  // FIXME: convert to LazyStmtPtr?
585  // Unlike C/C++, method bodies will never be in header files.
586  bool HasBodyStuff = D->getBody() != nullptr ||
587  D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr;
588  Record.push_back(HasBodyStuff);
589  if (HasBodyStuff) {
590  Writer.AddStmt(D->getBody());
591  Writer.AddDeclRef(D->getSelfDecl(), Record);
592  Writer.AddDeclRef(D->getCmdDecl(), Record);
593  }
594  Record.push_back(D->isInstanceMethod());
595  Record.push_back(D->isVariadic());
596  Record.push_back(D->isPropertyAccessor());
597  Record.push_back(D->isDefined());
598  Record.push_back(D->IsOverriding);
599  Record.push_back(D->HasSkippedBody);
600 
601  Record.push_back(D->IsRedeclaration);
602  Record.push_back(D->HasRedeclaration);
603  if (D->HasRedeclaration) {
605  Writer.AddDeclRef(Context.getObjCMethodRedeclaration(D), Record);
606  }
607 
608  // FIXME: stable encoding for @required/@optional
609  Record.push_back(D->getImplementationControl());
610  // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
611  Record.push_back(D->getObjCDeclQualifier());
612  Record.push_back(D->hasRelatedResultType());
613  Writer.AddTypeRef(D->getReturnType(), Record);
614  Writer.AddTypeSourceInfo(D->getReturnTypeSourceInfo(), Record);
615  Writer.AddSourceLocation(D->getLocEnd(), Record);
616  Record.push_back(D->param_size());
617  for (const auto *P : D->params())
618  Writer.AddDeclRef(P, Record);
619 
620  Record.push_back(D->SelLocsKind);
621  unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
622  SourceLocation *SelLocs = D->getStoredSelLocs();
623  Record.push_back(NumStoredSelLocs);
624  for (unsigned i = 0; i != NumStoredSelLocs; ++i)
625  Writer.AddSourceLocation(SelLocs[i], Record);
626 
628 }
629 
631  VisitTypedefNameDecl(D);
632  Record.push_back(D->Variance);
633  Record.push_back(D->Index);
634  Writer.AddSourceLocation(D->VarianceLoc, Record);
635  Writer.AddSourceLocation(D->ColonLoc, Record);
636 
638 }
639 
641  VisitNamedDecl(D);
642  Writer.AddSourceLocation(D->getAtStartLoc(), Record);
643  Writer.AddSourceRange(D->getAtEndRange(), Record);
644  // Abstract class (no need to define a stable serialization::DECL code).
645 }
646 
648  VisitRedeclarable(D);
649  VisitObjCContainerDecl(D);
650  Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);
651  AddObjCTypeParamList(D->TypeParamList);
652 
653  Record.push_back(D->isThisDeclarationADefinition());
654  if (D->isThisDeclarationADefinition()) {
655  // Write the DefinitionData
656  ObjCInterfaceDecl::DefinitionData &Data = D->data();
657 
658  Writer.AddTypeSourceInfo(D->getSuperClassTInfo(), Record);
659  Writer.AddSourceLocation(D->getEndOfDefinitionLoc(), Record);
660  Record.push_back(Data.HasDesignatedInitializers);
661 
662  // Write out the protocols that are directly referenced by the @interface.
663  Record.push_back(Data.ReferencedProtocols.size());
664  for (const auto *P : D->protocols())
665  Writer.AddDeclRef(P, Record);
666  for (const auto &PL : D->protocol_locs())
667  Writer.AddSourceLocation(PL, Record);
668 
669  // Write out the protocols that are transitively referenced.
670  Record.push_back(Data.AllReferencedProtocols.size());
672  P = Data.AllReferencedProtocols.begin(),
673  PEnd = Data.AllReferencedProtocols.end();
674  P != PEnd; ++P)
675  Writer.AddDeclRef(*P, Record);
676 
677 
678  if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
679  // Ensure that we write out the set of categories for this class.
680  Writer.ObjCClassesWithCategories.insert(D);
681 
682  // Make sure that the categories get serialized.
683  for (; Cat; Cat = Cat->getNextClassCategoryRaw())
684  (void)Writer.GetDeclRef(Cat);
685  }
686  }
687 
689 }
690 
692  VisitFieldDecl(D);
693  // FIXME: stable encoding for @public/@private/@protected/@package
694  Record.push_back(D->getAccessControl());
695  Record.push_back(D->getSynthesize());
696 
697  if (D->getDeclContext() == D->getLexicalDeclContext() &&
698  !D->hasAttrs() &&
699  !D->isImplicit() &&
700  !D->isUsed(false) &&
701  !D->isInvalidDecl() &&
702  !D->isReferenced() &&
703  !D->isModulePrivate() &&
704  !D->getBitWidth() &&
705  !D->hasExtInfo() &&
706  D->getDeclName())
707  AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
708 
710 }
711 
713  VisitRedeclarable(D);
714  VisitObjCContainerDecl(D);
715 
716  Record.push_back(D->isThisDeclarationADefinition());
717  if (D->isThisDeclarationADefinition()) {
718  Record.push_back(D->protocol_size());
719  for (const auto *I : D->protocols())
720  Writer.AddDeclRef(I, Record);
721  for (const auto &PL : D->protocol_locs())
722  Writer.AddSourceLocation(PL, Record);
723  }
724 
726 }
727 
729  VisitFieldDecl(D);
731 }
732 
734  VisitObjCContainerDecl(D);
735  Writer.AddSourceLocation(D->getCategoryNameLoc(), Record);
736  Writer.AddSourceLocation(D->getIvarLBraceLoc(), Record);
737  Writer.AddSourceLocation(D->getIvarRBraceLoc(), Record);
738  Writer.AddDeclRef(D->getClassInterface(), Record);
739  AddObjCTypeParamList(D->TypeParamList);
740  Record.push_back(D->protocol_size());
741  for (const auto *I : D->protocols())
742  Writer.AddDeclRef(I, Record);
743  for (const auto &PL : D->protocol_locs())
744  Writer.AddSourceLocation(PL, Record);
746 }
747 
749  VisitNamedDecl(D);
750  Writer.AddDeclRef(D->getClassInterface(), Record);
752 }
753 
755  VisitNamedDecl(D);
756  Writer.AddSourceLocation(D->getAtLoc(), Record);
757  Writer.AddSourceLocation(D->getLParenLoc(), Record);
758  Writer.AddTypeRef(D->getType(), Record);
759  Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);
760  // FIXME: stable encoding
761  Record.push_back((unsigned)D->getPropertyAttributes());
762  Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
763  // FIXME: stable encoding
764  Record.push_back((unsigned)D->getPropertyImplementation());
765  Writer.AddDeclarationName(D->getGetterName(), Record);
766  Writer.AddDeclarationName(D->getSetterName(), Record);
767  Writer.AddDeclRef(D->getGetterMethodDecl(), Record);
768  Writer.AddDeclRef(D->getSetterMethodDecl(), Record);
769  Writer.AddDeclRef(D->getPropertyIvarDecl(), Record);
771 }
772 
774  VisitObjCContainerDecl(D);
775  Writer.AddDeclRef(D->getClassInterface(), Record);
776  // Abstract class (no need to define a stable serialization::DECL code).
777 }
778 
780  VisitObjCImplDecl(D);
781  Writer.AddIdentifierRef(D->getIdentifier(), Record);
782  Writer.AddSourceLocation(D->getCategoryNameLoc(), Record);
784 }
785 
787  VisitObjCImplDecl(D);
788  Writer.AddDeclRef(D->getSuperClass(), Record);
789  Writer.AddSourceLocation(D->getSuperClassLoc(), Record);
790  Writer.AddSourceLocation(D->getIvarLBraceLoc(), Record);
791  Writer.AddSourceLocation(D->getIvarRBraceLoc(), Record);
792  Record.push_back(D->hasNonZeroConstructors());
793  Record.push_back(D->hasDestructors());
794  Record.push_back(D->NumIvarInitializers);
795  if (D->NumIvarInitializers)
796  Writer.AddCXXCtorInitializersRef(
797  llvm::makeArrayRef(D->init_begin(), D->init_end()), Record);
799 }
800 
802  VisitDecl(D);
803  Writer.AddSourceLocation(D->getLocStart(), Record);
804  Writer.AddDeclRef(D->getPropertyDecl(), Record);
805  Writer.AddDeclRef(D->getPropertyIvarDecl(), Record);
806  Writer.AddSourceLocation(D->getPropertyIvarDeclLoc(), Record);
807  Writer.AddStmt(D->getGetterCXXConstructor());
808  Writer.AddStmt(D->getSetterCXXAssignment());
810 }
811 
813  VisitDeclaratorDecl(D);
814  Record.push_back(D->isMutable());
815  if (D->InitStorage.getInt() == FieldDecl::ISK_BitWidthOrNothing &&
816  D->InitStorage.getPointer() == nullptr) {
817  Record.push_back(0);
818  } else if (D->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
819  Record.push_back(D->InitStorage.getInt() + 1);
820  Writer.AddTypeRef(
821  QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0),
822  Record);
823  } else {
824  Record.push_back(D->InitStorage.getInt() + 1);
825  Writer.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer()));
826  }
827  if (!D->getDeclName())
828  Writer.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D), Record);
829 
830  if (D->getDeclContext() == D->getLexicalDeclContext() &&
831  !D->hasAttrs() &&
832  !D->isImplicit() &&
833  !D->isUsed(false) &&
834  !D->isInvalidDecl() &&
835  !D->isReferenced() &&
837  !D->isModulePrivate() &&
838  !D->getBitWidth() &&
839  !D->hasInClassInitializer() &&
840  !D->hasExtInfo() &&
843  D->getDeclName())
844  AbbrevToUse = Writer.getDeclFieldAbbrev();
845 
847 }
848 
850  VisitDeclaratorDecl(D);
851  Writer.AddIdentifierRef(D->getGetterId(), Record);
852  Writer.AddIdentifierRef(D->getSetterId(), Record);
854 }
855 
857  VisitValueDecl(D);
858  Record.push_back(D->getChainingSize());
859 
860  for (const auto *P : D->chain())
861  Writer.AddDeclRef(P, Record);
863 }
864 
866  VisitRedeclarable(D);
867  VisitDeclaratorDecl(D);
868  Record.push_back(D->getStorageClass());
869  Record.push_back(D->getTSCSpec());
870  Record.push_back(D->getInitStyle());
871  if (!isa<ParmVarDecl>(D)) {
872  Record.push_back(D->isExceptionVariable());
873  Record.push_back(D->isNRVOVariable());
874  Record.push_back(D->isCXXForRangeDecl());
875  Record.push_back(D->isARCPseudoStrong());
876  Record.push_back(D->isConstexpr());
877  Record.push_back(D->isInitCapture());
878  Record.push_back(D->isPreviousDeclInSameBlockScope());
879  }
880  Record.push_back(D->getLinkageInternal());
881 
882  if (D->getInit()) {
883  Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2));
884  Writer.AddStmt(D->getInit());
885  } else {
886  Record.push_back(0);
887  }
888 
889  enum {
890  VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
891  };
892  if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
893  Record.push_back(VarTemplate);
894  Writer.AddDeclRef(TemplD, Record);
895  } else if (MemberSpecializationInfo *SpecInfo
897  Record.push_back(StaticDataMemberSpecialization);
898  Writer.AddDeclRef(SpecInfo->getInstantiatedFrom(), Record);
899  Record.push_back(SpecInfo->getTemplateSpecializationKind());
900  Writer.AddSourceLocation(SpecInfo->getPointOfInstantiation(), Record);
901  } else {
902  Record.push_back(VarNotTemplate);
903  }
904 
905  if (D->getDeclContext() == D->getLexicalDeclContext() &&
906  !D->hasAttrs() &&
907  !D->isImplicit() &&
908  !D->isUsed(false) &&
909  !D->isInvalidDecl() &&
910  !D->isReferenced() &&
912  D->getAccess() == AS_none &&
913  !D->isModulePrivate() &&
916  !D->hasExtInfo() &&
917  D->getFirstDecl() == D->getMostRecentDecl() &&
918  D->getInitStyle() == VarDecl::CInit &&
919  D->getInit() == nullptr &&
920  !isa<ParmVarDecl>(D) &&
921  !isa<VarTemplateSpecializationDecl>(D) &&
922  !D->isConstexpr() &&
923  !D->isInitCapture() &&
926  AbbrevToUse = Writer.getDeclVarAbbrev();
927 
929 }
930 
932  VisitVarDecl(D);
934 }
935 
937  VisitVarDecl(D);
938  Record.push_back(D->isObjCMethodParameter());
939  Record.push_back(D->getFunctionScopeDepth());
940  Record.push_back(D->getFunctionScopeIndex());
941  Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding
942  Record.push_back(D->isKNRPromoted());
943  Record.push_back(D->hasInheritedDefaultArg());
944  Record.push_back(D->hasUninstantiatedDefaultArg());
946  Writer.AddStmt(D->getUninstantiatedDefaultArg());
948 
949  assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
950 
951  // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
952  // we dynamically check for the properties that we optimize for, but don't
953  // know are true of all PARM_VAR_DECLs.
954  if (D->getDeclContext() == D->getLexicalDeclContext() &&
955  !D->hasAttrs() &&
956  !D->hasExtInfo() &&
957  !D->isImplicit() &&
958  !D->isUsed(false) &&
959  !D->isInvalidDecl() &&
960  !D->isReferenced() &&
961  D->getAccess() == AS_none &&
962  !D->isModulePrivate() &&
963  D->getStorageClass() == 0 &&
964  D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
965  D->getFunctionScopeDepth() == 0 &&
966  D->getObjCDeclQualifier() == 0 &&
967  !D->isKNRPromoted() &&
968  !D->hasInheritedDefaultArg() &&
969  D->getInit() == nullptr &&
970  !D->hasUninstantiatedDefaultArg()) // No default expr.
971  AbbrevToUse = Writer.getDeclParmVarAbbrev();
972 
973  // Check things we know are true of *every* PARM_VAR_DECL, which is more than
974  // just us assuming it.
975  assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
976  assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
977  assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
978  assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
979  assert(!D->isStaticDataMember() &&
980  "PARM_VAR_DECL can't be static data member");
981 }
982 
984  VisitDecl(D);
985  Writer.AddStmt(D->getAsmString());
986  Writer.AddSourceLocation(D->getRParenLoc(), Record);
988 }
989 
991  VisitDecl(D);
993 }
994 
996  VisitDecl(D);
997  Writer.AddStmt(D->getBody());
998  Writer.AddTypeSourceInfo(D->getSignatureAsWritten(), Record);
999  Record.push_back(D->param_size());
1000  for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end();
1001  P != PEnd; ++P)
1002  Writer.AddDeclRef(*P, Record);
1003  Record.push_back(D->isVariadic());
1004  Record.push_back(D->blockMissingReturnType());
1005  Record.push_back(D->isConversionFromLambda());
1006  Record.push_back(D->capturesCXXThis());
1007  Record.push_back(D->getNumCaptures());
1008  for (const auto &capture : D->captures()) {
1009  Writer.AddDeclRef(capture.getVariable(), Record);
1010 
1011  unsigned flags = 0;
1012  if (capture.isByRef()) flags |= 1;
1013  if (capture.isNested()) flags |= 2;
1014  if (capture.hasCopyExpr()) flags |= 4;
1015  Record.push_back(flags);
1016 
1017  if (capture.hasCopyExpr()) Writer.AddStmt(capture.getCopyExpr());
1018  }
1019 
1021 }
1022 
1024  Record.push_back(CD->getNumParams());
1025  VisitDecl(CD);
1026  Record.push_back(CD->getContextParamPosition());
1027  Record.push_back(CD->isNothrow() ? 1 : 0);
1028  // Body is stored by VisitCapturedStmt.
1029  for (unsigned I = 0; I < CD->getNumParams(); ++I)
1030  Writer.AddDeclRef(CD->getParam(I), Record);
1032 }
1033 
1035  VisitDecl(D);
1036  Record.push_back(D->getLanguage());
1037  Writer.AddSourceLocation(D->getExternLoc(), Record);
1038  Writer.AddSourceLocation(D->getRBraceLoc(), Record);
1040 }
1041 
1043  VisitNamedDecl(D);
1044  Writer.AddSourceLocation(D->getLocStart(), Record);
1046 }
1047 
1048 
1050  VisitRedeclarable(D);
1051  VisitNamedDecl(D);
1052  Record.push_back(D->isInline());
1053  Writer.AddSourceLocation(D->getLocStart(), Record);
1054  Writer.AddSourceLocation(D->getRBraceLoc(), Record);
1055 
1056  if (D->isOriginalNamespace())
1057  Writer.AddDeclRef(D->getAnonymousNamespace(), Record);
1059 
1060  if (Writer.hasChain() && D->isAnonymousNamespace() &&
1061  D == D->getMostRecentDecl()) {
1062  // This is a most recent reopening of the anonymous namespace. If its parent
1063  // is in a previous PCH (or is the TU), mark that parent for update, because
1064  // the original namespace always points to the latest re-opening of its
1065  // anonymous namespace.
1066  Decl *Parent = cast<Decl>(
1068  if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1069  Writer.DeclUpdates[Parent].push_back(
1070  ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D));
1071  }
1072  }
1073 }
1074 
1076  VisitRedeclarable(D);
1077  VisitNamedDecl(D);
1078  Writer.AddSourceLocation(D->getNamespaceLoc(), Record);
1079  Writer.AddSourceLocation(D->getTargetNameLoc(), Record);
1080  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1081  Writer.AddDeclRef(D->getNamespace(), Record);
1083 }
1084 
1086  VisitNamedDecl(D);
1087  Writer.AddSourceLocation(D->getUsingLoc(), Record);
1088  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1089  Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
1090  Writer.AddDeclRef(D->FirstUsingShadow.getPointer(), Record);
1091  Record.push_back(D->hasTypename());
1092  Writer.AddDeclRef(Context.getInstantiatedFromUsingDecl(D), Record);
1094 }
1095 
1097  VisitRedeclarable(D);
1098  VisitNamedDecl(D);
1099  Writer.AddDeclRef(D->getTargetDecl(), Record);
1100  Writer.AddDeclRef(D->UsingOrNextShadow, Record);
1101  Writer.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D), Record);
1103 }
1104 
1106  VisitNamedDecl(D);
1107  Writer.AddSourceLocation(D->getUsingLoc(), Record);
1108  Writer.AddSourceLocation(D->getNamespaceKeyLocation(), Record);
1109  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1110  Writer.AddDeclRef(D->getNominatedNamespace(), Record);
1111  Writer.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()), Record);
1113 }
1114 
1116  VisitValueDecl(D);
1117  Writer.AddSourceLocation(D->getUsingLoc(), Record);
1118  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1119  Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
1121 }
1122 
1125  VisitTypeDecl(D);
1126  Writer.AddSourceLocation(D->getTypenameLoc(), Record);
1127  Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
1129 }
1130 
1132  VisitRecordDecl(D);
1133 
1134  enum {
1135  CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1136  };
1137  if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1138  Record.push_back(CXXRecTemplate);
1139  Writer.AddDeclRef(TemplD, Record);
1140  } else if (MemberSpecializationInfo *MSInfo
1141  = D->getMemberSpecializationInfo()) {
1142  Record.push_back(CXXRecMemberSpecialization);
1143  Writer.AddDeclRef(MSInfo->getInstantiatedFrom(), Record);
1144  Record.push_back(MSInfo->getTemplateSpecializationKind());
1145  Writer.AddSourceLocation(MSInfo->getPointOfInstantiation(), Record);
1146  } else {
1147  Record.push_back(CXXRecNotTemplate);
1148  }
1149 
1150  Record.push_back(D->isThisDeclarationADefinition());
1152  Writer.AddCXXDefinitionData(D, Record);
1153 
1154  // Store (what we currently believe to be) the key function to avoid
1155  // deserializing every method so we can compute it.
1156  if (D->IsCompleteDefinition)
1157  Writer.AddDeclRef(Context.getCurrentKeyFunction(D), Record);
1158 
1160 }
1161 
1163  VisitFunctionDecl(D);
1164  if (D->isCanonicalDecl()) {
1165  Record.push_back(D->size_overridden_methods());
1168  I != E; ++I)
1169  Writer.AddDeclRef(*I, Record);
1170  } else {
1171  // We only need to record overridden methods once for the canonical decl.
1172  Record.push_back(0);
1173  }
1174 
1175  if (D->getDeclContext() == D->getLexicalDeclContext() &&
1176  D->getFirstDecl() == D->getMostRecentDecl() &&
1177  !D->isInvalidDecl() &&
1178  !D->hasAttrs() &&
1181  !D->hasExtInfo() &&
1182  !D->hasInheritedPrototype() &&
1183  D->hasWrittenPrototype())
1184  AbbrevToUse = Writer.getDeclCXXMethodAbbrev();
1185 
1187 }
1188 
1190  VisitCXXMethodDecl(D);
1191 
1192  Writer.AddDeclRef(D->getInheritedConstructor(), Record);
1193  Record.push_back(D->IsExplicitSpecified);
1194 
1196 }
1197 
1199  VisitCXXMethodDecl(D);
1200 
1201  Writer.AddDeclRef(D->getOperatorDelete(), Record);
1202 
1204 }
1205 
1207  VisitCXXMethodDecl(D);
1208  Record.push_back(D->IsExplicitSpecified);
1210 }
1211 
1213  VisitDecl(D);
1214  Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1215  ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1216  Record.push_back(!IdentifierLocs.empty());
1217  if (IdentifierLocs.empty()) {
1218  Writer.AddSourceLocation(D->getLocEnd(), Record);
1219  Record.push_back(1);
1220  } else {
1221  for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1222  Writer.AddSourceLocation(IdentifierLocs[I], Record);
1223  Record.push_back(IdentifierLocs.size());
1224  }
1225  // Note: the number of source locations must always be the last element in
1226  // the record.
1228 }
1229 
1231  VisitDecl(D);
1232  Writer.AddSourceLocation(D->getColonLoc(), Record);
1234 }
1235 
1237  // Record the number of friend type template parameter lists here
1238  // so as to simplify memory allocation during deserialization.
1239  Record.push_back(D->NumTPLists);
1240  VisitDecl(D);
1241  bool hasFriendDecl = D->Friend.is<NamedDecl*>();
1242  Record.push_back(hasFriendDecl);
1243  if (hasFriendDecl)
1244  Writer.AddDeclRef(D->getFriendDecl(), Record);
1245  else
1246  Writer.AddTypeSourceInfo(D->getFriendType(), Record);
1247  for (unsigned i = 0; i < D->NumTPLists; ++i)
1248  Writer.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i),
1249  Record);
1250  Writer.AddDeclRef(D->getNextFriend(), Record);
1251  Record.push_back(D->UnsupportedFriend);
1252  Writer.AddSourceLocation(D->FriendLoc, Record);
1254 }
1255 
1257  VisitDecl(D);
1258  Record.push_back(D->getNumTemplateParameters());
1259  for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1260  Writer.AddTemplateParameterList(D->getTemplateParameterList(i), Record);
1261  Record.push_back(D->getFriendDecl() != nullptr);
1262  if (D->getFriendDecl())
1263  Writer.AddDeclRef(D->getFriendDecl(), Record);
1264  else
1265  Writer.AddTypeSourceInfo(D->getFriendType(), Record);
1266  Writer.AddSourceLocation(D->getFriendLoc(), Record);
1268 }
1269 
1271  VisitNamedDecl(D);
1272 
1273  Writer.AddDeclRef(D->getTemplatedDecl(), Record);
1274  Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
1275 }
1276 
1278  VisitRedeclarable(D);
1279 
1280  // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1281  // getCommonPtr() can be used while this is still initializing.
1282  if (D->isFirstDecl()) {
1283  // This declaration owns the 'common' pointer, so serialize that data now.
1284  Writer.AddDeclRef(D->getInstantiatedFromMemberTemplate(), Record);
1286  Record.push_back(D->isMemberSpecialization());
1287  }
1288 
1289  VisitTemplateDecl(D);
1290  Record.push_back(D->getIdentifierNamespace());
1291 }
1292 
1294  VisitRedeclarableTemplateDecl(D);
1295 
1296  if (D->isFirstDecl())
1297  AddTemplateSpecializations(D);
1299 }
1300 
1303  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1304 
1305  VisitCXXRecordDecl(D);
1306 
1307  llvm::PointerUnion<ClassTemplateDecl *,
1310  if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1311  Writer.AddDeclRef(InstFromD, Record);
1312  } else {
1313  Writer.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>(),
1314  Record);
1315  Writer.AddTemplateArgumentList(&D->getTemplateInstantiationArgs(), Record);
1316  }
1317 
1318  Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record);
1319  Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);
1320  Record.push_back(D->getSpecializationKind());
1321  Record.push_back(D->isCanonicalDecl());
1322 
1323  if (D->isCanonicalDecl()) {
1324  // When reading, we'll add it to the folding set of the following template.
1325  Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record);
1326  }
1327 
1328  // Explicit info.
1329  Writer.AddTypeSourceInfo(D->getTypeAsWritten(), Record);
1330  if (D->getTypeAsWritten()) {
1331  Writer.AddSourceLocation(D->getExternLoc(), Record);
1332  Writer.AddSourceLocation(D->getTemplateKeywordLoc(), Record);
1333  }
1334 
1336 }
1337 
1340  VisitClassTemplateSpecializationDecl(D);
1341 
1342  Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
1343  Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);
1344 
1345  // These are read/set from/to the first declaration.
1346  if (D->getPreviousDecl() == nullptr) {
1347  Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);
1348  Record.push_back(D->isMemberSpecialization());
1349  }
1350 
1352 }
1353 
1355  VisitRedeclarableTemplateDecl(D);
1356 
1357  if (D->isFirstDecl())
1358  AddTemplateSpecializations(D);
1360 }
1361 
1364  RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1365 
1366  VisitVarDecl(D);
1367 
1368  llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
1369  InstFrom = D->getSpecializedTemplateOrPartial();
1370  if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
1371  Writer.AddDeclRef(InstFromD, Record);
1372  } else {
1373  Writer.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>(),
1374  Record);
1375  Writer.AddTemplateArgumentList(&D->getTemplateInstantiationArgs(), Record);
1376  }
1377 
1378  // Explicit info.
1379  Writer.AddTypeSourceInfo(D->getTypeAsWritten(), Record);
1380  if (D->getTypeAsWritten()) {
1381  Writer.AddSourceLocation(D->getExternLoc(), Record);
1382  Writer.AddSourceLocation(D->getTemplateKeywordLoc(), Record);
1383  }
1384 
1385  Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record);
1386  Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);
1387  Record.push_back(D->getSpecializationKind());
1388  Record.push_back(D->isCanonicalDecl());
1389 
1390  if (D->isCanonicalDecl()) {
1391  // When reading, we'll add it to the folding set of the following template.
1392  Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record);
1393  }
1394 
1396 }
1397 
1400  VisitVarTemplateSpecializationDecl(D);
1401 
1402  Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
1403  Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);
1404 
1405  // These are read/set from/to the first declaration.
1406  if (D->getPreviousDecl() == nullptr) {
1407  Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);
1408  Record.push_back(D->isMemberSpecialization());
1409  }
1410 
1412 }
1413 
1416  VisitDecl(D);
1417  Writer.AddDeclRef(D->getSpecialization(), Record);
1419 }
1420 
1421 
1423  VisitRedeclarableTemplateDecl(D);
1424 
1425  if (D->isFirstDecl())
1426  AddTemplateSpecializations(D);
1428 }
1429 
1431  VisitTypeDecl(D);
1432 
1433  Record.push_back(D->wasDeclaredWithTypename());
1434 
1435  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1437  Record.push_back(OwnsDefaultArg);
1438  if (OwnsDefaultArg)
1439  Writer.AddTypeSourceInfo(D->getDefaultArgumentInfo(), Record);
1440 
1442 }
1443 
1445  // For an expanded parameter pack, record the number of expansion types here
1446  // so that it's easier for deserialization to allocate the right amount of
1447  // memory.
1448  if (D->isExpandedParameterPack())
1449  Record.push_back(D->getNumExpansionTypes());
1450 
1451  VisitDeclaratorDecl(D);
1452  // TemplateParmPosition.
1453  Record.push_back(D->getDepth());
1454  Record.push_back(D->getPosition());
1455 
1456  if (D->isExpandedParameterPack()) {
1457  for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
1458  Writer.AddTypeRef(D->getExpansionType(I), Record);
1459  Writer.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I), Record);
1460  }
1461 
1463  } else {
1464  // Rest of NonTypeTemplateParmDecl.
1465  Record.push_back(D->isParameterPack());
1466  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1468  Record.push_back(OwnsDefaultArg);
1469  if (OwnsDefaultArg)
1470  Writer.AddStmt(D->getDefaultArgument());
1472  }
1473 }
1474 
1476  // For an expanded parameter pack, record the number of expansion types here
1477  // so that it's easier for deserialization to allocate the right amount of
1478  // memory.
1479  if (D->isExpandedParameterPack())
1480  Record.push_back(D->getNumExpansionTemplateParameters());
1481 
1482  VisitTemplateDecl(D);
1483  // TemplateParmPosition.
1484  Record.push_back(D->getDepth());
1485  Record.push_back(D->getPosition());
1486 
1487  if (D->isExpandedParameterPack()) {
1488  for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
1489  I != N; ++I)
1490  Writer.AddTemplateParameterList(D->getExpansionTemplateParameters(I),
1491  Record);
1493  } else {
1494  // Rest of TemplateTemplateParmDecl.
1495  Record.push_back(D->isParameterPack());
1496  bool OwnsDefaultArg = D->hasDefaultArgument() &&
1498  Record.push_back(OwnsDefaultArg);
1499  if (OwnsDefaultArg)
1500  Writer.AddTemplateArgumentLoc(D->getDefaultArgument(), Record);
1502  }
1503 }
1504 
1506  VisitRedeclarableTemplateDecl(D);
1508 }
1509 
1511  VisitDecl(D);
1512  Writer.AddStmt(D->getAssertExpr());
1513  Record.push_back(D->isFailed());
1514  Writer.AddStmt(D->getMessage());
1515  Writer.AddSourceLocation(D->getRParenLoc(), Record);
1517 }
1518 
1519 /// \brief Emit the DeclContext part of a declaration context decl.
1520 ///
1521 /// \param LexicalOffset the offset at which the DECL_CONTEXT_LEXICAL
1522 /// block for this declaration context is stored. May be 0 to indicate
1523 /// that there are no declarations stored within this context.
1524 ///
1525 /// \param VisibleOffset the offset at which the DECL_CONTEXT_VISIBLE
1526 /// block for this declaration context is stored. May be 0 to indicate
1527 /// that there are no declarations visible from this context. Note
1528 /// that this value will not be emitted for non-primary declaration
1529 /// contexts.
1530 void ASTDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
1531  uint64_t VisibleOffset) {
1532  Record.push_back(LexicalOffset);
1533  Record.push_back(VisibleOffset);
1534 }
1535 
1537  /// \brief Is this a local declaration (that is, one that will be written to
1538  /// our AST file)? This is the case for declarations that are neither imported
1539  /// from another AST file nor predefined.
1540  auto IsLocalDecl = [&](const Decl *D) -> bool {
1541  if (D->isFromASTFile())
1542  return false;
1543  auto I = DeclIDs.find(D);
1544  return (I == DeclIDs.end() || I->second >= NUM_PREDEF_DECL_IDS);
1545  };
1546 
1547  assert(IsLocalDecl(D) && "expected a local declaration");
1548 
1549  const Decl *Canon = D->getCanonicalDecl();
1550  if (IsLocalDecl(Canon))
1551  return Canon;
1552 
1553  const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
1554  if (CacheEntry)
1555  return CacheEntry;
1556 
1557  for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
1558  if (IsLocalDecl(Redecl))
1559  D = Redecl;
1560  return CacheEntry = D;
1561 }
1562 
1563 template <typename T>
1565  T *First = D->getFirstDecl();
1566  T *MostRecent = First->getMostRecentDecl();
1567  T *DAsT = static_cast<T *>(D);
1568  if (MostRecent != First) {
1569  assert(isRedeclarableDeclKind(DAsT->getKind()) &&
1570  "Not considered redeclarable?");
1571 
1572  Writer.AddDeclRef(First, Record);
1573 
1574  // Write out a list of local redeclarations of this declaration if it's the
1575  // first local declaration in the chain.
1576  const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
1577  if (DAsT == FirstLocal) {
1578  // Emit a list of all imported first declarations so that we can be sure
1579  // that all redeclarations visible to this module are before D in the
1580  // redecl chain.
1581  unsigned I = Record.size();
1582  Record.push_back(0);
1583  if (Writer.Chain)
1584  AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
1585  // This is the number of imported first declarations + 1.
1586  Record[I] = Record.size() - I;
1587 
1588  // Collect the set of local redeclarations of this declaration, from
1589  // newest to oldest.
1590  RecordData LocalRedecls;
1591  for (const Decl *Prev = FirstLocal->getMostRecentDecl();
1592  Prev != FirstLocal; Prev = Prev->getPreviousDecl())
1593  if (!Prev->isFromASTFile())
1594  Writer.AddDeclRef(Prev, LocalRedecls);
1595 
1596  // If we have any redecls, write them now as a separate record preceding
1597  // the declaration itself.
1598  if (LocalRedecls.empty())
1599  Record.push_back(0);
1600  else {
1601  Record.push_back(Writer.Stream.GetCurrentBitNo());
1602  Writer.Stream.EmitRecord(LOCAL_REDECLARATIONS, LocalRedecls);
1603  }
1604  } else {
1605  Record.push_back(0);
1606  Writer.AddDeclRef(FirstLocal, Record);
1607  }
1608 
1609  // Make sure that we serialize both the previous and the most-recent
1610  // declarations, which (transitively) ensures that all declarations in the
1611  // chain get serialized.
1612  //
1613  // FIXME: This is not correct; when we reach an imported declaration we
1614  // won't emit its previous declaration.
1615  (void)Writer.GetDeclRef(D->getPreviousDecl());
1616  (void)Writer.GetDeclRef(MostRecent);
1617  } else {
1618  // We use the sentinel value 0 to indicate an only declaration.
1619  Record.push_back(0);
1620  }
1621 }
1622 
1624  Record.push_back(D->varlist_size());
1625  VisitDecl(D);
1626  for (auto *I : D->varlists())
1627  Writer.AddStmt(I);
1629 }
1630 
1631 //===----------------------------------------------------------------------===//
1632 // ASTWriter Implementation
1633 //===----------------------------------------------------------------------===//
1634 
1635 void ASTWriter::WriteDeclAbbrevs() {
1636  using namespace llvm;
1637 
1638  BitCodeAbbrev *Abv;
1639 
1640  // Abbreviation for DECL_FIELD
1641  Abv = new BitCodeAbbrev();
1642  Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
1643  // Decl
1644  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1645  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1646  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1647  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1648  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1649  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1650  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1651  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1652  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1653  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1654  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1655  // NamedDecl
1656  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1657  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1658  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1659  // ValueDecl
1660  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1661  // DeclaratorDecl
1662  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1663  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1664  // FieldDecl
1665  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1666  Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth
1667  // Type Source Info
1668  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1669  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1670  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1671  DeclFieldAbbrev = Stream.EmitAbbrev(Abv);
1672 
1673  // Abbreviation for DECL_OBJC_IVAR
1674  Abv = new BitCodeAbbrev();
1675  Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
1676  // Decl
1677  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1678  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1679  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1680  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1681  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1682  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1683  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1684  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1685  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // AccessSpecifier
1686  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1687  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1688  // NamedDecl
1689  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1690  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1691  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1692  // ValueDecl
1693  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1694  // DeclaratorDecl
1695  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1696  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1697  // FieldDecl
1698  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
1699  Abv->Add(BitCodeAbbrevOp(0)); //getBitWidth
1700  // ObjC Ivar
1701  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
1702  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
1703  // Type Source Info
1704  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1705  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1706  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1707  DeclObjCIvarAbbrev = Stream.EmitAbbrev(Abv);
1708 
1709  // Abbreviation for DECL_ENUM
1710  Abv = new BitCodeAbbrev();
1711  Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
1712  // Redeclarable
1713  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1714  // Decl
1715  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1716  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1717  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1718  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1719  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1720  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1721  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1722  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1723  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1724  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1725  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1726  // NamedDecl
1727  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1728  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1729  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1730  // TypeDecl
1731  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1732  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1733  // TagDecl
1734  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1735  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1736  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1737  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1738  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1739  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1740  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1741  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1742  // EnumDecl
1743  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
1744  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
1745  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
1746  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumPositiveBits
1747  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getNumNegativeBits
1748  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScoped
1749  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isScopedUsingClassTag
1750  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isFixed
1751  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
1752  // DC
1753  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1754  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1755  DeclEnumAbbrev = Stream.EmitAbbrev(Abv);
1756 
1757  // Abbreviation for DECL_RECORD
1758  Abv = new BitCodeAbbrev();
1759  Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
1760  // Redeclarable
1761  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1762  // Decl
1763  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1764  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1765  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1766  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1767  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1768  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1769  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1770  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1771  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1772  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1773  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1774  // NamedDecl
1775  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1776  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1777  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1778  // TypeDecl
1779  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1780  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1781  // TagDecl
1782  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
1783  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getTagKind
1784  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCompleteDefinition
1785  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // EmbeddedInDeclarator
1786  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
1787  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
1788  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
1789  Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
1790  // RecordDecl
1791  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember
1792  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
1793  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
1794  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
1795  // DC
1796  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
1797  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
1798  DeclRecordAbbrev = Stream.EmitAbbrev(Abv);
1799 
1800  // Abbreviation for DECL_PARM_VAR
1801  Abv = new BitCodeAbbrev();
1802  Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
1803  // Redeclarable
1804  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1805  // Decl
1806  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1807  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1808  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1809  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1810  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1811  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1812  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1813  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1814  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1815  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1816  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1817  // NamedDecl
1818  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1819  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1820  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1821  // ValueDecl
1822  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1823  // DeclaratorDecl
1824  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1825  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1826  // VarDecl
1827  Abv->Add(BitCodeAbbrevOp(0)); // StorageClass
1828  Abv->Add(BitCodeAbbrevOp(0)); // getTSCSpec
1829  Abv->Add(BitCodeAbbrevOp(0)); // hasCXXDirectInitializer
1830  Abv->Add(BitCodeAbbrevOp(0)); // Linkage
1831  Abv->Add(BitCodeAbbrevOp(0)); // HasInit
1832  Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo
1833  // ParmVarDecl
1834  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsObjCMethodParameter
1835  Abv->Add(BitCodeAbbrevOp(0)); // ScopeDepth
1836  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
1837  Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier
1838  Abv->Add(BitCodeAbbrevOp(0)); // KNRPromoted
1839  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg
1840  Abv->Add(BitCodeAbbrevOp(0)); // HasUninstantiatedDefaultArg
1841  // Type Source Info
1842  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1843  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1844  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1845  DeclParmVarAbbrev = Stream.EmitAbbrev(Abv);
1846 
1847  // Abbreviation for DECL_TYPEDEF
1848  Abv = new BitCodeAbbrev();
1849  Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
1850  // Redeclarable
1851  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1852  // Decl
1853  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1854  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1855  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1856  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1857  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1858  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isUsed
1859  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isReferenced
1860  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1861  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // C++ AccessSpecifier
1862  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1863  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1864  // NamedDecl
1865  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1866  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1867  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1868  // TypeDecl
1869  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
1870  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
1871  // TypedefDecl
1872  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1873  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1874  DeclTypedefAbbrev = Stream.EmitAbbrev(Abv);
1875 
1876  // Abbreviation for DECL_VAR
1877  Abv = new BitCodeAbbrev();
1878  Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
1879  // Redeclarable
1880  Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
1881  // Decl
1882  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1883  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1884  Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl
1885  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1886  Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
1887  Abv->Add(BitCodeAbbrevOp(0)); // isUsed
1888  Abv->Add(BitCodeAbbrevOp(0)); // isReferenced
1889  Abv->Add(BitCodeAbbrevOp(0)); // TopLevelDeclInObjCContainer
1890  Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
1891  Abv->Add(BitCodeAbbrevOp(0)); // ModulePrivate
1892  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1893  // NamedDecl
1894  Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
1895  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
1896  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1897  // ValueDecl
1898  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1899  // DeclaratorDecl
1900  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
1901  Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
1902  // VarDecl
1903  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // StorageClass
1904  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // getTSCSpec
1905  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // CXXDirectInitializer
1906  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
1907  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
1908  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
1909  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
1910  Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
1911  Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
1912  Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
1913  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
1914  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasInit
1915  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasMemberSpecInfo
1916  // Type Source Info
1917  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1918  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1919  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
1920  DeclVarAbbrev = Stream.EmitAbbrev(Abv);
1921 
1922  // Abbreviation for DECL_CXX_METHOD
1923  Abv = new BitCodeAbbrev();
1924  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD));
1925  // RedeclarableDecl
1926  Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
1927  // Decl
1928  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
1929  Abv->Add(BitCodeAbbrevOp(0)); // LexicalDeclContext
1930  Abv->Add(BitCodeAbbrevOp(0)); // Invalid
1931  Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs
1932  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Implicit
1933  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Used
1934  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Referenced
1935  Abv->Add(BitCodeAbbrevOp(0)); // InObjCContainer
1936  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Access
1937  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModulePrivate
1938  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
1939  // NamedDecl
1940  Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
1941  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
1942  Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
1943  // ValueDecl
1944  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1945  // DeclaratorDecl
1946  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
1947  Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
1948  // FunctionDecl
1949  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
1950  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass
1951  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline
1952  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified
1953  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // VirtualAsWritten
1954  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Pure
1955  Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedProto
1956  Abv->Add(BitCodeAbbrevOp(1)); // HasWrittenProto
1957  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Deleted
1958  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Trivial
1959  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
1960  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
1961  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
1962  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
1963  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
1964  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed
1965  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
1966  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
1967  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // TemplateKind
1968  // This Array slurps the rest of the record. Fortunately we want to encode
1969  // (nearly) all the remaining (variable number of) fields in the same way.
1970  //
1971  // This is the function template information if any, then
1972  // NumParams and Params[] from FunctionDecl, and
1973  // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
1974  //
1975  // Add an AbbrevOp for 'size then elements' and use it here.
1976  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1977  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1978  DeclCXXMethodAbbrev = Stream.EmitAbbrev(Abv);
1979 
1980  // Abbreviation for EXPR_DECL_REF
1981  Abv = new BitCodeAbbrev();
1982  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
1983  //Stmt
1984  //Expr
1985  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
1986  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
1987  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
1988  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
1989  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
1990  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
1991  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
1992  //DeclRefExpr
1993  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HasQualifier
1994  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //GetDeclFound
1995  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ExplicitTemplateArgs
1996  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //HadMultipleCandidates
1997  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
1998  1)); // RefersToEnclosingVariableOrCapture
1999  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2000  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2001  DeclRefExprAbbrev = Stream.EmitAbbrev(Abv);
2002 
2003  // Abbreviation for EXPR_INTEGER_LITERAL
2004  Abv = new BitCodeAbbrev();
2005  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2006  //Stmt
2007  //Expr
2008  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2009  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2010  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2011  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2012  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2013  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2014  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2015  //Integer Literal
2016  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2017  Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2018  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2019  IntegerLiteralAbbrev = Stream.EmitAbbrev(Abv);
2020 
2021  // Abbreviation for EXPR_CHARACTER_LITERAL
2022  Abv = new BitCodeAbbrev();
2023  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2024  //Stmt
2025  //Expr
2026  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2027  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2028  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2029  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2030  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2031  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2032  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2033  //Character Literal
2034  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2035  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2036  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2037  CharacterLiteralAbbrev = Stream.EmitAbbrev(Abv);
2038 
2039  // Abbreviation for EXPR_IMPLICIT_CAST
2040  Abv = new BitCodeAbbrev();
2041  Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2042  // Stmt
2043  // Expr
2044  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2045  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent
2046  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
2047  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
2048  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
2049  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
2050  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
2051  // CastExpr
2052  Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2053  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); // CastKind
2054  // ImplicitCastExpr
2055  ExprImplicitCastAbbrev = Stream.EmitAbbrev(Abv);
2056 
2057  Abv = new BitCodeAbbrev();
2058  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2059  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2060  DeclContextLexicalAbbrev = Stream.EmitAbbrev(Abv);
2061 
2062  Abv = new BitCodeAbbrev();
2063  Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2064  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2065  DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(Abv);
2066 }
2067 
2068 /// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2069 /// consumers of the AST.
2070 ///
2071 /// Such decls will always be deserialized from the AST file, so we would like
2072 /// this to be as restrictive as possible. Currently the predicate is driven by
2073 /// code generation requirements, if other clients have a different notion of
2074 /// what is "required" then we may have to consider an alternate scheme where
2075 /// clients can iterate over the top-level decls and get information on them,
2076 /// without necessary deserializing them. We could explicitly require such
2077 /// clients to use a separate API call to "realize" the decl. This should be
2078 /// relatively painless since they would presumably only do it for top-level
2079 /// decls.
2080 static bool isRequiredDecl(const Decl *D, ASTContext &Context,
2081  bool WritingModule) {
2082  // An ObjCMethodDecl is never considered as "required" because its
2083  // implementation container always is.
2084 
2085  // File scoped assembly or obj-c implementation must be seen.
2086  if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D))
2087  return true;
2088 
2089  // ImportDecl is used by codegen to determine the set of imported modules to
2090  // search for inputs for automatic linking; include it if it has a semantic
2091  // effect.
2092  if (isa<ImportDecl>(D) && !WritingModule)
2093  return true;
2094 
2095  return Context.DeclMustBeEmitted(D);
2096 }
2097 
2098 void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
2099  // Switch case IDs are per Decl.
2100  ClearSwitchCaseIDs();
2101 
2102  RecordData Record;
2103  ASTDeclWriter W(*this, Context, Record);
2104 
2105  // Determine the ID for this declaration.
2107  assert(!D->isFromASTFile() && "should not be emitting imported decl");
2108  serialization::DeclID &IDR = DeclIDs[D];
2109  if (IDR == 0)
2110  IDR = NextDeclID++;
2111 
2112  ID = IDR;
2113 
2114  bool isReplacingADecl = ID < FirstDeclID;
2115 
2116  // If this declaration is also a DeclContext, write blocks for the
2117  // declarations that lexically stored inside its context and those
2118  // declarations that are visible from its context. These blocks
2119  // are written before the declaration itself so that we can put
2120  // their offsets into the record for the declaration.
2121  uint64_t LexicalOffset = 0;
2122  uint64_t VisibleOffset = 0;
2123  DeclContext *DC = dyn_cast<DeclContext>(D);
2124  if (DC) {
2125  if (isReplacingADecl) {
2126  // It is replacing a decl from a chained PCH; make sure that the
2127  // DeclContext is fully loaded.
2128  if (DC->hasExternalLexicalStorage())
2129  DC->LoadLexicalDeclsFromExternalStorage();
2130  if (DC->hasExternalVisibleStorage())
2131  Chain->completeVisibleDeclsMap(DC);
2132  }
2133  LexicalOffset = WriteDeclContextLexicalBlock(Context, DC);
2134  VisibleOffset = WriteDeclContextVisibleBlock(Context, DC);
2135  }
2136 
2137  // Build a record for this declaration
2138  Record.clear();
2139  W.Code = (serialization::DeclCode)0;
2140  W.AbbrevToUse = 0;
2141  W.Visit(D);
2142  if (DC) W.VisitDeclContext(DC, LexicalOffset, VisibleOffset);
2143 
2144  if (isReplacingADecl) {
2145  // We're replacing a decl in a previous file.
2146  ReplacedDecls.push_back(ReplacedDeclInfo(ID, Stream.GetCurrentBitNo(),
2147  D->getLocation()));
2148  } else {
2149  unsigned Index = ID - FirstDeclID;
2150 
2151  // Record the offset for this declaration
2152  SourceLocation Loc = D->getLocation();
2153  if (DeclOffsets.size() == Index)
2154  DeclOffsets.push_back(DeclOffset(Loc, Stream.GetCurrentBitNo()));
2155  else if (DeclOffsets.size() < Index) {
2156  DeclOffsets.resize(Index+1);
2157  DeclOffsets[Index].setLocation(Loc);
2158  DeclOffsets[Index].BitOffset = Stream.GetCurrentBitNo();
2159  }
2160 
2161  SourceManager &SM = Context.getSourceManager();
2162  if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
2163  associateDeclWithFile(D, ID);
2164  }
2165 
2166  if (!W.Code)
2167  llvm::report_fatal_error(StringRef("unexpected declaration kind '") +
2168  D->getDeclKindName() + "'");
2169  Stream.EmitRecord(W.Code, Record, W.AbbrevToUse);
2170 
2171  // Flush any expressions, base specifiers, and ctor initializers that
2172  // were written as part of this declaration.
2173  FlushPendingAfterDecl();
2174 
2175  // Note declarations that should be deserialized eagerly so that we can add
2176  // them to a record in the AST file later.
2177  if (isRequiredDecl(D, Context, WritingModule))
2178  EagerlyDeserializedDecls.push_back(ID);
2179 }
2180 
2181 void ASTWriter::AddFunctionDefinition(const FunctionDecl *FD,
2182  RecordData &Record) {
2183  ClearSwitchCaseIDs();
2184 
2185  ASTDeclWriter W(*this, FD->getASTContext(), Record);
2186  W.AddFunctionDefinition(FD);
2187 }
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1109
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1127
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
Definition: DeclTemplate.h:465
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition: DeclFriend.h:113
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1483
void VisitAccessSpecDecl(AccessSpecDecl *D)
protocol_range protocols() const
Definition: DeclObjC.h:1785
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
void VisitStaticAssertDecl(StaticAssertDecl *D)
void VisitCXXMethodDecl(CXXMethodDecl *D)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
Definition: DeclCXX.cpp:1221
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
Definition: ASTCommon.cpp:265
A (possibly-)qualified type.
Definition: Type.h:575
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:587
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:1974
bool isVariadic() const
Definition: Decl.h:3445
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
unsigned param_size() const
Definition: Decl.h:3456
void VisitRedeclarable(Redeclarable< T > *D)
void VisitEmptyDecl(EmptyDecl *D)
void RegisterTemplateSpecialization(const Decl *Template, const Decl *Specialization)
Ensure that this template specialization is associated with the specified template on reload...
void VisitTypedefNameDecl(TypedefNameDecl *D)
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1152
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:2575
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:3116
bool isDefined() const
Definition: DeclObjC.h:429
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
Definition: Decl.cpp:2213
const Expr * getInitExpr() const
Definition: Decl.h:2414
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1197
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Definition: Decl.h:2397
void VisitCXXRecordDecl(CXXRecordDecl *D)
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Definition: Decl.h:2598
Defines the SourceManager interface.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1352
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
QualType getUnderlyingType() const
Definition: Decl.h:2566
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
Definition: Decl.cpp:3048
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:77
An ImplicitCastExpr record.
Definition: ASTBitCodes.h:1251
chain_range chain() const
Definition: Decl.h:2457
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1121
param_iterator param_end()
Definition: Decl.h:3471
Defines the C++ template declaration subclasses.
bool hasFlexibleArrayMember() const
Definition: Decl.h:3218
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Definition: DeclBase.h:834
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
Definition: Decl.h:3143
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:1066
Represents an empty-declaration.
Definition: Decl.h:3718
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:63
Declaration of a variable template.
const Expr * getInit() const
Definition: Decl.h:1070
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:402
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1039
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: Decl.h:1356
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:3070
protocol_range protocols() const
Definition: DeclObjC.h:2005
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclBase.h:380
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2134
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:590
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:1111
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1090
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:1579
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:40
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:699
Expr * getSetterCXXAssignment() const
Definition: DeclObjC.h:2700
Declaration of a redeclarable template.
Definition: DeclTemplate.h:621
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
bool capturesCXXThis() const
Definition: Decl.h:3521
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:3174
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1084
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:2059
AccessSpecifier getAccess() const
Definition: DeclBase.h:428
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
Definition: ASTBitCodes.h:996
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1240
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
Definition: ASTBitCodes.h:1145
void VisitIndirectFieldDecl(IndirectFieldDecl *D)
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition: Decl.cpp:3236
capture_range captures()
Definition: Decl.h:3509
unsigned param_size() const
Definition: DeclObjC.h:348
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:653
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1129
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1299
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:1023
Provides information about a dependent function-template specialization declaration.
Definition: DeclTemplate.h:556
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names the category interface associated with this implementat...
Definition: DeclObjC.h:2171
QualType getType() const
Definition: DeclObjC.h:2497
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:2826
TypeSourceInfo * getTypeSourceInfo() const
Definition: DeclObjC.h:2495
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:107
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3166
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1414
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:27
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:3110
method_iterator end_overridden_methods() const
Definition: DeclCXX.cpp:1588
StringLiteral * getMessage()
Definition: DeclCXX.h:3169
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:91
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition: DeclBase.h:1742
ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, RecordData &Record)
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition: DeclCXX.h:2720
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2016
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2209
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Definition: Decl.h:2788
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:353
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition: Decl.h:452
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:682
TagKind getTagKind() const
Definition: Decl.h:2847
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
Definition: Decl.h:1217
param_range params()
Definition: DeclObjC.h:354
TypeSourceInfo * getFriendType() const
If this friend declaration names a templated type (or a dependent member type of a templated type)...
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:2615
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.h:3449
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
getNumCaptures - Returns the number of captured variables.
Definition: Decl.h:3502
bool isThisDeclarationADefinition() const
isThisDeclarationADefinition() - Return true if this declaration is a completion definition of the ty...
Definition: Decl.h:2782
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2053
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:875
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1139
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:391
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Represents a C++ using-declaration.
Definition: DeclCXX.h:2858
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:3601
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Definition: DeclTemplate.h:424
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:906
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:3234
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:696
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1803
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:514
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:457
void VisitTypedefDecl(TypedefDecl *D)
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1104
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2057
SourceLocation getRBraceLoc() const
Definition: Decl.h:500
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:1086
TypeDecl - Represents a declaration of a type.
Definition: Decl.h:2486
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
Definition: Decl.cpp:2206
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2693
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:579
unsigned getNumTemplateParameters() const
Selector getSetterName() const
Definition: DeclObjC.h:2562
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
SourceLocation getRBraceLoc() const
Definition: Decl.h:2763
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1113
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:1728
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
Definition: DeclBase.h:708
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.cpp:3063
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:3560
Represents an ObjC class declaration.
Definition: DeclObjC.h:853
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclObjC.cpp:879
Represents a linkage specification.
Definition: DeclCXX.h:2454
detail::InMemoryDirectory::const_iterator I
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:2508
QualType getType() const
Definition: Decl.h:530
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:753
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2353
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:798
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition: DeclCXX.h:2888
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
SourceLocation getAtLoc() const
Definition: DeclObjC.h:2489
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion: ...
Definition: Decl.h:1373
unsigned getNumParams() const
Definition: Decl.h:3599
SourceRange getAtEndRange() const
Definition: DeclObjC.h:802
AnnotatingParser & P
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2605
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3178
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:1869
void VisitObjCContainerDecl(ObjCContainerDecl *D)
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclObjC.h:2659
RecordDecl * getMostRecentDecl()
Definition: Decl.h:3211
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2618
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:3525
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:2510
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:2711
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:577
unsigned getChainingSize() const
Definition: Decl.h:2463
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
ASTContext * Context
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclObjC.h:269
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
Definition: Decl.cpp:2291
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1133
SourceLocation getSuperClassLoc() const
Definition: DeclObjC.h:2348
ID
Defines the set of possible language-specific address spaces.
Definition: AddressSpaces.h:27
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1119
const CXXMethodDecl *const * method_iterator
Definition: DeclCXX.h:1793
SourceManager & SM
static bool classofKind(Kind K)
Definition: DeclObjC.h:1663
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1156
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction...
Definition: DeclObjC.h:2316
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:2282
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:4200
const Type * getTypeForDecl() const
Definition: Decl.h:2507
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1448
unsigned param_size() const
Definition: Decl.h:1900
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3369
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:521
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1033
bool isModed() const
Definition: Decl.h:2559
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1041
void VisitRecordDecl(RecordDecl *D)
Declaration of a template type parameter.
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
NamedDecl * getFriendDecl() const
If this friend declaration names a templated function (or a member function of a templated type)...
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2671
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:582
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Expr * getBitWidth() const
Definition: Decl.h:2291
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:548
void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal)
Add to the record the first declaration from each module file that provides a declaration of D...
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2345
A CXXConstructorDecl record.
Definition: ASTBitCodes.h:1098
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:849
Kind getKind() const
Definition: DeclBase.h:387
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:163
DeclContext * getDeclContext()
Definition: DeclBase.h:393
void VisitUsingDecl(UsingDecl *D)
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
const char * getDeclKindName() const
Definition: DeclBase.cpp:102
bool isFailed() const
Definition: DeclCXX.h:3172
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1117
ImplicitParamDecl * getSelfDecl() const
Definition: DeclObjC.h:411
unsigned getContextParamPosition() const
Definition: Decl.h:3620
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
EnumDecl * getMostRecentDecl()
Definition: Decl.h:2992
bool isObjCMethodParameter() const
Definition: Decl.h:1342
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1100
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:1142
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:740
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3105
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:3351
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:1140
A NamespaceAliasDecl record.
Definition: ASTBitCodes.h:1080
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1200
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:635
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
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:190
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1067
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1049
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition: Decl.h:2635
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition: Decl.cpp:1027
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2392
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1017
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition: Decl.h:1790
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Definition: DeclTemplate.h:434
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
void VisitTagDecl(TagDecl *D)
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1150
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1031
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:2878
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
CXXMethodDecl * getMostRecentDecl()
Definition: DeclCXX.h:1776
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition: DeclObjC.h:344
static DeclType * getDecl(EntryType *D)
Definition: DeclTemplate.h:639
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:156
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2281
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
void VisitMSPropertyDecl(MSPropertyDecl *D)
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:1037
void VisitVarTemplateDecl(VarTemplateDecl *D)
AttrVec & getAttrs()
Definition: DeclBase.h:443
void VisitTypeAliasDecl(TypeAliasDecl *D)
param_iterator param_begin()
Definition: Decl.h:3470
bool isEmbeddedInDeclarator() const
Definition: Decl.h:2803
Stmt * getBody(const FunctionDecl *&Definition) const
getBody - Retrieve the body (definition) of the function.
Definition: Decl.cpp:2497
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclBase.h:377
bool doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
Definition: Decl.h:1732
const Decl * getFirstLocalDecl(const Decl *D)
Find the first local declaration of a given local redeclarable decl.
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Definition: DeclTemplate.h:511
An UnresolvedUsingValueDecl record.
Definition: ASTBitCodes.h:1088
SourceLocation getExternLoc() const
Definition: DeclCXX.h:2506
IdentifierInfo * getGetterId() const
Definition: DeclCXX.h:3232
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:144
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:427
Encodes a location in the source.
unsigned protocol_size() const
Definition: DeclObjC.h:2012
A record that stores the set of declarations that are visible from a given DeclContext.
Definition: ASTBitCodes.h:1074
method_iterator begin_overridden_methods() const
Definition: DeclCXX.cpp:1583
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists...
void VisitObjCImplDecl(ObjCImplDecl *D)
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2401
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:499
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:2644
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:311
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:1593
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition: DeclCXX.h:2739
ObjCList - This is a simple template class used to hold various lists of decls etc, which is heavily used by the ObjC front-end.
Definition: DeclObjC.h:58
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:355
bool isVariadic() const
Definition: DeclObjC.h:421
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3004
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:787
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:756
bool getSynthesize() const
Definition: DeclObjC.h:1655
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1701
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
bool blockMissingReturnType() const
Definition: Decl.h:3522
C-style initialization with assignment.
Definition: Decl.h:709
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:1125
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:836
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:1931
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:3702
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2085
bool isPropertyAccessor() const
Definition: DeclObjC.h:426
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition: DeclCXX.h:3030
bool hasVolatileMember() const
Definition: Decl.h:3241
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:2289
ThreadStorageClassSpecifier getTSCSpec() const
Definition: Decl.h:884
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:2416
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:1078
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3146
bool hasObjectMember() const
Definition: Decl.h:3238
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2178
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
Definition: DeclTemplate.h:604
unsigned varlist_size() const
Definition: DeclOpenMP.h:71
SourceLocation getLParenLoc() const
Definition: DeclObjC.h:2492
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:3658
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition: DeclCXX.h:2611
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1235
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1025
param_range params()
Definition: Decl.h:1910
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition: Decl.h:1207
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2526
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
Definition: Decl.h:3233
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1102
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:1999
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition: DeclCXX.h:2910
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition: Decl.cpp:3025
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1121
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:331
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:759
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2582
QualType getPromotionType() const
getPromotionType - Return the integer type that enumerators should promote to.
Definition: Decl.h:3046
bool isInvalidDecl() const
Definition: DeclBase.h:509
void VisitNamedDecl(NamedDecl *D)
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Definition: Decl.h:2437
bool isFreeStanding() const
Definition: Decl.h:2810
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1115
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition: DeclCXX.h:2607
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1007
const llvm::APSInt & getInitVal() const
Definition: Decl.h:2416
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:514
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2495
bool hasWrittenPrototype() const
Definition: Decl.h:1786
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2674
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3087
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
Definition: ASTBitCodes.h:1148
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:537
Selector getGetterName() const
Definition: DeclObjC.h:2559
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
Definition: DeclBase.cpp:332
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1092
decltype(T::PartialSpecializations)& getPartialSpecializations(T *Common)
Get the list of partial specializations from a template's common ptr.
EnumDecl - Represents an enum.
Definition: Decl.h:2930
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Definition: TemplateBase.h:576
bool hasAttrs() const
Definition: DeclBase.h:439
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1346
detail::InMemoryDirectory::const_iterator E
SourceLocation getEndOfDefinitionLoc() const
Definition: DeclObjC.h:1539
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:2794
serialization::DeclCode Code
bool hasInheritedDefaultArg() const
Definition: Decl.h:1427
void VisitNamespaceDecl(NamespaceDecl *D)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2220
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:2565
bool hasNonZeroConstructors() const
Do any of the ivars of this class (not counting its base classes) require construction other than zer...
Definition: DeclObjC.h:2311
void VisitVarDecl(VarDecl *D)
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition: Decl.h:3097
Expr * getUninstantiatedDefaultArg()
Definition: Decl.cpp:2414
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition: DeclFriend.h:120
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
Definition: DeclTemplate.h:532
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:2568
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
bool isNothrow() const
Definition: Decl.cpp:4009
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
Definition: Decl.h:3054
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:601
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1495
SourceLocation getRBraceLoc() const
Definition: DeclCXX.h:2507
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:2895
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
Definition: Decl.h:1158
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2045
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1129
unsigned protocol_size() const
Definition: DeclObjC.h:1818
protocol_range protocols() const
Definition: DeclObjC.h:1040
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
void VisitFunctionDecl(FunctionDecl *D)
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition: Decl.h:986
const CXXConstructorDecl * getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition: DeclCXX.cpp:1881
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition: DeclCXX.h:3114
SourceManager & getSourceManager()
Definition: ASTContext.h:553
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement...
Definition: Decl.h:1168
static bool classofKind(Kind K)
Definition: DeclCXX.h:1687
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
void VisitDecl(Decl *D)
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2662
AccessControl getAccessControl() const
Definition: DeclObjC.h:1648
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:1695
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:1676
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:360
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition: Decl.h:1180
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:3080
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:3453
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:437
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
Definition: Decl.cpp:43
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3118
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1609
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:346
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:492
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:1035
void VisitEnumConstantDecl(EnumConstantDecl *D)
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1029
Declaration of a class template.
void VisitCXXConversionDecl(CXXConversionDecl *D)
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:615
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1189
void VisitClassScopeFunctionSpecializationDecl(ClassScopeFunctionSpecializationDecl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:355
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:84
VarTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
Definition: ASTBitCodes.h:999
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1011
const FunctionDecl * getOperatorDelete() const
Definition: DeclCXX.h:2370
TemplateParameterList * getTemplateParameterList(unsigned i) const
PropertyAttributeKind getPropertyAttributesAsWritten() const
Definition: DeclObjC.h:2518
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2355
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:166
void VisitFriendDecl(FriendDecl *D)
TranslationUnitDecl - The top declaration context.
Definition: Decl.h:79
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:2585
static bool isRequiredDecl(const Decl *D, ASTContext &Context, bool WritingModule)
isRequiredDecl - Check if this is a "required" Decl, which must be seen by consumers of the AST...
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
Definition: Decl.h:479
NamedDecl * getMostRecentDecl()
Definition: Decl.h:332
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:953
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1123
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3040
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
Definition: Decl.h:616
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1131
void VisitImportDecl(ImportDecl *D)
varlist_range varlists()
Definition: DeclOpenMP.h:74
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3213
SourceLocation getLocation() const
Definition: DeclBase.h:384
NamedDecl - This represents a decl with a name.
Definition: Decl.h:145
Represents a C++ namespace alias.
Definition: DeclCXX.h:2649
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:2546
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:2561
void VisitObjCMethodDecl(ObjCMethodDecl *D)
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:36
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2139
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
Definition: DeclBase.h:563
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:830
Source range/offset of a preprocessed entity.
Definition: ASTBitCodes.h:181
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:2766
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:2736
void VisitObjCIvarDecl(ObjCIvarDecl *D)
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2385
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2274
bool hasInClassInitializer() const
hasInClassInitializer - Determine whether this member has a C++11 in-class initializer.
Definition: Decl.h:2324
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
Definition: DeclBase.h:1752
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2346
const StringLiteral * getAsmString() const
Definition: Decl.h:3357