clang  15.0.0git
ASTReaderDecl.cpp
Go to the documentation of this file.
1 //===- ASTReaderDecl.cpp - Decl Deserialization ---------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the ASTReader::readDeclRecord method, which is the
10 // entrypoint for loading a decl.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "ASTCommon.h"
15 #include "ASTReaderInternals.h"
16 #include "clang/AST/ASTContext.h"
17 #include "clang/AST/Attr.h"
18 #include "clang/AST/AttrIterator.h"
19 #include "clang/AST/Decl.h"
20 #include "clang/AST/DeclBase.h"
21 #include "clang/AST/DeclCXX.h"
22 #include "clang/AST/DeclFriend.h"
23 #include "clang/AST/DeclObjC.h"
24 #include "clang/AST/DeclOpenMP.h"
25 #include "clang/AST/DeclTemplate.h"
26 #include "clang/AST/DeclVisitor.h"
28 #include "clang/AST/Expr.h"
32 #include "clang/AST/OpenMPClause.h"
33 #include "clang/AST/Redeclarable.h"
34 #include "clang/AST/Stmt.h"
35 #include "clang/AST/TemplateBase.h"
36 #include "clang/AST/Type.h"
38 #include "clang/Basic/AttrKinds.h"
42 #include "clang/Basic/LLVM.h"
43 #include "clang/Basic/Lambda.h"
45 #include "clang/Basic/Linkage.h"
46 #include "clang/Basic/Module.h"
49 #include "clang/Basic/Specifiers.h"
55 #include "llvm/ADT/DenseMap.h"
56 #include "llvm/ADT/FoldingSet.h"
57 #include "llvm/ADT/STLExtras.h"
58 #include "llvm/ADT/SmallPtrSet.h"
59 #include "llvm/ADT/SmallVector.h"
60 #include "llvm/ADT/iterator_range.h"
61 #include "llvm/Bitstream/BitstreamReader.h"
62 #include "llvm/Support/Casting.h"
63 #include "llvm/Support/ErrorHandling.h"
64 #include "llvm/Support/SaveAndRestore.h"
65 #include <algorithm>
66 #include <cassert>
67 #include <cstdint>
68 #include <cstring>
69 #include <string>
70 #include <utility>
71 
72 using namespace clang;
73 using namespace serialization;
74 
75 //===----------------------------------------------------------------------===//
76 // Declaration deserialization
77 //===----------------------------------------------------------------------===//
78 
79 namespace clang {
80 
81  class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> {
82  ASTReader &Reader;
83  ASTRecordReader &Record;
84  ASTReader::RecordLocation Loc;
85  const DeclID ThisDeclID;
86  const SourceLocation ThisDeclLoc;
87 
89 
90  TypeID DeferredTypeID = 0;
91  unsigned AnonymousDeclNumber;
92  GlobalDeclID NamedDeclForTagDecl = 0;
93  IdentifierInfo *TypedefNameForLinkage = nullptr;
94 
95  bool HasPendingBody = false;
96 
97  ///A flag to carry the information for a decl from the entity is
98  /// used. We use it to delay the marking of the canonical decl as used until
99  /// the entire declaration is deserialized and merged.
100  bool IsDeclMarkedUsed = false;
101 
102  uint64_t GetCurrentCursorOffset();
103 
104  uint64_t ReadLocalOffset() {
105  uint64_t LocalOffset = Record.readInt();
106  assert(LocalOffset < Loc.Offset && "offset point after current record");
107  return LocalOffset ? Loc.Offset - LocalOffset : 0;
108  }
109 
110  uint64_t ReadGlobalOffset() {
111  uint64_t Local = ReadLocalOffset();
112  return Local ? Record.getGlobalBitOffset(Local) : 0;
113  }
114 
115  SourceLocation readSourceLocation() {
116  return Record.readSourceLocation();
117  }
118 
119  SourceRange readSourceRange() {
120  return Record.readSourceRange();
121  }
122 
123  TypeSourceInfo *readTypeSourceInfo() {
124  return Record.readTypeSourceInfo();
125  }
126 
127  serialization::DeclID readDeclID() {
128  return Record.readDeclID();
129  }
130 
131  std::string readString() {
132  return Record.readString();
133  }
134 
135  void readDeclIDList(SmallVectorImpl<DeclID> &IDs) {
136  for (unsigned I = 0, Size = Record.readInt(); I != Size; ++I)
137  IDs.push_back(readDeclID());
138  }
139 
140  Decl *readDecl() {
141  return Record.readDecl();
142  }
143 
144  template<typename T>
145  T *readDeclAs() {
146  return Record.readDeclAs<T>();
147  }
148 
149  serialization::SubmoduleID readSubmoduleID() {
150  if (Record.getIdx() == Record.size())
151  return 0;
152 
153  return Record.getGlobalSubmoduleID(Record.readInt());
154  }
155 
156  Module *readModule() {
157  return Record.getSubmodule(readSubmoduleID());
158  }
159 
160  void ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update);
161  void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data,
162  const CXXRecordDecl *D);
163  void MergeDefinitionData(CXXRecordDecl *D,
164  struct CXXRecordDecl::DefinitionData &&NewDD);
165  void ReadObjCDefinitionData(struct ObjCInterfaceDecl::DefinitionData &Data);
166  void MergeDefinitionData(ObjCInterfaceDecl *D,
167  struct ObjCInterfaceDecl::DefinitionData &&NewDD);
168  void ReadObjCDefinitionData(struct ObjCProtocolDecl::DefinitionData &Data);
169  void MergeDefinitionData(ObjCProtocolDecl *D,
170  struct ObjCProtocolDecl::DefinitionData &&NewDD);
171 
172  static DeclContext *getPrimaryDCForAnonymousDecl(DeclContext *LexicalDC);
173 
174  static NamedDecl *getAnonymousDeclForMerging(ASTReader &Reader,
175  DeclContext *DC,
176  unsigned Index);
177  static void setAnonymousDeclForMerging(ASTReader &Reader, DeclContext *DC,
178  unsigned Index, NamedDecl *D);
179 
180  /// Results from loading a RedeclarableDecl.
181  class RedeclarableResult {
182  Decl *MergeWith;
183  GlobalDeclID FirstID;
184  bool IsKeyDecl;
185 
186  public:
187  RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool IsKeyDecl)
188  : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {}
189 
190  /// Retrieve the first ID.
191  GlobalDeclID getFirstID() const { return FirstID; }
192 
193  /// Is this declaration a key declaration?
194  bool isKeyDecl() const { return IsKeyDecl; }
195 
196  /// Get a known declaration that this should be merged with, if
197  /// any.
198  Decl *getKnownMergeTarget() const { return MergeWith; }
199  };
200 
201  /// Class used to capture the result of searching for an existing
202  /// declaration of a specific kind and name, along with the ability
203  /// to update the place where this result was found (the declaration
204  /// chain hanging off an identifier or the DeclContext we searched in)
205  /// if requested.
206  class FindExistingResult {
207  ASTReader &Reader;
208  NamedDecl *New = nullptr;
209  NamedDecl *Existing = nullptr;
210  bool AddResult = false;
211  unsigned AnonymousDeclNumber = 0;
212  IdentifierInfo *TypedefNameForLinkage = nullptr;
213 
214  public:
215  FindExistingResult(ASTReader &Reader) : Reader(Reader) {}
216 
217  FindExistingResult(ASTReader &Reader, NamedDecl *New, NamedDecl *Existing,
218  unsigned AnonymousDeclNumber,
219  IdentifierInfo *TypedefNameForLinkage)
220  : Reader(Reader), New(New), Existing(Existing), AddResult(true),
221  AnonymousDeclNumber(AnonymousDeclNumber),
222  TypedefNameForLinkage(TypedefNameForLinkage) {}
223 
224  FindExistingResult(FindExistingResult &&Other)
225  : Reader(Other.Reader), New(Other.New), Existing(Other.Existing),
226  AddResult(Other.AddResult),
227  AnonymousDeclNumber(Other.AnonymousDeclNumber),
228  TypedefNameForLinkage(Other.TypedefNameForLinkage) {
229  Other.AddResult = false;
230  }
231 
232  FindExistingResult &operator=(FindExistingResult &&) = delete;
233  ~FindExistingResult();
234 
235  /// Suppress the addition of this result into the known set of
236  /// names.
237  void suppress() { AddResult = false; }
238 
239  operator NamedDecl*() const { return Existing; }
240 
241  template<typename T>
242  operator T*() const { return dyn_cast_or_null<T>(Existing); }
243  };
244 
245  static DeclContext *getPrimaryContextForMerging(ASTReader &Reader,
246  DeclContext *DC);
247  FindExistingResult findExisting(NamedDecl *D);
248 
249  public:
251  ASTReader::RecordLocation Loc,
252  DeclID thisDeclID, SourceLocation ThisDeclLoc)
253  : Reader(Reader), Record(Record), Loc(Loc), ThisDeclID(thisDeclID),
254  ThisDeclLoc(ThisDeclLoc) {}
255 
256  template <typename T> static
259  if (IDs.empty())
260  return;
261 
262  // FIXME: We should avoid this pattern of getting the ASTContext.
263  ASTContext &C = D->getASTContext();
264 
265  auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations;
266 
267  if (auto &Old = LazySpecializations) {
268  IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
269  llvm::sort(IDs);
270  IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
271  }
272 
273  auto *Result = new (C) serialization::DeclID[1 + IDs.size()];
274  *Result = IDs.size();
275  std::copy(IDs.begin(), IDs.end(), Result + 1);
276 
277  LazySpecializations = Result;
278  }
279 
280  template <typename DeclT>
281  static Decl *getMostRecentDeclImpl(Redeclarable<DeclT> *D);
282  static Decl *getMostRecentDeclImpl(...);
283  static Decl *getMostRecentDecl(Decl *D);
284 
285  static void mergeInheritableAttributes(ASTReader &Reader, Decl *D,
286  Decl *Previous);
287 
288  template <typename DeclT>
289  static void attachPreviousDeclImpl(ASTReader &Reader,
291  Decl *Canon);
292  static void attachPreviousDeclImpl(ASTReader &Reader, ...);
293  static void attachPreviousDecl(ASTReader &Reader, Decl *D, Decl *Previous,
294  Decl *Canon);
295 
296  template <typename DeclT>
297  static void attachLatestDeclImpl(Redeclarable<DeclT> *D, Decl *Latest);
298  static void attachLatestDeclImpl(...);
299  static void attachLatestDecl(Decl *D, Decl *latest);
300 
301  template <typename DeclT>
302  static void markIncompleteDeclChainImpl(Redeclarable<DeclT> *D);
303  static void markIncompleteDeclChainImpl(...);
304 
305  /// Determine whether this declaration has a pending body.
306  bool hasPendingBody() const { return HasPendingBody; }
307 
308  void ReadFunctionDefinition(FunctionDecl *FD);
309  void Visit(Decl *D);
310 
311  void UpdateDecl(Decl *D, SmallVectorImpl<serialization::DeclID> &);
312 
314  ObjCCategoryDecl *Next) {
315  Cat->NextClassCategory = Next;
316  }
317 
318  void VisitDecl(Decl *D);
319  void VisitPragmaCommentDecl(PragmaCommentDecl *D);
320  void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D);
321  void VisitTranslationUnitDecl(TranslationUnitDecl *TU);
322  void VisitNamedDecl(NamedDecl *ND);
323  void VisitLabelDecl(LabelDecl *LD);
324  void VisitNamespaceDecl(NamespaceDecl *D);
325  void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
326  void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
327  void VisitTypeDecl(TypeDecl *TD);
328  RedeclarableResult VisitTypedefNameDecl(TypedefNameDecl *TD);
329  void VisitTypedefDecl(TypedefDecl *TD);
330  void VisitTypeAliasDecl(TypeAliasDecl *TD);
331  void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
332  void VisitUnresolvedUsingIfExistsDecl(UnresolvedUsingIfExistsDecl *D);
333  RedeclarableResult VisitTagDecl(TagDecl *TD);
334  void VisitEnumDecl(EnumDecl *ED);
335  RedeclarableResult VisitRecordDeclImpl(RecordDecl *RD);
336  void VisitRecordDecl(RecordDecl *RD);
337  RedeclarableResult VisitCXXRecordDeclImpl(CXXRecordDecl *D);
338  void VisitCXXRecordDecl(CXXRecordDecl *D) { VisitCXXRecordDeclImpl(D); }
339  RedeclarableResult VisitClassTemplateSpecializationDeclImpl(
341 
344  VisitClassTemplateSpecializationDeclImpl(D);
345  }
346 
347  void VisitClassTemplatePartialSpecializationDecl(
349  void VisitClassScopeFunctionSpecializationDecl(
351  RedeclarableResult
352  VisitVarTemplateSpecializationDeclImpl(VarTemplateSpecializationDecl *D);
353 
355  VisitVarTemplateSpecializationDeclImpl(D);
356  }
357 
358  void VisitVarTemplatePartialSpecializationDecl(
360  void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
361  void VisitValueDecl(ValueDecl *VD);
362  void VisitEnumConstantDecl(EnumConstantDecl *ECD);
363  void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
364  void VisitDeclaratorDecl(DeclaratorDecl *DD);
365  void VisitFunctionDecl(FunctionDecl *FD);
366  void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *GD);
367  void VisitCXXMethodDecl(CXXMethodDecl *D);
368  void VisitCXXConstructorDecl(CXXConstructorDecl *D);
369  void VisitCXXDestructorDecl(CXXDestructorDecl *D);
370  void VisitCXXConversionDecl(CXXConversionDecl *D);
371  void VisitFieldDecl(FieldDecl *FD);
372  void VisitMSPropertyDecl(MSPropertyDecl *FD);
373  void VisitMSGuidDecl(MSGuidDecl *D);
374  void VisitUnnamedGlobalConstantDecl(UnnamedGlobalConstantDecl *D);
375  void VisitTemplateParamObjectDecl(TemplateParamObjectDecl *D);
376  void VisitIndirectFieldDecl(IndirectFieldDecl *FD);
377  RedeclarableResult VisitVarDeclImpl(VarDecl *D);
378  void VisitVarDecl(VarDecl *VD) { VisitVarDeclImpl(VD); }
379  void VisitImplicitParamDecl(ImplicitParamDecl *PD);
380  void VisitParmVarDecl(ParmVarDecl *PD);
381  void VisitDecompositionDecl(DecompositionDecl *DD);
382  void VisitBindingDecl(BindingDecl *BD);
383  void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
384  DeclID VisitTemplateDecl(TemplateDecl *D);
385  void VisitConceptDecl(ConceptDecl *D);
386  void VisitRequiresExprBodyDecl(RequiresExprBodyDecl *D);
387  RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
388  void VisitClassTemplateDecl(ClassTemplateDecl *D);
389  void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D);
390  void VisitVarTemplateDecl(VarTemplateDecl *D);
391  void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
392  void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
393  void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
394  void VisitUsingDecl(UsingDecl *D);
395  void VisitUsingEnumDecl(UsingEnumDecl *D);
396  void VisitUsingPackDecl(UsingPackDecl *D);
397  void VisitUsingShadowDecl(UsingShadowDecl *D);
398  void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D);
399  void VisitLinkageSpecDecl(LinkageSpecDecl *D);
400  void VisitExportDecl(ExportDecl *D);
401  void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD);
402  void VisitImportDecl(ImportDecl *D);
403  void VisitAccessSpecDecl(AccessSpecDecl *D);
404  void VisitFriendDecl(FriendDecl *D);
405  void VisitFriendTemplateDecl(FriendTemplateDecl *D);
406  void VisitStaticAssertDecl(StaticAssertDecl *D);
407  void VisitBlockDecl(BlockDecl *BD);
408  void VisitCapturedDecl(CapturedDecl *CD);
409  void VisitEmptyDecl(EmptyDecl *D);
410  void VisitLifetimeExtendedTemporaryDecl(LifetimeExtendedTemporaryDecl *D);
411 
412  std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC);
413 
414  template<typename T>
415  RedeclarableResult VisitRedeclarable(Redeclarable<T> *D);
416 
417  template<typename T>
418  void mergeRedeclarable(Redeclarable<T> *D, RedeclarableResult &Redecl,
419  DeclID TemplatePatternID = 0);
420 
421  template<typename T>
422  void mergeRedeclarable(Redeclarable<T> *D, T *Existing,
423  RedeclarableResult &Redecl,
424  DeclID TemplatePatternID = 0);
425 
426  template<typename T>
427  void mergeMergeable(Mergeable<T> *D);
428 
429  void mergeMergeable(LifetimeExtendedTemporaryDecl *D);
430 
431  void mergeTemplatePattern(RedeclarableTemplateDecl *D,
432  RedeclarableTemplateDecl *Existing,
433  DeclID DsID, bool IsKeyDecl);
434 
435  ObjCTypeParamList *ReadObjCTypeParamList();
436 
437  // FIXME: Reorder according to DeclNodes.td?
438  void VisitObjCMethodDecl(ObjCMethodDecl *D);
439  void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D);
440  void VisitObjCContainerDecl(ObjCContainerDecl *D);
441  void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
442  void VisitObjCIvarDecl(ObjCIvarDecl *D);
443  void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
444  void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D);
445  void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
446  void VisitObjCImplDecl(ObjCImplDecl *D);
447  void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
448  void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
449  void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
450  void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
451  void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
452  void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
453  void VisitOMPAllocateDecl(OMPAllocateDecl *D);
454  void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
455  void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D);
456  void VisitOMPRequiresDecl(OMPRequiresDecl *D);
457  void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
458  };
459 
460 } // namespace clang
461 
462 namespace {
463 
464 /// Iterator over the redeclarations of a declaration that have already
465 /// been merged into the same redeclaration chain.
466 template<typename DeclT>
467 class MergedRedeclIterator {
468  DeclT *Start;
469  DeclT *Canonical = nullptr;
470  DeclT *Current = nullptr;
471 
472 public:
473  MergedRedeclIterator() = default;
474  MergedRedeclIterator(DeclT *Start) : Start(Start), Current(Start) {}
475 
476  DeclT *operator*() { return Current; }
477 
478  MergedRedeclIterator &operator++() {
479  if (Current->isFirstDecl()) {
480  Canonical = Current;
481  Current = Current->getMostRecentDecl();
482  } else
483  Current = Current->getPreviousDecl();
484 
485  // If we started in the merged portion, we'll reach our start position
486  // eventually. Otherwise, we'll never reach it, but the second declaration
487  // we reached was the canonical declaration, so stop when we see that one
488  // again.
489  if (Current == Start || Current == Canonical)
490  Current = nullptr;
491  return *this;
492  }
493 
494  friend bool operator!=(const MergedRedeclIterator &A,
495  const MergedRedeclIterator &B) {
496  return A.Current != B.Current;
497  }
498 };
499 
500 } // namespace
501 
502 template <typename DeclT>
503 static llvm::iterator_range<MergedRedeclIterator<DeclT>>
504 merged_redecls(DeclT *D) {
505  return llvm::make_range(MergedRedeclIterator<DeclT>(D),
506  MergedRedeclIterator<DeclT>());
507 }
508 
509 uint64_t ASTDeclReader::GetCurrentCursorOffset() {
510  return Loc.F->DeclsCursor.GetCurrentBitNo() + Loc.F->GlobalBitOffset;
511 }
512 
514  if (Record.readInt()) {
515  Reader.DefinitionSource[FD] =
516  Loc.F->Kind == ModuleKind::MK_MainFile ||
517  Reader.getContext().getLangOpts().BuildingPCHWithObjectFile;
518  }
519  if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
520  CD->setNumCtorInitializers(Record.readInt());
521  if (CD->getNumCtorInitializers())
522  CD->CtorInitializers = ReadGlobalOffset();
523  }
524  // Store the offset of the body so we can lazily load it later.
525  Reader.PendingBodies[FD] = GetCurrentCursorOffset();
526  HasPendingBody = true;
527 }
528 
531 
532  // At this point we have deserialized and merged the decl and it is safe to
533  // update its canonical decl to signal that the entire entity is used.
534  D->getCanonicalDecl()->Used |= IsDeclMarkedUsed;
535  IsDeclMarkedUsed = false;
536 
537  if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
538  if (auto *TInfo = DD->getTypeSourceInfo())
539  Record.readTypeLoc(TInfo->getTypeLoc());
540  }
541 
542  if (auto *TD = dyn_cast<TypeDecl>(D)) {
543  // We have a fully initialized TypeDecl. Read its type now.
544  TD->setTypeForDecl(Reader.GetType(DeferredTypeID).getTypePtrOrNull());
545 
546  // If this is a tag declaration with a typedef name for linkage, it's safe
547  // to load that typedef now.
548  if (NamedDeclForTagDecl)
549  cast<TagDecl>(D)->TypedefNameDeclOrQualifier =
550  cast<TypedefNameDecl>(Reader.GetDecl(NamedDeclForTagDecl));
551  } else if (auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
552  // if we have a fully initialized TypeDecl, we can safely read its type now.
553  ID->TypeForDecl = Reader.GetType(DeferredTypeID).getTypePtrOrNull();
554  } else if (auto *FD = dyn_cast<FunctionDecl>(D)) {
555  // FunctionDecl's body was written last after all other Stmts/Exprs.
556  // We only read it if FD doesn't already have a body (e.g., from another
557  // module).
558  // FIXME: Can we diagnose ODR violations somehow?
559  if (Record.readInt())
560  ReadFunctionDefinition(FD);
561  }
562 }
563 
565  if (D->isTemplateParameter() || D->isTemplateParameterPack() ||
566  isa<ParmVarDecl>(D) || isa<ObjCTypeParamDecl>(D)) {
567  // We don't want to deserialize the DeclContext of a template
568  // parameter or of a parameter of a function template immediately. These
569  // entities might be used in the formulation of its DeclContext (for
570  // example, a function parameter can be used in decltype() in trailing
571  // return type of the function). Use the translation unit DeclContext as a
572  // placeholder.
573  GlobalDeclID SemaDCIDForTemplateParmDecl = readDeclID();
574  GlobalDeclID LexicalDCIDForTemplateParmDecl = readDeclID();
575  if (!LexicalDCIDForTemplateParmDecl)
576  LexicalDCIDForTemplateParmDecl = SemaDCIDForTemplateParmDecl;
577  Reader.addPendingDeclContextInfo(D,
578  SemaDCIDForTemplateParmDecl,
579  LexicalDCIDForTemplateParmDecl);
580  D->setDeclContext(Reader.getContext().getTranslationUnitDecl());
581  } else {
582  auto *SemaDC = readDeclAs<DeclContext>();
583  auto *LexicalDC = readDeclAs<DeclContext>();
584  if (!LexicalDC)
585  LexicalDC = SemaDC;
586  DeclContext *MergedSemaDC = Reader.MergedDeclContexts.lookup(SemaDC);
587  // Avoid calling setLexicalDeclContext() directly because it uses
588  // Decl::getASTContext() internally which is unsafe during derialization.
589  D->setDeclContextsImpl(MergedSemaDC ? MergedSemaDC : SemaDC, LexicalDC,
590  Reader.getContext());
591  }
592  D->setLocation(ThisDeclLoc);
593  D->InvalidDecl = Record.readInt();
594  if (Record.readInt()) { // hasAttrs
595  AttrVec Attrs;
596  Record.readAttributes(Attrs);
597  // Avoid calling setAttrs() directly because it uses Decl::getASTContext()
598  // internally which is unsafe during derialization.
599  D->setAttrsImpl(Attrs, Reader.getContext());
600  }
601  D->setImplicit(Record.readInt());
602  D->Used = Record.readInt();
603  IsDeclMarkedUsed |= D->Used;
604  D->setReferenced(Record.readInt());
605  D->setTopLevelDeclInObjCContainer(Record.readInt());
606  D->setAccess((AccessSpecifier)Record.readInt());
607  D->FromASTFile = true;
608  bool ModulePrivate = Record.readInt();
609 
610  // Determine whether this declaration is part of a (sub)module. If so, it
611  // may not yet be visible.
612  if (unsigned SubmoduleID = readSubmoduleID()) {
613  // Store the owning submodule ID in the declaration.
618 
619  if (ModulePrivate) {
620  // Module-private declarations are never visible, so there is no work to
621  // do.
622  } else if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
623  // If local visibility is being tracked, this declaration will become
624  // hidden and visible as the owning module does.
625  } else if (Module *Owner = Reader.getSubmodule(SubmoduleID)) {
626  // Mark the declaration as visible when its owning module becomes visible.
627  if (Owner->NameVisibility == Module::AllVisible)
629  else
630  Reader.HiddenNamesMap[Owner].push_back(D);
631  }
632  } else if (ModulePrivate) {
634  }
635 }
636 
638  VisitDecl(D);
639  D->setLocation(readSourceLocation());
640  D->CommentKind = (PragmaMSCommentKind)Record.readInt();
641  std::string Arg = readString();
642  memcpy(D->getTrailingObjects<char>(), Arg.data(), Arg.size());
643  D->getTrailingObjects<char>()[Arg.size()] = '\0';
644 }
645 
647  VisitDecl(D);
648  D->setLocation(readSourceLocation());
649  std::string Name = readString();
650  memcpy(D->getTrailingObjects<char>(), Name.data(), Name.size());
651  D->getTrailingObjects<char>()[Name.size()] = '\0';
652 
653  D->ValueStart = Name.size() + 1;
654  std::string Value = readString();
655  memcpy(D->getTrailingObjects<char>() + D->ValueStart, Value.data(),
656  Value.size());
657  D->getTrailingObjects<char>()[D->ValueStart + Value.size()] = '\0';
658 }
659 
661  llvm_unreachable("Translation units are not serialized");
662 }
663 
665  VisitDecl(ND);
666  ND->setDeclName(Record.readDeclarationName());
667  AnonymousDeclNumber = Record.readInt();
668 }
669 
671  VisitNamedDecl(TD);
672  TD->setLocStart(readSourceLocation());
673  // Delay type reading until after we have fully initialized the decl.
674  DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
675 }
676 
677 ASTDeclReader::RedeclarableResult
679  RedeclarableResult Redecl = VisitRedeclarable(TD);
680  VisitTypeDecl(TD);
681  TypeSourceInfo *TInfo = readTypeSourceInfo();
682  if (Record.readInt()) { // isModed
683  QualType modedT = Record.readType();
684  TD->setModedTypeSourceInfo(TInfo, modedT);
685  } else
686  TD->setTypeSourceInfo(TInfo);
687  // Read and discard the declaration for which this is a typedef name for
688  // linkage, if it exists. We cannot rely on our type to pull in this decl,
689  // because it might have been merged with a type from another module and
690  // thus might not refer to our version of the declaration.
691  readDecl();
692  return Redecl;
693 }
694 
696  RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
697  mergeRedeclarable(TD, Redecl);
698 }
699 
701  RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
702  if (auto *Template = readDeclAs<TypeAliasTemplateDecl>())
703  // Merged when we merge the template.
704  TD->setDescribedAliasTemplate(Template);
705  else
706  mergeRedeclarable(TD, Redecl);
707 }
708 
709 ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) {
710  RedeclarableResult Redecl = VisitRedeclarable(TD);
711  VisitTypeDecl(TD);
712 
713  TD->IdentifierNamespace = Record.readInt();
714  TD->setTagKind((TagDecl::TagKind)Record.readInt());
715  if (!isa<CXXRecordDecl>(TD))
716  TD->setCompleteDefinition(Record.readInt());
717  TD->setEmbeddedInDeclarator(Record.readInt());
718  TD->setFreeStanding(Record.readInt());
719  TD->setCompleteDefinitionRequired(Record.readInt());
720  TD->setBraceRange(readSourceRange());
721 
722  switch (Record.readInt()) {
723  case 0:
724  break;
725  case 1: { // ExtInfo
726  auto *Info = new (Reader.getContext()) TagDecl::ExtInfo();
727  Record.readQualifierInfo(*Info);
728  TD->TypedefNameDeclOrQualifier = Info;
729  break;
730  }
731  case 2: // TypedefNameForAnonDecl
732  NamedDeclForTagDecl = readDeclID();
733  TypedefNameForLinkage = Record.readIdentifier();
734  break;
735  default:
736  llvm_unreachable("unexpected tag info kind");
737  }
738 
739  if (!isa<CXXRecordDecl>(TD))
740  mergeRedeclarable(TD, Redecl);
741  return Redecl;
742 }
743 
745  VisitTagDecl(ED);
746  if (TypeSourceInfo *TI = readTypeSourceInfo())
747  ED->setIntegerTypeSourceInfo(TI);
748  else
749  ED->setIntegerType(Record.readType());
750  ED->setPromotionType(Record.readType());
751  ED->setNumPositiveBits(Record.readInt());
752  ED->setNumNegativeBits(Record.readInt());
753  ED->setScoped(Record.readInt());
754  ED->setScopedUsingClassTag(Record.readInt());
755  ED->setFixed(Record.readInt());
756 
757  ED->setHasODRHash(true);
758  ED->ODRHash = Record.readInt();
759 
760  // If this is a definition subject to the ODR, and we already have a
761  // definition, merge this one into it.
762  if (ED->isCompleteDefinition() &&
763  Reader.getContext().getLangOpts().Modules &&
764  Reader.getContext().getLangOpts().CPlusPlus) {
765  EnumDecl *&OldDef = Reader.EnumDefinitions[ED->getCanonicalDecl()];
766  if (!OldDef) {
767  // This is the first time we've seen an imported definition. Look for a
768  // local definition before deciding that we are the first definition.
769  for (auto *D : merged_redecls(ED->getCanonicalDecl())) {
770  if (!D->isFromASTFile() && D->isCompleteDefinition()) {
771  OldDef = D;
772  break;
773  }
774  }
775  }
776  if (OldDef) {
777  Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
779  Reader.mergeDefinitionVisibility(OldDef, ED);
780  if (OldDef->getODRHash() != ED->getODRHash())
781  Reader.PendingEnumOdrMergeFailures[OldDef].push_back(ED);
782  } else {
783  OldDef = ED;
784  }
785  }
786 
787  if (auto *InstED = readDeclAs<EnumDecl>()) {
788  auto TSK = (TemplateSpecializationKind)Record.readInt();
789  SourceLocation POI = readSourceLocation();
790  ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK);
792  }
793 }
794 
795 ASTDeclReader::RedeclarableResult
797  RedeclarableResult Redecl = VisitTagDecl(RD);
798  RD->setHasFlexibleArrayMember(Record.readInt());
799  RD->setAnonymousStructOrUnion(Record.readInt());
800  RD->setHasObjectMember(Record.readInt());
801  RD->setHasVolatileMember(Record.readInt());
802  RD->setNonTrivialToPrimitiveDefaultInitialize(Record.readInt());
803  RD->setNonTrivialToPrimitiveCopy(Record.readInt());
804  RD->setNonTrivialToPrimitiveDestroy(Record.readInt());
806  RD->setHasNonTrivialToPrimitiveDestructCUnion(Record.readInt());
807  RD->setHasNonTrivialToPrimitiveCopyCUnion(Record.readInt());
808  RD->setParamDestroyedInCallee(Record.readInt());
810  return Redecl;
811 }
812 
814  VisitRecordDeclImpl(RD);
815 
816  // Maintain the invariant of a redeclaration chain containing only
817  // a single definition.
818  if (RD->isCompleteDefinition()) {
819  RecordDecl *Canon = static_cast<RecordDecl *>(RD->getCanonicalDecl());
820  RecordDecl *&OldDef = Reader.RecordDefinitions[Canon];
821  if (!OldDef) {
822  // This is the first time we've seen an imported definition. Look for a
823  // local definition before deciding that we are the first definition.
824  for (auto *D : merged_redecls(Canon)) {
825  if (!D->isFromASTFile() && D->isCompleteDefinition()) {
826  OldDef = D;
827  break;
828  }
829  }
830  }
831  if (OldDef) {
832  Reader.MergedDeclContexts.insert(std::make_pair(RD, OldDef));
834  Reader.mergeDefinitionVisibility(OldDef, RD);
835  } else {
836  OldDef = RD;
837  }
838  }
839 }
840 
842  VisitNamedDecl(VD);
843  // For function declarations, defer reading the type in case the function has
844  // a deduced return type that references an entity declared within the
845  // function.
846  if (isa<FunctionDecl>(VD))
847  DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
848  else
849  VD->setType(Record.readType());
850 }
851 
853  VisitValueDecl(ECD);
854  if (Record.readInt())
855  ECD->setInitExpr(Record.readExpr());
856  ECD->setInitVal(Record.readAPSInt());
857  mergeMergeable(ECD);
858 }
859 
861  VisitValueDecl(DD);
862  DD->setInnerLocStart(readSourceLocation());
863  if (Record.readInt()) { // hasExtInfo
864  auto *Info = new (Reader.getContext()) DeclaratorDecl::ExtInfo();
865  Record.readQualifierInfo(*Info);
866  Info->TrailingRequiresClause = Record.readExpr();
867  DD->DeclInfo = Info;
868  }
869  QualType TSIType = Record.readType();
870  DD->setTypeSourceInfo(
871  TSIType.isNull() ? nullptr
872  : Reader.getContext().CreateTypeSourceInfo(TSIType));
873 }
874 
876  RedeclarableResult Redecl = VisitRedeclarable(FD);
877  VisitDeclaratorDecl(FD);
878 
879  // Attach a type to this function. Use the real type if possible, but fall
880  // back to the type as written if it involves a deduced return type.
881  if (FD->getTypeSourceInfo() &&
884  // We'll set up the real type in Visit, once we've finished loading the
885  // function.
886  FD->setType(FD->getTypeSourceInfo()->getType());
887  Reader.PendingFunctionTypes.push_back({FD, DeferredTypeID});
888  } else {
889  FD->setType(Reader.GetType(DeferredTypeID));
890  }
891  DeferredTypeID = 0;
892 
893  FD->DNLoc = Record.readDeclarationNameLoc(FD->getDeclName());
894  FD->IdentifierNamespace = Record.readInt();
895 
896  // FunctionDecl's body is handled last at ASTDeclReader::Visit,
897  // after everything else is read.
898 
899  FD->setStorageClass(static_cast<StorageClass>(Record.readInt()));
900  FD->setInlineSpecified(Record.readInt());
901  FD->setImplicitlyInline(Record.readInt());
902  FD->setVirtualAsWritten(Record.readInt());
903  // We defer calling `FunctionDecl::setPure()` here as for methods of
904  // `CXXTemplateSpecializationDecl`s, we may not have connected up the
905  // definition (which is required for `setPure`).
906  const bool Pure = Record.readInt();
907  FD->setHasInheritedPrototype(Record.readInt());
908  FD->setHasWrittenPrototype(Record.readInt());
909  FD->setDeletedAsWritten(Record.readInt());
910  FD->setTrivial(Record.readInt());
911  FD->setTrivialForCall(Record.readInt());
912  FD->setDefaulted(Record.readInt());
913  FD->setExplicitlyDefaulted(Record.readInt());
914  FD->setHasImplicitReturnZero(Record.readInt());
915  FD->setConstexprKind(static_cast<ConstexprSpecKind>(Record.readInt()));
916  FD->setUsesSEHTry(Record.readInt());
917  FD->setHasSkippedBody(Record.readInt());
918  FD->setIsMultiVersion(Record.readInt());
919  FD->setLateTemplateParsed(Record.readInt());
920 
921  FD->setCachedLinkage(static_cast<Linkage>(Record.readInt()));
922  FD->EndRangeLoc = readSourceLocation();
923 
924  FD->ODRHash = Record.readInt();
925  FD->setHasODRHash(true);
926 
927  if (FD->isDefaulted()) {
928  if (unsigned NumLookups = Record.readInt()) {
930  for (unsigned I = 0; I != NumLookups; ++I) {
931  NamedDecl *ND = Record.readDeclAs<NamedDecl>();
932  AccessSpecifier AS = (AccessSpecifier)Record.readInt();
933  Lookups.push_back(DeclAccessPair::make(ND, AS));
934  }
936  Reader.getContext(), Lookups));
937  }
938  }
939 
940  switch ((FunctionDecl::TemplatedKind)Record.readInt()) {
942  mergeRedeclarable(FD, Redecl);
943  break;
945  // Merged when we merge the template.
946  FD->setDescribedFunctionTemplate(readDeclAs<FunctionTemplateDecl>());
947  break;
949  auto *InstFD = readDeclAs<FunctionDecl>();
950  auto TSK = (TemplateSpecializationKind)Record.readInt();
951  SourceLocation POI = readSourceLocation();
952  FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
954  mergeRedeclarable(FD, Redecl);
955  break;
956  }
958  auto *Template = readDeclAs<FunctionTemplateDecl>();
959  auto TSK = (TemplateSpecializationKind)Record.readInt();
960 
961  // Template arguments.
963  Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
964 
965  // Template args as written.
967  SourceLocation LAngleLoc, RAngleLoc;
968  bool HasTemplateArgumentsAsWritten = Record.readInt();
969  if (HasTemplateArgumentsAsWritten) {
970  unsigned NumTemplateArgLocs = Record.readInt();
971  TemplArgLocs.reserve(NumTemplateArgLocs);
972  for (unsigned i = 0; i != NumTemplateArgLocs; ++i)
973  TemplArgLocs.push_back(Record.readTemplateArgumentLoc());
974 
975  LAngleLoc = readSourceLocation();
976  RAngleLoc = readSourceLocation();
977  }
978 
979  SourceLocation POI = readSourceLocation();
980 
981  ASTContext &C = Reader.getContext();
982  TemplateArgumentList *TemplArgList
983  = TemplateArgumentList::CreateCopy(C, TemplArgs);
984  TemplateArgumentListInfo TemplArgsInfo(LAngleLoc, RAngleLoc);
985  for (unsigned i = 0, e = TemplArgLocs.size(); i != e; ++i)
986  TemplArgsInfo.addArgument(TemplArgLocs[i]);
987 
988  MemberSpecializationInfo *MSInfo = nullptr;
989  if (Record.readInt()) {
990  auto *FD = readDeclAs<FunctionDecl>();
991  auto TSK = (TemplateSpecializationKind)Record.readInt();
992  SourceLocation POI = readSourceLocation();
993 
994  MSInfo = new (C) MemberSpecializationInfo(FD, TSK);
995  MSInfo->setPointOfInstantiation(POI);
996  }
997 
1000  C, FD, Template, TSK, TemplArgList,
1001  HasTemplateArgumentsAsWritten ? &TemplArgsInfo : nullptr, POI,
1002  MSInfo);
1003  FD->TemplateOrSpecialization = FTInfo;
1004 
1005  if (FD->isCanonicalDecl()) { // if canonical add to template's set.
1006  // The template that contains the specializations set. It's not safe to
1007  // use getCanonicalDecl on Template since it may still be initializing.
1008  auto *CanonTemplate = readDeclAs<FunctionTemplateDecl>();
1009  // Get the InsertPos by FindNodeOrInsertPos() instead of calling
1010  // InsertNode(FTInfo) directly to avoid the getASTContext() call in
1011  // FunctionTemplateSpecializationInfo's Profile().
1012  // We avoid getASTContext because a decl in the parent hierarchy may
1013  // be initializing.
1014  llvm::FoldingSetNodeID ID;
1016  void *InsertPos = nullptr;
1017  FunctionTemplateDecl::Common *CommonPtr = CanonTemplate->getCommonPtr();
1018  FunctionTemplateSpecializationInfo *ExistingInfo =
1019  CommonPtr->Specializations.FindNodeOrInsertPos(ID, InsertPos);
1020  if (InsertPos)
1021  CommonPtr->Specializations.InsertNode(FTInfo, InsertPos);
1022  else {
1023  assert(Reader.getContext().getLangOpts().Modules &&
1024  "already deserialized this template specialization");
1025  mergeRedeclarable(FD, ExistingInfo->getFunction(), Redecl);
1026  }
1027  }
1028  break;
1029  }
1031  // Templates.
1032  UnresolvedSet<8> TemplDecls;
1033  unsigned NumTemplates = Record.readInt();
1034  while (NumTemplates--)
1035  TemplDecls.addDecl(readDeclAs<NamedDecl>());
1036 
1037  // Templates args.
1038  TemplateArgumentListInfo TemplArgs;
1039  unsigned NumArgs = Record.readInt();
1040  while (NumArgs--)
1041  TemplArgs.addArgument(Record.readTemplateArgumentLoc());
1042  TemplArgs.setLAngleLoc(readSourceLocation());
1043  TemplArgs.setRAngleLoc(readSourceLocation());
1044 
1045  FD->setDependentTemplateSpecialization(Reader.getContext(),
1046  TemplDecls, TemplArgs);
1047  // These are not merged; we don't need to merge redeclarations of dependent
1048  // template friends.
1049  break;
1050  }
1051  }
1052 
1053  // Defer calling `setPure` until merging above has guaranteed we've set
1054  // `DefinitionData` (as this will need to access it).
1055  FD->setPure(Pure);
1056 
1057  // Read in the parameters.
1058  unsigned NumParams = Record.readInt();
1060  Params.reserve(NumParams);
1061  for (unsigned I = 0; I != NumParams; ++I)
1062  Params.push_back(readDeclAs<ParmVarDecl>());
1063  FD->setParams(Reader.getContext(), Params);
1064 }
1065 
1067  VisitNamedDecl(MD);
1068  if (Record.readInt()) {
1069  // Load the body on-demand. Most clients won't care, because method
1070  // definitions rarely show up in headers.
1071  Reader.PendingBodies[MD] = GetCurrentCursorOffset();
1072  HasPendingBody = true;
1073  }
1074  MD->setSelfDecl(readDeclAs<ImplicitParamDecl>());
1075  MD->setCmdDecl(readDeclAs<ImplicitParamDecl>());
1076  MD->setInstanceMethod(Record.readInt());
1077  MD->setVariadic(Record.readInt());
1078  MD->setPropertyAccessor(Record.readInt());
1079  MD->setSynthesizedAccessorStub(Record.readInt());
1080  MD->setDefined(Record.readInt());
1081  MD->setOverriding(Record.readInt());
1082  MD->setHasSkippedBody(Record.readInt());
1083 
1084  MD->setIsRedeclaration(Record.readInt());
1085  MD->setHasRedeclaration(Record.readInt());
1086  if (MD->hasRedeclaration())
1087  Reader.getContext().setObjCMethodRedeclaration(MD,
1088  readDeclAs<ObjCMethodDecl>());
1089 
1091  MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record.readInt());
1092  MD->setRelatedResultType(Record.readInt());
1093  MD->setReturnType(Record.readType());
1094  MD->setReturnTypeSourceInfo(readTypeSourceInfo());
1095  MD->DeclEndLoc = readSourceLocation();
1096  unsigned NumParams = Record.readInt();
1098  Params.reserve(NumParams);
1099  for (unsigned I = 0; I != NumParams; ++I)
1100  Params.push_back(readDeclAs<ParmVarDecl>());
1101 
1102  MD->setSelLocsKind((SelectorLocationsKind)Record.readInt());
1103  unsigned NumStoredSelLocs = Record.readInt();
1105  SelLocs.reserve(NumStoredSelLocs);
1106  for (unsigned i = 0; i != NumStoredSelLocs; ++i)
1107  SelLocs.push_back(readSourceLocation());
1108 
1109  MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs);
1110 }
1111 
1113  VisitTypedefNameDecl(D);
1114 
1115  D->Variance = Record.readInt();
1116  D->Index = Record.readInt();
1117  D->VarianceLoc = readSourceLocation();
1118  D->ColonLoc = readSourceLocation();
1119 }
1120 
1122  VisitNamedDecl(CD);
1123  CD->setAtStartLoc(readSourceLocation());
1124  CD->setAtEndRange(readSourceRange());
1125 }
1126 
1128  unsigned numParams = Record.readInt();
1129  if (numParams == 0)
1130  return nullptr;
1131 
1133  typeParams.reserve(numParams);
1134  for (unsigned i = 0; i != numParams; ++i) {
1135  auto *typeParam = readDeclAs<ObjCTypeParamDecl>();
1136  if (!typeParam)
1137  return nullptr;
1138 
1139  typeParams.push_back(typeParam);
1140  }
1141 
1142  SourceLocation lAngleLoc = readSourceLocation();
1143  SourceLocation rAngleLoc = readSourceLocation();
1144 
1145  return ObjCTypeParamList::create(Reader.getContext(), lAngleLoc,
1146  typeParams, rAngleLoc);
1147 }
1148 
1149 void ASTDeclReader::ReadObjCDefinitionData(
1150  struct ObjCInterfaceDecl::DefinitionData &Data) {
1151  // Read the superclass.
1152  Data.SuperClassTInfo = readTypeSourceInfo();
1153 
1154  Data.EndLoc = readSourceLocation();
1155  Data.HasDesignatedInitializers = Record.readInt();
1156 
1157  // Read the directly referenced protocols and their SourceLocations.
1158  unsigned NumProtocols = Record.readInt();
1160  Protocols.reserve(NumProtocols);
1161  for (unsigned I = 0; I != NumProtocols; ++I)
1162  Protocols.push_back(readDeclAs<ObjCProtocolDecl>());
1164  ProtoLocs.reserve(NumProtocols);
1165  for (unsigned I = 0; I != NumProtocols; ++I)
1166  ProtoLocs.push_back(readSourceLocation());
1167  Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, ProtoLocs.data(),
1168  Reader.getContext());
1169 
1170  // Read the transitive closure of protocols referenced by this class.
1171  NumProtocols = Record.readInt();
1172  Protocols.clear();
1173  Protocols.reserve(NumProtocols);
1174  for (unsigned I = 0; I != NumProtocols; ++I)
1175  Protocols.push_back(readDeclAs<ObjCProtocolDecl>());
1176  Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
1177  Reader.getContext());
1178 }
1179 
1180 void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D,
1181  struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
1182  struct ObjCInterfaceDecl::DefinitionData &DD = D->data();
1183  if (DD.Definition != NewDD.Definition) {
1184  Reader.MergedDeclContexts.insert(
1185  std::make_pair(NewDD.Definition, DD.Definition));
1186  Reader.mergeDefinitionVisibility(DD.Definition, NewDD.Definition);
1187  }
1188 
1189  // FIXME: odr checking?
1190 }
1191 
1193  RedeclarableResult Redecl = VisitRedeclarable(ID);
1194  VisitObjCContainerDecl(ID);
1195  DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
1196  mergeRedeclarable(ID, Redecl);
1197 
1198  ID->TypeParamList = ReadObjCTypeParamList();
1199  if (Record.readInt()) {
1200  // Read the definition.
1201  ID->allocateDefinitionData();
1202 
1203  ReadObjCDefinitionData(ID->data());
1204  ObjCInterfaceDecl *Canon = ID->getCanonicalDecl();
1205  if (Canon->Data.getPointer()) {
1206  // If we already have a definition, keep the definition invariant and
1207  // merge the data.
1208  MergeDefinitionData(Canon, std::move(ID->data()));
1209  ID->Data = Canon->Data;
1210  } else {
1211  // Set the definition data of the canonical declaration, so other
1212  // redeclarations will see it.
1213  ID->getCanonicalDecl()->Data = ID->Data;
1214 
1215  // We will rebuild this list lazily.
1216  ID->setIvarList(nullptr);
1217  }
1218 
1219  // Note that we have deserialized a definition.
1220  Reader.PendingDefinitions.insert(ID);
1221 
1222  // Note that we've loaded this Objective-C class.
1223  Reader.ObjCClassesLoaded.push_back(ID);
1224  } else {
1225  ID->Data = ID->getCanonicalDecl()->Data;
1226  }
1227 }
1228 
1230  VisitFieldDecl(IVD);
1231  IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record.readInt());
1232  // This field will be built lazily.
1233  IVD->setNextIvar(nullptr);
1234  bool synth = Record.readInt();
1235  IVD->setSynthesize(synth);
1236 
1237  // Check ivar redeclaration.
1238  if (IVD->isInvalidDecl())
1239  return;
1240  // Don't check ObjCInterfaceDecl as interfaces are named and mismatches can be
1241  // detected in VisitObjCInterfaceDecl. Here we are looking for redeclarations
1242  // in extensions.
1243  if (isa<ObjCInterfaceDecl>(IVD->getDeclContext()))
1244  return;
1245  ObjCInterfaceDecl *CanonIntf =
1247  IdentifierInfo *II = IVD->getIdentifier();
1248  ObjCIvarDecl *PrevIvar = CanonIntf->lookupInstanceVariable(II);
1249  if (PrevIvar && PrevIvar != IVD) {
1250  auto *ParentExt = dyn_cast<ObjCCategoryDecl>(IVD->getDeclContext());
1251  auto *PrevParentExt =
1252  dyn_cast<ObjCCategoryDecl>(PrevIvar->getDeclContext());
1253  if (ParentExt && PrevParentExt) {
1254  // Postpone diagnostic as we should merge identical extensions from
1255  // different modules.
1256  Reader
1257  .PendingObjCExtensionIvarRedeclarations[std::make_pair(ParentExt,
1258  PrevParentExt)]
1259  .push_back(std::make_pair(IVD, PrevIvar));
1260  } else if (ParentExt || PrevParentExt) {
1261  // Duplicate ivars in extension + implementation are never compatible.
1262  // Compatibility of implementation + implementation should be handled in
1263  // VisitObjCImplementationDecl.
1264  Reader.Diag(IVD->getLocation(), diag::err_duplicate_ivar_declaration)
1265  << II;
1266  Reader.Diag(PrevIvar->getLocation(), diag::note_previous_definition);
1267  }
1268  }
1269 }
1270 
1271 void ASTDeclReader::ReadObjCDefinitionData(
1272  struct ObjCProtocolDecl::DefinitionData &Data) {
1273  unsigned NumProtoRefs = Record.readInt();
1275  ProtoRefs.reserve(NumProtoRefs);
1276  for (unsigned I = 0; I != NumProtoRefs; ++I)
1277  ProtoRefs.push_back(readDeclAs<ObjCProtocolDecl>());
1279  ProtoLocs.reserve(NumProtoRefs);
1280  for (unsigned I = 0; I != NumProtoRefs; ++I)
1281  ProtoLocs.push_back(readSourceLocation());
1282  Data.ReferencedProtocols.set(ProtoRefs.data(), NumProtoRefs,
1283  ProtoLocs.data(), Reader.getContext());
1284 }
1285 
1286 void ASTDeclReader::MergeDefinitionData(ObjCProtocolDecl *D,
1287  struct ObjCProtocolDecl::DefinitionData &&NewDD) {
1288  struct ObjCProtocolDecl::DefinitionData &DD = D->data();
1289  if (DD.Definition != NewDD.Definition) {
1290  Reader.MergedDeclContexts.insert(
1291  std::make_pair(NewDD.Definition, DD.Definition));
1292  Reader.mergeDefinitionVisibility(DD.Definition, NewDD.Definition);
1293  }
1294 
1295  // FIXME: odr checking?
1296 }
1297 
1299  RedeclarableResult Redecl = VisitRedeclarable(PD);
1300  VisitObjCContainerDecl(PD);
1301  mergeRedeclarable(PD, Redecl);
1302 
1303  if (Record.readInt()) {
1304  // Read the definition.
1305  PD->allocateDefinitionData();
1306 
1307  ReadObjCDefinitionData(PD->data());
1308 
1309  ObjCProtocolDecl *Canon = PD->getCanonicalDecl();
1310  if (Canon->Data.getPointer()) {
1311  // If we already have a definition, keep the definition invariant and
1312  // merge the data.
1313  MergeDefinitionData(Canon, std::move(PD->data()));
1314  PD->Data = Canon->Data;
1315  } else {
1316  // Set the definition data of the canonical declaration, so other
1317  // redeclarations will see it.
1318  PD->getCanonicalDecl()->Data = PD->Data;
1319  }
1320  // Note that we have deserialized a definition.
1321  Reader.PendingDefinitions.insert(PD);
1322  } else {
1323  PD->Data = PD->getCanonicalDecl()->Data;
1324  }
1325 }
1326 
1328  VisitFieldDecl(FD);
1329 }
1330 
1332  VisitObjCContainerDecl(CD);
1333  CD->setCategoryNameLoc(readSourceLocation());
1334  CD->setIvarLBraceLoc(readSourceLocation());
1335  CD->setIvarRBraceLoc(readSourceLocation());
1336 
1337  // Note that this category has been deserialized. We do this before
1338  // deserializing the interface declaration, so that it will consider this
1339  /// category.
1340  Reader.CategoriesDeserialized.insert(CD);
1341 
1342  CD->ClassInterface = readDeclAs<ObjCInterfaceDecl>();
1343  CD->TypeParamList = ReadObjCTypeParamList();
1344  unsigned NumProtoRefs = Record.readInt();
1346  ProtoRefs.reserve(NumProtoRefs);
1347  for (unsigned I = 0; I != NumProtoRefs; ++I)
1348  ProtoRefs.push_back(readDeclAs<ObjCProtocolDecl>());
1350  ProtoLocs.reserve(NumProtoRefs);
1351  for (unsigned I = 0; I != NumProtoRefs; ++I)
1352  ProtoLocs.push_back(readSourceLocation());
1353  CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
1354  Reader.getContext());
1355 
1356  // Protocols in the class extension belong to the class.
1357  if (NumProtoRefs > 0 && CD->ClassInterface && CD->IsClassExtension())
1358  CD->ClassInterface->mergeClassExtensionProtocolList(
1359  (ObjCProtocolDecl *const *)ProtoRefs.data(), NumProtoRefs,
1360  Reader.getContext());
1361 }
1362 
1364  VisitNamedDecl(CAD);
1365  CAD->setClassInterface(readDeclAs<ObjCInterfaceDecl>());
1366 }
1367 
1369  VisitNamedDecl(D);
1370  D->setAtLoc(readSourceLocation());
1371  D->setLParenLoc(readSourceLocation());
1372  QualType T = Record.readType();
1373  TypeSourceInfo *TSI = readTypeSourceInfo();
1374  D->setType(T, TSI);
1375  D->setPropertyAttributes((ObjCPropertyAttribute::Kind)Record.readInt());
1377  (ObjCPropertyAttribute::Kind)Record.readInt());
1379  (ObjCPropertyDecl::PropertyControl)Record.readInt());
1380  DeclarationName GetterName = Record.readDeclarationName();
1381  SourceLocation GetterLoc = readSourceLocation();
1382  D->setGetterName(GetterName.getObjCSelector(), GetterLoc);
1383  DeclarationName SetterName = Record.readDeclarationName();
1384  SourceLocation SetterLoc = readSourceLocation();
1385  D->setSetterName(SetterName.getObjCSelector(), SetterLoc);
1386  D->setGetterMethodDecl(readDeclAs<ObjCMethodDecl>());
1387  D->setSetterMethodDecl(readDeclAs<ObjCMethodDecl>());
1388  D->setPropertyIvarDecl(readDeclAs<ObjCIvarDecl>());
1389 }
1390 
1392  VisitObjCContainerDecl(D);
1393  D->setClassInterface(readDeclAs<ObjCInterfaceDecl>());
1394 }
1395 
1397  VisitObjCImplDecl(D);
1398  D->CategoryNameLoc = readSourceLocation();
1399 }
1400 
1402  VisitObjCImplDecl(D);
1403  D->setSuperClass(readDeclAs<ObjCInterfaceDecl>());
1404  D->SuperLoc = readSourceLocation();
1405  D->setIvarLBraceLoc(readSourceLocation());
1406  D->setIvarRBraceLoc(readSourceLocation());
1407  D->setHasNonZeroConstructors(Record.readInt());
1408  D->setHasDestructors(Record.readInt());
1409  D->NumIvarInitializers = Record.readInt();
1410  if (D->NumIvarInitializers)
1411  D->IvarInitializers = ReadGlobalOffset();
1412 }
1413 
1415  VisitDecl(D);
1416  D->setAtLoc(readSourceLocation());
1417  D->setPropertyDecl(readDeclAs<ObjCPropertyDecl>());
1418  D->PropertyIvarDecl = readDeclAs<ObjCIvarDecl>();
1419  D->IvarLoc = readSourceLocation();
1420  D->setGetterMethodDecl(readDeclAs<ObjCMethodDecl>());
1421  D->setSetterMethodDecl(readDeclAs<ObjCMethodDecl>());
1422  D->setGetterCXXConstructor(Record.readExpr());
1423  D->setSetterCXXAssignment(Record.readExpr());
1424 }
1425 
1427  VisitDeclaratorDecl(FD);
1428  FD->Mutable = Record.readInt();
1429 
1430  if (auto ISK = static_cast<FieldDecl::InitStorageKind>(Record.readInt())) {
1431  FD->InitStorage.setInt(ISK);
1432  FD->InitStorage.setPointer(ISK == FieldDecl::ISK_CapturedVLAType
1433  ? Record.readType().getAsOpaquePtr()
1434  : Record.readExpr());
1435  }
1436 
1437  if (auto *BW = Record.readExpr())
1438  FD->setBitWidth(BW);
1439 
1440  if (!FD->getDeclName()) {
1441  if (auto *Tmpl = readDeclAs<FieldDecl>())
1442  Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
1443  }
1444  mergeMergeable(FD);
1445 }
1446 
1448  VisitDeclaratorDecl(PD);
1449  PD->GetterId = Record.readIdentifier();
1450  PD->SetterId = Record.readIdentifier();
1451 }
1452 
1454  VisitValueDecl(D);
1455  D->PartVal.Part1 = Record.readInt();
1456  D->PartVal.Part2 = Record.readInt();
1457  D->PartVal.Part3 = Record.readInt();
1458  for (auto &C : D->PartVal.Part4And5)
1459  C = Record.readInt();
1460 
1461  // Add this GUID to the AST context's lookup structure, and merge if needed.
1462  if (MSGuidDecl *Existing = Reader.getContext().MSGuidDecls.GetOrInsertNode(D))
1463  Reader.getContext().setPrimaryMergedDecl(D, Existing->getCanonicalDecl());
1464 }
1465 
1468  VisitValueDecl(D);
1469  D->Value = Record.readAPValue();
1470 
1471  // Add this to the AST context's lookup structure, and merge if needed.
1472  if (UnnamedGlobalConstantDecl *Existing =
1473  Reader.getContext().UnnamedGlobalConstantDecls.GetOrInsertNode(D))
1474  Reader.getContext().setPrimaryMergedDecl(D, Existing->getCanonicalDecl());
1475 }
1476 
1478  VisitValueDecl(D);
1479  D->Value = Record.readAPValue();
1480 
1481  // Add this template parameter object to the AST context's lookup structure,
1482  // and merge if needed.
1483  if (TemplateParamObjectDecl *Existing =
1484  Reader.getContext().TemplateParamObjectDecls.GetOrInsertNode(D))
1485  Reader.getContext().setPrimaryMergedDecl(D, Existing->getCanonicalDecl());
1486 }
1487 
1489  VisitValueDecl(FD);
1490 
1491  FD->ChainingSize = Record.readInt();
1492  assert(FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2");
1493  FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize];
1494 
1495  for (unsigned I = 0; I != FD->ChainingSize; ++I)
1496  FD->Chaining[I] = readDeclAs<NamedDecl>();
1497 
1498  mergeMergeable(FD);
1499 }
1500 
1501 ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
1502  RedeclarableResult Redecl = VisitRedeclarable(VD);
1503  VisitDeclaratorDecl(VD);
1504 
1505  VD->VarDeclBits.SClass = (StorageClass)Record.readInt();
1506  VD->VarDeclBits.TSCSpec = Record.readInt();
1507  VD->VarDeclBits.InitStyle = Record.readInt();
1508  VD->VarDeclBits.ARCPseudoStrong = Record.readInt();
1509  if (!isa<ParmVarDecl>(VD)) {
1510  VD->NonParmVarDeclBits.IsThisDeclarationADemotedDefinition =
1511  Record.readInt();
1512  VD->NonParmVarDeclBits.ExceptionVar = Record.readInt();
1513  VD->NonParmVarDeclBits.NRVOVariable = Record.readInt();
1514  VD->NonParmVarDeclBits.CXXForRangeDecl = Record.readInt();
1515  VD->NonParmVarDeclBits.ObjCForDecl = Record.readInt();
1516  VD->NonParmVarDeclBits.IsInline = Record.readInt();
1517  VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
1518  VD->NonParmVarDeclBits.IsConstexpr = Record.readInt();
1519  VD->NonParmVarDeclBits.IsInitCapture = Record.readInt();
1520  VD->NonParmVarDeclBits.PreviousDeclInSameBlockScope = Record.readInt();
1521  VD->NonParmVarDeclBits.ImplicitParamKind = Record.readInt();
1522  VD->NonParmVarDeclBits.EscapingByref = Record.readInt();
1523  }
1524  auto VarLinkage = Linkage(Record.readInt());
1525  VD->setCachedLinkage(VarLinkage);
1526 
1527  // Reconstruct the one piece of the IdentifierNamespace that we need.
1528  if (VD->getStorageClass() == SC_Extern && VarLinkage != NoLinkage &&
1530  VD->setLocalExternDecl();
1531 
1532  if (uint64_t Val = Record.readInt()) {
1533  VD->setInit(Record.readExpr());
1534  if (Val != 1) {
1535  EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
1536  Eval->HasConstantInitialization = (Val & 2) != 0;
1537  Eval->HasConstantDestruction = (Val & 4) != 0;
1538  }
1539  }
1540 
1541  if (VD->hasAttr<BlocksAttr>() && VD->getType()->getAsCXXRecordDecl()) {
1542  Expr *CopyExpr = Record.readExpr();
1543  if (CopyExpr)
1544  Reader.getContext().setBlockVarCopyInit(VD, CopyExpr, Record.readInt());
1545  }
1546 
1547  if (VD->getStorageDuration() == SD_Static && Record.readInt()) {
1548  Reader.DefinitionSource[VD] =
1549  Loc.F->Kind == ModuleKind::MK_MainFile ||
1550  Reader.getContext().getLangOpts().BuildingPCHWithObjectFile;
1551  }
1552 
1553  enum VarKind {
1554  VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1555  };
1556  switch ((VarKind)Record.readInt()) {
1557  case VarNotTemplate:
1558  // Only true variables (not parameters or implicit parameters) can be
1559  // merged; the other kinds are not really redeclarable at all.
1560  if (!isa<ParmVarDecl>(VD) && !isa<ImplicitParamDecl>(VD) &&
1561  !isa<VarTemplateSpecializationDecl>(VD))
1562  mergeRedeclarable(VD, Redecl);
1563  break;
1564  case VarTemplate:
1565  // Merged when we merge the template.
1566  VD->setDescribedVarTemplate(readDeclAs<VarTemplateDecl>());
1567  break;
1568  case StaticDataMemberSpecialization: { // HasMemberSpecializationInfo.
1569  auto *Tmpl = readDeclAs<VarDecl>();
1570  auto TSK = (TemplateSpecializationKind)Record.readInt();
1571  SourceLocation POI = readSourceLocation();
1572  Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
1573  mergeRedeclarable(VD, Redecl);
1574  break;
1575  }
1576  }
1577 
1578  return Redecl;
1579 }
1580 
1582  VisitVarDecl(PD);
1583 }
1584 
1586  VisitVarDecl(PD);
1587  unsigned isObjCMethodParam = Record.readInt();
1588  unsigned scopeDepth = Record.readInt();
1589  unsigned scopeIndex = Record.readInt();
1590  unsigned declQualifier = Record.readInt();
1591  if (isObjCMethodParam) {
1592  assert(scopeDepth == 0);
1593  PD->setObjCMethodScopeInfo(scopeIndex);
1594  PD->ParmVarDeclBits.ScopeDepthOrObjCQuals = declQualifier;
1595  } else {
1596  PD->setScopeInfo(scopeDepth, scopeIndex);
1597  }
1598  PD->ParmVarDeclBits.IsKNRPromoted = Record.readInt();
1599  PD->ParmVarDeclBits.HasInheritedDefaultArg = Record.readInt();
1600  if (Record.readInt()) // hasUninstantiatedDefaultArg.
1601  PD->setUninstantiatedDefaultArg(Record.readExpr());
1602 
1603  // FIXME: If this is a redeclaration of a function from another module, handle
1604  // inheritance of default arguments.
1605 }
1606 
1608  VisitVarDecl(DD);
1609  auto **BDs = DD->getTrailingObjects<BindingDecl *>();
1610  for (unsigned I = 0; I != DD->NumBindings; ++I) {
1611  BDs[I] = readDeclAs<BindingDecl>();
1612  BDs[I]->setDecomposedDecl(DD);
1613  }
1614 }
1615 
1617  VisitValueDecl(BD);
1618  BD->Binding = Record.readExpr();
1619 }
1620 
1622  VisitDecl(AD);
1623  AD->setAsmString(cast<StringLiteral>(Record.readExpr()));
1624  AD->setRParenLoc(readSourceLocation());
1625 }
1626 
1628  VisitDecl(BD);
1629  BD->setBody(cast_or_null<CompoundStmt>(Record.readStmt()));
1630  BD->setSignatureAsWritten(readTypeSourceInfo());
1631  unsigned NumParams = Record.readInt();
1633  Params.reserve(NumParams);
1634  for (unsigned I = 0; I != NumParams; ++I)
1635  Params.push_back(readDeclAs<ParmVarDecl>());
1636  BD->setParams(Params);
1637 
1638  BD->setIsVariadic(Record.readInt());
1639  BD->setBlockMissingReturnType(Record.readInt());
1640  BD->setIsConversionFromLambda(Record.readInt());
1641  BD->setDoesNotEscape(Record.readInt());
1642  BD->setCanAvoidCopyToHeap(Record.readInt());
1643 
1644  bool capturesCXXThis = Record.readInt();
1645  unsigned numCaptures = Record.readInt();
1647  captures.reserve(numCaptures);
1648  for (unsigned i = 0; i != numCaptures; ++i) {
1649  auto *decl = readDeclAs<VarDecl>();
1650  unsigned flags = Record.readInt();
1651  bool byRef = (flags & 1);
1652  bool nested = (flags & 2);
1653  Expr *copyExpr = ((flags & 4) ? Record.readExpr() : nullptr);
1654 
1655  captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr));
1656  }
1657  BD->setCaptures(Reader.getContext(), captures, capturesCXXThis);
1658 }
1659 
1661  VisitDecl(CD);
1662  unsigned ContextParamPos = Record.readInt();
1663  CD->setNothrow(Record.readInt() != 0);
1664  // Body is set by VisitCapturedStmt.
1665  for (unsigned I = 0; I < CD->NumParams; ++I) {
1666  if (I != ContextParamPos)
1667  CD->setParam(I, readDeclAs<ImplicitParamDecl>());
1668  else
1669  CD->setContextParam(I, readDeclAs<ImplicitParamDecl>());
1670  }
1671 }
1672 
1674  VisitDecl(D);
1675  D->setLanguage((LinkageSpecDecl::LanguageIDs)Record.readInt());
1676  D->setExternLoc(readSourceLocation());
1677  D->setRBraceLoc(readSourceLocation());
1678 }
1679 
1681  VisitDecl(D);
1682  D->RBraceLoc = readSourceLocation();
1683 }
1684 
1686  VisitNamedDecl(D);
1687  D->setLocStart(readSourceLocation());
1688 }
1689 
1691  RedeclarableResult Redecl = VisitRedeclarable(D);
1692  VisitNamedDecl(D);
1693  D->setInline(Record.readInt());
1694  D->LocStart = readSourceLocation();
1695  D->RBraceLoc = readSourceLocation();
1696 
1697  // Defer loading the anonymous namespace until we've finished merging
1698  // this namespace; loading it might load a later declaration of the
1699  // same namespace, and we have an invariant that older declarations
1700  // get merged before newer ones try to merge.
1701  GlobalDeclID AnonNamespace = 0;
1702  if (Redecl.getFirstID() == ThisDeclID) {
1703  AnonNamespace = readDeclID();
1704  } else {
1705  // Link this namespace back to the first declaration, which has already
1706  // been deserialized.
1707  D->AnonOrFirstNamespaceAndInline.setPointer(D->getFirstDecl());
1708  }
1709 
1710  mergeRedeclarable(D, Redecl);
1711 
1712  if (AnonNamespace) {
1713  // Each module has its own anonymous namespace, which is disjoint from
1714  // any other module's anonymous namespaces, so don't attach the anonymous
1715  // namespace at all.
1716  auto *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
1717  if (!Record.isModule())
1718  D->setAnonymousNamespace(Anon);
1719  }
1720 }
1721 
1723  RedeclarableResult Redecl = VisitRedeclarable(D);
1724  VisitNamedDecl(D);
1725  D->NamespaceLoc = readSourceLocation();
1726  D->IdentLoc = readSourceLocation();
1727  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1728  D->Namespace = readDeclAs<NamedDecl>();
1729  mergeRedeclarable(D, Redecl);
1730 }
1731 
1733  VisitNamedDecl(D);
1734  D->setUsingLoc(readSourceLocation());
1735  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1736  D->DNLoc = Record.readDeclarationNameLoc(D->getDeclName());
1737  D->FirstUsingShadow.setPointer(readDeclAs<UsingShadowDecl>());
1738  D->setTypename(Record.readInt());
1739  if (auto *Pattern = readDeclAs<NamedDecl>())
1740  Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
1741  mergeMergeable(D);
1742 }
1743 
1745  VisitNamedDecl(D);
1746  D->setUsingLoc(readSourceLocation());
1747  D->setEnumLoc(readSourceLocation());
1748  D->Enum = readDeclAs<EnumDecl>();
1749  D->FirstUsingShadow.setPointer(readDeclAs<UsingShadowDecl>());
1750  if (auto *Pattern = readDeclAs<UsingEnumDecl>())
1751  Reader.getContext().setInstantiatedFromUsingEnumDecl(D, Pattern);
1752  mergeMergeable(D);
1753 }
1754 
1756  VisitNamedDecl(D);
1757  D->InstantiatedFrom = readDeclAs<NamedDecl>();
1758  auto **Expansions = D->getTrailingObjects<NamedDecl *>();
1759  for (unsigned I = 0; I != D->NumExpansions; ++I)
1760  Expansions[I] = readDeclAs<NamedDecl>();
1761  mergeMergeable(D);
1762 }
1763 
1765  RedeclarableResult Redecl = VisitRedeclarable(D);
1766  VisitNamedDecl(D);
1767  D->Underlying = readDeclAs<NamedDecl>();
1768  D->IdentifierNamespace = Record.readInt();
1769  D->UsingOrNextShadow = readDeclAs<NamedDecl>();
1770  auto *Pattern = readDeclAs<UsingShadowDecl>();
1771  if (Pattern)
1772  Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern);
1773  mergeRedeclarable(D, Redecl);
1774 }
1775 
1778  VisitUsingShadowDecl(D);
1779  D->NominatedBaseClassShadowDecl = readDeclAs<ConstructorUsingShadowDecl>();
1780  D->ConstructedBaseClassShadowDecl = readDeclAs<ConstructorUsingShadowDecl>();
1781  D->IsVirtual = Record.readInt();
1782 }
1783 
1785  VisitNamedDecl(D);
1786  D->UsingLoc = readSourceLocation();
1787  D->NamespaceLoc = readSourceLocation();
1788  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1789  D->NominatedNamespace = readDeclAs<NamedDecl>();
1790  D->CommonAncestor = readDeclAs<DeclContext>();
1791 }
1792 
1794  VisitValueDecl(D);
1795  D->setUsingLoc(readSourceLocation());
1796  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1797  D->DNLoc = Record.readDeclarationNameLoc(D->getDeclName());
1798  D->EllipsisLoc = readSourceLocation();
1799  mergeMergeable(D);
1800 }
1801 
1804  VisitTypeDecl(D);
1805  D->TypenameLocation = readSourceLocation();
1806  D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1807  D->EllipsisLoc = readSourceLocation();
1808  mergeMergeable(D);
1809 }
1810 
1813  VisitNamedDecl(D);
1814 }
1815 
1816 void ASTDeclReader::ReadCXXDefinitionData(
1817  struct CXXRecordDecl::DefinitionData &Data, const CXXRecordDecl *D) {
1818  #define FIELD(Name, Width, Merge) \
1819  Data.Name = Record.readInt();
1820  #include "clang/AST/CXXRecordDeclDefinitionBits.def"
1821 
1822  // Note: the caller has deserialized the IsLambda bit already.
1823  Data.ODRHash = Record.readInt();
1824  Data.HasODRHash = true;
1825 
1826  if (Record.readInt()) {
1827  Reader.DefinitionSource[D] =
1828  Loc.F->Kind == ModuleKind::MK_MainFile ||
1829  Reader.getContext().getLangOpts().BuildingPCHWithObjectFile;
1830  }
1831 
1832  Data.NumBases = Record.readInt();
1833  if (Data.NumBases)
1834  Data.Bases = ReadGlobalOffset();
1835  Data.NumVBases = Record.readInt();
1836  if (Data.NumVBases)
1837  Data.VBases = ReadGlobalOffset();
1838 
1839  Record.readUnresolvedSet(Data.Conversions);
1840  Data.ComputedVisibleConversions = Record.readInt();
1841  if (Data.ComputedVisibleConversions)
1842  Record.readUnresolvedSet(Data.VisibleConversions);
1843  assert(Data.Definition && "Data.Definition should be already set!");
1844  Data.FirstFriend = readDeclID();
1845 
1846  if (Data.IsLambda) {
1847  using Capture = LambdaCapture;
1848 
1849  auto &Lambda = static_cast<CXXRecordDecl::LambdaDefinitionData &>(Data);
1850  Lambda.DependencyKind = Record.readInt();
1851  Lambda.IsGenericLambda = Record.readInt();
1852  Lambda.CaptureDefault = Record.readInt();
1853  Lambda.NumCaptures = Record.readInt();
1854  Lambda.NumExplicitCaptures = Record.readInt();
1855  Lambda.HasKnownInternalLinkage = Record.readInt();
1856  Lambda.ManglingNumber = Record.readInt();
1857  D->setDeviceLambdaManglingNumber(Record.readInt());
1858  Lambda.ContextDecl = readDeclID();
1859  Lambda.Captures = (Capture *)Reader.getContext().Allocate(
1860  sizeof(Capture) * Lambda.NumCaptures);
1861  Capture *ToCapture = Lambda.Captures;
1862  Lambda.MethodTyInfo = readTypeSourceInfo();
1863  for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
1864  SourceLocation Loc = readSourceLocation();
1865  bool IsImplicit = Record.readInt();
1866  auto Kind = static_cast<LambdaCaptureKind>(Record.readInt());
1867  switch (Kind) {
1868  case LCK_StarThis:
1869  case LCK_This:
1870  case LCK_VLAType:
1871  *ToCapture++ = Capture(Loc, IsImplicit, Kind, nullptr,SourceLocation());
1872  break;
1873  case LCK_ByCopy:
1874  case LCK_ByRef:
1875  auto *Var = readDeclAs<VarDecl>();
1876  SourceLocation EllipsisLoc = readSourceLocation();
1877  *ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
1878  break;
1879  }
1880  }
1881  }
1882 }
1883 
1884 void ASTDeclReader::MergeDefinitionData(
1885  CXXRecordDecl *D, struct CXXRecordDecl::DefinitionData &&MergeDD) {
1886  assert(D->DefinitionData &&
1887  "merging class definition into non-definition");
1888  auto &DD = *D->DefinitionData;
1889 
1890  if (DD.Definition != MergeDD.Definition) {
1891  // Track that we merged the definitions.
1892  Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition,
1893  DD.Definition));
1894  Reader.PendingDefinitions.erase(MergeDD.Definition);
1895  MergeDD.Definition->setCompleteDefinition(false);
1896  Reader.mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
1897  assert(Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() &&
1898  "already loaded pending lookups for merged definition");
1899  }
1900 
1901  auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
1902  if (PFDI != Reader.PendingFakeDefinitionData.end() &&
1903  PFDI->second == ASTReader::PendingFakeDefinitionKind::Fake) {
1904  // We faked up this definition data because we found a class for which we'd
1905  // not yet loaded the definition. Replace it with the real thing now.
1906  assert(!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?");
1907  PFDI->second = ASTReader::PendingFakeDefinitionKind::FakeLoaded;
1908 
1909  // Don't change which declaration is the definition; that is required
1910  // to be invariant once we select it.
1911  auto *Def = DD.Definition;
1912  DD = std::move(MergeDD);
1913  DD.Definition = Def;
1914  return;
1915  }
1916 
1917  bool DetectedOdrViolation = false;
1918 
1919  #define FIELD(Name, Width, Merge) Merge(Name)
1920  #define MERGE_OR(Field) DD.Field |= MergeDD.Field;
1921  #define NO_MERGE(Field) \
1922  DetectedOdrViolation |= DD.Field != MergeDD.Field; \
1923  MERGE_OR(Field)
1924  #include "clang/AST/CXXRecordDeclDefinitionBits.def"
1925  NO_MERGE(IsLambda)
1926  #undef NO_MERGE
1927  #undef MERGE_OR
1928 
1929  if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases)
1930  DetectedOdrViolation = true;
1931  // FIXME: Issue a diagnostic if the base classes don't match when we come
1932  // to lazily load them.
1933 
1934  // FIXME: Issue a diagnostic if the list of conversion functions doesn't
1935  // match when we come to lazily load them.
1936  if (MergeDD.ComputedVisibleConversions && !DD.ComputedVisibleConversions) {
1937  DD.VisibleConversions = std::move(MergeDD.VisibleConversions);
1938  DD.ComputedVisibleConversions = true;
1939  }
1940 
1941  // FIXME: Issue a diagnostic if FirstFriend doesn't match when we come to
1942  // lazily load it.
1943 
1944  if (DD.IsLambda) {
1945  // FIXME: ODR-checking for merging lambdas (this happens, for instance,
1946  // when they occur within the body of a function template specialization).
1947  }
1948 
1949  if (D->getODRHash() != MergeDD.ODRHash) {
1950  DetectedOdrViolation = true;
1951  }
1952 
1953  if (DetectedOdrViolation)
1954  Reader.PendingOdrMergeFailures[DD.Definition].push_back(
1955  {MergeDD.Definition, &MergeDD});
1956 }
1957 
1958 void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update) {
1959  struct CXXRecordDecl::DefinitionData *DD;
1960  ASTContext &C = Reader.getContext();
1961 
1962  // Determine whether this is a lambda closure type, so that we can
1963  // allocate the appropriate DefinitionData structure.
1964  bool IsLambda = Record.readInt();
1965  if (IsLambda)
1966  DD = new (C) CXXRecordDecl::LambdaDefinitionData(
1967  D, nullptr, CXXRecordDecl::LDK_Unknown, false, LCD_None);
1968  else
1969  DD = new (C) struct CXXRecordDecl::DefinitionData(D);
1970 
1971  CXXRecordDecl *Canon = D->getCanonicalDecl();
1972  // Set decl definition data before reading it, so that during deserialization
1973  // when we read CXXRecordDecl, it already has definition data and we don't
1974  // set fake one.
1975  if (!Canon->DefinitionData)
1976  Canon->DefinitionData = DD;
1977  D->DefinitionData = Canon->DefinitionData;
1978  ReadCXXDefinitionData(*DD, D);
1979 
1980  // We might already have a different definition for this record. This can
1981  // happen either because we're reading an update record, or because we've
1982  // already done some merging. Either way, just merge into it.
1983  if (Canon->DefinitionData != DD) {
1984  MergeDefinitionData(Canon, std::move(*DD));
1985  return;
1986  }
1987 
1988  // Mark this declaration as being a definition.
1989  D->setCompleteDefinition(true);
1990 
1991  // If this is not the first declaration or is an update record, we can have
1992  // other redeclarations already. Make a note that we need to propagate the
1993  // DefinitionData pointer onto them.
1994  if (Update || Canon != D)
1995  Reader.PendingDefinitions.insert(D);
1996 }
1997 
1998 ASTDeclReader::RedeclarableResult
2000  RedeclarableResult Redecl = VisitRecordDeclImpl(D);
2001 
2002  ASTContext &C = Reader.getContext();
2003 
2004  enum CXXRecKind {
2005  CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
2006  };
2007  switch ((CXXRecKind)Record.readInt()) {
2008  case CXXRecNotTemplate:
2009  // Merged when we merge the folding set entry in the primary template.
2010  if (!isa<ClassTemplateSpecializationDecl>(D))
2011  mergeRedeclarable(D, Redecl);
2012  break;
2013  case CXXRecTemplate: {
2014  // Merged when we merge the template.
2015  auto *Template = readDeclAs<ClassTemplateDecl>();
2016  D->TemplateOrInstantiation = Template;
2017  if (!Template->getTemplatedDecl()) {
2018  // We've not actually loaded the ClassTemplateDecl yet, because we're
2019  // currently being loaded as its pattern. Rely on it to set up our
2020  // TypeForDecl (see VisitClassTemplateDecl).
2021  //
2022  // Beware: we do not yet know our canonical declaration, and may still
2023  // get merged once the surrounding class template has got off the ground.
2024  DeferredTypeID = 0;
2025  }
2026  break;
2027  }
2028  case CXXRecMemberSpecialization: {
2029  auto *RD = readDeclAs<CXXRecordDecl>();
2030  auto TSK = (TemplateSpecializationKind)Record.readInt();
2031  SourceLocation POI = readSourceLocation();
2032  MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK);
2033  MSI->setPointOfInstantiation(POI);
2034  D->TemplateOrInstantiation = MSI;
2035  mergeRedeclarable(D, Redecl);
2036  break;
2037  }
2038  }
2039 
2040  bool WasDefinition = Record.readInt();
2041  if (WasDefinition)
2042  ReadCXXRecordDefinition(D, /*Update*/false);
2043  else
2044  // Propagate DefinitionData pointer from the canonical declaration.
2045  D->DefinitionData = D->getCanonicalDecl()->DefinitionData;
2046 
2047  // Lazily load the key function to avoid deserializing every method so we can
2048  // compute it.
2049  if (WasDefinition) {
2050  DeclID KeyFn = readDeclID();
2051  if (KeyFn && D->isCompleteDefinition())
2052  // FIXME: This is wrong for the ARM ABI, where some other module may have
2053  // made this function no longer be a key function. We need an update
2054  // record or similar for that case.
2055  C.KeyFunctions[D] = KeyFn;
2056  }
2057 
2058  return Redecl;
2059 }
2060 
2062  D->setExplicitSpecifier(Record.readExplicitSpec());
2063  D->Ctor = readDeclAs<CXXConstructorDecl>();
2064  VisitFunctionDecl(D);
2065  D->setIsCopyDeductionCandidate(Record.readInt());
2066 }
2067 
2069  VisitFunctionDecl(D);
2070 
2071  unsigned NumOverridenMethods = Record.readInt();
2072  if (D->isCanonicalDecl()) {
2073  while (NumOverridenMethods--) {
2074  // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
2075  // MD may be initializing.
2076  if (auto *MD = readDeclAs<CXXMethodDecl>())
2077  Reader.getContext().addOverriddenMethod(D, MD->getCanonicalDecl());
2078  }
2079  } else {
2080  // We don't care about which declarations this used to override; we get
2081  // the relevant information from the canonical declaration.
2082  Record.skipInts(NumOverridenMethods);
2083  }
2084 }
2085 
2087  // We need the inherited constructor information to merge the declaration,
2088  // so we have to read it before we call VisitCXXMethodDecl.
2089  D->setExplicitSpecifier(Record.readExplicitSpec());
2090  if (D->isInheritingConstructor()) {
2091  auto *Shadow = readDeclAs<ConstructorUsingShadowDecl>();
2092  auto *Ctor = readDeclAs<CXXConstructorDecl>();
2093  *D->getTrailingObjects<InheritedConstructor>() =
2094  InheritedConstructor(Shadow, Ctor);
2095  }
2096 
2097  VisitCXXMethodDecl(D);
2098 }
2099 
2101  VisitCXXMethodDecl(D);
2102 
2103  if (auto *OperatorDelete = readDeclAs<FunctionDecl>()) {
2104  CXXDestructorDecl *Canon = D->getCanonicalDecl();
2105  auto *ThisArg = Record.readExpr();
2106  // FIXME: Check consistency if we have an old and new operator delete.
2107  if (!Canon->OperatorDelete) {
2108  Canon->OperatorDelete = OperatorDelete;
2109  Canon->OperatorDeleteThisArg = ThisArg;
2110  }
2111  }
2112 }
2113 
2115  D->setExplicitSpecifier(Record.readExplicitSpec());
2116  VisitCXXMethodDecl(D);
2117 }
2118 
2120  VisitDecl(D);
2121  D->ImportedModule = readModule();
2122  D->setImportComplete(Record.readInt());
2123  auto *StoredLocs = D->getTrailingObjects<SourceLocation>();
2124  for (unsigned I = 0, N = Record.back(); I != N; ++I)
2125  StoredLocs[I] = readSourceLocation();
2126  Record.skipInts(1); // The number of stored source locations.
2127 }
2128 
2130  VisitDecl(D);
2131  D->setColonLoc(readSourceLocation());
2132 }
2133 
2135  VisitDecl(D);
2136  if (Record.readInt()) // hasFriendDecl
2137  D->Friend = readDeclAs<NamedDecl>();
2138  else
2139  D->Friend = readTypeSourceInfo();
2140  for (unsigned i = 0; i != D->NumTPLists; ++i)
2141  D->getTrailingObjects<TemplateParameterList *>()[i] =
2142  Record.readTemplateParameterList();
2143  D->NextFriend = readDeclID();
2144  D->UnsupportedFriend = (Record.readInt() != 0);
2145  D->FriendLoc = readSourceLocation();
2146 }
2147 
2149  VisitDecl(D);
2150  unsigned NumParams = Record.readInt();
2151  D->NumParams = NumParams;
2152  D->Params = new (Reader.getContext()) TemplateParameterList *[NumParams];
2153  for (unsigned i = 0; i != NumParams; ++i)
2154  D->Params[i] = Record.readTemplateParameterList();
2155  if (Record.readInt()) // HasFriendDecl
2156  D->Friend = readDeclAs<NamedDecl>();
2157  else
2158  D->Friend = readTypeSourceInfo();
2159  D->FriendLoc = readSourceLocation();
2160 }
2161 
2163  VisitNamedDecl(D);
2164 
2165  DeclID PatternID = readDeclID();
2166  auto *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
2167  TemplateParameterList *TemplateParams = Record.readTemplateParameterList();
2168  D->init(TemplatedDecl, TemplateParams);
2169 
2170  return PatternID;
2171 }
2172 
2174  VisitTemplateDecl(D);
2175  D->ConstraintExpr = Record.readExpr();
2176  mergeMergeable(D);
2177 }
2178 
2180 }
2181 
2182 ASTDeclReader::RedeclarableResult
2184  RedeclarableResult Redecl = VisitRedeclarable(D);
2185 
2186  // Make sure we've allocated the Common pointer first. We do this before
2187  // VisitTemplateDecl so that getCommonPtr() can be used during initialization.
2189  if (!CanonD->Common) {
2190  CanonD->Common = CanonD->newCommon(Reader.getContext());
2191  Reader.PendingDefinitions.insert(CanonD);
2192  }
2193  D->Common = CanonD->Common;
2194 
2195  // If this is the first declaration of the template, fill in the information
2196  // for the 'common' pointer.
2197  if (ThisDeclID == Redecl.getFirstID()) {
2198  if (auto *RTD = readDeclAs<RedeclarableTemplateDecl>()) {
2199  assert(RTD->getKind() == D->getKind() &&
2200  "InstantiatedFromMemberTemplate kind mismatch");
2202  if (Record.readInt())
2204  }
2205  }
2206 
2207  DeclID PatternID = VisitTemplateDecl(D);
2208  D->IdentifierNamespace = Record.readInt();
2209 
2210  mergeRedeclarable(D, Redecl, PatternID);
2211 
2212  // If we merged the template with a prior declaration chain, merge the common
2213  // pointer.
2214  // FIXME: Actually merge here, don't just overwrite.
2215  D->Common = D->getCanonicalDecl()->Common;
2216 
2217  return Redecl;
2218 }
2219 
2221  RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2222 
2223  if (ThisDeclID == Redecl.getFirstID()) {
2224  // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of
2225  // the specializations.
2227  readDeclIDList(SpecIDs);
2229  }
2230 
2231  if (D->getTemplatedDecl()->TemplateOrInstantiation) {
2232  // We were loaded before our templated declaration was. We've not set up
2233  // its corresponding type yet (see VisitCXXRecordDeclImpl), so reconstruct
2234  // it now.
2235  Reader.getContext().getInjectedClassNameType(
2237  }
2238 }
2239 
2241  llvm_unreachable("BuiltinTemplates are not serialized");
2242 }
2243 
2244 /// TODO: Unify with ClassTemplateDecl version?
2245 /// May require unifying ClassTemplateDecl and
2246 /// VarTemplateDecl beyond TemplateDecl...
2248  RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2249 
2250  if (ThisDeclID == Redecl.getFirstID()) {
2251  // This VarTemplateDecl owns a CommonPtr; read it to keep track of all of
2252  // the specializations.
2254  readDeclIDList(SpecIDs);
2256  }
2257 }
2258 
2259 ASTDeclReader::RedeclarableResult
2262  RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D);
2263 
2264  ASTContext &C = Reader.getContext();
2265  if (Decl *InstD = readDecl()) {
2266  if (auto *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
2267  D->SpecializedTemplate = CTD;
2268  } else {
2270  Record.readTemplateArgumentList(TemplArgs);
2271  TemplateArgumentList *ArgList
2272  = TemplateArgumentList::CreateCopy(C, TemplArgs);
2273  auto *PS =
2275  SpecializedPartialSpecialization();
2276  PS->PartialSpecialization
2277  = cast<ClassTemplatePartialSpecializationDecl>(InstD);
2278  PS->TemplateArgs = ArgList;
2279  D->SpecializedTemplate = PS;
2280  }
2281  }
2282 
2284  Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
2285  D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
2286  D->PointOfInstantiation = readSourceLocation();
2287  D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
2288 
2289  bool writtenAsCanonicalDecl = Record.readInt();
2290  if (writtenAsCanonicalDecl) {
2291  auto *CanonPattern = readDeclAs<ClassTemplateDecl>();
2292  if (D->isCanonicalDecl()) { // It's kept in the folding set.
2293  // Set this as, or find, the canonical declaration for this specialization
2295  if (auto *Partial = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
2296  CanonSpec = CanonPattern->getCommonPtr()->PartialSpecializations
2297  .GetOrInsertNode(Partial);
2298  } else {
2299  CanonSpec =
2300  CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2301  }
2302  // If there was already a canonical specialization, merge into it.
2303  if (CanonSpec != D) {
2304  mergeRedeclarable<TagDecl>(D, CanonSpec, Redecl);
2305 
2306  // This declaration might be a definition. Merge with any existing
2307  // definition.
2308  if (auto *DDD = D->DefinitionData) {
2309  if (CanonSpec->DefinitionData)
2310  MergeDefinitionData(CanonSpec, std::move(*DDD));
2311  else
2312  CanonSpec->DefinitionData = D->DefinitionData;
2313  }
2314  D->DefinitionData = CanonSpec->DefinitionData;
2315  }
2316  }
2317  }
2318 
2319  // Explicit info.
2320  if (TypeSourceInfo *TyInfo = readTypeSourceInfo()) {
2321  auto *ExplicitInfo =
2322  new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
2323  ExplicitInfo->TypeAsWritten = TyInfo;
2324  ExplicitInfo->ExternLoc = readSourceLocation();
2325  ExplicitInfo->TemplateKeywordLoc = readSourceLocation();
2326  D->ExplicitInfo = ExplicitInfo;
2327  }
2328 
2329  return Redecl;
2330 }
2331 
2334  // We need to read the template params first because redeclarable is going to
2335  // need them for profiling
2336  TemplateParameterList *Params = Record.readTemplateParameterList();
2337  D->TemplateParams = Params;
2338  D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2339 
2340  RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
2341 
2342  // These are read/set from/to the first declaration.
2343  if (ThisDeclID == Redecl.getFirstID()) {
2344  D->InstantiatedFromMember.setPointer(
2345  readDeclAs<ClassTemplatePartialSpecializationDecl>());
2346  D->InstantiatedFromMember.setInt(Record.readInt());
2347  }
2348 }
2349 
2352  VisitDecl(D);
2353  D->Specialization = readDeclAs<CXXMethodDecl>();
2354  if (Record.readInt())
2355  D->TemplateArgs = Record.readASTTemplateArgumentListInfo();
2356 }
2357 
2359  RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2360 
2361  if (ThisDeclID == Redecl.getFirstID()) {
2362  // This FunctionTemplateDecl owns a CommonPtr; read it.
2364  readDeclIDList(SpecIDs);
2366  }
2367 }
2368 
2369 /// TODO: Unify with ClassTemplateSpecializationDecl version?
2370 /// May require unifying ClassTemplate(Partial)SpecializationDecl and
2371 /// VarTemplate(Partial)SpecializationDecl with a new data
2372 /// structure Template(Partial)SpecializationDecl, and
2373 /// using Template(Partial)SpecializationDecl as input type.
2374 ASTDeclReader::RedeclarableResult
2377  RedeclarableResult Redecl = VisitVarDeclImpl(D);
2378 
2379  ASTContext &C = Reader.getContext();
2380  if (Decl *InstD = readDecl()) {
2381  if (auto *VTD = dyn_cast<VarTemplateDecl>(InstD)) {
2382  D->SpecializedTemplate = VTD;
2383  } else {
2385  Record.readTemplateArgumentList(TemplArgs);
2387  C, TemplArgs);
2388  auto *PS =
2389  new (C)
2390  VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
2391  PS->PartialSpecialization =
2392  cast<VarTemplatePartialSpecializationDecl>(InstD);
2393  PS->TemplateArgs = ArgList;
2394  D->SpecializedTemplate = PS;
2395  }
2396  }
2397 
2398  // Explicit info.
2399  if (TypeSourceInfo *TyInfo = readTypeSourceInfo()) {
2400  auto *ExplicitInfo =
2401  new (C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo;
2402  ExplicitInfo->TypeAsWritten = TyInfo;
2403  ExplicitInfo->ExternLoc = readSourceLocation();
2404  ExplicitInfo->TemplateKeywordLoc = readSourceLocation();
2405  D->ExplicitInfo = ExplicitInfo;
2406  }
2407 
2409  Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
2410  D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
2411  D->PointOfInstantiation = readSourceLocation();
2412  D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
2413  D->IsCompleteDefinition = Record.readInt();
2414 
2415  bool writtenAsCanonicalDecl = Record.readInt();
2416  if (writtenAsCanonicalDecl) {
2417  auto *CanonPattern = readDeclAs<VarTemplateDecl>();
2418  if (D->isCanonicalDecl()) { // It's kept in the folding set.
2419  VarTemplateSpecializationDecl *CanonSpec;
2420  if (auto *Partial = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
2421  CanonSpec = CanonPattern->getCommonPtr()
2422  ->PartialSpecializations.GetOrInsertNode(Partial);
2423  } else {
2424  CanonSpec =
2425  CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2426  }
2427  // If we already have a matching specialization, merge it.
2428  if (CanonSpec != D)
2429  mergeRedeclarable<VarDecl>(D, CanonSpec, Redecl);
2430  }
2431  }
2432 
2433  return Redecl;
2434 }
2435 
2436 /// TODO: Unify with ClassTemplatePartialSpecializationDecl version?
2437 /// May require unifying ClassTemplate(Partial)SpecializationDecl and
2438 /// VarTemplate(Partial)SpecializationDecl with a new data
2439 /// structure Template(Partial)SpecializationDecl, and
2440 /// using Template(Partial)SpecializationDecl as input type.
2443  TemplateParameterList *Params = Record.readTemplateParameterList();
2444  D->TemplateParams = Params;
2445  D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2446 
2447  RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
2448 
2449  // These are read/set from/to the first declaration.
2450  if (ThisDeclID == Redecl.getFirstID()) {
2451  D->InstantiatedFromMember.setPointer(
2452  readDeclAs<VarTemplatePartialSpecializationDecl>());
2453  D->InstantiatedFromMember.setInt(Record.readInt());
2454  }
2455 }
2456 
2458  VisitTypeDecl(D);
2459 
2460  D->setDeclaredWithTypename(Record.readInt());
2461 
2462  if (Record.readBool()) {
2463  NestedNameSpecifierLoc NNS = Record.readNestedNameSpecifierLoc();
2464  DeclarationNameInfo DN = Record.readDeclarationNameInfo();
2465  ConceptDecl *NamedConcept = Record.readDeclAs<ConceptDecl>();
2466  const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr;
2467  if (Record.readBool())
2468  ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2469  Expr *ImmediatelyDeclaredConstraint = Record.readExpr();
2470  D->setTypeConstraint(NNS, DN, /*FoundDecl=*/nullptr, NamedConcept,
2471  ArgsAsWritten, ImmediatelyDeclaredConstraint);
2472  if ((D->ExpandedParameterPack = Record.readInt()))
2473  D->NumExpanded = Record.readInt();
2474  }
2475 
2476  if (Record.readInt())
2477  D->setDefaultArgument(readTypeSourceInfo());
2478 }
2479 
2481  VisitDeclaratorDecl(D);
2482  // TemplateParmPosition.
2483  D->setDepth(Record.readInt());
2484  D->setPosition(Record.readInt());
2486  D->setPlaceholderTypeConstraint(Record.readExpr());
2487  if (D->isExpandedParameterPack()) {
2488  auto TypesAndInfos =
2489  D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
2490  for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2491  new (&TypesAndInfos[I].first) QualType(Record.readType());
2492  TypesAndInfos[I].second = readTypeSourceInfo();
2493  }
2494  } else {
2495  // Rest of NonTypeTemplateParmDecl.
2496  D->ParameterPack = Record.readInt();
2497  if (Record.readInt())
2498  D->setDefaultArgument(Record.readExpr());
2499  }
2500 }
2501 
2503  VisitTemplateDecl(D);
2504  // TemplateParmPosition.
2505  D->setDepth(Record.readInt());
2506  D->setPosition(Record.readInt());
2507  if (D->isExpandedParameterPack()) {
2508  auto **Data = D->getTrailingObjects<TemplateParameterList *>();
2509  for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2510  I != N; ++I)
2511  Data[I] = Record.readTemplateParameterList();
2512  } else {
2513  // Rest of TemplateTemplateParmDecl.
2514  D->ParameterPack = Record.readInt();
2515  if (Record.readInt())
2516  D->setDefaultArgument(Reader.getContext(),
2517  Record.readTemplateArgumentLoc());
2518  }
2519 }
2520 
2522  VisitRedeclarableTemplateDecl(D);
2523 }
2524 
2526  VisitDecl(D);
2527  D->AssertExprAndFailed.setPointer(Record.readExpr());
2528  D->AssertExprAndFailed.setInt(Record.readInt());
2529  D->Message = cast_or_null<StringLiteral>(Record.readExpr());
2530  D->RParenLoc = readSourceLocation();
2531 }
2532 
2534  VisitDecl(D);
2535 }
2536 
2539  VisitDecl(D);
2540  D->ExtendingDecl = readDeclAs<ValueDecl>();
2541  D->ExprWithTemporary = Record.readStmt();
2542  if (Record.readInt()) {
2543  D->Value = new (D->getASTContext()) APValue(Record.readAPValue());
2544  D->getASTContext().addDestruction(D->Value);
2545  }
2546  D->ManglingNumber = Record.readInt();
2547  mergeMergeable(D);
2548 }
2549 
2550 std::pair<uint64_t, uint64_t>
2552  uint64_t LexicalOffset = ReadLocalOffset();
2553  uint64_t VisibleOffset = ReadLocalOffset();
2554  return std::make_pair(LexicalOffset, VisibleOffset);
2555 }
2556 
2557 template <typename T>
2558 ASTDeclReader::RedeclarableResult
2560  DeclID FirstDeclID = readDeclID();
2561  Decl *MergeWith = nullptr;
2562 
2563  bool IsKeyDecl = ThisDeclID == FirstDeclID;
2564  bool IsFirstLocalDecl = false;
2565 
2566  uint64_t RedeclOffset = 0;
2567 
2568  // 0 indicates that this declaration was the only declaration of its entity,
2569  // and is used for space optimization.
2570  if (FirstDeclID == 0) {
2571  FirstDeclID = ThisDeclID;
2572  IsKeyDecl = true;
2573  IsFirstLocalDecl = true;
2574  } else if (unsigned N = Record.readInt()) {
2575  // This declaration was the first local declaration, but may have imported
2576  // other declarations.
2577  IsKeyDecl = N == 1;
2578  IsFirstLocalDecl = true;
2579 
2580  // We have some declarations that must be before us in our redeclaration
2581  // chain. Read them now, and remember that we ought to merge with one of
2582  // them.
2583  // FIXME: Provide a known merge target to the second and subsequent such
2584  // declaration.
2585  for (unsigned I = 0; I != N - 1; ++I)
2586  MergeWith = readDecl();
2587 
2588  RedeclOffset = ReadLocalOffset();
2589  } else {
2590  // This declaration was not the first local declaration. Read the first
2591  // local declaration now, to trigger the import of other redeclarations.
2592  (void)readDecl();
2593  }
2594 
2595  auto *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID));
2596  if (FirstDecl != D) {
2597  // We delay loading of the redeclaration chain to avoid deeply nested calls.
2598  // We temporarily set the first (canonical) declaration as the previous one
2599  // which is the one that matters and mark the real previous DeclID to be
2600  // loaded & attached later on.
2602  D->First = FirstDecl->getCanonicalDecl();
2603  }
2604 
2605  auto *DAsT = static_cast<T *>(D);
2606 
2607  // Note that we need to load local redeclarations of this decl and build a
2608  // decl chain for them. This must happen *after* we perform the preloading
2609  // above; this ensures that the redeclaration chain is built in the correct
2610  // order.
2611  if (IsFirstLocalDecl)
2612  Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset));
2613 
2614  return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl);
2615 }
2616 
2617 /// Attempts to merge the given declaration (D) with another declaration
2618 /// of the same entity.
2619 template<typename T>
2621  RedeclarableResult &Redecl,
2622  DeclID TemplatePatternID) {
2623  // If modules are not available, there is no reason to perform this merge.
2624  if (!Reader.getContext().getLangOpts().Modules)
2625  return;
2626 
2627  // If we're not the canonical declaration, we don't need to merge.
2628  if (!DBase->isFirstDecl())
2629  return;
2630 
2631  auto *D = static_cast<T *>(DBase);
2632 
2633  if (auto *Existing = Redecl.getKnownMergeTarget())
2634  // We already know of an existing declaration we should merge with.
2635  mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID);
2636  else if (FindExistingResult ExistingRes = findExisting(D))
2637  if (T *Existing = ExistingRes)
2638  mergeRedeclarable(D, Existing, Redecl, TemplatePatternID);
2639 }
2640 
2641 /// "Cast" to type T, asserting if we don't have an implicit conversion.
2642 /// We use this to put code in a template that will only be valid for certain
2643 /// instantiations.
2644 template<typename T> static T assert_cast(T t) { return t; }
2645 template<typename T> static T assert_cast(...) {
2646  llvm_unreachable("bad assert_cast");
2647 }
2648 
2649 /// Merge together the pattern declarations from two template
2650 /// declarations.
2652  RedeclarableTemplateDecl *Existing,
2653  DeclID DsID, bool IsKeyDecl) {
2654  auto *DPattern = D->getTemplatedDecl();
2655  auto *ExistingPattern = Existing->getTemplatedDecl();
2656  RedeclarableResult Result(/*MergeWith*/ ExistingPattern,
2657  DPattern->getCanonicalDecl()->getGlobalID(),
2658  IsKeyDecl);
2659 
2660  if (auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) {
2661  // Merge with any existing definition.
2662  // FIXME: This is duplicated in several places. Refactor.
2663  auto *ExistingClass =
2664  cast<CXXRecordDecl>(ExistingPattern)->getCanonicalDecl();
2665  if (auto *DDD = DClass->DefinitionData) {
2666  if (ExistingClass->DefinitionData) {
2667  MergeDefinitionData(ExistingClass, std::move(*DDD));
2668  } else {
2669  ExistingClass->DefinitionData = DClass->DefinitionData;
2670  // We may have skipped this before because we thought that DClass
2671  // was the canonical declaration.
2672  Reader.PendingDefinitions.insert(DClass);
2673  }
2674  }
2675  DClass->DefinitionData = ExistingClass->DefinitionData;
2676 
2677  return mergeRedeclarable(DClass, cast<TagDecl>(ExistingPattern),
2678  Result);
2679  }
2680  if (auto *DFunction = dyn_cast<FunctionDecl>(DPattern))
2681  return mergeRedeclarable(DFunction, cast<FunctionDecl>(ExistingPattern),
2682  Result);
2683  if (auto *DVar = dyn_cast<VarDecl>(DPattern))
2684  return mergeRedeclarable(DVar, cast<VarDecl>(ExistingPattern), Result);
2685  if (auto *DAlias = dyn_cast<TypeAliasDecl>(DPattern))
2686  return mergeRedeclarable(DAlias, cast<TypedefNameDecl>(ExistingPattern),
2687  Result);
2688  llvm_unreachable("merged an unknown kind of redeclarable template");
2689 }
2690 
2691 /// Attempts to merge the given declaration (D) with another declaration
2692 /// of the same entity.
2693 template<typename T>
2695  RedeclarableResult &Redecl,
2696  DeclID TemplatePatternID) {
2697  auto *D = static_cast<T *>(DBase);
2698  T *ExistingCanon = Existing->getCanonicalDecl();
2699  T *DCanon = D->getCanonicalDecl();
2700  if (ExistingCanon != DCanon) {
2701  assert(DCanon->getGlobalID() == Redecl.getFirstID() &&
2702  "already merged this declaration");
2703 
2704  // Have our redeclaration link point back at the canonical declaration
2705  // of the existing declaration, so that this declaration has the
2706  // appropriate canonical declaration.
2707  D->RedeclLink = Redeclarable<T>::PreviousDeclLink(ExistingCanon);
2708  D->First = ExistingCanon;
2709  ExistingCanon->Used |= D->Used;
2710  D->Used = false;
2711 
2712  // When we merge a namespace, update its pointer to the first namespace.
2713  // We cannot have loaded any redeclarations of this declaration yet, so
2714  // there's nothing else that needs to be updated.
2715  if (auto *Namespace = dyn_cast<NamespaceDecl>(D))
2716  Namespace->AnonOrFirstNamespaceAndInline.setPointer(
2717  assert_cast<NamespaceDecl*>(ExistingCanon));
2718 
2719  // When we merge a template, merge its pattern.
2720  if (auto *DTemplate = dyn_cast<RedeclarableTemplateDecl>(D))
2721  mergeTemplatePattern(
2722  DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon),
2723  TemplatePatternID, Redecl.isKeyDecl());
2724 
2725  // If this declaration is a key declaration, make a note of that.
2726  if (Redecl.isKeyDecl())
2727  Reader.KeyDecls[ExistingCanon].push_back(Redecl.getFirstID());
2728  }
2729 }
2730 
2731 /// ODR-like semantics for C/ObjC allow us to merge tag types and a structural
2732 /// check in Sema guarantees the types can be merged (see C11 6.2.7/1 or C89
2733 /// 6.1.2.6/1). Although most merging is done in Sema, we need to guarantee
2734 /// that some types are mergeable during deserialization, otherwise name
2735 /// lookup fails. This is the case for EnumConstantDecl.
2737  if (!ND)
2738  return false;
2739  // TODO: implement merge for other necessary decls.
2740  if (isa<EnumConstantDecl, FieldDecl, IndirectFieldDecl>(ND))
2741  return true;
2742  return false;
2743 }
2744 
2745 /// Attempts to merge LifetimeExtendedTemporaryDecl with
2746 /// identical class definitions from two different modules.
2748  // If modules are not available, there is no reason to perform this merge.
2749  if (!Reader.getContext().getLangOpts().Modules)
2750  return;
2751 
2752  LifetimeExtendedTemporaryDecl *LETDecl = D;
2753 
2755  Reader.LETemporaryForMerging[std::make_pair(
2756  LETDecl->getExtendingDecl(), LETDecl->getManglingNumber())];
2757  if (LookupResult)
2758  Reader.getContext().setPrimaryMergedDecl(LETDecl,
2759  LookupResult->getCanonicalDecl());
2760  else
2761  LookupResult = LETDecl;
2762 }
2763 
2764 /// Attempts to merge the given declaration (D) with another declaration
2765 /// of the same entity, for the case where the entity is not actually
2766 /// redeclarable. This happens, for instance, when merging the fields of
2767 /// identical class definitions from two different modules.
2768 template<typename T>
2770  // If modules are not available, there is no reason to perform this merge.
2771  if (!Reader.getContext().getLangOpts().Modules)
2772  return;
2773 
2774  // ODR-based merging is performed in C++ and in some cases (tag types) in C.
2775  // Note that C identically-named things in different translation units are
2776  // not redeclarations, but may still have compatible types, where ODR-like
2777  // semantics may apply.
2778  if (!Reader.getContext().getLangOpts().CPlusPlus &&
2779  !allowODRLikeMergeInC(dyn_cast<NamedDecl>(static_cast<T*>(D))))
2780  return;
2781 
2782  if (FindExistingResult ExistingRes = findExisting(static_cast<T*>(D)))
2783  if (T *Existing = ExistingRes)
2784  Reader.getContext().setPrimaryMergedDecl(static_cast<T *>(D),
2785  Existing->getCanonicalDecl());
2786 }
2787 
2789  Record.readOMPChildren(D->Data);
2790  VisitDecl(D);
2791 }
2792 
2794  Record.readOMPChildren(D->Data);
2795  VisitDecl(D);
2796 }
2797 
2799  Record.readOMPChildren(D->Data);
2800  VisitDecl(D);
2801 }
2802 
2804  VisitValueDecl(D);
2805  D->setLocation(readSourceLocation());
2806  Expr *In = Record.readExpr();
2807  Expr *Out = Record.readExpr();
2808  D->setCombinerData(In, Out);
2809  Expr *Combiner = Record.readExpr();
2810  D->setCombiner(Combiner);
2811  Expr *Orig = Record.readExpr();
2812  Expr *Priv = Record.readExpr();
2813  D->setInitializerData(Orig, Priv);
2814  Expr *Init = Record.readExpr();
2815  auto IK = static_cast<OMPDeclareReductionDecl::InitKind>(Record.readInt());
2816  D->setInitializer(Init, IK);
2817  D->PrevDeclInScope = readDeclID();
2818 }
2819 
2821  Record.readOMPChildren(D->Data);
2822  VisitValueDecl(D);
2823  D->VarName = Record.readDeclarationName();
2824  D->PrevDeclInScope = readDeclID();
2825 }
2826 
2828  VisitVarDecl(D);
2829 }
2830 
2831 //===----------------------------------------------------------------------===//
2832 // Attribute Reading
2833 //===----------------------------------------------------------------------===//
2834 
2835 namespace {
2836 class AttrReader {
2837  ASTRecordReader &Reader;
2838 
2839 public:
2840  AttrReader(ASTRecordReader &Reader) : Reader(Reader) {}
2841 
2842  uint64_t readInt() {
2843  return Reader.readInt();
2844  }
2845 
2846  SourceRange readSourceRange() {
2847  return Reader.readSourceRange();
2848  }
2849 
2850  SourceLocation readSourceLocation() {
2851  return Reader.readSourceLocation();
2852  }
2853 
2854  Expr *readExpr() { return Reader.readExpr(); }
2855 
2856  std::string readString() {
2857  return Reader.readString();
2858  }
2859 
2860  TypeSourceInfo *readTypeSourceInfo() {
2861  return Reader.readTypeSourceInfo();
2862  }
2863 
2864  IdentifierInfo *readIdentifier() {
2865  return Reader.readIdentifier();
2866  }
2867 
2868  VersionTuple readVersionTuple() {
2869  return Reader.readVersionTuple();
2870  }
2871 
2872  OMPTraitInfo *readOMPTraitInfo() { return Reader.readOMPTraitInfo(); }
2873 
2874  template <typename T> T *GetLocalDeclAs(uint32_t LocalID) {
2875  return Reader.GetLocalDeclAs<T>(LocalID);
2876  }
2877 };
2878 }
2879 
2881  AttrReader Record(*this);
2882  auto V = Record.readInt();
2883  if (!V)
2884  return nullptr;
2885 
2886  Attr *New = nullptr;
2887  // Kind is stored as a 1-based integer because 0 is used to indicate a null
2888  // Attr pointer.
2889  auto Kind = static_cast<attr::Kind>(V - 1);
2890  ASTContext &Context = getContext();
2891 
2892  IdentifierInfo *AttrName = Record.readIdentifier();
2893  IdentifierInfo *ScopeName = Record.readIdentifier();
2894  SourceRange AttrRange = Record.readSourceRange();
2895  SourceLocation ScopeLoc = Record.readSourceLocation();
2896  unsigned ParsedKind = Record.readInt();
2897  unsigned Syntax = Record.readInt();
2898  unsigned SpellingIndex = Record.readInt();
2899 
2900  AttributeCommonInfo Info(AttrName, ScopeName, AttrRange, ScopeLoc,
2901  AttributeCommonInfo::Kind(ParsedKind),
2902  AttributeCommonInfo::Syntax(Syntax), SpellingIndex);
2903 
2904 #include "clang/Serialization/AttrPCHRead.inc"
2905 
2906  assert(New && "Unable to decode attribute?");
2907  return New;
2908 }
2909 
2910 /// Reads attributes from the current stream position.
2912  for (unsigned I = 0, E = readInt(); I != E; ++I)
2913  Attrs.push_back(readAttr());
2914 }
2915 
2916 //===----------------------------------------------------------------------===//
2917 // ASTReader Implementation
2918 //===----------------------------------------------------------------------===//
2919 
2920 /// Note that we have loaded the declaration with the given
2921 /// Index.
2922 ///
2923 /// This routine notes that this declaration has already been loaded,
2924 /// so that future GetDecl calls will return this declaration rather
2925 /// than trying to load a new declaration.
2926 inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) {
2927  assert(!DeclsLoaded[Index] && "Decl loaded twice?");
2928  DeclsLoaded[Index] = D;
2929 }
2930 
2931 /// Determine whether the consumer will be interested in seeing
2932 /// this declaration (via HandleTopLevelDecl).
2933 ///
2934 /// This routine should return true for anything that might affect
2935 /// code generation, e.g., inline function definitions, Objective-C
2936 /// declarations with metadata, etc.
2937 static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody) {
2938  // An ObjCMethodDecl is never considered as "interesting" because its
2939  // implementation container always is.
2940 
2941  // An ImportDecl or VarDecl imported from a module map module will get
2942  // emitted when we import the relevant module.
2944  auto *M = D->getImportedOwningModule();
2945  if (M && M->Kind == Module::ModuleMapModule &&
2946  Ctx.DeclMustBeEmitted(D))
2947  return false;
2948  }
2949 
2950  if (isa<FileScopeAsmDecl>(D) ||
2951  isa<ObjCProtocolDecl>(D) ||
2952  isa<ObjCImplDecl>(D) ||
2953  isa<ImportDecl>(D) ||
2954  isa<PragmaCommentDecl>(D) ||
2955  isa<PragmaDetectMismatchDecl>(D))
2956  return true;
2957  if (isa<OMPThreadPrivateDecl>(D) || isa<OMPDeclareReductionDecl>(D) ||
2958  isa<OMPDeclareMapperDecl>(D) || isa<OMPAllocateDecl>(D) ||
2959  isa<OMPRequiresDecl>(D))
2960  return !D->getDeclContext()->isFunctionOrMethod();
2961  if (const auto *Var = dyn_cast<VarDecl>(D))
2962  return Var->isFileVarDecl() &&
2963  (Var->isThisDeclarationADefinition() == VarDecl::Definition ||
2964  OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Var));
2965  if (const auto *Func = dyn_cast<FunctionDecl>(D))
2966  return Func->doesThisDeclarationHaveABody() || HasBody;
2967 
2968  if (auto *ES = D->getASTContext().getExternalSource())
2969  if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
2970  return true;
2971 
2972  return false;
2973 }
2974 
2975 /// Get the correct cursor and offset for loading a declaration.
2976 ASTReader::RecordLocation
2977 ASTReader::DeclCursorForID(DeclID ID, SourceLocation &Loc) {
2978  GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID);
2979  assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
2980  ModuleFile *M = I->second;
2981  const DeclOffset &DOffs =
2983  Loc = TranslateSourceLocation(*M, DOffs.getLocation());
2984  return RecordLocation(M, DOffs.getBitOffset(M->DeclsBlockStartOffset));
2985 }
2986 
2987 ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
2988  auto I = GlobalBitOffsetsMap.find(GlobalOffset);
2989 
2990  assert(I != GlobalBitOffsetsMap.end() && "Corrupted global bit offsets map");
2991  return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
2992 }
2993 
2994 uint64_t ASTReader::getGlobalBitOffset(ModuleFile &M, uint64_t LocalOffset) {
2995  return LocalOffset + M.GlobalBitOffset;
2996 }
2997 
2998 /// Find the context in which we should search for previous declarations when
2999 /// looking for declarations to merge.
3000 DeclContext *ASTDeclReader::getPrimaryContextForMerging(ASTReader &Reader,
3001  DeclContext *DC) {
3002  if (auto *ND = dyn_cast<NamespaceDecl>(DC))
3003  return ND->getOriginalNamespace();
3004 
3005  if (auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
3006  // Try to dig out the definition.
3007  auto *DD = RD->DefinitionData;
3008  if (!DD)
3009  DD = RD->getCanonicalDecl()->DefinitionData;
3010 
3011  // If there's no definition yet, then DC's definition is added by an update
3012  // record, but we've not yet loaded that update record. In this case, we
3013  // commit to DC being the canonical definition now, and will fix this when
3014  // we load the update record.
3015  if (!DD) {
3016  DD = new (Reader.getContext()) struct CXXRecordDecl::DefinitionData(RD);
3017  RD->setCompleteDefinition(true);
3018  RD->DefinitionData = DD;
3019  RD->getCanonicalDecl()->DefinitionData = DD;
3020 
3021  // Track that we did this horrible thing so that we can fix it later.
3022  Reader.PendingFakeDefinitionData.insert(
3023  std::make_pair(DD, ASTReader::PendingFakeDefinitionKind::Fake));
3024  }
3025 
3026  return DD->Definition;
3027  }
3028 
3029  if (auto *RD = dyn_cast<RecordDecl>(DC))
3030  return RD->getDefinition();
3031 
3032  if (auto *ED = dyn_cast<EnumDecl>(DC))
3033  return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition()
3034  : nullptr;
3035 
3036  if (auto *OID = dyn_cast<ObjCInterfaceDecl>(DC))
3037  return OID->getDefinition();
3038 
3039  // We can see the TU here only if we have no Sema object. In that case,
3040  // there's no TU scope to look in, so using the DC alone is sufficient.
3041  if (auto *TU = dyn_cast<TranslationUnitDecl>(DC))
3042  return TU;
3043 
3044  return nullptr;
3045 }
3046 
3047 ASTDeclReader::FindExistingResult::~FindExistingResult() {
3048  // Record that we had a typedef name for linkage whether or not we merge
3049  // with that declaration.
3050  if (TypedefNameForLinkage) {
3051  DeclContext *DC = New->getDeclContext()->getRedeclContext();
3052  Reader.ImportedTypedefNamesForLinkage.insert(
3053  std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New));
3054  return;
3055  }
3056 
3057  if (!AddResult || Existing)
3058  return;
3059 
3060  DeclarationName Name = New->getDeclName();
3061  DeclContext *DC = New->getDeclContext()->getRedeclContext();
3063  setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
3064  AnonymousDeclNumber, New);
3065  } else if (DC->isTranslationUnit() &&
3066  !Reader.getContext().getLangOpts().CPlusPlus) {
3067  if (Reader.getIdResolver().tryAddTopLevelDecl(New, Name))
3068  Reader.PendingFakeLookupResults[Name.getAsIdentifierInfo()]
3069  .push_back(New);
3070  } else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
3071  // Add the declaration to its redeclaration context so later merging
3072  // lookups will find it.
3073  MergeDC->makeDeclVisibleInContextImpl(New, /*Internal*/true);
3074  }
3075 }
3076 
3077 /// Find the declaration that should be merged into, given the declaration found
3078 /// by name lookup. If we're merging an anonymous declaration within a typedef,
3079 /// we need a matching typedef, and we merge with the type inside it.
3081  bool IsTypedefNameForLinkage) {
3082  if (!IsTypedefNameForLinkage)
3083  return Found;
3084 
3085  // If we found a typedef declaration that gives a name to some other
3086  // declaration, then we want that inner declaration. Declarations from
3087  // AST files are handled via ImportedTypedefNamesForLinkage.
3088  if (Found->isFromASTFile())
3089  return nullptr;
3090 
3091  if (auto *TND = dyn_cast<TypedefNameDecl>(Found))
3092  return TND->getAnonDeclWithTypedefName(/*AnyRedecl*/true);
3093 
3094  return nullptr;
3095 }
3096 
3097 /// Find the declaration to use to populate the anonymous declaration table
3098 /// for the given lexical DeclContext. We only care about finding local
3099 /// definitions of the context; we'll merge imported ones as we go.
3100 DeclContext *
3101 ASTDeclReader::getPrimaryDCForAnonymousDecl(DeclContext *LexicalDC) {
3102  // For classes, we track the definition as we merge.
3103  if (auto *RD = dyn_cast<CXXRecordDecl>(LexicalDC)) {
3104  auto *DD = RD->getCanonicalDecl()->DefinitionData;
3105  return DD ? DD->Definition : nullptr;
3106  } else if (auto *OID = dyn_cast<ObjCInterfaceDecl>(LexicalDC)) {
3107  return OID->getCanonicalDecl()->getDefinition();
3108  }
3109 
3110  // For anything else, walk its merged redeclarations looking for a definition.
3111  // Note that we can't just call getDefinition here because the redeclaration
3112  // chain isn't wired up.
3113  for (auto *D : merged_redecls(cast<Decl>(LexicalDC))) {
3114  if (auto *FD = dyn_cast<FunctionDecl>(D))
3115  if (FD->isThisDeclarationADefinition())
3116  return FD;
3117  if (auto *MD = dyn_cast<ObjCMethodDecl>(D))
3118  if (MD->isThisDeclarationADefinition())
3119  return MD;
3120  if (auto *RD = dyn_cast<RecordDecl>(D))
3121  if (RD->isThisDeclarationADefinition())
3122  return RD;
3123  }
3124 
3125  // No merged definition yet.
3126  return nullptr;
3127 }
3128 
3129 NamedDecl *ASTDeclReader::getAnonymousDeclForMerging(ASTReader &Reader,
3130  DeclContext *DC,
3131  unsigned Index) {
3132  // If the lexical context has been merged, look into the now-canonical
3133  // definition.
3134  auto *CanonDC = cast<Decl>(DC)->getCanonicalDecl();
3135 
3136  // If we've seen this before, return the canonical declaration.
3137  auto &Previous = Reader.AnonymousDeclarationsForMerging[CanonDC];
3138  if (Index < Previous.size() && Previous[Index])
3139  return Previous[Index];
3140 
3141  // If this is the first time, but we have parsed a declaration of the context,
3142  // build the anonymous declaration list from the parsed declaration.
3143  auto *PrimaryDC = getPrimaryDCForAnonymousDecl(DC);
3144  if (PrimaryDC && !cast<Decl>(PrimaryDC)->isFromASTFile()) {
3145  numberAnonymousDeclsWithin(PrimaryDC, [&](NamedDecl *ND, unsigned Number) {
3146  if (Previous.size() == Number)
3147  Previous.push_back(cast<NamedDecl>(ND->getCanonicalDecl()));
3148  else
3149  Previous[Number] = cast<NamedDecl>(ND->getCanonicalDecl());
3150  });
3151  }
3152 
3153  return Index < Previous.size() ? Previous[Index] : nullptr;
3154 }
3155 
3156 void ASTDeclReader::setAnonymousDeclForMerging(ASTReader &Reader,
3157  DeclContext *DC, unsigned Index,
3158  NamedDecl *D) {
3159  auto *CanonDC = cast<Decl>(DC)->getCanonicalDecl();
3160 
3161  auto &Previous = Reader.AnonymousDeclarationsForMerging[CanonDC];
3162  if (Index >= Previous.size())
3163  Previous.resize(Index + 1);
3164  if (!Previous[Index])
3165  Previous[Index] = D;
3166 }
3167 
3168 ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) {
3169  DeclarationName Name = TypedefNameForLinkage ? TypedefNameForLinkage
3170  : D->getDeclName();
3171 
3172  if (!Name && !needsAnonymousDeclarationNumber(D)) {
3173  // Don't bother trying to find unnamed declarations that are in
3174  // unmergeable contexts.
3175  FindExistingResult Result(Reader, D, /*Existing=*/nullptr,
3176  AnonymousDeclNumber, TypedefNameForLinkage);
3177  Result.suppress();
3178  return Result;
3179  }
3180 
3181  ASTContext &C = Reader.getContext();
3183  if (TypedefNameForLinkage) {
3184  auto It = Reader.ImportedTypedefNamesForLinkage.find(
3185  std::make_pair(DC, TypedefNameForLinkage));
3186  if (It != Reader.ImportedTypedefNamesForLinkage.end())
3187  if (C.isSameEntity(It->second, D))
3188  return FindExistingResult(Reader, D, It->second, AnonymousDeclNumber,
3189  TypedefNameForLinkage);
3190  // Go on to check in other places in case an existing typedef name
3191  // was not imported.
3192  }
3193 
3195  // This is an anonymous declaration that we may need to merge. Look it up
3196  // in its context by number.
3197  if (auto *Existing = getAnonymousDeclForMerging(
3198  Reader, D->getLexicalDeclContext(), AnonymousDeclNumber))
3199  if (C.isSameEntity(Existing, D))
3200  return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3201  TypedefNameForLinkage);
3202  } else if (DC->isTranslationUnit() &&
3203  !Reader.getContext().getLangOpts().CPlusPlus) {
3204  IdentifierResolver &IdResolver = Reader.getIdResolver();
3205 
3206  // Temporarily consider the identifier to be up-to-date. We don't want to
3207  // cause additional lookups here.
3208  class UpToDateIdentifierRAII {
3209  IdentifierInfo *II;
3210  bool WasOutToDate = false;
3211 
3212  public:
3213  explicit UpToDateIdentifierRAII(IdentifierInfo *II) : II(II) {
3214  if (II) {
3215  WasOutToDate = II->isOutOfDate();
3216  if (WasOutToDate)
3217  II->setOutOfDate(false);
3218  }
3219  }
3220 
3221  ~UpToDateIdentifierRAII() {
3222  if (WasOutToDate)
3223  II->setOutOfDate(true);
3224  }
3225  } UpToDate(Name.getAsIdentifierInfo());
3226 
3227  for (IdentifierResolver::iterator I = IdResolver.begin(Name),
3228  IEnd = IdResolver.end();
3229  I != IEnd; ++I) {
3230  if (NamedDecl *Existing = getDeclForMerging(*I, TypedefNameForLinkage))
3231  if (C.isSameEntity(Existing, D))
3232  return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3233  TypedefNameForLinkage);
3234  }
3235  } else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
3236  DeclContext::lookup_result R = MergeDC->noload_lookup(Name);
3237  for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; ++I) {
3238  if (NamedDecl *Existing = getDeclForMerging(*I, TypedefNameForLinkage))
3239  if (C.isSameEntity(Existing, D))
3240  return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3241  TypedefNameForLinkage);
3242  }
3243  } else {
3244  // Not in a mergeable context.
3245  return FindExistingResult(Reader);
3246  }
3247 
3248  // If this declaration is from a merged context, make a note that we need to
3249  // check that the canonical definition of that context contains the decl.
3250  //
3251  // FIXME: We should do something similar if we merge two definitions of the
3252  // same template specialization into the same CXXRecordDecl.
3253  auto MergedDCIt = Reader.MergedDeclContexts.find(D->getLexicalDeclContext());
3254  if (MergedDCIt != Reader.MergedDeclContexts.end() &&
3255  MergedDCIt->second == D->getDeclContext())
3256  Reader.PendingOdrMergeChecks.push_back(D);
3257 
3258  return FindExistingResult(Reader, D, /*Existing=*/nullptr,
3259  AnonymousDeclNumber, TypedefNameForLinkage);
3260 }
3261 
3262 template<typename DeclT>
3264  return D->RedeclLink.getLatestNotUpdated();
3265 }
3266 
3268  llvm_unreachable("getMostRecentDecl on non-redeclarable declaration");
3269 }
3270 
3272  assert(D);
3273 
3274  switch (D->getKind()) {
3275 #define ABSTRACT_DECL(TYPE)
3276 #define DECL(TYPE, BASE) \
3277  case Decl::TYPE: \
3278  return getMostRecentDeclImpl(cast<TYPE##Decl>(D));
3279 #include "clang/AST/DeclNodes.inc"
3280  }
3281  llvm_unreachable("unknown decl kind");
3282 }
3283 
3284 Decl *ASTReader::getMostRecentExistingDecl(Decl *D) {
3286 }
3287 
3289  Decl *Previous) {
3290  InheritableAttr *NewAttr = nullptr;
3291  ASTContext &Context = Reader.getContext();
3292  const auto *IA = Previous->getAttr<MSInheritanceAttr>();
3293 
3294  if (IA && !D->hasAttr<MSInheritanceAttr>()) {
3295  NewAttr = cast<InheritableAttr>(IA->clone(Context));
3296  NewAttr->setInherited(true);
3297  D->addAttr(NewAttr);
3298  }
3299 }
3300 
3301 template<typename DeclT>
3304  Decl *Previous, Decl *Canon) {
3305  D->RedeclLink.setPrevious(cast<DeclT>(Previous));
3306  D->First = cast<DeclT>(Previous)->First;
3307 }
3308 
3309 namespace clang {
3310 
3311 template<>
3314  Decl *Previous, Decl *Canon) {
3315  auto *VD = static_cast<VarDecl *>(D);
3316  auto *PrevVD = cast<VarDecl>(Previous);
3317  D->RedeclLink.setPrevious(PrevVD);
3318  D->First = PrevVD->First;
3319 
3320  // We should keep at most one definition on the chain.
3321  // FIXME: Cache the definition once we've found it. Building a chain with
3322  // N definitions currently takes O(N^2) time here.
3323  if (VD->isThisDeclarationADefinition() == VarDecl::Definition) {
3324  for (VarDecl *CurD = PrevVD; CurD; CurD = CurD->getPreviousDecl()) {
3325  if (CurD->isThisDeclarationADefinition() == VarDecl::Definition) {
3326  Reader.mergeDefinitionVisibility(CurD, VD);
3327  VD->demoteThisDefinitionToDeclaration();
3328  break;
3329  }
3330  }
3331  }
3332 }
3333 
3335  auto *DT = T->getContainedDeducedType();
3336  return DT && !DT->isDeduced();
3337 }
3338 
3339 template<>
3342  Decl *Previous, Decl *Canon) {
3343  auto *FD = static_cast<FunctionDecl *>(D);
3344  auto *PrevFD = cast<FunctionDecl>(Previous);
3345 
3346  FD->RedeclLink.setPrevious(PrevFD);
3347  FD->First = PrevFD->First;
3348 
3349  // If the previous declaration is an inline function declaration, then this
3350  // declaration is too.
3351  if (PrevFD->isInlined() != FD->isInlined()) {
3352  // FIXME: [dcl.fct.spec]p4:
3353  // If a function with external linkage is declared inline in one
3354  // translation unit, it shall be declared inline in all translation
3355  // units in which it appears.
3356  //
3357  // Be careful of this case:
3358  //
3359  // module A:
3360  // template<typename T> struct X { void f(); };
3361  // template<typename T> inline void X<T>::f() {}
3362  //
3363  // module B instantiates the declaration of X<int>::f
3364  // module C instantiates the definition of X<int>::f
3365  //
3366  // If module B and C are merged, we do not have a violation of this rule.
3367  FD->setImplicitlyInline(true);
3368  }
3369 
3370  auto *FPT = FD->getType()->getAs<FunctionProtoType>();
3371  auto *PrevFPT = PrevFD->getType()->getAs<FunctionProtoType>();
3372  if (FPT && PrevFPT) {
3373  // If we need to propagate an exception specification along the redecl
3374  // chain, make a note of that so that we can do so later.
3375  bool IsUnresolved = isUnresolvedExceptionSpec(FPT->getExceptionSpecType());
3376  bool WasUnresolved =
3378  if (IsUnresolved != WasUnresolved)
3379  Reader.PendingExceptionSpecUpdates.insert(
3380  {Canon, IsUnresolved ? PrevFD : FD});
3381 
3382  // If we need to propagate a deduced return type along the redecl chain,
3383  // make a note of that so that we can do it later.
3384  bool IsUndeduced = isUndeducedReturnType(FPT->getReturnType());
3385  bool WasUndeduced = isUndeducedReturnType(PrevFPT->getReturnType());
3386  if (IsUndeduced != WasUndeduced)
3387  Reader.PendingDeducedTypeUpdates.insert(
3388  {cast<FunctionDecl>(Canon),
3389  (IsUndeduced ? PrevFPT : FPT)->getReturnType()});
3390  }
3391 }
3392 
3393 } // namespace clang
3394 
3396  llvm_unreachable("attachPreviousDecl on non-redeclarable declaration");
3397 }
3398 
3399 /// Inherit the default template argument from \p From to \p To. Returns
3400 /// \c false if there is no default template for \p From.
3401 template <typename ParmDecl>
3402 static bool inheritDefaultTemplateArgument(ASTContext &Context, ParmDecl *From,
3403  Decl *ToD) {
3404  auto *To = cast<ParmDecl>(ToD);
3405  if (!From->hasDefaultArgument())
3406  return false;
3407  To->setInheritedDefaultArgument(Context, From);
3408  return true;
3409 }
3410 
3412  TemplateDecl *From,
3413  TemplateDecl *To) {
3414  auto *FromTP = From->getTemplateParameters();
3415  auto *ToTP = To->getTemplateParameters();
3416  assert(FromTP->size() == ToTP->size() && "merged mismatched templates?");
3417 
3418  for (unsigned I = 0, N = FromTP->size(); I != N; ++I) {
3419  NamedDecl *FromParam = FromTP->getParam(I);
3420  NamedDecl *ToParam = ToTP->getParam(I);
3421 
3422  if (auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam))
3423  inheritDefaultTemplateArgument(Context, FTTP, ToParam);
3424  else if (auto *FNTTP = dyn_cast<NonTypeTemplateParmDecl>(FromParam))
3425  inheritDefaultTemplateArgument(Context, FNTTP, ToParam);
3426  else
3428  Context, cast<TemplateTemplateParmDecl>(FromParam), ToParam);
3429  }
3430 }
3431 
3433  Decl *Previous, Decl *Canon) {
3434  assert(D && Previous);
3435 
3436  switch (D->getKind()) {
3437 #define ABSTRACT_DECL(TYPE)
3438 #define DECL(TYPE, BASE) \
3439  case Decl::TYPE: \
3440  attachPreviousDeclImpl(Reader, cast<TYPE##Decl>(D), Previous, Canon); \
3441  break;
3442 #include "clang/AST/DeclNodes.inc"
3443  }
3444 
3445  // If the declaration was visible in one module, a redeclaration of it in
3446  // another module remains visible even if it wouldn't be visible by itself.
3447  //
3448  // FIXME: In this case, the declaration should only be visible if a module
3449  // that makes it visible has been imported.
3450  D->IdentifierNamespace |=
3451  Previous->IdentifierNamespace &
3453 
3454  // If the declaration declares a template, it may inherit default arguments
3455  // from the previous declaration.
3456  if (auto *TD = dyn_cast<TemplateDecl>(D))
3458  cast<TemplateDecl>(Previous), TD);
3459 
3460  // If any of the declaration in the chain contains an Inheritable attribute,
3461  // it needs to be added to all the declarations in the redeclarable chain.
3462  // FIXME: Only the logic of merging MSInheritableAttr is present, it should
3463  // be extended for all inheritable attributes.
3464  mergeInheritableAttributes(Reader, D, Previous);
3465 }
3466 
3467 template<typename DeclT>
3469  D->RedeclLink.setLatest(cast<DeclT>(Latest));
3470 }
3471 
3473  llvm_unreachable("attachLatestDecl on non-redeclarable declaration");
3474 }
3475 
3477  assert(D && Latest);
3478 
3479  switch (D->getKind()) {
3480 #define ABSTRACT_DECL(TYPE)
3481 #define DECL(TYPE, BASE) \
3482  case Decl::TYPE: \
3483  attachLatestDeclImpl(cast<TYPE##Decl>(D), Latest); \
3484  break;
3485 #include "clang/AST/DeclNodes.inc"
3486  }
3487 }
3488 
3489 template<typename DeclT>
3491  D->RedeclLink.markIncomplete();
3492 }
3493 
3495  llvm_unreachable("markIncompleteDeclChain on non-redeclarable declaration");
3496 }
3497 
3498 void ASTReader::markIncompleteDeclChain(Decl *D) {
3499  switch (D->getKind()) {
3500 #define ABSTRACT_DECL(TYPE)
3501 #define DECL(TYPE, BASE) \
3502  case Decl::TYPE: \
3503  ASTDeclReader::markIncompleteDeclChainImpl(cast<TYPE##Decl>(D)); \
3504  break;
3505 #include "clang/AST/DeclNodes.inc"
3506  }
3507 }
3508 
3509 /// Read the declaration at the given offset from the AST file.
3510 Decl *ASTReader::ReadDeclRecord(DeclID ID) {
3511  unsigned Index = ID - NUM_PREDEF_DECL_IDS;
3512  SourceLocation DeclLoc;
3513  RecordLocation Loc = DeclCursorForID(ID, DeclLoc);
3514  llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
3515  // Keep track of where we are in the stream, then jump back there
3516  // after reading this declaration.
3517  SavedStreamPosition SavedPosition(DeclsCursor);
3518 
3519  ReadingKindTracker ReadingKind(Read_Decl, *this);
3520 
3521  // Note that we are loading a declaration record.
3522  Deserializing ADecl(this);
3523 
3524  auto Fail = [](const char *what, llvm::Error &&Err) {
3525  llvm::report_fatal_error(Twine("ASTReader::readDeclRecord failed ") + what +
3526  ": " + toString(std::move(Err)));
3527  };
3528 
3529  if (llvm::Error JumpFailed = DeclsCursor.JumpToBit(Loc.Offset))
3530  Fail("jumping", std::move(JumpFailed));
3531  ASTRecordReader Record(*this, *Loc.F);
3532  ASTDeclReader Reader(*this, Record, Loc, ID, DeclLoc);
3533  Expected<unsigned> MaybeCode = DeclsCursor.ReadCode();
3534  if (!MaybeCode)
3535  Fail("reading code", MaybeCode.takeError());
3536  unsigned Code = MaybeCode.get();
3537 
3538  ASTContext &Context = getContext();
3539  Decl *D = nullptr;
3540  Expected<unsigned> MaybeDeclCode = Record.readRecord(DeclsCursor, Code);
3541  if (!MaybeDeclCode)
3542  llvm::report_fatal_error(
3543  Twine("ASTReader::readDeclRecord failed reading decl code: ") +
3544  toString(MaybeDeclCode.takeError()));
3545  switch ((DeclCode)MaybeDeclCode.get()) {
3546  case DECL_CONTEXT_LEXICAL:
3547  case DECL_CONTEXT_VISIBLE:
3548  llvm_unreachable("Record cannot be de-serialized with readDeclRecord");
3549  case DECL_TYPEDEF:
3550  D = TypedefDecl::CreateDeserialized(Context, ID);
3551  break;
3552  case DECL_TYPEALIAS:
3553  D = TypeAliasDecl::CreateDeserialized(Context, ID);
3554  break;
3555  case DECL_ENUM:
3556  D = EnumDecl::CreateDeserialized(Context, ID);
3557  break;
3558  case DECL_RECORD:
3559  D = RecordDecl::CreateDeserialized(Context, ID);
3560  break;
3561  case DECL_ENUM_CONSTANT:
3563  break;
3564  case DECL_FUNCTION:
3565  D = FunctionDecl::CreateDeserialized(Context, ID);
3566  break;
3567  case DECL_LINKAGE_SPEC:
3569  break;
3570  case DECL_EXPORT:
3571  D = ExportDecl::CreateDeserialized(Context, ID);
3572  break;
3573  case DECL_LABEL:
3574  D = LabelDecl::CreateDeserialized(Context, ID);
3575  break;
3576  case DECL_NAMESPACE:
3577  D = NamespaceDecl::CreateDeserialized(Context, ID);
3578  break;
3579  case DECL_NAMESPACE_ALIAS:
3581  break;
3582  case DECL_USING:
3583  D = UsingDecl::CreateDeserialized(Context, ID);
3584  break;
3585  case DECL_USING_PACK:
3586  D = UsingPackDecl::CreateDeserialized(Context, ID, Record.readInt());
3587  break;
3588  case DECL_USING_SHADOW:
3590  break;
3591  case DECL_USING_ENUM:
3592  D = UsingEnumDecl::CreateDeserialized(Context, ID);
3593  break;
3596  break;
3597  case DECL_USING_DIRECTIVE:
3599  break;
3602  break;
3605  break;
3608  break;
3609  case DECL_CXX_RECORD:
3610  D = CXXRecordDecl::CreateDeserialized(Context, ID);
3611  break;
3614  break;
3615  case DECL_CXX_METHOD:
3616  D = CXXMethodDecl::CreateDeserialized(Context, ID);
3617  break;
3618  case DECL_CXX_CONSTRUCTOR:
3619  D = CXXConstructorDecl::CreateDeserialized(Context, ID, Record.readInt());
3620  break;
3621  case DECL_CXX_DESTRUCTOR:
3623  break;
3624  case DECL_CXX_CONVERSION:
3626  break;
3627  case DECL_ACCESS_SPEC:
3628  D = AccessSpecDecl::CreateDeserialized(Context, ID);
3629  break;
3630  case DECL_FRIEND:
3631  D = FriendDecl::CreateDeserialized(Context, ID, Record.readInt());
3632  break;
3633  case DECL_FRIEND_TEMPLATE:
3635  break;
3636  case DECL_CLASS_TEMPLATE:
3638  break;
3641  break;
3644  break;
3645  case DECL_VAR_TEMPLATE:
3647  break;
3650  break;
3653  break;
3656  break;
3659  break;
3660  case DECL_TEMPLATE_TYPE_PARM: {
3661  bool HasTypeConstraint = Record.readInt();
3663  HasTypeConstraint);
3664  break;
3665  }
3667  bool HasTypeConstraint = Record.readInt();
3669  HasTypeConstraint);
3670  break;
3671  }
3673  bool HasTypeConstraint = Record.readInt();
3675  Record.readInt(),
3676  HasTypeConstraint);
3677  break;
3678  }
3681  break;
3684  Record.readInt());
3685  break;
3688  break;
3689  case DECL_CONCEPT:
3690  D = ConceptDecl::CreateDeserialized(Context, ID);
3691  break;
3694  break;
3695  case DECL_STATIC_ASSERT:
3697  break;
3698  case DECL_OBJC_METHOD:
3699  D = ObjCMethodDecl::CreateDeserialized(Context, ID);
3700  break;
3701  case DECL_OBJC_INTERFACE:
3703  break;
3704  case DECL_OBJC_IVAR:
3705  D = ObjCIvarDecl::CreateDeserialized(Context, ID);
3706  break;
3707  case DECL_OBJC_PROTOCOL:
3709  break;
3712  break;
3713  case DECL_OBJC_CATEGORY:
3715  break;
3718  break;
3721  break;
3724  break;
3725  case DECL_OBJC_PROPERTY:
3727  break;
3730  break;
3731  case DECL_FIELD:
3732  D = FieldDecl::CreateDeserialized(Context, ID);
3733  break;
3734  case DECL_INDIRECTFIELD:
3736  break;
3737  case DECL_VAR:
3738  D = VarDecl::CreateDeserialized(Context, ID);
3739  break;
3740  case DECL_IMPLICIT_PARAM:
3742  break;
3743  case DECL_PARM_VAR:
3744  D = ParmVarDecl::CreateDeserialized(Context, ID);
3745  break;
3746  case DECL_DECOMPOSITION:
3747  D = DecompositionDecl::CreateDeserialized(Context, ID, Record.readInt());
3748  break;
3749  case DECL_BINDING:
3750  D = BindingDecl::CreateDeserialized(Context, ID);
3751  break;
3752  case DECL_FILE_SCOPE_ASM:
3754  break;
3755  case DECL_BLOCK:
3756  D = BlockDecl::CreateDeserialized(Context, ID);
3757  break;
3758  case DECL_MS_PROPERTY:
3759  D = MSPropertyDecl::CreateDeserialized(Context, ID);
3760  break;
3761  case DECL_MS_GUID:
3762  D = MSGuidDecl::CreateDeserialized(Context, ID);
3763  break;
3765  D = UnnamedGlobalConstantDecl::CreateDeserialized(Context, ID);
3766  break;
3768  D = TemplateParamObjectDecl::CreateDeserialized(Context, ID);
3769  break;
3770  case DECL_CAPTURED:
3771  D = CapturedDecl::CreateDeserialized(Context, ID, Record.readInt());
3772  break;
3774  Error("attempt to read a C++ base-specifier record as a declaration");
3775  return nullptr;
3777  Error("attempt to read a C++ ctor initializer record as a declaration");
3778  return nullptr;
3779  case DECL_IMPORT:
3780  // Note: last entry of the ImportDecl record is the number of stored source
3781  // locations.
3782  D = ImportDecl::CreateDeserialized(Context, ID, Record.back());
3783  break;
3784  case DECL_OMP_THREADPRIVATE: {
3785  Record.skipInts(1);
3786  unsigned NumChildren = Record.readInt();
3787  Record.skipInts(1);
3788  D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, NumChildren);
3789  break;
3790  }
3791  case DECL_OMP_ALLOCATE: {
3792  unsigned NumClauses = Record.readInt();
3793  unsigned NumVars = Record.readInt();
3794  Record.skipInts(1);
3795  D = OMPAllocateDecl::CreateDeserialized(Context, ID, NumVars, NumClauses);
3796  break;
3797  }
3798  case DECL_OMP_REQUIRES: {
3799  unsigned NumClauses = Record.readInt();
3800  Record.skipInts(2);
3801  D = OMPRequiresDecl::CreateDeserialized(Context, ID, NumClauses);
3802  break;
3803  }
3806  break;
3807  case DECL_OMP_DECLARE_MAPPER: {
3808  unsigned NumClauses = Record.readInt();
3809  Record.skipInts(2);
3810  D = OMPDeclareMapperDecl::CreateDeserialized(Context, ID, NumClauses);
3811  break;
3812  }
3813  case DECL_OMP_CAPTUREDEXPR:
3815  break;
3816  case DECL_PRAGMA_COMMENT:
3817  D = PragmaCommentDecl::CreateDeserialized(Context, ID, Record.readInt());
3818  break;
3821  Record.readInt());
3822  break;
3823  case DECL_EMPTY:
3824  D = EmptyDecl::CreateDeserialized(Context, ID);
3825  break;
3828  break;
3829  case DECL_OBJC_TYPE_PARAM:
3831  break;
3832  }
3833 
3834  assert(D && "Unknown declaration reading AST file");
3835  LoadedDecl(Index, D);
3836  // Set the DeclContext before doing any deserialization, to make sure internal
3837  // calls to Decl::getASTContext() by Decl's methods will find the
3838  // TranslationUnitDecl without crashing.
3839  D->setDeclContext(Context.getTranslationUnitDecl());
3840  Reader.Visit(D);
3841 
3842  // If this declaration is also a declaration context, get the
3843  // offsets for its tables of lexical and visible declarations.
3844  if (auto *DC = dyn_cast<DeclContext>(D)) {
3845  std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC);
3846  if (Offsets.first &&
3847  ReadLexicalDeclContextStorage(*Loc.F, DeclsCursor, Offsets.first, DC))
3848  return nullptr;
3849  if (Offsets.second &&
3850  ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID))
3851  return nullptr;
3852  }
3853  assert(Record.getIdx() == Record.size());
3854 
3855  // Load any relevant update records.
3856  PendingUpdateRecords.push_back(
3857  PendingUpdateRecord(ID, D, /*JustLoaded=*/true));
3858 
3859  // Load the categories after recursive loading is finished.
3860  if (auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
3861  // If we already have a definition when deserializing the ObjCInterfaceDecl,
3862  // we put the Decl in PendingDefinitions so we can pull the categories here.
3863  if (Class->isThisDeclarationADefinition() ||
3864  PendingDefinitions.count(Class))
3865  loadObjCCategories(ID, Class);
3866 
3867  // If we have deserialized a declaration that has a definition the
3868  // AST consumer might need to know about, queue it.
3869  // We don't pass it to the consumer immediately because we may be in recursive
3870  // loading, and some declarations may still be initializing.
3871  PotentiallyInterestingDecls.push_back(
3872  InterestingDecl(D, Reader.hasPendingBody()));
3873 
3874  return D;
3875 }
3876 
3877 void ASTReader::PassInterestingDeclsToConsumer() {
3878  assert(Consumer);
3879 
3880  if (PassingDeclsToConsumer)
3881  return;
3882 
3883  // Guard variable to avoid recursively redoing the process of passing
3884  // decls to consumer.
3885  SaveAndRestore<bool> GuardPassingDeclsToConsumer(PassingDeclsToConsumer,
3886  true);
3887 
3888  // Ensure that we've loaded all potentially-interesting declarations
3889  // that need to be eagerly loaded.
3890  for (auto ID : EagerlyDeserializedDecls)
3891  GetDecl(ID);
3892  EagerlyDeserializedDecls.clear();
3893 
3894  while (!PotentiallyInterestingDecls.empty()) {
3895  InterestingDecl D = PotentiallyInterestingDecls.front();
3896  PotentiallyInterestingDecls.pop_front();
3897  if (isConsumerInterestedIn(getContext(), D.getDecl(), D.hasPendingBody()))
3898  PassInterestingDeclToConsumer(D.getDecl());
3899  }
3900 }
3901 
3902 void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
3903  // The declaration may have been modified by files later in the chain.
3904  // If this is the case, read the record containing the updates from each file
3905  // and pass it to ASTDeclReader to make the modifications.
3906  serialization::GlobalDeclID ID = Record.ID;
3907  Decl *D = Record.D;
3908  ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
3909  DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
3910 
3911  SmallVector<serialization::DeclID, 8> PendingLazySpecializationIDs;
3912 
3913  if (UpdI != DeclUpdateOffsets.end()) {
3914  auto UpdateOffsets = std::move(UpdI->second);
3915  DeclUpdateOffsets.erase(UpdI);
3916 
3917  // Check if this decl was interesting to the consumer. If we just loaded
3918  // the declaration, then we know it was interesting and we skip the call
3919  // to isConsumerInterestedIn because it is unsafe to call in the
3920  // current ASTReader state.
3921  bool WasInteresting =
3922  Record.JustLoaded || isConsumerInterestedIn(getContext(), D, false);
3923  for (auto &FileAndOffset : UpdateOffsets) {
3924  ModuleFile *F = FileAndOffset.first;
3925  uint64_t Offset = FileAndOffset.second;
3926  llvm::BitstreamCursor &Cursor = F->DeclsCursor;
3927  SavedStreamPosition SavedPosition(Cursor);
3928  if (llvm::Error JumpFailed = Cursor.JumpToBit(Offset))
3929  // FIXME don't do a fatal error.
3930  llvm::report_fatal_error(
3931  Twine("ASTReader::loadDeclUpdateRecords failed jumping: ") +
3932  toString(std::move(JumpFailed)));
3933  Expected<unsigned> MaybeCode = Cursor.ReadCode();
3934  if (!MaybeCode)
3935  llvm::report_fatal_error(
3936  Twine("ASTReader::loadDeclUpdateRecords failed reading code: ") +
3937  toString(MaybeCode.takeError()));
3938  unsigned Code = MaybeCode.get();
3939  ASTRecordReader Record(*this, *F);
3940  if (Expected<unsigned> MaybeRecCode = Record.readRecord(Cursor, Code))
3941  assert(MaybeRecCode.get() == DECL_UPDATES &&
3942  "Expected DECL_UPDATES record!");
3943  else
3944  llvm::report_fatal_error(
3945  Twine("ASTReader::loadDeclUpdateRecords failed reading rec code: ") +
3946  toString(MaybeCode.takeError()));
3947 
3948  ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
3949  SourceLocation());
3950  Reader.UpdateDecl(D, PendingLazySpecializationIDs);
3951 
3952  // We might have made this declaration interesting. If so, remember that
3953  // we need to hand it off to the consumer.
3954  if (!WasInteresting &&
3955  isConsumerInterestedIn(getContext(), D, Reader.hasPendingBody())) {
3956  PotentiallyInterestingDecls.push_back(
3957  InterestingDecl(D, Reader.hasPendingBody()));
3958  WasInteresting = true;
3959  }
3960  }
3961  }
3962  // Add the lazy specializations to the template.
3963  assert((PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) ||
3964  isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) &&
3965  "Must not have pending specializations");
3966  if (auto *CTD = dyn_cast<ClassTemplateDecl>(D))
3967  ASTDeclReader::AddLazySpecializations(CTD, PendingLazySpecializationIDs);
3968  else if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
3969  ASTDeclReader::AddLazySpecializations(FTD, PendingLazySpecializationIDs);
3970  else if (auto *VTD = dyn_cast<VarTemplateDecl>(D))
3971  ASTDeclReader::AddLazySpecializations(VTD, PendingLazySpecializationIDs);
3972  PendingLazySpecializationIDs.clear();
3973 
3974  // Load the pending visible updates for this decl context, if it has any.
3975  auto I = PendingVisibleUpdates.find(ID);
3976  if (I != PendingVisibleUpdates.end()) {
3977  auto VisibleUpdates = std::move(I->second);
3978  PendingVisibleUpdates.erase(I);
3979 
3980  auto *DC = cast<DeclContext>(D)->getPrimaryContext();
3981  for (const auto &Update : VisibleUpdates)
3982  Lookups[DC].Table.add(
3983  Update.Mod, Update.Data,
3985  DC->setHasExternalVisibleStorage(true);
3986  }
3987 }
3988 
3989 void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) {
3990  // Attach FirstLocal to the end of the decl chain.
3991  Decl *CanonDecl = FirstLocal->getCanonicalDecl();
3992  if (FirstLocal != CanonDecl) {
3993  Decl *PrevMostRecent = ASTDeclReader::getMostRecentDecl(CanonDecl);
3995  *this, FirstLocal, PrevMostRecent ? PrevMostRecent : CanonDecl,
3996  CanonDecl);
3997  }
3998 
3999  if (!LocalOffset) {
4000  ASTDeclReader::attachLatestDecl(CanonDecl, FirstLocal);
4001  return;
4002  }
4003 
4004  // Load the list of other redeclarations from this module file.
4005  ModuleFile *M = getOwningModuleFile(FirstLocal);
4006  assert(M && "imported decl from no module file");
4007 
4008  llvm::BitstreamCursor &Cursor = M->DeclsCursor;
4009  SavedStreamPosition SavedPosition(Cursor);
4010  if (llvm::Error JumpFailed = Cursor.JumpToBit(LocalOffset))
4011  llvm::report_fatal_error(
4012  Twine("ASTReader::loadPendingDeclChain failed jumping: ") +
4013  toString(std::move(JumpFailed)));
4014 
4015  RecordData Record;
4016  Expected<unsigned> MaybeCode = Cursor.ReadCode();
4017  if (!MaybeCode)
4018  llvm::report_fatal_error(
4019  Twine("ASTReader::loadPendingDeclChain failed reading code: ") +
4020  toString(MaybeCode.takeError()));
4021  unsigned Code = MaybeCode.get();
4022  if (Expected<unsigned> MaybeRecCode = Cursor.readRecord(Code, Record))
4023  assert(MaybeRecCode.get() == LOCAL_REDECLARATIONS &&
4024  "expected LOCAL_REDECLARATIONS record!");
4025  else
4026  llvm::report_fatal_error(
4027  Twine("ASTReader::loadPendingDeclChain failed reading rec code: ") +
4028  toString(MaybeCode.takeError()));
4029 
4030  // FIXME: We have several different dispatches on decl kind here; maybe
4031  // we should instead generate one loop per kind and dispatch up-front?
4032  Decl *MostRecent = FirstLocal;
4033  for (unsigned I = 0, N = Record.size(); I != N; ++I) {
4034  auto *D = GetLocalDecl(*M, Record[N - I - 1]);
4035  ASTDeclReader::attachPreviousDecl(*this, D, MostRecent, CanonDecl);
4036  MostRecent = D;
4037  }
4038  ASTDeclReader::attachLatestDecl(CanonDecl, MostRecent);
4039 }
4040 
4041 namespace {
4042 
4043  /// Given an ObjC interface, goes through the modules and links to the
4044  /// interface all the categories for it.
4045  class ObjCCategoriesVisitor {
4046  ASTReader &Reader;
4047  ObjCInterfaceDecl *Interface;
4048  llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized;
4049  ObjCCategoryDecl *Tail = nullptr;
4050  llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap;
4051  serialization::GlobalDeclID InterfaceID;
4052  unsigned PreviousGeneration;
4053 
4054  void add(ObjCCategoryDecl *Cat) {
4055  // Only process each category once.
4056  if (!Deserialized.erase(Cat))
4057  return;
4058 
4059  // Check for duplicate categories.
4060  if (Cat->getDeclName()) {
4061  ObjCCategoryDecl *&Existing = NameCategoryMap[Cat->getDeclName()];
4062  if (Existing &&
4063  Reader.getOwningModuleFile(Existing)
4064  != Reader.getOwningModuleFile(Cat)) {
4065  // FIXME: We should not warn for duplicates in diamond:
4066  //
4067  // MT //
4068  // / \ //
4069  // ML MR //
4070  // \ / //
4071  // MB //
4072  //
4073  // If there are duplicates in ML/MR, there will be warning when
4074  // creating MB *and* when importing MB. We should not warn when
4075  // importing.
4076  Reader.Diag(Cat->getLocation(), diag::warn_dup_category_def)
4077  << Interface->getDeclName() << Cat->getDeclName();
4078  Reader.Diag(Existing->getLocation(), diag::note_previous_definition);
4079  } else if (!Existing) {
4080  // Record this category.
4081  Existing = Cat;
4082  }
4083  }
4084 
4085  // Add this category to the end of the chain.
4086  if (Tail)
4088  else
4089  Interface->setCategoryListRaw(Cat);
4090  Tail = Cat;
4091  }
4092 
4093  public:
4094  ObjCCategoriesVisitor(ASTReader &Reader,
4095  ObjCInterfaceDecl *Interface,
4096  llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
4097  serialization::GlobalDeclID InterfaceID,
4098  unsigned PreviousGeneration)
4099  : Reader(Reader), Interface(Interface), Deserialized(Deserialized),
4100  InterfaceID(InterfaceID), PreviousGeneration(PreviousGeneration) {
4101  // Populate the name -> category map with the set of known categories.
4102  for (auto *Cat : Interface->known_categories()) {
4103  if (Cat->getDeclName())
4104  NameCategoryMap[Cat->getDeclName()] = Cat;
4105 
4106  // Keep track of the tail of the category list.
4107  Tail = Cat;
4108  }
4109  }
4110 
4111  bool operator()(ModuleFile &M) {
4112  // If we've loaded all of the category information we care about from
4113  // this module file, we're done.
4114  if (M.Generation <= PreviousGeneration)
4115  return true;
4116 
4117  // Map global ID of the definition down to the local ID used in this
4118  // module file. If there is no such mapping, we'll find nothing here
4119  // (or in any module it imports).
4120  DeclID LocalID = Reader.mapGlobalIDToModuleFileGlobalID(M, InterfaceID);
4121  if (!LocalID)
4122  return true;
4123 
4124  // Perform a binary search to find the local redeclarations for this
4125  // declaration (if any).
4126  const ObjCCategoriesInfo Compare = { LocalID, 0 };
4127  const ObjCCategoriesInfo *Result
4128  = std::lower_bound(M.ObjCCategoriesMap,
4130  Compare);
4131  if (Result == M.ObjCCategoriesMap + M.LocalNumObjCCategoriesInMap ||
4132  Result->DefinitionID != LocalID) {
4133  // We didn't find anything. If the class definition is in this module
4134  // file, then the module files it depends on cannot have any categories,
4135  // so suppress further lookup.
4136  return Reader.isDeclIDFromModule(InterfaceID, M);
4137  }
4138 
4139  // We found something. Dig out all of the categories.
4140  unsigned Offset = Result->Offset;
4141  unsigned N = M.ObjCCategories[Offset];
4142  M.ObjCCategories[Offset++] = 0; // Don't try to deserialize again
4143  for (unsigned I = 0; I != N; ++I)
4144  add(cast_or_null<ObjCCategoryDecl>(
4145  Reader.GetLocalDecl(M, M.ObjCCategories[Offset++])));
4146  return true;
4147  }
4148  };
4149 
4150 } // namespace
4151 
4152 void ASTReader::loadObjCCategories(serialization::GlobalDeclID ID,
4153  ObjCInterfaceDecl *D,
4154  unsigned PreviousGeneration) {
4155  ObjCCategoriesVisitor Visitor(*this, D, CategoriesDeserialized, ID,
4156  PreviousGeneration);
4157  ModuleMgr.visit(Visitor);
4158 }
4159 
4160 template<typename DeclT, typename Fn>
4161 static void forAllLaterRedecls(DeclT *D, Fn F) {
4162  F(D);
4163 
4164  // Check whether we've already merged D into its redeclaration chain.
4165  // MostRecent may or may not be nullptr if D has not been merged. If
4166  // not, walk the merged redecl chain and see if it's there.
4167  auto *MostRecent = D->getMostRecentDecl();
4168  bool Found = false;
4169  for (auto *Redecl = MostRecent; Redecl && !Found;
4170  Redecl = Redecl->getPreviousDecl())
4171  Found = (Redecl == D);
4172 
4173  // If this declaration is merged, apply the functor to all later decls.
4174  if (Found) {
4175  for (auto *Redecl = MostRecent; Redecl != D;
4176  Redecl = Redecl->getPreviousDecl())
4177  F(Redecl);
4178  }
4179 }
4180 
4182  llvm::SmallVectorImpl<serialization::DeclID> &PendingLazySpecializationIDs) {
4183  while (Record.getIdx() < Record.size()) {
4184  switch ((DeclUpdateKind)Record.readInt()) {
4186  auto *RD = cast<CXXRecordDecl>(D);
4187  // FIXME: If we also have an update record for instantiating the
4188  // definition of D, we need that to happen before we get here.
4189  Decl *MD = Record.readDecl();
4190  assert(MD && "couldn't read decl from update record");
4191  // FIXME: We should call addHiddenDecl instead, to add the member
4192  // to its DeclContext.
4193  RD->addedMember(MD);
4194  break;
4195  }
4196 
4198  // It will be added to the template's lazy specialization set.
4199  PendingLazySpecializationIDs.push_back(readDeclID());
4200  break;
4201 
4203  auto *Anon = readDeclAs<NamespaceDecl>();
4204 
4205  // Each module has its own anonymous namespace, which is disjoint from
4206  // any other module's anonymous namespaces, so don't attach the anonymous
4207  // namespace at all.
4208  if (!Record.isModule()) {
4209  if (auto *TU = dyn_cast<TranslationUnitDecl>(D))
4210  TU->setAnonymousNamespace(Anon);
4211  else
4212  cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
4213  }
4214  break;
4215  }
4216 
4218  auto *VD = cast<VarDecl>(D);
4219  VD->NonParmVarDeclBits.IsInline = Record.readInt();
4220  VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
4221  uint64_t Val = Record.readInt();
4222  if (Val && !VD->getInit()) {
4223  VD->setInit(Record.readExpr());
4224  if (Val != 1) {
4225  EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
4226  Eval->HasConstantInitialization = (Val & 2) != 0;
4227  Eval->HasConstantDestruction = (Val & 4) != 0;
4228  }
4229  }
4230  break;
4231  }
4232 
4234  SourceLocation POI = Record.readSourceLocation();
4235  if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D)) {
4236  VTSD->setPointOfInstantiation(POI);
4237  } else if (auto *VD = dyn_cast<VarDecl>(D)) {
4238  VD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
4239  } else {
4240  auto *FD = cast<FunctionDecl>(D);
4241  if (auto *FTSInfo = FD->TemplateOrSpecialization
4242  .dyn_cast<FunctionTemplateSpecializationInfo *>())
4243  FTSInfo->setPointOfInstantiation(POI);
4244  else
4245  FD->TemplateOrSpecialization.get<MemberSpecializationInfo *>()
4246  ->setPointOfInstantiation(POI);
4247  }
4248  break;
4249  }
4250 
4252  auto *Param = cast<ParmVarDecl>(D);
4253 
4254  // We have to read the default argument regardless of whether we use it
4255  // so that hypothetical further update records aren't messed up.
4256  // TODO: Add a function to skip over the next expr record.
4257  auto *DefaultArg = Record.readExpr();
4258 
4259  // Only apply the update if the parameter still has an uninstantiated
4260  // default argument.
4261  if (Param->hasUninstantiatedDefaultArg())
4262  Param->setDefaultArg(DefaultArg);
4263  break;
4264  }
4265 
4267  auto *FD = cast<FieldDecl>(D);
4268  auto *DefaultInit = Record.readExpr();
4269 
4270  // Only apply the update if the field still has an uninstantiated
4271  // default member initializer.
4272  if (FD->hasInClassInitializer() && !FD->getInClassInitializer()) {
4273  if (DefaultInit)
4274  FD->setInClassInitializer(DefaultInit);
4275  else
4276  // Instantiation failed. We can get here if we serialized an AST for
4277  // an invalid program.
4278  FD->removeInClassInitializer();
4279  }
4280  break;
4281  }
4282 
4284  auto *FD = cast<FunctionDecl>(D);
4285  if (Reader.PendingBodies[FD]) {
4286  // FIXME: Maybe check for ODR violations.
4287  // It's safe to stop now because this update record is always last.
4288  return;
4289  }
4290 
4291  if (Record.readInt()) {
4292  // Maintain AST consistency: any later redeclarations of this function
4293  // are inline if this one is. (We might have merged another declaration
4294  // into this one.)
4295  forAllLaterRedecls(FD, [](FunctionDecl *FD) {
4296  FD->setImplicitlyInline();
4297  });
4298  }
4299  FD->setInnerLocStart(readSourceLocation());
4300  ReadFunctionDefinition(FD);
4301  assert(Record.getIdx() == Record.size() && "lazy body must be last");
4302  break;
4303  }
4304 
4306  auto *RD = cast<CXXRecordDecl>(D);
4307  auto *OldDD = RD->getCanonicalDecl()->DefinitionData;
4308  bool HadRealDefinition =
4309  OldDD && (OldDD->Definition != RD ||
4310  !Reader.PendingFakeDefinitionData.count(OldDD));
4311  RD->setParamDestroyedInCallee(Record.readInt());
4312  RD->setArgPassingRestrictions(
4313  (RecordDecl::ArgPassingKind)Record.readInt());
4314  ReadCXXRecordDefinition(RD, /*Update*/true);
4315 
4316  // Visible update is handled separately.
4317  uint64_t LexicalOffset = ReadLocalOffset();
4318  if (!HadRealDefinition && LexicalOffset) {
4319  Record.readLexicalDeclContextStorage(LexicalOffset, RD);
4320  Reader.PendingFakeDefinitionData.erase(OldDD);
4321  }
4322 
4323  auto TSK = (TemplateSpecializationKind)Record.readInt();
4324  SourceLocation POI = readSourceLocation();
4325  if (MemberSpecializationInfo *MSInfo =
4326  RD->getMemberSpecializationInfo()) {
4327  MSInfo->setTemplateSpecializationKind(TSK);
4328  MSInfo->setPointOfInstantiation(POI);
4329  } else {
4330  auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
4331  Spec->setTemplateSpecializationKind(TSK);
4332  Spec->setPointOfInstantiation(POI);
4333 
4334  if (Record.readInt()) {
4335  auto *PartialSpec =
4336  readDeclAs<ClassTemplatePartialSpecializationDecl>();
4338  Record.readTemplateArgumentList(TemplArgs);
4339  auto *TemplArgList = TemplateArgumentList::CreateCopy(
4340  Reader.getContext(), TemplArgs);
4341 
4342  // FIXME: If we already have a partial specialization set,
4343  // check that it matches.
4344  if (!Spec->getSpecializedTemplateOrPartial()
4346  Spec->setInstantiationOf(PartialSpec, TemplArgList);
4347  }
4348  }
4349 
4350  RD->setTagKind((TagTypeKind)Record.readInt());
4351  RD->setLocation(readSourceLocation());
4352  RD->setLocStart(readSourceLocation());
4353  RD->setBraceRange(readSourceRange());
4354 
4355  if (Record.readInt()) {
4356  AttrVec Attrs;
4357  Record.readAttributes(Attrs);
4358  // If the declaration already has attributes, we assume that some other
4359  // AST file already loaded them.
4360  if (!D->hasAttrs())
4361  D->setAttrsImpl(Attrs, Reader.getContext());
4362  }
4363  break;
4364  }
4365 
4367  // Set the 'operator delete' directly to avoid emitting another update
4368  // record.
4369  auto *Del = readDeclAs<FunctionDecl>();
4370  auto *First = cast<CXXDestructorDecl>(D->getCanonicalDecl());
4371  auto *ThisArg = Record.readExpr();
4372  // FIXME: Check consistency if we have an old and new operator delete.
4373  if (!First->OperatorDelete) {
4374  First->OperatorDelete = Del;
4375  First->OperatorDeleteThisArg = ThisArg;
4376  }
4377  break;
4378  }
4379 
4381  SmallVector<QualType, 8> ExceptionStorage;
4382  auto ESI = Record.readExceptionSpecInfo(ExceptionStorage);
4383 
4384  // Update this declaration's exception specification, if needed.
4385  auto *FD = cast<FunctionDecl>(D);
4386  auto *FPT = FD->getType()->castAs<FunctionProtoType>();
4387  // FIXME: If the exception specification is already present, check that it
4388  // matches.
4389  if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType())) {
4390  FD->setType(Reader.getContext().getFunctionType(
4391  FPT->getReturnType(), FPT->getParamTypes(),
4392  FPT->getExtProtoInfo().withExceptionSpec(ESI)));
4393 
4394  // When we get to the end of deserializing, see if there are other decls
4395  // that we need to propagate this exception specification onto.
4396  Reader.PendingExceptionSpecUpdates.insert(
4397  std::make_pair(FD->getCanonicalDecl(), FD));
4398  }
4399  break;
4400  }
4401 
4403  auto *FD = cast<FunctionDecl>(D);
4404  QualType DeducedResultType = Record.readType();
4405  Reader.PendingDeducedTypeUpdates.insert(
4406  {FD->getCanonicalDecl(), DeducedResultType});
4407  break;
4408  }
4409 
4410  case UPD_DECL_MARKED_USED:
4411  // Maintain AST consistency: any later redeclarations are used too.
4412  D->markUsed(Reader.getContext());
4413  break;
4414 
4415  case UPD_MANGLING_NUMBER:
4416  Reader.getContext().setManglingNumber(cast<NamedDecl>(D),
4417  Record.readInt());
4418  break;
4419 
4421  Reader.getContext().setStaticLocalNumber(cast<VarDecl>(D),
4422  Record.readInt());
4423  break;
4424 
4426  D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(
4427  Reader.getContext(), readSourceRange(),
4429  break;
4430 
4432  auto AllocatorKind =
4433  static_cast<OMPAllocateDeclAttr::AllocatorTypeTy>(Record.readInt());
4434  Expr *Allocator = Record.readExpr();
4435  Expr *Alignment = Record.readExpr();
4436  SourceRange SR = readSourceRange();
4437  D->addAttr(OMPAllocateDeclAttr::CreateImplicit(
4438  Reader.getContext(), AllocatorKind, Allocator, Alignment, SR,
4440  break;
4441  }
4442 
4443  case UPD_DECL_EXPORTED: {
4444  unsigned SubmoduleID = readSubmoduleID();
4445  auto *Exported = cast<NamedDecl>(D);
4446  Module *Owner = SubmoduleID ? Reader.getSubmodule(SubmoduleID) : nullptr;
4447  Reader.getContext().mergeDefinitionIntoModule(Exported, Owner);
4448  Reader.PendingMergedDefinitionsToDeduplicate.insert(Exported);
4449  break;
4450  }
4451 
4453  auto MapType = Record.readEnum<OMPDeclareTargetDeclAttr::MapTypeTy>();
4454  auto DevType = Record.readEnum<OMPDeclareTargetDeclAttr::DevTypeTy>();
4455  Expr *IndirectE = Record.readExpr();
4456  bool Indirect = Record.readBool();
4457  unsigned Level = Record.readInt();
4458  D->addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(
4459  Reader.getContext(), MapType, DevType, IndirectE, Indirect, Level,
4460  readSourceRange(), AttributeCommonInfo::AS_Pragma));
4461  break;
4462  }
4463 
4465  AttrVec Attrs;
4466  Record.readAttributes(Attrs);
4467  assert(Attrs.size() == 1);
4468  D->addAttr(Attrs[0]);
4469  break;
4470  }
4471  }
4472 }
clang::ASTDeclReader::AddLazySpecializations
static void AddLazySpecializations(T *D, SmallVectorImpl< serialization::DeclID > &IDs)
Definition: ASTReaderDecl.cpp:257
clang::serialization::DECL_CXX_METHOD
@ DECL_CXX_METHOD
A CXXMethodDecl record.
Definition: ASTBitCodes.h:1389
clang::operator!=
bool operator!=(CanQual< T > x, CanQual< U > y)
Definition: CanonicalType.h:207
clang::EnumDecl::setIntegerTypeSourceInfo
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
Definition: Decl.h:3800
clang::serialization::DECL_NAMESPACE
@ DECL_NAMESPACE
A NamespaceDecl record.
Definition: ASTBitCodes.h:1347
clang::TemplateDecl::getTemplatedDecl
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:432
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1150
clang::ObjCMethodDecl::setHasRedeclaration
void setHasRedeclaration(bool HRD) const
Definition: DeclObjC.h:275
clang::OMPAllocateDecl
This represents '#pragma omp allocate ...' directive.
Definition: DeclOpenMP.h:473
clang::EmptyDecl
Represents an empty-declaration.
Definition: Decl.h:4632
clang::ObjCImplementationDecl::setSuperClass
void setSuperClass(ObjCInterfaceDecl *superCls)
Definition: DeclObjC.h:2687
clang::ObjCInterfaceDecl::CreateDeserialized
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1523
clang::serialization::DECL_OMP_DECLARE_MAPPER
@ DECL_OMP_DECLARE_MAPPER
An OMPDeclareMapperDecl record.
Definition: ASTBitCodes.h:1506
clang::ASTRecordReader::getSubmodule
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTRecordReader.h:95
clang::ObjCCompatibleAliasDecl
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2723
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:414
clang::serialization::DECL_CAPTURED
@ DECL_CAPTURED
A CapturedDecl record.
Definition: ASTBitCodes.h:1322
clang::AccessSpecDecl
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:86
clang::RedeclarableTemplateDecl::setInstantiatedFromMemberTemplate
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
Definition: DeclTemplate.h:941
clang::FunctionDecl::isDefaulted
bool isDefaulted() const
Whether this function is defaulted.
Definition: Decl.h:2231
clang::serialization::DECL_USING
@ DECL_USING
A UsingDecl record.
Definition: ASTBitCodes.h:1353
clang::ASTReader::getContext
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Definition: ASTReader.h:2277
clang::serialization::DECL_PARM_VAR
@ DECL_PARM_VAR
A ParmVarDecl record.
Definition: ASTBitCodes.h:1307
clang::serialization::DECL_USING_SHADOW
@ DECL_USING_SHADOW
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1362
clang::Decl::IDNS_Type
@ IDNS_Type
Types, declared with 'struct foo', typedefs, etc.
Definition: DeclBase.h:127
clang::ObjCMethodDecl::hasRedeclaration
bool hasRedeclaration() const
True if redeclared in the same interface.
Definition: DeclObjC.h:274
clang::serialization::ModuleFile::ObjCCategories
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
Definition: ModuleFile.h:471
clang::RecordDecl::setHasNonTrivialToPrimitiveCopyCUnion
void setHasNonTrivialToPrimitiveCopyCUnion(bool V)
Definition: Decl.h:4044
clang::CXXConstructorDecl
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2421
clang::VarDecl::getStorageDuration
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition: Decl.h:1144
clang::ASTDeclReader::VisitUnresolvedUsingTypenameDecl
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
Definition: ASTReaderDecl.cpp:1802
clang::ASTDeclReader::VisitObjCPropertyDecl
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
Definition: ASTReaderDecl.cpp:1368
clang::ASTDeclReader::VisitObjCContainerDecl
void VisitObjCContainerDecl(ObjCContainerDecl *D)
Definition: ASTReaderDecl.cpp:1121
clang::RecordDecl::setArgPassingRestrictions
void setArgPassingRestrictions(ArgPassingKind Kind)
Definition: Decl.h:4059
clang::FriendTemplateDecl
Declaration of a friend template.
Definition: DeclTemplate.h:2461
clang::Decl::setDeclContext
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
Definition: DeclBase.cpp:327
Specifiers.h
clang::FunctionProtoType::getExceptionSpecType
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Definition: Type.h:4133
clang::RedeclarableTemplateDecl::newCommon
virtual CommonBase * newCommon(ASTContext &C) const =0
clang::RecordDecl::setHasFlexibleArrayMember
void setHasFlexibleArrayMember(bool V)
Definition: Decl.h:3959
clang::LinkageSpecDecl::setLanguage
void setLanguage(LanguageIDs L)
Set the language specified by this linkage specification.
Definition: DeclCXX.h:2851
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6482
clang::AttributeCommonInfo::Kind
Kind
Definition: AttributeCommonInfo.h:55
clang::index::SymbolKind::Class
@ Class
clang::serialization::DECL_UNRESOLVED_USING_IF_EXISTS
@ DECL_UNRESOLVED_USING_IF_EXISTS
An UnresolvedUsingIfExistsDecl record.
Definition: ASTBitCodes.h:1446
clang::UsingPackDecl::CreateDeserialized
static UsingPackDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions)
Definition: DeclCXX.cpp:3092
clang::VarTemplatePartialSpecializationDecl::CreateDeserialized
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1384
clang::MemberSpecializationInfo
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:620
clang::ObjCPropertyDecl::setPropertyAttributesAsWritten
void setPropertyAttributesAsWritten(ObjCPropertyAttribute::Kind PRVal)
Definition: DeclObjC.h:827
clang::ASTDeclReader::VisitEnumDecl
void VisitEnumDecl(EnumDecl *ED)
Definition: ASTReaderDecl.cpp:744
clang::serialization::DECL_EMPTY
@ DECL_EMPTY
An EmptyDecl record.
Definition: ASTBitCodes.h:1485
clang::for
for(unsigned I=0, E=TL.getNumArgs();I !=E;++I)
Definition: RecursiveASTVisitor.h:1401
clang::serialization::DECL_FRIEND_TEMPLATE
@ DECL_FRIEND_TEMPLATE
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1407
clang::BlockDecl::CreateDeserialized
static BlockDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4991
clang::TypeAliasTemplateDecl::CreateDeserialized
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
Definition: DeclTemplate.cpp:1131
clang::FunctionDecl::TK_MemberSpecialization
@ TK_MemberSpecialization
Definition: Decl.h:1886
Error
llvm::Error Error
Definition: ByteCodeEmitter.cpp:20
clang::ObjCMethodDecl::setPropertyAccessor
void setPropertyAccessor(bool isAccessor)
Definition: DeclObjC.h:445
clang::LinkageSpecDecl
Represents a linkage specification.
Definition: DeclCXX.h:2817
clang::TagDecl::setFreeStanding
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
Definition: Decl.h:3491
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::Decl::getImportedOwningModule
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
Definition: DeclBase.h:752
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::serialization::DECL_TYPE_ALIAS_TEMPLATE
@ DECL_TYPE_ALIAS_TEMPLATE
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1440
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1356
clang::NonTypeTemplateParmDecl::hasPlaceholderTypeConstraint
bool hasPlaceholderTypeConstraint() const
Determine whether this non-type template parameter's type has a placeholder with a type-constraint.
Definition: DeclTemplate.h:1590
clang::serialization::DECL_DECOMPOSITION
@ DECL_DECOMPOSITION
A DecompositionDecl record.
Definition: ASTBitCodes.h:1310
clang::ASTDeclReader::VisitVarTemplateSpecializationDeclImpl
RedeclarableResult VisitVarTemplateSpecializationDeclImpl(VarTemplateSpecializationDecl *D)
TODO: Unify with ClassTemplateSpecializationDecl version? May require unifying ClassTemplate(Partial)...
Definition: ASTReaderDecl.cpp:2375
clang::FunctionDecl::TK_FunctionTemplate
@ TK_FunctionTemplate
Definition: Decl.h:1883
clang::LambdaCapture
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
clang::CXXConversionDecl
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2751
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:542
clang::ImplicitParamDecl::CreateDeserialized
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4962
clang::Redeclarable
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:84
clang::ASTDeclReader::VisitTemplateDecl
DeclID VisitTemplateDecl(TemplateDecl *D)
Definition: ASTReaderDecl.cpp:2162
clang::ASTDeclReader::VisitObjCCategoryDecl
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
Definition: ASTReaderDecl.cpp:1331
clang::NamespaceAliasDecl
Represents a C++ namespace alias.
Definition: DeclCXX.h:3006
clang::ObjCImplementationDecl
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2548
clang::serialization::DECL_USING_PACK
@ DECL_USING_PACK
A UsingPackDecl record.
Definition: ASTBitCodes.h:1359
clang::OMPRequiresDecl::CreateDeserialized
static OMPRequiresDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Create deserialized requires node.
Definition: DeclOpenMP.cpp:92
clang::OMPDeclareMapperDecl::CreateDeserialized
static OMPDeclareMapperDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Creates deserialized declare mapper node.
Definition: DeclOpenMP.cpp:150
clang::Decl::isTemplateParameter
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
Definition: DeclBase.h:2556
clang::serialization::DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION
@ DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
Definition: ASTBitCodes.h:1470
clang::IdentifierResolver::begin
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
Definition: IdentifierResolver.cpp:232
clang::ASTDeclReader::VisitFriendTemplateDecl
void VisitFriendTemplateDecl(FriendTemplateDecl *D)
Definition: ASTReaderDecl.cpp:2148
clang::EnumConstantDecl::setInitVal
void setInitVal(const llvm::APSInt &V)
Definition: Decl.h:3094
clang::ASTDeclReader::VisitUsingDecl
void VisitUsingDecl(UsingDecl *D)
Definition: ASTReaderDecl.cpp:1732
clang::serialization::DeclOffset
Source location and bit offset of a declaration.
Definition: ASTBitCodes.h:241
clang::serialization::ModuleFile::ObjCCategoriesMap
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID.
Definition: ModuleFile.h:464
clang::ASTDeclReader::VisitBindingDecl
void VisitBindingDecl(BindingDecl *BD)
Definition: ASTReaderDecl.cpp:1616
clang::UsingDirectiveDecl
Represents C++ using-directive.
Definition: DeclCXX.h:2902
clang::BindingDecl
A binding in a decomposition declaration.
Definition: DeclCXX.h:3979
clang::TemplateTypeParmDecl::CreateDeserialized
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:645
clang::serialization::DECL_OMP_THREADPRIVATE
@ DECL_OMP_THREADPRIVATE
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1476
clang::ASTDeclReader::VisitObjCProtocolDecl
void VisitObjCProtocolDecl(ObjCProtocolDecl *D)
Definition: ASTReaderDecl.cpp:1298
llvm::SmallVector< uint64_t, 64 >
clang::UsingDirectiveDecl::CreateDeserialized
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2831
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::ASTDeclReader::VisitEnumConstantDecl
void VisitEnumConstantDecl(EnumConstantDecl *ECD)
Definition: ASTReaderDecl.cpp:852
clang::ObjCImplementationDecl::setHasNonZeroConstructors
void setHasNonZeroConstructors(bool val)
Definition: DeclObjC.h:2651
clang::Redeclarable::PreviousDeclLink
static DeclLink PreviousDeclLink(decl_type *D)
Definition: Redeclarable.h:166
clang::OMPThreadPrivateDecl
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:110
clang::serialization::DECL_PRAGMA_COMMENT
@ DECL_PRAGMA_COMMENT
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1500
clang::VarDecl::ParmVarDeclBits
ParmVarDeclBitfields ParmVarDeclBits
Definition: Decl.h:1039
clang::ASTRecordReader
An object for streaming information from a record.
Definition: ASTRecordReader.h:31
clang::ASTRecordReader::readAttributes
void readAttributes(AttrVec &Attrs)
Reads attributes from the current stream position, advancing Idx.
Definition: ASTReaderDecl.cpp:2911
clang::NamespaceDecl::setInline
void setInline(bool Inline)
Set whether this is an inline namespace declaration.
Definition: Decl.h:606
clang::ASTReader::RecordData
SmallVector< uint64_t, 64 > RecordData
Definition: ASTReader.h:361
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::DeclContext::getPrimaryContext
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1242
clang::Decl::ModuleOwnershipKind::ModulePrivate
@ ModulePrivate
This declaration has an owning module, but is only visible to lookups that occur within that module.
clang::VarDecl::setInit
void setInit(Expr *I)
Definition: Decl.cpp:2359
clang::serialization::ModuleFile::DeclsBlockStartOffset
uint64_t DeclsBlockStartOffset
The offset to the start of the DECLTYPES_BLOCK block.
Definition: ModuleFile.h:434
clang::UsingDecl::setTypename
void setTypename(bool TN)
Sets whether the using declaration has 'typename'.
Definition: DeclCXX.h:3451
clang::BlockDecl::setSignatureAsWritten
void setSignatureAsWritten(TypeSourceInfo *Sig)
Definition: Decl.h:4283
IdentifierResolver.h
clang::serialization::ModuleFile::Generation
unsigned Generation
The generation of which this module file is a part.
Definition: ModuleFile.h:185
clang::OMPThreadPrivateDecl::CreateDeserialized
static OMPThreadPrivateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Definition: DeclOpenMP.cpp:38
clang::RecordDecl::setHasVolatileMember
void setHasVolatileMember(bool val)
Definition: Decl.h:3987
clang::TemplateTypeParmDecl::setDefaultArgument
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
Definition: DeclTemplate.h:1288
clang::ObjCPropertyDecl::setSetterMethodDecl
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
Definition: DeclObjC.h:901
getDeclForMerging
static NamedDecl * getDeclForMerging(NamedDecl *Found, bool IsTypedefNameForLinkage)
Find the declaration that should be merged into, given the declaration found by name lookup.
Definition: ASTReaderDecl.cpp:3080
clang::OMPTraitInfo
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
Definition: OpenMPClause.h:8801
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:675
clang::ASTRecordReader::GetLocalDeclAs
T * GetLocalDeclAs(uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTRecordReader.h:146
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1401
clang::OMPDeclareReductionDecl::CreateDeserialized
static OMPDeclareReductionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create deserialized declare reduction node.
Definition: DeclOpenMP.cpp:120
Attr.h
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:55
clang::ASTDeclReader::VisitEmptyDecl
void VisitEmptyDecl(EmptyDecl *D)
Definition: ASTReaderDecl.cpp:2533
clang::VarDecl::NonParmVarDeclBits
NonParmVarDeclBitfields NonParmVarDeclBits
Definition: Decl.h:1040
Cursor
Cursor
Definition: SerializedDiagnosticReader.cpp:109
clang::serialization::DECL_USING_ENUM
@ DECL_USING_ENUM
A UsingEnumDecl record.
Definition: ASTBitCodes.h:1356
clang::ClassScopeFunctionSpecializationDecl
Declaration of a function specialization at template class scope.
Definition: DeclTemplate.h:2621
clang::TemplateTemplateParmDecl::setDefaultArgument
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Definition: DeclTemplate.cpp:854
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2855
clang::TagDecl::setBraceRange
void setBraceRange(SourceRange R)
Definition: Decl.h:3430
clang::LookupResult
Represents the results of name lookup.
Definition: Lookup.h:46
clang::serialization::UPD_CXX_POINT_OF_INSTANTIATION
@ UPD_CXX_POINT_OF_INSTANTIATION
Definition: ASTCommon.h:30
clang::ExportDecl::CreateDeserialized
static ExportDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:5253
clang::ASTDeclReader::VisitObjCAtDefsFieldDecl
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
Definition: ASTReaderDecl.cpp:1327
clang::DeclListNode::iterator
Definition: DeclBase.h:1253
clang::isUnresolvedExceptionSpec
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
Definition: ExceptionSpecificationType.h:49
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1680
clang::NamespaceAliasDecl::CreateDeserialized
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2927
clang::Redeclarable::getFirstDecl
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:216
clang::ObjCProtocolDecl::getCanonicalDecl
ObjCProtocolDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C protocol.
Definition: DeclObjC.h:2246
clang::ASTRecordReader::getGlobalBitOffset
uint64_t getGlobalBitOffset(uint64_t LocalOffset)
Read information about an exception specification (inherited).
Definition: ASTRecordReader.h:125
DeclCXX.h
memcpy
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Definition: __clang_cuda_device_functions.h:1549
clang::TagDecl::getCanonicalDecl
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:4371
clang::ASTContext::getFunctionType
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:1547
clang::EnumDecl::getODRHash
unsigned getODRHash()
Definition: Decl.cpp:4579
clang::Type::getContainedDeducedType
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.cpp:1888
clang::CXXMethodDecl::getCanonicalDecl
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:2053
clang::ParmVarDecl::CreateDeserialized
static ParmVarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:2827
clang::serialization::DECL_CONSTRUCTOR_USING_SHADOW
@ DECL_CONSTRUCTOR_USING_SHADOW
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1365
Module.h
clang::FunctionDecl::TK_FunctionTemplateSpecialization
@ TK_FunctionTemplateSpecialization
Definition: Decl.h:1890
AttrIterator.h
clang::IdentifierInfo::isOutOfDate
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
Definition: IdentifierTable.h:414
clang::serialization::UPD_CXX_RESOLVED_EXCEPTION_SPEC
@ UPD_CXX_RESOLVED_EXCEPTION_SPEC
Definition: ASTCommon.h:35
clang::UsingShadowDecl
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3207
clang::serialization::UPD_DECL_MARKED_OPENMP_DECLARETARGET
@ UPD_DECL_MARKED_OPENMP_DECLARETARGET
Definition: ASTCommon.h:42
DeclOpenMP.h
clang::Decl::isTemplateParameterPack
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
Definition: DeclBase.cpp:201
clang::ASTDeclReader::VisitTemplateTemplateParmDecl
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
Definition: ASTReaderDecl.cpp:2502
clang::Decl::setTopLevelDeclInObjCContainer
void setTopLevelDeclInObjCContainer(bool V=true)
Definition: DeclBase.h:597
clang::serialization::UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT
@ UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT
Definition: ASTCommon.h:32
clang::TemplateTemplateParmDecl::setDepth
void setDepth(unsigned D)
Definition: DeclTemplate.h:1172
clang::ASTDeclReader::mergeMergeable
void mergeMergeable(Mergeable< T > *D)
Attempts to merge the given declaration (D) with another declaration of the same entity,...
Definition: ASTReaderDecl.cpp:2769
clang::Module::ModuleMapModule
@ ModuleMapModule
This is a module that was defined by a module map and built out of header files.
Definition: Module.h:107
clang::ASTDeclReader::VisitTypeAliasTemplateDecl
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
Definition: ASTReaderDecl.cpp:2521
clang::ObjCPropertyImplDecl
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2753
clang::ASTRecordReader::readOMPTraitInfo
OMPTraitInfo * readOMPTraitInfo()
Read an OMPTraitInfo object, advancing Idx.
Definition: ASTReader.cpp:13012
clang::ASTDeclReader::VisitNamedDecl
void VisitNamedDecl(NamedDecl *ND)
Definition: ASTReaderDecl.cpp:664
clang::serialization::UPD_STATIC_LOCAL_NUMBER
@ UPD_STATIC_LOCAL_NUMBER
Definition: ASTCommon.h:39
assert_cast
static T assert_cast(T t)
"Cast" to type T, asserting if we don't have an implicit conversion.
Definition: ASTReaderDecl.cpp:2644
clang::serialization::DECL_IMPLICIT_PARAM
@ DECL_IMPLICIT_PARAM
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1304
clang::ObjCCategoryDecl::IsClassExtension
bool IsClassExtension() const
Definition: DeclObjC.h:2386
clang::ASTRecordReader::readDeclID
serialization::DeclID readDeclID()
Reads a declaration ID from the given position in this record.
Definition: ASTRecordReader.h:187
clang::UnresolvedUsingValueDecl::CreateDeserialized
static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3117
clang::ComparisonCategoryType::First
@ First
clang::ObjCImplementationDecl::setHasDestructors
void setHasDestructors(bool val)
Definition: DeclObjC.h:2656
clang::RedeclarableTemplateDecl::setMemberSpecialization
void setMemberSpecialization()
Note that this member template is a specialization.
Definition: DeclTemplate.h:895
ASTRecordReader.h
clang::OMPAllocateDecl::CreateDeserialized
static OMPAllocateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NVars, unsigned NClauses)
Definition: DeclOpenMP.cpp:66
clang::ASTDeclReader::VisitImportDecl
void VisitImportDecl(ImportDecl *D)
Definition: ASTReaderDecl.cpp:2119
clang::serialization::DECL_UNRESOLVED_USING_TYPENAME
@ DECL_UNRESOLVED_USING_TYPENAME
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1374
clang::ASTRecordReader::readVersionTuple
VersionTuple readVersionTuple()
Read a version tuple, advancing Idx.
Definition: ASTRecordReader.h:320
clang::FunctionDecl::setInlineSpecified
void setInlineSpecified(bool I)
Set whether the "inline" keyword was specified for this function.
Definition: Decl.h:2614
clang::ASTDeclReader::Visit
void Visit(Decl *D)
Definition: ASTReaderDecl.cpp:529
clang::FunctionDecl::setDefaulted
void setDefaulted(bool D=true)
Definition: Decl.h:2232
clang::ASTDeclReader::VisitClassTemplateDecl
void VisitClassTemplateDecl(ClassTemplateDecl *D)
Definition: ASTReaderDecl.cpp:2220
clang::ObjCPropertyDecl::setPropertyAttributes
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
Definition: DeclObjC.h:815
clang::ASTDeclReader::getMostRecentDeclImpl
static Decl * getMostRecentDeclImpl(Redeclarable< DeclT > *D)
Definition: ASTReaderDecl.cpp:3263
clang::serialization::ModuleFile::BaseDeclID
serialization::DeclID BaseDeclID
Base declaration ID for declarations local to this module.
Definition: ModuleFile.h:444
clang::ASTRecordReader::readIdentifier
IdentifierInfo * readIdentifier()
Definition: ASTRecordReader.h:210
clang::serialization::ModuleFile::GlobalBitOffset
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
Definition: ModuleFile.h:195
clang::ASTDeclReader::VisitObjCCompatibleAliasDecl
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
Definition: ASTReaderDecl.cpp:1363
clang::serialization::DECL_CLASS_TEMPLATE
@ DECL_CLASS_TEMPLATE
A ClassTemplateDecl record.
Definition: ASTBitCodes.h:1410
clang::serialization::DECL_OBJC_PROPERTY_IMPL
@ DECL_OBJC_PROPERTY_IMPL
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1286
clang::ObjCCompatibleAliasDecl::CreateDeserialized
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2285
clang::NonTypeTemplateParmDecl::setPosition
void setPosition(unsigned P)
Definition: DeclTemplate.h:1180
llvm::Expected
Definition: LLVM.h:41
clang::BlockDecl::setDoesNotEscape
void setDoesNotEscape(bool B=true)
Definition: Decl.h:4353
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2092
clang::UsingPackDecl
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition: DeclCXX.h:3664
clang::TypedefNameDecl::setModedTypeSourceInfo
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
Definition: Decl.h:3266
clang::ASTDeclReader::VisitVarTemplatePartialSpecializationDecl
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
TODO: Unify with ClassTemplatePartialSpecializationDecl version? May require unifying ClassTemplate(P...
Definition: ASTReaderDecl.cpp:2441
ContinuousRangeMap.h
clang::ObjCCategoryDecl::setIvarLBraceLoc
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2412
clang::sema::Capture
Definition: ScopeInfo.h:528
clang::ExportDecl
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:4585
clang::RedeclarableTemplateDecl
Declaration of a redeclarable template.
Definition: DeclTemplate.h:753
clang::MSGuidDeclParts::Part1
uint32_t Part1
{01234567-...
Definition: DeclCXX.h:4138
clang::serialization::DECL_REQUIRES_EXPR_BODY
@ DECL_REQUIRES_EXPR_BODY
A RequiresExprBodyDecl record.
Definition: ASTBitCodes.h:1491
clang::FunctionDecl::setDeletedAsWritten
void setDeletedAsWritten(bool D=true)
Definition: Decl.h:2362
clang::TypeDecl::setLocStart
void setLocStart(SourceLocation L)
Definition: Decl.h:3186
clang::FunctionDecl::setStorageClass
void setStorageClass(StorageClass SClass)
Sets the storage class as written in the source.
Definition: Decl.h:2605
clang::LifetimeExtendedTemporaryDecl::getManglingNumber
unsigned getManglingNumber() const
Definition: DeclCXX.h:3165
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3559
clang::FunctionDecl::setLateTemplateParsed
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
Definition: Decl.h:2215
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2681
clang::UsingDecl::setUsingLoc
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
Definition: DeclCXX.h:3429
clang::CapturedDecl
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4390
clang::serialization::DECL_FIELD
@ DECL_FIELD
A FieldDecl record.
Definition: ASTBitCodes.h:1289
clang::serialization::DECL_TYPEALIAS
@ DECL_TYPEALIAS
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1241
clang::FunctionDecl::getMemberSpecializationInfo
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
Definition: Decl.cpp:3752
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
clang::serialization::isPartOfPerModuleInitializer
bool isPartOfPerModuleInitializer(const Decl *D)
Determine whether the given declaration will be included in the per-module initializer if it needs to...
Definition: ASTCommon.h:116
clang::AttributeCommonInfo::Syntax
Syntax
The style used to specify an attribute.
Definition: AttributeCommonInfo.h:25
clang::serialization::DECL_UNNAMED_GLOBAL_CONSTANT
@ DECL_UNNAMED_GLOBAL_CONSTANT
A UnnamedGlobalConstantDecl record.
Definition: ASTBitCodes.h:1512
clang::serialization::UPD_CXX_ADDED_VAR_DEFINITION
@ UPD_CXX_ADDED_VAR_DEFINITION
Definition: ASTCommon.h:29
clang::ASTContext::getTranslationUnitDecl
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1078
clang::ASTDeclReader::VisitOMPAllocateDecl
void VisitOMPAllocateDecl(OMPAllocateDecl *D)
Definition: ASTReaderDecl.cpp:2793
clang::ASTDeclReader::attachLatestDeclImpl
static void attachLatestDeclImpl(Redeclarable< DeclT > *D, Decl *Latest)
Definition: ASTReaderDecl.cpp:3468
clang::ClassTemplateDecl::CreateDeserialized
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
Definition: DeclTemplate.cpp:462
clang::serialization::DECL_RECORD
@ DECL_RECORD
A RecordDecl record.
Definition: ASTBitCodes.h:1247
clang::serialization::DECL_OBJC_INTERFACE
@ DECL_OBJC_INTERFACE
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:1259
clang::serialization::DECL_FUNCTION_TEMPLATE
@ DECL_FUNCTION_TEMPLATE
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1428
clang::DeclContextLookupResult::begin
iterator begin()
Definition: DeclBase.h:1315
clang::Decl::markUsed
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
Definition: DeclBase.cpp:458
clang::ASTDeclReader::VisitValueDecl
void VisitValueDecl(ValueDecl *VD)
Definition: ASTReaderDecl.cpp:841
clang::FriendDecl::CreateDeserialized
static FriendDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned FriendTypeNumTPLists)
Definition: DeclFriend.cpp:65
clang::EnumDecl::setIntegerType
void setIntegerType(QualType T)
Set the underlying integer type.
Definition: Decl.h:3797
clang::ASTDeclReader::VisitTypedefNameDecl
RedeclarableResult VisitTypedefNameDecl(TypedefNameDecl *TD)
Definition: ASTReaderDecl.cpp:678
clang::RecordDecl::setHasNonTrivialToPrimitiveDefaultInitializeCUnion
void setHasNonTrivialToPrimitiveDefaultInitializeCUnion(bool V)
Definition: Decl.h:4028
clang::serialization::DeclUpdateKind
DeclUpdateKind
Definition: ASTCommon.h:24
clang::ASTDeclReader::VisitClassTemplateSpecializationDecl
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
Definition: ASTReaderDecl.cpp:342
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3628
clang::ASTDeclReader::VisitObjCImplDecl
void VisitObjCImplDecl(ObjCImplDecl *D)
Definition: ASTReaderDecl.cpp:1391
clang::serialization::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
@ DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1416
clang::TemplateTypeParmDecl::setTypeConstraint
void setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
Definition: DeclTemplate.cpp:690
clang::TemplateDecl::init
void init(NamedDecl *templatedDecl, TemplateParameterList *templateParams)
Initialize the underlying templated declaration and template parameters.
Definition: DeclTemplate.h:457
clang::ObjCIvarDecl::AccessControl
AccessControl
Definition: DeclObjC.h:1927
Decl.h
clang::TypeAliasDecl::CreateDeserialized
static TypeAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:5123
DeclObjC.h
Offset
unsigned Offset
Definition: Format.cpp:2553
clang::ObjCIvarDecl::getContainingInterface
ObjCInterfaceDecl * getContainingInterface()
Return the class interface that this ivar is logically contained in; this is either the interface whe...
Definition: DeclObjC.cpp:1846
clang::ASTDeclReader::VisitDecl
void VisitDecl(Decl *D)
Definition: ASTReaderDecl.cpp:564
clang::serialization::DECL_CXX_RECORD
@ DECL_CXX_RECORD
A CXXRecordDecl record.
Definition: ASTBitCodes.h:1383
clang::InheritableAttr
Definition: Attr.h:137
clang::IdentifierResolver::tryAddTopLevelDecl
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...
Definition: IdentifierResolver.cpp:304
clang::RecordDecl::setHasObjectMember
void setHasObjectMember(bool val)
Definition: Decl.h:3983
clang::serialization::needsAnonymousDeclarationNumber
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:449
forAllLaterRedecls
static void forAllLaterRedecls(DeclT *D, Fn F)
Definition: ASTReaderDecl.cpp:4161
clang::serialization::DECL_CXX_BASE_SPECIFIERS
@ DECL_CXX_BASE_SPECIFIERS
A record containing CXXBaseSpecifiers.
Definition: ASTBitCodes.h:1452
clang::PragmaDetectMismatchDecl::CreateDeserialized
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize)
Definition: Decl.cpp:4901
clang::ASTDeclReader::VisitCXXDeductionGuideDecl
void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *GD)
Definition: ASTReaderDecl.cpp:2061
clang::CXXConstructorDecl::CreateDeserialized
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, unsigned ID, uint64_t AllocKind)
Definition: DeclCXX.cpp:2584
clang::TagDecl::setTagKind
void setTagKind(TagKind TK)
Definition: Decl.h:3549
clang::UnresolvedUsingTypenameDecl
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3829
clang::ParmVarDecl::setScopeInfo
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1713
clang::Decl::getLexicalDeclContext
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:852
clang::CXXRecordDecl::LDK_Unknown
@ LDK_Unknown
Definition: DeclCXX.h:280
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:979
clang::serialization::DECL_FILE_SCOPE_ASM
@ DECL_FILE_SCOPE_ASM
A FileScopeAsmDecl record.
Definition: ASTBitCodes.h:1316
clang::serialization::DECL_OBJC_COMPATIBLE_ALIAS
@ DECL_OBJC_COMPATIBLE_ALIAS
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:1280
clang::FunctionDecl::setConstexprKind
void setConstexprKind(ConstexprSpecKind CSK)
Definition: Decl.h:2302
TemplateBase.h
clang::UnresolvedUsingTypenameDecl::CreateDeserialized
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3147
V
#define V(N, I)
Definition: ASTContext.h:3176
clang::ASTContext::getExternalSource
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Definition: ASTContext.h:1183
clang::serialization::SubmoduleID
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:171
clang::ObjCInterfaceDecl::mergeClassExtensionProtocolList
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
Definition: DeclObjC.cpp:446
clang::interp::Compare
ComparisonCategoryResult Compare(const T &X, const T &Y)
Helper to compare two comparable types.
Definition: Integral.h:32
clang::ASTReader::GetLocalDecl
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:1864
clang::TranslationUnitDecl
The top declaration context.
Definition: Decl.h:80
clang::ASTDeclReader::VisitOMPThreadPrivateDecl
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
Definition: ASTReaderDecl.cpp:2788
clang::ObjCMethodDecl::setSelfDecl
void setSelfDecl(ImplicitParamDecl *SD)
Definition: DeclObjC.h:424
clang::InheritableAttr::setInherited
void setInherited(bool I)
Definition: Attr.h:147
clang::TemplateArgumentList::CreateCopy
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
Definition: DeclTemplate.cpp:873
clang::ASTDeclReader::VisitExportDecl
void VisitExportDecl(ExportDecl *D)
Definition: ASTReaderDecl.cpp:1680
clang::serialization::DECL_TEMPLATE_TEMPLATE_PARM
@ DECL_TEMPLATE_TEMPLATE_PARM
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1437
clang::DeclarationName::getObjCSelector
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
Definition: DeclarationName.h:490
clang::ASTRecordReader::readTypeSourceInfo
TypeSourceInfo * readTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
Definition: ASTReader.cpp:6838
clang::ObjCPropertyImplDecl::setGetterCXXConstructor
void setGetterCXXConstructor(Expr *getterCXXConstructor)
Definition: DeclObjC.h:2858
clang::ASTDeclReader::markIncompleteDeclChainImpl
static void markIncompleteDeclChainImpl(Redeclarable< DeclT > *D)
Definition: ASTReaderDecl.cpp:3490
clang::Module
Describes a module or submodule.
Definition: Module.h:96
DeclTemplate.h
clang::serialization::ModuleFile::DeclsCursor
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLTYPES_BLOCK block.
Definition: ModuleFile.h:431
clang::ASTDeclReader::VisitBuiltinTemplateDecl
void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D)
Definition: ASTReaderDecl.cpp:2240
clang::NoLinkage
@ NoLinkage
No linkage, which means that the entity is unique and can only be referred to from within its scope.
Definition: Linkage.h:26
clang::NamespaceDecl::CreateDeserialized
static NamespaceDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2865
clang::FunctionDecl::CreateDeserialized
static FunctionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4981
clang::ASTDeclReader::VisitOMPDeclareReductionDecl
void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D)
Definition: ASTReaderDecl.cpp:2803
clang::VarDecl::ensureEvaluatedStmt
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form,...
Definition: Decl.cpp:2433
clang::Decl::IdentifierNamespace
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
Definition: DeclBase.h:112
clang::FunctionTemplateSpecializationInfo::Profile
void Profile(llvm::FoldingSetNodeID &ID)
Definition: DeclTemplate.h:604
clang::OMPDeclareReductionDecl
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:171
clang::RequiresExprBodyDecl
Represents the body of a requires-expression.
Definition: DeclCXX.h:1946
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:563
clang::serialization::NUM_PREDEF_DECL_IDS
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
Definition: ASTBitCodes.h:1220
clang::ObjCPropertyDecl::setPropertyImplementation
void setPropertyImplementation(PropertyControl pc)
Definition: DeclObjC.h:904
clang::Linkage
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:23
clang::ImportDecl
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4505
clang::DeclAccessPair::make
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
Definition: DeclAccessPair.h:35
clang::TagTypeKind
TagTypeKind
The kind of a tag type.
Definition: Type.h:5384
DeclFriend.h
clang::BlockDecl
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4201
clang::serialization::UPD_DECL_EXPORTED
@ UPD_DECL_EXPORTED
Definition: ASTCommon.h:43
clang::serialization::UPD_ADDED_ATTR_TO_RECORD
@ UPD_ADDED_ATTR_TO_RECORD
Definition: ASTCommon.h:44
clang::Decl::getKind
Kind getKind() const
Definition: DeclBase.h:428
clang::ASTDeclReader::VisitMSPropertyDecl
void VisitMSPropertyDecl(MSPropertyDecl *FD)
Definition: ASTReaderDecl.cpp:1447
clang::Decl::ModuleOwnershipKind::VisibleWhenImported
@ VisibleWhenImported
This declaration has an owning module, and is visible when that module is imported.
clang::PragmaCommentDecl::CreateDeserialized
static PragmaCommentDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned ArgSize)
Definition: Decl.cpp:4875
clang::Decl::setAccess
void setAccess(AccessSpecifier AS)
Definition: DeclBase.h:468
clang::NonTypeTemplateParmDecl::getNumExpansionTypes
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
Definition: DeclTemplate.h:1554
ExceptionSpecificationType.h
clang::ObjCMethodDecl::setReturnType
void setReturnType(QualType T)
Definition: DeclObjC.h:333
ASTCommon.h
DeclBase.h
clang::ASTRecordReader::readSourceRange
SourceRange readSourceRange(LocSeq *Seq=nullptr)
Read a source range, advancing Idx.
Definition: ASTRecordReader.h:280
clang::TemplateArgumentListInfo::addArgument
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:603
clang::ObjCCategoryImplDecl::CreateDeserialized
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2134
clang::ConceptDecl
Declaration of a C++2a concept.
Definition: DeclTemplate.h:3252
clang::ASTDeclReader::VisitBlockDecl
void VisitBlockDecl(BlockDecl *BD)
Definition: ASTReaderDecl.cpp:1627
clang::serialization::DECL_VAR_TEMPLATE_SPECIALIZATION
@ DECL_VAR_TEMPLATE_SPECIALIZATION
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1422
clang::ASTDeclReader::VisitPragmaDetectMismatchDecl
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
Definition: ASTReaderDecl.cpp:646
clang::serialization::DECL_CXX_DEDUCTION_GUIDE
@ DECL_CXX_DEDUCTION_GUIDE
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1386
clang::Decl::setModuleOwnershipKind
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
Definition: DeclBase.h:815
clang::OMPDeclareReductionDecl::setInitializer
void setInitializer(Expr *E, InitKind IK)
Set initializer expression for the declare reduction construct.
Definition: DeclOpenMP.h:252
clang::UsingDecl::CreateDeserialized
static UsingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3054
clang::NonTypeTemplateParmDecl::CreateDeserialized
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool HasTypeConstraint)
Definition: DeclTemplate.cpp:756
clang::Decl::ObjCDeclQualifier
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition: DeclBase.h:195
clang::VarDecl::VarDeclBits
VarDeclBitfields VarDeclBits
Definition: Decl.h:1038
clang::threadSafety::sx::toString
std::string toString(const til::SExpr *E)
Definition: ThreadSafetyCommon.h:90
clang::serialization::DECL_CXX_DESTRUCTOR
@ DECL_CXX_DESTRUCTOR
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1395
clang::FunctionTemplateDecl::Common
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:985
clang::SC_Extern
@ SC_Extern
Definition: Specifiers.h:236
Redeclarable.h
clang::DeclContext::setHasExternalVisibleStorage
void setHasExternalVisibleStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations visible in this context.
Definition: DeclBase.h:2464
clang::EvaluatedStmt::HasConstantInitialization
bool HasConstantInitialization
Whether this variable is known to have constant initialization.
Definition: Decl.h:850
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:208
clang::BlockDecl::setBody
void setBody(CompoundStmt *B)
Definition: Decl.h:4281
clang::ASTDeclReader::VisitUsingEnumDecl
void VisitUsingEnumDecl(UsingEnumDecl *D)
Definition: ASTReaderDecl.cpp:1744
clang::ObjCMethodDecl::setDeclImplementation
void setDeclImplementation(ImplementationControl ic)
Definition: DeclObjC.h:501
clang::ConstructorUsingShadowDecl::CreateDeserialized
static ConstructorUsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3006
clang::ASTDeclReader::VisitUsingDirectiveDecl
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
Definition: ASTReaderDecl.cpp:1784
NestedNameSpecifier.h
LangOptions.h
clang::ClassTemplateSpecializationDecl::CreateDeserialized
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:938
clang::CapturedDecl::setNothrow
void setNothrow(bool Nothrow=true)
Definition: Decl.cpp:5015
clang::ASTDeclReader::VisitVarTemplateDecl
void VisitVarTemplateDecl(VarTemplateDecl *D)
TODO: Unify with ClassTemplateDecl version? May require unifying ClassTemplateDecl and VarTemplateDec...
Definition: ASTReaderDecl.cpp:2247
clang::Decl::FromASTFile
unsigned FromASTFile
Whether this declaration was loaded from an AST file.
Definition: DeclBase.h:324
clang::ASTDeclReader::VisitRequiresExprBodyDecl
void VisitRequiresExprBodyDecl(RequiresExprBodyDecl *D)
Definition: ASTReaderDecl.cpp:2179
clang::DecompositionDecl
A decomposition declaration.
Definition: DeclCXX.h:4036
clang::LifetimeExtendedTemporaryDecl::CreateDeserialized
static LifetimeExtendedTemporaryDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.h:3146
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7243
clang::serialization::DECL_OBJC_CATEGORY
@ DECL_OBJC_CATEGORY
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1271
clang::ObjCMethodDecl::setHasSkippedBody
void setHasSkippedBody(bool Skipped=true)
Definition: DeclObjC.h:483
clang::CXXConversionDecl::CreateDeserialized
static CXXConversionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2764
clang::Decl::isInvalidDecl
bool isInvalidDecl() const
Definition: DeclBase.h:553
clang::serialization::DECL_OBJC_AT_DEFS_FIELD
@ DECL_OBJC_AT_DEFS_FIELD
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1268
clang::ObjCMethodDecl::setIsRedeclaration
void setIsRedeclaration(bool RD)
Definition: DeclObjC.h:270
clang::ObjCInterfaceDecl::lookupInstanceVariable
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
Definition: DeclObjC.cpp:630
clang::ObjCCompatibleAliasDecl::setClassInterface
void setClassInterface(ObjCInterfaceDecl *D)
Definition: DeclObjC.h:2743
clang::serialization::DECL_LINKAGE_SPEC
@ DECL_LINKAGE_SPEC
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1377
clang::serialization::DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
@ DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1425
clang::serialization::DECL_CLASS_TEMPLATE_SPECIALIZATION
@ DECL_CLASS_TEMPLATE_SPECIALIZATION
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1413
clang::ObjCMethodDecl::CreateDeserialized
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:831
clang::RecordDecl::setHasNonTrivialToPrimitiveDestructCUnion
void setHasNonTrivialToPrimitiveDestructCUnion(bool V)
Definition: Decl.h:4036
clang::ASTRecordReader::readString
std::string readString()
Read a string, advancing Idx.
Definition: ASTRecordReader.h:310
clang::ASTDeclReader::UpdateDecl
void UpdateDecl(Decl *D, SmallVectorImpl< serialization::DeclID > &)
Definition: ASTReaderDecl.cpp:4181
clang::LabelDecl
Represents the declaration of a label.
Definition: Decl.h:494
clang::Module::AllVisible
@ AllVisible
All of the names in this module are visible.
Definition: Module.h:333
clang::serialization::DECL_VAR_TEMPLATE
@ DECL_VAR_TEMPLATE
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1419
clang::Decl::getCanonicalDecl
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:910
clang::ObjCAtDefsFieldDecl::CreateDeserialized
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1888
clang::EnumDecl::getMemberSpecializationInfo
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition: Decl.h:3882
clang::serialization::UPD_DECL_MARKED_OPENMP_THREADPRIVATE
@ UPD_DECL_MARKED_OPENMP_THREADPRIVATE
Definition: ASTCommon.h:40
clang::MSGuidDecl
A global _GUID constant.
Definition: DeclCXX.h:4159
Linkage.h
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2688
IdentifierTable.h
clang::DeclContext::isTranslationUnit
bool isTranslationUnit() const
Definition: DeclBase.h:1951
clang::ASTDeclReader::VisitConceptDecl
void VisitConceptDecl(ConceptDecl *D)
Definition: ASTReaderDecl.cpp:2173
clang::ASTDeclReader::VisitParmVarDecl
void VisitParmVarDecl(ParmVarDecl *PD)
Definition: ASTReaderDecl.cpp:1585
clang::NonTypeTemplateParmDecl::setPlaceholderTypeConstraint
void setPlaceholderTypeConstraint(Expr *E)
Definition: DeclTemplate.h:1584
clang::ASTReader::getSubmodule
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTReader.cpp:8645
clang::ObjCMethodDecl::setDefined
void setDefined(bool isDefined)
Definition: DeclObjC.h:458
Type.h
clang::ImplicitParamDecl
Definition: Decl.h:1613
merged_redecls
static llvm::iterator_range< MergedRedeclIterator< DeclT > > merged_redecls(DeclT *D)
Definition: ASTReaderDecl.cpp:504
isConsumerInterestedIn
static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody)
Determine whether the consumer will be interested in seeing this declaration (via HandleTopLevelDecl)...
Definition: ASTReaderDecl.cpp:2937
Expr.h
clang::diff::Update
@ Update
Definition: ASTDiff.h:30
clang::FriendDecl
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition: DeclFriend.h:53
clang::TemplateTemplateParmDecl
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Definition: DeclTemplate.h:1618
clang::FunctionDecl::DefaultedFunctionInfo::Create
static DefaultedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups)
Definition: Decl.cpp:2987
clang::TemplateArgumentListInfo::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:582
clang::TypeAliasDecl::setDescribedAliasTemplate
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
Definition: Decl.h:3340
clang::NamespaceDecl::setAnonymousNamespace
void setAnonymousNamespace(NamespaceDecl *D)
Definition: Decl.h:639
ASTContext.h
clang::UnresolvedSet< 8 >
clang::TemplateTemplateParmDecl::getNumExpansionTemplateParameters
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
Definition: DeclTemplate.h:1720
clang::serialization::DECL_OBJC_PROPERTY
@ DECL_OBJC_PROPERTY
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1283
clang::EnumConstantDecl::setInitExpr
void setInitExpr(Expr *E)
Definition: Decl.h:3093
clang::ParmVarDecl::setUninstantiatedDefaultArg
void setUninstantiatedDefaultArg(Expr *arg)
Definition: Decl.cpp:2900
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:874
clang::serialization::DECL_OMP_REQUIRES
@ DECL_OMP_REQUIRES
An OMPRequiresDecl record.
Definition: ASTBitCodes.h:1479
clang::ASTDeclReader::getMostRecentDecl
static Decl * getMostRecentDecl(Decl *D)
Definition: ASTReaderDecl.cpp:3271
clang::serialization::DECL_CXX_CONVERSION
@ DECL_CXX_CONVERSION
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1398
clang::TemplateTemplateParmDecl::setPosition
void setPosition(unsigned P)
Definition: DeclTemplate.h:1180
clang::serialization::DECL_USING_DIRECTIVE
@ DECL_USING_DIRECTIVE
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1368
clang::UnresolvedUsingIfExistsDecl::CreateDeserialized
static UnresolvedUsingIfExistsDecl * CreateDeserialized(ASTContext &Ctx, unsigned ID)
Definition: DeclCXX.cpp:3160
clang::serialization::ModuleFile::DeclOffsets
const DeclOffset * DeclOffsets
Offset of each declaration within the bitstream, indexed by the declaration ID (-1).
Definition: ModuleFile.h:441
clang::MSPropertyDecl::CreateDeserialized
static MSPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3265
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3348
clang::OMPDeclareMapperDecl
This represents '#pragma omp declare mapper ...' directive.
Definition: DeclOpenMP.h:286
clang::serialization::TypeID
uint32_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:85
clang::ASTDeclReader::VisitUsingShadowDecl
void VisitUsingShadowDecl(UsingShadowDecl *D)
Definition: ASTReaderDecl.cpp:1764
clang::serialization::UPD_CXX_ADDED_FUNCTION_DEFINITION
@ UPD_CXX_ADDED_FUNCTION_DEFINITION
Definition: ASTCommon.h:28
clang::FunctionDecl::setHasInheritedPrototype
void setHasInheritedPrototype(bool P=true)
State that this function inherited its prototype from a previous declaration.
Definition: Decl.h:2294
clang::CapturedDecl::setContextParam
void setContextParam(unsigned i, ImplicitParamDecl *P)
Definition: Decl.h:4459
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
clang::SelectorLocationsKind
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
Definition: SelectorLocationsKind.h:27
clang::serialization::UPD_DECL_MARKED_USED
@ UPD_DECL_MARKED_USED
Definition: ASTCommon.h:37
clang::RedeclarableTemplateDecl::getCanonicalDecl
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:865
clang::ObjCCategoryImplDecl
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2495
clang::ASTDeclReader::VisitDecompositionDecl
void VisitDecompositionDecl(DecompositionDecl *DD)
Definition: ASTReaderDecl.cpp:1607
clang::serialization::DECL_ENUM
@ DECL_ENUM
An EnumDecl record.
Definition: ASTBitCodes.h:1244
clang::Redeclarable::RedeclLink
DeclLink RedeclLink
Points to the next redeclaration in the chain.
Definition: Redeclarable.h:185
clang::ASTDeclReader::VisitCXXMethodDecl
void VisitCXXMethodDecl(CXXMethodDecl *D)
Definition: ASTReaderDecl.cpp:2068
clang::TypeDecl
Represents a declaration of a type.
Definition: Decl.h:3158
clang::Type::getAsCXXRecordDecl
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1759
clang::Decl::setVisibleDespiteOwningModule
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
Definition: DeclBase.h:804
clang::LinkageSpecDecl::LanguageIDs
LanguageIDs
Represents the language in a linkage specification.
Definition: DeclCXX.h:2826
clang::serialization::DECL_STATIC_ASSERT
@ DECL_STATIC_ASSERT
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1449
clang::ASTContext::addDestruction
void addDestruction(T *Ptr) const
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
Definition: ASTContext.h:3005
clang::ASTDeclReader::VisitOMPCapturedExprDecl
void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D)
Definition: ASTReaderDecl.cpp:2827
clang::serialization::ObjCCategoriesInfo
Describes the categories of an Objective-C class.
Definition: ASTBitCodes.h:2056
clang::EvaluatedStmt
Structure used to store a statement, the constant value to which it was evaluated (if any),...
Definition: Decl.h:839
clang::serialization::DECL_OBJC_TYPE_PARAM
@ DECL_OBJC_TYPE_PARAM
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1494
clang::FunctionDecl::setPure
void setPure(bool P=true)
Definition: Decl.cpp:3111
clang::EnumConstantDecl
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3070
clang::serialization::DECL_MS_GUID
@ DECL_MS_GUID
A MSGuidDecl record.
Definition: ASTBitCodes.h:1295
clang::ObjCContainerDecl::setAtStartLoc
void setAtStartLoc(SourceLocation Loc)
Definition: DeclObjC.h:1095
clang::FunctionTemplateSpecializationInfo::Create
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
Definition: DeclTemplate.cpp:879
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::Redeclarable::getPreviousDecl
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:204
clang::ObjCImplementationDecl::setIvarLBraceLoc
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2689
clang::serialization::DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
@ DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack.
Definition: ASTBitCodes.h:1466
clang::FriendTemplateDecl::CreateDeserialized
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1111
clang::LCD_None
@ LCD_None
Definition: Lambda.h:23
clang::RecordDecl::CreateDeserialized
static RecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: Decl.cpp:4638
clang::UnresolvedUsingValueDecl
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3733
clang::Redeclarable::isFirstDecl
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:223
clang::TagDecl::isCompleteDefinition
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3453
clang::OMPCapturedExprDecl::CreateDeserialized
static OMPCapturedExprDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclOpenMP.cpp:181
clang::ASTDeclReader::VisitFileScopeAsmDecl
void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD)
Definition: ASTReaderDecl.cpp:1621
clang::AccessSpecDecl::setColonLoc
void setColonLoc(SourceLocation CLoc)
Sets the location of the colon.
Definition: DeclCXX.h:111
clang::TypedefDecl::CreateDeserialized
static TypedefDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:5111
clang::CXXDestructorDecl::getCanonicalDecl
CXXDestructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:2729
clang::ObjCMethodDecl::setVariadic
void setVariadic(bool isVar)
Definition: DeclObjC.h:437
clang::Decl::setImplicit
void setImplicit(bool I=true)
Definition: DeclBase.h:559
clang::ObjCPropertyDecl::setSetterName
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
Definition: DeclObjC.h:892
clang::ASTReader::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
Definition: ASTReader.cpp:9054
clang::IdentifierResolver
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Definition: IdentifierResolver.h:38
clang::IdentifierResolver::end
iterator end()
end - Returns an iterator that has 'finished'.
Definition: IdentifierResolver.h:141
clang::serialization::UPD_CXX_RESOLVED_DTOR_DELETE
@ UPD_CXX_RESOLVED_DTOR_DELETE
Definition: ASTCommon.h:34
clang::CapturedDecl::CreateDeserialized
static CapturedDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumParams)
Definition: Decl.cpp:5005
clang::FieldDecl::CreateDeserialized
static FieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4242
clang::TemplateTypeParmDecl
Declaration of a template type parameter.
Definition: DeclTemplate.h:1196
clang::VarDecl::setDescribedVarTemplate
void setDescribedVarTemplate(VarTemplateDecl *Template)
Definition: Decl.cpp:2687
clang::serialization::UPD_DECL_MARKED_OPENMP_ALLOCATE
@ UPD_DECL_MARKED_OPENMP_ALLOCATE
Definition: ASTCommon.h:41
clang::EnumDecl::setFixed
void setFixed(bool Fixed=true)
True if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying type.
Definition: Decl.h:3699
clang::ASTDeclReader::VisitObjCMethodDecl
void VisitObjCMethodDecl(ObjCMethodDecl *D)
Definition: ASTReaderDecl.cpp:1066
clang::ASTDeclReader::VisitUnresolvedUsingIfExistsDecl
void VisitUnresolvedUsingIfExistsDecl(UnresolvedUsingIfExistsDecl *D)
Definition: ASTReaderDecl.cpp:1811
clang::ObjCPropertyDecl::setAtLoc
void setAtLoc(SourceLocation L)
Definition: DeclObjC.h:793
clang::TemplateParamObjectDecl
A template parameter object.
Definition: DeclTemplate.h:3304
clang::FieldDecl::setBitWidth
void setBitWidth(Expr *Width)
Set the bit-field width for this member.
Definition: Decl.h:2957
clang::ASTRecordReader::readDecl
Decl * readDecl()
Reads a declaration from the given position in a record in the given module, advancing Idx.
Definition: ASTRecordReader.h:193
clang::ASTDeclReader::ReadFunctionDefinition
void ReadFunctionDefinition(FunctionDecl *FD)
Definition: ASTReaderDecl.cpp:513
clang::TagDecl::setEmbeddedInDeclarator
void setEmbeddedInDeclarator(bool isInDeclarator)
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
Definition: Decl.h:3483
clang::RecordDecl::setAnonymousStructOrUnion
void setAnonymousStructOrUnion(bool Anon)
Definition: Decl.h:3978
clang::serialization::UPD_CXX_ADDED_IMPLICIT_MEMBER
@ UPD_CXX_ADDED_IMPLICIT_MEMBER
Definition: ASTCommon.h:25
clang::ASTContext::setManglingNumber
void setManglingNumber(const NamedDecl *ND, unsigned Number)
Definition: ASTContext.cpp:11762
clang::Decl::IDNS_Ordinary
@ IDNS_Ordinary
Ordinary names.
Definition: DeclBase.h:141
clang::ObjCContainerDecl::setAtEndRange
void setAtEndRange(SourceRange atEnd)
Definition: DeclObjC.h:1102
clang::serialization::DECL_OBJC_IMPLEMENTATION
@ DECL_OBJC_IMPLEMENTATION
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:1277
clang::CXXRecordDecl::getODRHash
unsigned getODRHash() const
Definition: DeclCXX.cpp:493
ExternalASTSource.h
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:419
clang::UsingDecl
Represents a C++ using-declaration.
Definition: DeclCXX.h:3399
clang::FunctionDecl::setHasImplicitReturnZero
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
Definition: Decl.h:2264
clang::ASTDeclReader::VisitAccessSpecDecl
void VisitAccessSpecDecl(AccessSpecDecl *D)
Definition: ASTReaderDecl.cpp:2129
clang::UsingEnumDecl::CreateDeserialized
static UsingEnumDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3074
clang::serialization::DECL_CXX_CTOR_INITIALIZERS
@ DECL_CXX_CTOR_INITIALIZERS
A record containing CXXCtorInitializers.
Definition: ASTBitCodes.h:1455
clang::ObjCCategoryDecl
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2276
clang::serialization::DECL_FRIEND
@ DECL_FRIEND
A FriendDecl record.
Definition: ASTBitCodes.h:1404
clang::DeducedType::isDeduced
bool isDeduced() const
Definition: Type.h:5036
DiagnosticSema.h
clang::serialization::DECL_OBJC_PROTOCOL
@ DECL_OBJC_PROTOCOL
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1262
clang::ASTDeclReader::VisitUnresolvedUsingValueDecl
void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
Definition: ASTReaderDecl.cpp:1793
clang::ASTDeclReader::VisitLifetimeExtendedTemporaryDecl
void VisitLifetimeExtendedTemporaryDecl(LifetimeExtendedTemporaryDecl *D)
Definition: ASTReaderDecl.cpp:2537
clang::serialization::DECL_BLOCK
@ DECL_BLOCK
A BlockDecl record.
Definition: ASTBitCodes.h:1319
clang::serialization::DECL_OMP_DECLARE_REDUCTION
@ DECL_OMP_DECLARE_REDUCTION
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1509
clang::ObjCImplementationDecl::CreateDeserialized
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2242
clang::isUndeducedReturnType
static bool isUndeducedReturnType(QualType T)
Definition: ASTReaderDecl.cpp:3334
clang::LinkageSpecDecl::CreateDeserialized
static LinkageSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2810
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7310
clang::ConstexprSpecKind
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition: Specifiers.h:32
operator*
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition: CharUnits.h:212
clang::serialization::UPD_CXX_INSTANTIATED_CLASS_DEFINITION
@ UPD_CXX_INSTANTIATED_CLASS_DEFINITION
Definition: ASTCommon.h:31
ASTBitCodes.h
clang::AccessSpecifier
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:108
clang::FileScopeAsmDecl::CreateDeserialized
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:5153
clang::serialization::DeclCode
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1236
clang::FunctionTemplateSpecializationInfo::getFunction
FunctionDecl * getFunction() const
Retrieve the declaration of the function template specialization.
Definition: DeclTemplate.h:524
clang::UsingEnumDecl
Represents a C++ using-enum-declaration.
Definition: DeclCXX.h:3599
clang::ConceptDecl::ConstraintExpr
Expr * ConstraintExpr
Definition: DeclTemplate.h:3254
clang::ASTDeclReader::VisitFunctionTemplateDecl
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
Definition: ASTReaderDecl.cpp:2358
clang::ASTDeclReader::attachPreviousDecl
static void attachPreviousDecl(ASTReader &Reader, Decl *D, Decl *Previous, Decl *Canon)
Definition: ASTReaderDecl.cpp:3432
clang::Decl::setLocation
void setLocation(SourceLocation L)
Definition: DeclBase.h:426
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::Mergeable
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
Definition: Redeclarable.h:314
clang::Redeclarable::First
decl_type * First
Definition: Redeclarable.h:187
clang::ASTRecordReader::size
size_t size() const
The length of this record.
Definition: ASTRecordReader.h:64
clang::serialization::UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION
@ UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION
Definition: ASTCommon.h:26
clang::serialization::DECL_EXPORT
@ DECL_EXPORT
An ExportDecl record.
Definition: ASTBitCodes.h:1380
SourceLocation.h
clang::DeclContext::getRedeclContext
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1793
clang::ast_matchers::decl
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Definition: ASTMatchersInternal.cpp:734
clang::declvisitor::Base< std::add_pointer, ImplClass, void >::Visit
void Visit(PTR(Decl) D)
Definition: DeclVisitor.h:37
clang::ObjCInterfaceDecl::setCategoryListRaw
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1775
clang::TemplateSpecializationKind
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:173
clang::LambdaCaptureKind
LambdaCaptureKind
The different capture forms in a lambda introducer.
Definition: Lambda.h:33
clang::TagDecl::setCompleteDefinition
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
Definition: Decl.h:3456
clang::BlockDecl::setIsVariadic
void setIsVariadic(bool value)
Definition: Decl.h:4277
clang::serialization::DECL_OBJC_METHOD
@ DECL_OBJC_METHOD
A ObjCMethodDecl record.
Definition: ASTBitCodes.h:1256
clang::serialization::numberAnonymousDeclsWithin
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:96
clang::Type::getContainedAutoType
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.h:2290
clang::CXXDeductionGuideDecl::CreateDeserialized
static CXXDeductionGuideDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2073
clang::attr::Kind
Kind
Definition: AttrKinds.h:22
clang::Decl::getPreviousDecl
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Definition: DeclBase.h:993
clang::FunctionTemplateSpecializationInfo
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:468
clang::DecompositionDecl::CreateDeserialized
static DecompositionDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumBindings)
Definition: DeclCXX.cpp:3227
clang::ASTDeclReader::VisitCXXConstructorDecl
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
Definition: ASTReaderDecl.cpp:2086
clang::ASTRecordReader::getGlobalSubmoduleID
serialization::SubmoduleID getGlobalSubmoduleID(unsigned LocalID)
Retrieve the global submodule ID its local ID number.
Definition: ASTRecordReader.h:90
clang::Decl::hasAttrs
bool hasAttrs() const
Definition: DeclBase.h:484
clang::serialization::ModuleFile::LocalNumObjCCategoriesInMap
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
Definition: ModuleFile.h:467
PragmaKinds.h
clang::Decl::isFromASTFile
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:725
clang::BindingDecl::CreateDeserialized
static BindingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3197
clang::StaticAssertDecl
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3930
clang::TypedefNameDecl::setTypeSourceInfo
void setTypeSourceInfo(TypeSourceInfo *newType)
Definition: Decl.h:3262
clang::ASTDeclReader::VisitCXXRecordDeclImpl
RedeclarableResult VisitCXXRecordDeclImpl(CXXRecordDecl *D)
Definition: ASTReaderDecl.cpp:1999
clang::EnumDecl::getCanonicalDecl
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.h:3709
clang::CXXRecordDecl::setDeviceLambdaManglingNumber
void setDeviceLambdaManglingNumber(unsigned Num) const
Set the device side mangling number.
Definition: DeclCXX.cpp:1606
clang::FunctionDecl::setTrivialForCall
void setTrivialForCall(bool IT)
Definition: Decl.h:2227
clang::serialization::DECL_OMP_ALLOCATE
@ DECL_OMP_ALLOCATE
An OMPAllocateDcl record.
Definition: ASTBitCodes.h:1482