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() && Reader.getContext().getLangOpts().Modules) {
809 EnumDecl *&OldDef = Reader.EnumDefinitions[ED->getCanonicalDecl()];
810 if (!OldDef) {
811 // This is the first time we've seen an imported definition. Look for a
812 // local definition before deciding that we are the first definition.
813 for (auto *D : merged_redecls(ED->getCanonicalDecl())) {
814 if (!D->isFromASTFile() && D->isCompleteDefinition()) {
815 OldDef = D;
816 break;
817 }
818 }
819 }
820 if (OldDef) {
821 Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
823 Reader.mergeDefinitionVisibility(OldDef, ED);
824 // We don't want to check the ODR hash value for declarations from global
825 // module fragment.
826 if (!shouldSkipCheckingODR(ED) &&
827 OldDef->getODRHash() != ED->getODRHash())
828 Reader.PendingEnumOdrMergeFailures[OldDef].push_back(ED);
829 } else {
830 OldDef = ED;
831 }
832 }
833
834 if (auto *InstED = readDeclAs<EnumDecl>()) {
835 auto TSK = (TemplateSpecializationKind)Record.readInt();
836 SourceLocation POI = readSourceLocation();
837 ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK);
839 }
840}
841
842ASTDeclReader::RedeclarableResult
844 RedeclarableResult Redecl = VisitTagDecl(RD);
845
846 BitsUnpacker RecordDeclBits(Record.readInt());
847 RD->setHasFlexibleArrayMember(RecordDeclBits.getNextBit());
848 RD->setAnonymousStructOrUnion(RecordDeclBits.getNextBit());
849 RD->setHasObjectMember(RecordDeclBits.getNextBit());
850 RD->setHasVolatileMember(RecordDeclBits.getNextBit());
852 RD->setNonTrivialToPrimitiveCopy(RecordDeclBits.getNextBit());
853 RD->setNonTrivialToPrimitiveDestroy(RecordDeclBits.getNextBit());
855 RecordDeclBits.getNextBit());
858 RD->setParamDestroyedInCallee(RecordDeclBits.getNextBit());
860 (RecordArgPassingKind)RecordDeclBits.getNextBits(/*Width=*/2));
861 return Redecl;
862}
863
866 // We should only reach here if we're in C/Objective-C. There is no
867 // global module fragment.
868 assert(!shouldSkipCheckingODR(RD));
869 RD->setODRHash(Record.readInt());
870
871 // Maintain the invariant of a redeclaration chain containing only
872 // a single definition.
873 if (RD->isCompleteDefinition()) {
874 RecordDecl *Canon = static_cast<RecordDecl *>(RD->getCanonicalDecl());
875 RecordDecl *&OldDef = Reader.RecordDefinitions[Canon];
876 if (!OldDef) {
877 // This is the first time we've seen an imported definition. Look for a
878 // local definition before deciding that we are the first definition.
879 for (auto *D : merged_redecls(Canon)) {
880 if (!D->isFromASTFile() && D->isCompleteDefinition()) {
881 OldDef = D;
882 break;
883 }
884 }
885 }
886 if (OldDef) {
887 Reader.MergedDeclContexts.insert(std::make_pair(RD, OldDef));
889 Reader.mergeDefinitionVisibility(OldDef, RD);
890 if (OldDef->getODRHash() != RD->getODRHash())
891 Reader.PendingRecordOdrMergeFailures[OldDef].push_back(RD);
892 } else {
893 OldDef = RD;
894 }
895 }
896}
897
899 VisitNamedDecl(VD);
900 // For function or variable declarations, defer reading the type in case the
901 // declaration has a deduced type that references an entity declared within
902 // the function definition or variable initializer.
903 if (isa<FunctionDecl, VarDecl>(VD))
904 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
905 else
906 VD->setType(Record.readType());
907}
908
910 VisitValueDecl(ECD);
911 if (Record.readInt())
912 ECD->setInitExpr(Record.readExpr());
913 ECD->setInitVal(Reader.getContext(), Record.readAPSInt());
914 mergeMergeable(ECD);
915}
916
918 VisitValueDecl(DD);
919 DD->setInnerLocStart(readSourceLocation());
920 if (Record.readInt()) { // hasExtInfo
921 auto *Info = new (Reader.getContext()) DeclaratorDecl::ExtInfo();
922 Record.readQualifierInfo(*Info);
923 Info->TrailingRequiresClause = Record.readExpr();
924 DD->DeclInfo = Info;
925 }
926 QualType TSIType = Record.readType();
928 TSIType.isNull() ? nullptr
929 : Reader.getContext().CreateTypeSourceInfo(TSIType));
930}
931
933 RedeclarableResult Redecl = VisitRedeclarable(FD);
934
935 FunctionDecl *Existing = nullptr;
936
937 switch ((FunctionDecl::TemplatedKind)Record.readInt()) {
939 break;
941 FD->setInstantiatedFromDecl(readDeclAs<FunctionDecl>());
942 break;
944 auto *Template = readDeclAs<FunctionTemplateDecl>();
945 Template->init(FD);
946 FD->setDescribedFunctionTemplate(Template);
947 break;
948 }
950 auto *InstFD = readDeclAs<FunctionDecl>();
951 auto TSK = (TemplateSpecializationKind)Record.readInt();
952 SourceLocation POI = readSourceLocation();
953 FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
955 break;
956 }
958 auto *Template = readDeclAs<FunctionTemplateDecl>();
959 auto TSK = (TemplateSpecializationKind)Record.readInt();
960
961 // Template arguments.
963 Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
964
965 // Template args as written.
966 TemplateArgumentListInfo TemplArgsWritten;
967 bool HasTemplateArgumentsAsWritten = Record.readBool();
968 if (HasTemplateArgumentsAsWritten)
969 Record.readTemplateArgumentListInfo(TemplArgsWritten);
970
971 SourceLocation POI = readSourceLocation();
972
973 ASTContext &C = Reader.getContext();
974 TemplateArgumentList *TemplArgList =
976
977 MemberSpecializationInfo *MSInfo = nullptr;
978 if (Record.readInt()) {
979 auto *FD = readDeclAs<FunctionDecl>();
980 auto TSK = (TemplateSpecializationKind)Record.readInt();
981 SourceLocation POI = readSourceLocation();
982
983 MSInfo = new (C) MemberSpecializationInfo(FD, TSK);
984 MSInfo->setPointOfInstantiation(POI);
985 }
986
989 C, FD, Template, TSK, TemplArgList,
990 HasTemplateArgumentsAsWritten ? &TemplArgsWritten : nullptr, POI,
991 MSInfo);
992 FD->TemplateOrSpecialization = FTInfo;
993
994 if (FD->isCanonicalDecl()) { // if canonical add to template's set.
995 // The template that contains the specializations set. It's not safe to
996 // use getCanonicalDecl on Template since it may still be initializing.
997 auto *CanonTemplate = readDeclAs<FunctionTemplateDecl>();
998 // Get the InsertPos by FindNodeOrInsertPos() instead of calling
999 // InsertNode(FTInfo) directly to avoid the getASTContext() call in
1000 // FunctionTemplateSpecializationInfo's Profile().
1001 // We avoid getASTContext because a decl in the parent hierarchy may
1002 // be initializing.
1003 llvm::FoldingSetNodeID ID;
1005 void *InsertPos = nullptr;
1006 FunctionTemplateDecl::Common *CommonPtr = CanonTemplate->getCommonPtr();
1008 CommonPtr->Specializations.FindNodeOrInsertPos(ID, InsertPos);
1009 if (InsertPos)
1010 CommonPtr->Specializations.InsertNode(FTInfo, InsertPos);
1011 else {
1012 assert(Reader.getContext().getLangOpts().Modules &&
1013 "already deserialized this template specialization");
1014 Existing = ExistingInfo->getFunction();
1015 }
1016 }
1017 break;
1018 }
1020 // Templates.
1021 UnresolvedSet<8> Candidates;
1022 unsigned NumCandidates = Record.readInt();
1023 while (NumCandidates--)
1024 Candidates.addDecl(readDeclAs<NamedDecl>());
1025
1026 // Templates args.
1027 TemplateArgumentListInfo TemplArgsWritten;
1028 bool HasTemplateArgumentsAsWritten = Record.readBool();
1029 if (HasTemplateArgumentsAsWritten)
1030 Record.readTemplateArgumentListInfo(TemplArgsWritten);
1031
1033 Reader.getContext(), Candidates,
1034 HasTemplateArgumentsAsWritten ? &TemplArgsWritten : nullptr);
1035 // These are not merged; we don't need to merge redeclarations of dependent
1036 // template friends.
1037 break;
1038 }
1039 }
1040
1042
1043 // Attach a type to this function. Use the real type if possible, but fall
1044 // back to the type as written if it involves a deduced return type.
1045 if (FD->getTypeSourceInfo() && FD->getTypeSourceInfo()
1046 ->getType()
1047 ->castAs<FunctionType>()
1048 ->getReturnType()
1050 // We'll set up the real type in Visit, once we've finished loading the
1051 // function.
1052 FD->setType(FD->getTypeSourceInfo()->getType());
1053 Reader.PendingDeducedFunctionTypes.push_back({FD, DeferredTypeID});
1054 } else {
1055 FD->setType(Reader.GetType(DeferredTypeID));
1056 }
1057 DeferredTypeID = 0;
1058
1059 FD->DNLoc = Record.readDeclarationNameLoc(FD->getDeclName());
1060 FD->IdentifierNamespace = Record.readInt();
1061
1062 // FunctionDecl's body is handled last at ASTDeclReader::Visit,
1063 // after everything else is read.
1064 BitsUnpacker FunctionDeclBits(Record.readInt());
1065
1066 FD->setCachedLinkage((Linkage)FunctionDeclBits.getNextBits(/*Width=*/3));
1067 FD->setStorageClass((StorageClass)FunctionDeclBits.getNextBits(/*Width=*/3));
1068 bool ShouldSkipCheckingODR = FunctionDeclBits.getNextBit();
1069 FD->setInlineSpecified(FunctionDeclBits.getNextBit());
1070 FD->setImplicitlyInline(FunctionDeclBits.getNextBit());
1071 FD->setHasSkippedBody(FunctionDeclBits.getNextBit());
1072 FD->setVirtualAsWritten(FunctionDeclBits.getNextBit());
1073 // We defer calling `FunctionDecl::setPure()` here as for methods of
1074 // `CXXTemplateSpecializationDecl`s, we may not have connected up the
1075 // definition (which is required for `setPure`).
1076 const bool Pure = FunctionDeclBits.getNextBit();
1077 FD->setHasInheritedPrototype(FunctionDeclBits.getNextBit());
1078 FD->setHasWrittenPrototype(FunctionDeclBits.getNextBit());
1079 FD->setDeletedAsWritten(FunctionDeclBits.getNextBit());
1080 FD->setTrivial(FunctionDeclBits.getNextBit());
1081 FD->setTrivialForCall(FunctionDeclBits.getNextBit());
1082 FD->setDefaulted(FunctionDeclBits.getNextBit());
1083 FD->setExplicitlyDefaulted(FunctionDeclBits.getNextBit());
1084 FD->setIneligibleOrNotSelected(FunctionDeclBits.getNextBit());
1085 FD->setConstexprKind(
1086 (ConstexprSpecKind)FunctionDeclBits.getNextBits(/*Width=*/2));
1087 FD->setHasImplicitReturnZero(FunctionDeclBits.getNextBit());
1088 FD->setIsMultiVersion(FunctionDeclBits.getNextBit());
1089 FD->setLateTemplateParsed(FunctionDeclBits.getNextBit());
1091 FunctionDeclBits.getNextBit());
1092 FD->setUsesSEHTry(FunctionDeclBits.getNextBit());
1093
1094 FD->EndRangeLoc = readSourceLocation();
1095 if (FD->isExplicitlyDefaulted())
1096 FD->setDefaultLoc(readSourceLocation());
1097
1098 if (!ShouldSkipCheckingODR) {
1099 FD->ODRHash = Record.readInt();
1100 FD->setHasODRHash(true);
1101 }
1102
1103 if (FD->isDefaulted() || FD->isDeletedAsWritten()) {
1104 // If 'Info' is nonzero, we need to read an DefaultedOrDeletedInfo; if,
1105 // additionally, the second bit is also set, we also need to read
1106 // a DeletedMessage for the DefaultedOrDeletedInfo.
1107 if (auto Info = Record.readInt()) {
1108 bool HasMessage = Info & 2;
1109 StringLiteral *DeletedMessage =
1110 HasMessage ? cast<StringLiteral>(Record.readExpr()) : nullptr;
1111
1112 unsigned NumLookups = Record.readInt();
1114 for (unsigned I = 0; I != NumLookups; ++I) {
1115 NamedDecl *ND = Record.readDeclAs<NamedDecl>();
1116 AccessSpecifier AS = (AccessSpecifier)Record.readInt();
1117 Lookups.push_back(DeclAccessPair::make(ND, AS));
1118 }
1119
1122 Reader.getContext(), Lookups, DeletedMessage));
1123 }
1124 }
1125
1126 if (Existing)
1127 mergeRedeclarable(FD, Existing, Redecl);
1128 else if (auto Kind = FD->getTemplatedKind();
1131 // Function Templates have their FunctionTemplateDecls merged instead of
1132 // their FunctionDecls.
1133 auto merge = [this, &Redecl, FD](auto &&F) {
1134 auto *Existing = cast_or_null<FunctionDecl>(Redecl.getKnownMergeTarget());
1135 RedeclarableResult NewRedecl(Existing ? F(Existing) : nullptr,
1136 Redecl.getFirstID(), Redecl.isKeyDecl());
1137 mergeRedeclarableTemplate(F(FD), NewRedecl);
1138 };
1140 merge(
1141 [](FunctionDecl *FD) { return FD->getDescribedFunctionTemplate(); });
1142 else
1143 merge([](FunctionDecl *FD) {
1144 return FD->getTemplateSpecializationInfo()->getTemplate();
1145 });
1146 } else
1147 mergeRedeclarable(FD, Redecl);
1148
1149 // Defer calling `setPure` until merging above has guaranteed we've set
1150 // `DefinitionData` (as this will need to access it).
1151 FD->setIsPureVirtual(Pure);
1152
1153 // Read in the parameters.
1154 unsigned NumParams = Record.readInt();
1156 Params.reserve(NumParams);
1157 for (unsigned I = 0; I != NumParams; ++I)
1158 Params.push_back(readDeclAs<ParmVarDecl>());
1159 FD->setParams(Reader.getContext(), Params);
1160}
1161
1163 VisitNamedDecl(MD);
1164 if (Record.readInt()) {
1165 // Load the body on-demand. Most clients won't care, because method
1166 // definitions rarely show up in headers.
1167 Reader.PendingBodies[MD] = GetCurrentCursorOffset();
1168 }
1169 MD->setSelfDecl(readDeclAs<ImplicitParamDecl>());
1170 MD->setCmdDecl(readDeclAs<ImplicitParamDecl>());
1171 MD->setInstanceMethod(Record.readInt());
1172 MD->setVariadic(Record.readInt());
1173 MD->setPropertyAccessor(Record.readInt());
1174 MD->setSynthesizedAccessorStub(Record.readInt());
1175 MD->setDefined(Record.readInt());
1176 MD->setOverriding(Record.readInt());
1177 MD->setHasSkippedBody(Record.readInt());
1178
1179 MD->setIsRedeclaration(Record.readInt());
1180 MD->setHasRedeclaration(Record.readInt());
1181 if (MD->hasRedeclaration())
1183 readDeclAs<ObjCMethodDecl>());
1184
1186 static_cast<ObjCImplementationControl>(Record.readInt()));
1188 MD->setRelatedResultType(Record.readInt());
1189 MD->setReturnType(Record.readType());
1190 MD->setReturnTypeSourceInfo(readTypeSourceInfo());
1191 MD->DeclEndLoc = readSourceLocation();
1192 unsigned NumParams = Record.readInt();
1194 Params.reserve(NumParams);
1195 for (unsigned I = 0; I != NumParams; ++I)
1196 Params.push_back(readDeclAs<ParmVarDecl>());
1197
1198 MD->setSelLocsKind((SelectorLocationsKind)Record.readInt());
1199 unsigned NumStoredSelLocs = Record.readInt();
1201 SelLocs.reserve(NumStoredSelLocs);
1202 for (unsigned i = 0; i != NumStoredSelLocs; ++i)
1203 SelLocs.push_back(readSourceLocation());
1204
1205 MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs);
1206}
1207
1210
1211 D->Variance = Record.readInt();
1212 D->Index = Record.readInt();
1213 D->VarianceLoc = readSourceLocation();
1214 D->ColonLoc = readSourceLocation();
1215}
1216
1218 VisitNamedDecl(CD);
1219 CD->setAtStartLoc(readSourceLocation());
1220 CD->setAtEndRange(readSourceRange());
1221}
1222
1224 unsigned numParams = Record.readInt();
1225 if (numParams == 0)
1226 return nullptr;
1227
1229 typeParams.reserve(numParams);
1230 for (unsigned i = 0; i != numParams; ++i) {
1231 auto *typeParam = readDeclAs<ObjCTypeParamDecl>();
1232 if (!typeParam)
1233 return nullptr;
1234
1235 typeParams.push_back(typeParam);
1236 }
1237
1238 SourceLocation lAngleLoc = readSourceLocation();
1239 SourceLocation rAngleLoc = readSourceLocation();
1240
1241 return ObjCTypeParamList::create(Reader.getContext(), lAngleLoc,
1242 typeParams, rAngleLoc);
1243}
1244
1245void ASTDeclReader::ReadObjCDefinitionData(
1246 struct ObjCInterfaceDecl::DefinitionData &Data) {
1247 // Read the superclass.
1248 Data.SuperClassTInfo = readTypeSourceInfo();
1249
1250 Data.EndLoc = readSourceLocation();
1251 Data.HasDesignatedInitializers = Record.readInt();
1252 Data.ODRHash = Record.readInt();
1253 Data.HasODRHash = true;
1254
1255 // Read the directly referenced protocols and their SourceLocations.
1256 unsigned NumProtocols = Record.readInt();
1258 Protocols.reserve(NumProtocols);
1259 for (unsigned I = 0; I != NumProtocols; ++I)
1260 Protocols.push_back(readDeclAs<ObjCProtocolDecl>());
1262 ProtoLocs.reserve(NumProtocols);
1263 for (unsigned I = 0; I != NumProtocols; ++I)
1264 ProtoLocs.push_back(readSourceLocation());
1265 Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, ProtoLocs.data(),
1266 Reader.getContext());
1267
1268 // Read the transitive closure of protocols referenced by this class.
1269 NumProtocols = Record.readInt();
1270 Protocols.clear();
1271 Protocols.reserve(NumProtocols);
1272 for (unsigned I = 0; I != NumProtocols; ++I)
1273 Protocols.push_back(readDeclAs<ObjCProtocolDecl>());
1274 Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
1275 Reader.getContext());
1276}
1277
1278void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D,
1279 struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
1280 struct ObjCInterfaceDecl::DefinitionData &DD = D->data();
1281 if (DD.Definition == NewDD.Definition)
1282 return;
1283
1284 Reader.MergedDeclContexts.insert(
1285 std::make_pair(NewDD.Definition, DD.Definition));
1286 Reader.mergeDefinitionVisibility(DD.Definition, NewDD.Definition);
1287
1288 if (D->getODRHash() != NewDD.ODRHash)
1289 Reader.PendingObjCInterfaceOdrMergeFailures[DD.Definition].push_back(
1290 {NewDD.Definition, &NewDD});
1291}
1292
1294 RedeclarableResult Redecl = VisitRedeclarable(ID);
1296 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
1297 mergeRedeclarable(ID, Redecl);
1298
1299 ID->TypeParamList = ReadObjCTypeParamList();
1300 if (Record.readInt()) {
1301 // Read the definition.
1302 ID->allocateDefinitionData();
1303
1304 ReadObjCDefinitionData(ID->data());
1305 ObjCInterfaceDecl *Canon = ID->getCanonicalDecl();
1306 if (Canon->Data.getPointer()) {
1307 // If we already have a definition, keep the definition invariant and
1308 // merge the data.
1309 MergeDefinitionData(Canon, std::move(ID->data()));
1310 ID->Data = Canon->Data;
1311 } else {
1312 // Set the definition data of the canonical declaration, so other
1313 // redeclarations will see it.
1314 ID->getCanonicalDecl()->Data = ID->Data;
1315
1316 // We will rebuild this list lazily.
1317 ID->setIvarList(nullptr);
1318 }
1319
1320 // Note that we have deserialized a definition.
1321 Reader.PendingDefinitions.insert(ID);
1322
1323 // Note that we've loaded this Objective-C class.
1324 Reader.ObjCClassesLoaded.push_back(ID);
1325 } else {
1326 ID->Data = ID->getCanonicalDecl()->Data;
1327 }
1328}
1329
1331 VisitFieldDecl(IVD);
1333 // This field will be built lazily.
1334 IVD->setNextIvar(nullptr);
1335 bool synth = Record.readInt();
1336 IVD->setSynthesize(synth);
1337
1338 // Check ivar redeclaration.
1339 if (IVD->isInvalidDecl())
1340 return;
1341 // Don't check ObjCInterfaceDecl as interfaces are named and mismatches can be
1342 // detected in VisitObjCInterfaceDecl. Here we are looking for redeclarations
1343 // in extensions.
1344 if (isa<ObjCInterfaceDecl>(IVD->getDeclContext()))
1345 return;
1346 ObjCInterfaceDecl *CanonIntf =
1348 IdentifierInfo *II = IVD->getIdentifier();
1349 ObjCIvarDecl *PrevIvar = CanonIntf->lookupInstanceVariable(II);
1350 if (PrevIvar && PrevIvar != IVD) {
1351 auto *ParentExt = dyn_cast<ObjCCategoryDecl>(IVD->getDeclContext());
1352 auto *PrevParentExt =
1353 dyn_cast<ObjCCategoryDecl>(PrevIvar->getDeclContext());
1354 if (ParentExt && PrevParentExt) {
1355 // Postpone diagnostic as we should merge identical extensions from
1356 // different modules.
1357 Reader
1358 .PendingObjCExtensionIvarRedeclarations[std::make_pair(ParentExt,
1359 PrevParentExt)]
1360 .push_back(std::make_pair(IVD, PrevIvar));
1361 } else if (ParentExt || PrevParentExt) {
1362 // Duplicate ivars in extension + implementation are never compatible.
1363 // Compatibility of implementation + implementation should be handled in
1364 // VisitObjCImplementationDecl.
1365 Reader.Diag(IVD->getLocation(), diag::err_duplicate_ivar_declaration)
1366 << II;
1367 Reader.Diag(PrevIvar->getLocation(), diag::note_previous_definition);
1368 }
1369 }
1370}
1371
1372void ASTDeclReader::ReadObjCDefinitionData(
1373 struct ObjCProtocolDecl::DefinitionData &Data) {
1374 unsigned NumProtoRefs = Record.readInt();
1376 ProtoRefs.reserve(NumProtoRefs);
1377 for (unsigned I = 0; I != NumProtoRefs; ++I)
1378 ProtoRefs.push_back(readDeclAs<ObjCProtocolDecl>());
1380 ProtoLocs.reserve(NumProtoRefs);
1381 for (unsigned I = 0; I != NumProtoRefs; ++I)
1382 ProtoLocs.push_back(readSourceLocation());
1383 Data.ReferencedProtocols.set(ProtoRefs.data(), NumProtoRefs,
1384 ProtoLocs.data(), Reader.getContext());
1385 Data.ODRHash = Record.readInt();
1386 Data.HasODRHash = true;
1387}
1388
1389void ASTDeclReader::MergeDefinitionData(
1390 ObjCProtocolDecl *D, struct ObjCProtocolDecl::DefinitionData &&NewDD) {
1391 struct ObjCProtocolDecl::DefinitionData &DD = D->data();
1392 if (DD.Definition == NewDD.Definition)
1393 return;
1394
1395 Reader.MergedDeclContexts.insert(
1396 std::make_pair(NewDD.Definition, DD.Definition));
1397 Reader.mergeDefinitionVisibility(DD.Definition, NewDD.Definition);
1398
1399 if (D->getODRHash() != NewDD.ODRHash)
1400 Reader.PendingObjCProtocolOdrMergeFailures[DD.Definition].push_back(
1401 {NewDD.Definition, &NewDD});
1402}
1403
1405 RedeclarableResult Redecl = VisitRedeclarable(PD);
1407 mergeRedeclarable(PD, Redecl);
1408
1409 if (Record.readInt()) {
1410 // Read the definition.
1411 PD->allocateDefinitionData();
1412
1413 ReadObjCDefinitionData(PD->data());
1414
1415 ObjCProtocolDecl *Canon = PD->getCanonicalDecl();
1416 if (Canon->Data.getPointer()) {
1417 // If we already have a definition, keep the definition invariant and
1418 // merge the data.
1419 MergeDefinitionData(Canon, std::move(PD->data()));
1420 PD->Data = Canon->Data;
1421 } else {
1422 // Set the definition data of the canonical declaration, so other
1423 // redeclarations will see it.
1424 PD->getCanonicalDecl()->Data = PD->Data;
1425 }
1426 // Note that we have deserialized a definition.
1427 Reader.PendingDefinitions.insert(PD);
1428 } else {
1429 PD->Data = PD->getCanonicalDecl()->Data;
1430 }
1431}
1432
1434 VisitFieldDecl(FD);
1435}
1436
1439 CD->setCategoryNameLoc(readSourceLocation());
1440 CD->setIvarLBraceLoc(readSourceLocation());
1441 CD->setIvarRBraceLoc(readSourceLocation());
1442
1443 // Note that this category has been deserialized. We do this before
1444 // deserializing the interface declaration, so that it will consider this
1445 /// category.
1446 Reader.CategoriesDeserialized.insert(CD);
1447
1448 CD->ClassInterface = readDeclAs<ObjCInterfaceDecl>();
1449 CD->TypeParamList = ReadObjCTypeParamList();
1450 unsigned NumProtoRefs = Record.readInt();
1452 ProtoRefs.reserve(NumProtoRefs);
1453 for (unsigned I = 0; I != NumProtoRefs; ++I)
1454 ProtoRefs.push_back(readDeclAs<ObjCProtocolDecl>());
1456 ProtoLocs.reserve(NumProtoRefs);
1457 for (unsigned I = 0; I != NumProtoRefs; ++I)
1458 ProtoLocs.push_back(readSourceLocation());
1459 CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
1460 Reader.getContext());
1461
1462 // Protocols in the class extension belong to the class.
1463 if (NumProtoRefs > 0 && CD->ClassInterface && CD->IsClassExtension())
1464 CD->ClassInterface->mergeClassExtensionProtocolList(
1465 (ObjCProtocolDecl *const *)ProtoRefs.data(), NumProtoRefs,
1466 Reader.getContext());
1467}
1468
1470 VisitNamedDecl(CAD);
1471 CAD->setClassInterface(readDeclAs<ObjCInterfaceDecl>());
1472}
1473
1475 VisitNamedDecl(D);
1476 D->setAtLoc(readSourceLocation());
1477 D->setLParenLoc(readSourceLocation());
1478 QualType T = Record.readType();
1479 TypeSourceInfo *TSI = readTypeSourceInfo();
1480 D->setType(T, TSI);
1486 DeclarationName GetterName = Record.readDeclarationName();
1487 SourceLocation GetterLoc = readSourceLocation();
1488 D->setGetterName(GetterName.getObjCSelector(), GetterLoc);
1489 DeclarationName SetterName = Record.readDeclarationName();
1490 SourceLocation SetterLoc = readSourceLocation();
1491 D->setSetterName(SetterName.getObjCSelector(), SetterLoc);
1492 D->setGetterMethodDecl(readDeclAs<ObjCMethodDecl>());
1493 D->setSetterMethodDecl(readDeclAs<ObjCMethodDecl>());
1494 D->setPropertyIvarDecl(readDeclAs<ObjCIvarDecl>());
1495}
1496
1499 D->setClassInterface(readDeclAs<ObjCInterfaceDecl>());
1500}
1501
1504 D->CategoryNameLoc = readSourceLocation();
1505}
1506
1509 D->setSuperClass(readDeclAs<ObjCInterfaceDecl>());
1510 D->SuperLoc = readSourceLocation();
1511 D->setIvarLBraceLoc(readSourceLocation());
1512 D->setIvarRBraceLoc(readSourceLocation());
1513 D->setHasNonZeroConstructors(Record.readInt());
1514 D->setHasDestructors(Record.readInt());
1515 D->NumIvarInitializers = Record.readInt();
1516 if (D->NumIvarInitializers)
1517 D->IvarInitializers = ReadGlobalOffset();
1518}
1519
1521 VisitDecl(D);
1522 D->setAtLoc(readSourceLocation());
1523 D->setPropertyDecl(readDeclAs<ObjCPropertyDecl>());
1524 D->PropertyIvarDecl = readDeclAs<ObjCIvarDecl>();
1525 D->IvarLoc = readSourceLocation();
1526 D->setGetterMethodDecl(readDeclAs<ObjCMethodDecl>());
1527 D->setSetterMethodDecl(readDeclAs<ObjCMethodDecl>());
1528 D->setGetterCXXConstructor(Record.readExpr());
1529 D->setSetterCXXAssignment(Record.readExpr());
1530}
1531
1534 FD->Mutable = Record.readInt();
1535
1536 unsigned Bits = Record.readInt();
1537 FD->StorageKind = Bits >> 1;
1538 if (FD->StorageKind == FieldDecl::ISK_CapturedVLAType)
1539 FD->CapturedVLAType =
1540 cast<VariableArrayType>(Record.readType().getTypePtr());
1541 else if (Bits & 1)
1542 FD->setBitWidth(Record.readExpr());
1543
1544 if (!FD->getDeclName()) {
1545 if (auto *Tmpl = readDeclAs<FieldDecl>())
1547 }
1548 mergeMergeable(FD);
1549}
1550
1553 PD->GetterId = Record.readIdentifier();
1554 PD->SetterId = Record.readIdentifier();
1555}
1556
1558 VisitValueDecl(D);
1559 D->PartVal.Part1 = Record.readInt();
1560 D->PartVal.Part2 = Record.readInt();
1561 D->PartVal.Part3 = Record.readInt();
1562 for (auto &C : D->PartVal.Part4And5)
1563 C = Record.readInt();
1564
1565 // Add this GUID to the AST context's lookup structure, and merge if needed.
1566 if (MSGuidDecl *Existing = Reader.getContext().MSGuidDecls.GetOrInsertNode(D))
1567 Reader.getContext().setPrimaryMergedDecl(D, Existing->getCanonicalDecl());
1568}
1569
1572 VisitValueDecl(D);
1573 D->Value = Record.readAPValue();
1574
1575 // Add this to the AST context's lookup structure, and merge if needed.
1576 if (UnnamedGlobalConstantDecl *Existing =
1577 Reader.getContext().UnnamedGlobalConstantDecls.GetOrInsertNode(D))
1578 Reader.getContext().setPrimaryMergedDecl(D, Existing->getCanonicalDecl());
1579}
1580
1582 VisitValueDecl(D);
1583 D->Value = Record.readAPValue();
1584
1585 // Add this template parameter object to the AST context's lookup structure,
1586 // and merge if needed.
1587 if (TemplateParamObjectDecl *Existing =
1588 Reader.getContext().TemplateParamObjectDecls.GetOrInsertNode(D))
1589 Reader.getContext().setPrimaryMergedDecl(D, Existing->getCanonicalDecl());
1590}
1591
1593 VisitValueDecl(FD);
1594
1595 FD->ChainingSize = Record.readInt();
1596 assert(FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2");
1597 FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize];
1598
1599 for (unsigned I = 0; I != FD->ChainingSize; ++I)
1600 FD->Chaining[I] = readDeclAs<NamedDecl>();
1601
1602 mergeMergeable(FD);
1603}
1604
1605ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
1606 RedeclarableResult Redecl = VisitRedeclarable(VD);
1608
1609 BitsUnpacker VarDeclBits(Record.readInt());
1610 auto VarLinkage = Linkage(VarDeclBits.getNextBits(/*Width=*/3));
1611 bool DefGeneratedInModule = VarDeclBits.getNextBit();
1612 VD->VarDeclBits.SClass = (StorageClass)VarDeclBits.getNextBits(/*Width=*/3);
1613 VD->VarDeclBits.TSCSpec = VarDeclBits.getNextBits(/*Width=*/2);
1614 VD->VarDeclBits.InitStyle = VarDeclBits.getNextBits(/*Width=*/2);
1615 VD->VarDeclBits.ARCPseudoStrong = VarDeclBits.getNextBit();
1616 bool HasDeducedType = false;
1617 if (!isa<ParmVarDecl>(VD)) {
1618 VD->NonParmVarDeclBits.IsThisDeclarationADemotedDefinition =
1619 VarDeclBits.getNextBit();
1620 VD->NonParmVarDeclBits.ExceptionVar = VarDeclBits.getNextBit();
1621 VD->NonParmVarDeclBits.NRVOVariable = VarDeclBits.getNextBit();
1622 VD->NonParmVarDeclBits.CXXForRangeDecl = VarDeclBits.getNextBit();
1623
1624 VD->NonParmVarDeclBits.IsInline = VarDeclBits.getNextBit();
1625 VD->NonParmVarDeclBits.IsInlineSpecified = VarDeclBits.getNextBit();
1626 VD->NonParmVarDeclBits.IsConstexpr = VarDeclBits.getNextBit();
1627 VD->NonParmVarDeclBits.IsInitCapture = VarDeclBits.getNextBit();
1628 VD->NonParmVarDeclBits.PreviousDeclInSameBlockScope =
1629 VarDeclBits.getNextBit();
1630
1631 VD->NonParmVarDeclBits.EscapingByref = VarDeclBits.getNextBit();
1632 HasDeducedType = VarDeclBits.getNextBit();
1633 VD->NonParmVarDeclBits.ImplicitParamKind =
1634 VarDeclBits.getNextBits(/*Width*/ 3);
1635
1636 VD->NonParmVarDeclBits.ObjCForDecl = VarDeclBits.getNextBit();
1637 }
1638
1639 // If this variable has a deduced type, defer reading that type until we are
1640 // done deserializing this variable, because the type might refer back to the
1641 // variable.
1642 if (HasDeducedType)
1643 Reader.PendingDeducedVarTypes.push_back({VD, DeferredTypeID});
1644 else
1645 VD->setType(Reader.GetType(DeferredTypeID));
1646 DeferredTypeID = 0;
1647
1648 VD->setCachedLinkage(VarLinkage);
1649
1650 // Reconstruct the one piece of the IdentifierNamespace that we need.
1651 if (VD->getStorageClass() == SC_Extern && VarLinkage != Linkage::None &&
1653 VD->setLocalExternDecl();
1654
1655 if (DefGeneratedInModule) {
1656 Reader.DefinitionSource[VD] =
1657 Loc.F->Kind == ModuleKind::MK_MainFile ||
1658 Reader.getContext().getLangOpts().BuildingPCHWithObjectFile;
1659 }
1660
1661 if (VD->hasAttr<BlocksAttr>()) {
1662 Expr *CopyExpr = Record.readExpr();
1663 if (CopyExpr)
1664 Reader.getContext().setBlockVarCopyInit(VD, CopyExpr, Record.readInt());
1665 }
1666
1667 enum VarKind {
1668 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1669 };
1670 switch ((VarKind)Record.readInt()) {
1671 case VarNotTemplate:
1672 // Only true variables (not parameters or implicit parameters) can be
1673 // merged; the other kinds are not really redeclarable at all.
1674 if (!isa<ParmVarDecl>(VD) && !isa<ImplicitParamDecl>(VD) &&
1675 !isa<VarTemplateSpecializationDecl>(VD))
1676 mergeRedeclarable(VD, Redecl);
1677 break;
1678 case VarTemplate:
1679 // Merged when we merge the template.
1680 VD->setDescribedVarTemplate(readDeclAs<VarTemplateDecl>());
1681 break;
1682 case StaticDataMemberSpecialization: { // HasMemberSpecializationInfo.
1683 auto *Tmpl = readDeclAs<VarDecl>();
1684 auto TSK = (TemplateSpecializationKind)Record.readInt();
1685 SourceLocation POI = readSourceLocation();
1686 Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
1687 mergeRedeclarable(VD, Redecl);
1688 break;
1689 }
1690 }
1691
1692 return Redecl;
1693}
1694
1696 if (uint64_t Val = Record.readInt()) {
1697 EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
1698 Eval->HasConstantInitialization = (Val & 2) != 0;
1699 Eval->HasConstantDestruction = (Val & 4) != 0;
1700 Eval->WasEvaluated = (Val & 8) != 0;
1701 if (Eval->WasEvaluated) {
1702 Eval->Evaluated = Record.readAPValue();
1703 if (Eval->Evaluated.needsCleanup())
1704 Reader.getContext().addDestruction(&Eval->Evaluated);
1705 }
1706
1707 // Store the offset of the initializer. Don't deserialize it yet: it might
1708 // not be needed, and might refer back to the variable, for example if it
1709 // contains a lambda.
1710 Eval->Value = GetCurrentCursorOffset();
1711 }
1712}
1713
1715 VisitVarDecl(PD);
1716}
1717
1719 VisitVarDecl(PD);
1720
1721 unsigned scopeIndex = Record.readInt();
1722 BitsUnpacker ParmVarDeclBits(Record.readInt());
1723 unsigned isObjCMethodParam = ParmVarDeclBits.getNextBit();
1724 unsigned scopeDepth = ParmVarDeclBits.getNextBits(/*Width=*/7);
1725 unsigned declQualifier = ParmVarDeclBits.getNextBits(/*Width=*/7);
1726 if (isObjCMethodParam) {
1727 assert(scopeDepth == 0);
1728 PD->setObjCMethodScopeInfo(scopeIndex);
1729 PD->ParmVarDeclBits.ScopeDepthOrObjCQuals = declQualifier;
1730 } else {
1731 PD->setScopeInfo(scopeDepth, scopeIndex);
1732 }
1733 PD->ParmVarDeclBits.IsKNRPromoted = ParmVarDeclBits.getNextBit();
1734
1735 PD->ParmVarDeclBits.HasInheritedDefaultArg = ParmVarDeclBits.getNextBit();
1736 if (ParmVarDeclBits.getNextBit()) // hasUninstantiatedDefaultArg.
1737 PD->setUninstantiatedDefaultArg(Record.readExpr());
1738
1739 if (ParmVarDeclBits.getNextBit()) // Valid explicit object parameter
1740 PD->ExplicitObjectParameterIntroducerLoc = Record.readSourceLocation();
1741
1742 // FIXME: If this is a redeclaration of a function from another module, handle
1743 // inheritance of default arguments.
1744}
1745
1747 VisitVarDecl(DD);
1748 auto **BDs = DD->getTrailingObjects<BindingDecl *>();
1749 for (unsigned I = 0; I != DD->NumBindings; ++I) {
1750 BDs[I] = readDeclAs<BindingDecl>();
1751 BDs[I]->setDecomposedDecl(DD);
1752 }
1753}
1754
1756 VisitValueDecl(BD);
1757 BD->Binding = Record.readExpr();
1758}
1759
1761 VisitDecl(AD);
1762 AD->setAsmString(cast<StringLiteral>(Record.readExpr()));
1763 AD->setRParenLoc(readSourceLocation());
1764}
1765
1767 VisitDecl(D);
1768 D->Statement = Record.readStmt();
1769}
1770
1772 VisitDecl(BD);
1773 BD->setBody(cast_or_null<CompoundStmt>(Record.readStmt()));
1774 BD->setSignatureAsWritten(readTypeSourceInfo());
1775 unsigned NumParams = Record.readInt();
1777 Params.reserve(NumParams);
1778 for (unsigned I = 0; I != NumParams; ++I)
1779 Params.push_back(readDeclAs<ParmVarDecl>());
1780 BD->setParams(Params);
1781
1782 BD->setIsVariadic(Record.readInt());
1783 BD->setBlockMissingReturnType(Record.readInt());
1784 BD->setIsConversionFromLambda(Record.readInt());
1785 BD->setDoesNotEscape(Record.readInt());
1786 BD->setCanAvoidCopyToHeap(Record.readInt());
1787
1788 bool capturesCXXThis = Record.readInt();
1789 unsigned numCaptures = Record.readInt();
1791 captures.reserve(numCaptures);
1792 for (unsigned i = 0; i != numCaptures; ++i) {
1793 auto *decl = readDeclAs<VarDecl>();
1794 unsigned flags = Record.readInt();
1795 bool byRef = (flags & 1);
1796 bool nested = (flags & 2);
1797 Expr *copyExpr = ((flags & 4) ? Record.readExpr() : nullptr);
1798
1799 captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr));
1800 }
1801 BD->setCaptures(Reader.getContext(), captures, capturesCXXThis);
1802}
1803
1805 VisitDecl(CD);
1806 unsigned ContextParamPos = Record.readInt();
1807 CD->setNothrow(Record.readInt() != 0);
1808 // Body is set by VisitCapturedStmt.
1809 for (unsigned I = 0; I < CD->NumParams; ++I) {
1810 if (I != ContextParamPos)
1811 CD->setParam(I, readDeclAs<ImplicitParamDecl>());
1812 else
1813 CD->setContextParam(I, readDeclAs<ImplicitParamDecl>());
1814 }
1815}
1816
1818 VisitDecl(D);
1819 D->setLanguage(static_cast<LinkageSpecLanguageIDs>(Record.readInt()));
1820 D->setExternLoc(readSourceLocation());
1821 D->setRBraceLoc(readSourceLocation());
1822}
1823
1825 VisitDecl(D);
1826 D->RBraceLoc = readSourceLocation();
1827}
1828
1830 VisitNamedDecl(D);
1831 D->setLocStart(readSourceLocation());
1832}
1833
1835 RedeclarableResult Redecl = VisitRedeclarable(D);
1836 VisitNamedDecl(D);
1837
1838 BitsUnpacker NamespaceDeclBits(Record.readInt());
1839 D->setInline(NamespaceDeclBits.getNextBit());
1840 D->setNested(NamespaceDeclBits.getNextBit());
1841 D->LocStart = readSourceLocation();
1842 D->RBraceLoc = readSourceLocation();
1843
1844 // Defer loading the anonymous namespace until we've finished merging
1845 // this namespace; loading it might load a later declaration of the
1846 // same namespace, and we have an invariant that older declarations
1847 // get merged before newer ones try to merge.
1848 GlobalDeclID AnonNamespace;
1849 if (Redecl.getFirstID() == ThisDeclID) {
1850 AnonNamespace = readDeclID();
1851 } else {
1852 // Link this namespace back to the first declaration, which has already
1853 // been deserialized.
1854 D->AnonOrFirstNamespaceAndFlags.setPointer(D->getFirstDecl());
1855 }
1856
1857 mergeRedeclarable(D, Redecl);
1858
1859 if (AnonNamespace.isValid()) {
1860 // Each module has its own anonymous namespace, which is disjoint from
1861 // any other module's anonymous namespaces, so don't attach the anonymous
1862 // namespace at all.
1863 auto *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
1864 if (!Record.isModule())
1865 D->setAnonymousNamespace(Anon);
1866 }
1867}
1868
1870 VisitNamedDecl(D);
1872 D->IsCBuffer = Record.readBool();
1873 D->KwLoc = readSourceLocation();
1874 D->LBraceLoc = readSourceLocation();
1875 D->RBraceLoc = readSourceLocation();
1876}
1877
1879 RedeclarableResult Redecl = VisitRedeclarable(D);
1880 VisitNamedDecl(D);
1881 D->NamespaceLoc = readSourceLocation();
1882 D->IdentLoc = readSourceLocation();
1883 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1884 D->Namespace = readDeclAs<NamedDecl>();
1885 mergeRedeclarable(D, Redecl);
1886}
1887
1889 VisitNamedDecl(D);
1890 D->setUsingLoc(readSourceLocation());
1891 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1892 D->DNLoc = Record.readDeclarationNameLoc(D->getDeclName());
1893 D->FirstUsingShadow.setPointer(readDeclAs<UsingShadowDecl>());
1894 D->setTypename(Record.readInt());
1895 if (auto *Pattern = readDeclAs<NamedDecl>())
1896 Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
1897 mergeMergeable(D);
1898}
1899
1901 VisitNamedDecl(D);
1902 D->setUsingLoc(readSourceLocation());
1903 D->setEnumLoc(readSourceLocation());
1904 D->setEnumType(Record.readTypeSourceInfo());
1905 D->FirstUsingShadow.setPointer(readDeclAs<UsingShadowDecl>());
1906 if (auto *Pattern = readDeclAs<UsingEnumDecl>())
1907 Reader.getContext().setInstantiatedFromUsingEnumDecl(D, Pattern);
1908 mergeMergeable(D);
1909}
1910
1912 VisitNamedDecl(D);
1913 D->InstantiatedFrom = readDeclAs<NamedDecl>();
1914 auto **Expansions = D->getTrailingObjects<NamedDecl *>();
1915 for (unsigned I = 0; I != D->NumExpansions; ++I)
1916 Expansions[I] = readDeclAs<NamedDecl>();
1917 mergeMergeable(D);
1918}
1919
1921 RedeclarableResult Redecl = VisitRedeclarable(D);
1922 VisitNamedDecl(D);
1923 D->Underlying = readDeclAs<NamedDecl>();
1924 D->IdentifierNamespace = Record.readInt();
1925 D->UsingOrNextShadow = readDeclAs<NamedDecl>();
1926 auto *Pattern = readDeclAs<UsingShadowDecl>();
1927 if (Pattern)
1929 mergeRedeclarable(D, Redecl);
1930}
1931
1935 D->NominatedBaseClassShadowDecl = readDeclAs<ConstructorUsingShadowDecl>();
1936 D->ConstructedBaseClassShadowDecl = readDeclAs<ConstructorUsingShadowDecl>();
1937 D->IsVirtual = Record.readInt();
1938}
1939
1941 VisitNamedDecl(D);
1942 D->UsingLoc = readSourceLocation();
1943 D->NamespaceLoc = readSourceLocation();
1944 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1945 D->NominatedNamespace = readDeclAs<NamedDecl>();
1946 D->CommonAncestor = readDeclAs<DeclContext>();
1947}
1948
1950 VisitValueDecl(D);
1951 D->setUsingLoc(readSourceLocation());
1952 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1953 D->DNLoc = Record.readDeclarationNameLoc(D->getDeclName());
1954 D->EllipsisLoc = readSourceLocation();
1955 mergeMergeable(D);
1956}
1957
1960 VisitTypeDecl(D);
1961 D->TypenameLocation = readSourceLocation();
1962 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1963 D->EllipsisLoc = readSourceLocation();
1964 mergeMergeable(D);
1965}
1966
1969 VisitNamedDecl(D);
1970}
1971
1972void ASTDeclReader::ReadCXXDefinitionData(
1973 struct CXXRecordDecl::DefinitionData &Data, const CXXRecordDecl *D,
1974 Decl *LambdaContext, unsigned IndexInLambdaContext) {
1975
1976 BitsUnpacker CXXRecordDeclBits = Record.readInt();
1977
1978 bool ShouldSkipCheckingODR = CXXRecordDeclBits.getNextBit();
1979
1980#define FIELD(Name, Width, Merge) \
1981 if (!CXXRecordDeclBits.canGetNextNBits(Width)) \
1982 CXXRecordDeclBits.updateValue(Record.readInt()); \
1983 Data.Name = CXXRecordDeclBits.getNextBits(Width);
1984
1985#include "clang/AST/CXXRecordDeclDefinitionBits.def"
1986#undef FIELD
1987
1988 // We only perform ODR checks for decls not in GMF.
1989 if (!ShouldSkipCheckingODR) {
1990 // Note: the caller has deserialized the IsLambda bit already.
1991 Data.ODRHash = Record.readInt();
1992 Data.HasODRHash = true;
1993 }
1994
1995 if (Record.readInt()) {
1996 Reader.DefinitionSource[D] =
1997 Loc.F->Kind == ModuleKind::MK_MainFile ||
1998 Reader.getContext().getLangOpts().BuildingPCHWithObjectFile;
1999 }
2000
2001 Record.readUnresolvedSet(Data.Conversions);
2002 Data.ComputedVisibleConversions = Record.readInt();
2003 if (Data.ComputedVisibleConversions)
2004 Record.readUnresolvedSet(Data.VisibleConversions);
2005 assert(Data.Definition && "Data.Definition should be already set!");
2006
2007 if (!Data.IsLambda) {
2008 assert(!LambdaContext && !IndexInLambdaContext &&
2009 "given lambda context for non-lambda");
2010
2011 Data.NumBases = Record.readInt();
2012 if (Data.NumBases)
2013 Data.Bases = ReadGlobalOffset();
2014
2015 Data.NumVBases = Record.readInt();
2016 if (Data.NumVBases)
2017 Data.VBases = ReadGlobalOffset();
2018
2019 Data.FirstFriend = readDeclID().get();
2020 } else {
2021 using Capture = LambdaCapture;
2022
2023 auto &Lambda = static_cast<CXXRecordDecl::LambdaDefinitionData &>(Data);
2024
2025 BitsUnpacker LambdaBits(Record.readInt());
2026 Lambda.DependencyKind = LambdaBits.getNextBits(/*Width=*/2);
2027 Lambda.IsGenericLambda = LambdaBits.getNextBit();
2028 Lambda.CaptureDefault = LambdaBits.getNextBits(/*Width=*/2);
2029 Lambda.NumCaptures = LambdaBits.getNextBits(/*Width=*/15);
2030 Lambda.HasKnownInternalLinkage = LambdaBits.getNextBit();
2031
2032 Lambda.NumExplicitCaptures = Record.readInt();
2033 Lambda.ManglingNumber = Record.readInt();
2034 if (unsigned DeviceManglingNumber = Record.readInt())
2035 Reader.getContext().DeviceLambdaManglingNumbers[D] = DeviceManglingNumber;
2036 Lambda.IndexInContext = IndexInLambdaContext;
2037 Lambda.ContextDecl = LambdaContext;
2038 Capture *ToCapture = nullptr;
2039 if (Lambda.NumCaptures) {
2040 ToCapture = (Capture *)Reader.getContext().Allocate(sizeof(Capture) *
2041 Lambda.NumCaptures);
2042 Lambda.AddCaptureList(Reader.getContext(), ToCapture);
2043 }
2044 Lambda.MethodTyInfo = readTypeSourceInfo();
2045 for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
2046 SourceLocation Loc = readSourceLocation();
2047 BitsUnpacker CaptureBits(Record.readInt());
2048 bool IsImplicit = CaptureBits.getNextBit();
2049 auto Kind =
2050 static_cast<LambdaCaptureKind>(CaptureBits.getNextBits(/*Width=*/3));
2051 switch (Kind) {
2052 case LCK_StarThis:
2053 case LCK_This:
2054 case LCK_VLAType:
2055 new (ToCapture)
2056 Capture(Loc, IsImplicit, Kind, nullptr, SourceLocation());
2057 ToCapture++;
2058 break;
2059 case LCK_ByCopy:
2060 case LCK_ByRef:
2061 auto *Var = readDeclAs<ValueDecl>();
2062 SourceLocation EllipsisLoc = readSourceLocation();
2063 new (ToCapture) Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
2064 ToCapture++;
2065 break;
2066 }
2067 }
2068 }
2069}
2070
2071void ASTDeclReader::MergeDefinitionData(
2072 CXXRecordDecl *D, struct CXXRecordDecl::DefinitionData &&MergeDD) {
2073 assert(D->DefinitionData &&
2074 "merging class definition into non-definition");
2075 auto &DD = *D->DefinitionData;
2076
2077 if (DD.Definition != MergeDD.Definition) {
2078 // Track that we merged the definitions.
2079 Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition,
2080 DD.Definition));
2081 Reader.PendingDefinitions.erase(MergeDD.Definition);
2082 MergeDD.Definition->setCompleteDefinition(false);
2083 Reader.mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
2084 assert(!Reader.Lookups.contains(MergeDD.Definition) &&
2085 "already loaded pending lookups for merged definition");
2086 }
2087
2088 auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
2089 if (PFDI != Reader.PendingFakeDefinitionData.end() &&
2090 PFDI->second == ASTReader::PendingFakeDefinitionKind::Fake) {
2091 // We faked up this definition data because we found a class for which we'd
2092 // not yet loaded the definition. Replace it with the real thing now.
2093 assert(!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?");
2094 PFDI->second = ASTReader::PendingFakeDefinitionKind::FakeLoaded;
2095
2096 // Don't change which declaration is the definition; that is required
2097 // to be invariant once we select it.
2098 auto *Def = DD.Definition;
2099 DD = std::move(MergeDD);
2100 DD.Definition = Def;
2101 return;
2102 }
2103
2104 bool DetectedOdrViolation = false;
2105
2106 #define FIELD(Name, Width, Merge) Merge(Name)
2107 #define MERGE_OR(Field) DD.Field |= MergeDD.Field;
2108 #define NO_MERGE(Field) \
2109 DetectedOdrViolation |= DD.Field != MergeDD.Field; \
2110 MERGE_OR(Field)
2111 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2112 NO_MERGE(IsLambda)
2113 #undef NO_MERGE
2114 #undef MERGE_OR
2115
2116 if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases)
2117 DetectedOdrViolation = true;
2118 // FIXME: Issue a diagnostic if the base classes don't match when we come
2119 // to lazily load them.
2120
2121 // FIXME: Issue a diagnostic if the list of conversion functions doesn't
2122 // match when we come to lazily load them.
2123 if (MergeDD.ComputedVisibleConversions && !DD.ComputedVisibleConversions) {
2124 DD.VisibleConversions = std::move(MergeDD.VisibleConversions);
2125 DD.ComputedVisibleConversions = true;
2126 }
2127
2128 // FIXME: Issue a diagnostic if FirstFriend doesn't match when we come to
2129 // lazily load it.
2130
2131 if (DD.IsLambda) {
2132 auto &Lambda1 = static_cast<CXXRecordDecl::LambdaDefinitionData &>(DD);
2133 auto &Lambda2 = static_cast<CXXRecordDecl::LambdaDefinitionData &>(MergeDD);
2134 DetectedOdrViolation |= Lambda1.DependencyKind != Lambda2.DependencyKind;
2135 DetectedOdrViolation |= Lambda1.IsGenericLambda != Lambda2.IsGenericLambda;
2136 DetectedOdrViolation |= Lambda1.CaptureDefault != Lambda2.CaptureDefault;
2137 DetectedOdrViolation |= Lambda1.NumCaptures != Lambda2.NumCaptures;
2138 DetectedOdrViolation |=
2139 Lambda1.NumExplicitCaptures != Lambda2.NumExplicitCaptures;
2140 DetectedOdrViolation |=
2141 Lambda1.HasKnownInternalLinkage != Lambda2.HasKnownInternalLinkage;
2142 DetectedOdrViolation |= Lambda1.ManglingNumber != Lambda2.ManglingNumber;
2143
2144 if (Lambda1.NumCaptures && Lambda1.NumCaptures == Lambda2.NumCaptures) {
2145 for (unsigned I = 0, N = Lambda1.NumCaptures; I != N; ++I) {
2146 LambdaCapture &Cap1 = Lambda1.Captures.front()[I];
2147 LambdaCapture &Cap2 = Lambda2.Captures.front()[I];
2148 DetectedOdrViolation |= Cap1.getCaptureKind() != Cap2.getCaptureKind();
2149 }
2150 Lambda1.AddCaptureList(Reader.getContext(), Lambda2.Captures.front());
2151 }
2152 }
2153
2154 // We don't want to check ODR for decls in the global module fragment.
2155 if (shouldSkipCheckingODR(MergeDD.Definition))
2156 return;
2157
2158 if (D->getODRHash() != MergeDD.ODRHash) {
2159 DetectedOdrViolation = true;
2160 }
2161
2162 if (DetectedOdrViolation)
2163 Reader.PendingOdrMergeFailures[DD.Definition].push_back(
2164 {MergeDD.Definition, &MergeDD});
2165}
2166
2167void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update,
2168 Decl *LambdaContext,
2169 unsigned IndexInLambdaContext) {
2170 struct CXXRecordDecl::DefinitionData *DD;
2171 ASTContext &C = Reader.getContext();
2172
2173 // Determine whether this is a lambda closure type, so that we can
2174 // allocate the appropriate DefinitionData structure.
2175 bool IsLambda = Record.readInt();
2176 assert(!(IsLambda && Update) &&
2177 "lambda definition should not be added by update record");
2178 if (IsLambda)
2179 DD = new (C) CXXRecordDecl::LambdaDefinitionData(
2180 D, nullptr, CXXRecordDecl::LDK_Unknown, false, LCD_None);
2181 else
2182 DD = new (C) struct CXXRecordDecl::DefinitionData(D);
2183
2184 CXXRecordDecl *Canon = D->getCanonicalDecl();
2185 // Set decl definition data before reading it, so that during deserialization
2186 // when we read CXXRecordDecl, it already has definition data and we don't
2187 // set fake one.
2188 if (!Canon->DefinitionData)
2189 Canon->DefinitionData = DD;
2190 D->DefinitionData = Canon->DefinitionData;
2191 ReadCXXDefinitionData(*DD, D, LambdaContext, IndexInLambdaContext);
2192
2193 // We might already have a different definition for this record. This can
2194 // happen either because we're reading an update record, or because we've
2195 // already done some merging. Either way, just merge into it.
2196 if (Canon->DefinitionData != DD) {
2197 MergeDefinitionData(Canon, std::move(*DD));
2198 return;
2199 }
2200
2201 // Mark this declaration as being a definition.
2202 D->setCompleteDefinition(true);
2203
2204 // If this is not the first declaration or is an update record, we can have
2205 // other redeclarations already. Make a note that we need to propagate the
2206 // DefinitionData pointer onto them.
2207 if (Update || Canon != D)
2208 Reader.PendingDefinitions.insert(D);
2209}
2210
2211ASTDeclReader::RedeclarableResult
2213 RedeclarableResult Redecl = VisitRecordDeclImpl(D);
2214
2215 ASTContext &C = Reader.getContext();
2216
2217 enum CXXRecKind {
2218 CXXRecNotTemplate = 0,
2219 CXXRecTemplate,
2220 CXXRecMemberSpecialization,
2221 CXXLambda
2222 };
2223
2224 Decl *LambdaContext = nullptr;
2225 unsigned IndexInLambdaContext = 0;
2226
2227 switch ((CXXRecKind)Record.readInt()) {
2228 case CXXRecNotTemplate:
2229 // Merged when we merge the folding set entry in the primary template.
2230 if (!isa<ClassTemplateSpecializationDecl>(D))
2231 mergeRedeclarable(D, Redecl);
2232 break;
2233 case CXXRecTemplate: {
2234 // Merged when we merge the template.
2235 auto *Template = readDeclAs<ClassTemplateDecl>();
2236 D->TemplateOrInstantiation = Template;
2237 if (!Template->getTemplatedDecl()) {
2238 // We've not actually loaded the ClassTemplateDecl yet, because we're
2239 // currently being loaded as its pattern. Rely on it to set up our
2240 // TypeForDecl (see VisitClassTemplateDecl).
2241 //
2242 // Beware: we do not yet know our canonical declaration, and may still
2243 // get merged once the surrounding class template has got off the ground.
2244 DeferredTypeID = 0;
2245 }
2246 break;
2247 }
2248 case CXXRecMemberSpecialization: {
2249 auto *RD = readDeclAs<CXXRecordDecl>();
2250 auto TSK = (TemplateSpecializationKind)Record.readInt();
2251 SourceLocation POI = readSourceLocation();
2253 MSI->setPointOfInstantiation(POI);
2254 D->TemplateOrInstantiation = MSI;
2255 mergeRedeclarable(D, Redecl);
2256 break;
2257 }
2258 case CXXLambda: {
2259 LambdaContext = readDecl();
2260 if (LambdaContext)
2261 IndexInLambdaContext = Record.readInt();
2262 mergeLambda(D, Redecl, LambdaContext, IndexInLambdaContext);
2263 break;
2264 }
2265 }
2266
2267 bool WasDefinition = Record.readInt();
2268 if (WasDefinition)
2269 ReadCXXRecordDefinition(D, /*Update=*/false, LambdaContext,
2270 IndexInLambdaContext);
2271 else
2272 // Propagate DefinitionData pointer from the canonical declaration.
2273 D->DefinitionData = D->getCanonicalDecl()->DefinitionData;
2274
2275 // Lazily load the key function to avoid deserializing every method so we can
2276 // compute it.
2277 if (WasDefinition) {
2278 GlobalDeclID KeyFn = readDeclID();
2279 if (KeyFn.get() && D->isCompleteDefinition())
2280 // FIXME: This is wrong for the ARM ABI, where some other module may have
2281 // made this function no longer be a key function. We need an update
2282 // record or similar for that case.
2283 C.KeyFunctions[D] = KeyFn.get();
2284 }
2285
2286 return Redecl;
2287}
2288
2290 D->setExplicitSpecifier(Record.readExplicitSpec());
2291 D->Ctor = readDeclAs<CXXConstructorDecl>();
2294 static_cast<DeductionCandidate>(Record.readInt()));
2295}
2296
2299
2300 unsigned NumOverridenMethods = Record.readInt();
2301 if (D->isCanonicalDecl()) {
2302 while (NumOverridenMethods--) {
2303 // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
2304 // MD may be initializing.
2305 if (auto *MD = readDeclAs<CXXMethodDecl>())
2307 }
2308 } else {
2309 // We don't care about which declarations this used to override; we get
2310 // the relevant information from the canonical declaration.
2311 Record.skipInts(NumOverridenMethods);
2312 }
2313}
2314
2316 // We need the inherited constructor information to merge the declaration,
2317 // so we have to read it before we call VisitCXXMethodDecl.
2318 D->setExplicitSpecifier(Record.readExplicitSpec());
2319 if (D->isInheritingConstructor()) {
2320 auto *Shadow = readDeclAs<ConstructorUsingShadowDecl>();
2321 auto *Ctor = readDeclAs<CXXConstructorDecl>();
2322 *D->getTrailingObjects<InheritedConstructor>() =
2323 InheritedConstructor(Shadow, Ctor);
2324 }
2325
2327}
2328
2331
2332 if (auto *OperatorDelete = readDeclAs<FunctionDecl>()) {
2333 CXXDestructorDecl *Canon = D->getCanonicalDecl();
2334 auto *ThisArg = Record.readExpr();
2335 // FIXME: Check consistency if we have an old and new operator delete.
2336 if (!Canon->OperatorDelete) {
2337 Canon->OperatorDelete = OperatorDelete;
2338 Canon->OperatorDeleteThisArg = ThisArg;
2339 }
2340 }
2341}
2342
2344 D->setExplicitSpecifier(Record.readExplicitSpec());
2346}
2347
2349 VisitDecl(D);
2350 D->ImportedModule = readModule();
2351 D->setImportComplete(Record.readInt());
2352 auto *StoredLocs = D->getTrailingObjects<SourceLocation>();
2353 for (unsigned I = 0, N = Record.back(); I != N; ++I)
2354 StoredLocs[I] = readSourceLocation();
2355 Record.skipInts(1); // The number of stored source locations.
2356}
2357
2359 VisitDecl(D);
2360 D->setColonLoc(readSourceLocation());
2361}
2362
2364 VisitDecl(D);
2365 if (Record.readInt()) // hasFriendDecl
2366 D->Friend = readDeclAs<NamedDecl>();
2367 else
2368 D->Friend = readTypeSourceInfo();
2369 for (unsigned i = 0; i != D->NumTPLists; ++i)
2370 D->getTrailingObjects<TemplateParameterList *>()[i] =
2371 Record.readTemplateParameterList();
2372 D->NextFriend = readDeclID().get();
2373 D->UnsupportedFriend = (Record.readInt() != 0);
2374 D->FriendLoc = readSourceLocation();
2375}
2376
2378 VisitDecl(D);
2379 unsigned NumParams = Record.readInt();
2380 D->NumParams = NumParams;
2381 D->Params = new (Reader.getContext()) TemplateParameterList *[NumParams];
2382 for (unsigned i = 0; i != NumParams; ++i)
2383 D->Params[i] = Record.readTemplateParameterList();
2384 if (Record.readInt()) // HasFriendDecl
2385 D->Friend = readDeclAs<NamedDecl>();
2386 else
2387 D->Friend = readTypeSourceInfo();
2388 D->FriendLoc = readSourceLocation();
2389}
2390
2392 VisitNamedDecl(D);
2393
2394 assert(!D->TemplateParams && "TemplateParams already set!");
2395 D->TemplateParams = Record.readTemplateParameterList();
2396 D->init(readDeclAs<NamedDecl>());
2397}
2398
2401 D->ConstraintExpr = Record.readExpr();
2402 mergeMergeable(D);
2403}
2404
2407 // The size of the template list was read during creation of the Decl, so we
2408 // don't have to re-read it here.
2409 VisitDecl(D);
2411 for (unsigned I = 0; I < D->NumTemplateArgs; ++I)
2412 Args.push_back(Record.readTemplateArgument(/*Canonicalize=*/true));
2413 D->setTemplateArguments(Args);
2414}
2415
2417}
2418
2419ASTDeclReader::RedeclarableResult
2421 RedeclarableResult Redecl = VisitRedeclarable(D);
2422
2423 // Make sure we've allocated the Common pointer first. We do this before
2424 // VisitTemplateDecl so that getCommonPtr() can be used during initialization.
2426 if (!CanonD->Common) {
2427 CanonD->Common = CanonD->newCommon(Reader.getContext());
2428 Reader.PendingDefinitions.insert(CanonD);
2429 }
2430 D->Common = CanonD->Common;
2431
2432 // If this is the first declaration of the template, fill in the information
2433 // for the 'common' pointer.
2434 if (ThisDeclID == Redecl.getFirstID()) {
2435 if (auto *RTD = readDeclAs<RedeclarableTemplateDecl>()) {
2436 assert(RTD->getKind() == D->getKind() &&
2437 "InstantiatedFromMemberTemplate kind mismatch");
2439 if (Record.readInt())
2441 }
2442 }
2443
2445 D->IdentifierNamespace = Record.readInt();
2446
2447 return Redecl;
2448}
2449
2451 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2452 mergeRedeclarableTemplate(D, Redecl);
2453
2454 if (ThisDeclID == Redecl.getFirstID()) {
2455 // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of
2456 // the specializations.
2458 readDeclIDList(SpecIDs);
2460 }
2461
2462 if (D->getTemplatedDecl()->TemplateOrInstantiation) {
2463 // We were loaded before our templated declaration was. We've not set up
2464 // its corresponding type yet (see VisitCXXRecordDeclImpl), so reconstruct
2465 // it now.
2468 }
2469}
2470
2472 llvm_unreachable("BuiltinTemplates are not serialized");
2473}
2474
2475/// TODO: Unify with ClassTemplateDecl version?
2476/// May require unifying ClassTemplateDecl and
2477/// VarTemplateDecl beyond TemplateDecl...
2479 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2480 mergeRedeclarableTemplate(D, Redecl);
2481
2482 if (ThisDeclID == Redecl.getFirstID()) {
2483 // This VarTemplateDecl owns a CommonPtr; read it to keep track of all of
2484 // the specializations.
2486 readDeclIDList(SpecIDs);
2488 }
2489}
2490
2491ASTDeclReader::RedeclarableResult
2494 RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D);
2495
2496 ASTContext &C = Reader.getContext();
2497 if (Decl *InstD = readDecl()) {
2498 if (auto *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
2499 D->SpecializedTemplate = CTD;
2500 } else {
2502 Record.readTemplateArgumentList(TemplArgs);
2503 TemplateArgumentList *ArgList
2504 = TemplateArgumentList::CreateCopy(C, TemplArgs);
2505 auto *PS =
2507 SpecializedPartialSpecialization();
2508 PS->PartialSpecialization
2509 = cast<ClassTemplatePartialSpecializationDecl>(InstD);
2510 PS->TemplateArgs = ArgList;
2511 D->SpecializedTemplate = PS;
2512 }
2513 }
2514
2516 Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
2517 D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
2518 D->PointOfInstantiation = readSourceLocation();
2519 D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
2520
2521 bool writtenAsCanonicalDecl = Record.readInt();
2522 if (writtenAsCanonicalDecl) {
2523 auto *CanonPattern = readDeclAs<ClassTemplateDecl>();
2524 if (D->isCanonicalDecl()) { // It's kept in the folding set.
2525 // Set this as, or find, the canonical declaration for this specialization
2527 if (auto *Partial = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
2528 CanonSpec = CanonPattern->getCommonPtr()->PartialSpecializations
2529 .GetOrInsertNode(Partial);
2530 } else {
2531 CanonSpec =
2532 CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2533 }
2534 // If there was already a canonical specialization, merge into it.
2535 if (CanonSpec != D) {
2536 mergeRedeclarable<TagDecl>(D, CanonSpec, Redecl);
2537
2538 // This declaration might be a definition. Merge with any existing
2539 // definition.
2540 if (auto *DDD = D->DefinitionData) {
2541 if (CanonSpec->DefinitionData)
2542 MergeDefinitionData(CanonSpec, std::move(*DDD));
2543 else
2544 CanonSpec->DefinitionData = D->DefinitionData;
2545 }
2546 D->DefinitionData = CanonSpec->DefinitionData;
2547 }
2548 }
2549 }
2550
2551 // extern/template keyword locations for explicit instantiations
2552 if (Record.readBool()) {
2553 auto *ExplicitInfo = new (C) ExplicitInstantiationInfo;
2554 ExplicitInfo->ExternKeywordLoc = readSourceLocation();
2555 ExplicitInfo->TemplateKeywordLoc = readSourceLocation();
2556 D->ExplicitInfo = ExplicitInfo;
2557 }
2558
2559 if (Record.readBool())
2560 D->setTemplateArgsAsWritten(Record.readASTTemplateArgumentListInfo());
2561
2562 return Redecl;
2563}
2564
2567 // We need to read the template params first because redeclarable is going to
2568 // need them for profiling
2569 TemplateParameterList *Params = Record.readTemplateParameterList();
2570 D->TemplateParams = Params;
2571
2572 RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
2573
2574 // These are read/set from/to the first declaration.
2575 if (ThisDeclID == Redecl.getFirstID()) {
2576 D->InstantiatedFromMember.setPointer(
2577 readDeclAs<ClassTemplatePartialSpecializationDecl>());
2578 D->InstantiatedFromMember.setInt(Record.readInt());
2579 }
2580}
2581
2583 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2584
2585 if (ThisDeclID == Redecl.getFirstID()) {
2586 // This FunctionTemplateDecl owns a CommonPtr; read it.
2588 readDeclIDList(SpecIDs);
2590 }
2591}
2592
2593/// TODO: Unify with ClassTemplateSpecializationDecl version?
2594/// May require unifying ClassTemplate(Partial)SpecializationDecl and
2595/// VarTemplate(Partial)SpecializationDecl with a new data
2596/// structure Template(Partial)SpecializationDecl, and
2597/// using Template(Partial)SpecializationDecl as input type.
2598ASTDeclReader::RedeclarableResult
2601 ASTContext &C = Reader.getContext();
2602 if (Decl *InstD = readDecl()) {
2603 if (auto *VTD = dyn_cast<VarTemplateDecl>(InstD)) {
2604 D->SpecializedTemplate = VTD;
2605 } else {
2607 Record.readTemplateArgumentList(TemplArgs);
2609 C, TemplArgs);
2610 auto *PS =
2611 new (C)
2612 VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
2613 PS->PartialSpecialization =
2614 cast<VarTemplatePartialSpecializationDecl>(InstD);
2615 PS->TemplateArgs = ArgList;
2616 D->SpecializedTemplate = PS;
2617 }
2618 }
2619
2620 // extern/template keyword locations for explicit instantiations
2621 if (Record.readBool()) {
2622 auto *ExplicitInfo = new (C) ExplicitInstantiationInfo;
2623 ExplicitInfo->ExternKeywordLoc = readSourceLocation();
2624 ExplicitInfo->TemplateKeywordLoc = readSourceLocation();
2625 D->ExplicitInfo = ExplicitInfo;
2626 }
2627
2628 if (Record.readBool())
2629 D->setTemplateArgsAsWritten(Record.readASTTemplateArgumentListInfo());
2630
2632 Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
2633 D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
2634 D->PointOfInstantiation = readSourceLocation();
2635 D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
2636 D->IsCompleteDefinition = Record.readInt();
2637
2638 RedeclarableResult Redecl = VisitVarDeclImpl(D);
2639
2640 bool writtenAsCanonicalDecl = Record.readInt();
2641 if (writtenAsCanonicalDecl) {
2642 auto *CanonPattern = readDeclAs<VarTemplateDecl>();
2643 if (D->isCanonicalDecl()) { // It's kept in the folding set.
2645 if (auto *Partial = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
2646 CanonSpec = CanonPattern->getCommonPtr()
2647 ->PartialSpecializations.GetOrInsertNode(Partial);
2648 } else {
2649 CanonSpec =
2650 CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2651 }
2652 // If we already have a matching specialization, merge it.
2653 if (CanonSpec != D)
2654 mergeRedeclarable<VarDecl>(D, CanonSpec, Redecl);
2655 }
2656 }
2657
2658 return Redecl;
2659}
2660
2661/// TODO: Unify with ClassTemplatePartialSpecializationDecl version?
2662/// May require unifying ClassTemplate(Partial)SpecializationDecl and
2663/// VarTemplate(Partial)SpecializationDecl with a new data
2664/// structure Template(Partial)SpecializationDecl, and
2665/// using Template(Partial)SpecializationDecl as input type.
2668 TemplateParameterList *Params = Record.readTemplateParameterList();
2669 D->TemplateParams = Params;
2670
2671 RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
2672
2673 // These are read/set from/to the first declaration.
2674 if (ThisDeclID == Redecl.getFirstID()) {
2675 D->InstantiatedFromMember.setPointer(
2676 readDeclAs<VarTemplatePartialSpecializationDecl>());
2677 D->InstantiatedFromMember.setInt(Record.readInt());
2678 }
2679}
2680
2682 VisitTypeDecl(D);
2683
2684 D->setDeclaredWithTypename(Record.readInt());
2685
2686 if (D->hasTypeConstraint()) {
2687 ConceptReference *CR = nullptr;
2688 if (Record.readBool())
2689 CR = Record.readConceptReference();
2690 Expr *ImmediatelyDeclaredConstraint = Record.readExpr();
2691
2692 D->setTypeConstraint(CR, ImmediatelyDeclaredConstraint);
2693 if ((D->ExpandedParameterPack = Record.readInt()))
2694 D->NumExpanded = Record.readInt();
2695 }
2696
2697 if (Record.readInt())
2698 D->setDefaultArgument(readTypeSourceInfo());
2699}
2700
2703 // TemplateParmPosition.
2704 D->setDepth(Record.readInt());
2705 D->setPosition(Record.readInt());
2707 D->setPlaceholderTypeConstraint(Record.readExpr());
2708 if (D->isExpandedParameterPack()) {
2709 auto TypesAndInfos =
2710 D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
2711 for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2712 new (&TypesAndInfos[I].first) QualType(Record.readType());
2713 TypesAndInfos[I].second = readTypeSourceInfo();
2714 }
2715 } else {
2716 // Rest of NonTypeTemplateParmDecl.
2717 D->ParameterPack = Record.readInt();
2718 if (Record.readInt())
2719 D->setDefaultArgument(Record.readExpr());
2720 }
2721}
2722
2725 D->setDeclaredWithTypename(Record.readBool());
2726 // TemplateParmPosition.
2727 D->setDepth(Record.readInt());
2728 D->setPosition(Record.readInt());
2729 if (D->isExpandedParameterPack()) {
2730 auto **Data = D->getTrailingObjects<TemplateParameterList *>();
2731 for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2732 I != N; ++I)
2733 Data[I] = Record.readTemplateParameterList();
2734 } else {
2735 // Rest of TemplateTemplateParmDecl.
2736 D->ParameterPack = Record.readInt();
2737 if (Record.readInt())
2738 D->setDefaultArgument(Reader.getContext(),
2739 Record.readTemplateArgumentLoc());
2740 }
2741}
2742
2744 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2745 mergeRedeclarableTemplate(D, Redecl);
2746}
2747
2749 VisitDecl(D);
2750 D->AssertExprAndFailed.setPointer(Record.readExpr());
2751 D->AssertExprAndFailed.setInt(Record.readInt());
2752 D->Message = cast_or_null<StringLiteral>(Record.readExpr());
2753 D->RParenLoc = readSourceLocation();
2754}
2755
2757 VisitDecl(D);
2758}
2759
2762 VisitDecl(D);
2763 D->ExtendingDecl = readDeclAs<ValueDecl>();
2764 D->ExprWithTemporary = Record.readStmt();
2765 if (Record.readInt()) {
2766 D->Value = new (D->getASTContext()) APValue(Record.readAPValue());
2767 D->getASTContext().addDestruction(D->Value);
2768 }
2769 D->ManglingNumber = Record.readInt();
2770 mergeMergeable(D);
2771}
2772
2773std::pair<uint64_t, uint64_t>
2775 uint64_t LexicalOffset = ReadLocalOffset();
2776 uint64_t VisibleOffset = ReadLocalOffset();
2777 return std::make_pair(LexicalOffset, VisibleOffset);
2778}
2779
2780template <typename T>
2781ASTDeclReader::RedeclarableResult
2783 GlobalDeclID FirstDeclID = readDeclID();
2784 Decl *MergeWith = nullptr;
2785
2786 bool IsKeyDecl = ThisDeclID == FirstDeclID;
2787 bool IsFirstLocalDecl = false;
2788
2789 uint64_t RedeclOffset = 0;
2790
2791 // invalid FirstDeclID indicates that this declaration was the only
2792 // declaration of its entity, and is used for space optimization.
2793 if (FirstDeclID.isInvalid()) {
2794 FirstDeclID = ThisDeclID;
2795 IsKeyDecl = true;
2796 IsFirstLocalDecl = true;
2797 } else if (unsigned N = Record.readInt()) {
2798 // This declaration was the first local declaration, but may have imported
2799 // other declarations.
2800 IsKeyDecl = N == 1;
2801 IsFirstLocalDecl = true;
2802
2803 // We have some declarations that must be before us in our redeclaration
2804 // chain. Read them now, and remember that we ought to merge with one of
2805 // them.
2806 // FIXME: Provide a known merge target to the second and subsequent such
2807 // declaration.
2808 for (unsigned I = 0; I != N - 1; ++I)
2809 MergeWith = readDecl();
2810
2811 RedeclOffset = ReadLocalOffset();
2812 } else {
2813 // This declaration was not the first local declaration. Read the first
2814 // local declaration now, to trigger the import of other redeclarations.
2815 (void)readDecl();
2816 }
2817
2818 auto *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID));
2819 if (FirstDecl != D) {
2820 // We delay loading of the redeclaration chain to avoid deeply nested calls.
2821 // We temporarily set the first (canonical) declaration as the previous one
2822 // which is the one that matters and mark the real previous DeclID to be
2823 // loaded & attached later on.
2825 D->First = FirstDecl->getCanonicalDecl();
2826 }
2827
2828 auto *DAsT = static_cast<T *>(D);
2829
2830 // Note that we need to load local redeclarations of this decl and build a
2831 // decl chain for them. This must happen *after* we perform the preloading
2832 // above; this ensures that the redeclaration chain is built in the correct
2833 // order.
2834 if (IsFirstLocalDecl)
2835 Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset));
2836
2837 return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl);
2838}
2839
2840/// Attempts to merge the given declaration (D) with another declaration
2841/// of the same entity.
2842template <typename T>
2844 RedeclarableResult &Redecl) {
2845 // If modules are not available, there is no reason to perform this merge.
2846 if (!Reader.getContext().getLangOpts().Modules)
2847 return;
2848
2849 // If we're not the canonical declaration, we don't need to merge.
2850 if (!DBase->isFirstDecl())
2851 return;
2852
2853 auto *D = static_cast<T *>(DBase);
2854
2855 if (auto *Existing = Redecl.getKnownMergeTarget())
2856 // We already know of an existing declaration we should merge with.
2857 mergeRedeclarable(D, cast<T>(Existing), Redecl);
2858 else if (FindExistingResult ExistingRes = findExisting(D))
2859 if (T *Existing = ExistingRes)
2860 mergeRedeclarable(D, Existing, Redecl);
2861}
2862
2863/// Attempt to merge D with a previous declaration of the same lambda, which is
2864/// found by its index within its context declaration, if it has one.
2865///
2866/// We can't look up lambdas in their enclosing lexical or semantic context in
2867/// general, because for lambdas in variables, both of those might be a
2868/// namespace or the translation unit.
2869void ASTDeclReader::mergeLambda(CXXRecordDecl *D, RedeclarableResult &Redecl,
2870 Decl *Context, unsigned IndexInContext) {
2871 // If we don't have a mangling context, treat this like any other
2872 // declaration.
2873 if (!Context)
2874 return mergeRedeclarable(D, Redecl);
2875
2876 // If modules are not available, there is no reason to perform this merge.
2877 if (!Reader.getContext().getLangOpts().Modules)
2878 return;
2879
2880 // If we're not the canonical declaration, we don't need to merge.
2881 if (!D->isFirstDecl())
2882 return;
2883
2884 if (auto *Existing = Redecl.getKnownMergeTarget())
2885 // We already know of an existing declaration we should merge with.
2886 mergeRedeclarable(D, cast<TagDecl>(Existing), Redecl);
2887
2888 // Look up this lambda to see if we've seen it before. If so, merge with the
2889 // one we already loaded.
2890 NamedDecl *&Slot = Reader.LambdaDeclarationsForMerging[{
2891 Context->getCanonicalDecl(), IndexInContext}];
2892 if (Slot)
2893 mergeRedeclarable(D, cast<TagDecl>(Slot), Redecl);
2894 else
2895 Slot = D;
2896}
2897
2899 RedeclarableResult &Redecl) {
2900 mergeRedeclarable(D, Redecl);
2901 // If we merged the template with a prior declaration chain, merge the
2902 // common pointer.
2903 // FIXME: Actually merge here, don't just overwrite.
2904 D->Common = D->getCanonicalDecl()->Common;
2905}
2906
2907/// "Cast" to type T, asserting if we don't have an implicit conversion.
2908/// We use this to put code in a template that will only be valid for certain
2909/// instantiations.
2910template<typename T> static T assert_cast(T t) { return t; }
2911template<typename T> static T assert_cast(...) {
2912 llvm_unreachable("bad assert_cast");
2913}
2914
2915/// Merge together the pattern declarations from two template
2916/// declarations.
2918 RedeclarableTemplateDecl *Existing,
2919 bool IsKeyDecl) {
2920 auto *DPattern = D->getTemplatedDecl();
2921 auto *ExistingPattern = Existing->getTemplatedDecl();
2922 RedeclarableResult Result(
2923 /*MergeWith*/ ExistingPattern,
2924 GlobalDeclID(DPattern->getCanonicalDecl()->getGlobalID()), IsKeyDecl);
2925
2926 if (auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) {
2927 // Merge with any existing definition.
2928 // FIXME: This is duplicated in several places. Refactor.
2929 auto *ExistingClass =
2930 cast<CXXRecordDecl>(ExistingPattern)->getCanonicalDecl();
2931 if (auto *DDD = DClass->DefinitionData) {
2932 if (ExistingClass->DefinitionData) {
2933 MergeDefinitionData(ExistingClass, std::move(*DDD));
2934 } else {
2935 ExistingClass->DefinitionData = DClass->DefinitionData;
2936 // We may have skipped this before because we thought that DClass
2937 // was the canonical declaration.
2938 Reader.PendingDefinitions.insert(DClass);
2939 }
2940 }
2941 DClass->DefinitionData = ExistingClass->DefinitionData;
2942
2943 return mergeRedeclarable(DClass, cast<TagDecl>(ExistingPattern),
2944 Result);
2945 }
2946 if (auto *DFunction = dyn_cast<FunctionDecl>(DPattern))
2947 return mergeRedeclarable(DFunction, cast<FunctionDecl>(ExistingPattern),
2948 Result);
2949 if (auto *DVar = dyn_cast<VarDecl>(DPattern))
2950 return mergeRedeclarable(DVar, cast<VarDecl>(ExistingPattern), Result);
2951 if (auto *DAlias = dyn_cast<TypeAliasDecl>(DPattern))
2952 return mergeRedeclarable(DAlias, cast<TypedefNameDecl>(ExistingPattern),
2953 Result);
2954 llvm_unreachable("merged an unknown kind of redeclarable template");
2955}
2956
2957/// Attempts to merge the given declaration (D) with another declaration
2958/// of the same entity.
2959template <typename T>
2961 RedeclarableResult &Redecl) {
2962 auto *D = static_cast<T *>(DBase);
2963 T *ExistingCanon = Existing->getCanonicalDecl();
2964 T *DCanon = D->getCanonicalDecl();
2965 if (ExistingCanon != DCanon) {
2966 // Have our redeclaration link point back at the canonical declaration
2967 // of the existing declaration, so that this declaration has the
2968 // appropriate canonical declaration.
2970 D->First = ExistingCanon;
2971 ExistingCanon->Used |= D->Used;
2972 D->Used = false;
2973
2974 // When we merge a namespace, update its pointer to the first namespace.
2975 // We cannot have loaded any redeclarations of this declaration yet, so
2976 // there's nothing else that needs to be updated.
2977 if (auto *Namespace = dyn_cast<NamespaceDecl>(D))
2978 Namespace->AnonOrFirstNamespaceAndFlags.setPointer(
2979 assert_cast<NamespaceDecl *>(ExistingCanon));
2980
2981 // When we merge a template, merge its pattern.
2982 if (auto *DTemplate = dyn_cast<RedeclarableTemplateDecl>(D))
2984 DTemplate, assert_cast<RedeclarableTemplateDecl *>(ExistingCanon),
2985 Redecl.isKeyDecl());
2986
2987 // If this declaration is a key declaration, make a note of that.
2988 if (Redecl.isKeyDecl())
2989 Reader.KeyDecls[ExistingCanon].push_back(Redecl.getFirstID());
2990 }
2991}
2992
2993/// ODR-like semantics for C/ObjC allow us to merge tag types and a structural
2994/// check in Sema guarantees the types can be merged (see C11 6.2.7/1 or C89
2995/// 6.1.2.6/1). Although most merging is done in Sema, we need to guarantee
2996/// that some types are mergeable during deserialization, otherwise name
2997/// lookup fails. This is the case for EnumConstantDecl.
2999 if (!ND)
3000 return false;
3001 // TODO: implement merge for other necessary decls.
3002 if (isa<EnumConstantDecl, FieldDecl, IndirectFieldDecl>(ND))
3003 return true;
3004 return false;
3005}
3006
3007/// Attempts to merge LifetimeExtendedTemporaryDecl with
3008/// identical class definitions from two different modules.
3010 // If modules are not available, there is no reason to perform this merge.
3011 if (!Reader.getContext().getLangOpts().Modules)
3012 return;
3013
3014 LifetimeExtendedTemporaryDecl *LETDecl = D;
3015
3017 Reader.LETemporaryForMerging[std::make_pair(
3018 LETDecl->getExtendingDecl(), LETDecl->getManglingNumber())];
3019 if (LookupResult)
3020 Reader.getContext().setPrimaryMergedDecl(LETDecl,
3021 LookupResult->getCanonicalDecl());
3022 else
3023 LookupResult = LETDecl;
3024}
3025
3026/// Attempts to merge the given declaration (D) with another declaration
3027/// of the same entity, for the case where the entity is not actually
3028/// redeclarable. This happens, for instance, when merging the fields of
3029/// identical class definitions from two different modules.
3030template<typename T>
3032 // If modules are not available, there is no reason to perform this merge.
3033 if (!Reader.getContext().getLangOpts().Modules)
3034 return;
3035
3036 // ODR-based merging is performed in C++ and in some cases (tag types) in C.
3037 // Note that C identically-named things in different translation units are
3038 // not redeclarations, but may still have compatible types, where ODR-like
3039 // semantics may apply.
3040 if (!Reader.getContext().getLangOpts().CPlusPlus &&
3041 !allowODRLikeMergeInC(dyn_cast<NamedDecl>(static_cast<T*>(D))))
3042 return;
3043
3044 if (FindExistingResult ExistingRes = findExisting(static_cast<T*>(D)))
3045 if (T *Existing = ExistingRes)
3046 Reader.getContext().setPrimaryMergedDecl(static_cast<T *>(D),
3047 Existing->getCanonicalDecl());
3048}
3049
3051 Record.readOMPChildren(D->Data);
3052 VisitDecl(D);
3053}
3054
3056 Record.readOMPChildren(D->Data);
3057 VisitDecl(D);
3058}
3059
3061 Record.readOMPChildren(D->Data);
3062 VisitDecl(D);
3063}
3064
3066 VisitValueDecl(D);
3067 D->setLocation(readSourceLocation());
3068 Expr *In = Record.readExpr();
3069 Expr *Out = Record.readExpr();
3070 D->setCombinerData(In, Out);
3071 Expr *Combiner = Record.readExpr();
3072 D->setCombiner(Combiner);
3073 Expr *Orig = Record.readExpr();
3074 Expr *Priv = Record.readExpr();
3075 D->setInitializerData(Orig, Priv);
3076 Expr *Init = Record.readExpr();
3077 auto IK = static_cast<OMPDeclareReductionInitKind>(Record.readInt());
3078 D->setInitializer(Init, IK);
3079 D->PrevDeclInScope = readDeclID().get();
3080}
3081
3083 Record.readOMPChildren(D->Data);
3084 VisitValueDecl(D);
3085 D->VarName = Record.readDeclarationName();
3086 D->PrevDeclInScope = readDeclID().get();
3087}
3088
3090 VisitVarDecl(D);
3091}
3092
3093//===----------------------------------------------------------------------===//
3094// Attribute Reading
3095//===----------------------------------------------------------------------===//
3096
3097namespace {
3098class AttrReader {
3099 ASTRecordReader &Reader;
3100
3101public:
3102 AttrReader(ASTRecordReader &Reader) : Reader(Reader) {}
3103
3104 uint64_t readInt() {
3105 return Reader.readInt();
3106 }
3107
3108 bool readBool() { return Reader.readBool(); }
3109
3110 SourceRange readSourceRange() {
3111 return Reader.readSourceRange();
3112 }
3113
3114 SourceLocation readSourceLocation() {
3115 return Reader.readSourceLocation();
3116 }
3117
3118 Expr *readExpr() { return Reader.readExpr(); }
3119
3120 Attr *readAttr() { return Reader.readAttr(); }
3121
3122 std::string readString() {
3123 return Reader.readString();
3124 }
3125
3126 TypeSourceInfo *readTypeSourceInfo() {
3127 return Reader.readTypeSourceInfo();
3128 }
3129
3130 IdentifierInfo *readIdentifier() {
3131 return Reader.readIdentifier();
3132 }
3133
3134 VersionTuple readVersionTuple() {
3135 return Reader.readVersionTuple();
3136 }
3137
3138 OMPTraitInfo *readOMPTraitInfo() { return Reader.readOMPTraitInfo(); }
3139
3140 template <typename T> T *GetLocalDeclAs(LocalDeclID LocalID) {
3141 return Reader.GetLocalDeclAs<T>(LocalID);
3142 }
3143};
3144}
3145
3147 AttrReader Record(*this);
3148 auto V = Record.readInt();
3149 if (!V)
3150 return nullptr;
3151
3152 Attr *New = nullptr;
3153 // Kind is stored as a 1-based integer because 0 is used to indicate a null
3154 // Attr pointer.
3155 auto Kind = static_cast<attr::Kind>(V - 1);
3156 ASTContext &Context = getContext();
3157
3158 IdentifierInfo *AttrName = Record.readIdentifier();
3159 IdentifierInfo *ScopeName = Record.readIdentifier();
3160 SourceRange AttrRange = Record.readSourceRange();
3161 SourceLocation ScopeLoc = Record.readSourceLocation();
3162 unsigned ParsedKind = Record.readInt();
3163 unsigned Syntax = Record.readInt();
3164 unsigned SpellingIndex = Record.readInt();
3165 bool IsAlignas = (ParsedKind == AttributeCommonInfo::AT_Aligned &&
3167 SpellingIndex == AlignedAttr::Keyword_alignas);
3168 bool IsRegularKeywordAttribute = Record.readBool();
3169
3170 AttributeCommonInfo Info(AttrName, ScopeName, AttrRange, ScopeLoc,
3171 AttributeCommonInfo::Kind(ParsedKind),
3172 {AttributeCommonInfo::Syntax(Syntax), SpellingIndex,
3173 IsAlignas, IsRegularKeywordAttribute});
3174
3175#include "clang/Serialization/AttrPCHRead.inc"
3176
3177 assert(New && "Unable to decode attribute?");
3178 return New;
3179}
3180
3181/// Reads attributes from the current stream position.
3183 for (unsigned I = 0, E = readInt(); I != E; ++I)
3184 if (auto *A = readAttr())
3185 Attrs.push_back(A);
3186}
3187
3188//===----------------------------------------------------------------------===//
3189// ASTReader Implementation
3190//===----------------------------------------------------------------------===//
3191
3192/// Note that we have loaded the declaration with the given
3193/// Index.
3194///
3195/// This routine notes that this declaration has already been loaded,
3196/// so that future GetDecl calls will return this declaration rather
3197/// than trying to load a new declaration.
3198inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) {
3199 assert(!DeclsLoaded[Index] && "Decl loaded twice?");
3200 DeclsLoaded[Index] = D;
3201}
3202
3203/// Determine whether the consumer will be interested in seeing
3204/// this declaration (via HandleTopLevelDecl).
3205///
3206/// This routine should return true for anything that might affect
3207/// code generation, e.g., inline function definitions, Objective-C
3208/// declarations with metadata, etc.
3209bool ASTReader::isConsumerInterestedIn(Decl *D) {
3210 // An ObjCMethodDecl is never considered as "interesting" because its
3211 // implementation container always is.
3212
3213 // An ImportDecl or VarDecl imported from a module map module will get
3214 // emitted when we import the relevant module.
3216 auto *M = D->getImportedOwningModule();
3217 if (M && M->Kind == Module::ModuleMapModule &&
3218 getContext().DeclMustBeEmitted(D))
3219 return false;
3220 }
3221
3224 return true;
3227 return !D->getDeclContext()->isFunctionOrMethod();
3228 if (const auto *Var = dyn_cast<VarDecl>(D))
3229 return Var->isFileVarDecl() &&
3230 (Var->isThisDeclarationADefinition() == VarDecl::Definition ||
3231 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Var));
3232 if (const auto *Func = dyn_cast<FunctionDecl>(D))
3233 return Func->doesThisDeclarationHaveABody() || PendingBodies.count(D);
3234
3235 if (auto *ES = D->getASTContext().getExternalSource())
3236 if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
3237 return true;
3238
3239 return false;
3240}
3241
3242/// Get the correct cursor and offset for loading a declaration.
3243ASTReader::RecordLocation ASTReader::DeclCursorForID(GlobalDeclID ID,
3245 GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID);
3246 assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
3247 ModuleFile *M = I->second;
3248 const DeclOffset &DOffs =
3250 Loc = ReadSourceLocation(*M, DOffs.getRawLoc());
3251 return RecordLocation(M, DOffs.getBitOffset(M->DeclsBlockStartOffset));
3252}
3253
3254ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
3255 auto I = GlobalBitOffsetsMap.find(GlobalOffset);
3256
3257 assert(I != GlobalBitOffsetsMap.end() && "Corrupted global bit offsets map");
3258 return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
3259}
3260
3261uint64_t ASTReader::getGlobalBitOffset(ModuleFile &M, uint64_t LocalOffset) {
3262 return LocalOffset + M.GlobalBitOffset;
3263}
3264
3266ASTDeclReader::getOrFakePrimaryClassDefinition(ASTReader &Reader,
3267 CXXRecordDecl *RD) {
3268 // Try to dig out the definition.
3269 auto *DD = RD->DefinitionData;
3270 if (!DD)
3271 DD = RD->getCanonicalDecl()->DefinitionData;
3272
3273 // If there's no definition yet, then DC's definition is added by an update
3274 // record, but we've not yet loaded that update record. In this case, we
3275 // commit to DC being the canonical definition now, and will fix this when
3276 // we load the update record.
3277 if (!DD) {
3278 DD = new (Reader.getContext()) struct CXXRecordDecl::DefinitionData(RD);
3279 RD->setCompleteDefinition(true);
3280 RD->DefinitionData = DD;
3281 RD->getCanonicalDecl()->DefinitionData = DD;
3282
3283 // Track that we did this horrible thing so that we can fix it later.
3284 Reader.PendingFakeDefinitionData.insert(
3285 std::make_pair(DD, ASTReader::PendingFakeDefinitionKind::Fake));
3286 }
3287
3288 return DD->Definition;
3289}
3290
3291/// Find the context in which we should search for previous declarations when
3292/// looking for declarations to merge.
3293DeclContext *ASTDeclReader::getPrimaryContextForMerging(ASTReader &Reader,
3294 DeclContext *DC) {
3295 if (auto *ND = dyn_cast<NamespaceDecl>(DC))
3296 return ND->getOriginalNamespace();
3297
3298 if (auto *RD = dyn_cast<CXXRecordDecl>(DC))
3299 return getOrFakePrimaryClassDefinition(Reader, RD);
3300
3301 if (auto *RD = dyn_cast<RecordDecl>(DC))
3302 return RD->getDefinition();
3303
3304 if (auto *ED = dyn_cast<EnumDecl>(DC))
3305 return ED->getDefinition();
3306
3307 if (auto *OID = dyn_cast<ObjCInterfaceDecl>(DC))
3308 return OID->getDefinition();
3309
3310 // We can see the TU here only if we have no Sema object. It is possible
3311 // we're in clang-repl so we still need to get the primary context.
3312 if (auto *TU = dyn_cast<TranslationUnitDecl>(DC))
3313 return TU->getPrimaryContext();
3314
3315 return nullptr;
3316}
3317
3318ASTDeclReader::FindExistingResult::~FindExistingResult() {
3319 // Record that we had a typedef name for linkage whether or not we merge
3320 // with that declaration.
3321 if (TypedefNameForLinkage) {
3322 DeclContext *DC = New->getDeclContext()->getRedeclContext();
3323 Reader.ImportedTypedefNamesForLinkage.insert(
3324 std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New));
3325 return;
3326 }
3327
3328 if (!AddResult || Existing)
3329 return;
3330
3331 DeclarationName Name = New->getDeclName();
3332 DeclContext *DC = New->getDeclContext()->getRedeclContext();
3334 setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
3335 AnonymousDeclNumber, New);
3336 } else if (DC->isTranslationUnit() &&
3337 !Reader.getContext().getLangOpts().CPlusPlus) {
3338 if (Reader.getIdResolver().tryAddTopLevelDecl(New, Name))
3339 Reader.PendingFakeLookupResults[Name.getAsIdentifierInfo()]
3340 .push_back(New);
3341 } else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
3342 // Add the declaration to its redeclaration context so later merging
3343 // lookups will find it.
3344 MergeDC->makeDeclVisibleInContextImpl(New, /*Internal*/true);
3345 }
3346}
3347
3348/// Find the declaration that should be merged into, given the declaration found
3349/// by name lookup. If we're merging an anonymous declaration within a typedef,
3350/// we need a matching typedef, and we merge with the type inside it.
3352 bool IsTypedefNameForLinkage) {
3353 if (!IsTypedefNameForLinkage)
3354 return Found;
3355
3356 // If we found a typedef declaration that gives a name to some other
3357 // declaration, then we want that inner declaration. Declarations from
3358 // AST files are handled via ImportedTypedefNamesForLinkage.
3359 if (Found->isFromASTFile())
3360 return nullptr;
3361
3362 if (auto *TND = dyn_cast<TypedefNameDecl>(Found))
3363 return TND->getAnonDeclWithTypedefName(/*AnyRedecl*/true);
3364
3365 return nullptr;
3366}
3367
3368/// Find the declaration to use to populate the anonymous declaration table
3369/// for the given lexical DeclContext. We only care about finding local
3370/// definitions of the context; we'll merge imported ones as we go.
3372ASTDeclReader::getPrimaryDCForAnonymousDecl(DeclContext *LexicalDC) {
3373 // For classes, we track the definition as we merge.
3374 if (auto *RD = dyn_cast<CXXRecordDecl>(LexicalDC)) {
3375 auto *DD = RD->getCanonicalDecl()->DefinitionData;
3376 return DD ? DD->Definition : nullptr;
3377 } else if (auto *OID = dyn_cast<ObjCInterfaceDecl>(LexicalDC)) {
3378 return OID->getCanonicalDecl()->getDefinition();
3379 }
3380
3381 // For anything else, walk its merged redeclarations looking for a definition.
3382 // Note that we can't just call getDefinition here because the redeclaration
3383 // chain isn't wired up.
3384 for (auto *D : merged_redecls(cast<Decl>(LexicalDC))) {
3385 if (auto *FD = dyn_cast<FunctionDecl>(D))
3386 if (FD->isThisDeclarationADefinition())
3387 return FD;
3388 if (auto *MD = dyn_cast<ObjCMethodDecl>(D))
3389 if (MD->isThisDeclarationADefinition())
3390 return MD;
3391 if (auto *RD = dyn_cast<RecordDecl>(D))
3393 return RD;
3394 }
3395
3396 // No merged definition yet.
3397 return nullptr;
3398}
3399
3400NamedDecl *ASTDeclReader::getAnonymousDeclForMerging(ASTReader &Reader,
3401 DeclContext *DC,
3402 unsigned Index) {
3403 // If the lexical context has been merged, look into the now-canonical
3404 // definition.
3405 auto *CanonDC = cast<Decl>(DC)->getCanonicalDecl();
3406
3407 // If we've seen this before, return the canonical declaration.
3408 auto &Previous = Reader.AnonymousDeclarationsForMerging[CanonDC];
3409 if (Index < Previous.size() && Previous[Index])
3410 return Previous[Index];
3411
3412 // If this is the first time, but we have parsed a declaration of the context,
3413 // build the anonymous declaration list from the parsed declaration.
3414 auto *PrimaryDC = getPrimaryDCForAnonymousDecl(DC);
3415 if (PrimaryDC && !cast<Decl>(PrimaryDC)->isFromASTFile()) {
3416 numberAnonymousDeclsWithin(PrimaryDC, [&](NamedDecl *ND, unsigned Number) {
3417 if (Previous.size() == Number)
3418 Previous.push_back(cast<NamedDecl>(ND->getCanonicalDecl()));
3419 else
3420 Previous[Number] = cast<NamedDecl>(ND->getCanonicalDecl());
3421 });
3422 }
3423
3424 return Index < Previous.size() ? Previous[Index] : nullptr;
3425}
3426
3427void ASTDeclReader::setAnonymousDeclForMerging(ASTReader &Reader,
3428 DeclContext *DC, unsigned Index,
3429 NamedDecl *D) {
3430 auto *CanonDC = cast<Decl>(DC)->getCanonicalDecl();
3431
3432 auto &Previous = Reader.AnonymousDeclarationsForMerging[CanonDC];
3433 if (Index >= Previous.size())
3434 Previous.resize(Index + 1);
3435 if (!Previous[Index])
3436 Previous[Index] = D;
3437}
3438
3439ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) {
3440 DeclarationName Name = TypedefNameForLinkage ? TypedefNameForLinkage
3441 : D->getDeclName();
3442
3443 if (!Name && !needsAnonymousDeclarationNumber(D)) {
3444 // Don't bother trying to find unnamed declarations that are in
3445 // unmergeable contexts.
3446 FindExistingResult Result(Reader, D, /*Existing=*/nullptr,
3447 AnonymousDeclNumber, TypedefNameForLinkage);
3448 Result.suppress();
3449 return Result;
3450 }
3451
3452 ASTContext &C = Reader.getContext();
3454 if (TypedefNameForLinkage) {
3455 auto It = Reader.ImportedTypedefNamesForLinkage.find(
3456 std::make_pair(DC, TypedefNameForLinkage));
3457 if (It != Reader.ImportedTypedefNamesForLinkage.end())
3458 if (C.isSameEntity(It->second, D))
3459 return FindExistingResult(Reader, D, It->second, AnonymousDeclNumber,
3460 TypedefNameForLinkage);
3461 // Go on to check in other places in case an existing typedef name
3462 // was not imported.
3463 }
3464
3466 // This is an anonymous declaration that we may need to merge. Look it up
3467 // in its context by number.
3468 if (auto *Existing = getAnonymousDeclForMerging(
3469 Reader, D->getLexicalDeclContext(), AnonymousDeclNumber))
3470 if (C.isSameEntity(Existing, D))
3471 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3472 TypedefNameForLinkage);
3473 } else if (DC->isTranslationUnit() &&
3474 !Reader.getContext().getLangOpts().CPlusPlus) {
3475 IdentifierResolver &IdResolver = Reader.getIdResolver();
3476
3477 // Temporarily consider the identifier to be up-to-date. We don't want to
3478 // cause additional lookups here.
3479 class UpToDateIdentifierRAII {
3480 IdentifierInfo *II;
3481 bool WasOutToDate = false;
3482
3483 public:
3484 explicit UpToDateIdentifierRAII(IdentifierInfo *II) : II(II) {
3485 if (II) {
3486 WasOutToDate = II->isOutOfDate();
3487 if (WasOutToDate)
3488 II->setOutOfDate(false);
3489 }
3490 }
3491
3492 ~UpToDateIdentifierRAII() {
3493 if (WasOutToDate)
3494 II->setOutOfDate(true);
3495 }
3496 } UpToDate(Name.getAsIdentifierInfo());
3497
3498 for (IdentifierResolver::iterator I = IdResolver.begin(Name),
3499 IEnd = IdResolver.end();
3500 I != IEnd; ++I) {
3501 if (NamedDecl *Existing = getDeclForMerging(*I, TypedefNameForLinkage))
3502 if (C.isSameEntity(Existing, D))
3503 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3504 TypedefNameForLinkage);
3505 }
3506 } else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
3507 DeclContext::lookup_result R = MergeDC->noload_lookup(Name);
3508 for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; ++I) {
3509 if (NamedDecl *Existing = getDeclForMerging(*I, TypedefNameForLinkage))
3510 if (C.isSameEntity(Existing, D))
3511 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3512 TypedefNameForLinkage);
3513 }
3514 } else {
3515 // Not in a mergeable context.
3516 return FindExistingResult(Reader);
3517 }
3518
3519 // If this declaration is from a merged context, make a note that we need to
3520 // check that the canonical definition of that context contains the decl.
3521 //
3522 // Note that we don't perform ODR checks for decls from the global module
3523 // fragment.
3524 //
3525 // FIXME: We should do something similar if we merge two definitions of the
3526 // same template specialization into the same CXXRecordDecl.
3527 auto MergedDCIt = Reader.MergedDeclContexts.find(D->getLexicalDeclContext());
3528 if (MergedDCIt != Reader.MergedDeclContexts.end() &&
3529 !shouldSkipCheckingODR(D) && MergedDCIt->second == D->getDeclContext())
3530 Reader.PendingOdrMergeChecks.push_back(D);
3531
3532 return FindExistingResult(Reader, D, /*Existing=*/nullptr,
3533 AnonymousDeclNumber, TypedefNameForLinkage);
3534}
3535
3536template<typename DeclT>
3538 return D->RedeclLink.getLatestNotUpdated();
3539}
3540
3542 llvm_unreachable("getMostRecentDecl on non-redeclarable declaration");
3543}
3544
3546 assert(D);
3547
3548 switch (D->getKind()) {
3549#define ABSTRACT_DECL(TYPE)
3550#define DECL(TYPE, BASE) \
3551 case Decl::TYPE: \
3552 return getMostRecentDeclImpl(cast<TYPE##Decl>(D));
3553#include "clang/AST/DeclNodes.inc"
3554 }
3555 llvm_unreachable("unknown decl kind");
3556}
3557
3558Decl *ASTReader::getMostRecentExistingDecl(Decl *D) {
3560}
3561
3563 Decl *Previous) {
3564 InheritableAttr *NewAttr = nullptr;
3565 ASTContext &Context = Reader.getContext();
3566 const auto *IA = Previous->getAttr<MSInheritanceAttr>();
3567
3568 if (IA && !D->hasAttr<MSInheritanceAttr>()) {
3569 NewAttr = cast<InheritableAttr>(IA->clone(Context));
3570 NewAttr->setInherited(true);
3571 D->addAttr(NewAttr);
3572 }
3573
3574 const auto *AA = Previous->getAttr<AvailabilityAttr>();
3575 if (AA && !D->hasAttr<AvailabilityAttr>()) {
3576 NewAttr = AA->clone(Context);
3577 NewAttr->setInherited(true);
3578 D->addAttr(NewAttr);
3579 }
3580}
3581
3582template<typename DeclT>
3585 Decl *Previous, Decl *Canon) {
3586 D->RedeclLink.setPrevious(cast<DeclT>(Previous));
3587 D->First = cast<DeclT>(Previous)->First;
3588}
3589
3590namespace clang {
3591
3592template<>
3595 Decl *Previous, Decl *Canon) {
3596 auto *VD = static_cast<VarDecl *>(D);
3597 auto *PrevVD = cast<VarDecl>(Previous);
3598 D->RedeclLink.setPrevious(PrevVD);
3599 D->First = PrevVD->First;
3600
3601 // We should keep at most one definition on the chain.
3602 // FIXME: Cache the definition once we've found it. Building a chain with
3603 // N definitions currently takes O(N^2) time here.
3604 if (VD->isThisDeclarationADefinition() == VarDecl::Definition) {
3605 for (VarDecl *CurD = PrevVD; CurD; CurD = CurD->getPreviousDecl()) {
3606 if (CurD->isThisDeclarationADefinition() == VarDecl::Definition) {
3607 Reader.mergeDefinitionVisibility(CurD, VD);
3608 VD->demoteThisDefinitionToDeclaration();
3609 break;
3610 }
3611 }
3612 }
3613}
3614
3616 auto *DT = T->getContainedDeducedType();
3617 return DT && !DT->isDeduced();
3618}
3619
3620template<>
3623 Decl *Previous, Decl *Canon) {
3624 auto *FD = static_cast<FunctionDecl *>(D);
3625 auto *PrevFD = cast<FunctionDecl>(Previous);
3626
3627 FD->RedeclLink.setPrevious(PrevFD);
3628 FD->First = PrevFD->First;
3629
3630 // If the previous declaration is an inline function declaration, then this
3631 // declaration is too.
3632 if (PrevFD->isInlined() != FD->isInlined()) {
3633 // FIXME: [dcl.fct.spec]p4:
3634 // If a function with external linkage is declared inline in one
3635 // translation unit, it shall be declared inline in all translation
3636 // units in which it appears.
3637 //
3638 // Be careful of this case:
3639 //
3640 // module A:
3641 // template<typename T> struct X { void f(); };
3642 // template<typename T> inline void X<T>::f() {}
3643 //
3644 // module B instantiates the declaration of X<int>::f
3645 // module C instantiates the definition of X<int>::f
3646 //
3647 // If module B and C are merged, we do not have a violation of this rule.
3648 FD->setImplicitlyInline(true);
3649 }
3650
3651 auto *FPT = FD->getType()->getAs<FunctionProtoType>();
3652 auto *PrevFPT = PrevFD->getType()->getAs<FunctionProtoType>();
3653 if (FPT && PrevFPT) {
3654 // If we need to propagate an exception specification along the redecl
3655 // chain, make a note of that so that we can do so later.
3656 bool IsUnresolved = isUnresolvedExceptionSpec(FPT->getExceptionSpecType());
3657 bool WasUnresolved =
3659 if (IsUnresolved != WasUnresolved)
3660 Reader.PendingExceptionSpecUpdates.insert(
3661 {Canon, IsUnresolved ? PrevFD : FD});
3662
3663 // If we need to propagate a deduced return type along the redecl chain,
3664 // make a note of that so that we can do it later.
3665 bool IsUndeduced = isUndeducedReturnType(FPT->getReturnType());
3666 bool WasUndeduced = isUndeducedReturnType(PrevFPT->getReturnType());
3667 if (IsUndeduced != WasUndeduced)
3668 Reader.PendingDeducedTypeUpdates.insert(
3669 {cast<FunctionDecl>(Canon),
3670 (IsUndeduced ? PrevFPT : FPT)->getReturnType()});
3671 }
3672}
3673
3674} // namespace clang
3675
3677 llvm_unreachable("attachPreviousDecl on non-redeclarable declaration");
3678}
3679
3680/// Inherit the default template argument from \p From to \p To. Returns
3681/// \c false if there is no default template for \p From.
3682template <typename ParmDecl>
3683static bool inheritDefaultTemplateArgument(ASTContext &Context, ParmDecl *From,
3684 Decl *ToD) {
3685 auto *To = cast<ParmDecl>(ToD);
3686 if (!From->hasDefaultArgument())
3687 return false;
3688 To->setInheritedDefaultArgument(Context, From);
3689 return true;
3690}
3691
3693 TemplateDecl *From,
3694 TemplateDecl *To) {
3695 auto *FromTP = From->getTemplateParameters();
3696 auto *ToTP = To->getTemplateParameters();
3697 assert(FromTP->size() == ToTP->size() && "merged mismatched templates?");
3698
3699 for (unsigned I = 0, N = FromTP->size(); I != N; ++I) {
3700 NamedDecl *FromParam = FromTP->getParam(I);
3701 NamedDecl *ToParam = ToTP->getParam(I);
3702
3703 if (auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam))
3704 inheritDefaultTemplateArgument(Context, FTTP, ToParam);
3705 else if (auto *FNTTP = dyn_cast<NonTypeTemplateParmDecl>(FromParam))
3706 inheritDefaultTemplateArgument(Context, FNTTP, ToParam);
3707 else
3709 Context, cast<TemplateTemplateParmDecl>(FromParam), ToParam);
3710 }
3711}
3712
3714 Decl *Previous, Decl *Canon) {
3715 assert(D && Previous);
3716
3717 switch (D->getKind()) {
3718#define ABSTRACT_DECL(TYPE)
3719#define DECL(TYPE, BASE) \
3720 case Decl::TYPE: \
3721 attachPreviousDeclImpl(Reader, cast<TYPE##Decl>(D), Previous, Canon); \
3722 break;
3723#include "clang/AST/DeclNodes.inc"
3724 }
3725
3726 // If the declaration was visible in one module, a redeclaration of it in
3727 // another module remains visible even if it wouldn't be visible by itself.
3728 //
3729 // FIXME: In this case, the declaration should only be visible if a module
3730 // that makes it visible has been imported.
3732 Previous->IdentifierNamespace &
3734
3735 // If the declaration declares a template, it may inherit default arguments
3736 // from the previous declaration.
3737 if (auto *TD = dyn_cast<TemplateDecl>(D))
3739 cast<TemplateDecl>(Previous), TD);
3740
3741 // If any of the declaration in the chain contains an Inheritable attribute,
3742 // it needs to be added to all the declarations in the redeclarable chain.
3743 // FIXME: Only the logic of merging MSInheritableAttr is present, it should
3744 // be extended for all inheritable attributes.
3746}
3747
3748template<typename DeclT>
3750 D->RedeclLink.setLatest(cast<DeclT>(Latest));
3751}
3752
3754 llvm_unreachable("attachLatestDecl on non-redeclarable declaration");
3755}
3756
3758 assert(D && Latest);
3759
3760 switch (D->getKind()) {
3761#define ABSTRACT_DECL(TYPE)
3762#define DECL(TYPE, BASE) \
3763 case Decl::TYPE: \
3764 attachLatestDeclImpl(cast<TYPE##Decl>(D), Latest); \
3765 break;
3766#include "clang/AST/DeclNodes.inc"
3767 }
3768}
3769
3770template<typename DeclT>
3773}
3774
3776 llvm_unreachable("markIncompleteDeclChain on non-redeclarable declaration");
3777}
3778
3779void ASTReader::markIncompleteDeclChain(Decl *D) {
3780 switch (D->getKind()) {
3781#define ABSTRACT_DECL(TYPE)
3782#define DECL(TYPE, BASE) \
3783 case Decl::TYPE: \
3784 ASTDeclReader::markIncompleteDeclChainImpl(cast<TYPE##Decl>(D)); \
3785 break;
3786#include "clang/AST/DeclNodes.inc"
3787 }
3788}
3789
3790/// Read the declaration at the given offset from the AST file.
3791Decl *ASTReader::ReadDeclRecord(GlobalDeclID ID) {
3792 unsigned Index = ID.get() - NUM_PREDEF_DECL_IDS;
3793 SourceLocation DeclLoc;
3794 RecordLocation Loc = DeclCursorForID(ID, DeclLoc);
3795 llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
3796 // Keep track of where we are in the stream, then jump back there
3797 // after reading this declaration.
3798 SavedStreamPosition SavedPosition(DeclsCursor);
3799
3800 ReadingKindTracker ReadingKind(Read_Decl, *this);
3801
3802 // Note that we are loading a declaration record.
3803 Deserializing ADecl(this);
3804
3805 auto Fail = [](const char *what, llvm::Error &&Err) {
3806 llvm::report_fatal_error(Twine("ASTReader::readDeclRecord failed ") + what +
3807 ": " + toString(std::move(Err)));
3808 };
3809
3810 if (llvm::Error JumpFailed = DeclsCursor.JumpToBit(Loc.Offset))
3811 Fail("jumping", std::move(JumpFailed));
3812 ASTRecordReader Record(*this, *Loc.F);
3813 ASTDeclReader Reader(*this, Record, Loc, ID, DeclLoc);
3814 Expected<unsigned> MaybeCode = DeclsCursor.ReadCode();
3815 if (!MaybeCode)
3816 Fail("reading code", MaybeCode.takeError());
3817 unsigned Code = MaybeCode.get();
3818
3819 ASTContext &Context = getContext();
3820 Decl *D = nullptr;
3821 Expected<unsigned> MaybeDeclCode = Record.readRecord(DeclsCursor, Code);
3822 if (!MaybeDeclCode)
3823 llvm::report_fatal_error(
3824 Twine("ASTReader::readDeclRecord failed reading decl code: ") +
3825 toString(MaybeDeclCode.takeError()));
3826
3827 switch ((DeclCode)MaybeDeclCode.get()) {
3830 llvm_unreachable("Record cannot be de-serialized with readDeclRecord");
3831 case DECL_TYPEDEF:
3832 D = TypedefDecl::CreateDeserialized(Context, ID);
3833 break;
3834 case DECL_TYPEALIAS:
3835 D = TypeAliasDecl::CreateDeserialized(Context, ID);
3836 break;
3837 case DECL_ENUM:
3838 D = EnumDecl::CreateDeserialized(Context, ID);
3839 break;
3840 case DECL_RECORD:
3841 D = RecordDecl::CreateDeserialized(Context, ID);
3842 break;
3843 case DECL_ENUM_CONSTANT:
3844 D = EnumConstantDecl::CreateDeserialized(Context, ID);
3845 break;
3846 case DECL_FUNCTION:
3847 D = FunctionDecl::CreateDeserialized(Context, ID);
3848 break;
3849 case DECL_LINKAGE_SPEC:
3850 D = LinkageSpecDecl::CreateDeserialized(Context, ID);
3851 break;
3852 case DECL_EXPORT:
3853 D = ExportDecl::CreateDeserialized(Context, ID);
3854 break;
3855 case DECL_LABEL:
3856 D = LabelDecl::CreateDeserialized(Context, ID);
3857 break;
3858 case DECL_NAMESPACE:
3859 D = NamespaceDecl::CreateDeserialized(Context, ID);
3860 break;
3863 break;
3864 case DECL_USING:
3865 D = UsingDecl::CreateDeserialized(Context, ID);
3866 break;
3867 case DECL_USING_PACK:
3868 D = UsingPackDecl::CreateDeserialized(Context, ID, Record.readInt());
3869 break;
3870 case DECL_USING_SHADOW:
3871 D = UsingShadowDecl::CreateDeserialized(Context, ID);
3872 break;
3873 case DECL_USING_ENUM:
3874 D = UsingEnumDecl::CreateDeserialized(Context, ID);
3875 break;
3878 break;
3881 break;
3884 break;
3887 break;
3890 break;
3891 case DECL_CXX_RECORD:
3892 D = CXXRecordDecl::CreateDeserialized(Context, ID);
3893 break;
3896 break;
3897 case DECL_CXX_METHOD:
3898 D = CXXMethodDecl::CreateDeserialized(Context, ID);
3899 break;
3901 D = CXXConstructorDecl::CreateDeserialized(Context, ID, Record.readInt());
3902 break;
3905 break;
3908 break;
3909 case DECL_ACCESS_SPEC:
3910 D = AccessSpecDecl::CreateDeserialized(Context, ID);
3911 break;
3912 case DECL_FRIEND:
3913 D = FriendDecl::CreateDeserialized(Context, ID, Record.readInt());
3914 break;
3917 break;
3920 break;
3923 break;
3926 break;
3927 case DECL_VAR_TEMPLATE:
3928 D = VarTemplateDecl::CreateDeserialized(Context, ID);
3929 break;
3932 break;
3935 break;
3938 break;
3940 bool HasTypeConstraint = Record.readInt();
3942 HasTypeConstraint);
3943 break;
3944 }
3946 bool HasTypeConstraint = Record.readInt();
3948 HasTypeConstraint);
3949 break;
3950 }
3952 bool HasTypeConstraint = Record.readInt();
3954 Context, ID, Record.readInt(), HasTypeConstraint);
3955 break;
3956 }
3959 break;
3962 Record.readInt());
3963 break;
3966 break;
3967 case DECL_CONCEPT:
3968 D = ConceptDecl::CreateDeserialized(Context, ID);
3969 break;
3972 break;
3973 case DECL_STATIC_ASSERT:
3974 D = StaticAssertDecl::CreateDeserialized(Context, ID);
3975 break;
3976 case DECL_OBJC_METHOD:
3977 D = ObjCMethodDecl::CreateDeserialized(Context, ID);
3978 break;
3981 break;
3982 case DECL_OBJC_IVAR:
3983 D = ObjCIvarDecl::CreateDeserialized(Context, ID);
3984 break;
3985 case DECL_OBJC_PROTOCOL:
3986 D = ObjCProtocolDecl::CreateDeserialized(Context, ID);
3987 break;
3990 break;
3991 case DECL_OBJC_CATEGORY:
3992 D = ObjCCategoryDecl::CreateDeserialized(Context, ID);
3993 break;
3996 break;
3999 break;
4002 break;
4003 case DECL_OBJC_PROPERTY:
4004 D = ObjCPropertyDecl::CreateDeserialized(Context, ID);
4005 break;
4008 break;
4009 case DECL_FIELD:
4010 D = FieldDecl::CreateDeserialized(Context, ID);
4011 break;
4012 case DECL_INDIRECTFIELD:
4014 break;
4015 case DECL_VAR:
4016 D = VarDecl::CreateDeserialized(Context, ID);
4017 break;
4020 break;
4021 case DECL_PARM_VAR:
4022 D = ParmVarDecl::CreateDeserialized(Context, ID);
4023 break;
4024 case DECL_DECOMPOSITION:
4025 D = DecompositionDecl::CreateDeserialized(Context, ID, Record.readInt());
4026 break;
4027 case DECL_BINDING:
4028 D = BindingDecl::CreateDeserialized(Context, ID);
4029 break;
4031 D = FileScopeAsmDecl::CreateDeserialized(Context, ID);
4032 break;
4034 D = TopLevelStmtDecl::CreateDeserialized(Context, ID);
4035 break;
4036 case DECL_BLOCK:
4037 D = BlockDecl::CreateDeserialized(Context, ID);
4038 break;
4039 case DECL_MS_PROPERTY:
4040 D = MSPropertyDecl::CreateDeserialized(Context, ID);
4041 break;
4042 case DECL_MS_GUID:
4043 D = MSGuidDecl::CreateDeserialized(Context, ID);
4044 break;
4046 D = UnnamedGlobalConstantDecl::CreateDeserialized(Context, ID);
4047 break;
4049 D = TemplateParamObjectDecl::CreateDeserialized(Context, ID);
4050 break;
4051 case DECL_CAPTURED:
4052 D = CapturedDecl::CreateDeserialized(Context, ID, Record.readInt());
4053 break;
4055 Error("attempt to read a C++ base-specifier record as a declaration");
4056 return nullptr;
4058 Error("attempt to read a C++ ctor initializer record as a declaration");
4059 return nullptr;
4060 case DECL_IMPORT:
4061 // Note: last entry of the ImportDecl record is the number of stored source
4062 // locations.
4063 D = ImportDecl::CreateDeserialized(Context, ID, Record.back());
4064 break;
4066 Record.skipInts(1);
4067 unsigned NumChildren = Record.readInt();
4068 Record.skipInts(1);
4069 D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, NumChildren);
4070 break;
4071 }
4072 case DECL_OMP_ALLOCATE: {
4073 unsigned NumClauses = Record.readInt();
4074 unsigned NumVars = Record.readInt();
4075 Record.skipInts(1);
4076 D = OMPAllocateDecl::CreateDeserialized(Context, ID, NumVars, NumClauses);
4077 break;
4078 }
4079 case DECL_OMP_REQUIRES: {
4080 unsigned NumClauses = Record.readInt();
4081 Record.skipInts(2);
4082 D = OMPRequiresDecl::CreateDeserialized(Context, ID, NumClauses);
4083 break;
4084 }
4087 break;
4089 unsigned NumClauses = Record.readInt();
4090 Record.skipInts(2);
4091 D = OMPDeclareMapperDecl::CreateDeserialized(Context, ID, NumClauses);
4092 break;
4093 }
4096 break;
4098 D = PragmaCommentDecl::CreateDeserialized(Context, ID, Record.readInt());
4099 break;
4102 Record.readInt());
4103 break;
4104 case DECL_EMPTY:
4105 D = EmptyDecl::CreateDeserialized(Context, ID);
4106 break;
4109 break;
4112 break;
4113 case DECL_HLSL_BUFFER:
4114 D = HLSLBufferDecl::CreateDeserialized(Context, ID);
4115 break;
4118 Record.readInt());
4119 break;
4120 }
4121
4122 assert(D && "Unknown declaration reading AST file");
4123 LoadedDecl(Index, D);
4124 // Set the DeclContext before doing any deserialization, to make sure internal
4125 // calls to Decl::getASTContext() by Decl's methods will find the
4126 // TranslationUnitDecl without crashing.
4128 Reader.Visit(D);
4129
4130 // If this declaration is also a declaration context, get the
4131 // offsets for its tables of lexical and visible declarations.
4132 if (auto *DC = dyn_cast<DeclContext>(D)) {
4133 std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC);
4134
4135 // Get the lexical and visible block for the delayed namespace.
4136 // It is sufficient to judge if ID is in DelayedNamespaceOffsetMap.
4137 // But it may be more efficient to filter the other cases.
4138 if (!Offsets.first && !Offsets.second && isa<NamespaceDecl>(D))
4139 if (auto Iter = DelayedNamespaceOffsetMap.find(ID);
4140 Iter != DelayedNamespaceOffsetMap.end())
4141 Offsets = Iter->second;
4142
4143 if (Offsets.first &&
4144 ReadLexicalDeclContextStorage(*Loc.F, DeclsCursor, Offsets.first, DC))
4145 return nullptr;
4146 if (Offsets.second &&
4147 ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID))
4148 return nullptr;
4149 }
4150 assert(Record.getIdx() == Record.size());
4151
4152 // Load any relevant update records.
4153 PendingUpdateRecords.push_back(
4154 PendingUpdateRecord(ID, D, /*JustLoaded=*/true));
4155
4156 // Load the categories after recursive loading is finished.
4157 if (auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
4158 // If we already have a definition when deserializing the ObjCInterfaceDecl,
4159 // we put the Decl in PendingDefinitions so we can pull the categories here.
4160 if (Class->isThisDeclarationADefinition() ||
4161 PendingDefinitions.count(Class))
4162 loadObjCCategories(ID, Class);
4163
4164 // If we have deserialized a declaration that has a definition the
4165 // AST consumer might need to know about, queue it.
4166 // We don't pass it to the consumer immediately because we may be in recursive
4167 // loading, and some declarations may still be initializing.
4168 PotentiallyInterestingDecls.push_back(D);
4169
4170 return D;
4171}
4172
4173void ASTReader::PassInterestingDeclsToConsumer() {
4174 assert(Consumer);
4175
4176 if (PassingDeclsToConsumer)
4177 return;
4178
4179 // Guard variable to avoid recursively redoing the process of passing
4180 // decls to consumer.
4181 SaveAndRestore GuardPassingDeclsToConsumer(PassingDeclsToConsumer, true);
4182
4183 // Ensure that we've loaded all potentially-interesting declarations
4184 // that need to be eagerly loaded.
4185 for (auto ID : EagerlyDeserializedDecls)
4186 GetDecl(ID);
4187 EagerlyDeserializedDecls.clear();
4188
4189 auto ConsumingPotentialInterestingDecls = [this]() {
4190 while (!PotentiallyInterestingDecls.empty()) {
4191 Decl *D = PotentiallyInterestingDecls.front();
4192 PotentiallyInterestingDecls.pop_front();
4193 if (isConsumerInterestedIn(D))
4194 PassInterestingDeclToConsumer(D);
4195 }
4196 };
4197 std::deque<Decl *> MaybeInterestingDecls =
4198 std::move(PotentiallyInterestingDecls);
4199 assert(PotentiallyInterestingDecls.empty());
4200 while (!MaybeInterestingDecls.empty()) {
4201 Decl *D = MaybeInterestingDecls.front();
4202 MaybeInterestingDecls.pop_front();
4203 // Since we load the variable's initializers lazily, it'd be problematic
4204 // if the initializers dependent on each other. So here we try to load the
4205 // initializers of static variables to make sure they are passed to code
4206 // generator by order. If we read anything interesting, we would consume
4207 // that before emitting the current declaration.
4208 if (auto *VD = dyn_cast<VarDecl>(D);
4209 VD && VD->isFileVarDecl() && !VD->isExternallyVisible())
4210 VD->getInit();
4211 ConsumingPotentialInterestingDecls();
4212 if (isConsumerInterestedIn(D))
4213 PassInterestingDeclToConsumer(D);
4214 }
4215
4216 // If we add any new potential interesting decl in the last call, consume it.
4217 ConsumingPotentialInterestingDecls();
4218}
4219
4220void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
4221 // The declaration may have been modified by files later in the chain.
4222 // If this is the case, read the record containing the updates from each file
4223 // and pass it to ASTDeclReader to make the modifications.
4224 GlobalDeclID ID = Record.ID;
4225 Decl *D = Record.D;
4226 ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
4227 DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
4228
4229 SmallVector<GlobalDeclID, 8> PendingLazySpecializationIDs;
4230
4231 if (UpdI != DeclUpdateOffsets.end()) {
4232 auto UpdateOffsets = std::move(UpdI->second);
4233 DeclUpdateOffsets.erase(UpdI);
4234
4235 // Check if this decl was interesting to the consumer. If we just loaded
4236 // the declaration, then we know it was interesting and we skip the call
4237 // to isConsumerInterestedIn because it is unsafe to call in the
4238 // current ASTReader state.
4239 bool WasInteresting = Record.JustLoaded || isConsumerInterestedIn(D);
4240 for (auto &FileAndOffset : UpdateOffsets) {
4241 ModuleFile *F = FileAndOffset.first;
4242 uint64_t Offset = FileAndOffset.second;
4243 llvm::BitstreamCursor &Cursor = F->DeclsCursor;
4244 SavedStreamPosition SavedPosition(Cursor);
4245 if (llvm::Error JumpFailed = Cursor.JumpToBit(Offset))
4246 // FIXME don't do a fatal error.
4247 llvm::report_fatal_error(
4248 Twine("ASTReader::loadDeclUpdateRecords failed jumping: ") +
4249 toString(std::move(JumpFailed)));
4250 Expected<unsigned> MaybeCode = Cursor.ReadCode();
4251 if (!MaybeCode)
4252 llvm::report_fatal_error(
4253 Twine("ASTReader::loadDeclUpdateRecords failed reading code: ") +
4254 toString(MaybeCode.takeError()));
4255 unsigned Code = MaybeCode.get();
4256 ASTRecordReader Record(*this, *F);
4257 if (Expected<unsigned> MaybeRecCode = Record.readRecord(Cursor, Code))
4258 assert(MaybeRecCode.get() == DECL_UPDATES &&
4259 "Expected DECL_UPDATES record!");
4260 else
4261 llvm::report_fatal_error(
4262 Twine("ASTReader::loadDeclUpdateRecords failed reading rec code: ") +
4263 toString(MaybeCode.takeError()));
4264
4265 ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
4266 SourceLocation());
4267 Reader.UpdateDecl(D, PendingLazySpecializationIDs);
4268
4269 // We might have made this declaration interesting. If so, remember that
4270 // we need to hand it off to the consumer.
4271 if (!WasInteresting && isConsumerInterestedIn(D)) {
4272 PotentiallyInterestingDecls.push_back(D);
4273 WasInteresting = true;
4274 }
4275 }
4276 }
4277 // Add the lazy specializations to the template.
4278 assert((PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) ||
4279 isa<FunctionTemplateDecl, VarTemplateDecl>(D)) &&
4280 "Must not have pending specializations");
4281 if (auto *CTD = dyn_cast<ClassTemplateDecl>(D))
4282 ASTDeclReader::AddLazySpecializations(CTD, PendingLazySpecializationIDs);
4283 else if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
4284 ASTDeclReader::AddLazySpecializations(FTD, PendingLazySpecializationIDs);
4285 else if (auto *VTD = dyn_cast<VarTemplateDecl>(D))
4286 ASTDeclReader::AddLazySpecializations(VTD, PendingLazySpecializationIDs);
4287 PendingLazySpecializationIDs.clear();
4288
4289 // Load the pending visible updates for this decl context, if it has any.
4290 auto I = PendingVisibleUpdates.find(ID);
4291 if (I != PendingVisibleUpdates.end()) {
4292 auto VisibleUpdates = std::move(I->second);
4293 PendingVisibleUpdates.erase(I);
4294
4295 auto *DC = cast<DeclContext>(D)->getPrimaryContext();
4296 for (const auto &Update : VisibleUpdates)
4297 Lookups[DC].Table.add(
4298 Update.Mod, Update.Data,
4301 }
4302}
4303
4304void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) {
4305 // Attach FirstLocal to the end of the decl chain.
4306 Decl *CanonDecl = FirstLocal->getCanonicalDecl();
4307 if (FirstLocal != CanonDecl) {
4308 Decl *PrevMostRecent = ASTDeclReader::getMostRecentDecl(CanonDecl);
4310 *this, FirstLocal, PrevMostRecent ? PrevMostRecent : CanonDecl,
4311 CanonDecl);
4312 }
4313
4314 if (!LocalOffset) {
4315 ASTDeclReader::attachLatestDecl(CanonDecl, FirstLocal);
4316 return;
4317 }
4318
4319 // Load the list of other redeclarations from this module file.
4320 ModuleFile *M = getOwningModuleFile(FirstLocal);
4321 assert(M && "imported decl from no module file");
4322
4323 llvm::BitstreamCursor &Cursor = M->DeclsCursor;
4324 SavedStreamPosition SavedPosition(Cursor);
4325 if (llvm::Error JumpFailed = Cursor.JumpToBit(LocalOffset))
4326 llvm::report_fatal_error(
4327 Twine("ASTReader::loadPendingDeclChain failed jumping: ") +
4328 toString(std::move(JumpFailed)));
4329
4331 Expected<unsigned> MaybeCode = Cursor.ReadCode();
4332 if (!MaybeCode)
4333 llvm::report_fatal_error(
4334 Twine("ASTReader::loadPendingDeclChain failed reading code: ") +
4335 toString(MaybeCode.takeError()));
4336 unsigned Code = MaybeCode.get();
4337 if (Expected<unsigned> MaybeRecCode = Cursor.readRecord(Code, Record))
4338 assert(MaybeRecCode.get() == LOCAL_REDECLARATIONS &&
4339 "expected LOCAL_REDECLARATIONS record!");
4340 else
4341 llvm::report_fatal_error(
4342 Twine("ASTReader::loadPendingDeclChain failed reading rec code: ") +
4343 toString(MaybeCode.takeError()));
4344
4345 // FIXME: We have several different dispatches on decl kind here; maybe
4346 // we should instead generate one loop per kind and dispatch up-front?
4347 Decl *MostRecent = FirstLocal;
4348 for (unsigned I = 0, N = Record.size(); I != N; ++I) {
4349 auto *D = GetLocalDecl(*M, LocalDeclID(Record[N - I - 1]));
4350 ASTDeclReader::attachPreviousDecl(*this, D, MostRecent, CanonDecl);
4351 MostRecent = D;
4352 }
4353 ASTDeclReader::attachLatestDecl(CanonDecl, MostRecent);
4354}
4355
4356namespace {
4357
4358 /// Given an ObjC interface, goes through the modules and links to the
4359 /// interface all the categories for it.
4360 class ObjCCategoriesVisitor {
4361 ASTReader &Reader;
4363 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized;
4364 ObjCCategoryDecl *Tail = nullptr;
4365 llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap;
4366 GlobalDeclID InterfaceID;
4367 unsigned PreviousGeneration;
4368
4369 void add(ObjCCategoryDecl *Cat) {
4370 // Only process each category once.
4371 if (!Deserialized.erase(Cat))
4372 return;
4373
4374 // Check for duplicate categories.
4375 if (Cat->getDeclName()) {
4376 ObjCCategoryDecl *&Existing = NameCategoryMap[Cat->getDeclName()];
4377 if (Existing && Reader.getOwningModuleFile(Existing) !=
4378 Reader.getOwningModuleFile(Cat)) {
4379 llvm::DenseSet<std::pair<Decl *, Decl *>> NonEquivalentDecls;
4381 Cat->getASTContext(), Existing->getASTContext(),
4382 NonEquivalentDecls, StructuralEquivalenceKind::Default,
4383 /*StrictTypeSpelling =*/false,
4384 /*Complain =*/false,
4385 /*ErrorOnTagTypeMismatch =*/true);
4386 if (!Ctx.IsEquivalent(Cat, Existing)) {
4387 // Warn only if the categories with the same name are different.
4388 Reader.Diag(Cat->getLocation(), diag::warn_dup_category_def)
4389 << Interface->getDeclName() << Cat->getDeclName();
4390 Reader.Diag(Existing->getLocation(),
4391 diag::note_previous_definition);
4392 }
4393 } else if (!Existing) {
4394 // Record this category.
4395 Existing = Cat;
4396 }
4397 }
4398
4399 // Add this category to the end of the chain.
4400 if (Tail)
4402 else
4403 Interface->setCategoryListRaw(Cat);
4404 Tail = Cat;
4405 }
4406
4407 public:
4408 ObjCCategoriesVisitor(
4410 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
4411 GlobalDeclID InterfaceID, unsigned PreviousGeneration)
4412 : Reader(Reader), Interface(Interface), Deserialized(Deserialized),
4413 InterfaceID(InterfaceID), PreviousGeneration(PreviousGeneration) {
4414 // Populate the name -> category map with the set of known categories.
4415 for (auto *Cat : Interface->known_categories()) {
4416 if (Cat->getDeclName())
4417 NameCategoryMap[Cat->getDeclName()] = Cat;
4418
4419 // Keep track of the tail of the category list.
4420 Tail = Cat;
4421 }
4422 }
4423
4424 bool operator()(ModuleFile &M) {
4425 // If we've loaded all of the category information we care about from
4426 // this module file, we're done.
4427 if (M.Generation <= PreviousGeneration)
4428 return true;
4429
4430 // Map global ID of the definition down to the local ID used in this
4431 // module file. If there is no such mapping, we'll find nothing here
4432 // (or in any module it imports).
4433 LocalDeclID LocalID =
4434 Reader.mapGlobalIDToModuleFileGlobalID(M, InterfaceID);
4435 if (LocalID.isInvalid())
4436 return true;
4437
4438 // Perform a binary search to find the local redeclarations for this
4439 // declaration (if any).
4440 const ObjCCategoriesInfo Compare = { LocalID, 0 };
4441 const ObjCCategoriesInfo *Result
4442 = std::lower_bound(M.ObjCCategoriesMap,
4444 Compare);
4445 if (Result == M.ObjCCategoriesMap + M.LocalNumObjCCategoriesInMap ||
4446 Result->DefinitionID != LocalID) {
4447 // We didn't find anything. If the class definition is in this module
4448 // file, then the module files it depends on cannot have any categories,
4449 // so suppress further lookup.
4450 return Reader.isDeclIDFromModule(InterfaceID, M);
4451 }
4452
4453 // We found something. Dig out all of the categories.
4454 unsigned Offset = Result->Offset;
4455 unsigned N = M.ObjCCategories[Offset];
4456 M.ObjCCategories[Offset++] = 0; // Don't try to deserialize again
4457 for (unsigned I = 0; I != N; ++I)
4458 add(cast_or_null<ObjCCategoryDecl>(
4459 Reader.GetLocalDecl(M, LocalDeclID(M.ObjCCategories[Offset++]))));
4460 return true;
4461 }
4462 };
4463
4464} // namespace
4465
4466void ASTReader::loadObjCCategories(GlobalDeclID ID, ObjCInterfaceDecl *D,
4467 unsigned PreviousGeneration) {
4468 ObjCCategoriesVisitor Visitor(*this, D, CategoriesDeserialized, ID,
4469 PreviousGeneration);
4470 ModuleMgr.visit(Visitor);
4471}
4472
4473template<typename DeclT, typename Fn>
4474static void forAllLaterRedecls(DeclT *D, Fn F) {
4475 F(D);
4476
4477 // Check whether we've already merged D into its redeclaration chain.
4478 // MostRecent may or may not be nullptr if D has not been merged. If
4479 // not, walk the merged redecl chain and see if it's there.
4480 auto *MostRecent = D->getMostRecentDecl();
4481 bool Found = false;
4482 for (auto *Redecl = MostRecent; Redecl && !Found;
4483 Redecl = Redecl->getPreviousDecl())
4484 Found = (Redecl == D);
4485
4486 // If this declaration is merged, apply the functor to all later decls.
4487 if (Found) {
4488 for (auto *Redecl = MostRecent; Redecl != D;
4489 Redecl = Redecl->getPreviousDecl())
4490 F(Redecl);
4491 }
4492}
4493
4495 Decl *D,
4496 llvm::SmallVectorImpl<GlobalDeclID> &PendingLazySpecializationIDs) {
4497 while (Record.getIdx() < Record.size()) {
4498 switch ((DeclUpdateKind)Record.readInt()) {
4500 auto *RD = cast<CXXRecordDecl>(D);
4501 Decl *MD = Record.readDecl();
4502 assert(MD && "couldn't read decl from update record");
4503 Reader.PendingAddedClassMembers.push_back({RD, MD});
4504 break;
4505 }
4506
4508 // It will be added to the template's lazy specialization set.
4509 PendingLazySpecializationIDs.push_back(readDeclID());
4510 break;
4511
4513 auto *Anon = readDeclAs<NamespaceDecl>();
4514
4515 // Each module has its own anonymous namespace, which is disjoint from
4516 // any other module's anonymous namespaces, so don't attach the anonymous
4517 // namespace at all.
4518 if (!Record.isModule()) {
4519 if (auto *TU = dyn_cast<TranslationUnitDecl>(D))
4520 TU->setAnonymousNamespace(Anon);
4521 else
4522 cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
4523 }
4524 break;
4525 }
4526
4528 auto *VD = cast<VarDecl>(D);
4529 VD->NonParmVarDeclBits.IsInline = Record.readInt();
4530 VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
4531 ReadVarDeclInit(VD);
4532 break;
4533 }
4534
4536 SourceLocation POI = Record.readSourceLocation();
4537 if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D)) {
4538 VTSD->setPointOfInstantiation(POI);
4539 } else if (auto *VD = dyn_cast<VarDecl>(D)) {
4540 MemberSpecializationInfo *MSInfo = VD->getMemberSpecializationInfo();
4541 assert(MSInfo && "No member specialization information");
4542 MSInfo->setPointOfInstantiation(POI);
4543 } else {
4544 auto *FD = cast<FunctionDecl>(D);
4545 if (auto *FTSInfo = FD->TemplateOrSpecialization
4547 FTSInfo->setPointOfInstantiation(POI);
4548 else
4549 FD->TemplateOrSpecialization.get<MemberSpecializationInfo *>()
4550 ->setPointOfInstantiation(POI);
4551 }
4552 break;
4553 }
4554
4556 auto *Param = cast<ParmVarDecl>(D);
4557
4558 // We have to read the default argument regardless of whether we use it
4559 // so that hypothetical further update records aren't messed up.
4560 // TODO: Add a function to skip over the next expr record.
4561 auto *DefaultArg = Record.readExpr();
4562
4563 // Only apply the update if the parameter still has an uninstantiated
4564 // default argument.
4565 if (Param->hasUninstantiatedDefaultArg())
4566 Param->setDefaultArg(DefaultArg);
4567 break;
4568 }
4569
4571 auto *FD = cast<FieldDecl>(D);
4572 auto *DefaultInit = Record.readExpr();
4573
4574 // Only apply the update if the field still has an uninstantiated
4575 // default member initializer.
4576 if (FD->hasInClassInitializer() && !FD->hasNonNullInClassInitializer()) {
4577 if (DefaultInit)
4578 FD->setInClassInitializer(DefaultInit);
4579 else
4580 // Instantiation failed. We can get here if we serialized an AST for
4581 // an invalid program.
4582 FD->removeInClassInitializer();
4583 }
4584 break;
4585 }
4586
4588 auto *FD = cast<FunctionDecl>(D);
4589 if (Reader.PendingBodies[FD]) {
4590 // FIXME: Maybe check for ODR violations.
4591 // It's safe to stop now because this update record is always last.
4592 return;
4593 }
4594
4595 if (Record.readInt()) {
4596 // Maintain AST consistency: any later redeclarations of this function
4597 // are inline if this one is. (We might have merged another declaration
4598 // into this one.)
4599 forAllLaterRedecls(FD, [](FunctionDecl *FD) {
4600 FD->setImplicitlyInline();
4601 });
4602 }
4603 FD->setInnerLocStart(readSourceLocation());
4605 assert(Record.getIdx() == Record.size() && "lazy body must be last");
4606 break;
4607 }
4608
4610 auto *RD = cast<CXXRecordDecl>(D);
4611 auto *OldDD = RD->getCanonicalDecl()->DefinitionData;
4612 bool HadRealDefinition =
4613 OldDD && (OldDD->Definition != RD ||
4614 !Reader.PendingFakeDefinitionData.count(OldDD));
4615 RD->setParamDestroyedInCallee(Record.readInt());
4617 static_cast<RecordArgPassingKind>(Record.readInt()));
4618 ReadCXXRecordDefinition(RD, /*Update*/true);
4619
4620 // Visible update is handled separately.
4621 uint64_t LexicalOffset = ReadLocalOffset();
4622 if (!HadRealDefinition && LexicalOffset) {
4623 Record.readLexicalDeclContextStorage(LexicalOffset, RD);
4624 Reader.PendingFakeDefinitionData.erase(OldDD);
4625 }
4626
4627 auto TSK = (TemplateSpecializationKind)Record.readInt();
4628 SourceLocation POI = readSourceLocation();
4629 if (MemberSpecializationInfo *MSInfo =
4631 MSInfo->setTemplateSpecializationKind(TSK);
4632 MSInfo->setPointOfInstantiation(POI);
4633 } else {
4634 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
4635 Spec->setTemplateSpecializationKind(TSK);
4636 Spec->setPointOfInstantiation(POI);
4637
4638 if (Record.readInt()) {
4639 auto *PartialSpec =
4640 readDeclAs<ClassTemplatePartialSpecializationDecl>();
4642 Record.readTemplateArgumentList(TemplArgs);
4643 auto *TemplArgList = TemplateArgumentList::CreateCopy(
4644 Reader.getContext(), TemplArgs);
4645
4646 // FIXME: If we already have a partial specialization set,
4647 // check that it matches.
4648 if (!Spec->getSpecializedTemplateOrPartial()
4650 Spec->setInstantiationOf(PartialSpec, TemplArgList);
4651 }
4652 }
4653
4654 RD->setTagKind(static_cast<TagTypeKind>(Record.readInt()));
4655 RD->setLocation(readSourceLocation());
4656 RD->setLocStart(readSourceLocation());
4657 RD->setBraceRange(readSourceRange());
4658
4659 if (Record.readInt()) {
4660 AttrVec Attrs;
4661 Record.readAttributes(Attrs);
4662 // If the declaration already has attributes, we assume that some other
4663 // AST file already loaded them.
4664 if (!D->hasAttrs())
4665 D->setAttrsImpl(Attrs, Reader.getContext());
4666 }
4667 break;
4668 }
4669
4671 // Set the 'operator delete' directly to avoid emitting another update
4672 // record.
4673 auto *Del = readDeclAs<FunctionDecl>();
4674 auto *First = cast<CXXDestructorDecl>(D->getCanonicalDecl());
4675 auto *ThisArg = Record.readExpr();
4676 // FIXME: Check consistency if we have an old and new operator delete.
4677 if (!First->OperatorDelete) {
4678 First->OperatorDelete = Del;
4679 First->OperatorDeleteThisArg = ThisArg;
4680 }
4681 break;
4682 }
4683
4685 SmallVector<QualType, 8> ExceptionStorage;
4686 auto ESI = Record.readExceptionSpecInfo(ExceptionStorage);
4687
4688 // Update this declaration's exception specification, if needed.
4689 auto *FD = cast<FunctionDecl>(D);
4690 auto *FPT = FD->getType()->castAs<FunctionProtoType>();
4691 // FIXME: If the exception specification is already present, check that it
4692 // matches.
4693 if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType())) {
4694 FD->setType(Reader.getContext().getFunctionType(
4695 FPT->getReturnType(), FPT->getParamTypes(),
4696 FPT->getExtProtoInfo().withExceptionSpec(ESI)));
4697
4698 // When we get to the end of deserializing, see if there are other decls
4699 // that we need to propagate this exception specification onto.
4700 Reader.PendingExceptionSpecUpdates.insert(
4701 std::make_pair(FD->getCanonicalDecl(), FD));
4702 }
4703 break;
4704 }
4705
4707 auto *FD = cast<FunctionDecl>(D);
4708 QualType DeducedResultType = Record.readType();
4709 Reader.PendingDeducedTypeUpdates.insert(
4710 {FD->getCanonicalDecl(), DeducedResultType});
4711 break;
4712 }
4713
4715 // Maintain AST consistency: any later redeclarations are used too.
4716 D->markUsed(Reader.getContext());
4717 break;
4718
4720 Reader.getContext().setManglingNumber(cast<NamedDecl>(D),
4721 Record.readInt());
4722 break;
4723
4725 Reader.getContext().setStaticLocalNumber(cast<VarDecl>(D),
4726 Record.readInt());
4727 break;
4728
4730 D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(Reader.getContext(),
4731 readSourceRange()));
4732 break;
4733
4735 auto AllocatorKind =
4736 static_cast<OMPAllocateDeclAttr::AllocatorTypeTy>(Record.readInt());
4737 Expr *Allocator = Record.readExpr();
4738 Expr *Alignment = Record.readExpr();
4739 SourceRange SR = readSourceRange();
4740 D->addAttr(OMPAllocateDeclAttr::CreateImplicit(
4741 Reader.getContext(), AllocatorKind, Allocator, Alignment, SR));
4742 break;
4743 }
4744
4745 case UPD_DECL_EXPORTED: {
4746 unsigned SubmoduleID = readSubmoduleID();
4747 auto *Exported = cast<NamedDecl>(D);
4748 Module *Owner = SubmoduleID ? Reader.getSubmodule(SubmoduleID) : nullptr;
4749 Reader.getContext().mergeDefinitionIntoModule(Exported, Owner);
4750 Reader.PendingMergedDefinitionsToDeduplicate.insert(Exported);
4751 break;
4752 }
4753
4755 auto MapType = Record.readEnum<OMPDeclareTargetDeclAttr::MapTypeTy>();
4756 auto DevType = Record.readEnum<OMPDeclareTargetDeclAttr::DevTypeTy>();
4757 Expr *IndirectE = Record.readExpr();
4758 bool Indirect = Record.readBool();
4759 unsigned Level = Record.readInt();
4760 D->addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(
4761 Reader.getContext(), MapType, DevType, IndirectE, Indirect, Level,
4762 readSourceRange()));
4763 break;
4764 }
4765
4767 AttrVec Attrs;
4768 Record.readAttributes(Attrs);
4769 assert(Attrs.size() == 1);
4770 D->addAttr(Attrs[0]);
4771 break;
4772 }
4773 }
4774}
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
#define V(N, I)
Definition: ASTContext.h:3285
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.
SourceLocation Loc
Definition: SemaObjC.cpp:755
bool Indirect
Definition: SemaObjC.cpp:756
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:1569
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:3112
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Definition: ASTContext.h:1189
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:7659
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
Definition: ASTReader.cpp:9398
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Definition: ASTReader.h:2377
SourceLocation ReadSourceLocation(ModuleFile &MF, RawLocEncoding Raw, LocSeq *Seq=nullptr) const
Read a source location from raw form.
Definition: ASTReader.h:2242
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:7801
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
Definition: ASTReader.cpp:7136
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:7668
Decl * GetDecl(GlobalDeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:7780
Decl * GetLocalDecl(ModuleFile &F, LocalDeclID LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:1930
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTReader.cpp:8973
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:4324
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:7126
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:2439
uint32_t getNextBits(uint32_t Width)
Definition: ASTReader.h:2462
A class which contains all the information about a particular captured value.
Definition: Decl.h:4500
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4494
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
Definition: Decl.cpp:5229
void setDoesNotEscape(bool B=true)
Definition: Decl.h:4646
void setSignatureAsWritten(TypeSourceInfo *Sig)
Definition: Decl.h:4576
void setCanAvoidCopyToHeap(bool B=true)
Definition: Decl.h:4651
void setIsConversionFromLambda(bool val=true)
Definition: Decl.h:4641
void setBlockMissingReturnType(bool val=true)
Definition: Decl.h:4633
static BlockDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5420
void setIsVariadic(bool value)
Definition: Decl.h:4570
void setBody(CompoundStmt *B)
Definition: Decl.h:4574
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
Definition: Decl.cpp:5240
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:4686
static CapturedDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumParams)
Definition: Decl.cpp:5434
void setContextParam(unsigned i, ImplicitParamDecl *P)
Definition: Decl.h:4752
void setNothrow(bool Nothrow=true)
Definition: Decl.cpp:5444
void setParam(unsigned i, ImplicitParamDecl *P)
Definition: Decl.h:4734
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)
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
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:1938
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1372
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:991
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:5969
Represents an empty-declaration.
Definition: Decl.h:4925
static EmptyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5633
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3297
static EnumConstantDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5460
void setInitExpr(Expr *E)
Definition: Decl.h:3321
void setInitVal(const ASTContext &C, const llvm::APSInt &V)
Definition: Decl.h:3322
Represents an enum.
Definition: Decl.h:3867
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition: Decl.h:4126
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:3938
void setIntegerType(QualType T)
Set the underlying integer type.
Definition: Decl.h:4036
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
Definition: Decl.h:4039
unsigned getODRHash()
Definition: Decl.cpp:4951
static EnumDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:4864
void setScoped(bool Scoped=true)
True if this tag declaration is a scoped enumeration.
Definition: Decl.h:3926
void setPromotionType(QualType T)
Set the promotion type.
Definition: Decl.h:4022
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.h:3948
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:3932
Represents a standard C++ module export declaration.
Definition: Decl.h:4878
static ExportDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5756
This represents one expression.
Definition: Expr.h:110
Represents a member of a struct/union/class.
Definition: Decl.h:3057
void setBitWidth(Expr *Width)
Set the bit-field width for this member.
Definition: Decl.h:3173
static FieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:4554
const VariableArrayType * CapturedVLAType
Definition: Decl.h:3113
void setRParenLoc(SourceLocation L)
Definition: Decl.h:4439
void setAsmString(StringLiteral *Asm)
Definition: Decl.h:4446
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5593
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:2611
void setHasSkippedBody(bool Skipped=true)
Definition: Decl.h:2590
static FunctionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5410
void setUsesSEHTry(bool UST)
Definition: Decl.h:2481
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
Definition: Decl.h:2605
void setHasWrittenPrototype(bool P=true)
State that this function has a written prototype.
Definition: Decl.h:2415
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
Definition: Decl.h:2351
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:2364
void setInlineSpecified(bool I)
Set whether the "inline" keyword was specified for this function.
Definition: Decl.h:2811
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:2340
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:2506
void setHasInheritedPrototype(bool P=true)
State that this function inherited its prototype from a previous declaration.
Definition: Decl.h:2427
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:4226
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
Definition: Decl.h:2318
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
Definition: Decl.h:2331
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
Definition: Decl.h:2825
void setTrivialForCall(bool IT)
Definition: Decl.h:2343
bool isDefaulted() const
Whether this function is defaulted.
Definition: Decl.h:2347
void setIneligibleOrNotSelected(bool II)
Definition: Decl.h:2383
void setConstexprKind(ConstexprSpecKind CSK)
Definition: Decl.h:2435
void setDefaulted(bool D=true)
Definition: Decl.h:2348
void setStorageClass(StorageClass SClass)
Sets the storage class as written in the source.
Definition: Decl.h:2802
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:2356
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
Definition: Decl.h:2397
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4656
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Definition: Type.h:4915
Declaration of a template function.
Definition: DeclTemplate.h:957
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
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
void Profile(llvm::FoldingSetNodeID &ID)
Definition: DeclTemplate.h:599
FunctionDecl * getFunction() const
Retrieve the declaration of the function template specialization.
Definition: DeclTemplate.h:519
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:4256
QualType getReturnType() const
Definition: Type.h:4573
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition: Decl.h:4940
static HLSLBufferDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5666
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:5391
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4799
static ImportDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
Definition: Decl.cpp:5723
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3341
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5487
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:5351
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:615
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
Definition: DeclTemplate.h:660
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:391
@ 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:5298
Represents a #pragma detect_mismatch line.
Definition: Decl.h:176
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NameValueSize)
Definition: Decl.cpp:5324
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:7363
Represents a struct/union/class.
Definition: Decl.h:4168
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition: Decl.cpp:5202
void setAnonymousStructOrUnion(bool Anon)
Definition: Decl.h:4224
void setArgPassingRestrictions(RecordArgPassingKind Kind)
Definition: Decl.h:4306
void setNonTrivialToPrimitiveCopy(bool V)
Definition: Decl.h:4258
void setHasNonTrivialToPrimitiveCopyCUnion(bool V)
Definition: Decl.h:4290
void setHasNonTrivialToPrimitiveDestructCUnion(bool V)
Definition: Decl.h:4282
void setHasFlexibleArrayMember(bool V)
Definition: Decl.h:4205
void setParamDestroyedInCallee(bool V)
Definition: Decl.h:4314
void setNonTrivialToPrimitiveDestroy(bool V)
Definition: Decl.h:4266
void setHasObjectMember(bool val)
Definition: Decl.h:4229
void setHasVolatileMember(bool val)
Definition: Decl.h:4233
void setHasNonTrivialToPrimitiveDefaultInitializeCUnion(bool V)
Definition: Decl.h:4274
static RecordDecl * CreateDeserialized(const ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5026
void setNonTrivialToPrimitiveDefaultInitialize(bool V)
Definition: Decl.h:4250
Declaration of a redeclarable template.
Definition: DeclTemplate.h:716
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
Definition: DeclTemplate.h:813
virtual CommonBase * newCommon(ASTContext &C) const =0
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:835
void setMemberSpecialization()
Note that this member template is a specialization.
Definition: DeclTemplate.h:865
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
Definition: DeclTemplate.h:911
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:3584
void setTagKind(TagKind TK)
Definition: Decl.h:3783
void setCompleteDefinitionRequired(bool V=true)
True if this complete decl is required to be complete for some existing use.
Definition: Decl.h:3702
void demoteThisDefinitionToDeclaration()
Mark a definition as a declaration and maintain information it was a definition.
Definition: Decl.h:3751
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition: Decl.h:3682
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:3717
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3687
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:4726
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
Definition: Decl.h:3725
void setBraceRange(SourceRange R)
Definition: Decl.h:3664
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
Definition: Decl.h:3690
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:4457
static TopLevelStmtDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5611
The top declaration context.
Definition: Decl.h:84
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3555
static TypeAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5562
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
Definition: Decl.h:3574
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:3390
void setLocStart(SourceLocation L)
Definition: Decl.h:3418
A container of type source information.
Definition: Type.h:7330
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:7341
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8193
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.h:2758
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.cpp:2000
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8126
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3534
static TypedefDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: Decl.cpp:5549
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3432
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
Definition: Decl.h:3498
void setTypeSourceInfo(TypeSourceInfo *newType)
Definition: Decl.h:3494
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...
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
RetTy Visit(PTR(Decl) D)
Definition: DeclVisitor.h:37
Source location and bit offset of a declaration.
Definition: ASTBitCodes.h:228
RawLocEncoding getRawLoc() const
Definition: ASTBitCodes.h:247
uint64_t getBitOffset(const uint64_t DeclTypesBlockStartOffset) const
Definition: ASTBitCodes.h:253
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:458
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID.
Definition: ModuleFile.h:478
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
Definition: ModuleFile.h:481
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLTYPES_BLOCK block.
Definition: ModuleFile.h:445
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:455
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:448
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
Definition: ModuleFile.h:485
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:1163
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1171
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
Definition: ASTBitCodes.h:1159
@ DECL_EMPTY
An EmptyDecl record.
Definition: ASTBitCodes.h:1419
@ DECL_CAPTURED
A CapturedDecl record.
Definition: ASTBitCodes.h:1260
@ DECL_CXX_BASE_SPECIFIERS
A record containing CXXBaseSpecifiers.
Definition: ASTBitCodes.h:1390
@ DECL_CXX_RECORD
A CXXRecordDecl record.
Definition: ASTBitCodes.h:1321
@ DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1363
@ DECL_OMP_ALLOCATE
An OMPAllocateDcl record.
Definition: ASTBitCodes.h:1416
@ DECL_MS_PROPERTY
A MSPropertyDecl record.
Definition: ASTBitCodes.h:1227
@ DECL_OMP_DECLARE_MAPPER
An OMPDeclareMapperDecl record.
Definition: ASTBitCodes.h:1440
@ DECL_TOP_LEVEL_STMT_DECL
A TopLevelStmtDecl record.
Definition: ASTBitCodes.h:1254
@ DECL_REQUIRES_EXPR_BODY
A RequiresExprBodyDecl record.
Definition: ASTBitCodes.h:1425
@ DECL_STATIC_ASSERT
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1387
@ DECL_INDIRECTFIELD
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1396
@ DECL_TEMPLATE_TEMPLATE_PARM
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1375
@ DECL_IMPORT
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1407
@ DECL_UNNAMED_GLOBAL_CONSTANT
A UnnamedGlobalConstantDecl record.
Definition: ASTBitCodes.h:1446
@ DECL_ACCESS_SPEC
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1339
@ DECL_OBJC_TYPE_PARAM
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1428
@ DECL_OBJC_CATEGORY_IMPL
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1209
@ DECL_ENUM_CONSTANT
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1185
@ DECL_PARM_VAR
A ParmVarDecl record.
Definition: ASTBitCodes.h:1242
@ DECL_TYPEDEF
A TypedefDecl record.
Definition: ASTBitCodes.h:1173
@ DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack.
Definition: ASTBitCodes.h:1404
@ DECL_HLSL_BUFFER
A HLSLBufferDecl record.
Definition: ASTBitCodes.h:1449
@ DECL_NAMESPACE_ALIAS
A NamespaceAliasDecl record.
Definition: ASTBitCodes.h:1288
@ DECL_TYPEALIAS
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1176
@ DECL_FUNCTION_TEMPLATE
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1366
@ DECL_MS_GUID
A MSGuidDecl record.
Definition: ASTBitCodes.h:1230
@ DECL_UNRESOLVED_USING_TYPENAME
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1312
@ DECL_CLASS_TEMPLATE_SPECIALIZATION
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1351
@ DECL_FILE_SCOPE_ASM
A FileScopeAsmDecl record.
Definition: ASTBitCodes.h:1251
@ DECL_CXX_CONSTRUCTOR
A CXXConstructorDecl record.
Definition: ASTBitCodes.h:1330
@ DECL_CXX_CONVERSION
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1336
@ DECL_FIELD
A FieldDecl record.
Definition: ASTBitCodes.h:1224
@ DECL_LINKAGE_SPEC
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1315
@ DECL_NAMESPACE
A NamespaceDecl record.
Definition: ASTBitCodes.h:1285
@ DECL_NON_TYPE_TEMPLATE_PARM
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1372
@ DECL_USING_PACK
A UsingPackDecl record.
Definition: ASTBitCodes.h:1297
@ DECL_FUNCTION
A FunctionDecl record.
Definition: ASTBitCodes.h:1188
@ DECL_USING_DIRECTIVE
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1306
@ DECL_RECORD
A RecordDecl record.
Definition: ASTBitCodes.h:1182
@ DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext.
Definition: ASTBitCodes.h:1270
@ DECL_BLOCK
A BlockDecl record.
Definition: ASTBitCodes.h:1257
@ DECL_UNRESOLVED_USING_VALUE
An UnresolvedUsingValueDecl record.
Definition: ASTBitCodes.h:1309
@ DECL_TYPE_ALIAS_TEMPLATE
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1378
@ DECL_CXX_CTOR_INITIALIZERS
A record containing CXXCtorInitializers.
Definition: ASTBitCodes.h:1393
@ DECL_OBJC_CATEGORY
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1206
@ DECL_VAR
A VarDecl record.
Definition: ASTBitCodes.h:1236
@ DECL_UNRESOLVED_USING_IF_EXISTS
An UnresolvedUsingIfExistsDecl record.
Definition: ASTBitCodes.h:1384
@ DECL_USING
A UsingDecl record.
Definition: ASTBitCodes.h:1291
@ DECL_OBJC_PROTOCOL
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1197
@ DECL_TEMPLATE_TYPE_PARM
A TemplateTypeParmDecl record.
Definition: ASTBitCodes.h:1369
@ DECL_VAR_TEMPLATE_SPECIALIZATION
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1360
@ DECL_OBJC_IMPLEMENTATION
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:1212
@ DECL_LABEL
A LabelDecl record.
Definition: ASTBitCodes.h:1282
@ DECL_OBJC_COMPATIBLE_ALIAS
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:1215
@ DECL_CONSTRUCTOR_USING_SHADOW
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1303
@ DECL_USING_ENUM
A UsingEnumDecl record.
Definition: ASTBitCodes.h:1294
@ DECL_FRIEND_TEMPLATE
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1345
@ DECL_PRAGMA_DETECT_MISMATCH
A PragmaDetectMismatchDecl record.
Definition: ASTBitCodes.h:1437
@ DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack.
Definition: ASTBitCodes.h:1400
@ DECL_OBJC_AT_DEFS_FIELD
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1203
@ DECL_IMPLICIT_PARAM
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1239
@ DECL_FRIEND
A FriendDecl record.
Definition: ASTBitCodes.h:1342
@ DECL_CXX_METHOD
A CXXMethodDecl record.
Definition: ASTBitCodes.h:1327
@ DECL_EXPORT
An ExportDecl record.
Definition: ASTBitCodes.h:1318
@ DECL_BINDING
A BindingDecl record.
Definition: ASTBitCodes.h:1248
@ DECL_PRAGMA_COMMENT
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1434
@ DECL_ENUM
An EnumDecl record.
Definition: ASTBitCodes.h:1179
@ DECL_DECOMPOSITION
A DecompositionDecl record.
Definition: ASTBitCodes.h:1245
@ DECL_OMP_DECLARE_REDUCTION
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1443
@ DECL_OMP_THREADPRIVATE
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1410
@ DECL_OBJC_METHOD
A ObjCMethodDecl record.
Definition: ASTBitCodes.h:1191
@ DECL_CXX_DESTRUCTOR
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1333
@ DECL_OMP_CAPTUREDEXPR
An OMPCapturedExprDecl record.
Definition: ASTBitCodes.h:1431
@ DECL_CLASS_TEMPLATE
A ClassTemplateDecl record.
Definition: ASTBitCodes.h:1348
@ DECL_USING_SHADOW
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1300
@ DECL_CONCEPT
A ConceptDecl record.
Definition: ASTBitCodes.h:1381
@ DECL_CXX_DEDUCTION_GUIDE
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1324
@ DECL_OMP_REQUIRES
An OMPRequiresDecl record.
Definition: ASTBitCodes.h:1413
@ DECL_OBJC_IVAR
A ObjCIvarDecl record.
Definition: ASTBitCodes.h:1200
@ DECL_OBJC_PROPERTY
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1218
@ DECL_TEMPLATE_PARAM_OBJECT
A TemplateParamObjectDecl record.
Definition: ASTBitCodes.h:1233
@ DECL_OBJC_INTERFACE
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:1194
@ DECL_VAR_TEMPLATE
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1357
@ DECL_LIFETIME_EXTENDED_TEMPORARY
An LifetimeExtendedTemporaryDecl record.
Definition: ASTBitCodes.h:1422
@ DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1354
@ DECL_IMPLICIT_CONCEPT_SPECIALIZATION
An ImplicitConceptSpecializationDecl record.
Definition: ASTBitCodes.h:1452
@ DECL_CONTEXT_VISIBLE
A record that stores the set of declarations that are visible from a given DeclContext.
Definition: ASTBitCodes.h:1279
@ DECL_OBJC_PROPERTY_IMPL
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1221
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:81
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:161
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:459
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:72
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:92
@ 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:6299
ObjCImplementationControl
Definition: DeclObjC.h:118
RecordArgPassingKind
Enum that represents the different ways arguments are passed to and returned from function calls.
Definition: Decl.h:4145
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:2481
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
Provides information about an explicit instantiation of a variable or class template.
SourceLocation ExternKeywordLoc
The location of the extern keyword.
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:963
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
Definition: DeclTemplate.h:966
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.
Describes the categories of an Objective-C class.
Definition: ASTBitCodes.h:1981