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