54 #include "llvm/ADT/DenseMap.h" 55 #include "llvm/ADT/FoldingSet.h" 56 #include "llvm/ADT/STLExtras.h" 57 #include "llvm/ADT/SmallPtrSet.h" 58 #include "llvm/ADT/SmallVector.h" 59 #include "llvm/ADT/iterator_range.h" 60 #include "llvm/Bitstream/BitstreamReader.h" 61 #include "llvm/Support/Casting.h" 62 #include "llvm/Support/ErrorHandling.h" 63 #include "llvm/Support/SaveAndRestore.h" 71 using namespace clang;
72 using namespace serialization;
83 ASTReader::RecordLocation Loc;
90 unsigned AnonymousDeclNumber;
94 bool HasPendingBody =
false;
99 bool IsDeclMarkedUsed =
false;
101 uint64_t GetCurrentCursorOffset();
103 uint64_t ReadLocalOffset() {
104 uint64_t LocalOffset = Record.
readInt();
105 assert(LocalOffset < Loc.Offset &&
"offset point after current record");
106 return LocalOffset ? Loc.Offset - LocalOffset : 0;
109 uint64_t ReadGlobalOffset() {
110 uint64_t Local = ReadLocalOffset();
130 std::string readString() {
135 for (
unsigned I = 0, Size = Record.
readInt(); I != Size; ++I)
136 IDs.push_back(readDeclID());
160 void ReadCXXDefinitionData(
struct CXXRecordDecl::DefinitionData &Data,
163 struct CXXRecordDecl::DefinitionData &&NewDD);
164 void ReadObjCDefinitionData(
struct ObjCInterfaceDecl::DefinitionData &Data);
166 struct ObjCInterfaceDecl::DefinitionData &&NewDD);
167 void ReadObjCDefinitionData(
struct ObjCProtocolDecl::DefinitionData &Data);
169 struct ObjCProtocolDecl::DefinitionData &&NewDD);
180 class RedeclarableResult {
187 : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {}
193 bool isKeyDecl()
const {
return IsKeyDecl; }
197 Decl *getKnownMergeTarget()
const {
return MergeWith; }
205 class FindExistingResult {
209 bool AddResult =
false;
210 unsigned AnonymousDeclNumber = 0;
214 FindExistingResult(
ASTReader &Reader) : Reader(Reader) {}
217 unsigned AnonymousDeclNumber,
219 : Reader(Reader), New(New), Existing(Existing), AddResult(
true),
220 AnonymousDeclNumber(AnonymousDeclNumber),
221 TypedefNameForLinkage(TypedefNameForLinkage) {}
223 FindExistingResult(FindExistingResult &&Other)
224 : Reader(Other.Reader), New(Other.New), Existing(Other.Existing),
225 AddResult(Other.AddResult),
226 AnonymousDeclNumber(Other.AnonymousDeclNumber),
227 TypedefNameForLinkage(Other.TypedefNameForLinkage) {
228 Other.AddResult =
false;
231 FindExistingResult &operator=(FindExistingResult &&) =
delete;
232 ~FindExistingResult();
236 void suppress() { AddResult =
false; }
238 operator NamedDecl*()
const {
return Existing; }
241 operator T*()
const {
return dyn_cast_or_null<T>(Existing); }
246 FindExistingResult findExisting(
NamedDecl *D);
250 ASTReader::RecordLocation Loc,
252 : Reader(Reader), Record(Record), Loc(Loc), ThisDeclID(thisDeclID),
253 ThisDeclLoc(ThisDeclLoc) {}
255 template <
typename T>
static 264 auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations;
266 if (
auto &Old = LazySpecializations) {
267 IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
269 IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
273 *Result = IDs.size();
274 std::copy(IDs.begin(), IDs.end(), Result + 1);
276 LazySpecializations = Result;
279 template <
typename DeclT>
281 static Decl *getMostRecentDeclImpl(...);
282 static Decl *getMostRecentDecl(
Decl *D);
284 template <
typename DeclT>
285 static void attachPreviousDeclImpl(
ASTReader &Reader,
288 static void attachPreviousDeclImpl(
ASTReader &Reader, ...);
292 template <
typename DeclT>
294 static void attachLatestDeclImpl(...);
295 static void attachLatestDecl(
Decl *D,
Decl *latest);
297 template <
typename DeclT>
299 static void markIncompleteDeclChainImpl(...);
311 Cat->NextClassCategory = Next;
314 void VisitDecl(
Decl *D);
328 RedeclarableResult VisitTagDecl(
TagDecl *TD);
330 RedeclarableResult VisitRecordDeclImpl(
RecordDecl *RD);
334 RedeclarableResult VisitClassTemplateSpecializationDeclImpl(
339 VisitClassTemplateSpecializationDeclImpl(D);
342 void VisitClassTemplatePartialSpecializationDecl(
344 void VisitClassScopeFunctionSpecializationDecl(
350 VisitVarTemplateSpecializationDeclImpl(D);
353 void VisitVarTemplatePartialSpecializationDecl(
369 RedeclarableResult VisitVarDeclImpl(
VarDecl *D);
403 std::pair<uint64_t, uint64_t> VisitDeclContext(
DeclContext *DC);
410 DeclID TemplatePatternID = 0);
414 RedeclarableResult &Redecl,
415 DeclID TemplatePatternID = 0);
424 DeclID DsID,
bool IsKeyDecl);
457 template<
typename DeclT>
458 class MergedRedeclIterator {
460 DeclT *Canonical =
nullptr;
461 DeclT *Current =
nullptr;
464 MergedRedeclIterator() =
default;
465 MergedRedeclIterator(DeclT *Start) : Start(Start), Current(Start) {}
469 MergedRedeclIterator &operator++() {
470 if (Current->isFirstDecl()) {
472 Current = Current->getMostRecentDecl();
474 Current = Current->getPreviousDecl();
480 if (Current == Start || Current == Canonical)
485 friend bool operator!=(
const MergedRedeclIterator &A,
486 const MergedRedeclIterator &B) {
487 return A.Current != B.Current;
493 template <
typename DeclT>
494 static llvm::iterator_range<MergedRedeclIterator<DeclT>>
496 return llvm::make_range(MergedRedeclIterator<DeclT>(D),
497 MergedRedeclIterator<DeclT>());
500 uint64_t ASTDeclReader::GetCurrentCursorOffset() {
501 return Loc.F->DeclsCursor.GetCurrentBitNo() + Loc.F->GlobalBitOffset;
505 if (Record.readInt()) {
507 if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
508 Reader.DeclIsFromPCHWithObjectFile(FD))
509 Reader.DefinitionSource[FD] =
true;
511 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
512 CD->setNumCtorInitializers(Record.readInt());
513 if (CD->getNumCtorInitializers())
514 CD->CtorInitializers = ReadGlobalOffset();
517 Reader.PendingBodies[FD] = GetCurrentCursorOffset();
518 HasPendingBody =
true;
527 IsDeclMarkedUsed =
false;
529 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
530 if (
auto *TInfo = DD->getTypeSourceInfo())
531 Record.readTypeLoc(TInfo->getTypeLoc());
534 if (
auto *TD = dyn_cast<TypeDecl>(D)) {
536 TD->setTypeForDecl(Reader.GetType(DeferredTypeID).getTypePtrOrNull());
540 if (NamedDeclForTagDecl)
541 cast<TagDecl>(D)->TypedefNameDeclOrQualifier =
542 cast<TypedefNameDecl>(Reader.GetDecl(NamedDeclForTagDecl));
543 }
else if (
auto *
ID = dyn_cast<ObjCInterfaceDecl>(D)) {
545 ID->TypeForDecl = Reader.GetType(DeferredTypeID).getTypePtrOrNull();
546 }
else if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
551 if (Record.readInt())
552 ReadFunctionDefinition(FD);
558 isa<ParmVarDecl>(D) || isa<ObjCTypeParamDecl>(D)) {
565 GlobalDeclID SemaDCIDForTemplateParmDecl = readDeclID();
566 GlobalDeclID LexicalDCIDForTemplateParmDecl = readDeclID();
567 if (!LexicalDCIDForTemplateParmDecl)
568 LexicalDCIDForTemplateParmDecl = SemaDCIDForTemplateParmDecl;
569 Reader.addPendingDeclContextInfo(D,
570 SemaDCIDForTemplateParmDecl,
571 LexicalDCIDForTemplateParmDecl);
574 auto *SemaDC = readDeclAs<DeclContext>();
575 auto *LexicalDC = readDeclAs<DeclContext>();
581 D->setDeclContextsImpl(MergedSemaDC ? MergedSemaDC : SemaDC, LexicalDC,
582 Reader.getContext());
586 if (Record.readInt()) {
588 Record.readAttributes(Attrs);
591 D->setAttrsImpl(Attrs, Reader.getContext());
594 D->Used = Record.readInt();
595 IsDeclMarkedUsed |= D->Used;
600 bool ModulePrivate = Record.readInt();
614 }
else if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
622 Reader.HiddenNamesMap[Owner].push_back(D);
624 }
else if (ModulePrivate) {
633 std::string Arg = readString();
634 memcpy(D->getTrailingObjects<
char>(), Arg.data(), Arg.size());
635 D->getTrailingObjects<
char>()[Arg.size()] =
'\0';
641 std::string Name = readString();
642 memcpy(D->getTrailingObjects<
char>(), Name.data(), Name.size());
643 D->getTrailingObjects<
char>()[Name.size()] =
'\0';
645 D->ValueStart = Name.size() + 1;
646 std::string
Value = readString();
647 memcpy(D->getTrailingObjects<
char>() + D->ValueStart, Value.data(),
649 D->getTrailingObjects<
char>()[D->ValueStart + Value.size()] =
'\0';
653 llvm_unreachable(
"Translation units are not serialized");
659 AnonymousDeclNumber = Record.readInt();
666 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
669 ASTDeclReader::RedeclarableResult
671 RedeclarableResult Redecl = VisitRedeclarable(TD);
674 if (Record.readInt()) {
675 QualType modedT = Record.readType();
688 RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
689 mergeRedeclarable(TD, Redecl);
693 RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
694 if (
auto *Template = readDeclAs<TypeAliasTemplateDecl>())
698 mergeRedeclarable(TD, Redecl);
702 RedeclarableResult Redecl = VisitRedeclarable(TD);
707 if (!isa<CXXRecordDecl>(TD))
714 switch (Record.readInt()) {
719 Record.readQualifierInfo(*Info);
720 TD->TypedefNameDeclOrQualifier = Info;
724 NamedDeclForTagDecl = readDeclID();
725 TypedefNameForLinkage = Record.readIdentifier();
728 llvm_unreachable(
"unexpected tag info kind");
731 if (!isa<CXXRecordDecl>(TD))
732 mergeRedeclarable(TD, Redecl);
743 ED->setNumPositiveBits(Record.readInt());
744 ED->setNumNegativeBits(Record.readInt());
745 ED->setScoped(Record.readInt());
746 ED->setScopedUsingClassTag(Record.readInt());
747 ED->setFixed(Record.readInt());
749 ED->setHasODRHash(
true);
750 ED->ODRHash = Record.readInt();
755 Reader.getContext().getLangOpts().Modules &&
756 Reader.getContext().getLangOpts().CPlusPlus) {
762 if (!D->isFromASTFile() && D->isCompleteDefinition()) {
769 Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
771 Reader.mergeDefinitionVisibility(OldDef, ED);
773 Reader.PendingEnumOdrMergeFailures[OldDef].push_back(ED);
779 if (
auto *InstED = readDeclAs<EnumDecl>()) {
782 ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK);
787 ASTDeclReader::RedeclarableResult
789 RedeclarableResult Redecl = VisitTagDecl(RD);
810 if (isa<FunctionDecl>(VD))
811 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
813 VD->
setType(Record.readType());
818 if (Record.readInt())
827 if (Record.readInt()) {
828 auto *Info =
new (Reader.getContext()) DeclaratorDecl::ExtInfo();
829 Record.readQualifierInfo(*Info);
830 Info->TrailingRequiresClause = Record.readExpr();
833 QualType TSIType = Record.readType();
835 TSIType.
isNull() ? nullptr
836 : Reader.getContext().CreateTypeSourceInfo(TSIType));
840 RedeclarableResult Redecl = VisitRedeclarable(FD);
841 VisitDeclaratorDecl(FD);
851 Reader.PendingFunctionTypes.push_back({FD, DeferredTypeID});
853 FD->
setType(Reader.GetType(DeferredTypeID));
857 FD->DNLoc = Record.readDeclarationNameLoc(FD->
getDeclName());
883 FD->EndRangeLoc = readSourceLocation();
885 FD->ODRHash = Record.readInt();
886 FD->setHasODRHash(
true);
890 if (
unsigned NumLookups = Record.readInt()) {
892 for (
unsigned I = 0; I != NumLookups; ++I) {
898 Reader.getContext(), Lookups));
904 mergeRedeclarable(FD, Redecl);
911 auto *InstFD = readDeclAs<FunctionDecl>();
914 FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
916 mergeRedeclarable(FD, Redecl);
920 auto *Template = readDeclAs<FunctionTemplateDecl>();
925 Record.readTemplateArgumentList(TemplArgs,
true);
930 bool HasTemplateArgumentsAsWritten = Record.readInt();
931 if (HasTemplateArgumentsAsWritten) {
932 unsigned NumTemplateArgLocs = Record.readInt();
933 TemplArgLocs.reserve(NumTemplateArgLocs);
934 for (
unsigned i = 0; i != NumTemplateArgLocs; ++i)
935 TemplArgLocs.push_back(Record.readTemplateArgumentLoc());
937 LAngleLoc = readSourceLocation();
938 RAngleLoc = readSourceLocation();
947 for (
unsigned i = 0, e = TemplArgLocs.size(); i != e; ++i)
951 if (Record.readInt()) {
952 auto *FD = readDeclAs<FunctionDecl>();
962 C, FD, Template, TSK, TemplArgList,
963 HasTemplateArgumentsAsWritten ? &TemplArgsInfo :
nullptr, POI,
965 FD->TemplateOrSpecialization = FTInfo;
970 auto *CanonTemplate = readDeclAs<FunctionTemplateDecl>();
976 llvm::FoldingSetNodeID
ID;
978 void *InsertPos =
nullptr;
985 assert(Reader.getContext().getLangOpts().Modules &&
986 "already deserialized this template specialization");
987 mergeRedeclarable(FD, ExistingInfo->
getFunction(), Redecl);
995 unsigned NumTemplates = Record.readInt();
996 while (NumTemplates--)
997 TemplDecls.
addDecl(readDeclAs<NamedDecl>());
1001 unsigned NumArgs = Record.readInt();
1003 TemplArgs.
addArgument(Record.readTemplateArgumentLoc());
1008 TemplDecls, TemplArgs);
1016 unsigned NumParams = Record.readInt();
1018 Params.reserve(NumParams);
1019 for (
unsigned I = 0; I != NumParams; ++I)
1020 Params.push_back(readDeclAs<ParmVarDecl>());
1021 FD->setParams(Reader.getContext(), Params);
1026 if (Record.readInt()) {
1029 Reader.PendingBodies[MD] = GetCurrentCursorOffset();
1030 HasPendingBody =
true;
1033 MD->
setCmdDecl(readDeclAs<ImplicitParamDecl>());
1045 Reader.getContext().setObjCMethodRedeclaration(MD,
1046 readDeclAs<ObjCMethodDecl>());
1053 MD->DeclEndLoc = readSourceLocation();
1054 unsigned NumParams = Record.readInt();
1056 Params.reserve(NumParams);
1057 for (
unsigned I = 0; I != NumParams; ++I)
1058 Params.push_back(readDeclAs<ParmVarDecl>());
1061 unsigned NumStoredSelLocs = Record.readInt();
1063 SelLocs.reserve(NumStoredSelLocs);
1064 for (
unsigned i = 0; i != NumStoredSelLocs; ++i)
1065 SelLocs.push_back(readSourceLocation());
1067 MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs);
1071 VisitTypedefNameDecl(D);
1073 D->Variance = Record.readInt();
1074 D->Index = Record.readInt();
1075 D->VarianceLoc = readSourceLocation();
1076 D->ColonLoc = readSourceLocation();
1086 unsigned numParams = Record.readInt();
1091 typeParams.reserve(numParams);
1092 for (
unsigned i = 0; i != numParams; ++i) {
1093 auto *typeParam = readDeclAs<ObjCTypeParamDecl>();
1097 typeParams.push_back(typeParam);
1104 typeParams, rAngleLoc);
1107 void ASTDeclReader::ReadObjCDefinitionData(
1108 struct ObjCInterfaceDecl::DefinitionData &Data) {
1110 Data.SuperClassTInfo = readTypeSourceInfo();
1112 Data.EndLoc = readSourceLocation();
1113 Data.HasDesignatedInitializers = Record.readInt();
1116 unsigned NumProtocols = Record.readInt();
1118 Protocols.reserve(NumProtocols);
1119 for (
unsigned I = 0; I != NumProtocols; ++I)
1120 Protocols.push_back(readDeclAs<ObjCProtocolDecl>());
1122 ProtoLocs.reserve(NumProtocols);
1123 for (
unsigned I = 0; I != NumProtocols; ++I)
1124 ProtoLocs.push_back(readSourceLocation());
1125 Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, ProtoLocs.data(),
1126 Reader.getContext());
1129 NumProtocols = Record.readInt();
1131 Protocols.reserve(NumProtocols);
1132 for (
unsigned I = 0; I != NumProtocols; ++I)
1133 Protocols.push_back(readDeclAs<ObjCProtocolDecl>());
1134 Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
1135 Reader.getContext());
1139 struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
1144 RedeclarableResult Redecl = VisitRedeclarable(ID);
1145 VisitObjCContainerDecl(ID);
1146 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
1147 mergeRedeclarable(ID, Redecl);
1149 ID->TypeParamList = ReadObjCTypeParamList();
1150 if (Record.readInt()) {
1152 ID->allocateDefinitionData();
1154 ReadObjCDefinitionData(ID->data());
1156 if (Canon->Data.getPointer()) {
1159 MergeDefinitionData(Canon, std::move(ID->data()));
1160 ID->Data = Canon->Data;
1171 Reader.PendingDefinitions.insert(ID);
1174 Reader.ObjCClassesLoaded.push_back(ID);
1181 VisitFieldDecl(IVD);
1185 bool synth = Record.readInt();
1189 void ASTDeclReader::ReadObjCDefinitionData(
1190 struct ObjCProtocolDecl::DefinitionData &Data) {
1191 unsigned NumProtoRefs = Record.readInt();
1193 ProtoRefs.reserve(NumProtoRefs);
1194 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1195 ProtoRefs.push_back(readDeclAs<ObjCProtocolDecl>());
1197 ProtoLocs.reserve(NumProtoRefs);
1198 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1199 ProtoLocs.push_back(readSourceLocation());
1200 Data.ReferencedProtocols.set(ProtoRefs.data(), NumProtoRefs,
1201 ProtoLocs.data(), Reader.getContext());
1205 struct ObjCProtocolDecl::DefinitionData &&NewDD) {
1210 RedeclarableResult Redecl = VisitRedeclarable(PD);
1211 VisitObjCContainerDecl(PD);
1212 mergeRedeclarable(PD, Redecl);
1214 if (Record.readInt()) {
1216 PD->allocateDefinitionData();
1218 ReadObjCDefinitionData(PD->data());
1221 if (Canon->Data.getPointer()) {
1224 MergeDefinitionData(Canon, std::move(PD->data()));
1225 PD->Data = Canon->Data;
1232 Reader.PendingDefinitions.insert(PD);
1243 VisitObjCContainerDecl(CD);
1251 Reader.CategoriesDeserialized.insert(CD);
1253 CD->ClassInterface = readDeclAs<ObjCInterfaceDecl>();
1254 CD->TypeParamList = ReadObjCTypeParamList();
1255 unsigned NumProtoRefs = Record.readInt();
1257 ProtoRefs.reserve(NumProtoRefs);
1258 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1259 ProtoRefs.push_back(readDeclAs<ObjCProtocolDecl>());
1261 ProtoLocs.reserve(NumProtoRefs);
1262 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1263 ProtoLocs.push_back(readSourceLocation());
1265 Reader.getContext());
1271 Reader.getContext());
1275 VisitNamedDecl(CAD);
1304 VisitObjCContainerDecl(D);
1309 VisitObjCImplDecl(D);
1310 D->CategoryNameLoc = readSourceLocation();
1314 VisitObjCImplDecl(D);
1316 D->SuperLoc = readSourceLocation();
1321 D->NumIvarInitializers = Record.readInt();
1322 if (D->NumIvarInitializers)
1323 D->IvarInitializers = ReadGlobalOffset();
1330 D->PropertyIvarDecl = readDeclAs<ObjCIvarDecl>();
1331 D->IvarLoc = readSourceLocation();
1339 VisitDeclaratorDecl(FD);
1340 FD->Mutable = Record.readInt();
1342 if (
auto ISK = static_cast<FieldDecl::InitStorageKind>(Record.readInt())) {
1343 FD->InitStorage.setInt(ISK);
1344 FD->InitStorage.setPointer(ISK == FieldDecl::ISK_CapturedVLAType
1345 ? Record.readType().getAsOpaquePtr()
1346 : Record.readExpr());
1349 if (
auto *BW = Record.readExpr())
1353 if (
auto *Tmpl = readDeclAs<FieldDecl>())
1354 Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
1360 VisitDeclaratorDecl(PD);
1361 PD->GetterId = Record.readIdentifier();
1362 PD->SetterId = Record.readIdentifier();
1368 FD->ChainingSize = Record.readInt();
1369 assert(FD->ChainingSize >= 2 &&
"Anonymous chaining must be >= 2");
1370 FD->Chaining =
new (Reader.getContext())
NamedDecl*[FD->ChainingSize];
1372 for (
unsigned I = 0; I != FD->ChainingSize; ++I)
1373 FD->Chaining[I] = readDeclAs<NamedDecl>();
1379 RedeclarableResult Redecl = VisitRedeclarable(VD);
1380 VisitDeclaratorDecl(VD);
1385 VD->
VarDeclBits.ARCPseudoStrong = Record.readInt();
1386 if (!isa<ParmVarDecl>(VD)) {
1401 auto VarLinkage =
Linkage(Record.readInt());
1409 if (uint64_t Val = Record.readInt()) {
1410 VD->
setInit(Record.readExpr());
1414 Eval->
IsICE = (Val & 1) != 0;
1420 Expr *CopyExpr = Record.readExpr();
1422 Reader.getContext().setBlockVarCopyInit(VD, CopyExpr, Record.readInt());
1427 if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
1428 Reader.DeclIsFromPCHWithObjectFile(VD))
1429 Reader.DefinitionSource[VD] =
true;
1433 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1435 switch ((VarKind)Record.readInt()) {
1436 case VarNotTemplate:
1439 if (!isa<ParmVarDecl>(VD) && !isa<ImplicitParamDecl>(VD) &&
1440 !isa<VarTemplateSpecializationDecl>(VD))
1441 mergeRedeclarable(VD, Redecl);
1447 case StaticDataMemberSpecialization: {
1448 auto *Tmpl = readDeclAs<VarDecl>();
1451 Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
1452 mergeRedeclarable(VD, Redecl);
1466 unsigned isObjCMethodParam = Record.readInt();
1467 unsigned scopeDepth = Record.readInt();
1468 unsigned scopeIndex = Record.readInt();
1469 unsigned declQualifier = Record.readInt();
1470 if (isObjCMethodParam) {
1471 assert(scopeDepth == 0);
1479 if (Record.readInt())
1488 auto **BDs = DD->getTrailingObjects<
BindingDecl *>();
1489 for (
unsigned I = 0; I != DD->NumBindings; ++I) {
1490 BDs[I] = readDeclAs<BindingDecl>();
1497 BD->Binding = Record.readExpr();
1502 AD->
setAsmString(cast<StringLiteral>(Record.readExpr()));
1508 BD->
setBody(cast_or_null<CompoundStmt>(Record.readStmt()));
1510 unsigned NumParams = Record.readInt();
1512 Params.reserve(NumParams);
1513 for (
unsigned I = 0; I != NumParams; ++I)
1514 Params.push_back(readDeclAs<ParmVarDecl>());
1523 bool capturesCXXThis = Record.readInt();
1524 unsigned numCaptures = Record.readInt();
1526 captures.reserve(numCaptures);
1527 for (
unsigned i = 0; i != numCaptures; ++i) {
1528 auto *
decl = readDeclAs<VarDecl>();
1529 unsigned flags = Record.readInt();
1530 bool byRef = (flags & 1);
1531 bool nested = (flags & 2);
1532 Expr *copyExpr = ((flags & 4) ? Record.readExpr() :
nullptr);
1536 BD->
setCaptures(Reader.getContext(), captures, capturesCXXThis);
1541 unsigned ContextParamPos = Record.readInt();
1544 for (
unsigned I = 0; I < CD->NumParams; ++I) {
1545 if (I != ContextParamPos)
1546 CD->
setParam(I, readDeclAs<ImplicitParamDecl>());
1561 D->RBraceLoc = readSourceLocation();
1570 RedeclarableResult Redecl = VisitRedeclarable(D);
1573 D->LocStart = readSourceLocation();
1574 D->RBraceLoc = readSourceLocation();
1581 if (Redecl.getFirstID() == ThisDeclID) {
1582 AnonNamespace = readDeclID();
1586 D->AnonOrFirstNamespaceAndInline.setPointer(D->
getFirstDecl());
1589 mergeRedeclarable(D, Redecl);
1591 if (AnonNamespace) {
1595 auto *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
1596 if (!Record.isModule())
1602 RedeclarableResult Redecl = VisitRedeclarable(D);
1604 D->NamespaceLoc = readSourceLocation();
1605 D->IdentLoc = readSourceLocation();
1606 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1607 D->Namespace = readDeclAs<NamedDecl>();
1608 mergeRedeclarable(D, Redecl);
1614 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1615 D->DNLoc = Record.readDeclarationNameLoc(D->
getDeclName());
1616 D->FirstUsingShadow.setPointer(readDeclAs<UsingShadowDecl>());
1618 if (
auto *Pattern = readDeclAs<NamedDecl>())
1619 Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
1625 D->InstantiatedFrom = readDeclAs<NamedDecl>();
1626 auto **Expansions = D->getTrailingObjects<
NamedDecl *>();
1627 for (
unsigned I = 0; I != D->NumExpansions; ++I)
1628 Expansions[I] = readDeclAs<NamedDecl>();
1633 RedeclarableResult Redecl = VisitRedeclarable(D);
1635 D->Underlying = readDeclAs<NamedDecl>();
1637 D->UsingOrNextShadow = readDeclAs<NamedDecl>();
1638 auto *Pattern = readDeclAs<UsingShadowDecl>();
1640 Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern);
1641 mergeRedeclarable(D, Redecl);
1646 VisitUsingShadowDecl(D);
1647 D->NominatedBaseClassShadowDecl = readDeclAs<ConstructorUsingShadowDecl>();
1648 D->ConstructedBaseClassShadowDecl = readDeclAs<ConstructorUsingShadowDecl>();
1649 D->IsVirtual = Record.readInt();
1654 D->UsingLoc = readSourceLocation();
1655 D->NamespaceLoc = readSourceLocation();
1656 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1657 D->NominatedNamespace = readDeclAs<NamedDecl>();
1658 D->CommonAncestor = readDeclAs<DeclContext>();
1664 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1665 D->DNLoc = Record.readDeclarationNameLoc(D->
getDeclName());
1666 D->EllipsisLoc = readSourceLocation();
1673 D->TypenameLocation = readSourceLocation();
1674 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1675 D->EllipsisLoc = readSourceLocation();
1679 void ASTDeclReader::ReadCXXDefinitionData(
1680 struct CXXRecordDecl::DefinitionData &Data,
const CXXRecordDecl *D) {
1681 #define FIELD(Name, Width, Merge) \ 1682 Data.Name = Record.readInt(); 1683 #include "clang/AST/CXXRecordDeclDefinitionBits.def" 1686 Data.ODRHash = Record.readInt();
1687 Data.HasODRHash =
true;
1689 if (Record.readInt()) {
1691 if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
1692 Reader.DeclIsFromPCHWithObjectFile(D))
1693 Reader.DefinitionSource[D] =
true;
1696 Data.NumBases = Record.readInt();
1698 Data.Bases = ReadGlobalOffset();
1699 Data.NumVBases = Record.readInt();
1701 Data.VBases = ReadGlobalOffset();
1703 Record.readUnresolvedSet(Data.Conversions);
1704 Data.ComputedVisibleConversions = Record.readInt();
1705 if (Data.ComputedVisibleConversions)
1706 Record.readUnresolvedSet(Data.VisibleConversions);
1707 assert(Data.Definition &&
"Data.Definition should be already set!");
1708 Data.FirstFriend = readDeclID();
1710 if (Data.IsLambda) {
1713 auto &Lambda =
static_cast<CXXRecordDecl::LambdaDefinitionData &
>(Data);
1714 Lambda.Dependent = Record.readInt();
1715 Lambda.IsGenericLambda = Record.readInt();
1716 Lambda.CaptureDefault = Record.readInt();
1717 Lambda.NumCaptures = Record.readInt();
1718 Lambda.NumExplicitCaptures = Record.readInt();
1719 Lambda.HasKnownInternalLinkage = Record.readInt();
1720 Lambda.ManglingNumber = Record.readInt();
1721 Lambda.ContextDecl = readDeclID();
1722 Lambda.Captures = (
Capture *)Reader.getContext().Allocate(
1723 sizeof(
Capture) * Lambda.NumCaptures);
1724 Capture *ToCapture = Lambda.Captures;
1725 Lambda.MethodTyInfo = readTypeSourceInfo();
1726 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
1728 bool IsImplicit = Record.readInt();
1738 auto *Var = readDeclAs<VarDecl>();
1740 *ToCapture++ =
Capture(Loc, IsImplicit,
Kind, Var, EllipsisLoc);
1747 void ASTDeclReader::MergeDefinitionData(
1748 CXXRecordDecl *D,
struct CXXRecordDecl::DefinitionData &&MergeDD) {
1749 assert(D->DefinitionData &&
1750 "merging class definition into non-definition");
1751 auto &DD = *D->DefinitionData;
1753 if (DD.Definition != MergeDD.Definition) {
1755 Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition,
1757 Reader.PendingDefinitions.erase(MergeDD.Definition);
1758 MergeDD.Definition->setCompleteDefinition(
false);
1759 Reader.mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
1760 assert(Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() &&
1761 "already loaded pending lookups for merged definition");
1764 auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
1765 if (PFDI != Reader.PendingFakeDefinitionData.end() &&
1766 PFDI->second == ASTReader::PendingFakeDefinitionKind::Fake) {
1769 assert(!DD.IsLambda && !MergeDD.IsLambda &&
"faked up lambda definition?");
1770 PFDI->second = ASTReader::PendingFakeDefinitionKind::FakeLoaded;
1774 auto *Def = DD.Definition;
1775 DD = std::move(MergeDD);
1776 DD.Definition = Def;
1780 bool DetectedOdrViolation =
false;
1782 #define FIELD(Name, Width, Merge) Merge(Name) 1783 #define MERGE_OR(Field) DD.Field |= MergeDD.Field; 1784 #define NO_MERGE(Field) \ 1785 DetectedOdrViolation |= DD.Field != MergeDD.Field; \ 1787 #include "clang/AST/CXXRecordDeclDefinitionBits.def" 1792 if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases)
1793 DetectedOdrViolation =
true;
1799 if (MergeDD.ComputedVisibleConversions && !DD.ComputedVisibleConversions) {
1800 DD.VisibleConversions = std::move(MergeDD.VisibleConversions);
1801 DD.ComputedVisibleConversions =
true;
1813 DetectedOdrViolation =
true;
1816 if (DetectedOdrViolation)
1817 Reader.PendingOdrMergeFailures[DD.Definition].push_back(
1818 {MergeDD.Definition, &MergeDD});
1822 struct CXXRecordDecl::DefinitionData *DD;
1827 bool IsLambda = Record.readInt();
1829 DD =
new (
C) CXXRecordDecl::LambdaDefinitionData(D,
nullptr,
false,
false,
1832 DD =
new (
C)
struct CXXRecordDecl::DefinitionData(D);
1838 if (!Canon->DefinitionData)
1839 Canon->DefinitionData = DD;
1840 D->DefinitionData = Canon->DefinitionData;
1841 ReadCXXDefinitionData(*DD, D);
1846 if (Canon->DefinitionData != DD) {
1847 MergeDefinitionData(Canon, std::move(*DD));
1857 if (Update || Canon != D)
1858 Reader.PendingDefinitions.insert(D);
1861 ASTDeclReader::RedeclarableResult
1863 RedeclarableResult Redecl = VisitRecordDeclImpl(D);
1868 CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1870 switch ((CXXRecKind)Record.readInt()) {
1871 case CXXRecNotTemplate:
1873 if (!isa<ClassTemplateSpecializationDecl>(D))
1874 mergeRedeclarable(D, Redecl);
1876 case CXXRecTemplate: {
1878 auto *Template = readDeclAs<ClassTemplateDecl>();
1879 D->TemplateOrInstantiation = Template;
1880 if (!Template->getTemplatedDecl()) {
1891 case CXXRecMemberSpecialization: {
1892 auto *RD = readDeclAs<CXXRecordDecl>();
1897 D->TemplateOrInstantiation = MSI;
1898 mergeRedeclarable(D, Redecl);
1903 bool WasDefinition = Record.readInt();
1905 ReadCXXRecordDefinition(D,
false);
1912 if (WasDefinition) {
1913 DeclID KeyFn = readDeclID();
1918 C.KeyFunctions[D] = KeyFn;
1925 D->setExplicitSpecifier(Record.readExplicitSpec());
1926 VisitFunctionDecl(D);
1931 VisitFunctionDecl(D);
1933 unsigned NumOverridenMethods = Record.readInt();
1935 while (NumOverridenMethods--) {
1938 if (
auto *MD = readDeclAs<CXXMethodDecl>())
1944 Record.skipInts(NumOverridenMethods);
1951 D->setExplicitSpecifier(Record.readExplicitSpec());
1953 auto *Shadow = readDeclAs<ConstructorUsingShadowDecl>();
1954 auto *Ctor = readDeclAs<CXXConstructorDecl>();
1959 VisitCXXMethodDecl(D);
1963 VisitCXXMethodDecl(D);
1965 if (
auto *OperatorDelete = readDeclAs<FunctionDecl>()) {
1967 auto *ThisArg = Record.readExpr();
1969 if (!Canon->OperatorDelete) {
1970 Canon->OperatorDelete = OperatorDelete;
1971 Canon->OperatorDeleteThisArg = ThisArg;
1977 D->setExplicitSpecifier(Record.readExplicitSpec());
1978 VisitCXXMethodDecl(D);
1983 D->ImportedAndComplete.setPointer(readModule());
1984 D->ImportedAndComplete.setInt(Record.readInt());
1986 for (
unsigned I = 0, N = Record.back(); I != N; ++I)
1987 StoredLocs[I] = readSourceLocation();
1998 if (Record.readInt())
1999 D->Friend = readDeclAs<NamedDecl>();
2001 D->Friend = readTypeSourceInfo();
2002 for (
unsigned i = 0; i != D->NumTPLists; ++i)
2004 Record.readTemplateParameterList();
2005 D->NextFriend = readDeclID();
2006 D->UnsupportedFriend = (Record.readInt() != 0);
2007 D->FriendLoc = readSourceLocation();
2012 unsigned NumParams = Record.readInt();
2013 D->NumParams = NumParams;
2015 for (
unsigned i = 0; i != NumParams; ++i)
2016 D->Params[i] = Record.readTemplateParameterList();
2017 if (Record.readInt())
2018 D->Friend = readDeclAs<NamedDecl>();
2020 D->Friend = readTypeSourceInfo();
2021 D->FriendLoc = readSourceLocation();
2027 DeclID PatternID = readDeclID();
2028 auto *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
2030 D->
init(TemplatedDecl, TemplateParams);
2036 VisitTemplateDecl(D);
2044 ASTDeclReader::RedeclarableResult
2046 RedeclarableResult Redecl = VisitRedeclarable(D);
2053 Reader.PendingDefinitions.insert(CanonD);
2059 if (ThisDeclID == Redecl.getFirstID()) {
2060 if (
auto *RTD = readDeclAs<RedeclarableTemplateDecl>()) {
2061 assert(RTD->getKind() == D->
getKind() &&
2062 "InstantiatedFromMemberTemplate kind mismatch");
2064 if (Record.readInt())
2069 DeclID PatternID = VisitTemplateDecl(D);
2072 mergeRedeclarable(D, Redecl, PatternID);
2083 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2085 if (ThisDeclID == Redecl.getFirstID()) {
2089 readDeclIDList(SpecIDs);
2097 Reader.getContext().getInjectedClassNameType(
2103 llvm_unreachable(
"BuiltinTemplates are not serialized");
2110 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2112 if (ThisDeclID == Redecl.getFirstID()) {
2116 readDeclIDList(SpecIDs);
2121 ASTDeclReader::RedeclarableResult
2124 RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D);
2127 if (
Decl *InstD = readDecl()) {
2128 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
2129 D->SpecializedTemplate = CTD;
2132 Record.readTemplateArgumentList(TemplArgs);
2137 SpecializedPartialSpecialization();
2138 PS->PartialSpecialization
2139 = cast<ClassTemplatePartialSpecializationDecl>(InstD);
2140 PS->TemplateArgs = ArgList;
2141 D->SpecializedTemplate = PS;
2146 Record.readTemplateArgumentList(TemplArgs,
true);
2148 D->PointOfInstantiation = readSourceLocation();
2151 bool writtenAsCanonicalDecl = Record.readInt();
2152 if (writtenAsCanonicalDecl) {
2153 auto *CanonPattern = readDeclAs<ClassTemplateDecl>();
2157 if (
auto *Partial = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
2158 CanonSpec = CanonPattern->getCommonPtr()->PartialSpecializations
2159 .GetOrInsertNode(Partial);
2162 CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2165 if (CanonSpec != D) {
2166 mergeRedeclarable<TagDecl>(D, CanonSpec, Redecl);
2170 if (
auto *DDD = D->DefinitionData) {
2171 if (CanonSpec->DefinitionData)
2172 MergeDefinitionData(CanonSpec, std::move(*DDD));
2174 CanonSpec->DefinitionData = D->DefinitionData;
2176 D->DefinitionData = CanonSpec->DefinitionData;
2183 auto *ExplicitInfo =
2184 new (
C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
2185 ExplicitInfo->TypeAsWritten = TyInfo;
2186 ExplicitInfo->ExternLoc = readSourceLocation();
2187 ExplicitInfo->TemplateKeywordLoc = readSourceLocation();
2188 D->ExplicitInfo = ExplicitInfo;
2199 D->TemplateParams = Params;
2200 D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2202 RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
2205 if (ThisDeclID == Redecl.getFirstID()) {
2206 D->InstantiatedFromMember.setPointer(
2207 readDeclAs<ClassTemplatePartialSpecializationDecl>());
2208 D->InstantiatedFromMember.setInt(Record.readInt());
2215 D->Specialization = readDeclAs<CXXMethodDecl>();
2216 if (Record.readInt())
2217 D->TemplateArgs = Record.readASTTemplateArgumentListInfo();
2221 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2223 if (ThisDeclID == Redecl.getFirstID()) {
2226 readDeclIDList(SpecIDs);
2236 ASTDeclReader::RedeclarableResult
2239 RedeclarableResult Redecl = VisitVarDeclImpl(D);
2242 if (
Decl *InstD = readDecl()) {
2243 if (
auto *VTD = dyn_cast<VarTemplateDecl>(InstD)) {
2244 D->SpecializedTemplate = VTD;
2247 Record.readTemplateArgumentList(TemplArgs);
2252 VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
2253 PS->PartialSpecialization =
2254 cast<VarTemplatePartialSpecializationDecl>(InstD);
2255 PS->TemplateArgs = ArgList;
2256 D->SpecializedTemplate = PS;
2262 auto *ExplicitInfo =
2263 new (
C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo;
2264 ExplicitInfo->TypeAsWritten = TyInfo;
2265 ExplicitInfo->ExternLoc = readSourceLocation();
2266 ExplicitInfo->TemplateKeywordLoc = readSourceLocation();
2267 D->ExplicitInfo = ExplicitInfo;
2271 Record.readTemplateArgumentList(TemplArgs,
true);
2273 D->PointOfInstantiation = readSourceLocation();
2275 D->IsCompleteDefinition = Record.readInt();
2277 bool writtenAsCanonicalDecl = Record.readInt();
2278 if (writtenAsCanonicalDecl) {
2279 auto *CanonPattern = readDeclAs<VarTemplateDecl>();
2282 if (
auto *Partial = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
2283 CanonPattern->getCommonPtr()->PartialSpecializations
2284 .GetOrInsertNode(Partial);
2286 CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2302 D->TemplateParams = Params;
2303 D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2305 RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
2308 if (ThisDeclID == Redecl.getFirstID()) {
2309 D->InstantiatedFromMember.setPointer(
2310 readDeclAs<VarTemplatePartialSpecializationDecl>());
2311 D->InstantiatedFromMember.setInt(Record.readInt());
2320 if (Record.readBool()) {
2325 if (Record.readBool())
2326 ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2327 Expr *ImmediatelyDeclaredConstraint = Record.readExpr();
2329 ArgsAsWritten, ImmediatelyDeclaredConstraint);
2330 if ((D->ExpandedParameterPack = Record.readInt()))
2331 D->NumExpanded = Record.readInt();
2334 if (Record.readInt())
2339 VisitDeclaratorDecl(D);
2346 auto TypesAndInfos =
2347 D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
2349 new (&TypesAndInfos[I].first)
QualType(Record.readType());
2350 TypesAndInfos[I].second = readTypeSourceInfo();
2354 D->ParameterPack = Record.readInt();
2355 if (Record.readInt())
2361 VisitTemplateDecl(D);
2369 Data[I] = Record.readTemplateParameterList();
2372 D->ParameterPack = Record.readInt();
2373 if (Record.readInt())
2375 Record.readTemplateArgumentLoc());
2380 VisitRedeclarableTemplateDecl(D);
2385 D->AssertExprAndFailed.setPointer(Record.readExpr());
2386 D->AssertExprAndFailed.setInt(Record.readInt());
2387 D->Message = cast_or_null<StringLiteral>(Record.readExpr());
2388 D->RParenLoc = readSourceLocation();
2398 D->ExtendingDecl = readDeclAs<ValueDecl>();
2399 D->ExprWithTemporary = Record.readStmt();
2400 if (Record.readInt())
2402 D->ManglingNumber = Record.readInt();
2406 std::pair<uint64_t, uint64_t>
2408 uint64_t LexicalOffset = ReadLocalOffset();
2409 uint64_t VisibleOffset = ReadLocalOffset();
2410 return std::make_pair(LexicalOffset, VisibleOffset);
2413 template <
typename T>
2414 ASTDeclReader::RedeclarableResult
2416 DeclID FirstDeclID = readDeclID();
2417 Decl *MergeWith =
nullptr;
2419 bool IsKeyDecl = ThisDeclID == FirstDeclID;
2420 bool IsFirstLocalDecl =
false;
2422 uint64_t RedeclOffset = 0;
2426 if (FirstDeclID == 0) {
2427 FirstDeclID = ThisDeclID;
2429 IsFirstLocalDecl =
true;
2430 }
else if (
unsigned N = Record.readInt()) {
2434 IsFirstLocalDecl =
true;
2441 for (
unsigned I = 0; I != N - 1; ++I)
2442 MergeWith = readDecl();
2444 RedeclOffset = ReadLocalOffset();
2451 auto *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID));
2452 if (FirstDecl != D) {
2458 D->
First = FirstDecl->getCanonicalDecl();
2461 auto *DAsT =
static_cast<T *
>(D);
2467 if (IsFirstLocalDecl)
2468 Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset));
2470 return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl);
2475 template<
typename T>
2477 RedeclarableResult &Redecl,
2478 DeclID TemplatePatternID) {
2480 if (!Reader.getContext().getLangOpts().Modules)
2487 auto *D =
static_cast<T *
>(DBase);
2489 if (
auto *Existing = Redecl.getKnownMergeTarget())
2491 mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID);
2492 else if (FindExistingResult ExistingRes = findExisting(D))
2493 if (T *Existing = ExistingRes)
2494 mergeRedeclarable(D, Existing, Redecl, TemplatePatternID);
2502 llvm_unreachable(
"bad assert_cast");
2509 DeclID DsID,
bool IsKeyDecl) {
2512 RedeclarableResult Result( ExistingPattern,
2513 DPattern->getCanonicalDecl()->getGlobalID(),
2516 if (
auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) {
2519 auto *ExistingClass =
2521 if (
auto *DDD = DClass->DefinitionData) {
2522 if (ExistingClass->DefinitionData) {
2523 MergeDefinitionData(ExistingClass, std::move(*DDD));
2525 ExistingClass->DefinitionData = DClass->DefinitionData;
2528 Reader.PendingDefinitions.insert(DClass);
2531 DClass->DefinitionData = ExistingClass->DefinitionData;
2533 return mergeRedeclarable(DClass, cast<TagDecl>(ExistingPattern),
2536 if (
auto *DFunction = dyn_cast<FunctionDecl>(DPattern))
2537 return mergeRedeclarable(DFunction, cast<FunctionDecl>(ExistingPattern),
2539 if (
auto *DVar = dyn_cast<VarDecl>(DPattern))
2540 return mergeRedeclarable(DVar, cast<VarDecl>(ExistingPattern), Result);
2541 if (
auto *DAlias = dyn_cast<TypeAliasDecl>(DPattern))
2542 return mergeRedeclarable(DAlias, cast<TypedefNameDecl>(ExistingPattern),
2544 llvm_unreachable(
"merged an unknown kind of redeclarable template");
2549 template<
typename T>
2551 RedeclarableResult &Redecl,
2552 DeclID TemplatePatternID) {
2553 auto *D =
static_cast<T *
>(DBase);
2556 if (ExistingCanon != DCanon) {
2557 assert(DCanon->getGlobalID() == Redecl.getFirstID() &&
2558 "already merged this declaration");
2564 D->
First = ExistingCanon;
2565 ExistingCanon->Used |= D->Used;
2571 if (
auto *Namespace = dyn_cast<NamespaceDecl>(D))
2572 Namespace->AnonOrFirstNamespaceAndInline.setPointer(
2573 assert_cast<NamespaceDecl*>(ExistingCanon));
2576 if (
auto *DTemplate = dyn_cast<RedeclarableTemplateDecl>(D))
2577 mergeTemplatePattern(
2578 DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon),
2579 TemplatePatternID, Redecl.isKeyDecl());
2582 if (Redecl.isKeyDecl())
2583 Reader.KeyDecls[ExistingCanon].push_back(Redecl.getFirstID());
2596 if (isa<EnumConstantDecl>(ND))
2605 if (!Reader.getContext().getLangOpts().Modules)
2611 Reader.LETemporaryForMerging[std::make_pair(
2614 Reader.getContext().setPrimaryMergedDecl(LETDecl,
2617 LookupResult = LETDecl;
2624 template<
typename T>
2627 if (!Reader.getContext().getLangOpts().Modules)
2634 if (!Reader.getContext().getLangOpts().CPlusPlus &&
2638 if (FindExistingResult ExistingRes = findExisting(static_cast<T*>(D)))
2639 if (T *Existing = ExistingRes)
2640 Reader.getContext().setPrimaryMergedDecl(static_cast<T *>(D),
2641 Existing->getCanonicalDecl());
2648 Vars.reserve(NumVars);
2649 for (
unsigned i = 0; i != NumVars; ++i) {
2650 Vars.push_back(Record.readExpr());
2660 Vars.reserve(NumVars);
2661 for (
unsigned i = 0; i != NumVars; ++i) {
2662 Vars.push_back(Record.readExpr());
2666 Clauses.reserve(NumClauses);
2667 for (
unsigned I = 0; I != NumClauses; ++I)
2668 Clauses.push_back(Record.readOMPClause());
2669 D->setClauses(Clauses);
2676 Clauses.reserve(NumClauses);
2677 for (
unsigned I = 0; I != NumClauses; ++I)
2678 Clauses.push_back(Record.readOMPClause());
2679 D->setClauses(Clauses);
2685 Expr *In = Record.readExpr();
2686 Expr *Out = Record.readExpr();
2688 Expr *Combiner = Record.readExpr();
2690 Expr *Orig = Record.readExpr();
2691 Expr *Priv = Record.readExpr();
2693 Expr *Init = Record.readExpr();
2696 D->PrevDeclInScope = readDeclID();
2702 Expr *MapperVarRefE = Record.readExpr();
2704 D->VarName = Record.readDeclarationName();
2705 D->PrevDeclInScope = readDeclID();
2708 Clauses.reserve(NumClauses);
2709 for (
unsigned I = 0; I != NumClauses; ++I)
2710 Clauses.push_back(Record.readOMPClause());
2711 D->setClauses(Clauses);
2729 uint64_t readInt() {
2743 std::string readString() {
2755 VersionTuple readVersionTuple() {
2759 template <
typename T> T *GetLocalDeclAs(uint32_t LocalID) {
2766 AttrReader Record(*
this);
2767 auto V = Record.readInt();
2771 Attr *New =
nullptr;
2781 unsigned ParsedKind = Record.readInt();
2782 unsigned Syntax = Record.readInt();
2783 unsigned SpellingIndex = Record.readInt();
2789 #include "clang/Serialization/AttrPCHRead.inc" 2791 assert(New &&
"Unable to decode attribute?");
2797 for (
unsigned I = 0, E = readInt(); I != E; ++I)
2798 Attrs.push_back(readAttr());
2811 inline void ASTReader::LoadedDecl(
unsigned Index,
Decl *D) {
2812 assert(!DeclsLoaded[Index] &&
"Decl loaded twice?");
2813 DeclsLoaded[Index] = D;
2835 if (isa<FileScopeAsmDecl>(D) ||
2836 isa<ObjCProtocolDecl>(D) ||
2837 isa<ObjCImplDecl>(D) ||
2838 isa<ImportDecl>(D) ||
2839 isa<PragmaCommentDecl>(D) ||
2840 isa<PragmaDetectMismatchDecl>(D))
2842 if (isa<OMPThreadPrivateDecl>(D) || isa<OMPDeclareReductionDecl>(D) ||
2843 isa<OMPDeclareMapperDecl>(D) || isa<OMPAllocateDecl>(D))
2845 if (
const auto *Var = dyn_cast<VarDecl>(D))
2846 return Var->isFileVarDecl() &&
2848 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Var));
2849 if (
const auto *Func = dyn_cast<FunctionDecl>(D))
2850 return Func->doesThisDeclarationHaveABody() || HasBody;
2860 ASTReader::RecordLocation
2862 GlobalDeclMapType::iterator I = GlobalDeclMap.find(
ID);
2863 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
2867 Loc = TranslateSourceLocation(*M, DOffs.
getLocation());
2868 return RecordLocation(M, DOffs.
BitOffset);
2871 ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
2872 auto I = GlobalBitOffsetsMap.find(GlobalOffset);
2874 assert(I != GlobalBitOffsetsMap.end() &&
"Corrupted global bit offsets map");
2875 return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
2878 uint64_t ASTReader::getGlobalBitOffset(
ModuleFile &M, uint32_t LocalOffset) {
2892 if (
const auto *TX = dyn_cast<TemplateTypeParmDecl>(X)) {
2893 const auto *TY = cast<TemplateTypeParmDecl>(Y);
2894 return TX->isParameterPack() == TY->isParameterPack();
2897 if (
const auto *TX = dyn_cast<NonTypeTemplateParmDecl>(X)) {
2898 const auto *TY = cast<NonTypeTemplateParmDecl>(Y);
2899 return TX->isParameterPack() == TY->isParameterPack() &&
2900 TX->getASTContext().hasSameType(TX->getType(), TY->getType());
2903 const auto *TX = cast<TemplateTemplateParmDecl>(
X);
2904 const auto *TY = cast<TemplateTemplateParmDecl>(Y);
2905 return TX->isParameterPack() == TY->isParameterPack() &&
2907 TY->getTemplateParameters());
2914 return NAS->getNamespace();
2922 if (!NSY || NSX->getCanonicalDecl() != NSY->getCanonicalDecl())
2964 for (
unsigned I = 0, N = X->
size(); I != N; ++I)
2978 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
2982 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
2987 if (!Cand1A || !Cand2A)
2993 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
2994 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
2998 if (Cand1ID != Cand2ID)
3022 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(X))
3023 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
3025 TypedefY->getUnderlyingType());
3032 if (isa<ObjCInterfaceDecl>(X) || isa<ObjCProtocolDecl>(
X))
3035 if (isa<ClassTemplateSpecializationDecl>(X)) {
3042 if (
const auto *TagX = dyn_cast<TagDecl>(X)) {
3043 const auto *TagY = cast<TagDecl>(Y);
3044 return (TagX->getTagKind() == TagY->getTagKind()) ||
3054 if (
const auto *FuncX = dyn_cast<FunctionDecl>(X)) {
3055 const auto *FuncY = cast<FunctionDecl>(Y);
3056 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(X)) {
3057 const auto *CtorY = cast<CXXConstructorDecl>(Y);
3058 if (CtorX->getInheritedConstructor() &&
3059 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
3060 CtorY->getInheritedConstructor().getConstructor()))
3064 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
3069 if (FuncX->isMultiVersion()) {
3070 const auto *TAX = FuncX->getAttr<TargetAttr>();
3071 const auto *TAY = FuncY->getAttr<TargetAttr>();
3072 assert(TAX && TAY &&
"Multiversion Function without target attribute");
3074 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
3084 FD = FD->getCanonicalDecl();
3085 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
3088 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
3095 if (C.
getLangOpts().CPlusPlus17 && XFPT && YFPT &&
3102 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
3107 if (
const auto *VarX = dyn_cast<VarDecl>(X)) {
3108 const auto *VarY = cast<VarDecl>(Y);
3109 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
3111 if (C.
hasSameType(VarX->getType(), VarY->getType()))
3121 if (!VarXTy || !VarYTy)
3130 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(X)) {
3131 const auto *NamespaceY = cast<NamespaceDecl>(Y);
3132 return NamespaceX->isInline() == NamespaceY->isInline();
3137 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(X)) {
3138 const auto *TemplateY = cast<TemplateDecl>(Y);
3140 TemplateY->getTemplatedDecl()) &&
3142 TemplateY->getTemplateParameters());
3146 if (
const auto *FDX = dyn_cast<FieldDecl>(X)) {
3147 const auto *FDY = cast<FieldDecl>(Y);
3153 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(X)) {
3154 const auto *IFDY = cast<IndirectFieldDecl>(Y);
3155 return IFDX->getAnonField()->getCanonicalDecl() ==
3156 IFDY->getAnonField()->getCanonicalDecl();
3160 if (isa<EnumConstantDecl>(X))
3165 if (
const auto *USX = dyn_cast<UsingShadowDecl>(X)) {
3166 const auto *USY = cast<UsingShadowDecl>(Y);
3167 return USX->getTargetDecl() == USY->getTargetDecl();
3172 if (
const auto *UX = dyn_cast<UsingDecl>(X)) {
3173 const auto *UY = cast<UsingDecl>(Y);
3175 UX->hasTypename() == UY->hasTypename() &&
3176 UX->isAccessDeclaration() == UY->isAccessDeclaration();
3178 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(X)) {
3179 const auto *UY = cast<UnresolvedUsingValueDecl>(Y);
3181 UX->isAccessDeclaration() == UY->isAccessDeclaration();
3183 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(X))
3186 cast<UnresolvedUsingTypenameDecl>(Y)->getQualifier());
3189 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(X)) {
3190 const auto *NAY = cast<NamespaceAliasDecl>(Y);
3191 return NAX->getNamespace()->Equals(NAY->getNamespace());
3201 if (
auto *ND = dyn_cast<NamespaceDecl>(DC))
3202 return ND->getOriginalNamespace();
3204 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
3206 auto *DD = RD->DefinitionData;
3208 DD = RD->getCanonicalDecl()->DefinitionData;
3215 DD =
new (Reader.
getContext())
struct CXXRecordDecl::DefinitionData(RD);
3216 RD->setCompleteDefinition(
true);
3217 RD->DefinitionData = DD;
3218 RD->getCanonicalDecl()->DefinitionData = DD;
3221 Reader.PendingFakeDefinitionData.insert(
3222 std::make_pair(DD, ASTReader::PendingFakeDefinitionKind::Fake));
3225 return DD->Definition;
3228 if (
auto *ED = dyn_cast<EnumDecl>(DC))
3229 return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition()
3234 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
3240 ASTDeclReader::FindExistingResult::~FindExistingResult() {
3243 if (TypedefNameForLinkage) {
3245 Reader.ImportedTypedefNamesForLinkage.insert(
3246 std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New));
3250 if (!AddResult || Existing)
3256 setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
3257 AnonymousDeclNumber, New);
3263 }
else if (
DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
3266 MergeDC->makeDeclVisibleInContextImpl(New,
true);
3274 bool IsTypedefNameForLinkage) {
3275 if (!IsTypedefNameForLinkage)
3284 if (
auto *TND = dyn_cast<TypedefNameDecl>(Found))
3285 return TND->getAnonDeclWithTypedefName(
true);
3294 ASTDeclReader::getPrimaryDCForAnonymousDecl(
DeclContext *LexicalDC) {
3296 if (
auto *RD = dyn_cast<CXXRecordDecl>(LexicalDC)) {
3297 auto *DD = RD->getCanonicalDecl()->DefinitionData;
3298 return DD ? DD->Definition :
nullptr;
3305 if (
auto *FD = dyn_cast<FunctionDecl>(D))
3306 if (FD->isThisDeclarationADefinition())
3308 if (
auto *MD = dyn_cast<ObjCMethodDecl>(D))
3309 if (MD->isThisDeclarationADefinition())
3325 auto &
Previous = Reader.AnonymousDeclarationsForMerging[CanonDC];
3331 auto *PrimaryDC = getPrimaryDCForAnonymousDecl(DC);
3332 if (PrimaryDC && !cast<Decl>(PrimaryDC)->isFromASTFile()) {
3344 void ASTDeclReader::setAnonymousDeclForMerging(
ASTReader &Reader,
3349 auto &
Previous = Reader.AnonymousDeclarationsForMerging[CanonDC];
3356 ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(
NamedDecl *D) {
3363 FindExistingResult Result(Reader, D,
nullptr,
3364 AnonymousDeclNumber, TypedefNameForLinkage);
3370 if (TypedefNameForLinkage) {
3371 auto It = Reader.ImportedTypedefNamesForLinkage.find(
3372 std::make_pair(DC, TypedefNameForLinkage));
3373 if (It != Reader.ImportedTypedefNamesForLinkage.end())
3375 return FindExistingResult(Reader, D, It->second, AnonymousDeclNumber,
3376 TypedefNameForLinkage);
3384 if (
auto *Existing = getAnonymousDeclForMerging(
3387 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3388 TypedefNameForLinkage);
3395 class UpToDateIdentifierRAII {
3397 bool WasOutToDate =
false;
3408 ~UpToDateIdentifierRAII() {
3415 IEnd = IdResolver.
end();
3419 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3420 TypedefNameForLinkage);
3422 }
else if (
DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
3427 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
3428 TypedefNameForLinkage);
3432 return FindExistingResult(Reader);
3441 if (MergedDCIt != Reader.MergedDeclContexts.end() &&
3443 Reader.PendingOdrMergeChecks.push_back(D);
3445 return FindExistingResult(Reader, D,
nullptr,
3446 AnonymousDeclNumber, TypedefNameForLinkage);
3449 template<
typename DeclT>
3455 llvm_unreachable(
"getMostRecentDecl on non-redeclarable declaration");
3462 #define ABSTRACT_DECL(TYPE) 3463 #define DECL(TYPE, BASE) \ 3465 return getMostRecentDeclImpl(cast<TYPE##Decl>(D)); 3466 #include "clang/AST/DeclNodes.inc" 3468 llvm_unreachable(
"unknown decl kind");
3471 Decl *ASTReader::getMostRecentExistingDecl(
Decl *D) {
3475 template<
typename DeclT>
3479 D->
RedeclLink.setPrevious(cast<DeclT>(Previous));
3489 auto *VD =
static_cast<VarDecl *
>(D);
3490 auto *PrevVD = cast<VarDecl>(
Previous);
3501 VD->demoteThisDefinitionToDeclaration();
3518 auto *PrevFD = cast<FunctionDecl>(
Previous);
3521 FD->First = PrevFD->First;
3525 if (PrevFD->isInlined() != FD->isInlined()) {
3541 FD->setImplicitlyInline(
true);
3546 if (FPT && PrevFPT) {
3550 bool WasUnresolved =
3552 if (IsUnresolved != WasUnresolved)
3553 Reader.PendingExceptionSpecUpdates.insert(
3554 {Canon, IsUnresolved ? PrevFD : FD});
3560 if (IsUndeduced != WasUndeduced)
3561 Reader.PendingDeducedTypeUpdates.insert(
3562 {cast<FunctionDecl>(Canon),
3563 (IsUndeduced ? PrevFPT : FPT)->getReturnType()});
3570 llvm_unreachable(
"attachPreviousDecl on non-redeclarable declaration");
3575 template <
typename ParmDecl>
3578 auto *To = cast<ParmDecl>(ToD);
3579 if (!From->hasDefaultArgument())
3581 To->setInheritedDefaultArgument(Context, From);
3590 assert(FromTP->size() == ToTP->size() &&
"merged mismatched templates?");
3592 for (
unsigned I = 0, N = FromTP->size(); I != N; ++I) {
3593 NamedDecl *FromParam = FromTP->getParam(I);
3596 if (
auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam))
3598 else if (
auto *FNTTP = dyn_cast<NonTypeTemplateParmDecl>(FromParam))
3602 Context, cast<TemplateTemplateParmDecl>(FromParam), ToParam);
3608 assert(D && Previous);
3611 #define ABSTRACT_DECL(TYPE) 3612 #define DECL(TYPE, BASE) \ 3614 attachPreviousDeclImpl(Reader, cast<TYPE##Decl>(D), Previous, Canon); \ 3616 #include "clang/AST/DeclNodes.inc" 3630 if (
auto *TD = dyn_cast<TemplateDecl>(D))
3635 template<
typename DeclT>
3637 D->
RedeclLink.setLatest(cast<DeclT>(Latest));
3641 llvm_unreachable(
"attachLatestDecl on non-redeclarable declaration");
3645 assert(D && Latest);
3648 #define ABSTRACT_DECL(TYPE) 3649 #define DECL(TYPE, BASE) \ 3651 attachLatestDeclImpl(cast<TYPE##Decl>(D), Latest); \ 3653 #include "clang/AST/DeclNodes.inc" 3657 template<
typename DeclT>
3663 llvm_unreachable(
"markIncompleteDeclChain on non-redeclarable declaration");
3666 void ASTReader::markIncompleteDeclChain(
Decl *D) {
3668 #define ABSTRACT_DECL(TYPE) 3669 #define DECL(TYPE, BASE) \ 3671 ASTDeclReader::markIncompleteDeclChainImpl(cast<TYPE##Decl>(D)); \ 3673 #include "clang/AST/DeclNodes.inc" 3681 RecordLocation Loc = DeclCursorForID(ID, DeclLoc);
3682 llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
3687 ReadingKindTracker ReadingKind(Read_Decl, *
this);
3690 Deserializing ADecl(
this);
3692 auto Fail = [](
const char *what,
llvm::Error &&Err) {
3693 llvm::report_fatal_error(Twine(
"ASTReader::readDeclRecord failed ") + what +
3697 if (
llvm::Error JumpFailed = DeclsCursor.JumpToBit(Loc.Offset))
3698 Fail(
"jumping", std::move(JumpFailed));
3703 Fail(
"reading code", MaybeCode.takeError());
3704 unsigned Code = MaybeCode.get();
3710 llvm::report_fatal_error(
3711 "ASTReader::readDeclRecord failed reading decl code: " +
3712 toString(MaybeDeclCode.takeError()));
3713 switch ((
DeclCode)MaybeDeclCode.get()) {
3716 llvm_unreachable(
"Record cannot be de-serialized with readDeclRecord");
3823 bool HasTypeConstraint = Record.
readInt();
3829 bool HasTypeConstraint = Record.
readInt();
3835 bool HasTypeConstraint = Record.
readInt();
3927 Error(
"attempt to read a C++ base-specifier record as a declaration");
3930 Error(
"attempt to read a C++ ctor initializer record as a declaration");
3941 unsigned NumVars = Record.
readInt();
3942 unsigned NumClauses = Record.
readInt();
3976 assert(D &&
"Unknown declaration reading AST file");
3977 LoadedDecl(Index, D);
3986 if (
auto *DC = dyn_cast<DeclContext>(D)) {
3988 if (Offsets.first &&
3989 ReadLexicalDeclContextStorage(*Loc.F, DeclsCursor, Offsets.first, DC))
3991 if (Offsets.second &&
3992 ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID))
3998 PendingUpdateRecords.push_back(
3999 PendingUpdateRecord(ID, D,
true));
4002 if (
auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
4005 if (Class->isThisDeclarationADefinition() ||
4006 PendingDefinitions.count(Class))
4007 loadObjCCategories(ID, Class);
4013 PotentiallyInterestingDecls.push_back(
4019 void ASTReader::PassInterestingDeclsToConsumer() {
4022 if (PassingDeclsToConsumer)
4032 for (
auto ID : EagerlyDeserializedDecls)
4034 EagerlyDeserializedDecls.clear();
4036 while (!PotentiallyInterestingDecls.empty()) {
4037 InterestingDecl D = PotentiallyInterestingDecls.front();
4038 PotentiallyInterestingDecls.pop_front();
4040 PassInterestingDeclToConsumer(D.getDecl());
4044 void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
4050 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
4051 DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
4055 if (UpdI != DeclUpdateOffsets.end()) {
4056 auto UpdateOffsets = std::move(UpdI->second);
4057 DeclUpdateOffsets.erase(UpdI);
4063 bool WasInteresting =
4065 for (
auto &FileAndOffset : UpdateOffsets) {
4067 uint64_t
Offset = FileAndOffset.second;
4070 if (
llvm::Error JumpFailed = Cursor.JumpToBit(Offset))
4072 llvm::report_fatal_error(
4073 "ASTReader::loadDeclUpdateRecords failed jumping: " +
4077 llvm::report_fatal_error(
4078 "ASTReader::loadDeclUpdateRecords failed reading code: " +
4080 unsigned Code = MaybeCode.get();
4084 "Expected DECL_UPDATES record!");
4086 llvm::report_fatal_error(
4087 "ASTReader::loadDeclUpdateRecords failed reading rec code: " +
4090 ASTDeclReader Reader(*
this, Record, RecordLocation(F, Offset), ID,
4092 Reader.
UpdateDecl(D, PendingLazySpecializationIDs);
4096 if (!WasInteresting &&
4098 PotentiallyInterestingDecls.push_back(
4100 WasInteresting =
true;
4105 assert((PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) ||
4106 isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) &&
4107 "Must not have pending specializations");
4108 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(D))
4110 else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
4112 else if (
auto *VTD = dyn_cast<VarTemplateDecl>(D))
4114 PendingLazySpecializationIDs.clear();
4117 auto I = PendingVisibleUpdates.find(ID);
4118 if (I != PendingVisibleUpdates.end()) {
4119 auto VisibleUpdates = std::move(I->second);
4120 PendingVisibleUpdates.erase(I);
4122 auto *DC = cast<DeclContext>(D)->getPrimaryContext();
4123 for (
const auto &
Update : VisibleUpdates)
4124 Lookups[DC].Table.add(
4131 void ASTReader::loadPendingDeclChain(
Decl *FirstLocal, uint64_t LocalOffset) {
4134 if (FirstLocal != CanonDecl) {
4137 *
this, FirstLocal, PrevMostRecent ? PrevMostRecent : CanonDecl,
4147 ModuleFile *M = getOwningModuleFile(FirstLocal);
4148 assert(M &&
"imported decl from no module file");
4152 if (
llvm::Error JumpFailed = Cursor.JumpToBit(LocalOffset))
4153 llvm::report_fatal_error(
4154 "ASTReader::loadPendingDeclChain failed jumping: " +
4160 llvm::report_fatal_error(
4161 "ASTReader::loadPendingDeclChain failed reading code: " +
4163 unsigned Code = MaybeCode.get();
4166 "expected LOCAL_REDECLARATIONS record!");
4168 llvm::report_fatal_error(
4169 "ASTReader::loadPendingDeclChain failed reading rec code: " +
4174 Decl *MostRecent = FirstLocal;
4175 for (
unsigned I = 0, N = Record.size(); I != N; ++I) {
4176 auto *D = GetLocalDecl(*M, Record[N - I - 1]);
4187 class ObjCCategoriesVisitor {
4190 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized;
4192 llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap;
4194 unsigned PreviousGeneration;
4198 if (!Deserialized.erase(Cat))
4221 }
else if (!Existing) {
4236 ObjCCategoriesVisitor(
ASTReader &Reader,
4238 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
4240 unsigned PreviousGeneration)
4241 : Reader(Reader), Interface(Interface), Deserialized(Deserialized),
4242 InterfaceID(InterfaceID), PreviousGeneration(PreviousGeneration) {
4285 for (
unsigned I = 0; I != N; ++I)
4286 add(cast_or_null<ObjCCategoryDecl>(
4296 unsigned PreviousGeneration) {
4297 ObjCCategoriesVisitor Visitor(*
this, D, CategoriesDeserialized,
ID,
4298 PreviousGeneration);
4299 ModuleMgr.visit(Visitor);
4302 template<
typename DeclT,
typename Fn>
4309 auto *MostRecent = D->getMostRecentDecl();
4311 for (
auto *Redecl = MostRecent; Redecl && !Found;
4312 Redecl = Redecl->getPreviousDecl())
4313 Found = (Redecl == D);
4317 for (
auto *Redecl = MostRecent; Redecl != D;
4318 Redecl = Redecl->getPreviousDecl())
4325 while (Record.getIdx() < Record.size()) {
4328 auto *RD = cast<CXXRecordDecl>(D);
4331 Decl *MD = Record.readDecl();
4332 assert(MD &&
"couldn't read decl from update record");
4335 RD->addedMember(MD);
4341 PendingLazySpecializationIDs.push_back(readDeclID());
4345 auto *Anon = readDeclAs<NamespaceDecl>();
4350 if (!Record.isModule()) {
4351 if (
auto *TU = dyn_cast<TranslationUnitDecl>(D))
4352 TU->setAnonymousNamespace(Anon);
4354 cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
4360 auto *VD = cast<VarDecl>(D);
4361 VD->NonParmVarDeclBits.IsInline = Record.readInt();
4362 VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
4363 uint64_t Val = Record.readInt();
4364 if (Val && !VD->getInit()) {
4365 VD->setInit(Record.readExpr());
4369 Eval->
IsICE = Val == 3;
4377 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D)) {
4378 VTSD->setPointOfInstantiation(POI);
4379 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
4380 VD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
4382 auto *FD = cast<FunctionDecl>(D);
4383 if (
auto *FTSInfo = FD->TemplateOrSpecialization
4385 FTSInfo->setPointOfInstantiation(POI);
4388 ->setPointOfInstantiation(POI);
4394 auto *Param = cast<ParmVarDecl>(D);
4399 auto *DefaultArg = Record.readExpr();
4403 if (Param->hasUninstantiatedDefaultArg())
4404 Param->setDefaultArg(DefaultArg);
4409 auto *FD = cast<FieldDecl>(D);
4410 auto *DefaultInit = Record.readExpr();
4414 if (FD->hasInClassInitializer() && !FD->getInClassInitializer()) {
4416 FD->setInClassInitializer(DefaultInit);
4420 FD->removeInClassInitializer();
4426 auto *FD = cast<FunctionDecl>(D);
4427 if (Reader.PendingBodies[FD]) {
4433 if (Record.readInt()) {
4441 FD->setInnerLocStart(readSourceLocation());
4442 ReadFunctionDefinition(FD);
4443 assert(Record.getIdx() == Record.size() &&
"lazy body must be last");
4448 auto *RD = cast<CXXRecordDecl>(D);
4449 auto *OldDD = RD->getCanonicalDecl()->DefinitionData;
4450 bool HadRealDefinition =
4451 OldDD && (OldDD->Definition != RD ||
4452 !Reader.PendingFakeDefinitionData.count(OldDD));
4453 RD->setParamDestroyedInCallee(Record.readInt());
4454 RD->setArgPassingRestrictions(
4456 ReadCXXRecordDefinition(RD,
true);
4459 uint64_t LexicalOffset = ReadLocalOffset();
4460 if (!HadRealDefinition && LexicalOffset) {
4461 Record.readLexicalDeclContextStorage(LexicalOffset, RD);
4462 Reader.PendingFakeDefinitionData.erase(OldDD);
4468 RD->getMemberSpecializationInfo()) {
4469 MSInfo->setTemplateSpecializationKind(TSK);
4470 MSInfo->setPointOfInstantiation(POI);
4472 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
4473 Spec->setTemplateSpecializationKind(TSK);
4474 Spec->setPointOfInstantiation(POI);
4476 if (Record.readInt()) {
4478 readDeclAs<ClassTemplatePartialSpecializationDecl>();
4480 Record.readTemplateArgumentList(TemplArgs);
4486 if (!Spec->getSpecializedTemplateOrPartial()
4488 Spec->setInstantiationOf(PartialSpec, TemplArgList);
4493 RD->setLocation(readSourceLocation());
4494 RD->setLocStart(readSourceLocation());
4495 RD->setBraceRange(readSourceRange());
4497 if (Record.readInt()) {
4499 Record.readAttributes(Attrs);
4511 auto *Del = readDeclAs<FunctionDecl>();
4513 auto *ThisArg = Record.readExpr();
4515 if (!First->OperatorDelete) {
4516 First->OperatorDelete = Del;
4517 First->OperatorDeleteThisArg = ThisArg;
4524 auto ESI = Record.readExceptionSpecInfo(ExceptionStorage);
4527 auto *FD = cast<FunctionDecl>(D);
4533 FPT->getReturnType(), FPT->getParamTypes(),
4534 FPT->getExtProtoInfo().withExceptionSpec(ESI)));
4538 Reader.PendingExceptionSpecUpdates.insert(
4539 std::make_pair(FD->getCanonicalDecl(), FD));
4545 auto *FD = cast<FunctionDecl>(D);
4546 QualType DeducedResultType = Record.readType();
4547 Reader.PendingDeducedTypeUpdates.insert(
4548 {FD->getCanonicalDecl(), DeducedResultType});
4568 D->
addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(
4574 auto AllocatorKind =
4575 static_cast<OMPAllocateDeclAttr::AllocatorTypeTy
>(Record.readInt());
4576 Expr *Allocator = Record.readExpr();
4578 D->
addAttr(OMPAllocateDeclAttr::CreateImplicit(
4579 Reader.
getContext(), AllocatorKind, Allocator, SR,
4586 auto *Exported = cast<NamedDecl>(D);
4589 Reader.PendingMergedDefinitionsToDeduplicate.insert(Exported);
4594 OMPDeclareTargetDeclAttr::MapTypeTy MapType =
4595 static_cast<OMPDeclareTargetDeclAttr::MapTypeTy
>(Record.readInt());
4596 OMPDeclareTargetDeclAttr::DevTypeTy DevType =
4597 static_cast<OMPDeclareTargetDeclAttr::DevTypeTy
>(Record.readInt());
4598 D->
addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(
4599 Reader.
getContext(), MapType, DevType, readSourceRange(),
4606 Record.readAttributes(Attrs);
4607 assert(Attrs.size() == 1);
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 setGetterMethodDecl(ObjCMethodDecl *MD)
void setInitializerData(Expr *OrigE, Expr *PrivE)
Set initializer Orig and Priv vars.
void setNonTrivialToPrimitiveDestroy(bool V)
void VisitVarDecl(VarDecl *VD)
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.
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)
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)
FunctionType - C99 6.7.5.3 - Function Declarators.
This represents '#pragma omp allocate ...' directive.
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...
static LifetimeExtendedTemporaryDecl * CreateDeserialized(ASTContext &C, unsigned ID)
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...
unsigned clauselist_size() const
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.
Decl - This represents one declaration (or definition), e.g.
Syntax
The style used to specify an attribute.
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.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
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 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.
for(auto typeArg :T->getTypeArgsAsWritten())
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...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
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...
static OMPDeclareMapperDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Creates deserialized declare mapper node.
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.
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.
ValueDecl * getExtendingDecl()
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 ...
A C++ nested-name-specifier augmented with source location information.
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.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
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)
Expr * readExpr()
Reads an expression.
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)
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'.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
void setUsesFPIntrin(bool Val)
Represents a C++ using-declaration.
A RequiresExprBodyDecl record.
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.
Represents the results of name lookup.
static llvm::iterator_range< MergedRedeclIterator< DeclT > > merged_redecls(DeclT *D)
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
ObjCContainerDecl - Represents a container for method declarations.
void setAccessControl(AccessControl ac)
static void attachLatestDecl(Decl *D, Decl *latest)
< 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...
void setDefaultedFunctionInfo(DefaultedFunctionInfo *Info)
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)
bool isPartOfPerModuleInitializer(const Decl *D)
Determine whether the given declaration will be included in the per-module initializer if it needs to...
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.
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.
uint64_t back()
Returns the last value in this record.
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...
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)
unsigned varlist_size() const
TypeSourceInfo * readTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
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.
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...
Represents 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.
Represents the body of a requires-expression.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
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.
Expected< unsigned > readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
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()
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 VisitConceptDecl(ConceptDecl *D)
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.
static DefaultedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups)
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...
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)
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 setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool HasTypeConstraint)
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.
static OMPAllocateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NVars, unsigned NClauses)
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...
An LifetimeExtendedTemporaryDecl record.
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.
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 VisitLifetimeExtendedTemporaryDecl(LifetimeExtendedTemporaryDecl *D)
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 VisitRequiresExprBodyDecl(RequiresExprBodyDecl *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 readAttributes(AttrVec &Attrs)
Reads attributes from the current stream position, advancing Idx.
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)
void setSetterMethodDecl(ObjCMethodDecl *MD)
Represents a static or instance method of a struct/union/class.
Attr * readAttr()
Reads one attribute from the current stream position, advancing Idx.
void setDefaulted(bool D=true)
void setHasFlexibleArrayMember(bool V)
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
T * GetLocalDeclAs(uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
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...
static ConceptDecl * CreateDeserialized(ASTContext &C, unsigned ID)
FunctionDecl * getFunction() const
Retrieve the declaration of the function template specialization.
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.
Defines the clang::Module class, which describes a module in the source code.
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.
void setMapperVarRef(Expr *MapperVarRefE)
Set the variable declared in the mapper.
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.
An OMPDeclareMapperDecl record.
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.
An OMPAllocateDcl record.
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.
bool hasPlaceholderTypeConstraint() const
Determine whether this non-type template parameter's type has a placeholder with a type-constraint...
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()
void setPlaceholderTypeConstraint(Expr *E)
ComparisonCategoryResult Compare(const T &X, const T &Y)
Helper to compare two comparable types.
Dataflow Directional Tag Classes.
void VisitCXXConversionDecl(CXXConversionDecl *D)
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
void setBody(CompoundStmt *B)
unsigned getManglingNumber() const
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)
bool HasConstantDestruction
Whether this variable is known to have constant destruction.
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. ...
IdentifierInfo * readIdentifier()
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)
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.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
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.
VersionTuple readVersionTuple()
Read a version tuple, advancing Idx.
All of the names in this module are visible.
uint64_t readInt()
Returns the current value in this record, and advances to the next value.
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 VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D)
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)
Read information about an exception specification (inherited).
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setConstexprKind(ConstexprSpecKind CSK)
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.
void setHasNonTrivialToPrimitiveDestructCUnion(bool V)
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Capturing the *this object by reference.
unsigned clauselist_size() const
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, unsigned ID, uint64_t AllocKind)
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 setDescribedVarTemplate(VarTemplateDecl *Template)
void setInstanceMethod(bool isInst)
void setHasRedeclaration(bool HRD) const
void setSynthesizedAccessorStub(bool isSynthesizedAccessorStub)
void setClassInterface(ObjCInterfaceDecl *IFace)
void setDecomposedDecl(ValueDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
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 setCanAvoidCopyToHeap(bool B=true)
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
void setReturnTypeSourceInfo(TypeSourceInfo *TInfo)
void setHasNonTrivialToPrimitiveCopyCUnion(bool V)
A ObjCAtDefsFieldDecl record.
static RequiresExprBodyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Declaration of a class template.
void VisitOMPAllocateDecl(OMPAllocateDecl *D)
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)
This represents '#pragma omp declare mapper ...' directive.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
void VisitClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl *D)
unsigned clauselist_size() const
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
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 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.
void setHasNonTrivialToPrimitiveDefaultInitializeCUnion(bool V)
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.