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