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