clang  5.0.0
ASTReaderDecl.cpp
Go to the documentation of this file.
1 //===--- ASTReaderDecl.cpp - Decl Deserialization ---------------*- C++ -*-===//
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 the ASTReader::ReadDeclRecord method, which is the
11 // entrypoint for loading a decl.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "ASTCommon.h"
16 #include "ASTReaderInternals.h"
17 #include "clang/AST/ASTContext.h"
18 #include "clang/AST/DeclCXX.h"
19 #include "clang/AST/DeclGroup.h"
20 #include "clang/AST/DeclTemplate.h"
21 #include "clang/AST/DeclVisitor.h"
22 #include "clang/AST/Expr.h"
26 #include "llvm/Support/SaveAndRestore.h"
27 
28 using namespace clang;
29 using namespace clang::serialization;
30 
31 //===----------------------------------------------------------------------===//
32 // Declaration deserialization
33 //===----------------------------------------------------------------------===//
34 
35 namespace clang {
36  class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> {
37  ASTReader &Reader;
38  ASTRecordReader &Record;
39  ASTReader::RecordLocation Loc;
40  const DeclID ThisDeclID;
41  const SourceLocation ThisDeclLoc;
43  TypeID TypeIDForTypeDecl;
44  unsigned AnonymousDeclNumber;
45  GlobalDeclID NamedDeclForTagDecl;
46  IdentifierInfo *TypedefNameForLinkage;
47 
48  bool HasPendingBody;
49 
50  ///\brief A flag to carry the information for a decl from the entity is
51  /// used. We use it to delay the marking of the canonical decl as used until
52  /// the entire declaration is deserialized and merged.
53  bool IsDeclMarkedUsed;
54 
55  uint64_t GetCurrentCursorOffset();
56 
57  uint64_t ReadLocalOffset() {
58  uint64_t LocalOffset = Record.readInt();
59  assert(LocalOffset < Loc.Offset && "offset point after current record");
60  return LocalOffset ? Loc.Offset - LocalOffset : 0;
61  }
62 
63  uint64_t ReadGlobalOffset() {
64  uint64_t Local = ReadLocalOffset();
65  return Local ? Record.getGlobalBitOffset(Local) : 0;
66  }
67 
68  SourceLocation ReadSourceLocation() {
69  return Record.readSourceLocation();
70  }
71 
72  SourceRange ReadSourceRange() {
73  return Record.readSourceRange();
74  }
75 
76  TypeSourceInfo *GetTypeSourceInfo() {
77  return Record.getTypeSourceInfo();
78  }
79 
80  serialization::DeclID ReadDeclID() {
81  return Record.readDeclID();
82  }
83 
84  std::string ReadString() {
85  return Record.readString();
86  }
87 
88  void ReadDeclIDList(SmallVectorImpl<DeclID> &IDs) {
89  for (unsigned I = 0, Size = Record.readInt(); I != Size; ++I)
90  IDs.push_back(ReadDeclID());
91  }
92 
93  Decl *ReadDecl() {
94  return Record.readDecl();
95  }
96 
97  template<typename T>
98  T *ReadDeclAs() {
99  return Record.readDeclAs<T>();
100  }
101 
102  void ReadQualifierInfo(QualifierInfo &Info) {
103  Record.readQualifierInfo(Info);
104  }
105 
106  void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name) {
107  Record.readDeclarationNameLoc(DNLoc, Name);
108  }
109 
110  serialization::SubmoduleID readSubmoduleID() {
111  if (Record.getIdx() == Record.size())
112  return 0;
113 
114  return Record.getGlobalSubmoduleID(Record.readInt());
115  }
116 
117  Module *readModule() {
118  return Record.getSubmodule(readSubmoduleID());
119  }
120 
121  void ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update);
122  void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data,
123  const CXXRecordDecl *D);
124  void MergeDefinitionData(CXXRecordDecl *D,
125  struct CXXRecordDecl::DefinitionData &&NewDD);
126  void ReadObjCDefinitionData(struct ObjCInterfaceDecl::DefinitionData &Data);
127  void MergeDefinitionData(ObjCInterfaceDecl *D,
128  struct ObjCInterfaceDecl::DefinitionData &&NewDD);
129  void ReadObjCDefinitionData(struct ObjCProtocolDecl::DefinitionData &Data);
130  void MergeDefinitionData(ObjCProtocolDecl *D,
131  struct ObjCProtocolDecl::DefinitionData &&NewDD);
132 
133  static NamedDecl *getAnonymousDeclForMerging(ASTReader &Reader,
134  DeclContext *DC,
135  unsigned Index);
136  static void setAnonymousDeclForMerging(ASTReader &Reader, DeclContext *DC,
137  unsigned Index, NamedDecl *D);
138 
139  /// Results from loading a RedeclarableDecl.
140  class RedeclarableResult {
141  Decl *MergeWith;
142  GlobalDeclID FirstID;
143  bool IsKeyDecl;
144 
145  public:
146  RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool IsKeyDecl)
147  : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {}
148 
149  /// \brief Retrieve the first ID.
150  GlobalDeclID getFirstID() const { return FirstID; }
151 
152  /// \brief Is this declaration a key declaration?
153  bool isKeyDecl() const { return IsKeyDecl; }
154 
155  /// \brief Get a known declaration that this should be merged with, if
156  /// any.
157  Decl *getKnownMergeTarget() const { return MergeWith; }
158  };
159 
160  /// \brief Class used to capture the result of searching for an existing
161  /// declaration of a specific kind and name, along with the ability
162  /// to update the place where this result was found (the declaration
163  /// chain hanging off an identifier or the DeclContext we searched in)
164  /// if requested.
165  class FindExistingResult {
166  ASTReader &Reader;
167  NamedDecl *New;
168  NamedDecl *Existing;
169  bool AddResult;
170 
171  unsigned AnonymousDeclNumber;
172  IdentifierInfo *TypedefNameForLinkage;
173 
174  void operator=(FindExistingResult &&) = delete;
175 
176  public:
177  FindExistingResult(ASTReader &Reader)
178  : Reader(Reader), New(nullptr), Existing(nullptr), AddResult(false),
179  AnonymousDeclNumber(0), TypedefNameForLinkage(nullptr) {}
180 
181  FindExistingResult(ASTReader &Reader, NamedDecl *New, NamedDecl *Existing,
182  unsigned AnonymousDeclNumber,
183  IdentifierInfo *TypedefNameForLinkage)
184  : Reader(Reader), New(New), Existing(Existing), AddResult(true),
185  AnonymousDeclNumber(AnonymousDeclNumber),
186  TypedefNameForLinkage(TypedefNameForLinkage) {}
187 
188  FindExistingResult(FindExistingResult &&Other)
189  : Reader(Other.Reader), New(Other.New), Existing(Other.Existing),
190  AddResult(Other.AddResult),
191  AnonymousDeclNumber(Other.AnonymousDeclNumber),
192  TypedefNameForLinkage(Other.TypedefNameForLinkage) {
193  Other.AddResult = false;
194  }
195 
196  ~FindExistingResult();
197 
198  /// \brief Suppress the addition of this result into the known set of
199  /// names.
200  void suppress() { AddResult = false; }
201 
202  operator NamedDecl*() const { return Existing; }
203 
204  template<typename T>
205  operator T*() const { return dyn_cast_or_null<T>(Existing); }
206  };
207 
208  static DeclContext *getPrimaryContextForMerging(ASTReader &Reader,
209  DeclContext *DC);
210  FindExistingResult findExisting(NamedDecl *D);
211 
212  public:
214  ASTReader::RecordLocation Loc,
215  DeclID thisDeclID, SourceLocation ThisDeclLoc)
216  : Reader(Reader), Record(Record), Loc(Loc),
217  ThisDeclID(thisDeclID), ThisDeclLoc(ThisDeclLoc),
218  TypeIDForTypeDecl(0), NamedDeclForTagDecl(0),
219  TypedefNameForLinkage(nullptr), HasPendingBody(false),
220  IsDeclMarkedUsed(false) {}
221 
222  template <typename T> static
225  if (IDs.empty())
226  return;
227 
228  // FIXME: We should avoid this pattern of getting the ASTContext.
229  ASTContext &C = D->getASTContext();
230 
231  auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations;
232 
233  if (auto &Old = LazySpecializations) {
234  IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
235  std::sort(IDs.begin(), IDs.end());
236  IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
237  }
238 
239  auto *Result = new (C) serialization::DeclID[1 + IDs.size()];
240  *Result = IDs.size();
241  std::copy(IDs.begin(), IDs.end(), Result + 1);
242 
243  LazySpecializations = Result;
244  }
245 
246  template <typename DeclT>
247  static Decl *getMostRecentDeclImpl(Redeclarable<DeclT> *D);
248  static Decl *getMostRecentDeclImpl(...);
249  static Decl *getMostRecentDecl(Decl *D);
250 
251  template <typename DeclT>
252  static void attachPreviousDeclImpl(ASTReader &Reader,
254  Decl *Canon);
255  static void attachPreviousDeclImpl(ASTReader &Reader, ...);
256  static void attachPreviousDecl(ASTReader &Reader, Decl *D, Decl *Previous,
257  Decl *Canon);
258 
259  template <typename DeclT>
260  static void attachLatestDeclImpl(Redeclarable<DeclT> *D, Decl *Latest);
261  static void attachLatestDeclImpl(...);
262  static void attachLatestDecl(Decl *D, Decl *latest);
263 
264  template <typename DeclT>
265  static void markIncompleteDeclChainImpl(Redeclarable<DeclT> *D);
266  static void markIncompleteDeclChainImpl(...);
267 
268  /// \brief Determine whether this declaration has a pending body.
269  bool hasPendingBody() const { return HasPendingBody; }
270 
271  void ReadFunctionDefinition(FunctionDecl *FD);
272  void Visit(Decl *D);
273 
275 
278  Cat->NextClassCategory = Next;
279  }
280 
281  void VisitDecl(Decl *D);
282  void VisitPragmaCommentDecl(PragmaCommentDecl *D);
283  void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D);
284  void VisitTranslationUnitDecl(TranslationUnitDecl *TU);
285  void VisitNamedDecl(NamedDecl *ND);
286  void VisitLabelDecl(LabelDecl *LD);
287  void VisitNamespaceDecl(NamespaceDecl *D);
288  void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
289  void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
290  void VisitTypeDecl(TypeDecl *TD);
291  RedeclarableResult VisitTypedefNameDecl(TypedefNameDecl *TD);
292  void VisitTypedefDecl(TypedefDecl *TD);
293  void VisitTypeAliasDecl(TypeAliasDecl *TD);
294  void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
295  RedeclarableResult VisitTagDecl(TagDecl *TD);
296  void VisitEnumDecl(EnumDecl *ED);
297  RedeclarableResult VisitRecordDeclImpl(RecordDecl *RD);
298  void VisitRecordDecl(RecordDecl *RD) { VisitRecordDeclImpl(RD); }
299  RedeclarableResult VisitCXXRecordDeclImpl(CXXRecordDecl *D);
300  void VisitCXXRecordDecl(CXXRecordDecl *D) { VisitCXXRecordDeclImpl(D); }
301  RedeclarableResult VisitClassTemplateSpecializationDeclImpl(
305  VisitClassTemplateSpecializationDeclImpl(D);
306  }
307  void VisitClassTemplatePartialSpecializationDecl(
309  void VisitClassScopeFunctionSpecializationDecl(
311  RedeclarableResult
312  VisitVarTemplateSpecializationDeclImpl(VarTemplateSpecializationDecl *D);
314  VisitVarTemplateSpecializationDeclImpl(D);
315  }
316  void VisitVarTemplatePartialSpecializationDecl(
318  void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
319  void VisitValueDecl(ValueDecl *VD);
320  void VisitEnumConstantDecl(EnumConstantDecl *ECD);
321  void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
322  void VisitDeclaratorDecl(DeclaratorDecl *DD);
323  void VisitFunctionDecl(FunctionDecl *FD);
324  void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *GD);
325  void VisitCXXMethodDecl(CXXMethodDecl *D);
326  void VisitCXXConstructorDecl(CXXConstructorDecl *D);
327  void VisitCXXDestructorDecl(CXXDestructorDecl *D);
328  void VisitCXXConversionDecl(CXXConversionDecl *D);
329  void VisitFieldDecl(FieldDecl *FD);
330  void VisitMSPropertyDecl(MSPropertyDecl *FD);
331  void VisitIndirectFieldDecl(IndirectFieldDecl *FD);
332  RedeclarableResult VisitVarDeclImpl(VarDecl *D);
333  void VisitVarDecl(VarDecl *VD) { VisitVarDeclImpl(VD); }
334  void VisitImplicitParamDecl(ImplicitParamDecl *PD);
335  void VisitParmVarDecl(ParmVarDecl *PD);
336  void VisitDecompositionDecl(DecompositionDecl *DD);
337  void VisitBindingDecl(BindingDecl *BD);
338  void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
339  DeclID VisitTemplateDecl(TemplateDecl *D);
340  RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
341  void VisitClassTemplateDecl(ClassTemplateDecl *D);
342  void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D);
343  void VisitVarTemplateDecl(VarTemplateDecl *D);
344  void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
345  void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
346  void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
347  void VisitUsingDecl(UsingDecl *D);
348  void VisitUsingPackDecl(UsingPackDecl *D);
349  void VisitUsingShadowDecl(UsingShadowDecl *D);
350  void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D);
351  void VisitLinkageSpecDecl(LinkageSpecDecl *D);
352  void VisitExportDecl(ExportDecl *D);
353  void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD);
354  void VisitImportDecl(ImportDecl *D);
355  void VisitAccessSpecDecl(AccessSpecDecl *D);
356  void VisitFriendDecl(FriendDecl *D);
357  void VisitFriendTemplateDecl(FriendTemplateDecl *D);
358  void VisitStaticAssertDecl(StaticAssertDecl *D);
359  void VisitBlockDecl(BlockDecl *BD);
360  void VisitCapturedDecl(CapturedDecl *CD);
361  void VisitEmptyDecl(EmptyDecl *D);
362 
363  std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC);
364 
365  template<typename T>
366  RedeclarableResult VisitRedeclarable(Redeclarable<T> *D);
367 
368  template<typename T>
369  void mergeRedeclarable(Redeclarable<T> *D, RedeclarableResult &Redecl,
370  DeclID TemplatePatternID = 0);
371 
372  template<typename T>
373  void mergeRedeclarable(Redeclarable<T> *D, T *Existing,
374  RedeclarableResult &Redecl,
375  DeclID TemplatePatternID = 0);
376 
377  template<typename T>
378  void mergeMergeable(Mergeable<T> *D);
379 
380  void mergeTemplatePattern(RedeclarableTemplateDecl *D,
381  RedeclarableTemplateDecl *Existing,
382  DeclID DsID, bool IsKeyDecl);
383 
384  ObjCTypeParamList *ReadObjCTypeParamList();
385 
386  // FIXME: Reorder according to DeclNodes.td?
387  void VisitObjCMethodDecl(ObjCMethodDecl *D);
388  void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D);
389  void VisitObjCContainerDecl(ObjCContainerDecl *D);
390  void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
391  void VisitObjCIvarDecl(ObjCIvarDecl *D);
392  void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
393  void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D);
394  void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
395  void VisitObjCImplDecl(ObjCImplDecl *D);
396  void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
397  void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
398  void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
399  void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
400  void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
401  void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
402  void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
403  void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
404  };
405 } // end namespace clang
406 
407 namespace {
408 /// Iterator over the redeclarations of a declaration that have already
409 /// been merged into the same redeclaration chain.
410 template<typename DeclT>
411 class MergedRedeclIterator {
412  DeclT *Start, *Canonical, *Current;
413 public:
414  MergedRedeclIterator() : Current(nullptr) {}
415  MergedRedeclIterator(DeclT *Start)
416  : Start(Start), Canonical(nullptr), Current(Start) {}
417 
418  DeclT *operator*() { return Current; }
419 
420  MergedRedeclIterator &operator++() {
421  if (Current->isFirstDecl()) {
422  Canonical = Current;
423  Current = Current->getMostRecentDecl();
424  } else
425  Current = Current->getPreviousDecl();
426 
427  // If we started in the merged portion, we'll reach our start position
428  // eventually. Otherwise, we'll never reach it, but the second declaration
429  // we reached was the canonical declaration, so stop when we see that one
430  // again.
431  if (Current == Start || Current == Canonical)
432  Current = nullptr;
433  return *this;
434  }
435 
436  friend bool operator!=(const MergedRedeclIterator &A,
437  const MergedRedeclIterator &B) {
438  return A.Current != B.Current;
439  }
440 };
441 } // end anonymous namespace
442 
443 template <typename DeclT>
444 static llvm::iterator_range<MergedRedeclIterator<DeclT>>
445 merged_redecls(DeclT *D) {
446  return llvm::make_range(MergedRedeclIterator<DeclT>(D),
447  MergedRedeclIterator<DeclT>());
448 }
449 
450 uint64_t ASTDeclReader::GetCurrentCursorOffset() {
451  return Loc.F->DeclsCursor.GetCurrentBitNo() + Loc.F->GlobalBitOffset;
452 }
453 
455  if (Record.readInt())
456  Reader.BodySource[FD] = Loc.F->Kind == ModuleKind::MK_MainFile;
457  if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
458  CD->NumCtorInitializers = Record.readInt();
459  if (CD->NumCtorInitializers)
460  CD->CtorInitializers = ReadGlobalOffset();
461  }
462  // Store the offset of the body so we can lazily load it later.
463  Reader.PendingBodies[FD] = GetCurrentCursorOffset();
464  HasPendingBody = true;
465 }
466 
469 
470  // At this point we have deserialized and merged the decl and it is safe to
471  // update its canonical decl to signal that the entire entity is used.
472  D->getCanonicalDecl()->Used |= IsDeclMarkedUsed;
473  IsDeclMarkedUsed = false;
474 
475  if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
476  if (DD->DeclInfo) {
477  DeclaratorDecl::ExtInfo *Info =
478  DD->DeclInfo.get<DeclaratorDecl::ExtInfo *>();
479  Info->TInfo = GetTypeSourceInfo();
480  }
481  else {
482  DD->DeclInfo = GetTypeSourceInfo();
483  }
484  }
485 
486  if (TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
487  // We have a fully initialized TypeDecl. Read its type now.
488  TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull());
489 
490  // If this is a tag declaration with a typedef name for linkage, it's safe
491  // to load that typedef now.
492  if (NamedDeclForTagDecl)
493  cast<TagDecl>(D)->TypedefNameDeclOrQualifier =
494  cast<TypedefNameDecl>(Reader.GetDecl(NamedDeclForTagDecl));
495  } else if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
496  // if we have a fully initialized TypeDecl, we can safely read its type now.
497  ID->TypeForDecl = Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull();
498  } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
499  // FunctionDecl's body was written last after all other Stmts/Exprs.
500  // We only read it if FD doesn't already have a body (e.g., from another
501  // module).
502  // FIXME: Can we diagnose ODR violations somehow?
503  if (Record.readInt())
504  ReadFunctionDefinition(FD);
505  }
506 }
507 
509  if (D->isTemplateParameter() || D->isTemplateParameterPack() ||
510  isa<ParmVarDecl>(D)) {
511  // We don't want to deserialize the DeclContext of a template
512  // parameter or of a parameter of a function template immediately. These
513  // entities might be used in the formulation of its DeclContext (for
514  // example, a function parameter can be used in decltype() in trailing
515  // return type of the function). Use the translation unit DeclContext as a
516  // placeholder.
517  GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID();
518  GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID();
519  if (!LexicalDCIDForTemplateParmDecl)
520  LexicalDCIDForTemplateParmDecl = SemaDCIDForTemplateParmDecl;
521  Reader.addPendingDeclContextInfo(D,
522  SemaDCIDForTemplateParmDecl,
523  LexicalDCIDForTemplateParmDecl);
524  D->setDeclContext(Reader.getContext().getTranslationUnitDecl());
525  } else {
526  DeclContext *SemaDC = ReadDeclAs<DeclContext>();
527  DeclContext *LexicalDC = ReadDeclAs<DeclContext>();
528  if (!LexicalDC)
529  LexicalDC = SemaDC;
530  DeclContext *MergedSemaDC = Reader.MergedDeclContexts.lookup(SemaDC);
531  // Avoid calling setLexicalDeclContext() directly because it uses
532  // Decl::getASTContext() internally which is unsafe during derialization.
533  D->setDeclContextsImpl(MergedSemaDC ? MergedSemaDC : SemaDC, LexicalDC,
534  Reader.getContext());
535  }
536  D->setLocation(ThisDeclLoc);
537  D->setInvalidDecl(Record.readInt());
538  if (Record.readInt()) { // hasAttrs
539  AttrVec Attrs;
540  Record.readAttributes(Attrs);
541  // Avoid calling setAttrs() directly because it uses Decl::getASTContext()
542  // internally which is unsafe during derialization.
543  D->setAttrsImpl(Attrs, Reader.getContext());
544  }
545  D->setImplicit(Record.readInt());
546  D->Used = Record.readInt();
547  IsDeclMarkedUsed |= D->Used;
548  D->setReferenced(Record.readInt());
549  D->setTopLevelDeclInObjCContainer(Record.readInt());
550  D->setAccess((AccessSpecifier)Record.readInt());
551  D->FromASTFile = true;
552  bool ModulePrivate = Record.readInt();
553 
554  // Determine whether this declaration is part of a (sub)module. If so, it
555  // may not yet be visible.
556  if (unsigned SubmoduleID = readSubmoduleID()) {
557  // Store the owning submodule ID in the declaration.
562 
563  if (ModulePrivate) {
564  // Module-private declarations are never visible, so there is no work to
565  // do.
566  } else if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
567  // If local visibility is being tracked, this declaration will become
568  // hidden and visible as the owning module does.
569  } else if (Module *Owner = Reader.getSubmodule(SubmoduleID)) {
570  // Mark the declaration as visible when its owning module becomes visible.
571  if (Owner->NameVisibility == Module::AllVisible)
573  else
574  Reader.HiddenNamesMap[Owner].push_back(D);
575  }
576  } else if (ModulePrivate) {
578  }
579 }
580 
582  VisitDecl(D);
583  D->setLocation(ReadSourceLocation());
584  D->CommentKind = (PragmaMSCommentKind)Record.readInt();
585  std::string Arg = ReadString();
586  memcpy(D->getTrailingObjects<char>(), Arg.data(), Arg.size());
587  D->getTrailingObjects<char>()[Arg.size()] = '\0';
588 }
589 
591  VisitDecl(D);
592  D->setLocation(ReadSourceLocation());
593  std::string Name = ReadString();
594  memcpy(D->getTrailingObjects<char>(), Name.data(), Name.size());
595  D->getTrailingObjects<char>()[Name.size()] = '\0';
596 
597  D->ValueStart = Name.size() + 1;
598  std::string Value = ReadString();
599  memcpy(D->getTrailingObjects<char>() + D->ValueStart, Value.data(),
600  Value.size());
601  D->getTrailingObjects<char>()[D->ValueStart + Value.size()] = '\0';
602 }
603 
605  llvm_unreachable("Translation units are not serialized");
606 }
607 
609  VisitDecl(ND);
610  ND->setDeclName(Record.readDeclarationName());
611  AnonymousDeclNumber = Record.readInt();
612 }
613 
615  VisitNamedDecl(TD);
616  TD->setLocStart(ReadSourceLocation());
617  // Delay type reading until after we have fully initialized the decl.
618  TypeIDForTypeDecl = Record.getGlobalTypeID(Record.readInt());
619 }
620 
621 ASTDeclReader::RedeclarableResult
623  RedeclarableResult Redecl = VisitRedeclarable(TD);
624  VisitTypeDecl(TD);
625  TypeSourceInfo *TInfo = GetTypeSourceInfo();
626  if (Record.readInt()) { // isModed
627  QualType modedT = Record.readType();
628  TD->setModedTypeSourceInfo(TInfo, modedT);
629  } else
630  TD->setTypeSourceInfo(TInfo);
631  // Read and discard the declaration for which this is a typedef name for
632  // linkage, if it exists. We cannot rely on our type to pull in this decl,
633  // because it might have been merged with a type from another module and
634  // thus might not refer to our version of the declaration.
635  ReadDecl();
636  return Redecl;
637 }
638 
640  RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
641  mergeRedeclarable(TD, Redecl);
642 }
643 
645  RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
646  if (auto *Template = ReadDeclAs<TypeAliasTemplateDecl>())
647  // Merged when we merge the template.
648  TD->setDescribedAliasTemplate(Template);
649  else
650  mergeRedeclarable(TD, Redecl);
651 }
652 
653 ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) {
654  RedeclarableResult Redecl = VisitRedeclarable(TD);
655  VisitTypeDecl(TD);
656 
657  TD->IdentifierNamespace = Record.readInt();
658  TD->setTagKind((TagDecl::TagKind)Record.readInt());
659  if (!isa<CXXRecordDecl>(TD))
660  TD->setCompleteDefinition(Record.readInt());
661  TD->setEmbeddedInDeclarator(Record.readInt());
662  TD->setFreeStanding(Record.readInt());
663  TD->setCompleteDefinitionRequired(Record.readInt());
664  TD->setBraceRange(ReadSourceRange());
665 
666  switch (Record.readInt()) {
667  case 0:
668  break;
669  case 1: { // ExtInfo
670  TagDecl::ExtInfo *Info = new (Reader.getContext()) TagDecl::ExtInfo();
671  ReadQualifierInfo(*Info);
672  TD->TypedefNameDeclOrQualifier = Info;
673  break;
674  }
675  case 2: // TypedefNameForAnonDecl
676  NamedDeclForTagDecl = ReadDeclID();
677  TypedefNameForLinkage = Record.getIdentifierInfo();
678  break;
679  default:
680  llvm_unreachable("unexpected tag info kind");
681  }
682 
683  if (!isa<CXXRecordDecl>(TD))
684  mergeRedeclarable(TD, Redecl);
685  return Redecl;
686 }
687 
689  VisitTagDecl(ED);
690  if (TypeSourceInfo *TI = GetTypeSourceInfo())
691  ED->setIntegerTypeSourceInfo(TI);
692  else
693  ED->setIntegerType(Record.readType());
694  ED->setPromotionType(Record.readType());
695  ED->setNumPositiveBits(Record.readInt());
696  ED->setNumNegativeBits(Record.readInt());
697  ED->IsScoped = Record.readInt();
698  ED->IsScopedUsingClassTag = Record.readInt();
699  ED->IsFixed = Record.readInt();
700 
701  // If this is a definition subject to the ODR, and we already have a
702  // definition, merge this one into it.
703  if (ED->IsCompleteDefinition &&
704  Reader.getContext().getLangOpts().Modules &&
705  Reader.getContext().getLangOpts().CPlusPlus) {
706  EnumDecl *&OldDef = Reader.EnumDefinitions[ED->getCanonicalDecl()];
707  if (!OldDef) {
708  // This is the first time we've seen an imported definition. Look for a
709  // local definition before deciding that we are the first definition.
710  for (auto *D : merged_redecls(ED->getCanonicalDecl())) {
711  if (!D->isFromASTFile() && D->isCompleteDefinition()) {
712  OldDef = D;
713  break;
714  }
715  }
716  }
717  if (OldDef) {
718  Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
719  ED->IsCompleteDefinition = false;
720  Reader.mergeDefinitionVisibility(OldDef, ED);
721  } else {
722  OldDef = ED;
723  }
724  }
725 
726  if (EnumDecl *InstED = ReadDeclAs<EnumDecl>()) {
728  (TemplateSpecializationKind)Record.readInt();
729  SourceLocation POI = ReadSourceLocation();
730  ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK);
732  }
733 }
734 
735 ASTDeclReader::RedeclarableResult
737  RedeclarableResult Redecl = VisitTagDecl(RD);
738  RD->setHasFlexibleArrayMember(Record.readInt());
739  RD->setAnonymousStructOrUnion(Record.readInt());
740  RD->setHasObjectMember(Record.readInt());
741  RD->setHasVolatileMember(Record.readInt());
742  return Redecl;
743 }
744 
746  VisitNamedDecl(VD);
747  VD->setType(Record.readType());
748 }
749 
751  VisitValueDecl(ECD);
752  if (Record.readInt())
753  ECD->setInitExpr(Record.readExpr());
754  ECD->setInitVal(Record.readAPSInt());
755  mergeMergeable(ECD);
756 }
757 
759  VisitValueDecl(DD);
760  DD->setInnerLocStart(ReadSourceLocation());
761  if (Record.readInt()) { // hasExtInfo
762  DeclaratorDecl::ExtInfo *Info
763  = new (Reader.getContext()) DeclaratorDecl::ExtInfo();
764  ReadQualifierInfo(*Info);
765  DD->DeclInfo = Info;
766  }
767 }
768 
770  RedeclarableResult Redecl = VisitRedeclarable(FD);
771  VisitDeclaratorDecl(FD);
772 
773  ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName());
774  FD->IdentifierNamespace = Record.readInt();
775 
776  // FunctionDecl's body is handled last at ASTDeclReader::Visit,
777  // after everything else is read.
778 
779  FD->SClass = (StorageClass)Record.readInt();
780  FD->IsInline = Record.readInt();
781  FD->IsInlineSpecified = Record.readInt();
782  FD->IsExplicitSpecified = Record.readInt();
783  FD->IsVirtualAsWritten = Record.readInt();
784  FD->IsPure = Record.readInt();
785  FD->HasInheritedPrototype = Record.readInt();
786  FD->HasWrittenPrototype = Record.readInt();
787  FD->IsDeleted = Record.readInt();
788  FD->IsTrivial = Record.readInt();
789  FD->IsDefaulted = Record.readInt();
790  FD->IsExplicitlyDefaulted = Record.readInt();
791  FD->HasImplicitReturnZero = Record.readInt();
792  FD->IsConstexpr = Record.readInt();
793  FD->UsesSEHTry = Record.readInt();
794  FD->HasSkippedBody = Record.readInt();
795  FD->IsLateTemplateParsed = Record.readInt();
796  FD->setCachedLinkage(Linkage(Record.readInt()));
797  FD->EndRangeLoc = ReadSourceLocation();
798 
799  switch ((FunctionDecl::TemplatedKind)Record.readInt()) {
801  mergeRedeclarable(FD, Redecl);
802  break;
804  // Merged when we merge the template.
805  FD->setDescribedFunctionTemplate(ReadDeclAs<FunctionTemplateDecl>());
806  break;
808  FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>();
810  (TemplateSpecializationKind)Record.readInt();
811  SourceLocation POI = ReadSourceLocation();
812  FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
814  mergeRedeclarable(FD, Redecl);
815  break;
816  }
818  FunctionTemplateDecl *Template = ReadDeclAs<FunctionTemplateDecl>();
820  (TemplateSpecializationKind)Record.readInt();
821 
822  // Template arguments.
824  Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
825 
826  // Template args as written.
828  SourceLocation LAngleLoc, RAngleLoc;
829  bool HasTemplateArgumentsAsWritten = Record.readInt();
830  if (HasTemplateArgumentsAsWritten) {
831  unsigned NumTemplateArgLocs = Record.readInt();
832  TemplArgLocs.reserve(NumTemplateArgLocs);
833  for (unsigned i=0; i != NumTemplateArgLocs; ++i)
834  TemplArgLocs.push_back(Record.readTemplateArgumentLoc());
835 
836  LAngleLoc = ReadSourceLocation();
837  RAngleLoc = ReadSourceLocation();
838  }
839 
840  SourceLocation POI = ReadSourceLocation();
841 
842  ASTContext &C = Reader.getContext();
843  TemplateArgumentList *TemplArgList
844  = TemplateArgumentList::CreateCopy(C, TemplArgs);
845  TemplateArgumentListInfo TemplArgsInfo(LAngleLoc, RAngleLoc);
846  for (unsigned i=0, e = TemplArgLocs.size(); i != e; ++i)
847  TemplArgsInfo.addArgument(TemplArgLocs[i]);
849  = FunctionTemplateSpecializationInfo::Create(C, FD, Template, TSK,
850  TemplArgList,
851  HasTemplateArgumentsAsWritten ? &TemplArgsInfo
852  : nullptr,
853  POI);
854  FD->TemplateOrSpecialization = FTInfo;
855 
856  if (FD->isCanonicalDecl()) { // if canonical add to template's set.
857  // The template that contains the specializations set. It's not safe to
858  // use getCanonicalDecl on Template since it may still be initializing.
859  FunctionTemplateDecl *CanonTemplate = ReadDeclAs<FunctionTemplateDecl>();
860  // Get the InsertPos by FindNodeOrInsertPos() instead of calling
861  // InsertNode(FTInfo) directly to avoid the getASTContext() call in
862  // FunctionTemplateSpecializationInfo's Profile().
863  // We avoid getASTContext because a decl in the parent hierarchy may
864  // be initializing.
865  llvm::FoldingSetNodeID ID;
867  void *InsertPos = nullptr;
868  FunctionTemplateDecl::Common *CommonPtr = CanonTemplate->getCommonPtr();
869  FunctionTemplateSpecializationInfo *ExistingInfo =
870  CommonPtr->Specializations.FindNodeOrInsertPos(ID, InsertPos);
871  if (InsertPos)
872  CommonPtr->Specializations.InsertNode(FTInfo, InsertPos);
873  else {
874  assert(Reader.getContext().getLangOpts().Modules &&
875  "already deserialized this template specialization");
876  mergeRedeclarable(FD, ExistingInfo->Function, Redecl);
877  }
878  }
879  break;
880  }
882  // Templates.
883  UnresolvedSet<8> TemplDecls;
884  unsigned NumTemplates = Record.readInt();
885  while (NumTemplates--)
886  TemplDecls.addDecl(ReadDeclAs<NamedDecl>());
887 
888  // Templates args.
889  TemplateArgumentListInfo TemplArgs;
890  unsigned NumArgs = Record.readInt();
891  while (NumArgs--)
892  TemplArgs.addArgument(Record.readTemplateArgumentLoc());
893  TemplArgs.setLAngleLoc(ReadSourceLocation());
894  TemplArgs.setRAngleLoc(ReadSourceLocation());
895 
896  FD->setDependentTemplateSpecialization(Reader.getContext(),
897  TemplDecls, TemplArgs);
898  // These are not merged; we don't need to merge redeclarations of dependent
899  // template friends.
900  break;
901  }
902  }
903 
904  // Read in the parameters.
905  unsigned NumParams = Record.readInt();
907  Params.reserve(NumParams);
908  for (unsigned I = 0; I != NumParams; ++I)
909  Params.push_back(ReadDeclAs<ParmVarDecl>());
910  FD->setParams(Reader.getContext(), Params);
911 }
912 
914  VisitNamedDecl(MD);
915  if (Record.readInt()) {
916  // Load the body on-demand. Most clients won't care, because method
917  // definitions rarely show up in headers.
918  Reader.PendingBodies[MD] = GetCurrentCursorOffset();
919  HasPendingBody = true;
920  MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>());
921  MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>());
922  }
923  MD->setInstanceMethod(Record.readInt());
924  MD->setVariadic(Record.readInt());
925  MD->setPropertyAccessor(Record.readInt());
926  MD->setDefined(Record.readInt());
927  MD->IsOverriding = Record.readInt();
928  MD->HasSkippedBody = Record.readInt();
929 
930  MD->IsRedeclaration = Record.readInt();
931  MD->HasRedeclaration = Record.readInt();
932  if (MD->HasRedeclaration)
933  Reader.getContext().setObjCMethodRedeclaration(MD,
934  ReadDeclAs<ObjCMethodDecl>());
935 
937  MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record.readInt());
938  MD->SetRelatedResultType(Record.readInt());
939  MD->setReturnType(Record.readType());
940  MD->setReturnTypeSourceInfo(GetTypeSourceInfo());
941  MD->DeclEndLoc = ReadSourceLocation();
942  unsigned NumParams = Record.readInt();
944  Params.reserve(NumParams);
945  for (unsigned I = 0; I != NumParams; ++I)
946  Params.push_back(ReadDeclAs<ParmVarDecl>());
947 
948  MD->SelLocsKind = Record.readInt();
949  unsigned NumStoredSelLocs = Record.readInt();
951  SelLocs.reserve(NumStoredSelLocs);
952  for (unsigned i = 0; i != NumStoredSelLocs; ++i)
953  SelLocs.push_back(ReadSourceLocation());
954 
955  MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs);
956 }
957 
959  VisitTypedefNameDecl(D);
960 
961  D->Variance = Record.readInt();
962  D->Index = Record.readInt();
963  D->VarianceLoc = ReadSourceLocation();
964  D->ColonLoc = ReadSourceLocation();
965 }
966 
968  VisitNamedDecl(CD);
969  CD->setAtStartLoc(ReadSourceLocation());
970  CD->setAtEndRange(ReadSourceRange());
971 }
972 
974  unsigned numParams = Record.readInt();
975  if (numParams == 0)
976  return nullptr;
977 
979  typeParams.reserve(numParams);
980  for (unsigned i = 0; i != numParams; ++i) {
981  auto typeParam = ReadDeclAs<ObjCTypeParamDecl>();
982  if (!typeParam)
983  return nullptr;
984 
985  typeParams.push_back(typeParam);
986  }
987 
988  SourceLocation lAngleLoc = ReadSourceLocation();
989  SourceLocation rAngleLoc = ReadSourceLocation();
990 
991  return ObjCTypeParamList::create(Reader.getContext(), lAngleLoc,
992  typeParams, rAngleLoc);
993 }
994 
995 void ASTDeclReader::ReadObjCDefinitionData(
996  struct ObjCInterfaceDecl::DefinitionData &Data) {
997  // Read the superclass.
998  Data.SuperClassTInfo = GetTypeSourceInfo();
999 
1000  Data.EndLoc = ReadSourceLocation();
1001  Data.HasDesignatedInitializers = Record.readInt();
1002 
1003  // Read the directly referenced protocols and their SourceLocations.
1004  unsigned NumProtocols = Record.readInt();
1006  Protocols.reserve(NumProtocols);
1007  for (unsigned I = 0; I != NumProtocols; ++I)
1008  Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
1010  ProtoLocs.reserve(NumProtocols);
1011  for (unsigned I = 0; I != NumProtocols; ++I)
1012  ProtoLocs.push_back(ReadSourceLocation());
1013  Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, ProtoLocs.data(),
1014  Reader.getContext());
1015 
1016  // Read the transitive closure of protocols referenced by this class.
1017  NumProtocols = Record.readInt();
1018  Protocols.clear();
1019  Protocols.reserve(NumProtocols);
1020  for (unsigned I = 0; I != NumProtocols; ++I)
1021  Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
1022  Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
1023  Reader.getContext());
1024 }
1025 
1026 void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D,
1027  struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
1028  // FIXME: odr checking?
1029 }
1030 
1032  RedeclarableResult Redecl = VisitRedeclarable(ID);
1033  VisitObjCContainerDecl(ID);
1034  TypeIDForTypeDecl = Record.getGlobalTypeID(Record.readInt());
1035  mergeRedeclarable(ID, Redecl);
1036 
1037  ID->TypeParamList = ReadObjCTypeParamList();
1038  if (Record.readInt()) {
1039  // Read the definition.
1040  ID->allocateDefinitionData();
1041 
1042  ReadObjCDefinitionData(ID->data());
1043  ObjCInterfaceDecl *Canon = ID->getCanonicalDecl();
1044  if (Canon->Data.getPointer()) {
1045  // If we already have a definition, keep the definition invariant and
1046  // merge the data.
1047  MergeDefinitionData(Canon, std::move(ID->data()));
1048  ID->Data = Canon->Data;
1049  } else {
1050  // Set the definition data of the canonical declaration, so other
1051  // redeclarations will see it.
1052  ID->getCanonicalDecl()->Data = ID->Data;
1053 
1054  // We will rebuild this list lazily.
1055  ID->setIvarList(nullptr);
1056  }
1057 
1058  // Note that we have deserialized a definition.
1059  Reader.PendingDefinitions.insert(ID);
1060 
1061  // Note that we've loaded this Objective-C class.
1062  Reader.ObjCClassesLoaded.push_back(ID);
1063  } else {
1064  ID->Data = ID->getCanonicalDecl()->Data;
1065  }
1066 }
1067 
1069  VisitFieldDecl(IVD);
1070  IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record.readInt());
1071  // This field will be built lazily.
1072  IVD->setNextIvar(nullptr);
1073  bool synth = Record.readInt();
1074  IVD->setSynthesize(synth);
1075 }
1076 
1077 void ASTDeclReader::ReadObjCDefinitionData(
1078  struct ObjCProtocolDecl::DefinitionData &Data) {
1079 
1080  unsigned NumProtoRefs = Record.readInt();
1082  ProtoRefs.reserve(NumProtoRefs);
1083  for (unsigned I = 0; I != NumProtoRefs; ++I)
1084  ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
1086  ProtoLocs.reserve(NumProtoRefs);
1087  for (unsigned I = 0; I != NumProtoRefs; ++I)
1088  ProtoLocs.push_back(ReadSourceLocation());
1089  Data.ReferencedProtocols.set(ProtoRefs.data(), NumProtoRefs,
1090  ProtoLocs.data(), Reader.getContext());
1091 }
1092 
1093 void ASTDeclReader::MergeDefinitionData(ObjCProtocolDecl *D,
1094  struct ObjCProtocolDecl::DefinitionData &&NewDD) {
1095  // FIXME: odr checking?
1096 }
1097 
1099  RedeclarableResult Redecl = VisitRedeclarable(PD);
1100  VisitObjCContainerDecl(PD);
1101  mergeRedeclarable(PD, Redecl);
1102 
1103  if (Record.readInt()) {
1104  // Read the definition.
1105  PD->allocateDefinitionData();
1106 
1107  ReadObjCDefinitionData(PD->data());
1108 
1109  ObjCProtocolDecl *Canon = PD->getCanonicalDecl();
1110  if (Canon->Data.getPointer()) {
1111  // If we already have a definition, keep the definition invariant and
1112  // merge the data.
1113  MergeDefinitionData(Canon, std::move(PD->data()));
1114  PD->Data = Canon->Data;
1115  } else {
1116  // Set the definition data of the canonical declaration, so other
1117  // redeclarations will see it.
1118  PD->getCanonicalDecl()->Data = PD->Data;
1119  }
1120  // Note that we have deserialized a definition.
1121  Reader.PendingDefinitions.insert(PD);
1122  } else {
1123  PD->Data = PD->getCanonicalDecl()->Data;
1124  }
1125 }
1126 
1128  VisitFieldDecl(FD);
1129 }
1130 
1132  VisitObjCContainerDecl(CD);
1133  CD->setCategoryNameLoc(ReadSourceLocation());
1134  CD->setIvarLBraceLoc(ReadSourceLocation());
1135  CD->setIvarRBraceLoc(ReadSourceLocation());
1136 
1137  // Note that this category has been deserialized. We do this before
1138  // deserializing the interface declaration, so that it will consider this
1139  /// category.
1140  Reader.CategoriesDeserialized.insert(CD);
1141 
1142  CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>();
1143  CD->TypeParamList = ReadObjCTypeParamList();
1144  unsigned NumProtoRefs = Record.readInt();
1146  ProtoRefs.reserve(NumProtoRefs);
1147  for (unsigned I = 0; I != NumProtoRefs; ++I)
1148  ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
1150  ProtoLocs.reserve(NumProtoRefs);
1151  for (unsigned I = 0; I != NumProtoRefs; ++I)
1152  ProtoLocs.push_back(ReadSourceLocation());
1153  CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
1154  Reader.getContext());
1155 }
1156 
1158  VisitNamedDecl(CAD);
1159  CAD->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>());
1160 }
1161 
1163  VisitNamedDecl(D);
1164  D->setAtLoc(ReadSourceLocation());
1165  D->setLParenLoc(ReadSourceLocation());
1166  QualType T = Record.readType();
1167  TypeSourceInfo *TSI = GetTypeSourceInfo();
1168  D->setType(T, TSI);
1170  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
1172  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
1174  (ObjCPropertyDecl::PropertyControl)Record.readInt());
1175  DeclarationName GetterName = Record.readDeclarationName();
1176  SourceLocation GetterLoc = ReadSourceLocation();
1177  D->setGetterName(GetterName.getObjCSelector(), GetterLoc);
1178  DeclarationName SetterName = Record.readDeclarationName();
1179  SourceLocation SetterLoc = ReadSourceLocation();
1180  D->setSetterName(SetterName.getObjCSelector(), SetterLoc);
1181  D->setGetterMethodDecl(ReadDeclAs<ObjCMethodDecl>());
1182  D->setSetterMethodDecl(ReadDeclAs<ObjCMethodDecl>());
1183  D->setPropertyIvarDecl(ReadDeclAs<ObjCIvarDecl>());
1184 }
1185 
1187  VisitObjCContainerDecl(D);
1188  D->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>());
1189 }
1190 
1192  VisitObjCImplDecl(D);
1193  D->CategoryNameLoc = ReadSourceLocation();
1194 }
1195 
1197  VisitObjCImplDecl(D);
1198  D->setSuperClass(ReadDeclAs<ObjCInterfaceDecl>());
1199  D->SuperLoc = ReadSourceLocation();
1200  D->setIvarLBraceLoc(ReadSourceLocation());
1201  D->setIvarRBraceLoc(ReadSourceLocation());
1202  D->setHasNonZeroConstructors(Record.readInt());
1203  D->setHasDestructors(Record.readInt());
1204  D->NumIvarInitializers = Record.readInt();
1205  if (D->NumIvarInitializers)
1206  D->IvarInitializers = ReadGlobalOffset();
1207 }
1208 
1210  VisitDecl(D);
1211  D->setAtLoc(ReadSourceLocation());
1212  D->setPropertyDecl(ReadDeclAs<ObjCPropertyDecl>());
1213  D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>();
1214  D->IvarLoc = ReadSourceLocation();
1215  D->setGetterCXXConstructor(Record.readExpr());
1216  D->setSetterCXXAssignment(Record.readExpr());
1217 }
1218 
1220  VisitDeclaratorDecl(FD);
1221  FD->Mutable = Record.readInt();
1222  if (int BitWidthOrInitializer = Record.readInt()) {
1223  FD->InitStorage.setInt(
1224  static_cast<FieldDecl::InitStorageKind>(BitWidthOrInitializer - 1));
1225  if (FD->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
1226  // Read captured variable length array.
1227  FD->InitStorage.setPointer(Record.readType().getAsOpaquePtr());
1228  } else {
1229  FD->InitStorage.setPointer(Record.readExpr());
1230  }
1231  }
1232  if (!FD->getDeclName()) {
1233  if (FieldDecl *Tmpl = ReadDeclAs<FieldDecl>())
1234  Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
1235  }
1236  mergeMergeable(FD);
1237 }
1238 
1240  VisitDeclaratorDecl(PD);
1241  PD->GetterId = Record.getIdentifierInfo();
1242  PD->SetterId = Record.getIdentifierInfo();
1243 }
1244 
1246  VisitValueDecl(FD);
1247 
1248  FD->ChainingSize = Record.readInt();
1249  assert(FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2");
1250  FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize];
1251 
1252  for (unsigned I = 0; I != FD->ChainingSize; ++I)
1253  FD->Chaining[I] = ReadDeclAs<NamedDecl>();
1254 
1255  mergeMergeable(FD);
1256 }
1257 
1258 ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
1259  RedeclarableResult Redecl = VisitRedeclarable(VD);
1260  VisitDeclaratorDecl(VD);
1261 
1262  VD->VarDeclBits.SClass = (StorageClass)Record.readInt();
1263  VD->VarDeclBits.TSCSpec = Record.readInt();
1264  VD->VarDeclBits.InitStyle = Record.readInt();
1265  if (!isa<ParmVarDecl>(VD)) {
1266  VD->NonParmVarDeclBits.IsThisDeclarationADemotedDefinition =
1267  Record.readInt();
1268  VD->NonParmVarDeclBits.ExceptionVar = Record.readInt();
1269  VD->NonParmVarDeclBits.NRVOVariable = Record.readInt();
1270  VD->NonParmVarDeclBits.CXXForRangeDecl = Record.readInt();
1271  VD->NonParmVarDeclBits.ARCPseudoStrong = Record.readInt();
1272  VD->NonParmVarDeclBits.IsInline = Record.readInt();
1273  VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
1274  VD->NonParmVarDeclBits.IsConstexpr = Record.readInt();
1275  VD->NonParmVarDeclBits.IsInitCapture = Record.readInt();
1276  VD->NonParmVarDeclBits.PreviousDeclInSameBlockScope = Record.readInt();
1277  VD->NonParmVarDeclBits.ImplicitParamKind = Record.readInt();
1278  }
1279  Linkage VarLinkage = Linkage(Record.readInt());
1280  VD->setCachedLinkage(VarLinkage);
1281 
1282  // Reconstruct the one piece of the IdentifierNamespace that we need.
1283  if (VD->getStorageClass() == SC_Extern && VarLinkage != NoLinkage &&
1285  VD->setLocalExternDecl();
1286 
1287  if (uint64_t Val = Record.readInt()) {
1288  VD->setInit(Record.readExpr());
1289  if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3
1290  EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
1291  Eval->CheckedICE = true;
1292  Eval->IsICE = Val == 3;
1293  }
1294  }
1295 
1296  enum VarKind {
1297  VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1298  };
1299  switch ((VarKind)Record.readInt()) {
1300  case VarNotTemplate:
1301  // Only true variables (not parameters or implicit parameters) can be
1302  // merged; the other kinds are not really redeclarable at all.
1303  if (!isa<ParmVarDecl>(VD) && !isa<ImplicitParamDecl>(VD) &&
1304  !isa<VarTemplateSpecializationDecl>(VD))
1305  mergeRedeclarable(VD, Redecl);
1306  break;
1307  case VarTemplate:
1308  // Merged when we merge the template.
1309  VD->setDescribedVarTemplate(ReadDeclAs<VarTemplateDecl>());
1310  break;
1311  case StaticDataMemberSpecialization: { // HasMemberSpecializationInfo.
1312  VarDecl *Tmpl = ReadDeclAs<VarDecl>();
1314  (TemplateSpecializationKind)Record.readInt();
1315  SourceLocation POI = ReadSourceLocation();
1316  Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
1317  mergeRedeclarable(VD, Redecl);
1318  break;
1319  }
1320  }
1321 
1322  return Redecl;
1323 }
1324 
1326  VisitVarDecl(PD);
1327 }
1328 
1330  VisitVarDecl(PD);
1331  unsigned isObjCMethodParam = Record.readInt();
1332  unsigned scopeDepth = Record.readInt();
1333  unsigned scopeIndex = Record.readInt();
1334  unsigned declQualifier = Record.readInt();
1335  if (isObjCMethodParam) {
1336  assert(scopeDepth == 0);
1337  PD->setObjCMethodScopeInfo(scopeIndex);
1338  PD->ParmVarDeclBits.ScopeDepthOrObjCQuals = declQualifier;
1339  } else {
1340  PD->setScopeInfo(scopeDepth, scopeIndex);
1341  }
1342  PD->ParmVarDeclBits.IsKNRPromoted = Record.readInt();
1343  PD->ParmVarDeclBits.HasInheritedDefaultArg = Record.readInt();
1344  if (Record.readInt()) // hasUninstantiatedDefaultArg.
1345  PD->setUninstantiatedDefaultArg(Record.readExpr());
1346 
1347  // FIXME: If this is a redeclaration of a function from another module, handle
1348  // inheritance of default arguments.
1349 }
1350 
1352  VisitVarDecl(DD);
1353  BindingDecl **BDs = DD->getTrailingObjects<BindingDecl*>();
1354  for (unsigned I = 0; I != DD->NumBindings; ++I)
1355  BDs[I] = ReadDeclAs<BindingDecl>();
1356 }
1357 
1359  VisitValueDecl(BD);
1360  BD->Binding = Record.readExpr();
1361 }
1362 
1364  VisitDecl(AD);
1365  AD->setAsmString(cast<StringLiteral>(Record.readExpr()));
1366  AD->setRParenLoc(ReadSourceLocation());
1367 }
1368 
1370  VisitDecl(BD);
1371  BD->setBody(cast_or_null<CompoundStmt>(Record.readStmt()));
1372  BD->setSignatureAsWritten(GetTypeSourceInfo());
1373  unsigned NumParams = Record.readInt();
1375  Params.reserve(NumParams);
1376  for (unsigned I = 0; I != NumParams; ++I)
1377  Params.push_back(ReadDeclAs<ParmVarDecl>());
1378  BD->setParams(Params);
1379 
1380  BD->setIsVariadic(Record.readInt());
1381  BD->setBlockMissingReturnType(Record.readInt());
1382  BD->setIsConversionFromLambda(Record.readInt());
1383 
1384  bool capturesCXXThis = Record.readInt();
1385  unsigned numCaptures = Record.readInt();
1387  captures.reserve(numCaptures);
1388  for (unsigned i = 0; i != numCaptures; ++i) {
1389  VarDecl *decl = ReadDeclAs<VarDecl>();
1390  unsigned flags = Record.readInt();
1391  bool byRef = (flags & 1);
1392  bool nested = (flags & 2);
1393  Expr *copyExpr = ((flags & 4) ? Record.readExpr() : nullptr);
1394 
1395  captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr));
1396  }
1397  BD->setCaptures(Reader.getContext(), captures, capturesCXXThis);
1398 }
1399 
1401  VisitDecl(CD);
1402  unsigned ContextParamPos = Record.readInt();
1403  CD->setNothrow(Record.readInt() != 0);
1404  // Body is set by VisitCapturedStmt.
1405  for (unsigned I = 0; I < CD->NumParams; ++I) {
1406  if (I != ContextParamPos)
1407  CD->setParam(I, ReadDeclAs<ImplicitParamDecl>());
1408  else
1409  CD->setContextParam(I, ReadDeclAs<ImplicitParamDecl>());
1410  }
1411 }
1412 
1414  VisitDecl(D);
1415  D->setLanguage((LinkageSpecDecl::LanguageIDs)Record.readInt());
1416  D->setExternLoc(ReadSourceLocation());
1417  D->setRBraceLoc(ReadSourceLocation());
1418 }
1419 
1421  VisitDecl(D);
1422  D->RBraceLoc = ReadSourceLocation();
1423 }
1424 
1426  VisitNamedDecl(D);
1427  D->setLocStart(ReadSourceLocation());
1428 }
1429 
1431  RedeclarableResult Redecl = VisitRedeclarable(D);
1432  VisitNamedDecl(D);
1433  D->setInline(Record.readInt());
1434  D->LocStart = ReadSourceLocation();
1435  D->RBraceLoc = ReadSourceLocation();
1436 
1437  // Defer loading the anonymous namespace until we've finished merging
1438  // this namespace; loading it might load a later declaration of the
1439  // same namespace, and we have an invariant that older declarations
1440  // get merged before newer ones try to merge.
1441  GlobalDeclID AnonNamespace = 0;
1442  if (Redecl.getFirstID() == ThisDeclID) {
1443  AnonNamespace = ReadDeclID();
1444  } else {
1445  // Link this namespace back to the first declaration, which has already
1446  // been deserialized.
1447  D->AnonOrFirstNamespaceAndInline.setPointer(D->getFirstDecl());
1448  }
1449 
1450  mergeRedeclarable(D, Redecl);
1451 
1452  if (AnonNamespace) {
1453  // Each module has its own anonymous namespace, which is disjoint from
1454  // any other module's anonymous namespaces, so don't attach the anonymous
1455  // namespace at all.
1456  NamespaceDecl *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
1457  if (!Record.isModule())
1458  D->setAnonymousNamespace(Anon);
1459  }
1460 }
1461 
1463  RedeclarableResult Redecl = VisitRedeclarable(D);
1464  VisitNamedDecl(D);
1465  D->NamespaceLoc = ReadSourceLocation();
1466  D->IdentLoc = ReadSourceLocation();
1467  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1468  D->Namespace = ReadDeclAs<NamedDecl>();
1469  mergeRedeclarable(D, Redecl);
1470 }
1471 
1473  VisitNamedDecl(D);
1474  D->setUsingLoc(ReadSourceLocation());
1475  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1476  ReadDeclarationNameLoc(D->DNLoc, D->getDeclName());
1477  D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>());
1478  D->setTypename(Record.readInt());
1479  if (NamedDecl *Pattern = ReadDeclAs<NamedDecl>())
1480  Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
1481  mergeMergeable(D);
1482 }
1483 
1485  VisitNamedDecl(D);
1486  D->InstantiatedFrom = ReadDeclAs<NamedDecl>();
1487  NamedDecl **Expansions = D->getTrailingObjects<NamedDecl*>();
1488  for (unsigned I = 0; I != D->NumExpansions; ++I)
1489  Expansions[I] = ReadDeclAs<NamedDecl>();
1490  mergeMergeable(D);
1491 }
1492 
1494  RedeclarableResult Redecl = VisitRedeclarable(D);
1495  VisitNamedDecl(D);
1496  D->setTargetDecl(ReadDeclAs<NamedDecl>());
1497  D->UsingOrNextShadow = ReadDeclAs<NamedDecl>();
1498  UsingShadowDecl *Pattern = ReadDeclAs<UsingShadowDecl>();
1499  if (Pattern)
1500  Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern);
1501  mergeRedeclarable(D, Redecl);
1502 }
1503 
1506  VisitUsingShadowDecl(D);
1507  D->NominatedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
1508  D->ConstructedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
1509  D->IsVirtual = Record.readInt();
1510 }
1511 
1513  VisitNamedDecl(D);
1514  D->UsingLoc = ReadSourceLocation();
1515  D->NamespaceLoc = ReadSourceLocation();
1516  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1517  D->NominatedNamespace = ReadDeclAs<NamedDecl>();
1518  D->CommonAncestor = ReadDeclAs<DeclContext>();
1519 }
1520 
1522  VisitValueDecl(D);
1523  D->setUsingLoc(ReadSourceLocation());
1524  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1525  ReadDeclarationNameLoc(D->DNLoc, D->getDeclName());
1526  D->EllipsisLoc = ReadSourceLocation();
1527  mergeMergeable(D);
1528 }
1529 
1532  VisitTypeDecl(D);
1533  D->TypenameLocation = ReadSourceLocation();
1534  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1535  D->EllipsisLoc = ReadSourceLocation();
1536  mergeMergeable(D);
1537 }
1538 
1539 void ASTDeclReader::ReadCXXDefinitionData(
1540  struct CXXRecordDecl::DefinitionData &Data, const CXXRecordDecl *D) {
1541  // Note: the caller has deserialized the IsLambda bit already.
1542  Data.UserDeclaredConstructor = Record.readInt();
1543  Data.UserDeclaredSpecialMembers = Record.readInt();
1544  Data.Aggregate = Record.readInt();
1545  Data.PlainOldData = Record.readInt();
1546  Data.Empty = Record.readInt();
1547  Data.Polymorphic = Record.readInt();
1548  Data.Abstract = Record.readInt();
1549  Data.IsStandardLayout = Record.readInt();
1550  Data.HasNoNonEmptyBases = Record.readInt();
1551  Data.HasPrivateFields = Record.readInt();
1552  Data.HasProtectedFields = Record.readInt();
1553  Data.HasPublicFields = Record.readInt();
1554  Data.HasMutableFields = Record.readInt();
1555  Data.HasVariantMembers = Record.readInt();
1556  Data.HasOnlyCMembers = Record.readInt();
1557  Data.HasInClassInitializer = Record.readInt();
1558  Data.HasUninitializedReferenceMember = Record.readInt();
1559  Data.HasUninitializedFields = Record.readInt();
1560  Data.HasInheritedConstructor = Record.readInt();
1561  Data.HasInheritedAssignment = Record.readInt();
1562  Data.NeedOverloadResolutionForCopyConstructor = Record.readInt();
1563  Data.NeedOverloadResolutionForMoveConstructor = Record.readInt();
1564  Data.NeedOverloadResolutionForMoveAssignment = Record.readInt();
1565  Data.NeedOverloadResolutionForDestructor = Record.readInt();
1566  Data.DefaultedCopyConstructorIsDeleted = Record.readInt();
1567  Data.DefaultedMoveConstructorIsDeleted = Record.readInt();
1568  Data.DefaultedMoveAssignmentIsDeleted = Record.readInt();
1569  Data.DefaultedDestructorIsDeleted = Record.readInt();
1570  Data.HasTrivialSpecialMembers = Record.readInt();
1571  Data.DeclaredNonTrivialSpecialMembers = Record.readInt();
1572  Data.HasIrrelevantDestructor = Record.readInt();
1573  Data.HasConstexprNonCopyMoveConstructor = Record.readInt();
1574  Data.HasDefaultedDefaultConstructor = Record.readInt();
1575  Data.CanPassInRegisters = Record.readInt();
1576  Data.DefaultedDefaultConstructorIsConstexpr = Record.readInt();
1577  Data.HasConstexprDefaultConstructor = Record.readInt();
1578  Data.HasNonLiteralTypeFieldsOrBases = Record.readInt();
1579  Data.ComputedVisibleConversions = Record.readInt();
1580  Data.UserProvidedDefaultConstructor = Record.readInt();
1581  Data.DeclaredSpecialMembers = Record.readInt();
1582  Data.ImplicitCopyConstructorCanHaveConstParamForVBase = Record.readInt();
1583  Data.ImplicitCopyConstructorCanHaveConstParamForNonVBase = Record.readInt();
1584  Data.ImplicitCopyAssignmentHasConstParam = Record.readInt();
1585  Data.HasDeclaredCopyConstructorWithConstParam = Record.readInt();
1586  Data.HasDeclaredCopyAssignmentWithConstParam = Record.readInt();
1587  Data.ODRHash = Record.readInt();
1588  Data.HasODRHash = true;
1589 
1590  if (Record.readInt()) {
1591  Reader.BodySource[D] = Loc.F->Kind == ModuleKind::MK_MainFile
1594  }
1595 
1596  Data.NumBases = Record.readInt();
1597  if (Data.NumBases)
1598  Data.Bases = ReadGlobalOffset();
1599  Data.NumVBases = Record.readInt();
1600  if (Data.NumVBases)
1601  Data.VBases = ReadGlobalOffset();
1602 
1603  Record.readUnresolvedSet(Data.Conversions);
1604  Record.readUnresolvedSet(Data.VisibleConversions);
1605  assert(Data.Definition && "Data.Definition should be already set!");
1606  Data.FirstFriend = ReadDeclID();
1607 
1608  if (Data.IsLambda) {
1609  typedef LambdaCapture Capture;
1610  CXXRecordDecl::LambdaDefinitionData &Lambda
1611  = static_cast<CXXRecordDecl::LambdaDefinitionData &>(Data);
1612  Lambda.Dependent = Record.readInt();
1613  Lambda.IsGenericLambda = Record.readInt();
1614  Lambda.CaptureDefault = Record.readInt();
1615  Lambda.NumCaptures = Record.readInt();
1616  Lambda.NumExplicitCaptures = Record.readInt();
1617  Lambda.ManglingNumber = Record.readInt();
1618  Lambda.ContextDecl = ReadDeclID();
1619  Lambda.Captures = (Capture *)Reader.getContext().Allocate(
1620  sizeof(Capture) * Lambda.NumCaptures);
1621  Capture *ToCapture = Lambda.Captures;
1622  Lambda.MethodTyInfo = GetTypeSourceInfo();
1623  for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
1624  SourceLocation Loc = ReadSourceLocation();
1625  bool IsImplicit = Record.readInt();
1626  LambdaCaptureKind Kind = static_cast<LambdaCaptureKind>(Record.readInt());
1627  switch (Kind) {
1628  case LCK_StarThis:
1629  case LCK_This:
1630  case LCK_VLAType:
1631  *ToCapture++ = Capture(Loc, IsImplicit, Kind, nullptr,SourceLocation());
1632  break;
1633  case LCK_ByCopy:
1634  case LCK_ByRef:
1635  VarDecl *Var = ReadDeclAs<VarDecl>();
1636  SourceLocation EllipsisLoc = ReadSourceLocation();
1637  *ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
1638  break;
1639  }
1640  }
1641  }
1642 }
1643 
1644 void ASTDeclReader::MergeDefinitionData(
1645  CXXRecordDecl *D, struct CXXRecordDecl::DefinitionData &&MergeDD) {
1646  assert(D->DefinitionData &&
1647  "merging class definition into non-definition");
1648  auto &DD = *D->DefinitionData;
1649 
1650  if (DD.Definition != MergeDD.Definition) {
1651  // Track that we merged the definitions.
1652  Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition,
1653  DD.Definition));
1654  Reader.PendingDefinitions.erase(MergeDD.Definition);
1655  MergeDD.Definition->IsCompleteDefinition = false;
1656  Reader.mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
1657  assert(Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() &&
1658  "already loaded pending lookups for merged definition");
1659  }
1660 
1661  auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
1662  if (PFDI != Reader.PendingFakeDefinitionData.end() &&
1664  // We faked up this definition data because we found a class for which we'd
1665  // not yet loaded the definition. Replace it with the real thing now.
1666  assert(!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?");
1668 
1669  // Don't change which declaration is the definition; that is required
1670  // to be invariant once we select it.
1671  auto *Def = DD.Definition;
1672  DD = std::move(MergeDD);
1673  DD.Definition = Def;
1674  return;
1675  }
1676 
1677  // FIXME: Move this out into a .def file?
1678  bool DetectedOdrViolation = false;
1679 #define OR_FIELD(Field) DD.Field |= MergeDD.Field;
1680 #define MATCH_FIELD(Field) \
1681  DetectedOdrViolation |= DD.Field != MergeDD.Field; \
1682  OR_FIELD(Field)
1683  MATCH_FIELD(UserDeclaredConstructor)
1684  MATCH_FIELD(UserDeclaredSpecialMembers)
1685  MATCH_FIELD(Aggregate)
1686  MATCH_FIELD(PlainOldData)
1687  MATCH_FIELD(Empty)
1688  MATCH_FIELD(Polymorphic)
1689  MATCH_FIELD(Abstract)
1690  MATCH_FIELD(IsStandardLayout)
1691  MATCH_FIELD(HasNoNonEmptyBases)
1692  MATCH_FIELD(HasPrivateFields)
1693  MATCH_FIELD(HasProtectedFields)
1694  MATCH_FIELD(HasPublicFields)
1695  MATCH_FIELD(HasMutableFields)
1696  MATCH_FIELD(HasVariantMembers)
1697  MATCH_FIELD(HasOnlyCMembers)
1698  MATCH_FIELD(HasInClassInitializer)
1699  MATCH_FIELD(HasUninitializedReferenceMember)
1700  MATCH_FIELD(HasUninitializedFields)
1701  MATCH_FIELD(HasInheritedConstructor)
1702  MATCH_FIELD(HasInheritedAssignment)
1703  MATCH_FIELD(NeedOverloadResolutionForCopyConstructor)
1704  MATCH_FIELD(NeedOverloadResolutionForMoveConstructor)
1705  MATCH_FIELD(NeedOverloadResolutionForMoveAssignment)
1706  MATCH_FIELD(NeedOverloadResolutionForDestructor)
1707  MATCH_FIELD(DefaultedCopyConstructorIsDeleted)
1708  MATCH_FIELD(DefaultedMoveConstructorIsDeleted)
1709  MATCH_FIELD(DefaultedMoveAssignmentIsDeleted)
1710  MATCH_FIELD(DefaultedDestructorIsDeleted)
1711  OR_FIELD(HasTrivialSpecialMembers)
1712  OR_FIELD(DeclaredNonTrivialSpecialMembers)
1713  MATCH_FIELD(HasIrrelevantDestructor)
1714  OR_FIELD(HasConstexprNonCopyMoveConstructor)
1715  OR_FIELD(HasDefaultedDefaultConstructor)
1716  MATCH_FIELD(CanPassInRegisters)
1717  MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr)
1718  OR_FIELD(HasConstexprDefaultConstructor)
1719  MATCH_FIELD(HasNonLiteralTypeFieldsOrBases)
1720  // ComputedVisibleConversions is handled below.
1721  MATCH_FIELD(UserProvidedDefaultConstructor)
1722  OR_FIELD(DeclaredSpecialMembers)
1723  MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForVBase)
1724  MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForNonVBase)
1725  MATCH_FIELD(ImplicitCopyAssignmentHasConstParam)
1726  OR_FIELD(HasDeclaredCopyConstructorWithConstParam)
1727  OR_FIELD(HasDeclaredCopyAssignmentWithConstParam)
1728  MATCH_FIELD(IsLambda)
1729 #undef OR_FIELD
1730 #undef MATCH_FIELD
1731 
1732  if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases)
1733  DetectedOdrViolation = true;
1734  // FIXME: Issue a diagnostic if the base classes don't match when we come
1735  // to lazily load them.
1736 
1737  // FIXME: Issue a diagnostic if the list of conversion functions doesn't
1738  // match when we come to lazily load them.
1739  if (MergeDD.ComputedVisibleConversions && !DD.ComputedVisibleConversions) {
1740  DD.VisibleConversions = std::move(MergeDD.VisibleConversions);
1741  DD.ComputedVisibleConversions = true;
1742  }
1743 
1744  // FIXME: Issue a diagnostic if FirstFriend doesn't match when we come to
1745  // lazily load it.
1746 
1747  if (DD.IsLambda) {
1748  // FIXME: ODR-checking for merging lambdas (this happens, for instance,
1749  // when they occur within the body of a function template specialization).
1750  }
1751 
1752  if (D->getODRHash() != MergeDD.ODRHash) {
1753  DetectedOdrViolation = true;
1754  }
1755 
1756  if (DetectedOdrViolation)
1757  Reader.PendingOdrMergeFailures[DD.Definition].push_back(MergeDD.Definition);
1758 }
1759 
1760 void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update) {
1761  struct CXXRecordDecl::DefinitionData *DD;
1762  ASTContext &C = Reader.getContext();
1763 
1764  // Determine whether this is a lambda closure type, so that we can
1765  // allocate the appropriate DefinitionData structure.
1766  bool IsLambda = Record.readInt();
1767  if (IsLambda)
1768  DD = new (C) CXXRecordDecl::LambdaDefinitionData(D, nullptr, false, false,
1769  LCD_None);
1770  else
1771  DD = new (C) struct CXXRecordDecl::DefinitionData(D);
1772 
1773  ReadCXXDefinitionData(*DD, D);
1774 
1775  // We might already have a definition for this record. This can happen either
1776  // because we're reading an update record, or because we've already done some
1777  // merging. Either way, just merge into it.
1778  CXXRecordDecl *Canon = D->getCanonicalDecl();
1779  if (Canon->DefinitionData) {
1780  MergeDefinitionData(Canon, std::move(*DD));
1781  D->DefinitionData = Canon->DefinitionData;
1782  return;
1783  }
1784 
1785  // Mark this declaration as being a definition.
1786  D->IsCompleteDefinition = true;
1787  D->DefinitionData = DD;
1788 
1789  // If this is not the first declaration or is an update record, we can have
1790  // other redeclarations already. Make a note that we need to propagate the
1791  // DefinitionData pointer onto them.
1792  if (Update || Canon != D) {
1793  Canon->DefinitionData = D->DefinitionData;
1794  Reader.PendingDefinitions.insert(D);
1795  }
1796 }
1797 
1798 ASTDeclReader::RedeclarableResult
1800  RedeclarableResult Redecl = VisitRecordDeclImpl(D);
1801 
1802  ASTContext &C = Reader.getContext();
1803 
1804  enum CXXRecKind {
1805  CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1806  };
1807  switch ((CXXRecKind)Record.readInt()) {
1808  case CXXRecNotTemplate:
1809  // Merged when we merge the folding set entry in the primary template.
1810  if (!isa<ClassTemplateSpecializationDecl>(D))
1811  mergeRedeclarable(D, Redecl);
1812  break;
1813  case CXXRecTemplate: {
1814  // Merged when we merge the template.
1815  ClassTemplateDecl *Template = ReadDeclAs<ClassTemplateDecl>();
1816  D->TemplateOrInstantiation = Template;
1817  if (!Template->getTemplatedDecl()) {
1818  // We've not actually loaded the ClassTemplateDecl yet, because we're
1819  // currently being loaded as its pattern. Rely on it to set up our
1820  // TypeForDecl (see VisitClassTemplateDecl).
1821  //
1822  // Beware: we do not yet know our canonical declaration, and may still
1823  // get merged once the surrounding class template has got off the ground.
1824  TypeIDForTypeDecl = 0;
1825  }
1826  break;
1827  }
1828  case CXXRecMemberSpecialization: {
1829  CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>();
1831  (TemplateSpecializationKind)Record.readInt();
1832  SourceLocation POI = ReadSourceLocation();
1833  MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK);
1834  MSI->setPointOfInstantiation(POI);
1835  D->TemplateOrInstantiation = MSI;
1836  mergeRedeclarable(D, Redecl);
1837  break;
1838  }
1839  }
1840 
1841  bool WasDefinition = Record.readInt();
1842  if (WasDefinition)
1843  ReadCXXRecordDefinition(D, /*Update*/false);
1844  else
1845  // Propagate DefinitionData pointer from the canonical declaration.
1846  D->DefinitionData = D->getCanonicalDecl()->DefinitionData;
1847 
1848  // Lazily load the key function to avoid deserializing every method so we can
1849  // compute it.
1850  if (WasDefinition) {
1851  DeclID KeyFn = ReadDeclID();
1852  if (KeyFn && D->IsCompleteDefinition)
1853  // FIXME: This is wrong for the ARM ABI, where some other module may have
1854  // made this function no longer be a key function. We need an update
1855  // record or similar for that case.
1856  C.KeyFunctions[D] = KeyFn;
1857  }
1858 
1859  return Redecl;
1860 }
1861 
1863  VisitFunctionDecl(D);
1864 }
1865 
1867  VisitFunctionDecl(D);
1868 
1869  unsigned NumOverridenMethods = Record.readInt();
1870  if (D->isCanonicalDecl()) {
1871  while (NumOverridenMethods--) {
1872  // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
1873  // MD may be initializing.
1874  if (CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>())
1875  Reader.getContext().addOverriddenMethod(D, MD->getCanonicalDecl());
1876  }
1877  } else {
1878  // We don't care about which declarations this used to override; we get
1879  // the relevant information from the canonical declaration.
1880  Record.skipInts(NumOverridenMethods);
1881  }
1882 }
1883 
1885  // We need the inherited constructor information to merge the declaration,
1886  // so we have to read it before we call VisitCXXMethodDecl.
1887  if (D->isInheritingConstructor()) {
1888  auto *Shadow = ReadDeclAs<ConstructorUsingShadowDecl>();
1889  auto *Ctor = ReadDeclAs<CXXConstructorDecl>();
1890  *D->getTrailingObjects<InheritedConstructor>() =
1891  InheritedConstructor(Shadow, Ctor);
1892  }
1893 
1894  VisitCXXMethodDecl(D);
1895 }
1896 
1898  VisitCXXMethodDecl(D);
1899 
1900  if (auto *OperatorDelete = ReadDeclAs<FunctionDecl>()) {
1901  auto *Canon = cast<CXXDestructorDecl>(D->getCanonicalDecl());
1902  // FIXME: Check consistency if we have an old and new operator delete.
1903  if (!Canon->OperatorDelete)
1904  Canon->OperatorDelete = OperatorDelete;
1905  }
1906 }
1907 
1909  VisitCXXMethodDecl(D);
1910 }
1911 
1913  VisitDecl(D);
1914  D->ImportedAndComplete.setPointer(readModule());
1915  D->ImportedAndComplete.setInt(Record.readInt());
1916  SourceLocation *StoredLocs = D->getTrailingObjects<SourceLocation>();
1917  for (unsigned I = 0, N = Record.back(); I != N; ++I)
1918  StoredLocs[I] = ReadSourceLocation();
1919  Record.skipInts(1); // The number of stored source locations.
1920 }
1921 
1923  VisitDecl(D);
1924  D->setColonLoc(ReadSourceLocation());
1925 }
1926 
1928  VisitDecl(D);
1929  if (Record.readInt()) // hasFriendDecl
1930  D->Friend = ReadDeclAs<NamedDecl>();
1931  else
1932  D->Friend = GetTypeSourceInfo();
1933  for (unsigned i = 0; i != D->NumTPLists; ++i)
1934  D->getTrailingObjects<TemplateParameterList *>()[i] =
1935  Record.readTemplateParameterList();
1936  D->NextFriend = ReadDeclID();
1937  D->UnsupportedFriend = (Record.readInt() != 0);
1938  D->FriendLoc = ReadSourceLocation();
1939 }
1940 
1942  VisitDecl(D);
1943  unsigned NumParams = Record.readInt();
1944  D->NumParams = NumParams;
1945  D->Params = new TemplateParameterList*[NumParams];
1946  for (unsigned i = 0; i != NumParams; ++i)
1947  D->Params[i] = Record.readTemplateParameterList();
1948  if (Record.readInt()) // HasFriendDecl
1949  D->Friend = ReadDeclAs<NamedDecl>();
1950  else
1951  D->Friend = GetTypeSourceInfo();
1952  D->FriendLoc = ReadSourceLocation();
1953 }
1954 
1956  VisitNamedDecl(D);
1957 
1958  DeclID PatternID = ReadDeclID();
1959  NamedDecl *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
1960  TemplateParameterList *TemplateParams = Record.readTemplateParameterList();
1961  // FIXME handle associated constraints
1962  D->init(TemplatedDecl, TemplateParams);
1963 
1964  return PatternID;
1965 }
1966 
1967 ASTDeclReader::RedeclarableResult
1969  RedeclarableResult Redecl = VisitRedeclarable(D);
1970 
1971  // Make sure we've allocated the Common pointer first. We do this before
1972  // VisitTemplateDecl so that getCommonPtr() can be used during initialization.
1974  if (!CanonD->Common) {
1975  CanonD->Common = CanonD->newCommon(Reader.getContext());
1976  Reader.PendingDefinitions.insert(CanonD);
1977  }
1978  D->Common = CanonD->Common;
1979 
1980  // If this is the first declaration of the template, fill in the information
1981  // for the 'common' pointer.
1982  if (ThisDeclID == Redecl.getFirstID()) {
1983  if (RedeclarableTemplateDecl *RTD
1984  = ReadDeclAs<RedeclarableTemplateDecl>()) {
1985  assert(RTD->getKind() == D->getKind() &&
1986  "InstantiatedFromMemberTemplate kind mismatch");
1988  if (Record.readInt())
1990  }
1991  }
1992 
1993  DeclID PatternID = VisitTemplateDecl(D);
1994  D->IdentifierNamespace = Record.readInt();
1995 
1996  mergeRedeclarable(D, Redecl, PatternID);
1997 
1998  // If we merged the template with a prior declaration chain, merge the common
1999  // pointer.
2000  // FIXME: Actually merge here, don't just overwrite.
2001  D->Common = D->getCanonicalDecl()->Common;
2002 
2003  return Redecl;
2004 }
2005 
2007  RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2008 
2009  if (ThisDeclID == Redecl.getFirstID()) {
2010  // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of
2011  // the specializations.
2013  ReadDeclIDList(SpecIDs);
2015  }
2016 
2017  if (D->getTemplatedDecl()->TemplateOrInstantiation) {
2018  // We were loaded before our templated declaration was. We've not set up
2019  // its corresponding type yet (see VisitCXXRecordDeclImpl), so reconstruct
2020  // it now.
2021  Reader.getContext().getInjectedClassNameType(
2023  }
2024 }
2025 
2027  llvm_unreachable("BuiltinTemplates are not serialized");
2028 }
2029 
2030 /// TODO: Unify with ClassTemplateDecl version?
2031 /// May require unifying ClassTemplateDecl and
2032 /// VarTemplateDecl beyond TemplateDecl...
2034  RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2035 
2036  if (ThisDeclID == Redecl.getFirstID()) {
2037  // This VarTemplateDecl owns a CommonPtr; read it to keep track of all of
2038  // the specializations.
2040  ReadDeclIDList(SpecIDs);
2042  }
2043 }
2044 
2045 ASTDeclReader::RedeclarableResult
2048  RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D);
2049 
2050  ASTContext &C = Reader.getContext();
2051  if (Decl *InstD = ReadDecl()) {
2052  if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
2053  D->SpecializedTemplate = CTD;
2054  } else {
2056  Record.readTemplateArgumentList(TemplArgs);
2057  TemplateArgumentList *ArgList
2058  = TemplateArgumentList::CreateCopy(C, TemplArgs);
2059  ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
2061  SpecializedPartialSpecialization();
2062  PS->PartialSpecialization
2063  = cast<ClassTemplatePartialSpecializationDecl>(InstD);
2064  PS->TemplateArgs = ArgList;
2065  D->SpecializedTemplate = PS;
2066  }
2067  }
2068 
2070  Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
2071  D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
2072  D->PointOfInstantiation = ReadSourceLocation();
2073  D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
2074 
2075  bool writtenAsCanonicalDecl = Record.readInt();
2076  if (writtenAsCanonicalDecl) {
2077  ClassTemplateDecl *CanonPattern = ReadDeclAs<ClassTemplateDecl>();
2078  if (D->isCanonicalDecl()) { // It's kept in the folding set.
2079  // Set this as, or find, the canonical declaration for this specialization
2082  dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
2083  CanonSpec = CanonPattern->getCommonPtr()->PartialSpecializations
2084  .GetOrInsertNode(Partial);
2085  } else {
2086  CanonSpec =
2087  CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2088  }
2089  // If there was already a canonical specialization, merge into it.
2090  if (CanonSpec != D) {
2091  mergeRedeclarable<TagDecl>(D, CanonSpec, Redecl);
2092 
2093  // This declaration might be a definition. Merge with any existing
2094  // definition.
2095  if (auto *DDD = D->DefinitionData) {
2096  if (CanonSpec->DefinitionData)
2097  MergeDefinitionData(CanonSpec, std::move(*DDD));
2098  else
2099  CanonSpec->DefinitionData = D->DefinitionData;
2100  }
2101  D->DefinitionData = CanonSpec->DefinitionData;
2102  }
2103  }
2104  }
2105 
2106  // Explicit info.
2107  if (TypeSourceInfo *TyInfo = GetTypeSourceInfo()) {
2108  ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo
2109  = new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
2110  ExplicitInfo->TypeAsWritten = TyInfo;
2111  ExplicitInfo->ExternLoc = ReadSourceLocation();
2112  ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation();
2113  D->ExplicitInfo = ExplicitInfo;
2114  }
2115 
2116  return Redecl;
2117 }
2118 
2121  RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
2122 
2123  D->TemplateParams = Record.readTemplateParameterList();
2124  D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2125 
2126  // These are read/set from/to the first declaration.
2127  if (ThisDeclID == Redecl.getFirstID()) {
2128  D->InstantiatedFromMember.setPointer(
2129  ReadDeclAs<ClassTemplatePartialSpecializationDecl>());
2130  D->InstantiatedFromMember.setInt(Record.readInt());
2131  }
2132 }
2133 
2136  VisitDecl(D);
2137  D->Specialization = ReadDeclAs<CXXMethodDecl>();
2138 }
2139 
2141  RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2142 
2143  if (ThisDeclID == Redecl.getFirstID()) {
2144  // This FunctionTemplateDecl owns a CommonPtr; read it.
2146  ReadDeclIDList(SpecIDs);
2148  }
2149 }
2150 
2151 /// TODO: Unify with ClassTemplateSpecializationDecl version?
2152 /// May require unifying ClassTemplate(Partial)SpecializationDecl and
2153 /// VarTemplate(Partial)SpecializationDecl with a new data
2154 /// structure Template(Partial)SpecializationDecl, and
2155 /// using Template(Partial)SpecializationDecl as input type.
2156 ASTDeclReader::RedeclarableResult
2159  RedeclarableResult Redecl = VisitVarDeclImpl(D);
2160 
2161  ASTContext &C = Reader.getContext();
2162  if (Decl *InstD = ReadDecl()) {
2163  if (VarTemplateDecl *VTD = dyn_cast<VarTemplateDecl>(InstD)) {
2164  D->SpecializedTemplate = VTD;
2165  } else {
2167  Record.readTemplateArgumentList(TemplArgs);
2169  C, TemplArgs);
2170  VarTemplateSpecializationDecl::SpecializedPartialSpecialization *PS =
2171  new (C)
2172  VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
2173  PS->PartialSpecialization =
2174  cast<VarTemplatePartialSpecializationDecl>(InstD);
2175  PS->TemplateArgs = ArgList;
2176  D->SpecializedTemplate = PS;
2177  }
2178  }
2179 
2180  // Explicit info.
2181  if (TypeSourceInfo *TyInfo = GetTypeSourceInfo()) {
2182  VarTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo =
2183  new (C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo;
2184  ExplicitInfo->TypeAsWritten = TyInfo;
2185  ExplicitInfo->ExternLoc = ReadSourceLocation();
2186  ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation();
2187  D->ExplicitInfo = ExplicitInfo;
2188  }
2189 
2191  Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
2192  D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
2193  D->PointOfInstantiation = ReadSourceLocation();
2194  D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
2195 
2196  bool writtenAsCanonicalDecl = Record.readInt();
2197  if (writtenAsCanonicalDecl) {
2198  VarTemplateDecl *CanonPattern = ReadDeclAs<VarTemplateDecl>();
2199  if (D->isCanonicalDecl()) { // It's kept in the folding set.
2200  // FIXME: If it's already present, merge it.
2202  dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
2203  CanonPattern->getCommonPtr()->PartialSpecializations
2204  .GetOrInsertNode(Partial);
2205  } else {
2206  CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2207  }
2208  }
2209  }
2210 
2211  return Redecl;
2212 }
2213 
2214 /// TODO: Unify with ClassTemplatePartialSpecializationDecl version?
2215 /// May require unifying ClassTemplate(Partial)SpecializationDecl and
2216 /// VarTemplate(Partial)SpecializationDecl with a new data
2217 /// structure Template(Partial)SpecializationDecl, and
2218 /// using Template(Partial)SpecializationDecl as input type.
2221  RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
2222 
2223  D->TemplateParams = Record.readTemplateParameterList();
2224  D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2225 
2226  // These are read/set from/to the first declaration.
2227  if (ThisDeclID == Redecl.getFirstID()) {
2228  D->InstantiatedFromMember.setPointer(
2229  ReadDeclAs<VarTemplatePartialSpecializationDecl>());
2230  D->InstantiatedFromMember.setInt(Record.readInt());
2231  }
2232 }
2233 
2235  VisitTypeDecl(D);
2236 
2237  D->setDeclaredWithTypename(Record.readInt());
2238 
2239  if (Record.readInt())
2240  D->setDefaultArgument(GetTypeSourceInfo());
2241 }
2242 
2244  VisitDeclaratorDecl(D);
2245  // TemplateParmPosition.
2246  D->setDepth(Record.readInt());
2247  D->setPosition(Record.readInt());
2248  if (D->isExpandedParameterPack()) {
2249  auto TypesAndInfos =
2250  D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
2251  for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2252  new (&TypesAndInfos[I].first) QualType(Record.readType());
2253  TypesAndInfos[I].second = GetTypeSourceInfo();
2254  }
2255  } else {
2256  // Rest of NonTypeTemplateParmDecl.
2257  D->ParameterPack = Record.readInt();
2258  if (Record.readInt())
2259  D->setDefaultArgument(Record.readExpr());
2260  }
2261 }
2262 
2264  VisitTemplateDecl(D);
2265  // TemplateParmPosition.
2266  D->setDepth(Record.readInt());
2267  D->setPosition(Record.readInt());
2268  if (D->isExpandedParameterPack()) {
2269  TemplateParameterList **Data =
2270  D->getTrailingObjects<TemplateParameterList *>();
2271  for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2272  I != N; ++I)
2273  Data[I] = Record.readTemplateParameterList();
2274  } else {
2275  // Rest of TemplateTemplateParmDecl.
2276  D->ParameterPack = Record.readInt();
2277  if (Record.readInt())
2278  D->setDefaultArgument(Reader.getContext(),
2279  Record.readTemplateArgumentLoc());
2280  }
2281 }
2282 
2284  VisitRedeclarableTemplateDecl(D);
2285 }
2286 
2288  VisitDecl(D);
2289  D->AssertExprAndFailed.setPointer(Record.readExpr());
2290  D->AssertExprAndFailed.setInt(Record.readInt());
2291  D->Message = cast_or_null<StringLiteral>(Record.readExpr());
2292  D->RParenLoc = ReadSourceLocation();
2293 }
2294 
2296  VisitDecl(D);
2297 }
2298 
2299 std::pair<uint64_t, uint64_t>
2301  uint64_t LexicalOffset = ReadLocalOffset();
2302  uint64_t VisibleOffset = ReadLocalOffset();
2303  return std::make_pair(LexicalOffset, VisibleOffset);
2304 }
2305 
2306 template <typename T>
2307 ASTDeclReader::RedeclarableResult
2309  DeclID FirstDeclID = ReadDeclID();
2310  Decl *MergeWith = nullptr;
2311 
2312  bool IsKeyDecl = ThisDeclID == FirstDeclID;
2313  bool IsFirstLocalDecl = false;
2314 
2315  uint64_t RedeclOffset = 0;
2316 
2317  // 0 indicates that this declaration was the only declaration of its entity,
2318  // and is used for space optimization.
2319  if (FirstDeclID == 0) {
2320  FirstDeclID = ThisDeclID;
2321  IsKeyDecl = true;
2322  IsFirstLocalDecl = true;
2323  } else if (unsigned N = Record.readInt()) {
2324  // This declaration was the first local declaration, but may have imported
2325  // other declarations.
2326  IsKeyDecl = N == 1;
2327  IsFirstLocalDecl = true;
2328 
2329  // We have some declarations that must be before us in our redeclaration
2330  // chain. Read them now, and remember that we ought to merge with one of
2331  // them.
2332  // FIXME: Provide a known merge target to the second and subsequent such
2333  // declaration.
2334  for (unsigned I = 0; I != N - 1; ++I)
2335  MergeWith = ReadDecl();
2336 
2337  RedeclOffset = ReadLocalOffset();
2338  } else {
2339  // This declaration was not the first local declaration. Read the first
2340  // local declaration now, to trigger the import of other redeclarations.
2341  (void)ReadDecl();
2342  }
2343 
2344  T *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID));
2345  if (FirstDecl != D) {
2346  // We delay loading of the redeclaration chain to avoid deeply nested calls.
2347  // We temporarily set the first (canonical) declaration as the previous one
2348  // which is the one that matters and mark the real previous DeclID to be
2349  // loaded & attached later on.
2351  D->First = FirstDecl->getCanonicalDecl();
2352  }
2353 
2354  T *DAsT = static_cast<T*>(D);
2355 
2356  // Note that we need to load local redeclarations of this decl and build a
2357  // decl chain for them. This must happen *after* we perform the preloading
2358  // above; this ensures that the redeclaration chain is built in the correct
2359  // order.
2360  if (IsFirstLocalDecl)
2361  Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset));
2362 
2363  return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl);
2364 }
2365 
2366 /// \brief Attempts to merge the given declaration (D) with another declaration
2367 /// of the same entity.
2368 template<typename T>
2370  RedeclarableResult &Redecl,
2371  DeclID TemplatePatternID) {
2372  // If modules are not available, there is no reason to perform this merge.
2373  if (!Reader.getContext().getLangOpts().Modules)
2374  return;
2375 
2376  // If we're not the canonical declaration, we don't need to merge.
2377  if (!DBase->isFirstDecl())
2378  return;
2379 
2380  T *D = static_cast<T*>(DBase);
2381 
2382  if (auto *Existing = Redecl.getKnownMergeTarget())
2383  // We already know of an existing declaration we should merge with.
2384  mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID);
2385  else if (FindExistingResult ExistingRes = findExisting(D))
2386  if (T *Existing = ExistingRes)
2387  mergeRedeclarable(D, Existing, Redecl, TemplatePatternID);
2388 }
2389 
2390 /// \brief "Cast" to type T, asserting if we don't have an implicit conversion.
2391 /// We use this to put code in a template that will only be valid for certain
2392 /// instantiations.
2393 template<typename T> static T assert_cast(T t) { return t; }
2394 template<typename T> static T assert_cast(...) {
2395  llvm_unreachable("bad assert_cast");
2396 }
2397 
2398 /// \brief Merge together the pattern declarations from two template
2399 /// declarations.
2401  RedeclarableTemplateDecl *Existing,
2402  DeclID DsID, bool IsKeyDecl) {
2403  auto *DPattern = D->getTemplatedDecl();
2404  auto *ExistingPattern = Existing->getTemplatedDecl();
2405  RedeclarableResult Result(/*MergeWith*/ ExistingPattern,
2406  DPattern->getCanonicalDecl()->getGlobalID(),
2407  IsKeyDecl);
2408 
2409  if (auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) {
2410  // Merge with any existing definition.
2411  // FIXME: This is duplicated in several places. Refactor.
2412  auto *ExistingClass =
2413  cast<CXXRecordDecl>(ExistingPattern)->getCanonicalDecl();
2414  if (auto *DDD = DClass->DefinitionData) {
2415  if (ExistingClass->DefinitionData) {
2416  MergeDefinitionData(ExistingClass, std::move(*DDD));
2417  } else {
2418  ExistingClass->DefinitionData = DClass->DefinitionData;
2419  // We may have skipped this before because we thought that DClass
2420  // was the canonical declaration.
2421  Reader.PendingDefinitions.insert(DClass);
2422  }
2423  }
2424  DClass->DefinitionData = ExistingClass->DefinitionData;
2425 
2426  return mergeRedeclarable(DClass, cast<TagDecl>(ExistingPattern),
2427  Result);
2428  }
2429  if (auto *DFunction = dyn_cast<FunctionDecl>(DPattern))
2430  return mergeRedeclarable(DFunction, cast<FunctionDecl>(ExistingPattern),
2431  Result);
2432  if (auto *DVar = dyn_cast<VarDecl>(DPattern))
2433  return mergeRedeclarable(DVar, cast<VarDecl>(ExistingPattern), Result);
2434  if (auto *DAlias = dyn_cast<TypeAliasDecl>(DPattern))
2435  return mergeRedeclarable(DAlias, cast<TypedefNameDecl>(ExistingPattern),
2436  Result);
2437  llvm_unreachable("merged an unknown kind of redeclarable template");
2438 }
2439 
2440 /// \brief Attempts to merge the given declaration (D) with another declaration
2441 /// of the same entity.
2442 template<typename T>
2444  RedeclarableResult &Redecl,
2445  DeclID TemplatePatternID) {
2446  T *D = static_cast<T*>(DBase);
2447  T *ExistingCanon = Existing->getCanonicalDecl();
2448  T *DCanon = D->getCanonicalDecl();
2449  if (ExistingCanon != DCanon) {
2450  assert(DCanon->getGlobalID() == Redecl.getFirstID() &&
2451  "already merged this declaration");
2452 
2453  // Have our redeclaration link point back at the canonical declaration
2454  // of the existing declaration, so that this declaration has the
2455  // appropriate canonical declaration.
2456  D->RedeclLink = Redeclarable<T>::PreviousDeclLink(ExistingCanon);
2457  D->First = ExistingCanon;
2458  ExistingCanon->Used |= D->Used;
2459  D->Used = false;
2460 
2461  // When we merge a namespace, update its pointer to the first namespace.
2462  // We cannot have loaded any redeclarations of this declaration yet, so
2463  // there's nothing else that needs to be updated.
2464  if (auto *Namespace = dyn_cast<NamespaceDecl>(D))
2465  Namespace->AnonOrFirstNamespaceAndInline.setPointer(
2466  assert_cast<NamespaceDecl*>(ExistingCanon));
2467 
2468  // When we merge a template, merge its pattern.
2469  if (auto *DTemplate = dyn_cast<RedeclarableTemplateDecl>(D))
2470  mergeTemplatePattern(
2471  DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon),
2472  TemplatePatternID, Redecl.isKeyDecl());
2473 
2474  // If this declaration is a key declaration, make a note of that.
2475  if (Redecl.isKeyDecl())
2476  Reader.KeyDecls[ExistingCanon].push_back(Redecl.getFirstID());
2477  }
2478 }
2479 
2480 /// \brief Attempts to merge the given declaration (D) with another declaration
2481 /// of the same entity, for the case where the entity is not actually
2482 /// redeclarable. This happens, for instance, when merging the fields of
2483 /// identical class definitions from two different modules.
2484 template<typename T>
2486  // If modules are not available, there is no reason to perform this merge.
2487  if (!Reader.getContext().getLangOpts().Modules)
2488  return;
2489 
2490  // ODR-based merging is only performed in C++. In C, identically-named things
2491  // in different translation units are not redeclarations (but may still have
2492  // compatible types).
2493  if (!Reader.getContext().getLangOpts().CPlusPlus)
2494  return;
2495 
2496  if (FindExistingResult ExistingRes = findExisting(static_cast<T*>(D)))
2497  if (T *Existing = ExistingRes)
2498  Reader.getContext().setPrimaryMergedDecl(static_cast<T *>(D),
2499  Existing->getCanonicalDecl());
2500 }
2501 
2503  VisitDecl(D);
2504  unsigned NumVars = D->varlist_size();
2506  Vars.reserve(NumVars);
2507  for (unsigned i = 0; i != NumVars; ++i) {
2508  Vars.push_back(Record.readExpr());
2509  }
2510  D->setVars(Vars);
2511 }
2512 
2514  VisitValueDecl(D);
2515  D->setLocation(ReadSourceLocation());
2516  D->setCombiner(Record.readExpr());
2517  D->setInitializer(Record.readExpr());
2518  D->PrevDeclInScope = ReadDeclID();
2519 }
2520 
2522  VisitVarDecl(D);
2523 }
2524 
2525 //===----------------------------------------------------------------------===//
2526 // Attribute Reading
2527 //===----------------------------------------------------------------------===//
2528 
2529 /// \brief Reads attributes from the current stream position.
2531  for (unsigned i = 0, e = Record.readInt(); i != e; ++i) {
2532  Attr *New = nullptr;
2533  attr::Kind Kind = (attr::Kind)Record.readInt();
2534  SourceRange Range = Record.readSourceRange();
2535  ASTContext &Context = getContext();
2536 
2537 #include "clang/Serialization/AttrPCHRead.inc"
2538 
2539  assert(New && "Unable to decode attribute?");
2540  Attrs.push_back(New);
2541  }
2542 }
2543 
2544 //===----------------------------------------------------------------------===//
2545 // ASTReader Implementation
2546 //===----------------------------------------------------------------------===//
2547 
2548 /// \brief Note that we have loaded the declaration with the given
2549 /// Index.
2550 ///
2551 /// This routine notes that this declaration has already been loaded,
2552 /// so that future GetDecl calls will return this declaration rather
2553 /// than trying to load a new declaration.
2554 inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) {
2555  assert(!DeclsLoaded[Index] && "Decl loaded twice?");
2556  DeclsLoaded[Index] = D;
2557 }
2558 
2559 
2560 /// \brief Determine whether the consumer will be interested in seeing
2561 /// this declaration (via HandleTopLevelDecl).
2562 ///
2563 /// This routine should return true for anything that might affect
2564 /// code generation, e.g., inline function definitions, Objective-C
2565 /// declarations with metadata, etc.
2566 static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody) {
2567  // An ObjCMethodDecl is never considered as "interesting" because its
2568  // implementation container always is.
2569 
2570  // An ImportDecl or VarDecl imported from a module will get emitted when
2571  // we import the relevant module.
2572  if ((isa<ImportDecl>(D) || isa<VarDecl>(D)) && D->getImportedOwningModule() &&
2573  Ctx.DeclMustBeEmitted(D))
2574  return false;
2575 
2576  if (isa<FileScopeAsmDecl>(D) ||
2577  isa<ObjCProtocolDecl>(D) ||
2578  isa<ObjCImplDecl>(D) ||
2579  isa<ImportDecl>(D) ||
2580  isa<PragmaCommentDecl>(D) ||
2581  isa<PragmaDetectMismatchDecl>(D))
2582  return true;
2583  if (isa<OMPThreadPrivateDecl>(D) || isa<OMPDeclareReductionDecl>(D))
2584  return !D->getDeclContext()->isFunctionOrMethod();
2585  if (VarDecl *Var = dyn_cast<VarDecl>(D))
2586  return Var->isFileVarDecl() &&
2587  Var->isThisDeclarationADefinition() == VarDecl::Definition;
2588  if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D))
2589  return Func->doesThisDeclarationHaveABody() || HasBody;
2590 
2591  if (auto *ES = D->getASTContext().getExternalSource())
2592  if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
2593  return true;
2594 
2595  return false;
2596 }
2597 
2598 /// \brief Get the correct cursor and offset for loading a declaration.
2599 ASTReader::RecordLocation
2600 ASTReader::DeclCursorForID(DeclID ID, SourceLocation &Loc) {
2601  GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID);
2602  assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
2603  ModuleFile *M = I->second;
2604  const DeclOffset &DOffs =
2605  M->DeclOffsets[ID - M->BaseDeclID - NUM_PREDEF_DECL_IDS];
2606  Loc = TranslateSourceLocation(*M, DOffs.getLocation());
2607  return RecordLocation(M, DOffs.BitOffset);
2608 }
2609 
2610 ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
2612  = GlobalBitOffsetsMap.find(GlobalOffset);
2613 
2614  assert(I != GlobalBitOffsetsMap.end() && "Corrupted global bit offsets map");
2615  return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
2616 }
2617 
2618 uint64_t ASTReader::getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset) {
2619  return LocalOffset + M.GlobalBitOffset;
2620 }
2621 
2623  const TemplateParameterList *Y);
2624 
2625 /// \brief Determine whether two template parameters are similar enough
2626 /// that they may be used in declarations of the same template.
2628  const NamedDecl *Y) {
2629  if (X->getKind() != Y->getKind())
2630  return false;
2631 
2632  if (const TemplateTypeParmDecl *TX = dyn_cast<TemplateTypeParmDecl>(X)) {
2633  const TemplateTypeParmDecl *TY = cast<TemplateTypeParmDecl>(Y);
2634  return TX->isParameterPack() == TY->isParameterPack();
2635  }
2636 
2637  if (const NonTypeTemplateParmDecl *TX = dyn_cast<NonTypeTemplateParmDecl>(X)) {
2638  const NonTypeTemplateParmDecl *TY = cast<NonTypeTemplateParmDecl>(Y);
2639  return TX->isParameterPack() == TY->isParameterPack() &&
2640  TX->getASTContext().hasSameType(TX->getType(), TY->getType());
2641  }
2642 
2643  const TemplateTemplateParmDecl *TX = cast<TemplateTemplateParmDecl>(X);
2644  const TemplateTemplateParmDecl *TY = cast<TemplateTemplateParmDecl>(Y);
2645  return TX->isParameterPack() == TY->isParameterPack() &&
2647  TY->getTemplateParameters());
2648 }
2649 
2651  if (auto *NS = X->getAsNamespace())
2652  return NS;
2653  if (auto *NAS = X->getAsNamespaceAlias())
2654  return NAS->getNamespace();
2655  return nullptr;
2656 }
2657 
2659  const NestedNameSpecifier *Y) {
2660  if (auto *NSX = getNamespace(X)) {
2661  auto *NSY = getNamespace(Y);
2662  if (!NSY || NSX->getCanonicalDecl() != NSY->getCanonicalDecl())
2663  return false;
2664  } else if (X->getKind() != Y->getKind())
2665  return false;
2666 
2667  // FIXME: For namespaces and types, we're permitted to check that the entity
2668  // is named via the same tokens. We should probably do so.
2669  switch (X->getKind()) {
2671  if (X->getAsIdentifier() != Y->getAsIdentifier())
2672  return false;
2673  break;
2676  // We've already checked that we named the same namespace.
2677  break;
2680  if (X->getAsType()->getCanonicalTypeInternal() !=
2682  return false;
2683  break;
2686  return true;
2687  }
2688 
2689  // Recurse into earlier portion of NNS, if any.
2690  auto *PX = X->getPrefix();
2691  auto *PY = Y->getPrefix();
2692  if (PX && PY)
2693  return isSameQualifier(PX, PY);
2694  return !PX && !PY;
2695 }
2696 
2697 /// \brief Determine whether two template parameter lists are similar enough
2698 /// that they may be used in declarations of the same template.
2700  const TemplateParameterList *Y) {
2701  if (X->size() != Y->size())
2702  return false;
2703 
2704  for (unsigned I = 0, N = X->size(); I != N; ++I)
2705  if (!isSameTemplateParameter(X->getParam(I), Y->getParam(I)))
2706  return false;
2707 
2708  return true;
2709 }
2710 
2711 /// Determine whether the attributes we can overload on are identical for A and
2712 /// B. Will ignore any overloadable attrs represented in the type of A and B.
2714  const FunctionDecl *B) {
2715  // Note that pass_object_size attributes are represented in the function's
2716  // ExtParameterInfo, so we don't need to check them here.
2717 
2719  // Since this is an equality check, we can ignore that enable_if attrs show up
2720  // in reverse order.
2721  for (const auto *EIA : A->specific_attrs<EnableIfAttr>())
2722  AEnableIfs.push_back(EIA);
2723 
2725  for (const auto *EIA : B->specific_attrs<EnableIfAttr>())
2726  BEnableIfs.push_back(EIA);
2727 
2728  // Two very common cases: either we have 0 enable_if attrs, or we have an
2729  // unequal number of enable_if attrs.
2730  if (AEnableIfs.empty() && BEnableIfs.empty())
2731  return true;
2732 
2733  if (AEnableIfs.size() != BEnableIfs.size())
2734  return false;
2735 
2736  llvm::FoldingSetNodeID Cand1ID, Cand2ID;
2737  for (unsigned I = 0, E = AEnableIfs.size(); I != E; ++I) {
2738  Cand1ID.clear();
2739  Cand2ID.clear();
2740 
2741  AEnableIfs[I]->getCond()->Profile(Cand1ID, A->getASTContext(), true);
2742  BEnableIfs[I]->getCond()->Profile(Cand2ID, B->getASTContext(), true);
2743  if (Cand1ID != Cand2ID)
2744  return false;
2745  }
2746 
2747  return true;
2748 }
2749 
2750 /// \brief Determine whether the two declarations refer to the same entity.
2751 static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
2752  assert(X->getDeclName() == Y->getDeclName() && "Declaration name mismatch!");
2753 
2754  if (X == Y)
2755  return true;
2756 
2757  // Must be in the same context.
2758  if (!X->getDeclContext()->getRedeclContext()->Equals(
2760  return false;
2761 
2762  // Two typedefs refer to the same entity if they have the same underlying
2763  // type.
2764  if (TypedefNameDecl *TypedefX = dyn_cast<TypedefNameDecl>(X))
2765  if (TypedefNameDecl *TypedefY = dyn_cast<TypedefNameDecl>(Y))
2766  return X->getASTContext().hasSameType(TypedefX->getUnderlyingType(),
2767  TypedefY->getUnderlyingType());
2768 
2769  // Must have the same kind.
2770  if (X->getKind() != Y->getKind())
2771  return false;
2772 
2773  // Objective-C classes and protocols with the same name always match.
2774  if (isa<ObjCInterfaceDecl>(X) || isa<ObjCProtocolDecl>(X))
2775  return true;
2776 
2777  if (isa<ClassTemplateSpecializationDecl>(X)) {
2778  // No need to handle these here: we merge them when adding them to the
2779  // template.
2780  return false;
2781  }
2782 
2783  // Compatible tags match.
2784  if (TagDecl *TagX = dyn_cast<TagDecl>(X)) {
2785  TagDecl *TagY = cast<TagDecl>(Y);
2786  return (TagX->getTagKind() == TagY->getTagKind()) ||
2787  ((TagX->getTagKind() == TTK_Struct || TagX->getTagKind() == TTK_Class ||
2788  TagX->getTagKind() == TTK_Interface) &&
2789  (TagY->getTagKind() == TTK_Struct || TagY->getTagKind() == TTK_Class ||
2790  TagY->getTagKind() == TTK_Interface));
2791  }
2792 
2793  // Functions with the same type and linkage match.
2794  // FIXME: This needs to cope with merging of prototyped/non-prototyped
2795  // functions, etc.
2796  if (FunctionDecl *FuncX = dyn_cast<FunctionDecl>(X)) {
2797  FunctionDecl *FuncY = cast<FunctionDecl>(Y);
2798  if (CXXConstructorDecl *CtorX = dyn_cast<CXXConstructorDecl>(X)) {
2799  CXXConstructorDecl *CtorY = cast<CXXConstructorDecl>(Y);
2800  if (CtorX->getInheritedConstructor() &&
2801  !isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
2803  return false;
2804  }
2805  ASTContext &C = FuncX->getASTContext();
2806  if (!C.hasSameType(FuncX->getType(), FuncY->getType())) {
2807  // We can get functions with different types on the redecl chain in C++17
2808  // if they have differing exception specifications and at least one of
2809  // the excpetion specs is unresolved.
2810  // FIXME: Do we need to check for C++14 deduced return types here too?
2811  auto *XFPT = FuncX->getType()->getAs<FunctionProtoType>();
2812  auto *YFPT = FuncY->getType()->getAs<FunctionProtoType>();
2813  if (C.getLangOpts().CPlusPlus1z && XFPT && YFPT &&
2814  (isUnresolvedExceptionSpec(XFPT->getExceptionSpecType()) ||
2816  C.hasSameFunctionTypeIgnoringExceptionSpec(FuncX->getType(),
2817  FuncY->getType()))
2818  return true;
2819  return false;
2820  }
2821  return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
2822  hasSameOverloadableAttrs(FuncX, FuncY);
2823  }
2824 
2825  // Variables with the same type and linkage match.
2826  if (VarDecl *VarX = dyn_cast<VarDecl>(X)) {
2827  VarDecl *VarY = cast<VarDecl>(Y);
2828  if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
2829  ASTContext &C = VarX->getASTContext();
2830  if (C.hasSameType(VarX->getType(), VarY->getType()))
2831  return true;
2832 
2833  // We can get decls with different types on the redecl chain. Eg.
2834  // template <typename T> struct S { static T Var[]; }; // #1
2835  // template <typename T> T S<T>::Var[sizeof(T)]; // #2
2836  // Only? happens when completing an incomplete array type. In this case
2837  // when comparing #1 and #2 we should go through their element type.
2838  const ArrayType *VarXTy = C.getAsArrayType(VarX->getType());
2839  const ArrayType *VarYTy = C.getAsArrayType(VarY->getType());
2840  if (!VarXTy || !VarYTy)
2841  return false;
2842  if (VarXTy->isIncompleteArrayType() || VarYTy->isIncompleteArrayType())
2843  return C.hasSameType(VarXTy->getElementType(), VarYTy->getElementType());
2844  }
2845  return false;
2846  }
2847 
2848  // Namespaces with the same name and inlinedness match.
2849  if (NamespaceDecl *NamespaceX = dyn_cast<NamespaceDecl>(X)) {
2850  NamespaceDecl *NamespaceY = cast<NamespaceDecl>(Y);
2851  return NamespaceX->isInline() == NamespaceY->isInline();
2852  }
2853 
2854  // Identical template names and kinds match if their template parameter lists
2855  // and patterns match.
2856  if (TemplateDecl *TemplateX = dyn_cast<TemplateDecl>(X)) {
2857  TemplateDecl *TemplateY = cast<TemplateDecl>(Y);
2858  return isSameEntity(TemplateX->getTemplatedDecl(),
2859  TemplateY->getTemplatedDecl()) &&
2860  isSameTemplateParameterList(TemplateX->getTemplateParameters(),
2861  TemplateY->getTemplateParameters());
2862  }
2863 
2864  // Fields with the same name and the same type match.
2865  if (FieldDecl *FDX = dyn_cast<FieldDecl>(X)) {
2866  FieldDecl *FDY = cast<FieldDecl>(Y);
2867  // FIXME: Also check the bitwidth is odr-equivalent, if any.
2868  return X->getASTContext().hasSameType(FDX->getType(), FDY->getType());
2869  }
2870 
2871  // Indirect fields with the same target field match.
2872  if (auto *IFDX = dyn_cast<IndirectFieldDecl>(X)) {
2873  auto *IFDY = cast<IndirectFieldDecl>(Y);
2874  return IFDX->getAnonField()->getCanonicalDecl() ==
2875  IFDY->getAnonField()->getCanonicalDecl();
2876  }
2877 
2878  // Enumerators with the same name match.
2879  if (isa<EnumConstantDecl>(X))
2880  // FIXME: Also check the value is odr-equivalent.
2881  return true;
2882 
2883  // Using shadow declarations with the same target match.
2884  if (UsingShadowDecl *USX = dyn_cast<UsingShadowDecl>(X)) {
2885  UsingShadowDecl *USY = cast<UsingShadowDecl>(Y);
2886  return USX->getTargetDecl() == USY->getTargetDecl();
2887  }
2888 
2889  // Using declarations with the same qualifier match. (We already know that
2890  // the name matches.)
2891  if (auto *UX = dyn_cast<UsingDecl>(X)) {
2892  auto *UY = cast<UsingDecl>(Y);
2893  return isSameQualifier(UX->getQualifier(), UY->getQualifier()) &&
2894  UX->hasTypename() == UY->hasTypename() &&
2895  UX->isAccessDeclaration() == UY->isAccessDeclaration();
2896  }
2897  if (auto *UX = dyn_cast<UnresolvedUsingValueDecl>(X)) {
2898  auto *UY = cast<UnresolvedUsingValueDecl>(Y);
2899  return isSameQualifier(UX->getQualifier(), UY->getQualifier()) &&
2900  UX->isAccessDeclaration() == UY->isAccessDeclaration();
2901  }
2902  if (auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(X))
2903  return isSameQualifier(
2904  UX->getQualifier(),
2905  cast<UnresolvedUsingTypenameDecl>(Y)->getQualifier());
2906 
2907  // Namespace alias definitions with the same target match.
2908  if (auto *NAX = dyn_cast<NamespaceAliasDecl>(X)) {
2909  auto *NAY = cast<NamespaceAliasDecl>(Y);
2910  return NAX->getNamespace()->Equals(NAY->getNamespace());
2911  }
2912 
2913  return false;
2914 }
2915 
2916 /// Find the context in which we should search for previous declarations when
2917 /// looking for declarations to merge.
2918 DeclContext *ASTDeclReader::getPrimaryContextForMerging(ASTReader &Reader,
2919  DeclContext *DC) {
2920  if (NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC))
2921  return ND->getOriginalNamespace();
2922 
2923  if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
2924  // Try to dig out the definition.
2925  auto *DD = RD->DefinitionData;
2926  if (!DD)
2927  DD = RD->getCanonicalDecl()->DefinitionData;
2928 
2929  // If there's no definition yet, then DC's definition is added by an update
2930  // record, but we've not yet loaded that update record. In this case, we
2931  // commit to DC being the canonical definition now, and will fix this when
2932  // we load the update record.
2933  if (!DD) {
2934  DD = new (Reader.getContext()) struct CXXRecordDecl::DefinitionData(RD);
2935  RD->IsCompleteDefinition = true;
2936  RD->DefinitionData = DD;
2937  RD->getCanonicalDecl()->DefinitionData = DD;
2938 
2939  // Track that we did this horrible thing so that we can fix it later.
2940  Reader.PendingFakeDefinitionData.insert(
2941  std::make_pair(DD, ASTReader::PendingFakeDefinitionKind::Fake));
2942  }
2943 
2944  return DD->Definition;
2945  }
2946 
2947  if (EnumDecl *ED = dyn_cast<EnumDecl>(DC))
2948  return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition()
2949  : nullptr;
2950 
2951  // We can see the TU here only if we have no Sema object. In that case,
2952  // there's no TU scope to look in, so using the DC alone is sufficient.
2953  if (auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2954  return TU;
2955 
2956  return nullptr;
2957 }
2958 
2959 ASTDeclReader::FindExistingResult::~FindExistingResult() {
2960  // Record that we had a typedef name for linkage whether or not we merge
2961  // with that declaration.
2962  if (TypedefNameForLinkage) {
2963  DeclContext *DC = New->getDeclContext()->getRedeclContext();
2964  Reader.ImportedTypedefNamesForLinkage.insert(
2965  std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New));
2966  return;
2967  }
2968 
2969  if (!AddResult || Existing)
2970  return;
2971 
2972  DeclarationName Name = New->getDeclName();
2973  DeclContext *DC = New->getDeclContext()->getRedeclContext();
2975  setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
2976  AnonymousDeclNumber, New);
2977  } else if (DC->isTranslationUnit() &&
2978  !Reader.getContext().getLangOpts().CPlusPlus) {
2979  if (Reader.getIdResolver().tryAddTopLevelDecl(New, Name))
2980  Reader.PendingFakeLookupResults[Name.getAsIdentifierInfo()]
2981  .push_back(New);
2982  } else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
2983  // Add the declaration to its redeclaration context so later merging
2984  // lookups will find it.
2985  MergeDC->makeDeclVisibleInContextImpl(New, /*Internal*/true);
2986  }
2987 }
2988 
2989 /// Find the declaration that should be merged into, given the declaration found
2990 /// by name lookup. If we're merging an anonymous declaration within a typedef,
2991 /// we need a matching typedef, and we merge with the type inside it.
2993  bool IsTypedefNameForLinkage) {
2994  if (!IsTypedefNameForLinkage)
2995  return Found;
2996 
2997  // If we found a typedef declaration that gives a name to some other
2998  // declaration, then we want that inner declaration. Declarations from
2999  // AST files are handled via ImportedTypedefNamesForLinkage.
3000  if (Found->isFromASTFile())
3001  return nullptr;
3002 
3003  if (auto *TND = dyn_cast<TypedefNameDecl>(Found))
3004  return TND->getAnonDeclWithTypedefName(/*AnyRedecl*/true);
3005 
3006  return nullptr;
3007 }
3008 
3009 NamedDecl *ASTDeclReader::getAnonymousDeclForMerging(ASTReader &Reader,
3010  DeclContext *DC,
3011  unsigned Index) {
3012  // If the lexical context has been merged, look into the now-canonical
3013  // definition.
3014  if (auto *Merged = Reader.MergedDeclContexts.lookup(DC))
3015  DC = Merged;
3016 
3017  // If we've seen this before, return the canonical declaration.
3018  auto &Previous = Reader.AnonymousDeclarationsForMerging[DC];
3019  if (Index < Previous.size() && Previous[Index])
3020  return Previous[Index];
3021 
3022  // If this is the first time, but we have parsed a declaration of the context,
3023  // build the anonymous declaration list from the parsed declaration.
3024  if (!cast<Decl>(DC)->isFromASTFile()) {
3025  numberAnonymousDeclsWithin(DC, [&](NamedDecl *ND, unsigned Number) {
3026  if (Previous.size() == Number)
3027  Previous.push_back(cast<NamedDecl>(ND->getCanonicalDecl()));
3028  else
3029  Previous[Number] = cast<NamedDecl>(ND->getCanonicalDecl());
3030  });
3031  }
3032 
3033  return Index < Previous.size() ? Previous[Index] : nullptr;
3034 }
3035 
3036 void ASTDeclReader::setAnonymousDeclForMerging(ASTReader &Reader,
3037  DeclContext *DC, unsigned Index,
3038  NamedDecl *D) {
3039  if (auto *Merged = Reader.MergedDeclContexts.lookup(DC))
3040  DC = Merged;
3041 
3042  auto &Previous = Reader.AnonymousDeclarationsForMerging[DC];
3043  if (Index >= Previous.size())
3044  Previous.resize(Index + 1);
3045  if (!Previous[Index])
3046  Previous[Index] = D;
3047 }
3048 
3049 ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) {
3050  DeclarationName Name = TypedefNameForLinkage ? TypedefNameForLinkage
3051  : D->getDeclName();
3052 
3053  if (!Name && !needsAnonymousDeclarationNumber(D)) {
3054  // Don't bother trying to find unnamed declarations that are in
3055  // unmergeable contexts.
3056  FindExistingResult Result(Reader, D, /*Existing=*/nullptr,
3057  AnonymousDeclNumber, TypedefNameForLinkage);
3058  Result.suppress();
3059  return Result;
3060  }
3061 
3063  if (TypedefNameForLinkage) {
3064  auto It = Reader.ImportedTypedefNamesForLinkage.find(
3065  std::make_pair(DC, TypedefNameForLinkage));
3066  if (It != Reader.ImportedTypedefNamesForLinkage.end())
3067  if (isSameEntity(It->second, D))
3068  return FindExistingResult(Reader, D, It->second, AnonymousDeclNumber,
3069  TypedefNameForLinkage);
3070  // Go on to check in other places in case an existing typedef name
3071  // was not imported.
3072  }
3073 
3075  // This is an anonymous declaration that we may need to merge. Look it up
3076  // in its context by number.
3077  if (auto *Existing = getAnonymousDeclForMerging(
3078  Reader, D->getLexicalDeclContext(), AnonymousDeclNumber))
3079  if (isSameEntity(Existing, D))
3080  return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3081  TypedefNameForLinkage);
3082  } else if (DC->isTranslationUnit() &&
3083  !Reader.getContext().getLangOpts().CPlusPlus) {
3084  IdentifierResolver &IdResolver = Reader.getIdResolver();
3085 
3086  // Temporarily consider the identifier to be up-to-date. We don't want to
3087  // cause additional lookups here.
3088  class UpToDateIdentifierRAII {
3089  IdentifierInfo *II;
3090  bool WasOutToDate;
3091 
3092  public:
3093  explicit UpToDateIdentifierRAII(IdentifierInfo *II)
3094  : II(II), WasOutToDate(false)
3095  {
3096  if (II) {
3097  WasOutToDate = II->isOutOfDate();
3098  if (WasOutToDate)
3099  II->setOutOfDate(false);
3100  }
3101  }
3102 
3103  ~UpToDateIdentifierRAII() {
3104  if (WasOutToDate)
3105  II->setOutOfDate(true);
3106  }
3107  } UpToDate(Name.getAsIdentifierInfo());
3108 
3109  for (IdentifierResolver::iterator I = IdResolver.begin(Name),
3110  IEnd = IdResolver.end();
3111  I != IEnd; ++I) {
3112  if (NamedDecl *Existing = getDeclForMerging(*I, TypedefNameForLinkage))
3113  if (isSameEntity(Existing, D))
3114  return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3115  TypedefNameForLinkage);
3116  }
3117  } else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
3118  DeclContext::lookup_result R = MergeDC->noload_lookup(Name);
3119  for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; ++I) {
3120  if (NamedDecl *Existing = getDeclForMerging(*I, TypedefNameForLinkage))
3121  if (isSameEntity(Existing, D))
3122  return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3123  TypedefNameForLinkage);
3124  }
3125  } else {
3126  // Not in a mergeable context.
3127  return FindExistingResult(Reader);
3128  }
3129 
3130  // If this declaration is from a merged context, make a note that we need to
3131  // check that the canonical definition of that context contains the decl.
3132  //
3133  // FIXME: We should do something similar if we merge two definitions of the
3134  // same template specialization into the same CXXRecordDecl.
3135  auto MergedDCIt = Reader.MergedDeclContexts.find(D->getLexicalDeclContext());
3136  if (MergedDCIt != Reader.MergedDeclContexts.end() &&
3137  MergedDCIt->second == D->getDeclContext())
3138  Reader.PendingOdrMergeChecks.push_back(D);
3139 
3140  return FindExistingResult(Reader, D, /*Existing=*/nullptr,
3141  AnonymousDeclNumber, TypedefNameForLinkage);
3142 }
3143 
3144 template<typename DeclT>
3146  return D->RedeclLink.getLatestNotUpdated();
3147 }
3149  llvm_unreachable("getMostRecentDecl on non-redeclarable declaration");
3150 }
3151 
3153  assert(D);
3154 
3155  switch (D->getKind()) {
3156 #define ABSTRACT_DECL(TYPE)
3157 #define DECL(TYPE, BASE) \
3158  case Decl::TYPE: \
3159  return getMostRecentDeclImpl(cast<TYPE##Decl>(D));
3160 #include "clang/AST/DeclNodes.inc"
3161  }
3162  llvm_unreachable("unknown decl kind");
3163 }
3164 
3165 Decl *ASTReader::getMostRecentExistingDecl(Decl *D) {
3167 }
3168 
3169 template<typename DeclT>
3172  Decl *Previous, Decl *Canon) {
3173  D->RedeclLink.setPrevious(cast<DeclT>(Previous));
3174  D->First = cast<DeclT>(Previous)->First;
3175 }
3176 
3177 namespace clang {
3178 template<>
3181  Decl *Previous, Decl *Canon) {
3182  VarDecl *VD = static_cast<VarDecl*>(D);
3183  VarDecl *PrevVD = cast<VarDecl>(Previous);
3184  D->RedeclLink.setPrevious(PrevVD);
3185  D->First = PrevVD->First;
3186 
3187  // We should keep at most one definition on the chain.
3188  // FIXME: Cache the definition once we've found it. Building a chain with
3189  // N definitions currently takes O(N^2) time here.
3191  for (VarDecl *CurD = PrevVD; CurD; CurD = CurD->getPreviousDecl()) {
3192  if (CurD->isThisDeclarationADefinition() == VarDecl::Definition) {
3193  Reader.mergeDefinitionVisibility(CurD, VD);
3195  break;
3196  }
3197  }
3198  }
3199 }
3200 
3201 template<>
3204  Decl *Previous, Decl *Canon) {
3205  FunctionDecl *FD = static_cast<FunctionDecl*>(D);
3206  FunctionDecl *PrevFD = cast<FunctionDecl>(Previous);
3207 
3208  FD->RedeclLink.setPrevious(PrevFD);
3209  FD->First = PrevFD->First;
3210 
3211  // If the previous declaration is an inline function declaration, then this
3212  // declaration is too.
3213  if (PrevFD->IsInline != FD->IsInline) {
3214  // FIXME: [dcl.fct.spec]p4:
3215  // If a function with external linkage is declared inline in one
3216  // translation unit, it shall be declared inline in all translation
3217  // units in which it appears.
3218  //
3219  // Be careful of this case:
3220  //
3221  // module A:
3222  // template<typename T> struct X { void f(); };
3223  // template<typename T> inline void X<T>::f() {}
3224  //
3225  // module B instantiates the declaration of X<int>::f
3226  // module C instantiates the definition of X<int>::f
3227  //
3228  // If module B and C are merged, we do not have a violation of this rule.
3229  FD->IsInline = true;
3230  }
3231 
3232  // If we need to propagate an exception specification along the redecl
3233  // chain, make a note of that so that we can do so later.
3234  auto *FPT = FD->getType()->getAs<FunctionProtoType>();
3235  auto *PrevFPT = PrevFD->getType()->getAs<FunctionProtoType>();
3236  if (FPT && PrevFPT) {
3237  bool IsUnresolved = isUnresolvedExceptionSpec(FPT->getExceptionSpecType());
3238  bool WasUnresolved =
3240  if (IsUnresolved != WasUnresolved)
3241  Reader.PendingExceptionSpecUpdates.insert(
3242  std::make_pair(Canon, IsUnresolved ? PrevFD : FD));
3243  }
3244 }
3245 } // end namespace clang
3246 
3248  llvm_unreachable("attachPreviousDecl on non-redeclarable declaration");
3249 }
3250 
3251 /// Inherit the default template argument from \p From to \p To. Returns
3252 /// \c false if there is no default template for \p From.
3253 template <typename ParmDecl>
3255  Decl *ToD) {
3256  auto *To = cast<ParmDecl>(ToD);
3257  if (!From->hasDefaultArgument())
3258  return false;
3259  To->setInheritedDefaultArgument(Context, From);
3260  return true;
3261 }
3262 
3264  TemplateDecl *From,
3265  TemplateDecl *To) {
3266  auto *FromTP = From->getTemplateParameters();
3267  auto *ToTP = To->getTemplateParameters();
3268  assert(FromTP->size() == ToTP->size() && "merged mismatched templates?");
3269 
3270  for (unsigned I = 0, N = FromTP->size(); I != N; ++I) {
3271  NamedDecl *FromParam = FromTP->getParam(N - I - 1);
3272  if (FromParam->isParameterPack())
3273  continue;
3274  NamedDecl *ToParam = ToTP->getParam(N - I - 1);
3275 
3276  if (auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam)) {
3277  if (!inheritDefaultTemplateArgument(Context, FTTP, ToParam))
3278  break;
3279  } else if (auto *FNTTP = dyn_cast<NonTypeTemplateParmDecl>(FromParam)) {
3280  if (!inheritDefaultTemplateArgument(Context, FNTTP, ToParam))
3281  break;
3282  } else {
3284  Context, cast<TemplateTemplateParmDecl>(FromParam), ToParam))
3285  break;
3286  }
3287  }
3288 }
3289 
3291  Decl *Previous, Decl *Canon) {
3292  assert(D && Previous);
3293 
3294  switch (D->getKind()) {
3295 #define ABSTRACT_DECL(TYPE)
3296 #define DECL(TYPE, BASE) \
3297  case Decl::TYPE: \
3298  attachPreviousDeclImpl(Reader, cast<TYPE##Decl>(D), Previous, Canon); \
3299  break;
3300 #include "clang/AST/DeclNodes.inc"
3301  }
3302 
3303  // If the declaration was visible in one module, a redeclaration of it in
3304  // another module remains visible even if it wouldn't be visible by itself.
3305  //
3306  // FIXME: In this case, the declaration should only be visible if a module
3307  // that makes it visible has been imported.
3308  D->IdentifierNamespace |=
3309  Previous->IdentifierNamespace &
3311 
3312  // If the declaration declares a template, it may inherit default arguments
3313  // from the previous declaration.
3314  if (TemplateDecl *TD = dyn_cast<TemplateDecl>(D))
3316  cast<TemplateDecl>(Previous), TD);
3317 }
3318 
3319 template<typename DeclT>
3321  D->RedeclLink.setLatest(cast<DeclT>(Latest));
3322 }
3324  llvm_unreachable("attachLatestDecl on non-redeclarable declaration");
3325 }
3326 
3328  assert(D && Latest);
3329 
3330  switch (D->getKind()) {
3331 #define ABSTRACT_DECL(TYPE)
3332 #define DECL(TYPE, BASE) \
3333  case Decl::TYPE: \
3334  attachLatestDeclImpl(cast<TYPE##Decl>(D), Latest); \
3335  break;
3336 #include "clang/AST/DeclNodes.inc"
3337  }
3338 }
3339 
3340 template<typename DeclT>
3342  D->RedeclLink.markIncomplete();
3343 }
3345  llvm_unreachable("markIncompleteDeclChain on non-redeclarable declaration");
3346 }
3347 
3348 void ASTReader::markIncompleteDeclChain(Decl *D) {
3349  switch (D->getKind()) {
3350 #define ABSTRACT_DECL(TYPE)
3351 #define DECL(TYPE, BASE) \
3352  case Decl::TYPE: \
3353  ASTDeclReader::markIncompleteDeclChainImpl(cast<TYPE##Decl>(D)); \
3354  break;
3355 #include "clang/AST/DeclNodes.inc"
3356  }
3357 }
3358 
3359 /// \brief Read the declaration at the given offset from the AST file.
3360 Decl *ASTReader::ReadDeclRecord(DeclID ID) {
3361  unsigned Index = ID - NUM_PREDEF_DECL_IDS;
3362  SourceLocation DeclLoc;
3363  RecordLocation Loc = DeclCursorForID(ID, DeclLoc);
3364  llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
3365  // Keep track of where we are in the stream, then jump back there
3366  // after reading this declaration.
3367  SavedStreamPosition SavedPosition(DeclsCursor);
3368 
3369  ReadingKindTracker ReadingKind(Read_Decl, *this);
3370 
3371  // Note that we are loading a declaration record.
3372  Deserializing ADecl(this);
3373 
3374  DeclsCursor.JumpToBit(Loc.Offset);
3375  ASTRecordReader Record(*this, *Loc.F);
3376  ASTDeclReader Reader(*this, Record, Loc, ID, DeclLoc);
3377  unsigned Code = DeclsCursor.ReadCode();
3378 
3379  ASTContext &Context = getContext();
3380  Decl *D = nullptr;
3381  switch ((DeclCode)Record.readRecord(DeclsCursor, Code)) {
3382  case DECL_CONTEXT_LEXICAL:
3383  case DECL_CONTEXT_VISIBLE:
3384  llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord");
3385  case DECL_TYPEDEF:
3386  D = TypedefDecl::CreateDeserialized(Context, ID);
3387  break;
3388  case DECL_TYPEALIAS:
3389  D = TypeAliasDecl::CreateDeserialized(Context, ID);
3390  break;
3391  case DECL_ENUM:
3392  D = EnumDecl::CreateDeserialized(Context, ID);
3393  break;
3394  case DECL_RECORD:
3395  D = RecordDecl::CreateDeserialized(Context, ID);
3396  break;
3397  case DECL_ENUM_CONSTANT:
3398  D = EnumConstantDecl::CreateDeserialized(Context, ID);
3399  break;
3400  case DECL_FUNCTION:
3401  D = FunctionDecl::CreateDeserialized(Context, ID);
3402  break;
3403  case DECL_LINKAGE_SPEC:
3404  D = LinkageSpecDecl::CreateDeserialized(Context, ID);
3405  break;
3406  case DECL_EXPORT:
3407  D = ExportDecl::CreateDeserialized(Context, ID);
3408  break;
3409  case DECL_LABEL:
3410  D = LabelDecl::CreateDeserialized(Context, ID);
3411  break;
3412  case DECL_NAMESPACE:
3413  D = NamespaceDecl::CreateDeserialized(Context, ID);
3414  break;
3415  case DECL_NAMESPACE_ALIAS:
3416  D = NamespaceAliasDecl::CreateDeserialized(Context, ID);
3417  break;
3418  case DECL_USING:
3419  D = UsingDecl::CreateDeserialized(Context, ID);
3420  break;
3421  case DECL_USING_PACK:
3422  D = UsingPackDecl::CreateDeserialized(Context, ID, Record.readInt());
3423  break;
3424  case DECL_USING_SHADOW:
3425  D = UsingShadowDecl::CreateDeserialized(Context, ID);
3426  break;
3429  break;
3430  case DECL_USING_DIRECTIVE:
3431  D = UsingDirectiveDecl::CreateDeserialized(Context, ID);
3432  break;
3435  break;
3438  break;
3439  case DECL_CXX_RECORD:
3440  D = CXXRecordDecl::CreateDeserialized(Context, ID);
3441  break;
3444  break;
3445  case DECL_CXX_METHOD:
3446  D = CXXMethodDecl::CreateDeserialized(Context, ID);
3447  break;
3448  case DECL_CXX_CONSTRUCTOR:
3449  D = CXXConstructorDecl::CreateDeserialized(Context, ID, false);
3450  break;
3452  D = CXXConstructorDecl::CreateDeserialized(Context, ID, true);
3453  break;
3454  case DECL_CXX_DESTRUCTOR:
3455  D = CXXDestructorDecl::CreateDeserialized(Context, ID);
3456  break;
3457  case DECL_CXX_CONVERSION:
3458  D = CXXConversionDecl::CreateDeserialized(Context, ID);
3459  break;
3460  case DECL_ACCESS_SPEC:
3461  D = AccessSpecDecl::CreateDeserialized(Context, ID);
3462  break;
3463  case DECL_FRIEND:
3464  D = FriendDecl::CreateDeserialized(Context, ID, Record.readInt());
3465  break;
3466  case DECL_FRIEND_TEMPLATE:
3467  D = FriendTemplateDecl::CreateDeserialized(Context, ID);
3468  break;
3469  case DECL_CLASS_TEMPLATE:
3470  D = ClassTemplateDecl::CreateDeserialized(Context, ID);
3471  break;
3474  break;
3477  break;
3478  case DECL_VAR_TEMPLATE:
3479  D = VarTemplateDecl::CreateDeserialized(Context, ID);
3480  break;
3483  break;
3486  break;
3489  break;
3492  break;
3495  break;
3498  break;
3501  Record.readInt());
3502  break;
3505  break;
3508  Record.readInt());
3509  break;
3512  break;
3513  case DECL_STATIC_ASSERT:
3514  D = StaticAssertDecl::CreateDeserialized(Context, ID);
3515  break;
3516  case DECL_OBJC_METHOD:
3517  D = ObjCMethodDecl::CreateDeserialized(Context, ID);
3518  break;
3519  case DECL_OBJC_INTERFACE:
3520  D = ObjCInterfaceDecl::CreateDeserialized(Context, ID);
3521  break;
3522  case DECL_OBJC_IVAR:
3523  D = ObjCIvarDecl::CreateDeserialized(Context, ID);
3524  break;
3525  case DECL_OBJC_PROTOCOL:
3526  D = ObjCProtocolDecl::CreateDeserialized(Context, ID);
3527  break;
3529  D = ObjCAtDefsFieldDecl::CreateDeserialized(Context, ID);
3530  break;
3531  case DECL_OBJC_CATEGORY:
3532  D = ObjCCategoryDecl::CreateDeserialized(Context, ID);
3533  break;
3536  break;
3539  break;
3542  break;
3543  case DECL_OBJC_PROPERTY:
3544  D = ObjCPropertyDecl::CreateDeserialized(Context, ID);
3545  break;
3548  break;
3549  case DECL_FIELD:
3550  D = FieldDecl::CreateDeserialized(Context, ID);
3551  break;
3552  case DECL_INDIRECTFIELD:
3553  D = IndirectFieldDecl::CreateDeserialized(Context, ID);
3554  break;
3555  case DECL_VAR:
3556  D = VarDecl::CreateDeserialized(Context, ID);
3557  break;
3558  case DECL_IMPLICIT_PARAM:
3559  D = ImplicitParamDecl::CreateDeserialized(Context, ID);
3560  break;
3561  case DECL_PARM_VAR:
3562  D = ParmVarDecl::CreateDeserialized(Context, ID);
3563  break;
3564  case DECL_DECOMPOSITION:
3565  D = DecompositionDecl::CreateDeserialized(Context, ID, Record.readInt());
3566  break;
3567  case DECL_BINDING:
3568  D = BindingDecl::CreateDeserialized(Context, ID);
3569  break;
3570  case DECL_FILE_SCOPE_ASM:
3571  D = FileScopeAsmDecl::CreateDeserialized(Context, ID);
3572  break;
3573  case DECL_BLOCK:
3574  D = BlockDecl::CreateDeserialized(Context, ID);
3575  break;
3576  case DECL_MS_PROPERTY:
3577  D = MSPropertyDecl::CreateDeserialized(Context, ID);
3578  break;
3579  case DECL_CAPTURED:
3580  D = CapturedDecl::CreateDeserialized(Context, ID, Record.readInt());
3581  break;
3583  Error("attempt to read a C++ base-specifier record as a declaration");
3584  return nullptr;
3586  Error("attempt to read a C++ ctor initializer record as a declaration");
3587  return nullptr;
3588  case DECL_IMPORT:
3589  // Note: last entry of the ImportDecl record is the number of stored source
3590  // locations.
3591  D = ImportDecl::CreateDeserialized(Context, ID, Record.back());
3592  break;
3594  D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, Record.readInt());
3595  break;
3598  break;
3599  case DECL_OMP_CAPTUREDEXPR:
3600  D = OMPCapturedExprDecl::CreateDeserialized(Context, ID);
3601  break;
3602  case DECL_PRAGMA_COMMENT:
3603  D = PragmaCommentDecl::CreateDeserialized(Context, ID, Record.readInt());
3604  break;
3607  Record.readInt());
3608  break;
3609  case DECL_EMPTY:
3610  D = EmptyDecl::CreateDeserialized(Context, ID);
3611  break;
3612  case DECL_OBJC_TYPE_PARAM:
3613  D = ObjCTypeParamDecl::CreateDeserialized(Context, ID);
3614  break;
3615  }
3616 
3617  assert(D && "Unknown declaration reading AST file");
3618  LoadedDecl(Index, D);
3619  // Set the DeclContext before doing any deserialization, to make sure internal
3620  // calls to Decl::getASTContext() by Decl's methods will find the
3621  // TranslationUnitDecl without crashing.
3622  D->setDeclContext(Context.getTranslationUnitDecl());
3623  Reader.Visit(D);
3624 
3625  // If this declaration is also a declaration context, get the
3626  // offsets for its tables of lexical and visible declarations.
3627  if (DeclContext *DC = dyn_cast<DeclContext>(D)) {
3628  std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC);
3629  if (Offsets.first &&
3630  ReadLexicalDeclContextStorage(*Loc.F, DeclsCursor, Offsets.first, DC))
3631  return nullptr;
3632  if (Offsets.second &&
3633  ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID))
3634  return nullptr;
3635  }
3636  assert(Record.getIdx() == Record.size());
3637 
3638  // Load any relevant update records.
3639  PendingUpdateRecords.push_back(
3640  PendingUpdateRecord(ID, D, /*JustLoaded=*/true));
3641 
3642  // Load the categories after recursive loading is finished.
3643  if (ObjCInterfaceDecl *Class = dyn_cast<ObjCInterfaceDecl>(D))
3644  // If we already have a definition when deserializing the ObjCInterfaceDecl,
3645  // we put the Decl in PendingDefinitions so we can pull the categories here.
3646  if (Class->isThisDeclarationADefinition() ||
3647  PendingDefinitions.count(Class))
3648  loadObjCCategories(ID, Class);
3649 
3650  // If we have deserialized a declaration that has a definition the
3651  // AST consumer might need to know about, queue it.
3652  // We don't pass it to the consumer immediately because we may be in recursive
3653  // loading, and some declarations may still be initializing.
3654  PotentiallyInterestingDecls.push_back(
3655  InterestingDecl(D, Reader.hasPendingBody()));
3656 
3657  return D;
3658 }
3659 
3660 void ASTReader::PassInterestingDeclsToConsumer() {
3661  assert(Consumer);
3662 
3663  if (PassingDeclsToConsumer)
3664  return;
3665 
3666  // Guard variable to avoid recursively redoing the process of passing
3667  // decls to consumer.
3668  SaveAndRestore<bool> GuardPassingDeclsToConsumer(PassingDeclsToConsumer,
3669  true);
3670 
3671  // Ensure that we've loaded all potentially-interesting declarations
3672  // that need to be eagerly loaded.
3673  for (auto ID : EagerlyDeserializedDecls)
3674  GetDecl(ID);
3675  EagerlyDeserializedDecls.clear();
3676 
3677  while (!PotentiallyInterestingDecls.empty()) {
3678  InterestingDecl D = PotentiallyInterestingDecls.front();
3679  PotentiallyInterestingDecls.pop_front();
3680  if (isConsumerInterestedIn(getContext(), D.getDecl(), D.hasPendingBody()))
3681  PassInterestingDeclToConsumer(D.getDecl());
3682  }
3683 }
3684 
3685 void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
3686  // The declaration may have been modified by files later in the chain.
3687  // If this is the case, read the record containing the updates from each file
3688  // and pass it to ASTDeclReader to make the modifications.
3689  serialization::GlobalDeclID ID = Record.ID;
3690  Decl *D = Record.D;
3691  ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
3692  DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
3693 
3694  llvm::SmallVector<serialization::DeclID, 8> PendingLazySpecializationIDs;
3695 
3696  if (UpdI != DeclUpdateOffsets.end()) {
3697  auto UpdateOffsets = std::move(UpdI->second);
3698  DeclUpdateOffsets.erase(UpdI);
3699 
3700  // Check if this decl was interesting to the consumer. If we just loaded
3701  // the declaration, then we know it was interesting and we skip the call
3702  // to isConsumerInterestedIn because it is unsafe to call in the
3703  // current ASTReader state.
3704  bool WasInteresting =
3705  Record.JustLoaded || isConsumerInterestedIn(getContext(), D, false);
3706  for (auto &FileAndOffset : UpdateOffsets) {
3707  ModuleFile *F = FileAndOffset.first;
3708  uint64_t Offset = FileAndOffset.second;
3709  llvm::BitstreamCursor &Cursor = F->DeclsCursor;
3710  SavedStreamPosition SavedPosition(Cursor);
3711  Cursor.JumpToBit(Offset);
3712  unsigned Code = Cursor.ReadCode();
3713  ASTRecordReader Record(*this, *F);
3714  unsigned RecCode = Record.readRecord(Cursor, Code);
3715  (void)RecCode;
3716  assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!");
3717 
3718  ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
3719  SourceLocation());
3720  Reader.UpdateDecl(D, PendingLazySpecializationIDs);
3721 
3722  // We might have made this declaration interesting. If so, remember that
3723  // we need to hand it off to the consumer.
3724  if (!WasInteresting &&
3725  isConsumerInterestedIn(getContext(), D, Reader.hasPendingBody())) {
3726  PotentiallyInterestingDecls.push_back(
3727  InterestingDecl(D, Reader.hasPendingBody()));
3728  WasInteresting = true;
3729  }
3730  }
3731  }
3732  // Add the lazy specializations to the template.
3733  assert((PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) ||
3734  isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) &&
3735  "Must not have pending specializations");
3736  if (auto *CTD = dyn_cast<ClassTemplateDecl>(D))
3737  ASTDeclReader::AddLazySpecializations(CTD, PendingLazySpecializationIDs);
3738  else if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
3739  ASTDeclReader::AddLazySpecializations(FTD, PendingLazySpecializationIDs);
3740  else if (auto *VTD = dyn_cast<VarTemplateDecl>(D))
3741  ASTDeclReader::AddLazySpecializations(VTD, PendingLazySpecializationIDs);
3742  PendingLazySpecializationIDs.clear();
3743 
3744  // Load the pending visible updates for this decl context, if it has any.
3745  auto I = PendingVisibleUpdates.find(ID);
3746  if (I != PendingVisibleUpdates.end()) {
3747  auto VisibleUpdates = std::move(I->second);
3748  PendingVisibleUpdates.erase(I);
3749 
3750  auto *DC = cast<DeclContext>(D)->getPrimaryContext();
3751  for (const PendingVisibleUpdate &Update : VisibleUpdates)
3752  Lookups[DC].Table.add(
3753  Update.Mod, Update.Data,
3754  reader::ASTDeclContextNameLookupTrait(*this, *Update.Mod));
3755  DC->setHasExternalVisibleStorage(true);
3756  }
3757 }
3758 
3759 void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) {
3760  // Attach FirstLocal to the end of the decl chain.
3761  Decl *CanonDecl = FirstLocal->getCanonicalDecl();
3762  if (FirstLocal != CanonDecl) {
3763  Decl *PrevMostRecent = ASTDeclReader::getMostRecentDecl(CanonDecl);
3765  *this, FirstLocal, PrevMostRecent ? PrevMostRecent : CanonDecl,
3766  CanonDecl);
3767  }
3768 
3769  if (!LocalOffset) {
3770  ASTDeclReader::attachLatestDecl(CanonDecl, FirstLocal);
3771  return;
3772  }
3773 
3774  // Load the list of other redeclarations from this module file.
3775  ModuleFile *M = getOwningModuleFile(FirstLocal);
3776  assert(M && "imported decl from no module file");
3777 
3778  llvm::BitstreamCursor &Cursor = M->DeclsCursor;
3779  SavedStreamPosition SavedPosition(Cursor);
3780  Cursor.JumpToBit(LocalOffset);
3781 
3782  RecordData Record;
3783  unsigned Code = Cursor.ReadCode();
3784  unsigned RecCode = Cursor.readRecord(Code, Record);
3785  (void)RecCode;
3786  assert(RecCode == LOCAL_REDECLARATIONS && "expected LOCAL_REDECLARATIONS record!");
3787 
3788  // FIXME: We have several different dispatches on decl kind here; maybe
3789  // we should instead generate one loop per kind and dispatch up-front?
3790  Decl *MostRecent = FirstLocal;
3791  for (unsigned I = 0, N = Record.size(); I != N; ++I) {
3792  auto *D = GetLocalDecl(*M, Record[N - I - 1]);
3793  ASTDeclReader::attachPreviousDecl(*this, D, MostRecent, CanonDecl);
3794  MostRecent = D;
3795  }
3796  ASTDeclReader::attachLatestDecl(CanonDecl, MostRecent);
3797 }
3798 
3799 namespace {
3800  /// \brief Given an ObjC interface, goes through the modules and links to the
3801  /// interface all the categories for it.
3802  class ObjCCategoriesVisitor {
3803  ASTReader &Reader;
3804  ObjCInterfaceDecl *Interface;
3805  llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized;
3806  ObjCCategoryDecl *Tail;
3807  llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap;
3808  serialization::GlobalDeclID InterfaceID;
3809  unsigned PreviousGeneration;
3810 
3811  void add(ObjCCategoryDecl *Cat) {
3812  // Only process each category once.
3813  if (!Deserialized.erase(Cat))
3814  return;
3815 
3816  // Check for duplicate categories.
3817  if (Cat->getDeclName()) {
3818  ObjCCategoryDecl *&Existing = NameCategoryMap[Cat->getDeclName()];
3819  if (Existing &&
3820  Reader.getOwningModuleFile(Existing)
3821  != Reader.getOwningModuleFile(Cat)) {
3822  // FIXME: We should not warn for duplicates in diamond:
3823  //
3824  // MT //
3825  // / \ //
3826  // ML MR //
3827  // \ / //
3828  // MB //
3829  //
3830  // If there are duplicates in ML/MR, there will be warning when
3831  // creating MB *and* when importing MB. We should not warn when
3832  // importing.
3833  Reader.Diag(Cat->getLocation(), diag::warn_dup_category_def)
3834  << Interface->getDeclName() << Cat->getDeclName();
3835  Reader.Diag(Existing->getLocation(), diag::note_previous_definition);
3836  } else if (!Existing) {
3837  // Record this category.
3838  Existing = Cat;
3839  }
3840  }
3841 
3842  // Add this category to the end of the chain.
3843  if (Tail)
3845  else
3846  Interface->setCategoryListRaw(Cat);
3847  Tail = Cat;
3848  }
3849 
3850  public:
3851  ObjCCategoriesVisitor(ASTReader &Reader,
3852  ObjCInterfaceDecl *Interface,
3853  llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
3854  serialization::GlobalDeclID InterfaceID,
3855  unsigned PreviousGeneration)
3856  : Reader(Reader), Interface(Interface), Deserialized(Deserialized),
3857  Tail(nullptr), InterfaceID(InterfaceID),
3858  PreviousGeneration(PreviousGeneration)
3859  {
3860  // Populate the name -> category map with the set of known categories.
3861  for (auto *Cat : Interface->known_categories()) {
3862  if (Cat->getDeclName())
3863  NameCategoryMap[Cat->getDeclName()] = Cat;
3864 
3865  // Keep track of the tail of the category list.
3866  Tail = Cat;
3867  }
3868  }
3869 
3870  bool operator()(ModuleFile &M) {
3871  // If we've loaded all of the category information we care about from
3872  // this module file, we're done.
3873  if (M.Generation <= PreviousGeneration)
3874  return true;
3875 
3876  // Map global ID of the definition down to the local ID used in this
3877  // module file. If there is no such mapping, we'll find nothing here
3878  // (or in any module it imports).
3879  DeclID LocalID = Reader.mapGlobalIDToModuleFileGlobalID(M, InterfaceID);
3880  if (!LocalID)
3881  return true;
3882 
3883  // Perform a binary search to find the local redeclarations for this
3884  // declaration (if any).
3885  const ObjCCategoriesInfo Compare = { LocalID, 0 };
3886  const ObjCCategoriesInfo *Result
3887  = std::lower_bound(M.ObjCCategoriesMap,
3889  Compare);
3890  if (Result == M.ObjCCategoriesMap + M.LocalNumObjCCategoriesInMap ||
3891  Result->DefinitionID != LocalID) {
3892  // We didn't find anything. If the class definition is in this module
3893  // file, then the module files it depends on cannot have any categories,
3894  // so suppress further lookup.
3895  return Reader.isDeclIDFromModule(InterfaceID, M);
3896  }
3897 
3898  // We found something. Dig out all of the categories.
3899  unsigned Offset = Result->Offset;
3900  unsigned N = M.ObjCCategories[Offset];
3901  M.ObjCCategories[Offset++] = 0; // Don't try to deserialize again
3902  for (unsigned I = 0; I != N; ++I)
3903  add(cast_or_null<ObjCCategoryDecl>(
3904  Reader.GetLocalDecl(M, M.ObjCCategories[Offset++])));
3905  return true;
3906  }
3907  };
3908 } // end anonymous namespace
3909 
3910 void ASTReader::loadObjCCategories(serialization::GlobalDeclID ID,
3911  ObjCInterfaceDecl *D,
3912  unsigned PreviousGeneration) {
3913  ObjCCategoriesVisitor Visitor(*this, D, CategoriesDeserialized, ID,
3914  PreviousGeneration);
3915  ModuleMgr.visit(Visitor);
3916 }
3917 
3918 template<typename DeclT, typename Fn>
3919 static void forAllLaterRedecls(DeclT *D, Fn F) {
3920  F(D);
3921 
3922  // Check whether we've already merged D into its redeclaration chain.
3923  // MostRecent may or may not be nullptr if D has not been merged. If
3924  // not, walk the merged redecl chain and see if it's there.
3925  auto *MostRecent = D->getMostRecentDecl();
3926  bool Found = false;
3927  for (auto *Redecl = MostRecent; Redecl && !Found;
3928  Redecl = Redecl->getPreviousDecl())
3929  Found = (Redecl == D);
3930 
3931  // If this declaration is merged, apply the functor to all later decls.
3932  if (Found) {
3933  for (auto *Redecl = MostRecent; Redecl != D;
3934  Redecl = Redecl->getPreviousDecl())
3935  F(Redecl);
3936  }
3937 }
3938 
3940  llvm::SmallVectorImpl<serialization::DeclID> &PendingLazySpecializationIDs) {
3941  while (Record.getIdx() < Record.size()) {
3942  switch ((DeclUpdateKind)Record.readInt()) {
3944  auto *RD = cast<CXXRecordDecl>(D);
3945  // FIXME: If we also have an update record for instantiating the
3946  // definition of D, we need that to happen before we get here.
3947  Decl *MD = Record.readDecl();
3948  assert(MD && "couldn't read decl from update record");
3949  // FIXME: We should call addHiddenDecl instead, to add the member
3950  // to its DeclContext.
3951  RD->addedMember(MD);
3952  break;
3953  }
3954 
3956  // It will be added to the template's lazy specialization set.
3957  PendingLazySpecializationIDs.push_back(ReadDeclID());
3958  break;
3959 
3961  NamespaceDecl *Anon = ReadDeclAs<NamespaceDecl>();
3962 
3963  // Each module has its own anonymous namespace, which is disjoint from
3964  // any other module's anonymous namespaces, so don't attach the anonymous
3965  // namespace at all.
3966  if (!Record.isModule()) {
3967  if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D))
3968  TU->setAnonymousNamespace(Anon);
3969  else
3970  cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
3971  }
3972  break;
3973  }
3974 
3976  VarDecl *VD = cast<VarDecl>(D);
3978  ReadSourceLocation());
3979  uint64_t Val = Record.readInt();
3980  if (Val && !VD->getInit()) {
3981  VD->setInit(Record.readExpr());
3982  if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3
3983  EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
3984  Eval->CheckedICE = true;
3985  Eval->IsICE = Val == 3;
3986  }
3987  }
3988  break;
3989  }
3990 
3992  auto Param = cast<ParmVarDecl>(D);
3993 
3994  // We have to read the default argument regardless of whether we use it
3995  // so that hypothetical further update records aren't messed up.
3996  // TODO: Add a function to skip over the next expr record.
3997  auto DefaultArg = Record.readExpr();
3998 
3999  // Only apply the update if the parameter still has an uninstantiated
4000  // default argument.
4001  if (Param->hasUninstantiatedDefaultArg())
4002  Param->setDefaultArg(DefaultArg);
4003  break;
4004  }
4005 
4007  auto FD = cast<FieldDecl>(D);
4008  auto DefaultInit = Record.readExpr();
4009 
4010  // Only apply the update if the field still has an uninstantiated
4011  // default member initializer.
4012  if (FD->hasInClassInitializer() && !FD->getInClassInitializer()) {
4013  if (DefaultInit)
4014  FD->setInClassInitializer(DefaultInit);
4015  else
4016  // Instantiation failed. We can get here if we serialized an AST for
4017  // an invalid program.
4018  FD->removeInClassInitializer();
4019  }
4020  break;
4021  }
4022 
4024  FunctionDecl *FD = cast<FunctionDecl>(D);
4025  if (Reader.PendingBodies[FD]) {
4026  // FIXME: Maybe check for ODR violations.
4027  // It's safe to stop now because this update record is always last.
4028  return;
4029  }
4030 
4031  if (Record.readInt()) {
4032  // Maintain AST consistency: any later redeclarations of this function
4033  // are inline if this one is. (We might have merged another declaration
4034  // into this one.)
4035  forAllLaterRedecls(FD, [](FunctionDecl *FD) {
4036  FD->setImplicitlyInline();
4037  });
4038  }
4039  FD->setInnerLocStart(ReadSourceLocation());
4040  ReadFunctionDefinition(FD);
4041  assert(Record.getIdx() == Record.size() && "lazy body must be last");
4042  break;
4043  }
4044 
4046  auto *RD = cast<CXXRecordDecl>(D);
4047  auto *OldDD = RD->getCanonicalDecl()->DefinitionData;
4048  bool HadRealDefinition =
4049  OldDD && (OldDD->Definition != RD ||
4050  !Reader.PendingFakeDefinitionData.count(OldDD));
4051  ReadCXXRecordDefinition(RD, /*Update*/true);
4052 
4053  // Visible update is handled separately.
4054  uint64_t LexicalOffset = ReadLocalOffset();
4055  if (!HadRealDefinition && LexicalOffset) {
4056  Record.readLexicalDeclContextStorage(LexicalOffset, RD);
4057  Reader.PendingFakeDefinitionData.erase(OldDD);
4058  }
4059 
4060  auto TSK = (TemplateSpecializationKind)Record.readInt();
4061  SourceLocation POI = ReadSourceLocation();
4062  if (MemberSpecializationInfo *MSInfo =
4063  RD->getMemberSpecializationInfo()) {
4064  MSInfo->setTemplateSpecializationKind(TSK);
4065  MSInfo->setPointOfInstantiation(POI);
4066  } else {
4068  cast<ClassTemplateSpecializationDecl>(RD);
4069  Spec->setTemplateSpecializationKind(TSK);
4070  Spec->setPointOfInstantiation(POI);
4071 
4072  if (Record.readInt()) {
4073  auto PartialSpec =
4074  ReadDeclAs<ClassTemplatePartialSpecializationDecl>();
4076  Record.readTemplateArgumentList(TemplArgs);
4077  auto *TemplArgList = TemplateArgumentList::CreateCopy(
4078  Reader.getContext(), TemplArgs);
4079 
4080  // FIXME: If we already have a partial specialization set,
4081  // check that it matches.
4082  if (!Spec->getSpecializedTemplateOrPartial()
4084  Spec->setInstantiationOf(PartialSpec, TemplArgList);
4085  }
4086  }
4087 
4088  RD->setTagKind((TagTypeKind)Record.readInt());
4089  RD->setLocation(ReadSourceLocation());
4090  RD->setLocStart(ReadSourceLocation());
4091  RD->setBraceRange(ReadSourceRange());
4092 
4093  if (Record.readInt()) {
4094  AttrVec Attrs;
4095  Record.readAttributes(Attrs);
4096  // If the declaration already has attributes, we assume that some other
4097  // AST file already loaded them.
4098  if (!D->hasAttrs())
4099  D->setAttrsImpl(Attrs, Reader.getContext());
4100  }
4101  break;
4102  }
4103 
4105  // Set the 'operator delete' directly to avoid emitting another update
4106  // record.
4107  auto *Del = ReadDeclAs<FunctionDecl>();
4108  auto *First = cast<CXXDestructorDecl>(D->getCanonicalDecl());
4109  // FIXME: Check consistency if we have an old and new operator delete.
4110  if (!First->OperatorDelete)
4111  First->OperatorDelete = Del;
4112  break;
4113  }
4114 
4117  SmallVector<QualType, 8> ExceptionStorage;
4118  Record.readExceptionSpec(ExceptionStorage, ESI);
4119 
4120  // Update this declaration's exception specification, if needed.
4121  auto *FD = cast<FunctionDecl>(D);
4122  auto *FPT = FD->getType()->castAs<FunctionProtoType>();
4123  // FIXME: If the exception specification is already present, check that it
4124  // matches.
4125  if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType())) {
4126  FD->setType(Reader.getContext().getFunctionType(
4127  FPT->getReturnType(), FPT->getParamTypes(),
4128  FPT->getExtProtoInfo().withExceptionSpec(ESI)));
4129 
4130  // When we get to the end of deserializing, see if there are other decls
4131  // that we need to propagate this exception specification onto.
4132  Reader.PendingExceptionSpecUpdates.insert(
4133  std::make_pair(FD->getCanonicalDecl(), FD));
4134  }
4135  break;
4136  }
4137 
4139  // FIXME: Also do this when merging redecls.
4140  QualType DeducedResultType = Record.readType();
4141  for (auto *Redecl : merged_redecls(D)) {
4142  // FIXME: If the return type is already deduced, check that it matches.
4143  FunctionDecl *FD = cast<FunctionDecl>(Redecl);
4145  DeducedResultType);
4146  }
4147  break;
4148  }
4149 
4150  case UPD_DECL_MARKED_USED: {
4151  // Maintain AST consistency: any later redeclarations are used too.
4152  D->markUsed(Reader.getContext());
4153  break;
4154  }
4155 
4156  case UPD_MANGLING_NUMBER:
4157  Reader.getContext().setManglingNumber(cast<NamedDecl>(D),
4158  Record.readInt());
4159  break;
4160 
4162  Reader.getContext().setStaticLocalNumber(cast<VarDecl>(D),
4163  Record.readInt());
4164  break;
4165 
4167  D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(Reader.getContext(),
4168  ReadSourceRange()));
4169  break;
4170 
4171  case UPD_DECL_EXPORTED: {
4172  unsigned SubmoduleID = readSubmoduleID();
4173  auto *Exported = cast<NamedDecl>(D);
4174  if (auto *TD = dyn_cast<TagDecl>(Exported))
4175  Exported = TD->getDefinition();
4176  Module *Owner = SubmoduleID ? Reader.getSubmodule(SubmoduleID) : nullptr;
4177  if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
4178  Reader.getContext().mergeDefinitionIntoModule(cast<NamedDecl>(Exported),
4179  Owner);
4180  Reader.PendingMergedDefinitionsToDeduplicate.insert(
4181  cast<NamedDecl>(Exported));
4182  } else if (Owner && Owner->NameVisibility != Module::AllVisible) {
4183  // If Owner is made visible at some later point, make this declaration
4184  // visible too.
4185  Reader.HiddenNamesMap[Owner].push_back(Exported);
4186  } else {
4187  // The declaration is now visible.
4188  Exported->setVisibleDespiteOwningModule();
4189  }
4190  break;
4191  }
4192 
4195  AttrVec Attrs;
4196  Record.readAttributes(Attrs);
4197  assert(Attrs.size() == 1);
4198  D->addAttr(Attrs[0]);
4199  break;
4200  }
4201  }
4202 }
const uint64_t & readInt()
Returns the current value in this record, and advances to the next value.
Definition: ASTReader.h:2304
RedeclarableResult VisitTypedefNameDecl(TypedefNameDecl *TD)
void VisitTypeDecl(TypeDecl *TD)
void setCategoryNameLoc(SourceLocation Loc)
Definition: DeclObjC.h:2312
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1163
Defines the clang::ASTContext interface.
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1181
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1467
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:1761
bool hasPendingBody() const
Determine whether this declaration has a pending body.
void VisitClassScopeFunctionSpecializationDecl(ClassScopeFunctionSpecializationDecl *D)
static const Decl * getCanonicalDecl(const Decl *D)
void setImplicit(bool I=true)
Definition: DeclBase.h:538
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1618
iterator begin() const
Definition: DeclBase.h:1182
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
Definition: DeclBase.h:1906
void VisitVarDecl(VarDecl *VD)
#define MATCH_FIELD(Field)
void setAnonymousStructOrUnion(bool Anon)
Definition: Decl.h:3422
A class which contains all the information about a particular captured value.
Definition: Decl.h:3561
static ImportDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
Definition: Decl.cpp:4436
void VisitImportDecl(ImportDecl *D)
A (possibly-)qualified type.
Definition: Type.h:616
void mergeMergeable(Mergeable< T > *D)
Attempts to merge the given declaration (D) with another declaration of the same entity, for the case where the entity is not actually redeclarable.
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1735
FunctionDecl * Function
The function template specialization that this structure describes.
Definition: DeclTemplate.h:517
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
void VisitUsingDecl(UsingDecl *D)
static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2436
static VarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:1865
void setLParenLoc(SourceLocation L)
Definition: DeclObjC.h:784
bool tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name)
Try to add the given declaration to the top level scope, if it (or a redeclaration of it) hasn't alre...
void VisitFieldDecl(FieldDecl *FD)
void VisitImplicitParamDecl(ImplicitParamDecl *PD)
This declaration has an owning module, but is only visible to lookups that occur within that module...
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1206
void VisitObjCIvarDecl(ObjCIvarDecl *D)
#define OR_FIELD(Field)
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
bool isParameterPack() const
Returns whether this is a parameter pack.
static void setNextObjCCategory(ObjCCategoryDecl *Cat, ObjCCategoryDecl *Next)
bool IsICE
Whether this statement is an integral constant expression, or in C++11, whether the statement is a co...
Definition: Decl.h:750
RedeclarableResult VisitClassTemplateSpecializationDeclImpl(ClassTemplateSpecializationDecl *D)
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Definition: Decl.h:2554
void setEmbeddedInDeclarator(bool isInDeclarator)
Definition: Decl.h:2978
No linkage, which means that the entity is unique and can only be referred to from within its scope...
Definition: Linkage.h:28
unsigned Generation
The generation of which this module file is a part.
Definition: Module.h:164
static AccessSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:34
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Definition: Decl.h:2770
void setParam(unsigned i, ImplicitParamDecl *P)
Definition: Decl.h:3771
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1218
void VisitEnumConstantDecl(EnumConstantDecl *ECD)
static PragmaCommentDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned ArgSize)
Definition: Decl.cpp:4084
for(unsigned I=0, E=TL.getNumArgs();I!=E;++I)
static void attachLatestDeclImpl(Redeclarable< DeclT > *D, Decl *Latest)
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTReader.cpp:8212
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
Definition: Decl.cpp:3178
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
static NamedDecl * getDeclForMerging(NamedDecl *Found, bool IsTypedefNameForLinkage)
Find the declaration that should be merged into, given the declaration found by name lookup...
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1175
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
static Decl * getMostRecentDecl(Decl *D)
unsigned getODRHash() const
Definition: DeclCXX.cpp:390
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Definition: DeclBase.h:922
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
Definition: Decl.h:3331
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
A record that stores the set of declarations that are lexically stored within a given DeclContext...
Definition: ASTBitCodes.h:1110
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
Represents an empty-declaration.
Definition: Decl.h:3938
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:63
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
Definition: Module.h:420
Class that performs name lookup into a DeclContext stored in an AST file.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2497
Declaration of a variable template.
const Expr * getInit() const
Definition: Decl.h:1146
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:461
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1079
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
void setPropertyImplementation(PropertyControl pc)
Definition: DeclObjC.h:882
static bool hasSameOverloadableAttrs(const FunctionDecl *A, const FunctionDecl *B)
Determine whether the attributes we can overload on are identical for A and B.
NamedDecl * getParam(unsigned Idx)
Definition: DeclTemplate.h:112
static FriendDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned FriendTypeNumTPLists)
Definition: DeclFriend.cpp:58
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:94
A container of type source information.
Definition: Decl.h:62
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
Definition: Module.h:174
void setPropertyAccessor(bool isAccessor)
Definition: DeclObjC.h:424
static void inheritDefaultTemplateArguments(ASTContext &Context, TemplateDecl *From, TemplateDecl *To)
ASTDeclReader(ASTReader &Reader, ASTRecordReader &Record, ASTReader::RecordLocation Loc, DeclID thisDeclID, SourceLocation ThisDeclLoc)
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:26
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2329
static CapturedDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumParams)
Definition: Decl.cpp:4217
Represents a #pragma comment line.
Definition: Decl.h:109
A ClassTemplateDecl record.
Definition: ASTBitCodes.h:1165
void VisitStaticAssertDecl(StaticAssertDecl *D)
A PragmaDetectMismatchDecl record.
Definition: ASTBitCodes.h:1216
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1138
An identifier, stored as an IdentifierInfo*.
void setNothrow(bool Nothrow=true)
Definition: Decl.cpp:4227
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:544
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:40
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:758
void VisitNamedDecl(NamedDecl *ND)
Declaration of a redeclarable template.
Definition: DeclTemplate.h:724
An OMPCapturedExprDecl record.
Definition: ASTBitCodes.h:1212
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1130
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
Definition: ASTBitCodes.h:1031
The "__interface" keyword.
Definition: Type.h:4492
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
Definition: ASTBitCodes.h:1199
A namespace, stored as a NamespaceDecl*.
void VisitClassTemplateDecl(ClassTemplateDecl *D)
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
Definition: Decl.cpp:4022
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:50
void setSelfDecl(ImplicitParamDecl *SD)
Definition: DeclObjC.h:409
void VisitTypeAliasDecl(TypeAliasDecl *TD)
unsigned IsExplicitSpecified
Definition: Decl.h:1646
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1183
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1434
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Definition: Linkage.h:25
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:1063
void setHasExternalVisibleStorage(bool ES=true)
State whether this DeclContext has external storage for declarations visible in this context...
Definition: DeclBase.h:1854
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3032
RedeclarableResult VisitTagDecl(TagDecl *TD)
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
Definition: Decl.cpp:2181
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Definition: DeclCXX.cpp:1377
static void attachPreviousDeclImpl(ASTReader &Reader, Redeclarable< DeclT > *D, Decl *Previous, Decl *Canon)
Types, declared with 'struct foo', typedefs, etc.
Definition: DeclBase.h:125
A CXXConstructorDecl record for an inherited constructor.
Definition: ASTBitCodes.h:1152
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3354
Description of a constructor that was inherited from a base class.
Definition: DeclCXX.h:2303
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:80
ObjCProtocolDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C protocol.
Definition: DeclObjC.h:2154
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
void setIntegerType(QualType T)
Set the underlying integer type.
Definition: Decl.h:3235
void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D)
void mergeRedeclarable(Redeclarable< T > *D, RedeclarableResult &Redecl, DeclID TemplatePatternID=0)
Attempts to merge the given declaration (D) with another declaration of the same entity.
static OMPThreadPrivateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Definition: DeclOpenMP.cpp:41
void setManglingNumber(const NamedDecl *ND, unsigned Number)
void setCompleteDefinition(bool V)
Definition: Decl.h:3009
void setUninstantiatedDefaultArg(Expr *arg)
Definition: Decl.cpp:2510
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4263
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1146
bool CheckedICE
Whether we already checked whether this statement was an integral constant expression.
Definition: Decl.h:741
void VisitFriendTemplateDecl(FriendTemplateDecl *D)
void setLanguage(LanguageIDs L)
Set the language specified by this linkage specification.
Definition: DeclCXX.h:2709
Common * getCommonPtr() const
LambdaCaptureKind
The different capture forms in a lambda introducer.
Definition: Lambda.h:34
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2366
void setBlockMissingReturnType(bool val)
Definition: Decl.h:3689
void setLocStart(SourceLocation L)
Definition: Decl.h:443
static CXXRecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:134
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
Definition: DeclBase.h:751
RedeclarableResult VisitVarTemplateSpecializationDeclImpl(VarTemplateSpecializationDecl *D)
TODO: Unify with ClassTemplateSpecializationDecl version? May require unifying ClassTemplate(Partial)...
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Definition: ASTMatchers.h:281
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:1984
Helper class that saves the current stream position and then restores it when destroyed.
Definition: ASTReader.h:2556
bool isTranslationUnit() const
Definition: DeclBase.h:1364
TagKind getTagKind() const
Definition: Decl.h:3019
static NamespaceDecl * getNamespace(const NestedNameSpecifier *X)
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2103
void setOwningModuleID(unsigned ID)
Set the owning module ID.
Definition: DeclBase.h:613
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD)
This declaration is definitely a definition.
Definition: Decl.h:1078
unsigned FromASTFile
Whether this declaration was loaded from an AST file.
Definition: DeclBase.h:307
void Profile(llvm::FoldingSetNodeID &ID)
Definition: DeclTemplate.h:578
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition: CharUnits.h:208
void setNumPositiveBits(unsigned Num)
Definition: Decl.h:3255
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:103
void setReturnType(QualType T)
Definition: DeclObjC.h:331
Declaration of a function specialization at template class scope.
static StaticAssertDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2484
void VisitLabelDecl(LabelDecl *LD)
static NamespaceDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2236
void setDeclImplementation(ImplementationControl ic)
Definition: DeclObjC.h:462
Describes a module or submodule.
Definition: Module.h:57
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:947
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1193
static OMPCapturedExprDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclOpenMP.cpp:98
iterator end()
end - Returns an iterator that has 'finished'.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:494
Represents a C++ using-declaration.
Definition: DeclCXX.h:3183
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
Definition: DeclCXX.h:3216
bool isInheritingConstructor() const
Determine whether this is an implicit constructor synthesized to model a call to a constructor inheri...
Definition: DeclCXX.h:2517
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:160
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
static llvm::iterator_range< MergedRedeclIterator< DeclT > > merged_redecls(DeclT *D)
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:919
void setAccessControl(AccessControl ac)
Definition: DeclObjC.h:1903
const LangOptions & getLangOpts() const
Definition: ASTContext.h:659
static void attachLatestDecl(Decl *D, Decl *latest)
< Capturing the *this object by copy
Definition: Lambda.h:37
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:516
RedeclarableResult VisitVarDeclImpl(VarDecl *D)
DeclLink RedeclLink
Points to the next redeclaration in the chain.
Definition: Redeclarable.h:184
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1158
void setAtLoc(SourceLocation L)
Definition: DeclObjC.h:781
A convenient class for passing around template argument information.
Definition: TemplateBase.h:524
uint32_t Offset
Definition: CacheTokens.cpp:43
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1132
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1134
void ReadFunctionDefinition(FunctionDecl *FD)
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2466
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
void VisitCXXRecordDecl(CXXRecordDecl *D)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setSuperClass(ObjCInterfaceDecl *superCls)
Definition: DeclObjC.h:2581
A DecompositionDecl record.
Definition: ASTBitCodes.h:1093
TypeDecl - Represents a declaration of a type.
Definition: Decl.h:2642
void setHasObjectMember(bool val)
Definition: Decl.h:3427
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
Definition: DeclObjC.cpp:1384
void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D)
void VisitMSPropertyDecl(MSPropertyDecl *FD)
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2012
void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Definition: ASTReader.h:2211
DeclID VisitTemplateDecl(TemplateDecl *D)
SourceRange readSourceRange()
Read a source range, advancing Idx.
Definition: ASTReader.h:2500
void setClassInterface(ObjCInterfaceDecl *D)
Definition: DeclObjC.h:2634
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:671
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4367
void VisitCXXMethodDecl(CXXMethodDecl *D)
static TypeAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4337
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1167
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:1985
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
Definition: DeclBase.h:796
void setNumNegativeBits(unsigned Num)
Definition: Decl.h:3272
static bool isSameEntity(NamedDecl *X, NamedDecl *Y)
Determine whether the two declarations refer to the same entity.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI)
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3726
Represents an ObjC class declaration.
Definition: DeclObjC.h:1108
Represents a linkage specification.
Definition: DeclCXX.h:2666
static ParmVarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:2452
void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D)
detail::InMemoryDirectory::const_iterator I
A binding in a decomposition declaration.
Definition: DeclCXX.h:3624
void setInitVal(const llvm::APSInt &V)
Definition: Decl.h:2576
known_categories_range known_categories() const
Definition: DeclObjC.h:1610
QualType getCanonicalTypeInternal() const
Definition: Type.h:2045
Ordinary names.
Definition: DeclBase.h:139
QualType getType() const
Definition: Decl.h:589
void setInitExpr(Expr *E)
Definition: Decl.h:2575
void setLocStart(SourceLocation L)
Definition: Decl.h:2667
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:841
void setGetterCXXConstructor(Expr *getterCXXConstructor)
Definition: DeclObjC.h:2736
CXXConstructorDecl * getConstructor() const
Definition: DeclCXX.h:2316
void setInline(bool Inline)
Set whether this is an inline namespace declaration.
Definition: Decl.h:521
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
Definition: DeclBase.cpp:180
static CXXDeductionGuideDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:1543
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2645
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
Definition: DeclTemplate.h:948
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
void setVariadic(bool isVar)
Definition: DeclObjC.h:419
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2790
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3129
RedeclarableResult VisitRedeclarable(Redeclarable< T > *D)
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Definition: Type.h:3371
void setHasDestructors(bool val)
Definition: DeclObjC.h:2548
void VisitObjCContainerDecl(ObjCContainerDecl *D)
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2169
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
CXXDestructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:2580
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:636
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1146
void VisitParmVarDecl(ParmVarDecl *PD)
ASTContext * Context
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
Definition: Decl.cpp:2392
void setIvarRBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2585
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1187
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1173
void VisitUsingPackDecl(UsingPackDecl *D)
void VisitUsingShadowDecl(UsingShadowDecl *D)
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
TODO: Unify with ClassTemplatePartialSpecializationDecl version? May require unifying ClassTemplate(P...
void setNextIvar(ObjCIvarDecl *ivar)
Definition: DeclObjC.h:1901
void setSynthesize(bool synth)
Definition: DeclObjC.h:1911
void VisitFriendDecl(FriendDecl *D)
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1210
void VisitDecl(Decl *D)
A record containing CXXBaseSpecifiers.
Definition: ASTBitCodes.h:1189
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
void setType(QualType T, TypeSourceInfo *TSI)
Definition: DeclObjC.h:790
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition: DeclCXX.h:2520
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
Definition: DeclObjC.h:876
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3070
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3557
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:580
Expr - This represents one expression.
Definition: Expr.h:105
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1073
void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *GD)
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
static LinkageSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2180
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1081
StateNode * Previous
Declaration of a template type parameter.
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
Definition: DeclObjC.h:879
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2551
void setInit(Expr *I)
Definition: Decl.cpp:2142
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Definition: DeclBase.cpp:111
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:956
A CXXConstructorDecl record.
Definition: ASTBitCodes.h:1150
void VisitTypedefDecl(TypedefDecl *TD)
void setContextParam(unsigned i, ImplicitParamDecl *P)
Definition: Decl.h:3789
void setAtEndRange(SourceRange atEnd)
Definition: DeclObjC.h:1060
void setRBraceLoc(SourceLocation L)
Definition: DeclCXX.h:2721
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:937
Kind getKind() const
Definition: DeclBase.h:410
static DeclLink PreviousDeclLink(decl_type *D)
Definition: Redeclarable.h:165
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:216
DeclContext * getDeclContext()
Definition: DeclBase.h:416
A record containing CXXCtorInitializers.
Definition: ASTBitCodes.h:1191
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1171
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
void setMemberSpecialization()
Note that this member template is a specialization.
Definition: DeclTemplate.h:854
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
void setDefined(bool isDefined)
Definition: DeclObjC.h:427
void setCompleteDefinitionRequired(bool V=true)
Definition: Decl.h:3011
RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D)
Information about a module that has been loaded by the ASTReader.
Definition: Module.h:100
A namespace alias, stored as a NamespaceAliasDecl*.
static void attachPreviousDecl(ASTReader &Reader, Decl *D, Decl *Previous, Decl *Canon)
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1154
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
Definition: Module.h:424
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Definition: ASTBitCodes.h:1196
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2294
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool InheritsConstructor)
Definition: DeclCXX.cpp:1967
StorageClass
Storage classes.
Definition: Specifiers.h:202
static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody)
Determine whether the consumer will be interested in seeing this declaration (via HandleTopLevelDecl)...
PragmaMSCommentKind
Definition: PragmaKinds.h:15
bool isFunctionOrMethod() const
Definition: DeclBase.h:1343
This declaration has an owning module, and is visible when that module is imported.
A NamespaceAliasDecl record.
Definition: ASTBitCodes.h:1124
void setTypename(bool TN)
Sets whether the using declaration has 'typename'.
Definition: DeclCXX.h:3238
Declaration of an alias template.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
Definition: DeclBase.h:707
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:681
unsigned IsScopedUsingClassTag
IsScopedUsingClassTag - If this tag declaration is a scoped enum, then this is true if the scoped enu...
Definition: Decl.h:2857
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
Definition: Decl.h:2735
void setLocation(SourceLocation L)
Definition: DeclBase.h:408
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:258
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1089
void setIvarRBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2316
void VisitDecompositionDecl(DecompositionDecl *DD)
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition: Decl.cpp:1076
Represents a C++ deduction guide declaration.
Definition: DeclCXX.h:1857
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2605
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2201
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1057
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, unsigned ID)
Definition: DeclObjC.cpp:1349
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1204
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1071
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
Definition: DeclBase.cpp:264
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:771
static void AddLazySpecializations(T *D, SmallVectorImpl< serialization::DeclID > &IDs)
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:209
void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
void VisitObjCProtocolDecl(ObjCProtocolDecl *D)
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:1077
void VisitPragmaCommentDecl(PragmaCommentDecl *D)
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
Definition: ASTReader.cpp:3664
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
void setIsVariadic(bool value)
Definition: Decl.h:3634
void addAttr(Attr *A)
Definition: DeclBase.h:472
static bool isSameQualifier(const NestedNameSpecifier *X, const NestedNameSpecifier *Y)
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize)
Definition: Decl.cpp:4110
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:3894
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
Definition: Decl.h:603
void setColonLoc(SourceLocation CLoc)
Sets the location of the colon.
Definition: DeclCXX.h:124
An UnresolvedUsingValueDecl record.
Definition: ASTBitCodes.h:1136
Representation::iterator iterator
#define false
Definition: stdbool.h:33
The "struct" keyword.
Definition: Type.h:4490
void VisitDeclaratorDecl(DeclaratorDecl *DD)
static ObjCProtocolDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1818
static EnumConstantDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4237
Kind
static UsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2319
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:197
void setIsConversionFromLambda(bool val)
Definition: Decl.h:3692
SmallVectorImpl< AnnotatedLine * >::const_iterator Next
static void markIncompleteDeclChainImpl(Redeclarable< DeclT > *D)
static CXXDestructorDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2111
Encodes a location in the source.
static EmptyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4379
void setTopLevelDeclInObjCContainer(bool V=true)
Definition: DeclBase.h:576
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
Definition: ASTContext.h:1014
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
Definition: DeclBase.h:762
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:102
A record that stores the set of declarations that are visible from a given DeclContext.
Definition: ASTBitCodes.h:1118
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:171
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2314
void setBraceRange(SourceRange R)
Definition: Decl.h:2936
void setAtStartLoc(SourceLocation Loc)
Definition: DeclObjC.h:1054
void VisitEmptyDecl(EmptyDecl *D)
void setAnonymousNamespace(NamespaceDecl *D)
Definition: Decl.h:542
NameVisibilityKind NameVisibility
The visibility of names within this particular module.
Definition: Module.h:252
void setFreeStanding(bool isFreeStanding=true)
Definition: Decl.h:2983
const std::string ID
void setObjCDeclQualifier(ObjCDeclQualifier QV)
Definition: DeclObjC.h:272
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2816
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:346
static DecompositionDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumBindings)
Definition: DeclCXX.cpp:2527
void setReferenced(bool R=true)
Definition: DeclBase.h:567
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:414
void mergeTemplatePattern(RedeclarableTemplateDecl *D, RedeclarableTemplateDecl *Existing, DeclID DsID, bool IsKeyDecl)
Merge together the pattern declarations from two template declarations.
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal)
Definition: DeclObjC.h:813
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3400
void setPosition(unsigned P)
void VisitObjCImplDecl(ObjCImplDecl *D)
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
Definition: ASTReader.cpp:6971
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1903
void setHasFlexibleArrayMember(bool V)
Definition: Decl.h:3407
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.h:3149
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void VisitBindingDecl(BindingDecl *BD)
A TemplateTypeParmDecl record.
Definition: ASTBitCodes.h:1179
void demoteThisDefinitionToDeclaration()
This is a definition which should be demoted to a declaration.
Definition: Decl.h:1224
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:943
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2189
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
void addDecl(NamedDecl *D)
Definition: UnresolvedSet.h:83
void setDeclName(DeclarationName N)
Set the name of this declaration.
Definition: Decl.h:261
void setCachedLinkage(Linkage L) const
Definition: DeclBase.h:386
static MSPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2563
static ConstructorUsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2342
Describes the categories of an Objective-C class.
Definition: ASTBitCodes.h:1608
void init(NamedDecl *templatedDecl, TemplateParameterList *templateParams)
Initialize the underlying templated declaration and template parameters.
Definition: DeclTemplate.h:483
void setPointOfInstantiation(SourceLocation Loc)
void setTagKind(TagKind TK)
Definition: Decl.h:3023
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
Definition: DeclTemplate.h:798
static FunctionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4193
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:704
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
Definition: DeclObjC.h:2251
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:67
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
Definition: ASTBitCodes.h:1035
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
void VisitRecordDecl(RecordDecl *RD)
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1507
static T assert_cast(T t)
"Cast" to type T, asserting if we don't have an implicit conversion.
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
A NamespaceDecl record.
Definition: ASTBitCodes.h:1122
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3576
uint32_t BitOffset
Offset in the AST file.
Definition: ASTBitCodes.h:191
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:543
void VisitExportDecl(ExportDecl *D)
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:564
unsigned varlist_size() const
Definition: DeclOpenMP.h:74
File is a PCH file treated as the actual main file.
Definition: Module.h:52
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:3829
void VisitValueDecl(ValueDecl *VD)
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1065
void setDeclaredWithTypename(bool withTypename)
Set whether this template type parameter was declared with the 'typename' or 'class' keyword...
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void setSetterCXXAssignment(Expr *setterCXXAssignment)
Definition: DeclObjC.h:2743
void VisitEnumDecl(EnumDecl *ED)
static TypedefDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4325
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2682
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
void setPropertyDecl(ObjCPropertyDecl *Prop)
Definition: DeclObjC.h:2705
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1156
TagTypeKind
The kind of a tag type.
Definition: Type.h:4488
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
ObjCTypeParamList * ReadObjCTypeParamList()
void VisitCXXConversionDecl(CXXConversionDecl *D)
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
Definition: Decl.h:2808
void setBody(CompoundStmt *B)
Definition: Decl.h:3638
void setImplicitlyInline()
Flag that this function is implicitly inline.
Definition: Decl.h:2149
static CXXConversionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2142
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
Definition: Module.h:387
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
static bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y)
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
void setHasVolatileMember(bool val)
Definition: Decl.h:3430
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
Definition: DeclObjC.h:863
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1215
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
StringRef Name
Definition: USRFinder.cpp:123
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:378
void VisitFunctionDecl(FunctionDecl *FD)
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:847
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:328
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Definition: Decl.h:2594
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1169
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
Definition: DeclCXX.h:3433
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1047
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
unsigned IsScoped
IsScoped - True if this tag declaration is a scoped enumeration.
Definition: Decl.h:2852
A decomposition declaration.
Definition: DeclCXX.h:3672
RedeclarableResult VisitCXXRecordDeclImpl(CXXRecordDecl *D)
void setIvarList(ObjCIvarDecl *ivar)
Definition: DeclObjC.h:1410
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
Definition: DeclBase.h:110
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3497
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
Definition: ASTBitCodes.h:1202
DeclarationName - The name of a declaration.
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:537
void VisitObjCMethodDecl(ObjCMethodDecl *D)
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
Definition: Decl.cpp:3355
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
Definition: Decl.cpp:1969
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1140
RedeclarableResult VisitRecordDeclImpl(RecordDecl *RD)
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ParmVarDeclBitfields ParmVarDeclBits
Definition: Decl.h:907
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1967
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
EnumDecl - Represents an enum.
Definition: Decl.h:3102
bool hasAttrs() const
Definition: DeclBase.h:462
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
detail::InMemoryDirectory::const_iterator E
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:142
static void forAllLaterRedecls(DeclT *D, Fn F)
void setExternLoc(SourceLocation L)
Definition: DeclCXX.h:2720
static bool inheritDefaultTemplateArgument(ASTContext &Context, ParmDecl *From, Decl *ToD)
Inherit the default template argument from From to To.
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
Definition: DeclBase.h:120
A type that was preceded by the 'template' keyword, stored as a Type*.
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static LabelDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4137
All of the names in this module are visible.
Definition: Module.h:248
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
Definition: DeclBase.h:1004
Capturing variable-length array type.
Definition: Lambda.h:39
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1214
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1783
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2448
Common * getCommonPtr() const
Definition: DeclTemplate.h:975
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
Definition: Redeclarable.h:310
static ExportDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4469
NonParmVarDeclBitfields NonParmVarDeclBits
Definition: Decl.h:908
void UpdateDecl(Decl *D, llvm::SmallVectorImpl< serialization::DeclID > &)
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:6042
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
Definition: DeclTemplate.h:900
void setHasNonZeroConstructors(bool val)
Definition: DeclObjC.h:2543
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
LanguageIDs
Represents the language in a linkage specification.
Definition: DeclCXX.h:2675
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4173
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Definition: ASTContext.h:1281
static RecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: Decl.cpp:3885
void setCombiner(Expr *E)
Set combiner expression for the declare reduction construct.
Definition: DeclOpenMP.h:139
void setInitializer(Expr *E)
Set initializer expression for the declare reduction construct.
Definition: DeclOpenMP.h:146
static CXXMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:1628
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:824
static EnumDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:3770
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1634
void VisitNamespaceDecl(NamespaceDecl *D)
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
Definition: DeclObjC.h:1832
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
Definition: DeclObjC.h:870
The "class" keyword.
Definition: Type.h:4496
Capturing the *this object by reference.
Definition: Lambda.h:35
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
Definition: DeclBase.cpp:382
void setInnerLocStart(SourceLocation L)
Definition: Decl.h:676
void setObjCMethodScopeInfo(unsigned parameterIndex)
Definition: Decl.h:1462
void setSignatureAsWritten(TypeSourceInfo *Sig)
Definition: Decl.h:3640
void setPromotionType(QualType T)
Set the promotion type.
Definition: Decl.h:3221
static bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y)
Determine whether two template parameters are similar enough that they may be used in declarations of...
unsigned IsFixed
IsFixed - True if this is an enumeration with fixed underlying type.
Definition: Decl.h:2861
void setAsmString(StringLiteral *Asm)
Definition: Decl.h:3547
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setRParenLoc(SourceLocation L)
Definition: Decl.h:3540
A template argument list.
Definition: DeclTemplate.h:195
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
Definition: ASTContext.cpp:888
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:13074
static FieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:3583
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void VisitCapturedDecl(CapturedDecl *CD)
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:1933
static Decl * getMostRecentDeclImpl(Redeclarable< DeclT > *D)
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:431
FormatToken * Current
Represents a C++ struct/union/class.
Definition: DeclCXX.h:267
static OMPDeclareReductionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create deserialized declare reduction node.
Definition: DeclOpenMP.cpp:70
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2125
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition: DeclBase.h:190
void setDescribedVarTemplate(VarTemplateDecl *Template)
Definition: Decl.cpp:2388
void setInstanceMethod(bool isInst)
Definition: DeclObjC.h:417
void SetRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
Definition: DeclObjC.h:279
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
Definition: DeclBase.h:505
void setClassInterface(ObjCInterfaceDecl *IFace)
Definition: DeclObjC.cpp:2035
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1866
bool operator!=(CanQual< T > x, CanQual< U > y)
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:326
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:595
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:1075
Capturing by reference.
Definition: Lambda.h:38
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source...
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
void setReturnTypeSourceInfo(TypeSourceInfo *TInfo)
Definition: DeclObjC.h:345
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1069
Declaration of a class template.
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2583
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:615
void VisitAccessSpecDecl(AccessSpecDecl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:410
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
void setPropertyAttributes(PropertyAttributeKind PRVal)
Definition: DeclObjC.h:802
static BlockDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4203
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
Definition: ASTBitCodes.h:1039
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1051
void VisitClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl *D)
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U)
Determine whether two function types are the same, ignoring exception specifications in cases where t...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Definition: DeclBase.h:1414
An object for streaming information from a record.
Definition: ASTReader.h:2266
void VisitBlockDecl(BlockDecl *BD)
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
Definition: Decl.cpp:3197
An ExportDecl record.
Definition: ASTBitCodes.h:1142
void VisitIndirectFieldDecl(IndirectFieldDecl *FD)
bool isIncompleteArrayType() const
Definition: Type.h:5757
Common * getCommonPtr() const
VarDeclBitfields VarDeclBits
Definition: Decl.h:906
static UsingPackDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions)
Definition: DeclCXX.cpp:2411
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
virtual CommonBase * newCommon(ASTContext &C) const =0
TranslationUnitDecl - The top declaration context.
Definition: Decl.h:80
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1422
void ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs)
Reads attributes from the current stream position.
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D)
QualType getElementType() const
Definition: Type.h:2531
SourceLocation getLocation() const
Definition: ASTBitCodes.h:200
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1177
std::pair< uint64_t, uint64_t > VisitDeclContext(DeclContext *DC)
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2220
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Definition: ASTReader.cpp:6981
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1185
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3741
void setAtLoc(SourceLocation Loc)
Definition: DeclObjC.h:2700
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
uint32_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:80
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
Definition: Decl.cpp:4033
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:192
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
Definition: DeclBase.h:407
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
Definition: Decl.h:3238
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
void VisitVarTemplateDecl(VarTemplateDecl *D)
TODO: Unify with ClassTemplateDecl version? May require unifying ClassTemplateDecl and VarTemplateDec...
void setTypeSourceInfo(TypeSourceInfo *newType)
Definition: Decl.h:2732
void setAccess(AccessSpecifier AS)
Definition: DeclBase.h:446
void numberAnonymousDeclsWithin(const DeclContext *DC, Fn Visit)
Visit each declaration within DC that needs an anonymous declaration number and call Visit with the d...
Definition: ASTCommon.h:95
Represents a C++ namespace alias.
Definition: DeclCXX.h:2861
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
static UsingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2390
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
Definition: ASTReader.cpp:7110
Declaration of a friend template.
Represents C++ using-directive.
Definition: DeclCXX.h:2758
Represents a #pragma detect_mismatch line.
Definition: Decl.h:143
static ObjCPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2192
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
Definition: DeclTemplate.h:640
The global specifier '::'. There is no stored value.
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
Definition: ASTReader.cpp:8862
void VisitTranslationUnitDecl(TranslationUnitDecl *TU)
static BindingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2497
void setType(QualType newType)
Definition: Decl.h:590
void setCmdDecl(ImplicitParamDecl *CD)
Definition: DeclObjC.h:411
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:39
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2396
Declaration of a template function.
Definition: DeclTemplate.h:939
iterator - Iterate over the decls of a specified declaration name.
void setTargetDecl(NamedDecl *ND)
Sets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3036
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
Definition: DeclObjC.h:892
Source range/offset of a preprocessed entity.
Definition: ASTBitCodes.h:187
const NamedDecl * Result
Definition: USRFinder.cpp:70
Attr - This represents one attribute.
Definition: Attr.h:43
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID...
Definition: Module.h:417
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:2978
Represents a pack of using declarations that a single using-declarator pack-expanded into...
Definition: DeclCXX.h:3331
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2616
Structure used to store a statement, the constant value to which it was evaluated (if any)...
Definition: Decl.h:729
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
TemplatedKind
The kind of templated function a FunctionDecl can be.
Definition: Decl.h:1622