55 #include "llvm/ADT/DenseMap.h" 56 #include "llvm/ADT/FoldingSet.h" 57 #include "llvm/ADT/STLExtras.h" 58 #include "llvm/ADT/SmallPtrSet.h" 59 #include "llvm/ADT/SmallVector.h" 60 #include "llvm/ADT/iterator_range.h" 61 #include "llvm/Bitcode/BitstreamReader.h" 62 #include "llvm/Support/Casting.h" 63 #include "llvm/Support/ErrorHandling.h" 64 #include "llvm/Support/SaveAndRestore.h" 72 using namespace clang;
73 using namespace serialization;
84 ASTReader::RecordLocation Loc;
91 unsigned AnonymousDeclNumber;
95 bool HasPendingBody =
false;
100 bool IsDeclMarkedUsed =
false;
102 uint64_t GetCurrentCursorOffset();
104 uint64_t ReadLocalOffset() {
105 uint64_t LocalOffset = Record.
readInt();
106 assert(LocalOffset < Loc.Offset &&
"offset point after current record");
107 return LocalOffset ? Loc.Offset - LocalOffset : 0;
110 uint64_t ReadGlobalOffset() {
111 uint64_t Local = ReadLocalOffset();
131 std::string ReadString() {
136 for (
unsigned I = 0, Size = Record.
readInt(); I != Size; ++I)
137 IDs.push_back(ReadDeclID());
169 void ReadCXXDefinitionData(
struct CXXRecordDecl::DefinitionData &Data,
172 struct CXXRecordDecl::DefinitionData &&NewDD);
173 void ReadObjCDefinitionData(
struct ObjCInterfaceDecl::DefinitionData &Data);
175 struct ObjCInterfaceDecl::DefinitionData &&NewDD);
176 void ReadObjCDefinitionData(
struct ObjCProtocolDecl::DefinitionData &Data);
178 struct ObjCProtocolDecl::DefinitionData &&NewDD);
189 class RedeclarableResult {
196 : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {}
202 bool isKeyDecl()
const {
return IsKeyDecl; }
206 Decl *getKnownMergeTarget()
const {
return MergeWith; }
214 class FindExistingResult {
218 bool AddResult =
false;
219 unsigned AnonymousDeclNumber = 0;
223 FindExistingResult(
ASTReader &Reader) : Reader(Reader) {}
226 unsigned AnonymousDeclNumber,
228 : Reader(Reader), New(New), Existing(Existing), AddResult(
true),
229 AnonymousDeclNumber(AnonymousDeclNumber),
230 TypedefNameForLinkage(TypedefNameForLinkage) {}
232 FindExistingResult(FindExistingResult &&Other)
233 : Reader(Other.Reader), New(Other.New), Existing(Other.Existing),
234 AddResult(Other.AddResult),
235 AnonymousDeclNumber(Other.AnonymousDeclNumber),
236 TypedefNameForLinkage(Other.TypedefNameForLinkage) {
237 Other.AddResult =
false;
240 FindExistingResult &operator=(FindExistingResult &&) =
delete;
241 ~FindExistingResult();
245 void suppress() { AddResult =
false; }
247 operator NamedDecl*()
const {
return Existing; }
250 operator T*()
const {
return dyn_cast_or_null<T>(Existing); }
255 FindExistingResult findExisting(
NamedDecl *D);
259 ASTReader::RecordLocation Loc,
261 : Reader(Reader), Record(Record), Loc(Loc), ThisDeclID(thisDeclID),
262 ThisDeclLoc(ThisDeclLoc) {}
264 template <
typename T>
static 273 auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations;
275 if (
auto &Old = LazySpecializations) {
276 IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
278 IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
282 *Result = IDs.size();
283 std::copy(IDs.begin(), IDs.end(), Result + 1);
285 LazySpecializations = Result;
288 template <
typename DeclT>
290 static Decl *getMostRecentDeclImpl(...);
291 static Decl *getMostRecentDecl(
Decl *D);
293 template <
typename DeclT>
294 static void attachPreviousDeclImpl(
ASTReader &Reader,
297 static void attachPreviousDeclImpl(
ASTReader &Reader, ...);
301 template <
typename DeclT>
303 static void attachLatestDeclImpl(...);
304 static void attachLatestDecl(
Decl *D,
Decl *latest);
306 template <
typename DeclT>
308 static void markIncompleteDeclChainImpl(...);
320 Cat->NextClassCategory = Next;
323 void VisitDecl(
Decl *D);
337 RedeclarableResult VisitTagDecl(
TagDecl *TD);
339 RedeclarableResult VisitRecordDeclImpl(
RecordDecl *RD);
343 RedeclarableResult VisitClassTemplateSpecializationDeclImpl(
348 VisitClassTemplateSpecializationDeclImpl(D);
351 void VisitClassTemplatePartialSpecializationDecl(
353 void VisitClassScopeFunctionSpecializationDecl(
359 VisitVarTemplateSpecializationDeclImpl(D);
362 void VisitVarTemplatePartialSpecializationDecl(
378 RedeclarableResult VisitVarDeclImpl(
VarDecl *D);
409 std::pair<uint64_t, uint64_t> VisitDeclContext(
DeclContext *DC);
416 DeclID TemplatePatternID = 0);
420 RedeclarableResult &Redecl,
421 DeclID TemplatePatternID = 0);
428 DeclID DsID,
bool IsKeyDecl);
459 template<
typename DeclT>
460 class MergedRedeclIterator {
462 DeclT *Canonical =
nullptr;
463 DeclT *Current =
nullptr;
466 MergedRedeclIterator() =
default;
467 MergedRedeclIterator(DeclT *Start) : Start(Start), Current(Start) {}
471 MergedRedeclIterator &operator++() {
472 if (Current->isFirstDecl()) {
474 Current = Current->getMostRecentDecl();
476 Current = Current->getPreviousDecl();
482 if (Current == Start || Current == Canonical)
487 friend bool operator!=(
const MergedRedeclIterator &A,
488 const MergedRedeclIterator &B) {
489 return A.Current != B.Current;
495 template <
typename DeclT>
496 static llvm::iterator_range<MergedRedeclIterator<DeclT>>
498 return llvm::make_range(MergedRedeclIterator<DeclT>(D),
499 MergedRedeclIterator<DeclT>());
502 uint64_t ASTDeclReader::GetCurrentCursorOffset() {
503 return Loc.F->DeclsCursor.GetCurrentBitNo() + Loc.F->GlobalBitOffset;
507 if (Record.readInt())
509 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
510 CD->setNumCtorInitializers(Record.readInt());
511 if (CD->getNumCtorInitializers())
512 CD->CtorInitializers = ReadGlobalOffset();
515 Reader.PendingBodies[FD] = GetCurrentCursorOffset();
516 HasPendingBody =
true;
525 IsDeclMarkedUsed =
false;
527 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
528 if (
auto *TInfo = DD->getTypeSourceInfo())
529 Record.readTypeLoc(TInfo->getTypeLoc());
532 if (
auto *TD = dyn_cast<TypeDecl>(D)) {
534 TD->setTypeForDecl(Reader.GetType(DeferredTypeID).getTypePtrOrNull());
538 if (NamedDeclForTagDecl)
539 cast<TagDecl>(D)->TypedefNameDeclOrQualifier =
540 cast<TypedefNameDecl>(Reader.GetDecl(NamedDeclForTagDecl));
541 }
else if (
auto *
ID = dyn_cast<ObjCInterfaceDecl>(D)) {
543 ID->TypeForDecl = Reader.GetType(DeferredTypeID).getTypePtrOrNull();
544 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
549 if (Record.readInt())
550 ReadFunctionDefinition(FD);
556 isa<ParmVarDecl>(D)) {
563 GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID();
564 GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID();
565 if (!LexicalDCIDForTemplateParmDecl)
566 LexicalDCIDForTemplateParmDecl = SemaDCIDForTemplateParmDecl;
567 Reader.addPendingDeclContextInfo(D,
568 SemaDCIDForTemplateParmDecl,
569 LexicalDCIDForTemplateParmDecl);
572 auto *SemaDC = ReadDeclAs<DeclContext>();
573 auto *LexicalDC = ReadDeclAs<DeclContext>();
579 D->setDeclContextsImpl(MergedSemaDC ? MergedSemaDC : SemaDC, LexicalDC,
580 Reader.getContext());
584 if (Record.readInt()) {
586 Record.readAttributes(Attrs);
589 D->setAttrsImpl(Attrs, Reader.getContext());
592 D->Used = Record.readInt();
593 IsDeclMarkedUsed |= D->Used;
598 bool ModulePrivate = Record.readInt();
612 }
else if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
620 Reader.HiddenNamesMap[Owner].push_back(D);
622 }
else if (ModulePrivate) {
631 std::string Arg = ReadString();
632 memcpy(D->getTrailingObjects<
char>(), Arg.data(), Arg.size());
633 D->getTrailingObjects<
char>()[Arg.size()] =
'\0';
639 std::string Name = ReadString();
640 memcpy(D->getTrailingObjects<
char>(), Name.data(), Name.size());
641 D->getTrailingObjects<
char>()[Name.size()] =
'\0';
643 D->ValueStart = Name.size() + 1;
644 std::string
Value = ReadString();
645 memcpy(D->getTrailingObjects<
char>() + D->ValueStart, Value.data(),
647 D->getTrailingObjects<
char>()[D->ValueStart + Value.size()] =
'\0';
651 llvm_unreachable(
"Translation units are not serialized");
657 AnonymousDeclNumber = Record.readInt();
664 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
667 ASTDeclReader::RedeclarableResult
669 RedeclarableResult Redecl = VisitRedeclarable(TD);
672 if (Record.readInt()) {
673 QualType modedT = Record.readType();
686 RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
687 mergeRedeclarable(TD, Redecl);
691 RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
692 if (
auto *Template = ReadDeclAs<TypeAliasTemplateDecl>())
696 mergeRedeclarable(TD, Redecl);
700 RedeclarableResult Redecl = VisitRedeclarable(TD);
705 if (!isa<CXXRecordDecl>(TD))
712 switch (Record.readInt()) {
717 ReadQualifierInfo(*Info);
718 TD->TypedefNameDeclOrQualifier = Info;
722 NamedDeclForTagDecl = ReadDeclID();
723 TypedefNameForLinkage = Record.getIdentifierInfo();
726 llvm_unreachable(
"unexpected tag info kind");
729 if (!isa<CXXRecordDecl>(TD))
730 mergeRedeclarable(TD, Redecl);
741 ED->setNumPositiveBits(Record.readInt());
742 ED->setNumNegativeBits(Record.readInt());
743 ED->setScoped(Record.readInt());
744 ED->setScopedUsingClassTag(Record.readInt());
745 ED->setFixed(Record.readInt());
747 ED->setHasODRHash(
true);
748 ED->ODRHash = Record.readInt();
753 Reader.getContext().getLangOpts().Modules &&
754 Reader.getContext().getLangOpts().CPlusPlus) {
760 if (!D->isFromASTFile() && D->isCompleteDefinition()) {
767 Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
769 Reader.mergeDefinitionVisibility(OldDef, ED);
771 Reader.PendingEnumOdrMergeFailures[OldDef].push_back(ED);
777 if (
auto *InstED = ReadDeclAs<EnumDecl>()) {
780 ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK);
785 ASTDeclReader::RedeclarableResult
787 RedeclarableResult Redecl = VisitTagDecl(RD);
805 if (isa<FunctionDecl>(VD))
806 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
808 VD->
setType(Record.readType());
813 if (Record.readInt())
822 if (Record.readInt()) {
823 auto *Info =
new (Reader.getContext()) DeclaratorDecl::ExtInfo();
824 ReadQualifierInfo(*Info);
827 QualType TSIType = Record.readType();
829 TSIType.
isNull() ? nullptr
830 : Reader.getContext().CreateTypeSourceInfo(TSIType));
834 RedeclarableResult Redecl = VisitRedeclarable(FD);
835 VisitDeclaratorDecl(FD);
845 Reader.PendingFunctionTypes.push_back({FD, DeferredTypeID});
847 FD->
setType(Reader.GetType(DeferredTypeID));
851 ReadDeclarationNameLoc(FD->DNLoc, FD->
getDeclName());
878 FD->EndRangeLoc = ReadSourceLocation();
880 FD->ODRHash = Record.readInt();
881 FD->setHasODRHash(
true);
885 mergeRedeclarable(FD, Redecl);
892 auto *InstFD = ReadDeclAs<FunctionDecl>();
895 FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
897 mergeRedeclarable(FD, Redecl);
901 auto *Template = ReadDeclAs<FunctionTemplateDecl>();
906 Record.readTemplateArgumentList(TemplArgs,
true);
911 bool HasTemplateArgumentsAsWritten = Record.readInt();
912 if (HasTemplateArgumentsAsWritten) {
913 unsigned NumTemplateArgLocs = Record.readInt();
914 TemplArgLocs.reserve(NumTemplateArgLocs);
915 for (
unsigned i = 0; i != NumTemplateArgLocs; ++i)
916 TemplArgLocs.push_back(Record.readTemplateArgumentLoc());
918 LAngleLoc = ReadSourceLocation();
919 RAngleLoc = ReadSourceLocation();
928 for (
unsigned i = 0, e = TemplArgLocs.size(); i != e; ++i)
933 HasTemplateArgumentsAsWritten ? &TemplArgsInfo
936 FD->TemplateOrSpecialization = FTInfo;
941 auto *CanonTemplate = ReadDeclAs<FunctionTemplateDecl>();
947 llvm::FoldingSetNodeID
ID;
949 void *InsertPos =
nullptr;
956 assert(Reader.getContext().getLangOpts().Modules &&
957 "already deserialized this template specialization");
958 mergeRedeclarable(FD, ExistingInfo->
Function, Redecl);
966 unsigned NumTemplates = Record.readInt();
967 while (NumTemplates--)
968 TemplDecls.
addDecl(ReadDeclAs<NamedDecl>());
972 unsigned NumArgs = Record.readInt();
974 TemplArgs.
addArgument(Record.readTemplateArgumentLoc());
979 TemplDecls, TemplArgs);
987 unsigned NumParams = Record.readInt();
989 Params.reserve(NumParams);
990 for (
unsigned I = 0; I != NumParams; ++I)
991 Params.push_back(ReadDeclAs<ParmVarDecl>());
992 FD->setParams(Reader.getContext(), Params);
997 if (Record.readInt()) {
1000 Reader.PendingBodies[MD] = GetCurrentCursorOffset();
1001 HasPendingBody =
true;
1003 MD->
setCmdDecl(ReadDeclAs<ImplicitParamDecl>());
1015 Reader.getContext().setObjCMethodRedeclaration(MD,
1016 ReadDeclAs<ObjCMethodDecl>());
1023 MD->DeclEndLoc = ReadSourceLocation();
1024 unsigned NumParams = Record.readInt();
1026 Params.reserve(NumParams);
1027 for (
unsigned I = 0; I != NumParams; ++I)
1028 Params.push_back(ReadDeclAs<ParmVarDecl>());
1031 unsigned NumStoredSelLocs = Record.readInt();
1033 SelLocs.reserve(NumStoredSelLocs);
1034 for (
unsigned i = 0; i != NumStoredSelLocs; ++i)
1035 SelLocs.push_back(ReadSourceLocation());
1037 MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs);
1041 VisitTypedefNameDecl(D);
1043 D->Variance = Record.readInt();
1044 D->Index = Record.readInt();
1045 D->VarianceLoc = ReadSourceLocation();
1046 D->ColonLoc = ReadSourceLocation();
1056 unsigned numParams = Record.readInt();
1061 typeParams.reserve(numParams);
1062 for (
unsigned i = 0; i != numParams; ++i) {
1063 auto *typeParam = ReadDeclAs<ObjCTypeParamDecl>();
1067 typeParams.push_back(typeParam);
1074 typeParams, rAngleLoc);
1077 void ASTDeclReader::ReadObjCDefinitionData(
1078 struct ObjCInterfaceDecl::DefinitionData &Data) {
1080 Data.SuperClassTInfo = GetTypeSourceInfo();
1082 Data.EndLoc = ReadSourceLocation();
1083 Data.HasDesignatedInitializers = Record.readInt();
1086 unsigned NumProtocols = Record.readInt();
1088 Protocols.reserve(NumProtocols);
1089 for (
unsigned I = 0; I != NumProtocols; ++I)
1090 Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
1092 ProtoLocs.reserve(NumProtocols);
1093 for (
unsigned I = 0; I != NumProtocols; ++I)
1094 ProtoLocs.push_back(ReadSourceLocation());
1095 Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, ProtoLocs.data(),
1096 Reader.getContext());
1099 NumProtocols = Record.readInt();
1101 Protocols.reserve(NumProtocols);
1102 for (
unsigned I = 0; I != NumProtocols; ++I)
1103 Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
1104 Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
1105 Reader.getContext());
1109 struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
1114 RedeclarableResult Redecl = VisitRedeclarable(ID);
1115 VisitObjCContainerDecl(ID);
1116 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
1117 mergeRedeclarable(ID, Redecl);
1119 ID->TypeParamList = ReadObjCTypeParamList();
1120 if (Record.readInt()) {
1122 ID->allocateDefinitionData();
1124 ReadObjCDefinitionData(ID->data());
1126 if (Canon->Data.getPointer()) {
1129 MergeDefinitionData(Canon, std::move(ID->data()));
1130 ID->Data = Canon->Data;
1141 Reader.PendingDefinitions.insert(ID);
1144 Reader.ObjCClassesLoaded.push_back(ID);
1151 VisitFieldDecl(IVD);
1155 bool synth = Record.readInt();
1159 void ASTDeclReader::ReadObjCDefinitionData(
1160 struct ObjCProtocolDecl::DefinitionData &Data) {
1161 unsigned NumProtoRefs = Record.readInt();
1163 ProtoRefs.reserve(NumProtoRefs);
1164 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1165 ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
1167 ProtoLocs.reserve(NumProtoRefs);
1168 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1169 ProtoLocs.push_back(ReadSourceLocation());
1170 Data.ReferencedProtocols.set(ProtoRefs.data(), NumProtoRefs,
1171 ProtoLocs.data(), Reader.getContext());
1175 struct ObjCProtocolDecl::DefinitionData &&NewDD) {
1180 RedeclarableResult Redecl = VisitRedeclarable(PD);
1181 VisitObjCContainerDecl(PD);
1182 mergeRedeclarable(PD, Redecl);
1184 if (Record.readInt()) {
1186 PD->allocateDefinitionData();
1188 ReadObjCDefinitionData(PD->data());
1191 if (Canon->Data.getPointer()) {
1194 MergeDefinitionData(Canon, std::move(PD->data()));
1195 PD->Data = Canon->Data;
1202 Reader.PendingDefinitions.insert(PD);
1213 VisitObjCContainerDecl(CD);
1221 Reader.CategoriesDeserialized.insert(CD);
1223 CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>();
1224 CD->TypeParamList = ReadObjCTypeParamList();
1225 unsigned NumProtoRefs = Record.readInt();
1227 ProtoRefs.reserve(NumProtoRefs);
1228 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1229 ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
1231 ProtoLocs.reserve(NumProtoRefs);
1232 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1233 ProtoLocs.push_back(ReadSourceLocation());
1235 Reader.getContext());
1241 Reader.getContext());
1245 VisitNamedDecl(CAD);
1274 VisitObjCContainerDecl(D);
1279 VisitObjCImplDecl(D);
1280 D->CategoryNameLoc = ReadSourceLocation();
1284 VisitObjCImplDecl(D);
1286 D->SuperLoc = ReadSourceLocation();
1291 D->NumIvarInitializers = Record.readInt();
1292 if (D->NumIvarInitializers)
1293 D->IvarInitializers = ReadGlobalOffset();
1300 D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>();
1301 D->IvarLoc = ReadSourceLocation();
1307 VisitDeclaratorDecl(FD);
1308 FD->Mutable = Record.readInt();
1310 if (
auto ISK = static_cast<FieldDecl::InitStorageKind>(Record.readInt())) {
1311 FD->InitStorage.setInt(ISK);
1312 FD->InitStorage.setPointer(ISK == FieldDecl::ISK_CapturedVLAType
1313 ? Record.readType().getAsOpaquePtr()
1314 : Record.readExpr());
1317 if (
auto *BW = Record.readExpr())
1321 if (
auto *Tmpl = ReadDeclAs<FieldDecl>())
1322 Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
1328 VisitDeclaratorDecl(PD);
1329 PD->GetterId = Record.getIdentifierInfo();
1330 PD->SetterId = Record.getIdentifierInfo();
1336 FD->ChainingSize = Record.readInt();
1337 assert(FD->ChainingSize >= 2 &&
"Anonymous chaining must be >= 2");
1338 FD->Chaining =
new (Reader.getContext())
NamedDecl*[FD->ChainingSize];
1340 for (
unsigned I = 0; I != FD->ChainingSize; ++I)
1341 FD->Chaining[I] = ReadDeclAs<NamedDecl>();
1347 RedeclarableResult Redecl = VisitRedeclarable(VD);
1348 VisitDeclaratorDecl(VD);
1353 VD->
VarDeclBits.ARCPseudoStrong = Record.readInt();
1354 if (!isa<ParmVarDecl>(VD)) {
1369 auto VarLinkage =
Linkage(Record.readInt());
1377 if (uint64_t Val = Record.readInt()) {
1378 VD->
setInit(Record.readExpr());
1382 Eval->
IsICE = Val == 3;
1387 Expr *CopyExpr = Record.readExpr();
1389 Reader.getContext().setBlockVarCopyInit(VD, CopyExpr, Record.readInt());
1396 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1398 switch ((VarKind)Record.readInt()) {
1399 case VarNotTemplate:
1402 if (!isa<ParmVarDecl>(VD) && !isa<ImplicitParamDecl>(VD) &&
1403 !isa<VarTemplateSpecializationDecl>(VD))
1404 mergeRedeclarable(VD, Redecl);
1408 VD->setDescribedVarTemplate(ReadDeclAs<VarTemplateDecl>());
1410 case StaticDataMemberSpecialization: {
1411 auto *Tmpl = ReadDeclAs<VarDecl>();
1414 Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
1415 mergeRedeclarable(VD, Redecl);
1429 unsigned isObjCMethodParam = Record.readInt();
1430 unsigned scopeDepth = Record.readInt();
1431 unsigned scopeIndex = Record.readInt();
1432 unsigned declQualifier = Record.readInt();
1433 if (isObjCMethodParam) {
1434 assert(scopeDepth == 0);
1442 if (Record.readInt())
1451 auto **BDs = DD->getTrailingObjects<
BindingDecl *>();
1452 for (
unsigned I = 0; I != DD->NumBindings; ++I)
1453 BDs[I] = ReadDeclAs<BindingDecl>();
1458 BD->Binding = Record.readExpr();
1463 AD->
setAsmString(cast<StringLiteral>(Record.readExpr()));
1469 BD->
setBody(cast_or_null<CompoundStmt>(Record.readStmt()));
1471 unsigned NumParams = Record.readInt();
1473 Params.reserve(NumParams);
1474 for (
unsigned I = 0; I != NumParams; ++I)
1475 Params.push_back(ReadDeclAs<ParmVarDecl>());
1483 bool capturesCXXThis = Record.readInt();
1484 unsigned numCaptures = Record.readInt();
1486 captures.reserve(numCaptures);
1487 for (
unsigned i = 0; i != numCaptures; ++i) {
1488 auto *
decl = ReadDeclAs<VarDecl>();
1489 unsigned flags = Record.readInt();
1490 bool byRef = (flags & 1);
1491 bool nested = (flags & 2);
1492 Expr *copyExpr = ((flags & 4) ? Record.readExpr() :
nullptr);
1496 BD->
setCaptures(Reader.getContext(), captures, capturesCXXThis);
1501 unsigned ContextParamPos = Record.readInt();
1504 for (
unsigned I = 0; I < CD->NumParams; ++I) {
1505 if (I != ContextParamPos)
1506 CD->
setParam(I, ReadDeclAs<ImplicitParamDecl>());
1521 D->RBraceLoc = ReadSourceLocation();
1530 RedeclarableResult Redecl = VisitRedeclarable(D);
1533 D->LocStart = ReadSourceLocation();
1534 D->RBraceLoc = ReadSourceLocation();
1541 if (Redecl.getFirstID() == ThisDeclID) {
1542 AnonNamespace = ReadDeclID();
1546 D->AnonOrFirstNamespaceAndInline.setPointer(D->
getFirstDecl());
1549 mergeRedeclarable(D, Redecl);
1551 if (AnonNamespace) {
1555 auto *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
1556 if (!Record.isModule())
1562 RedeclarableResult Redecl = VisitRedeclarable(D);
1564 D->NamespaceLoc = ReadSourceLocation();
1565 D->IdentLoc = ReadSourceLocation();
1566 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1567 D->Namespace = ReadDeclAs<NamedDecl>();
1568 mergeRedeclarable(D, Redecl);
1574 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1575 ReadDeclarationNameLoc(D->DNLoc, D->
getDeclName());
1576 D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>());
1578 if (
auto *Pattern = ReadDeclAs<NamedDecl>())
1579 Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
1585 D->InstantiatedFrom = ReadDeclAs<NamedDecl>();
1586 auto **Expansions = D->getTrailingObjects<
NamedDecl *>();
1587 for (
unsigned I = 0; I != D->NumExpansions; ++I)
1588 Expansions[I] = ReadDeclAs<NamedDecl>();
1593 RedeclarableResult Redecl = VisitRedeclarable(D);
1595 D->Underlying = ReadDeclAs<NamedDecl>();
1597 D->UsingOrNextShadow = ReadDeclAs<NamedDecl>();
1598 auto *Pattern = ReadDeclAs<UsingShadowDecl>();
1600 Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern);
1601 mergeRedeclarable(D, Redecl);
1606 VisitUsingShadowDecl(D);
1607 D->NominatedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
1608 D->ConstructedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
1609 D->IsVirtual = Record.readInt();
1614 D->UsingLoc = ReadSourceLocation();
1615 D->NamespaceLoc = ReadSourceLocation();
1616 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1617 D->NominatedNamespace = ReadDeclAs<NamedDecl>();
1618 D->CommonAncestor = ReadDeclAs<DeclContext>();
1624 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1625 ReadDeclarationNameLoc(D->DNLoc, D->
getDeclName());
1626 D->EllipsisLoc = ReadSourceLocation();
1633 D->TypenameLocation = ReadSourceLocation();
1634 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1635 D->EllipsisLoc = ReadSourceLocation();
1639 void ASTDeclReader::ReadCXXDefinitionData(
1640 struct CXXRecordDecl::DefinitionData &Data,
const CXXRecordDecl *D) {
1642 Data.UserDeclaredConstructor = Record.readInt();
1643 Data.UserDeclaredSpecialMembers = Record.readInt();
1644 Data.Aggregate = Record.readInt();
1645 Data.PlainOldData = Record.readInt();
1646 Data.Empty = Record.readInt();
1647 Data.Polymorphic = Record.readInt();
1648 Data.Abstract = Record.readInt();
1649 Data.IsStandardLayout = Record.readInt();
1650 Data.IsCXX11StandardLayout = Record.readInt();
1651 Data.HasBasesWithFields = Record.readInt();
1652 Data.HasBasesWithNonStaticDataMembers = Record.readInt();
1653 Data.HasPrivateFields = Record.readInt();
1654 Data.HasProtectedFields = Record.readInt();
1655 Data.HasPublicFields = Record.readInt();
1656 Data.HasMutableFields = Record.readInt();
1657 Data.HasVariantMembers = Record.readInt();
1658 Data.HasOnlyCMembers = Record.readInt();
1659 Data.HasInClassInitializer = Record.readInt();
1660 Data.HasUninitializedReferenceMember = Record.readInt();
1661 Data.HasUninitializedFields = Record.readInt();
1662 Data.HasInheritedConstructor = Record.readInt();
1663 Data.HasInheritedAssignment = Record.readInt();
1664 Data.NeedOverloadResolutionForCopyConstructor = Record.readInt();
1665 Data.NeedOverloadResolutionForMoveConstructor = Record.readInt();
1666 Data.NeedOverloadResolutionForMoveAssignment = Record.readInt();
1667 Data.NeedOverloadResolutionForDestructor = Record.readInt();
1668 Data.DefaultedCopyConstructorIsDeleted = Record.readInt();
1669 Data.DefaultedMoveConstructorIsDeleted = Record.readInt();
1670 Data.DefaultedMoveAssignmentIsDeleted = Record.readInt();
1671 Data.DefaultedDestructorIsDeleted = Record.readInt();
1672 Data.HasTrivialSpecialMembers = Record.readInt();
1673 Data.HasTrivialSpecialMembersForCall = Record.readInt();
1674 Data.DeclaredNonTrivialSpecialMembers = Record.readInt();
1675 Data.DeclaredNonTrivialSpecialMembersForCall = Record.readInt();
1676 Data.HasIrrelevantDestructor = Record.readInt();
1677 Data.HasConstexprNonCopyMoveConstructor = Record.readInt();
1678 Data.HasDefaultedDefaultConstructor = Record.readInt();
1679 Data.DefaultedDefaultConstructorIsConstexpr = Record.readInt();
1680 Data.HasConstexprDefaultConstructor = Record.readInt();
1681 Data.HasNonLiteralTypeFieldsOrBases = Record.readInt();
1682 Data.ComputedVisibleConversions = Record.readInt();
1683 Data.UserProvidedDefaultConstructor = Record.readInt();
1684 Data.DeclaredSpecialMembers = Record.readInt();
1685 Data.ImplicitCopyConstructorCanHaveConstParamForVBase = Record.readInt();
1686 Data.ImplicitCopyConstructorCanHaveConstParamForNonVBase = Record.readInt();
1687 Data.ImplicitCopyAssignmentHasConstParam = Record.readInt();
1688 Data.HasDeclaredCopyConstructorWithConstParam = Record.readInt();
1689 Data.HasDeclaredCopyAssignmentWithConstParam = Record.readInt();
1690 Data.ODRHash = Record.readInt();
1691 Data.HasODRHash =
true;
1693 if (Record.readInt())
1696 Data.NumBases = Record.readInt();
1698 Data.Bases = ReadGlobalOffset();
1699 Data.NumVBases = Record.readInt();
1701 Data.VBases = ReadGlobalOffset();
1703 Record.readUnresolvedSet(Data.Conversions);
1704 Record.readUnresolvedSet(Data.VisibleConversions);
1705 assert(Data.Definition &&
"Data.Definition should be already set!");
1706 Data.FirstFriend = ReadDeclID();
1708 if (Data.IsLambda) {
1711 auto &Lambda =
static_cast<CXXRecordDecl::LambdaDefinitionData &
>(Data);
1712 Lambda.Dependent = Record.readInt();
1713 Lambda.IsGenericLambda = Record.readInt();
1714 Lambda.CaptureDefault = Record.readInt();
1715 Lambda.NumCaptures = Record.readInt();
1716 Lambda.NumExplicitCaptures = Record.readInt();
1717 Lambda.ManglingNumber = Record.readInt();
1718 Lambda.ContextDecl = ReadDeclID();
1719 Lambda.Captures = (
Capture *)Reader.getContext().Allocate(
1720 sizeof(
Capture) * Lambda.NumCaptures);
1721 Capture *ToCapture = Lambda.Captures;
1722 Lambda.MethodTyInfo = GetTypeSourceInfo();
1723 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
1725 bool IsImplicit = Record.readInt();
1735 auto *Var = ReadDeclAs<VarDecl>();
1737 *ToCapture++ =
Capture(Loc, IsImplicit,
Kind, Var, EllipsisLoc);
1744 void ASTDeclReader::MergeDefinitionData(
1745 CXXRecordDecl *D,
struct CXXRecordDecl::DefinitionData &&MergeDD) {
1746 assert(D->DefinitionData &&
1747 "merging class definition into non-definition");
1748 auto &DD = *D->DefinitionData;
1750 if (DD.Definition != MergeDD.Definition) {
1752 Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition,
1754 Reader.PendingDefinitions.erase(MergeDD.Definition);
1755 MergeDD.Definition->setCompleteDefinition(
false);
1756 Reader.mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
1757 assert(Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() &&
1758 "already loaded pending lookups for merged definition");
1761 auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
1762 if (PFDI != Reader.PendingFakeDefinitionData.end() &&
1763 PFDI->second == ASTReader::PendingFakeDefinitionKind::Fake) {
1766 assert(!DD.IsLambda && !MergeDD.IsLambda &&
"faked up lambda definition?");
1767 PFDI->second = ASTReader::PendingFakeDefinitionKind::FakeLoaded;
1771 auto *Def = DD.Definition;
1772 DD = std::move(MergeDD);
1773 DD.Definition = Def;
1778 bool DetectedOdrViolation =
false;
1779 #define OR_FIELD(Field) DD.Field |= MergeDD.Field; 1780 #define MATCH_FIELD(Field) \ 1781 DetectedOdrViolation |= DD.Field != MergeDD.Field; \ 1805 MATCH_FIELD(NeedOverloadResolutionForCopyConstructor)
1806 MATCH_FIELD(NeedOverloadResolutionForMoveConstructor)
1807 MATCH_FIELD(NeedOverloadResolutionForMoveAssignment)
1814 OR_FIELD(HasTrivialSpecialMembersForCall)
1815 OR_FIELD(DeclaredNonTrivialSpecialMembers)
1816 OR_FIELD(DeclaredNonTrivialSpecialMembersForCall)
1818 OR_FIELD(HasConstexprNonCopyMoveConstructor)
1819 OR_FIELD(HasDefaultedDefaultConstructor)
1820 MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr)
1821 OR_FIELD(HasConstexprDefaultConstructor)
1826 MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForVBase)
1827 MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForNonVBase)
1829 OR_FIELD(HasDeclaredCopyConstructorWithConstParam)
1830 OR_FIELD(HasDeclaredCopyAssignmentWithConstParam)
1835 if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases)
1836 DetectedOdrViolation =
true;
1842 if (MergeDD.ComputedVisibleConversions && !DD.ComputedVisibleConversions) {
1843 DD.VisibleConversions = std::move(MergeDD.VisibleConversions);
1844 DD.ComputedVisibleConversions =
true;
1856 DetectedOdrViolation =
true;
1859 if (DetectedOdrViolation)
1860 Reader.PendingOdrMergeFailures[DD.Definition].push_back(
1861 {MergeDD.Definition, &MergeDD});
1865 struct CXXRecordDecl::DefinitionData *DD;
1870 bool IsLambda = Record.readInt();
1872 DD =
new (
C) CXXRecordDecl::LambdaDefinitionData(D,
nullptr,
false,
false,
1875 DD =
new (
C)
struct CXXRecordDecl::DefinitionData(D);
1881 if (!Canon->DefinitionData)
1882 Canon->DefinitionData = DD;
1883 D->DefinitionData = Canon->DefinitionData;
1884 ReadCXXDefinitionData(*DD, D);
1889 if (Canon->DefinitionData != DD) {
1890 MergeDefinitionData(Canon, std::move(*DD));
1900 if (Update || Canon != D)
1901 Reader.PendingDefinitions.insert(D);
1904 ASTDeclReader::RedeclarableResult
1906 RedeclarableResult Redecl = VisitRecordDeclImpl(D);
1911 CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1913 switch ((CXXRecKind)Record.readInt()) {
1914 case CXXRecNotTemplate:
1916 if (!isa<ClassTemplateSpecializationDecl>(D))
1917 mergeRedeclarable(D, Redecl);
1919 case CXXRecTemplate: {
1921 auto *Template = ReadDeclAs<ClassTemplateDecl>();
1922 D->TemplateOrInstantiation = Template;
1923 if (!Template->getTemplatedDecl()) {
1934 case CXXRecMemberSpecialization: {
1935 auto *RD = ReadDeclAs<CXXRecordDecl>();
1940 D->TemplateOrInstantiation = MSI;
1941 mergeRedeclarable(D, Redecl);
1946 bool WasDefinition = Record.readInt();
1948 ReadCXXRecordDefinition(D,
false);
1955 if (WasDefinition) {
1956 DeclID KeyFn = ReadDeclID();
1961 C.KeyFunctions[D] = KeyFn;
1968 VisitFunctionDecl(D);
1973 VisitFunctionDecl(D);
1975 unsigned NumOverridenMethods = Record.readInt();
1977 while (NumOverridenMethods--) {
1980 if (
auto *MD = ReadDeclAs<CXXMethodDecl>())
1986 Record.skipInts(NumOverridenMethods);
1994 auto *Shadow = ReadDeclAs<ConstructorUsingShadowDecl>();
1995 auto *Ctor = ReadDeclAs<CXXConstructorDecl>();
2000 VisitCXXMethodDecl(D);
2004 VisitCXXMethodDecl(D);
2006 if (
auto *OperatorDelete = ReadDeclAs<FunctionDecl>()) {
2008 auto *ThisArg = Record.readExpr();
2010 if (!Canon->OperatorDelete) {
2011 Canon->OperatorDelete = OperatorDelete;
2012 Canon->OperatorDeleteThisArg = ThisArg;
2018 VisitCXXMethodDecl(D);
2023 D->ImportedAndComplete.setPointer(readModule());
2024 D->ImportedAndComplete.setInt(Record.readInt());
2026 for (
unsigned I = 0, N = Record.back(); I != N; ++I)
2027 StoredLocs[I] = ReadSourceLocation();
2038 if (Record.readInt())
2039 D->Friend = ReadDeclAs<NamedDecl>();
2041 D->Friend = GetTypeSourceInfo();
2042 for (
unsigned i = 0; i != D->NumTPLists; ++i)
2044 Record.readTemplateParameterList();
2045 D->NextFriend = ReadDeclID();
2046 D->UnsupportedFriend = (Record.readInt() != 0);
2047 D->FriendLoc = ReadSourceLocation();
2052 unsigned NumParams = Record.readInt();
2053 D->NumParams = NumParams;
2055 for (
unsigned i = 0; i != NumParams; ++i)
2056 D->Params[i] = Record.readTemplateParameterList();
2057 if (Record.readInt())
2058 D->Friend = ReadDeclAs<NamedDecl>();
2060 D->Friend = GetTypeSourceInfo();
2061 D->FriendLoc = ReadSourceLocation();
2067 DeclID PatternID = ReadDeclID();
2068 auto *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
2071 D->
init(TemplatedDecl, TemplateParams);
2076 ASTDeclReader::RedeclarableResult
2078 RedeclarableResult Redecl = VisitRedeclarable(D);
2085 Reader.PendingDefinitions.insert(CanonD);
2091 if (ThisDeclID == Redecl.getFirstID()) {
2092 if (
auto *RTD = ReadDeclAs<RedeclarableTemplateDecl>()) {
2093 assert(RTD->getKind() == D->
getKind() &&
2094 "InstantiatedFromMemberTemplate kind mismatch");
2096 if (Record.readInt())
2101 DeclID PatternID = VisitTemplateDecl(D);
2104 mergeRedeclarable(D, Redecl, PatternID);
2115 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2117 if (ThisDeclID == Redecl.getFirstID()) {
2121 ReadDeclIDList(SpecIDs);
2129 Reader.getContext().getInjectedClassNameType(
2135 llvm_unreachable(
"BuiltinTemplates are not serialized");
2142 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2144 if (ThisDeclID == Redecl.getFirstID()) {
2148 ReadDeclIDList(SpecIDs);
2153 ASTDeclReader::RedeclarableResult
2156 RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D);
2159 if (
Decl *InstD = ReadDecl()) {
2160 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
2161 D->SpecializedTemplate = CTD;
2164 Record.readTemplateArgumentList(TemplArgs);
2169 SpecializedPartialSpecialization();
2170 PS->PartialSpecialization
2171 = cast<ClassTemplatePartialSpecializationDecl>(InstD);
2172 PS->TemplateArgs = ArgList;
2173 D->SpecializedTemplate = PS;
2178 Record.readTemplateArgumentList(TemplArgs,
true);
2180 D->PointOfInstantiation = ReadSourceLocation();
2183 bool writtenAsCanonicalDecl = Record.readInt();
2184 if (writtenAsCanonicalDecl) {
2185 auto *CanonPattern = ReadDeclAs<ClassTemplateDecl>();
2189 if (
auto *Partial = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
2190 CanonSpec = CanonPattern->getCommonPtr()->PartialSpecializations
2191 .GetOrInsertNode(Partial);
2194 CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2197 if (CanonSpec != D) {
2198 mergeRedeclarable<TagDecl>(D, CanonSpec, Redecl);
2202 if (
auto *DDD = D->DefinitionData) {
2203 if (CanonSpec->DefinitionData)
2204 MergeDefinitionData(CanonSpec, std::move(*DDD));
2206 CanonSpec->DefinitionData = D->DefinitionData;
2208 D->DefinitionData = CanonSpec->DefinitionData;
2215 auto *ExplicitInfo =
2216 new (
C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
2217 ExplicitInfo->TypeAsWritten = TyInfo;
2218 ExplicitInfo->ExternLoc = ReadSourceLocation();
2219 ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation();
2220 D->ExplicitInfo = ExplicitInfo;
2228 RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
2230 D->TemplateParams = Record.readTemplateParameterList();
2231 D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2234 if (ThisDeclID == Redecl.getFirstID()) {
2235 D->InstantiatedFromMember.setPointer(
2236 ReadDeclAs<ClassTemplatePartialSpecializationDecl>());
2237 D->InstantiatedFromMember.setInt(Record.readInt());
2244 D->Specialization = ReadDeclAs<CXXMethodDecl>();
2248 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2250 if (ThisDeclID == Redecl.getFirstID()) {
2253 ReadDeclIDList(SpecIDs);
2263 ASTDeclReader::RedeclarableResult
2266 RedeclarableResult Redecl = VisitVarDeclImpl(D);
2269 if (
Decl *InstD = ReadDecl()) {
2270 if (
auto *VTD = dyn_cast<VarTemplateDecl>(InstD)) {
2271 D->SpecializedTemplate = VTD;
2274 Record.readTemplateArgumentList(TemplArgs);
2279 VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
2280 PS->PartialSpecialization =
2281 cast<VarTemplatePartialSpecializationDecl>(InstD);
2282 PS->TemplateArgs = ArgList;
2283 D->SpecializedTemplate = PS;
2289 auto *ExplicitInfo =
2290 new (
C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo;
2291 ExplicitInfo->TypeAsWritten = TyInfo;
2292 ExplicitInfo->ExternLoc = ReadSourceLocation();
2293 ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation();
2294 D->ExplicitInfo = ExplicitInfo;
2298 Record.readTemplateArgumentList(TemplArgs,
true);
2300 D->PointOfInstantiation = ReadSourceLocation();
2302 D->IsCompleteDefinition = Record.readInt();
2304 bool writtenAsCanonicalDecl = Record.readInt();
2305 if (writtenAsCanonicalDecl) {
2306 auto *CanonPattern = ReadDeclAs<VarTemplateDecl>();
2309 if (
auto *Partial = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
2310 CanonPattern->getCommonPtr()->PartialSpecializations
2311 .GetOrInsertNode(Partial);
2313 CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2328 RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
2330 D->TemplateParams = Record.readTemplateParameterList();
2331 D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2334 if (ThisDeclID == Redecl.getFirstID()) {
2335 D->InstantiatedFromMember.setPointer(
2336 ReadDeclAs<VarTemplatePartialSpecializationDecl>());
2337 D->InstantiatedFromMember.setInt(Record.readInt());
2346 if (Record.readInt())
2351 VisitDeclaratorDecl(D);
2356 auto TypesAndInfos =
2357 D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
2359 new (&TypesAndInfos[I].first)
QualType(Record.readType());
2360 TypesAndInfos[I].second = GetTypeSourceInfo();
2364 D->ParameterPack = Record.readInt();
2365 if (Record.readInt())
2371 VisitTemplateDecl(D);
2379 Data[I] = Record.readTemplateParameterList();
2382 D->ParameterPack = Record.readInt();
2383 if (Record.readInt())
2385 Record.readTemplateArgumentLoc());
2390 VisitRedeclarableTemplateDecl(D);
2395 D->AssertExprAndFailed.setPointer(Record.readExpr());
2396 D->AssertExprAndFailed.setInt(Record.readInt());
2397 D->Message = cast_or_null<StringLiteral>(Record.readExpr());
2398 D->RParenLoc = ReadSourceLocation();
2405 std::pair<uint64_t, uint64_t>
2407 uint64_t LexicalOffset = ReadLocalOffset();
2408 uint64_t VisibleOffset = ReadLocalOffset();
2409 return std::make_pair(LexicalOffset, VisibleOffset);
2412 template <
typename T>
2413 ASTDeclReader::RedeclarableResult
2415 DeclID FirstDeclID = ReadDeclID();
2416 Decl *MergeWith =
nullptr;
2418 bool IsKeyDecl = ThisDeclID == FirstDeclID;
2419 bool IsFirstLocalDecl =
false;
2421 uint64_t RedeclOffset = 0;
2425 if (FirstDeclID == 0) {
2426 FirstDeclID = ThisDeclID;
2428 IsFirstLocalDecl =
true;
2429 }
else if (
unsigned N = Record.readInt()) {
2433 IsFirstLocalDecl =
true;
2440 for (
unsigned I = 0; I != N - 1; ++I)
2441 MergeWith = ReadDecl();
2443 RedeclOffset = ReadLocalOffset();
2450 auto *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID));
2451 if (FirstDecl != D) {
2457 D->
First = FirstDecl->getCanonicalDecl();
2460 auto *DAsT =
static_cast<T *
>(D);
2466 if (IsFirstLocalDecl)
2467 Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset));
2469 return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl);
2474 template<
typename T>
2476 RedeclarableResult &Redecl,
2477 DeclID TemplatePatternID) {
2479 if (!Reader.getContext().getLangOpts().Modules)
2486 auto *D =
static_cast<T *
>(DBase);
2488 if (
auto *Existing = Redecl.getKnownMergeTarget())
2490 mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID);
2491 else if (FindExistingResult ExistingRes = findExisting(D))
2492 if (T *Existing = ExistingRes)
2493 mergeRedeclarable(D, Existing, Redecl, TemplatePatternID);
2501 llvm_unreachable(
"bad assert_cast");
2508 DeclID DsID,
bool IsKeyDecl) {
2511 RedeclarableResult Result( ExistingPattern,
2512 DPattern->getCanonicalDecl()->getGlobalID(),
2515 if (
auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) {
2518 auto *ExistingClass =
2520 if (
auto *DDD = DClass->DefinitionData) {
2521 if (ExistingClass->DefinitionData) {
2522 MergeDefinitionData(ExistingClass, std::move(*DDD));
2524 ExistingClass->DefinitionData = DClass->DefinitionData;
2527 Reader.PendingDefinitions.insert(DClass);
2530 DClass->DefinitionData = ExistingClass->DefinitionData;
2532 return mergeRedeclarable(DClass, cast<TagDecl>(ExistingPattern),
2535 if (
auto *DFunction = dyn_cast<FunctionDecl>(DPattern))
2536 return mergeRedeclarable(DFunction, cast<FunctionDecl>(ExistingPattern),
2538 if (
auto *DVar = dyn_cast<VarDecl>(DPattern))
2539 return mergeRedeclarable(DVar, cast<VarDecl>(ExistingPattern), Result);
2540 if (
auto *DAlias = dyn_cast<TypeAliasDecl>(DPattern))
2541 return mergeRedeclarable(DAlias, cast<TypedefNameDecl>(ExistingPattern),
2543 llvm_unreachable(
"merged an unknown kind of redeclarable template");
2548 template<
typename T>
2550 RedeclarableResult &Redecl,
2551 DeclID TemplatePatternID) {
2552 auto *D =
static_cast<T *
>(DBase);
2555 if (ExistingCanon != DCanon) {
2556 assert(DCanon->getGlobalID() == Redecl.getFirstID() &&
2557 "already merged this declaration");
2563 D->
First = ExistingCanon;
2564 ExistingCanon->Used |= D->Used;
2570 if (
auto *Namespace = dyn_cast<NamespaceDecl>(D))
2571 Namespace->AnonOrFirstNamespaceAndInline.setPointer(
2572 assert_cast<NamespaceDecl*>(ExistingCanon));
2575 if (
auto *DTemplate = dyn_cast<RedeclarableTemplateDecl>(D))
2576 mergeTemplatePattern(
2577 DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon),
2578 TemplatePatternID, Redecl.isKeyDecl());
2581 if (Redecl.isKeyDecl())
2582 Reader.KeyDecls[ExistingCanon].push_back(Redecl.getFirstID());
2595 if (isa<EnumConstantDecl>(ND))
2604 template<
typename T>
2607 if (!Reader.getContext().getLangOpts().Modules)
2614 if (!Reader.getContext().getLangOpts().CPlusPlus &&
2618 if (FindExistingResult ExistingRes = findExisting(static_cast<T*>(D)))
2619 if (T *Existing = ExistingRes)
2620 Reader.getContext().setPrimaryMergedDecl(static_cast<T *>(D),
2621 Existing->getCanonicalDecl());
2628 Vars.reserve(NumVars);
2629 for (
unsigned i = 0; i != NumVars; ++i) {
2630 Vars.push_back(Record.readExpr());
2639 Clauses.reserve(NumClauses);
2641 for (
unsigned I = 0; I != NumClauses; ++I)
2642 Clauses.push_back(ClauseReader.
readClause());
2643 D->setClauses(Clauses);
2649 Expr *In = Record.readExpr();
2650 Expr *Out = Record.readExpr();
2652 Expr *Combiner = Record.readExpr();
2654 Expr *Orig = Record.readExpr();
2655 Expr *Priv = Record.readExpr();
2657 Expr *Init = Record.readExpr();
2660 D->PrevDeclInScope = ReadDeclID();
2681 : F(&F), Reader(&Reader), Record(Record), Idx(Idx) {}
2683 const uint64_t &readInt() {
return Record[Idx++]; }
2691 std::string readString() {
2703 VersionTuple readVersionTuple() {
2707 template <
typename T> T *GetLocalDeclAs(uint32_t LocalID) {
2708 return cast_or_null<T>(Reader->
GetLocalDecl(*F, LocalID));
2715 AttrReader Record(M, *
this, Rec, Idx);
2716 auto V = Record.readInt();
2720 Attr *New =
nullptr;
2727 #include "clang/Serialization/AttrPCHRead.inc" 2729 assert(New &&
"Unable to decode attribute?");
2735 for (
unsigned I = 0, E = Record.
readInt(); I != E; ++I)
2736 Attrs.push_back(Record.
readAttr());
2749 inline void ASTReader::LoadedDecl(
unsigned Index,
Decl *D) {
2750 assert(!DeclsLoaded[Index] &&
"Decl loaded twice?");
2751 DeclsLoaded[Index] = D;
2766 if (isa<ImportDecl>(D) || isa<VarDecl>(D)) {
2773 if (isa<FileScopeAsmDecl>(D) ||
2774 isa<ObjCProtocolDecl>(D) ||
2775 isa<ObjCImplDecl>(D) ||
2776 isa<ImportDecl>(D) ||
2777 isa<PragmaCommentDecl>(D) ||
2778 isa<PragmaDetectMismatchDecl>(D))
2780 if (isa<OMPThreadPrivateDecl>(D) || isa<OMPDeclareReductionDecl>(D))
2782 if (
const auto *Var = dyn_cast<VarDecl>(D))
2783 return Var->isFileVarDecl() &&
2785 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Var));
2786 if (
const auto *Func = dyn_cast<FunctionDecl>(D))
2787 return Func->doesThisDeclarationHaveABody() || HasBody;
2797 ASTReader::RecordLocation
2799 GlobalDeclMapType::iterator I = GlobalDeclMap.find(
ID);
2800 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
2804 Loc = TranslateSourceLocation(*M, DOffs.
getLocation());
2805 return RecordLocation(M, DOffs.
BitOffset);
2808 ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
2809 auto I = GlobalBitOffsetsMap.find(GlobalOffset);
2811 assert(I != GlobalBitOffsetsMap.end() &&
"Corrupted global bit offsets map");
2812 return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
2815 uint64_t ASTReader::getGlobalBitOffset(
ModuleFile &M, uint32_t LocalOffset) {
2829 if (
const auto *TX = dyn_cast<TemplateTypeParmDecl>(X)) {
2830 const auto *TY = cast<TemplateTypeParmDecl>(Y);
2831 return TX->isParameterPack() == TY->isParameterPack();
2834 if (
const auto *TX = dyn_cast<NonTypeTemplateParmDecl>(X)) {
2835 const auto *TY = cast<NonTypeTemplateParmDecl>(Y);
2836 return TX->isParameterPack() == TY->isParameterPack() &&
2837 TX->getASTContext().hasSameType(TX->getType(), TY->getType());
2840 const auto *TX = cast<TemplateTemplateParmDecl>(
X);
2841 const auto *TY = cast<TemplateTemplateParmDecl>(Y);
2842 return TX->isParameterPack() == TY->isParameterPack() &&
2844 TY->getTemplateParameters());
2851 return NAS->getNamespace();
2859 if (!NSY || NSX->getCanonicalDecl() != NSY->getCanonicalDecl())
2901 for (
unsigned I = 0, N = X->
size(); I != N; ++I)
2915 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
2919 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
2924 if (!Cand1A || !Cand2A)
2930 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
2931 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
2935 if (Cand1ID != Cand2ID)
2959 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(X))
2960 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
2962 TypedefY->getUnderlyingType());
2969 if (isa<ObjCInterfaceDecl>(X) || isa<ObjCProtocolDecl>(
X))
2972 if (isa<ClassTemplateSpecializationDecl>(X)) {
2979 if (
const auto *TagX = dyn_cast<TagDecl>(X)) {
2980 const auto *TagY = cast<TagDecl>(Y);
2981 return (TagX->getTagKind() == TagY->getTagKind()) ||
2991 if (
const auto *FuncX = dyn_cast<FunctionDecl>(X)) {
2992 const auto *FuncY = cast<FunctionDecl>(Y);
2993 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(X)) {
2994 const auto *CtorY = cast<CXXConstructorDecl>(Y);
2995 if (CtorX->getInheritedConstructor() &&
2996 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
2997 CtorY->getInheritedConstructor().getConstructor()))
3001 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
3006 if (FuncX->isMultiVersion()) {
3007 const auto *TAX = FuncX->getAttr<TargetAttr>();
3008 const auto *TAY = FuncY->getAttr<TargetAttr>();
3009 assert(TAX && TAY &&
"Multiversion Function without target attribute");
3011 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
3021 FD = FD->getCanonicalDecl();
3022 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
3025 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
3032 if (C.
getLangOpts().CPlusPlus17 && XFPT && YFPT &&
3039 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
3044 if (
const auto *VarX = dyn_cast<VarDecl>(X)) {
3045 const auto *VarY = cast<VarDecl>(Y);
3046 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
3048 if (C.
hasSameType(VarX->getType(), VarY->getType()))
3058 if (!VarXTy || !VarYTy)
3067 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(X)) {
3068 const auto *NamespaceY = cast<NamespaceDecl>(Y);
3069 return NamespaceX->isInline() == NamespaceY->isInline();
3074 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(X)) {
3075 const auto *TemplateY = cast<TemplateDecl>(Y);
3077 TemplateY->getTemplatedDecl()) &&
3079 TemplateY->getTemplateParameters());
3083 if (
const auto *FDX = dyn_cast<FieldDecl>(X)) {
3084 const auto *FDY = cast<FieldDecl>(Y);
3090 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(X)) {
3091 const auto *IFDY = cast<IndirectFieldDecl>(Y);
3092 return IFDX->getAnonField()->getCanonicalDecl() ==
3093 IFDY->getAnonField()->getCanonicalDecl();
3097 if (isa<EnumConstantDecl>(X))
3102 if (
const auto *USX = dyn_cast<UsingShadowDecl>(X)) {
3103 const auto *USY = cast<UsingShadowDecl>(Y);
3104 return USX->getTargetDecl() == USY->getTargetDecl();
3109 if (
const auto *UX = dyn_cast<UsingDecl>(X)) {
3110 const auto *UY = cast<UsingDecl>(Y);
3112 UX->hasTypename() == UY->hasTypename() &&
3113 UX->isAccessDeclaration() == UY->isAccessDeclaration();
3115 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(X)) {
3116 const auto *UY = cast<UnresolvedUsingValueDecl>(Y);
3118 UX->isAccessDeclaration() == UY->isAccessDeclaration();
3120 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(X))
3123 cast<UnresolvedUsingTypenameDecl>(Y)->getQualifier());
3126 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(X)) {
3127 const auto *NAY = cast<NamespaceAliasDecl>(Y);
3128 return NAX->getNamespace()->Equals(NAY->getNamespace());
3138 if (
auto *ND = dyn_cast<NamespaceDecl>(DC))
3139 return ND->getOriginalNamespace();
3141 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
3143 auto *DD = RD->DefinitionData;
3145 DD = RD->getCanonicalDecl()->DefinitionData;
3152 DD =
new (Reader.
getContext())
struct CXXRecordDecl::DefinitionData(RD);
3153 RD->setCompleteDefinition(
true);
3154 RD->DefinitionData = DD;
3155 RD->getCanonicalDecl()->DefinitionData = DD;
3158 Reader.PendingFakeDefinitionData.insert(
3159 std::make_pair(DD, ASTReader::PendingFakeDefinitionKind::Fake));
3162 return DD->Definition;
3165 if (
auto *ED = dyn_cast<EnumDecl>(DC))
3166 return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition()
3171 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
3177 ASTDeclReader::FindExistingResult::~FindExistingResult() {
3180 if (TypedefNameForLinkage) {
3182 Reader.ImportedTypedefNamesForLinkage.insert(
3183 std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New));
3187 if (!AddResult || Existing)
3193 setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
3194 AnonymousDeclNumber, New);
3200 }
else if (
DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
3203 MergeDC->makeDeclVisibleInContextImpl(New,
true);
3211 bool IsTypedefNameForLinkage) {
3212 if (!IsTypedefNameForLinkage)
3221 if (
auto *TND = dyn_cast<TypedefNameDecl>(Found))
3222 return TND->getAnonDeclWithTypedefName(
true);
3231 ASTDeclReader::getPrimaryDCForAnonymousDecl(
DeclContext *LexicalDC) {
3233 if (
auto *RD = dyn_cast<CXXRecordDecl>(LexicalDC)) {
3234 auto *DD = RD->getCanonicalDecl()->DefinitionData;
3235 return DD ? DD->Definition :
nullptr;
3242 if (
auto *FD = dyn_cast<FunctionDecl>(D))
3243 if (FD->isThisDeclarationADefinition())
3245 if (
auto *MD = dyn_cast<ObjCMethodDecl>(D))
3246 if (MD->isThisDeclarationADefinition())
3262 auto &
Previous = Reader.AnonymousDeclarationsForMerging[CanonDC];
3268 auto *PrimaryDC = getPrimaryDCForAnonymousDecl(DC);
3269 if (PrimaryDC && !cast<Decl>(PrimaryDC)->isFromASTFile()) {
3281 void ASTDeclReader::setAnonymousDeclForMerging(
ASTReader &Reader,
3286 auto &
Previous = Reader.AnonymousDeclarationsForMerging[CanonDC];
3293 ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(
NamedDecl *D) {
3300 FindExistingResult Result(Reader, D,
nullptr,
3301 AnonymousDeclNumber, TypedefNameForLinkage);
3307 if (TypedefNameForLinkage) {
3308 auto It = Reader.ImportedTypedefNamesForLinkage.find(
3309 std::make_pair(DC, TypedefNameForLinkage));
3310 if (It != Reader.ImportedTypedefNamesForLinkage.end())
3312 return FindExistingResult(Reader, D, It->second, AnonymousDeclNumber,
3313 TypedefNameForLinkage);
3321 if (
auto *Existing = getAnonymousDeclForMerging(
3324 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3325 TypedefNameForLinkage);
3332 class UpToDateIdentifierRAII {
3334 bool WasOutToDate =
false;
3345 ~UpToDateIdentifierRAII() {
3352 IEnd = IdResolver.
end();
3356 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3357 TypedefNameForLinkage);
3359 }
else if (
DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
3364 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3365 TypedefNameForLinkage);
3369 return FindExistingResult(Reader);
3378 if (MergedDCIt != Reader.MergedDeclContexts.end() &&
3380 Reader.PendingOdrMergeChecks.push_back(D);
3382 return FindExistingResult(Reader, D,
nullptr,
3383 AnonymousDeclNumber, TypedefNameForLinkage);
3386 template<
typename DeclT>
3392 llvm_unreachable(
"getMostRecentDecl on non-redeclarable declaration");
3399 #define ABSTRACT_DECL(TYPE) 3400 #define DECL(TYPE, BASE) \ 3402 return getMostRecentDeclImpl(cast<TYPE##Decl>(D)); 3403 #include "clang/AST/DeclNodes.inc" 3405 llvm_unreachable(
"unknown decl kind");
3408 Decl *ASTReader::getMostRecentExistingDecl(
Decl *D) {
3412 template<
typename DeclT>
3416 D->
RedeclLink.setPrevious(cast<DeclT>(Previous));
3426 auto *VD =
static_cast<VarDecl *
>(D);
3427 auto *PrevVD = cast<VarDecl>(
Previous);
3438 VD->demoteThisDefinitionToDeclaration();
3455 auto *PrevFD = cast<FunctionDecl>(
Previous);
3458 FD->First = PrevFD->First;
3462 if (PrevFD->isInlined() != FD->isInlined()) {
3478 FD->setImplicitlyInline(
true);
3483 if (FPT && PrevFPT) {
3487 bool WasUnresolved =
3489 if (IsUnresolved != WasUnresolved)
3490 Reader.PendingExceptionSpecUpdates.insert(
3491 {Canon, IsUnresolved ? PrevFD : FD});
3497 if (IsUndeduced != WasUndeduced)
3498 Reader.PendingDeducedTypeUpdates.insert(
3499 {cast<FunctionDecl>(Canon),
3500 (IsUndeduced ? PrevFPT : FPT)->getReturnType()});
3507 llvm_unreachable(
"attachPreviousDecl on non-redeclarable declaration");
3512 template <
typename ParmDecl>
3515 auto *To = cast<ParmDecl>(ToD);
3516 if (!From->hasDefaultArgument())
3518 To->setInheritedDefaultArgument(Context, From);
3527 assert(FromTP->size() == ToTP->size() &&
"merged mismatched templates?");
3529 for (
unsigned I = 0, N = FromTP->size(); I != N; ++I) {
3530 NamedDecl *FromParam = FromTP->getParam(I);
3533 if (
auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam))
3535 else if (
auto *FNTTP = dyn_cast<NonTypeTemplateParmDecl>(FromParam))
3539 Context, cast<TemplateTemplateParmDecl>(FromParam), ToParam);
3545 assert(D && Previous);
3548 #define ABSTRACT_DECL(TYPE) 3549 #define DECL(TYPE, BASE) \ 3551 attachPreviousDeclImpl(Reader, cast<TYPE##Decl>(D), Previous, Canon); \ 3553 #include "clang/AST/DeclNodes.inc" 3567 if (
auto *TD = dyn_cast<TemplateDecl>(D))
3572 template<
typename DeclT>
3574 D->
RedeclLink.setLatest(cast<DeclT>(Latest));
3578 llvm_unreachable(
"attachLatestDecl on non-redeclarable declaration");
3582 assert(D && Latest);
3585 #define ABSTRACT_DECL(TYPE) 3586 #define DECL(TYPE, BASE) \ 3588 attachLatestDeclImpl(cast<TYPE##Decl>(D), Latest); \ 3590 #include "clang/AST/DeclNodes.inc" 3594 template<
typename DeclT>
3600 llvm_unreachable(
"markIncompleteDeclChain on non-redeclarable declaration");
3603 void ASTReader::markIncompleteDeclChain(
Decl *D) {
3605 #define ABSTRACT_DECL(TYPE) 3606 #define DECL(TYPE, BASE) \ 3608 ASTDeclReader::markIncompleteDeclChainImpl(cast<TYPE##Decl>(D)); \ 3610 #include "clang/AST/DeclNodes.inc" 3618 RecordLocation Loc = DeclCursorForID(ID, DeclLoc);
3619 llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
3624 ReadingKindTracker ReadingKind(Read_Decl, *
this);
3627 Deserializing ADecl(
this);
3629 DeclsCursor.JumpToBit(Loc.Offset);
3632 unsigned Code = DeclsCursor.ReadCode();
3639 llvm_unreachable(
"Record cannot be de-serialized with ReadDeclRecord");
3838 Error(
"attempt to read a C++ base-specifier record as a declaration");
3841 Error(
"attempt to read a C++ ctor initializer record as a declaration");
3875 assert(D &&
"Unknown declaration reading AST file");
3876 LoadedDecl(Index, D);
3885 if (
auto *DC = dyn_cast<DeclContext>(D)) {
3887 if (Offsets.first &&
3888 ReadLexicalDeclContextStorage(*Loc.F, DeclsCursor, Offsets.first, DC))
3890 if (Offsets.second &&
3891 ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID))
3897 PendingUpdateRecords.push_back(
3898 PendingUpdateRecord(ID, D,
true));
3901 if (
auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
3904 if (Class->isThisDeclarationADefinition() ||
3905 PendingDefinitions.count(Class))
3906 loadObjCCategories(ID, Class);
3912 PotentiallyInterestingDecls.push_back(
3918 void ASTReader::PassInterestingDeclsToConsumer() {
3921 if (PassingDeclsToConsumer)
3931 for (
auto ID : EagerlyDeserializedDecls)
3933 EagerlyDeserializedDecls.clear();
3935 while (!PotentiallyInterestingDecls.empty()) {
3936 InterestingDecl D = PotentiallyInterestingDecls.front();
3937 PotentiallyInterestingDecls.pop_front();
3939 PassInterestingDeclToConsumer(D.getDecl());
3943 void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
3949 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
3950 DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
3954 if (UpdI != DeclUpdateOffsets.end()) {
3955 auto UpdateOffsets = std::move(UpdI->second);
3956 DeclUpdateOffsets.erase(UpdI);
3962 bool WasInteresting =
3964 for (
auto &FileAndOffset : UpdateOffsets) {
3966 uint64_t
Offset = FileAndOffset.second;
3969 Cursor.JumpToBit(Offset);
3970 unsigned Code = Cursor.ReadCode();
3972 unsigned RecCode = Record.
readRecord(Cursor, Code);
3974 assert(RecCode ==
DECL_UPDATES &&
"Expected DECL_UPDATES record!");
3976 ASTDeclReader Reader(*
this, Record, RecordLocation(F, Offset), ID,
3978 Reader.
UpdateDecl(D, PendingLazySpecializationIDs);
3982 if (!WasInteresting &&
3984 PotentiallyInterestingDecls.push_back(
3986 WasInteresting =
true;
3991 assert((PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) ||
3992 isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) &&
3993 "Must not have pending specializations");
3994 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(D))
3996 else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
3998 else if (
auto *VTD = dyn_cast<VarTemplateDecl>(D))
4000 PendingLazySpecializationIDs.clear();
4003 auto I = PendingVisibleUpdates.find(ID);
4004 if (I != PendingVisibleUpdates.end()) {
4005 auto VisibleUpdates = std::move(I->second);
4006 PendingVisibleUpdates.erase(I);
4008 auto *DC = cast<DeclContext>(D)->getPrimaryContext();
4009 for (
const auto &
Update : VisibleUpdates)
4010 Lookups[DC].Table.add(
4017 void ASTReader::loadPendingDeclChain(
Decl *FirstLocal, uint64_t LocalOffset) {
4020 if (FirstLocal != CanonDecl) {
4023 *
this, FirstLocal, PrevMostRecent ? PrevMostRecent : CanonDecl,
4033 ModuleFile *M = getOwningModuleFile(FirstLocal);
4034 assert(M &&
"imported decl from no module file");
4038 Cursor.JumpToBit(LocalOffset);
4041 unsigned Code = Cursor.ReadCode();
4042 unsigned RecCode = Cursor.readRecord(Code, Record);
4048 Decl *MostRecent = FirstLocal;
4049 for (
unsigned I = 0, N = Record.size(); I != N; ++I) {
4050 auto *D = GetLocalDecl(*M, Record[N - I - 1]);
4061 class ObjCCategoriesVisitor {
4064 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized;
4066 llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap;
4068 unsigned PreviousGeneration;
4072 if (!Deserialized.erase(Cat))
4095 }
else if (!Existing) {
4110 ObjCCategoriesVisitor(
ASTReader &Reader,
4112 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
4114 unsigned PreviousGeneration)
4115 : Reader(Reader), Interface(Interface), Deserialized(Deserialized),
4116 InterfaceID(InterfaceID), PreviousGeneration(PreviousGeneration) {
4159 for (
unsigned I = 0; I != N; ++I)
4160 add(cast_or_null<ObjCCategoryDecl>(
4170 unsigned PreviousGeneration) {
4171 ObjCCategoriesVisitor Visitor(*
this, D, CategoriesDeserialized,
ID,
4172 PreviousGeneration);
4173 ModuleMgr.visit(Visitor);
4176 template<
typename DeclT,
typename Fn>
4183 auto *MostRecent = D->getMostRecentDecl();
4185 for (
auto *Redecl = MostRecent; Redecl && !Found;
4186 Redecl = Redecl->getPreviousDecl())
4187 Found = (Redecl == D);
4191 for (
auto *Redecl = MostRecent; Redecl != D;
4192 Redecl = Redecl->getPreviousDecl())
4199 while (Record.getIdx() < Record.size()) {
4202 auto *RD = cast<CXXRecordDecl>(D);
4205 Decl *MD = Record.readDecl();
4206 assert(MD &&
"couldn't read decl from update record");
4209 RD->addedMember(MD);
4215 PendingLazySpecializationIDs.push_back(ReadDeclID());
4219 auto *Anon = ReadDeclAs<NamespaceDecl>();
4224 if (!Record.isModule()) {
4225 if (
auto *TU = dyn_cast<TranslationUnitDecl>(D))
4226 TU->setAnonymousNamespace(Anon);
4228 cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
4234 auto *VD = cast<VarDecl>(D);
4235 VD->NonParmVarDeclBits.IsInline = Record.readInt();
4236 VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
4237 uint64_t Val = Record.readInt();
4238 if (Val && !VD->getInit()) {
4239 VD->setInit(Record.readExpr());
4243 Eval->
IsICE = Val == 3;
4251 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D)) {
4252 VTSD->setPointOfInstantiation(POI);
4253 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
4254 VD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
4256 auto *FD = cast<FunctionDecl>(D);
4257 if (
auto *FTSInfo = FD->TemplateOrSpecialization
4259 FTSInfo->setPointOfInstantiation(POI);
4262 ->setPointOfInstantiation(POI);
4268 auto *Param = cast<ParmVarDecl>(D);
4273 auto *DefaultArg = Record.readExpr();
4277 if (Param->hasUninstantiatedDefaultArg())
4278 Param->setDefaultArg(DefaultArg);
4283 auto *FD = cast<FieldDecl>(D);
4284 auto *DefaultInit = Record.readExpr();
4288 if (FD->hasInClassInitializer() && !FD->getInClassInitializer()) {
4290 FD->setInClassInitializer(DefaultInit);
4294 FD->removeInClassInitializer();
4300 auto *FD = cast<FunctionDecl>(D);
4301 if (Reader.PendingBodies[FD]) {
4307 if (Record.readInt()) {
4315 FD->setInnerLocStart(ReadSourceLocation());
4316 ReadFunctionDefinition(FD);
4317 assert(Record.getIdx() == Record.size() &&
"lazy body must be last");
4322 auto *RD = cast<CXXRecordDecl>(D);
4323 auto *OldDD = RD->getCanonicalDecl()->DefinitionData;
4324 bool HadRealDefinition =
4325 OldDD && (OldDD->Definition != RD ||
4326 !Reader.PendingFakeDefinitionData.count(OldDD));
4327 RD->setParamDestroyedInCallee(Record.readInt());
4328 RD->setArgPassingRestrictions(
4330 ReadCXXRecordDefinition(RD,
true);
4333 uint64_t LexicalOffset = ReadLocalOffset();
4334 if (!HadRealDefinition && LexicalOffset) {
4335 Record.readLexicalDeclContextStorage(LexicalOffset, RD);
4336 Reader.PendingFakeDefinitionData.erase(OldDD);
4342 RD->getMemberSpecializationInfo()) {
4343 MSInfo->setTemplateSpecializationKind(TSK);
4344 MSInfo->setPointOfInstantiation(POI);
4346 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
4347 Spec->setTemplateSpecializationKind(TSK);
4348 Spec->setPointOfInstantiation(POI);
4350 if (Record.readInt()) {
4352 ReadDeclAs<ClassTemplatePartialSpecializationDecl>();
4354 Record.readTemplateArgumentList(TemplArgs);
4360 if (!Spec->getSpecializedTemplateOrPartial()
4362 Spec->setInstantiationOf(PartialSpec, TemplArgList);
4367 RD->setLocation(ReadSourceLocation());
4368 RD->setLocStart(ReadSourceLocation());
4369 RD->setBraceRange(ReadSourceRange());
4371 if (Record.readInt()) {
4373 Record.readAttributes(Attrs);
4385 auto *Del = ReadDeclAs<FunctionDecl>();
4387 auto *ThisArg = Record.readExpr();
4389 if (!First->OperatorDelete) {
4390 First->OperatorDelete = Del;
4391 First->OperatorDeleteThisArg = ThisArg;
4399 Record.readExceptionSpec(ExceptionStorage, ESI);
4402 auto *FD = cast<FunctionDecl>(D);
4408 FPT->getReturnType(), FPT->getParamTypes(),
4409 FPT->getExtProtoInfo().withExceptionSpec(ESI)));
4413 Reader.PendingExceptionSpecUpdates.insert(
4414 std::make_pair(FD->getCanonicalDecl(), FD));
4420 auto *FD = cast<FunctionDecl>(D);
4421 QualType DeducedResultType = Record.readType();
4422 Reader.PendingDeducedTypeUpdates.insert(
4423 {FD->getCanonicalDecl(), DeducedResultType});
4444 ReadSourceRange()));
4449 auto *Exported = cast<NamedDecl>(D);
4452 Reader.PendingMergedDefinitionsToDeduplicate.insert(Exported);
4457 D->
addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(
4459 static_cast<OMPDeclareTargetDeclAttr::MapTypeTy
>(Record.readInt()),
4460 ReadSourceRange()));
4465 Record.readAttributes(Attrs);
4466 assert(Attrs.size() == 1);
const uint64_t & readInt()
Returns the current value in this record, and advances to the next value.
RedeclarableResult VisitTypedefNameDecl(TypedefNameDecl *TD)
void VisitTypeDecl(TypeDecl *TD)
void setCategoryNameLoc(SourceLocation Loc)
A FriendTemplateDecl record.
void setHasSkippedBody(bool Skipped=true)
Defines the clang::ASTContext interface.
A NonTypeTemplateParmDecl record.
static bool isUndeducedReturnType(QualType T)
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
SourceLocation readSourceLocation()
Read a source location, advancing Idx.
void VisitClassScopeFunctionSpecializationDecl(ClassScopeFunctionSpecializationDecl *D)
static const Decl * getCanonicalDecl(const Decl *D)
void setImplicit(bool I=true)
Represents a function declaration or definition.
void setInitializerData(Expr *OrigE, Expr *PrivE)
Set initializer Orig and Priv vars.
void setNonTrivialToPrimitiveDestroy(bool V)
void VisitVarDecl(VarDecl *VD)
#define MATCH_FIELD(Field)
void setAnonymousStructOrUnion(bool Anon)
A class which contains all the information about a particular captured value.
static ImportDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
void VisitImportDecl(ImportDecl *D)
A (possibly-)qualified type.
void mergeMergeable(Mergeable< T > *D)
Attempts to merge the given declaration (D) with another declaration of the same entity, for the case where the entity is not actually redeclarable.
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
FunctionDecl * Function
The function template specialization that this structure describes.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
void VisitUsingDecl(UsingDecl *D)
static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static VarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setLParenLoc(SourceLocation L)
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...
void VisitFieldDecl(FieldDecl *FD)
void VisitImplicitParamDecl(ImplicitParamDecl *PD)
This declaration has an owning module, but is only visible to lookups that occur within that module...
An OMPThreadPrivateDecl record.
void setNonTrivialToPrimitiveDefaultInitialize(bool V)
void VisitObjCIvarDecl(ObjCIvarDecl *D)
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
void setExplicitSpecified(bool ExpSpec=true)
State that this function is marked as explicit explicitly.
FunctionType - C99 6.7.5.3 - Function Declarators.
static void setNextObjCCategory(ObjCCategoryDecl *Cat, ObjCCategoryDecl *Next)
bool IsICE
Whether this statement is an integral constant expression, or in C++11, whether the statement is a co...
RedeclarableResult VisitClassTemplateSpecializationDeclImpl(ClassTemplateSpecializationDecl *D)
An instance of this object exists for each enum constant that is defined.
void setEmbeddedInDeclarator(bool isInDeclarator)
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
No linkage, which means that the entity is unique and can only be referred to from within its scope...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
unsigned Generation
The generation of which this module file is a part.
static AccessSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Represents the declaration of a typedef-name via the 'typedef' type specifier.
C Language Family Type Representation.
void setParam(unsigned i, ImplicitParamDecl *P)
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
An OMPDeclareReductionDecl record.
void VisitEnumConstantDecl(EnumConstantDecl *ECD)
static void attachLatestDeclImpl(Redeclarable< DeclT > *D, Decl *Latest)
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Defines the clang::Module class, which describes a module in the source code.
Decl - This represents one declaration (or definition), e.g.
static NamedDecl * getDeclForMerging(NamedDecl *Found, bool IsTypedefNameForLinkage)
Find the declaration that should be merged into, given the declaration found by name lookup...
A VarTemplatePartialSpecializationDecl record.
void setArgPassingRestrictions(ArgPassingKind Kind)
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
void setPure(bool P=true)
static Decl * getMostRecentDecl(Decl *D)
known_categories_range known_categories() const
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
A record that stores the set of declarations that are lexically stored within a given DeclContext...
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
Represents an empty-declaration.
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
Class that performs name lookup into a DeclContext stored in an AST file.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
Represent a C++ namespace.
A ObjCPropertyDecl record.
void setPropertyImplementation(PropertyControl pc)
bool hasRedeclaration() const
True if redeclared in the same interface.
static bool hasSameOverloadableAttrs(const FunctionDecl *A, const FunctionDecl *B)
Determine whether the attributes we can overload on are identical for A and B.
NamedDecl * getParam(unsigned Idx)
static FriendDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned FriendTypeNumTPLists)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
void readQualifierInfo(QualifierInfo &Info)
void setPropertyAccessor(bool isAccessor)
static void inheritDefaultTemplateArguments(ASTContext &Context, TemplateDecl *From, TemplateDecl *To)
ASTDeclReader(ASTReader &Reader, ASTRecordReader &Record, ASTReader::RecordLocation Loc, DeclID thisDeclID, SourceLocation ThisDeclLoc)
Describes the capture of a variable or of this, or of a C++1y init-capture.
An OMPRequiresDecl record.
Represents a C++ constructor within a class.
This is a module that was defined by a module map and built out of header files.
static CapturedDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumParams)
QualType getElementType() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
A ClassTemplateDecl record.
void VisitStaticAssertDecl(StaticAssertDecl *D)
A PragmaDetectMismatchDecl record.
An UnresolvedUsingTypenameDecl record.
An identifier, stored as an IdentifierInfo*.
void setNothrow(bool Nothrow=true)
void setRAngleLoc(SourceLocation Loc)
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Represents a variable declaration or definition.
void VisitNamedDecl(NamedDecl *ND)
Declaration of a redeclarable template.
An OMPCapturedExprDecl record.
const T * getAs() const
Member-template getAs<specific type>'.
A UsingShadowDecl record.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
The "__interface" keyword.
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
A namespace, stored as a NamespaceDecl*.
void VisitClassTemplateDecl(ClassTemplateDecl *D)
Stores a list of template parameters for a TemplateDecl and its derived classes.
unsigned getODRHash() const
void setSelfDecl(ImplicitParamDecl *SD)
void VisitTypeAliasDecl(TypeAliasDecl *TD)
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
void setCombinerData(Expr *InE, Expr *OutE)
Set combiner In and Out vars.
A TemplateTemplateParmDecl record.
Represents a parameter to a function.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
A ObjCInterfaceDecl record.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
RedeclarableResult VisitTagDecl(TagDecl *TD)
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
static void attachPreviousDeclImpl(ASTReader &Reader, Redeclarable< DeclT > *D, Decl *Previous, Decl *Canon)
Types, declared with 'struct foo', typedefs, etc.
A CXXConstructorDecl record for an inherited constructor.
Represents a struct/union/class.
Description of a constructor that was inherited from a base class.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Provides common interface for the Decls that can be redeclared.
ObjCProtocolDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C protocol.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
void setIntegerType(QualType T)
Set the underlying integer type.
T * readDeclAs()
Reads a declaration from the given position in the record, advancing Idx.
void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D)
void mergeRedeclarable(Redeclarable< T > *D, RedeclarableResult &Redecl, DeclID TemplatePatternID=0)
Attempts to merge the given declaration (D) with another declaration of the same entity.
static OMPThreadPrivateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
void setManglingNumber(const NamedDecl *ND, unsigned Number)
void setUninstantiatedDefaultArg(Expr *arg)
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
bool CheckedICE
Whether we already checked whether this statement was an integral constant expression.
void VisitFriendTemplateDecl(FriendTemplateDecl *D)
void setLanguage(LanguageIDs L)
Set the language specified by this linkage specification.
LambdaCaptureKind
The different capture forms in a lambda introducer.
Represents a member of a struct/union/class.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
void setLocStart(SourceLocation L)
static CXXRecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
ArgPassingKind
Enum that represents the different ways arguments are passed to and returned from function calls...
RedeclarableResult VisitVarTemplateSpecializationDeclImpl(VarTemplateSpecializationDecl *D)
TODO: Unify with ClassTemplateSpecializationDecl version? May require unifying ClassTemplate(Partial)...
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Helper class that saves the current stream position and then restores it when destroyed.
static NamespaceDecl * getNamespace(const NestedNameSpecifier *X)
void setOwningModuleID(unsigned ID)
Set the owning module ID.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD)
This declaration is definitely a definition.
unsigned FromASTFile
Whether this declaration was loaded from an AST file.
void Profile(llvm::FoldingSetNodeID &ID)
Defines the clang::attr::Kind enum.
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Represents an access specifier followed by colon ':'.
void setReturnType(QualType T)
Declaration of a function specialization at template class scope.
static StaticAssertDecl * CreateDeserialized(ASTContext &C, unsigned ID)
TypeSourceInfo * getTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
void VisitLabelDecl(LabelDecl *LD)
static NamespaceDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setDeclImplementation(ImplementationControl ic)
Describes a module or submodule.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
A IndirectFieldDecl record.
size_t size() const
The length of this record.
static OMPCapturedExprDecl * CreateDeserialized(ASTContext &C, unsigned ID)
iterator end()
end - Returns an iterator that has 'finished'.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Represents a C++ using-declaration.
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
static llvm::iterator_range< MergedRedeclIterator< DeclT > > merged_redecls(DeclT *D)
ObjCContainerDecl - Represents a container for method declarations.
void setAccessControl(AccessControl ac)
static void attachLatestDecl(Decl *D, Decl *latest)
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
< Capturing the *this object by copy
RedeclarableResult VisitVarDeclImpl(VarDecl *D)
DeclLink RedeclLink
Points to the next redeclaration in the chain.
An AccessSpecDecl record.
void setAtLoc(SourceLocation L)
A convenient class for passing around template argument information.
void setDepth(unsigned D)
void setParamDestroyedInCallee(bool V)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
A ConstructorUsingShadowDecl record.
A UsingDirecitveDecl record.
void ReadFunctionDefinition(FunctionDecl *FD)
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitCXXRecordDecl(CXXRecordDecl *D)
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setSuperClass(ObjCInterfaceDecl *superCls)
A DecompositionDecl record.
Represents a declaration of a type.
void setHasObjectMember(bool val)
void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D)
void VisitMSPropertyDecl(MSPropertyDecl *FD)
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
DeclID VisitTemplateDecl(TemplateDecl *D)
SourceRange readSourceRange()
Read a source range, advancing Idx.
void setClassInterface(ObjCInterfaceDecl *D)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitCXXMethodDecl(CXXMethodDecl *D)
void UpdateDecl(Decl *D, SmallVectorImpl< serialization::DeclID > &)
Defines the Linkage enumeration and various utility functions.
static TypeAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
A ClassTemplateSpecializationDecl record.
Represents an Objective-C protocol declaration.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
static bool isSameEntity(NamedDecl *X, NamedDecl *Y)
Determine whether the two declarations refer to the same entity.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI)
Represents the body of a CapturedStmt, and serves as its DeclContext.
Represents an ObjC class declaration.
Represents a linkage specification.
static ParmVarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D)
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
A binding in a decomposition declaration.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
void setInitVal(const llvm::APSInt &V)
void setInitExpr(Expr *E)
void setCachedLinkage(Linkage L) const
void setLocStart(SourceLocation L)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
void setHasInheritedPrototype(bool P=true)
State that this function inherited its prototype from a previous declaration.
static std::string ReadString(const RecordData &Record, unsigned &Idx)
void setGetterCXXConstructor(Expr *getterCXXConstructor)
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
void setInline(bool Inline)
Set whether this is an inline namespace declaration.
static CXXDeductionGuideDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
IdentifierInfo * GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx)
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
void setVariadic(bool isVar)
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Represents the declaration of a typedef-name via a C++11 alias-declaration.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
RedeclarableResult VisitRedeclarable(Redeclarable< T > *D)
void setHasDestructors(bool val)
void VisitObjCContainerDecl(ObjCContainerDecl *D)
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
CXXDestructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a ValueDecl that came out of a declarator.
A CXXDeductionGuideDecl record.
void VisitParmVarDecl(ParmVarDecl *PD)
void setStorageClass(StorageClass SClass)
Sets the storage class as written in the source.
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
static OMPRequiresDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Create deserialized requires node.
void setIvarRBraceLoc(SourceLocation Loc)
A StaticAssertDecl record.
for(unsigned I=0, E=TL.getNumArgs();I !=E;++I)
A VarTemplateSpecializationDecl record.
void VisitUsingPackDecl(UsingPackDecl *D)
void VisitUsingShadowDecl(UsingShadowDecl *D)
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
TODO: Unify with ClassTemplatePartialSpecializationDecl version? May require unifying ClassTemplate(P...
void setNextIvar(ObjCIvarDecl *ivar)
void setSynthesize(bool synth)
This represents '#pragma omp requires...' directive.
void VisitFriendDecl(FriendDecl *D)
An ObjCTypeParamDecl record.
A record containing CXXBaseSpecifiers.
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
void setTrivialForCall(bool IT)
void setType(QualType T, TypeSourceInfo *TSI)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
A ObjCCategoryImplDecl record.
Defines the clang::LangOptions interface.
void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *GD)
void setBitWidth(Expr *Width)
Set the bit-field width for this member.
static LinkageSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
A ObjCPropertyImplDecl record.
Declaration of a template type parameter.
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
const T * castAs() const
Member-template castAs<specific type>.
Represents a C++ destructor within a class.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
A CXXConstructorDecl record.
void VisitTypedefDecl(TypedefDecl *TD)
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
void setContextParam(unsigned i, ImplicitParamDecl *P)
void setAtEndRange(SourceRange atEnd)
void setRBraceLoc(SourceLocation L)
static DeclLink PreviousDeclLink(decl_type *D)
void setRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
DeclContext * getDeclContext()
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
A record containing CXXCtorInitializers.
A VarTemplateDecl record.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl *> typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
void setMemberSpecialization()
Note that this member template is a specialization.
Decl * readDecl()
Reads a declaration from the given position in a record in the given module, advancing Idx...
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
void setDefined(bool isDefined)
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
void setCompleteDefinitionRequired(bool V=true)
True if this complete decl is required to be complete for some existing use.
RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D)
Information about a module that has been loaded by the ASTReader.
A namespace alias, stored as a NamespaceAliasDecl*.
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
static void attachPreviousDecl(ASTReader &Reader, Decl *D, Decl *Previous, Decl *Canon)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
const uint64_t & back() const
The last element in this record.
A CXXDestructorDecl record.
void VisitOMPRequiresDecl(OMPRequiresDecl *D)
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool InheritsConstructor)
bool isFunctionOrMethod() const
StorageClass
Storage classes.
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody)
Determine whether the consumer will be interested in seeing this declaration (via HandleTopLevelDecl)...
This declaration has an owning module, and is visible when that module is imported.
A NamespaceAliasDecl record.
void setTypename(bool TN)
Sets whether the using declaration has 'typename'.
Declaration of an alias template.
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
void setLocation(SourceLocation L)
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
An ImplicitParamDecl record.
void setIvarRBraceLoc(SourceLocation Loc)
void VisitDecompositionDecl(DecompositionDecl *DD)
void setIsRedeclaration(bool RD)
Represents a C++ deduction guide declaration.
Represents a C++ conversion function within a class.
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, unsigned ID)
An EnumConstantDecl record.
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, unsigned ID)
std::string readString()
Read a string, advancing Idx.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
void setHasSkippedBody(bool Skipped=true)
An ImportDecl recording a module import.
A ObjCCategoryDecl record.
void setDoesNotEscape(bool B=true)
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
This file defines OpenMP AST classes for clauses.
static void AddLazySpecializations(T *D, SmallVectorImpl< serialization::DeclID > &IDs)
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
void VisitObjCProtocolDecl(ObjCProtocolDecl *D)
A FileScopeAsmDecl record.
A ObjCCompatibleAliasDecl record.
void setHasExternalVisibleStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations visible in this context...
Attr * ReadAttr(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Reads one attribute from the current stream position.
void VisitPragmaCommentDecl(PragmaCommentDecl *D)
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
unsigned readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
void setIsVariadic(bool value)
static bool isSameQualifier(const NestedNameSpecifier *X, const NestedNameSpecifier *Y)
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize)
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Represents a C++ Modules TS module export declaration.
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
void setIsConversionFromLambda(bool val=true)
void setColonLoc(SourceLocation CLoc)
Sets the location of the colon.
An UnresolvedUsingValueDecl record.
void VisitDeclaratorDecl(DeclaratorDecl *DD)
static ObjCProtocolDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static EnumConstantDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static UsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
static void markIncompleteDeclChainImpl(Redeclarable< DeclT > *D)
static CXXDestructorDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Encodes a location in the source.
static EmptyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
QualType getReturnType() const
void setTopLevelDeclInObjCContainer(bool V=true)
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
This represents '#pragma omp declare reduction ...' directive.
A record that stores the set of declarations that are visible from a given DeclContext.
Pseudo declaration for capturing expressions.
void setIvarLBraceLoc(SourceLocation Loc)
void setBraceRange(SourceRange R)
void setAtStartLoc(SourceLocation Loc)
void VisitEmptyDecl(EmptyDecl *D)
void setAnonymousNamespace(NamespaceDecl *D)
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
void setObjCDeclQualifier(ObjCDeclQualifier QV)
Represents the declaration of a struct/union/class/enum.
ASTContext & getASTContext() const LLVM_READONLY
static DecompositionDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumBindings)
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
void setReferenced(bool R=true)
Represents the declaration of a label.
void mergeTemplatePattern(RedeclarableTemplateDecl *D, RedeclarableTemplateDecl *Existing, DeclID DsID, bool IsKeyDecl)
Merge together the pattern declarations from two template declarations.
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal)
Represents a dependent using declaration which was not marked with typename.
void setPosition(unsigned P)
void setIsCopyDeductionCandidate(bool isCDC=true)
void VisitObjCImplDecl(ObjCImplDecl *D)
Represents a static or instance method of a struct/union/class.
void setDefaulted(bool D=true)
void setHasFlexibleArrayMember(bool V)
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void VisitBindingDecl(BindingDecl *BD)
A TemplateTypeParmDecl record.
This file defines OpenMP nodes for declarative directives.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Data that is common to all of the declarations of a given function template.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
ObjCCategoryDecl - Represents a category declaration.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
void readDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name)
void addDecl(NamedDecl *D)
void setDeclName(DeclarationName N)
Set the name of this declaration.
static MSPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
SourceLocation getLocation() const
void setOverriding(bool IsOver)
static ConstructorUsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Describes the categories of an Objective-C class.
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
void init(NamedDecl *templatedDecl, TemplateParameterList *templateParams)
Initialize the underlying templated declaration and template parameters.
void setTagKind(TagKind TK)
unsigned getIdx() const
The current position in this record.
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
static FunctionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Represents one property declaration in an Objective-C interface.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
uint32_t TypeID
An ID number that refers to a type in an AST file.
void setInitializer(Expr *E, InitKind IK)
Set initializer expression for the declare reduction construct.
A simple visitor class that helps create declaration visitors.
const unsigned int DECL_UPDATES
Record of updates for a declaration that was modified after being deserialized.
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
void VisitRecordDecl(RecordDecl *RD)
static T assert_cast(T t)
"Cast" to type T, asserting if we don't have an implicit conversion.
serialization::SubmoduleID getGlobalSubmoduleID(unsigned LocalID)
Retrieve the global submodule ID its local ID number.
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
Represents a C++11 static_assert declaration.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
uint32_t BitOffset
Offset in the AST file.
void setExplicitlyDefaulted(bool ED=true)
State that this function is explicitly defaulted per C++0x.
void setLAngleLoc(SourceLocation Loc)
void VisitExportDecl(ExportDecl *D)
void addArgument(const TemplateArgumentLoc &Loc)
File is a PCH file treated as the actual main file.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
serialization::DeclID readDeclID()
Reads a declaration ID from the given position in this record.
void VisitValueDecl(ValueDecl *VD)
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
A ObjCProtocolDecl record.
void setDeclaredWithTypename(bool withTypename)
Set whether this template type parameter was declared with the 'typename' or 'class' keyword...
void setHasWrittenPrototype(bool P=true)
State that this function has a written prototype.
bool hasPendingBody() const
Determine whether this declaration has a pending body.
Defines various enumerations that describe declaration and type specifiers.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void setSetterCXXAssignment(Expr *setterCXXAssignment)
void VisitEnumDecl(EnumDecl *ED)
static TypedefDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Base class for declarations which introduce a typedef-name.
void setPropertyDecl(ObjCPropertyDecl *Prop)
A CXXConversionDecl record.
TagTypeKind
The kind of a tag type.
ObjCTypeParamList * ReadObjCTypeParamList()
Dataflow Directional Tag Classes.
void VisitCXXConversionDecl(CXXConversionDecl *D)
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
void setBody(CompoundStmt *B)
static CXXConversionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
static bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y)
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
void setHasVolatileMember(bool val)
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
The base class of all kinds of template declarations (e.g., class, function, etc.).
void VisitFunctionDecl(FunctionDecl *FD)
Reads an AST files chain containing the contents of a translation unit.
Represents a field injected from an anonymous union/struct into the parent scope. ...
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
A ClassTemplatePartialSpecializationDecl record.
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
DeclCode
Record codes for each kind of declaration.
A decomposition declaration.
RedeclarableResult VisitCXXRecordDeclImpl(CXXRecordDecl *D)
void setIvarList(ObjCIvarDecl *ivar)
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Represents a dependent using declaration which was marked with typename.
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
The name of a declaration.
Represents the declaration of an Objective-C type parameter.
void VisitObjCMethodDecl(ObjCMethodDecl *D)
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
A LinkageSpecDecl record.
RedeclarableResult VisitRecordDeclImpl(RecordDecl *RD)
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ParmVarDeclBitfields ParmVarDeclBits
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
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...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
static void forAllLaterRedecls(DeclT *D, Fn F)
void setExternLoc(SourceLocation L)
static bool inheritDefaultTemplateArgument(ASTContext &Context, ParmDecl *From, Decl *ToD)
Inherit the default template argument from From to To.
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
A type that was preceded by the 'template' keyword, stored as a Type*.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static LabelDecl * CreateDeserialized(ASTContext &C, unsigned ID)
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
All of the names in this module are visible.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
Capturing variable-length array type.
SmallVector< uint64_t, 64 > RecordData
A PragmaCommentDecl record.
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
bool isIncompleteArrayType() const
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
static ExportDecl * CreateDeserialized(ASTContext &C, unsigned ID)
NonParmVarDeclBitfields NonParmVarDeclBits
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
QualType getCanonicalTypeInternal() const
void setHasNonZeroConstructors(bool val)
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
LanguageIDs
Represents the language in a linkage specification.
uint64_t getGlobalBitOffset(uint32_t LocalOffset)
Get the global offset corresponding to a local offset.
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static RecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
void setCombiner(Expr *E)
Set combiner expression for the declare reduction construct.
static CXXMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setTypeSourceInfo(TypeSourceInfo *TI)
TypeSourceInfo * getTypeSourceInfo() const
void setUsesSEHTry(bool UST)
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
static EnumDecl * CreateDeserialized(ASTContext &C, unsigned ID)
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void VisitNamespaceDecl(NamespaceDecl *D)
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
Holds information about the various types of exception specification.
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
Capturing the *this object by reference.
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
Attr * readAttr()
Reads one attribute from the current stream position, advancing Idx.
void setInnerLocStart(SourceLocation L)
void setObjCMethodScopeInfo(unsigned parameterIndex)
bool IsClassExtension() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setSignatureAsWritten(TypeSourceInfo *Sig)
void setPromotionType(QualType T)
Set the promotion type.
static bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y)
Determine whether two template parameters are similar enough that they may be used in declarations of...
void setAsmString(StringLiteral *Asm)
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setRParenLoc(SourceLocation L)
A template argument list.
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...
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
static FieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void VisitCapturedDecl(CapturedDecl *CD)
Represents a field declaration created by an @defs(...).
TranslationUnitDecl * getTranslationUnitDecl() const
static Decl * getMostRecentDeclImpl(Redeclarable< DeclT > *D)
Defines the clang::SourceLocation class and associated facilities.
Represents a C++ struct/union/class.
static OMPDeclareReductionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create deserialized declare reduction node.
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
void setInstanceMethod(bool isInst)
void setHasRedeclaration(bool HRD) const
void setConstexpr(bool IC)
void setClassInterface(ObjCInterfaceDecl *IFace)
ObjCIvarDecl - Represents an ObjC instance variable.
bool operator!=(CanQual< T > x, CanQual< U > y)
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Provides information a specialization of a member of a class template, which may be a member function...
A ObjCImplementationDecl record.
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source...
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
void setReturnTypeSourceInfo(TypeSourceInfo *TInfo)
A ObjCAtDefsFieldDecl record.
Declaration of a class template.
void setIvarLBraceLoc(SourceLocation Loc)
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
void VisitAccessSpecDecl(AccessSpecDecl *D)
void setPropertyAttributes(PropertyAttributeKind PRVal)
static BlockDecl * CreateDeserialized(ASTContext &C, unsigned ID)
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
void VisitClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl *D)
unsigned clauselist_size() const
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U)
Determine whether two function types are the same, ignoring exception specifications in cases where t...
An object for streaming information from a record.
void VisitBlockDecl(BlockDecl *BD)
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
void VisitIndirectFieldDecl(IndirectFieldDecl *FD)
unsigned varlist_size() const
VarDeclBitfields VarDeclBits
static UsingPackDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions)
virtual CommonBase * newCommon(ASTContext &C) const =0
The top declaration context.
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
void ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs)
Reads attributes from the current stream position.
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D)
A FunctionTemplateDecl record.
std::pair< uint64_t, uint64_t > VisitDeclContext(DeclContext *DC)
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
A TypeAliasTemplateDecl record.
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
An instance of this class represents the declaration of a property member.
void setAtLoc(SourceLocation Loc)
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
A trivial tuple used to represent a source range.
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
This represents a decl that may have a name.
void VisitVarTemplateDecl(VarTemplateDecl *D)
TODO: Unify with ClassTemplateDecl version? May require unifying ClassTemplateDecl and VarTemplateDec...
bool isTranslationUnit() const
void setTypeSourceInfo(TypeSourceInfo *newType)
void setAccess(AccessSpecifier AS)
void numberAnonymousDeclsWithin(const DeclContext *DC, Fn Visit)
Visit each declaration within DC that needs an anonymous declaration number and call Visit with the d...
Represents a C++ namespace alias.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
static UsingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
Declaration of a friend template.
Represents C++ using-directive.
Represents a #pragma detect_mismatch line.
void setBlockMissingReturnType(bool val=true)
static ObjCPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
The global specifier '::'. There is no stored value.
void VisitTranslationUnitDecl(TranslationUnitDecl *TU)
static BindingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setType(QualType newType)
const LangOptions & getLangOpts() const
void setNonTrivialToPrimitiveCopy(bool V)
void setDeletedAsWritten(bool D=true)
void setCmdDecl(ImplicitParamDecl *CD)
This represents '#pragma omp threadprivate ...' directive.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
void setInlineSpecified(bool I)
Set whether the "inline" keyword was specified for this function.
Declaration of a template function.
iterator - Iterate over the decls of a specified declaration name.
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
Source range/offset of a preprocessed entity.
Attr - This represents one attribute.
SourceLocation getLocation() const
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID...
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Represents a pack of using declarations that a single using-declarator pack-expanded into...
QualType getType() const
Return the type wrapped by this type source info.
Defines the LambdaCapture class.
ObjCCompatibleAliasDecl - Represents alias of a class.
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
bool isInheritingConstructor() const
Determine whether this is an implicit constructor synthesized to model a call to a constructor inheri...
Structure used to store a statement, the constant value to which it was evaluated (if any)...
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
TemplatedKind
The kind of templated function a FunctionDecl can be.