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());
168 void ReadCXXDefinitionData(
struct CXXRecordDecl::DefinitionData &Data,
171 struct CXXRecordDecl::DefinitionData &&NewDD);
172 void ReadObjCDefinitionData(
struct ObjCInterfaceDecl::DefinitionData &Data);
174 struct ObjCInterfaceDecl::DefinitionData &&NewDD);
175 void ReadObjCDefinitionData(
struct ObjCProtocolDecl::DefinitionData &Data);
177 struct ObjCProtocolDecl::DefinitionData &&NewDD);
188 class RedeclarableResult {
195 : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {}
201 bool isKeyDecl()
const {
return IsKeyDecl; }
205 Decl *getKnownMergeTarget()
const {
return MergeWith; }
213 class FindExistingResult {
217 bool AddResult =
false;
218 unsigned AnonymousDeclNumber = 0;
222 FindExistingResult(
ASTReader &Reader) : Reader(Reader) {}
225 unsigned AnonymousDeclNumber,
227 : Reader(Reader), New(New), Existing(Existing), AddResult(
true),
228 AnonymousDeclNumber(AnonymousDeclNumber),
229 TypedefNameForLinkage(TypedefNameForLinkage) {}
231 FindExistingResult(FindExistingResult &&Other)
232 : Reader(Other.Reader), New(Other.New), Existing(Other.Existing),
233 AddResult(Other.AddResult),
234 AnonymousDeclNumber(Other.AnonymousDeclNumber),
235 TypedefNameForLinkage(Other.TypedefNameForLinkage) {
236 Other.AddResult =
false;
239 FindExistingResult &operator=(FindExistingResult &&) =
delete;
240 ~FindExistingResult();
244 void suppress() { AddResult =
false; }
246 operator NamedDecl*()
const {
return Existing; }
249 operator T*()
const {
return dyn_cast_or_null<T>(Existing); }
254 FindExistingResult findExisting(
NamedDecl *D);
258 ASTReader::RecordLocation Loc,
260 : Reader(Reader), Record(Record), Loc(Loc), ThisDeclID(thisDeclID),
261 ThisDeclLoc(ThisDeclLoc) {}
263 template <
typename T>
static 272 auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations;
274 if (
auto &Old = LazySpecializations) {
275 IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
277 IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
281 *Result = IDs.size();
282 std::copy(IDs.begin(), IDs.end(), Result + 1);
284 LazySpecializations = Result;
287 template <
typename DeclT>
289 static Decl *getMostRecentDeclImpl(...);
290 static Decl *getMostRecentDecl(
Decl *D);
292 template <
typename DeclT>
293 static void attachPreviousDeclImpl(
ASTReader &Reader,
296 static void attachPreviousDeclImpl(
ASTReader &Reader, ...);
300 template <
typename DeclT>
302 static void attachLatestDeclImpl(...);
303 static void attachLatestDecl(
Decl *D,
Decl *latest);
305 template <
typename DeclT>
307 static void markIncompleteDeclChainImpl(...);
319 Cat->NextClassCategory = Next;
322 void VisitDecl(
Decl *D);
336 RedeclarableResult VisitTagDecl(
TagDecl *TD);
338 RedeclarableResult VisitRecordDeclImpl(
RecordDecl *RD);
342 RedeclarableResult VisitClassTemplateSpecializationDeclImpl(
347 VisitClassTemplateSpecializationDeclImpl(D);
350 void VisitClassTemplatePartialSpecializationDecl(
352 void VisitClassScopeFunctionSpecializationDecl(
358 VisitVarTemplateSpecializationDeclImpl(D);
361 void VisitVarTemplatePartialSpecializationDecl(
377 RedeclarableResult VisitVarDeclImpl(
VarDecl *D);
409 std::pair<uint64_t, uint64_t> VisitDeclContext(
DeclContext *DC);
416 DeclID TemplatePatternID = 0);
420 RedeclarableResult &Redecl,
421 DeclID TemplatePatternID = 0);
428 DeclID DsID,
bool IsKeyDecl);
461 template<
typename DeclT>
462 class MergedRedeclIterator {
464 DeclT *Canonical =
nullptr;
465 DeclT *Current =
nullptr;
468 MergedRedeclIterator() =
default;
469 MergedRedeclIterator(DeclT *Start) : Start(Start), Current(Start) {}
473 MergedRedeclIterator &operator++() {
474 if (Current->isFirstDecl()) {
476 Current = Current->getMostRecentDecl();
478 Current = Current->getPreviousDecl();
484 if (Current == Start || Current == Canonical)
489 friend bool operator!=(
const MergedRedeclIterator &A,
490 const MergedRedeclIterator &B) {
491 return A.Current != B.Current;
497 template <
typename DeclT>
498 static llvm::iterator_range<MergedRedeclIterator<DeclT>>
500 return llvm::make_range(MergedRedeclIterator<DeclT>(D),
501 MergedRedeclIterator<DeclT>());
504 uint64_t ASTDeclReader::GetCurrentCursorOffset() {
505 return Loc.F->DeclsCursor.GetCurrentBitNo() + Loc.F->GlobalBitOffset;
509 if (Record.readInt())
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)) {
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 ReadQualifierInfo(*Info);
720 TD->TypedefNameDeclOrQualifier = Info;
724 NamedDeclForTagDecl = ReadDeclID();
725 TypedefNameForLinkage = Record.getIdentifierInfo();
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 ReadQualifierInfo(*Info);
832 QualType TSIType = Record.readType();
834 TSIType.
isNull() ? nullptr
835 : Reader.getContext().CreateTypeSourceInfo(TSIType));
839 RedeclarableResult Redecl = VisitRedeclarable(FD);
840 VisitDeclaratorDecl(FD);
850 Reader.PendingFunctionTypes.push_back({FD, DeferredTypeID});
852 FD->
setType(Reader.GetType(DeferredTypeID));
856 ReadDeclarationNameLoc(FD->DNLoc, FD->
getDeclName());
882 FD->EndRangeLoc = ReadSourceLocation();
884 FD->ODRHash = Record.readInt();
885 FD->setHasODRHash(
true);
889 mergeRedeclarable(FD, Redecl);
896 auto *InstFD = ReadDeclAs<FunctionDecl>();
899 FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
901 mergeRedeclarable(FD, Redecl);
905 auto *Template = ReadDeclAs<FunctionTemplateDecl>();
910 Record.readTemplateArgumentList(TemplArgs,
true);
915 bool HasTemplateArgumentsAsWritten = Record.readInt();
916 if (HasTemplateArgumentsAsWritten) {
917 unsigned NumTemplateArgLocs = Record.readInt();
918 TemplArgLocs.reserve(NumTemplateArgLocs);
919 for (
unsigned i = 0;
i != NumTemplateArgLocs; ++
i)
920 TemplArgLocs.push_back(Record.readTemplateArgumentLoc());
922 LAngleLoc = ReadSourceLocation();
923 RAngleLoc = ReadSourceLocation();
932 for (
unsigned i = 0, e = TemplArgLocs.size();
i != e; ++
i)
936 if (Record.readInt()) {
937 auto *FD = ReadDeclAs<FunctionDecl>();
947 C, FD, Template, TSK, TemplArgList,
948 HasTemplateArgumentsAsWritten ? &TemplArgsInfo :
nullptr, POI,
950 FD->TemplateOrSpecialization = FTInfo;
955 auto *CanonTemplate = ReadDeclAs<FunctionTemplateDecl>();
961 llvm::FoldingSetNodeID
ID;
963 void *InsertPos =
nullptr;
970 assert(Reader.getContext().getLangOpts().Modules &&
971 "already deserialized this template specialization");
972 mergeRedeclarable(FD, ExistingInfo->
getFunction(), Redecl);
980 unsigned NumTemplates = Record.readInt();
981 while (NumTemplates--)
982 TemplDecls.
addDecl(ReadDeclAs<NamedDecl>());
986 unsigned NumArgs = Record.readInt();
988 TemplArgs.
addArgument(Record.readTemplateArgumentLoc());
993 TemplDecls, TemplArgs);
1001 unsigned NumParams = Record.readInt();
1003 Params.reserve(NumParams);
1004 for (
unsigned I = 0; I != NumParams; ++I)
1005 Params.push_back(ReadDeclAs<ParmVarDecl>());
1006 FD->setParams(Reader.getContext(), Params);
1011 if (Record.readInt()) {
1014 Reader.PendingBodies[MD] = GetCurrentCursorOffset();
1015 HasPendingBody =
true;
1017 MD->
setCmdDecl(ReadDeclAs<ImplicitParamDecl>());
1029 Reader.getContext().setObjCMethodRedeclaration(MD,
1030 ReadDeclAs<ObjCMethodDecl>());
1037 MD->DeclEndLoc = ReadSourceLocation();
1038 unsigned NumParams = Record.readInt();
1040 Params.reserve(NumParams);
1041 for (
unsigned I = 0; I != NumParams; ++I)
1042 Params.push_back(ReadDeclAs<ParmVarDecl>());
1045 unsigned NumStoredSelLocs = Record.readInt();
1047 SelLocs.reserve(NumStoredSelLocs);
1048 for (
unsigned i = 0;
i != NumStoredSelLocs; ++
i)
1049 SelLocs.push_back(ReadSourceLocation());
1051 MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs);
1055 VisitTypedefNameDecl(D);
1057 D->Variance = Record.readInt();
1058 D->Index = Record.readInt();
1059 D->VarianceLoc = ReadSourceLocation();
1060 D->ColonLoc = ReadSourceLocation();
1070 unsigned numParams = Record.readInt();
1075 typeParams.reserve(numParams);
1076 for (
unsigned i = 0;
i != numParams; ++
i) {
1077 auto *typeParam = ReadDeclAs<ObjCTypeParamDecl>();
1081 typeParams.push_back(typeParam);
1088 typeParams, rAngleLoc);
1091 void ASTDeclReader::ReadObjCDefinitionData(
1092 struct ObjCInterfaceDecl::DefinitionData &Data) {
1094 Data.SuperClassTInfo = GetTypeSourceInfo();
1096 Data.EndLoc = ReadSourceLocation();
1097 Data.HasDesignatedInitializers = Record.readInt();
1100 unsigned NumProtocols = Record.readInt();
1102 Protocols.reserve(NumProtocols);
1103 for (
unsigned I = 0; I != NumProtocols; ++I)
1104 Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
1106 ProtoLocs.reserve(NumProtocols);
1107 for (
unsigned I = 0; I != NumProtocols; ++I)
1108 ProtoLocs.push_back(ReadSourceLocation());
1109 Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, ProtoLocs.data(),
1110 Reader.getContext());
1113 NumProtocols = Record.readInt();
1115 Protocols.reserve(NumProtocols);
1116 for (
unsigned I = 0; I != NumProtocols; ++I)
1117 Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
1118 Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
1119 Reader.getContext());
1123 struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
1128 RedeclarableResult Redecl = VisitRedeclarable(ID);
1129 VisitObjCContainerDecl(ID);
1130 DeferredTypeID = Record.getGlobalTypeID(Record.readInt());
1131 mergeRedeclarable(ID, Redecl);
1133 ID->TypeParamList = ReadObjCTypeParamList();
1134 if (Record.readInt()) {
1136 ID->allocateDefinitionData();
1138 ReadObjCDefinitionData(ID->data());
1140 if (Canon->Data.getPointer()) {
1143 MergeDefinitionData(Canon, std::move(ID->data()));
1144 ID->Data = Canon->Data;
1155 Reader.PendingDefinitions.insert(ID);
1158 Reader.ObjCClassesLoaded.push_back(ID);
1165 VisitFieldDecl(IVD);
1169 bool synth = Record.readInt();
1173 void ASTDeclReader::ReadObjCDefinitionData(
1174 struct ObjCProtocolDecl::DefinitionData &Data) {
1175 unsigned NumProtoRefs = Record.readInt();
1177 ProtoRefs.reserve(NumProtoRefs);
1178 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1179 ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
1181 ProtoLocs.reserve(NumProtoRefs);
1182 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1183 ProtoLocs.push_back(ReadSourceLocation());
1184 Data.ReferencedProtocols.set(ProtoRefs.data(), NumProtoRefs,
1185 ProtoLocs.data(), Reader.getContext());
1189 struct ObjCProtocolDecl::DefinitionData &&NewDD) {
1194 RedeclarableResult Redecl = VisitRedeclarable(PD);
1195 VisitObjCContainerDecl(PD);
1196 mergeRedeclarable(PD, Redecl);
1198 if (Record.readInt()) {
1200 PD->allocateDefinitionData();
1202 ReadObjCDefinitionData(PD->data());
1205 if (Canon->Data.getPointer()) {
1208 MergeDefinitionData(Canon, std::move(PD->data()));
1209 PD->Data = Canon->Data;
1216 Reader.PendingDefinitions.insert(PD);
1227 VisitObjCContainerDecl(CD);
1235 Reader.CategoriesDeserialized.insert(CD);
1237 CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>();
1238 CD->TypeParamList = ReadObjCTypeParamList();
1239 unsigned NumProtoRefs = Record.readInt();
1241 ProtoRefs.reserve(NumProtoRefs);
1242 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1243 ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
1245 ProtoLocs.reserve(NumProtoRefs);
1246 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1247 ProtoLocs.push_back(ReadSourceLocation());
1249 Reader.getContext());
1255 Reader.getContext());
1259 VisitNamedDecl(CAD);
1288 VisitObjCContainerDecl(D);
1293 VisitObjCImplDecl(D);
1294 D->CategoryNameLoc = ReadSourceLocation();
1298 VisitObjCImplDecl(D);
1300 D->SuperLoc = ReadSourceLocation();
1305 D->NumIvarInitializers = Record.readInt();
1306 if (D->NumIvarInitializers)
1307 D->IvarInitializers = ReadGlobalOffset();
1314 D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>();
1315 D->IvarLoc = ReadSourceLocation();
1321 VisitDeclaratorDecl(FD);
1322 FD->Mutable = Record.readInt();
1324 if (
auto ISK = static_cast<FieldDecl::InitStorageKind>(Record.readInt())) {
1325 FD->InitStorage.setInt(ISK);
1326 FD->InitStorage.setPointer(ISK == FieldDecl::ISK_CapturedVLAType
1327 ? Record.readType().getAsOpaquePtr()
1328 : Record.readExpr());
1331 if (
auto *BW = Record.readExpr())
1335 if (
auto *Tmpl = ReadDeclAs<FieldDecl>())
1336 Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
1342 VisitDeclaratorDecl(PD);
1343 PD->GetterId = Record.getIdentifierInfo();
1344 PD->SetterId = Record.getIdentifierInfo();
1350 FD->ChainingSize = Record.readInt();
1351 assert(FD->ChainingSize >= 2 &&
"Anonymous chaining must be >= 2");
1352 FD->Chaining =
new (Reader.getContext())
NamedDecl*[FD->ChainingSize];
1354 for (
unsigned I = 0; I != FD->ChainingSize; ++I)
1355 FD->Chaining[I] = ReadDeclAs<NamedDecl>();
1361 RedeclarableResult Redecl = VisitRedeclarable(VD);
1362 VisitDeclaratorDecl(VD);
1367 VD->
VarDeclBits.ARCPseudoStrong = Record.readInt();
1368 if (!isa<ParmVarDecl>(VD)) {
1383 auto VarLinkage =
Linkage(Record.readInt());
1391 if (uint64_t Val = Record.readInt()) {
1392 VD->
setInit(Record.readExpr());
1396 Eval->
IsICE = Val == 3;
1401 Expr *CopyExpr = Record.readExpr();
1403 Reader.getContext().setBlockVarCopyInit(VD, CopyExpr, Record.readInt());
1410 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1412 switch ((VarKind)Record.readInt()) {
1413 case VarNotTemplate:
1416 if (!isa<ParmVarDecl>(VD) && !isa<ImplicitParamDecl>(VD) &&
1417 !isa<VarTemplateSpecializationDecl>(VD))
1418 mergeRedeclarable(VD, Redecl);
1422 VD->setDescribedVarTemplate(ReadDeclAs<VarTemplateDecl>());
1424 case StaticDataMemberSpecialization: {
1425 auto *Tmpl = ReadDeclAs<VarDecl>();
1428 Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
1429 mergeRedeclarable(VD, Redecl);
1443 unsigned isObjCMethodParam = Record.readInt();
1444 unsigned scopeDepth = Record.readInt();
1445 unsigned scopeIndex = Record.readInt();
1446 unsigned declQualifier = Record.readInt();
1447 if (isObjCMethodParam) {
1448 assert(scopeDepth == 0);
1456 if (Record.readInt())
1465 auto **BDs = DD->getTrailingObjects<
BindingDecl *>();
1466 for (
unsigned I = 0; I != DD->NumBindings; ++I) {
1467 BDs[I] = ReadDeclAs<BindingDecl>();
1474 BD->Binding = Record.readExpr();
1479 AD->
setAsmString(cast<StringLiteral>(Record.readExpr()));
1485 BD->
setBody(cast_or_null<CompoundStmt>(Record.readStmt()));
1487 unsigned NumParams = Record.readInt();
1489 Params.reserve(NumParams);
1490 for (
unsigned I = 0; I != NumParams; ++I)
1491 Params.push_back(ReadDeclAs<ParmVarDecl>());
1500 bool capturesCXXThis = Record.readInt();
1501 unsigned numCaptures = Record.readInt();
1503 captures.reserve(numCaptures);
1504 for (
unsigned i = 0;
i != numCaptures; ++
i) {
1505 auto *
decl = ReadDeclAs<VarDecl>();
1506 unsigned flags = Record.readInt();
1507 bool byRef = (flags & 1);
1508 bool nested = (flags & 2);
1509 Expr *copyExpr = ((flags & 4) ? Record.readExpr() :
nullptr);
1513 BD->
setCaptures(Reader.getContext(), captures, capturesCXXThis);
1518 unsigned ContextParamPos = Record.readInt();
1521 for (
unsigned I = 0; I < CD->NumParams; ++I) {
1522 if (I != ContextParamPos)
1523 CD->
setParam(I, ReadDeclAs<ImplicitParamDecl>());
1538 D->RBraceLoc = ReadSourceLocation();
1547 RedeclarableResult Redecl = VisitRedeclarable(D);
1550 D->LocStart = ReadSourceLocation();
1551 D->RBraceLoc = ReadSourceLocation();
1558 if (Redecl.getFirstID() == ThisDeclID) {
1559 AnonNamespace = ReadDeclID();
1563 D->AnonOrFirstNamespaceAndInline.setPointer(D->
getFirstDecl());
1566 mergeRedeclarable(D, Redecl);
1568 if (AnonNamespace) {
1572 auto *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
1573 if (!Record.isModule())
1579 RedeclarableResult Redecl = VisitRedeclarable(D);
1581 D->NamespaceLoc = ReadSourceLocation();
1582 D->IdentLoc = ReadSourceLocation();
1583 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1584 D->Namespace = ReadDeclAs<NamedDecl>();
1585 mergeRedeclarable(D, Redecl);
1591 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1592 ReadDeclarationNameLoc(D->DNLoc, D->
getDeclName());
1593 D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>());
1595 if (
auto *Pattern = ReadDeclAs<NamedDecl>())
1596 Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
1602 D->InstantiatedFrom = ReadDeclAs<NamedDecl>();
1603 auto **Expansions = D->getTrailingObjects<
NamedDecl *>();
1604 for (
unsigned I = 0; I != D->NumExpansions; ++I)
1605 Expansions[I] = ReadDeclAs<NamedDecl>();
1610 RedeclarableResult Redecl = VisitRedeclarable(D);
1612 D->Underlying = ReadDeclAs<NamedDecl>();
1614 D->UsingOrNextShadow = ReadDeclAs<NamedDecl>();
1615 auto *Pattern = ReadDeclAs<UsingShadowDecl>();
1617 Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern);
1618 mergeRedeclarable(D, Redecl);
1623 VisitUsingShadowDecl(D);
1624 D->NominatedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
1625 D->ConstructedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
1626 D->IsVirtual = Record.readInt();
1631 D->UsingLoc = ReadSourceLocation();
1632 D->NamespaceLoc = ReadSourceLocation();
1633 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1634 D->NominatedNamespace = ReadDeclAs<NamedDecl>();
1635 D->CommonAncestor = ReadDeclAs<DeclContext>();
1641 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1642 ReadDeclarationNameLoc(D->DNLoc, D->
getDeclName());
1643 D->EllipsisLoc = ReadSourceLocation();
1650 D->TypenameLocation = ReadSourceLocation();
1651 D->QualifierLoc = Record.readNestedNameSpecifierLoc();
1652 D->EllipsisLoc = ReadSourceLocation();
1656 void ASTDeclReader::ReadCXXDefinitionData(
1657 struct CXXRecordDecl::DefinitionData &Data,
const CXXRecordDecl *D) {
1659 Data.UserDeclaredConstructor = Record.readInt();
1660 Data.UserDeclaredSpecialMembers = Record.readInt();
1661 Data.Aggregate = Record.readInt();
1662 Data.PlainOldData = Record.readInt();
1663 Data.Empty = Record.readInt();
1664 Data.Polymorphic = Record.readInt();
1665 Data.Abstract = Record.readInt();
1666 Data.IsStandardLayout = Record.readInt();
1667 Data.IsCXX11StandardLayout = Record.readInt();
1668 Data.HasBasesWithFields = Record.readInt();
1669 Data.HasBasesWithNonStaticDataMembers = Record.readInt();
1670 Data.HasPrivateFields = Record.readInt();
1671 Data.HasProtectedFields = Record.readInt();
1672 Data.HasPublicFields = Record.readInt();
1673 Data.HasMutableFields = Record.readInt();
1674 Data.HasVariantMembers = Record.readInt();
1675 Data.HasOnlyCMembers = Record.readInt();
1676 Data.HasInClassInitializer = Record.readInt();
1677 Data.HasUninitializedReferenceMember = Record.readInt();
1678 Data.HasUninitializedFields = Record.readInt();
1679 Data.HasInheritedConstructor = Record.readInt();
1680 Data.HasInheritedAssignment = Record.readInt();
1681 Data.NeedOverloadResolutionForCopyConstructor = Record.readInt();
1682 Data.NeedOverloadResolutionForMoveConstructor = Record.readInt();
1683 Data.NeedOverloadResolutionForMoveAssignment = Record.readInt();
1684 Data.NeedOverloadResolutionForDestructor = Record.readInt();
1685 Data.DefaultedCopyConstructorIsDeleted = Record.readInt();
1686 Data.DefaultedMoveConstructorIsDeleted = Record.readInt();
1687 Data.DefaultedMoveAssignmentIsDeleted = Record.readInt();
1688 Data.DefaultedDestructorIsDeleted = Record.readInt();
1689 Data.HasTrivialSpecialMembers = Record.readInt();
1690 Data.HasTrivialSpecialMembersForCall = Record.readInt();
1691 Data.DeclaredNonTrivialSpecialMembers = Record.readInt();
1692 Data.DeclaredNonTrivialSpecialMembersForCall = Record.readInt();
1693 Data.HasIrrelevantDestructor = Record.readInt();
1694 Data.HasConstexprNonCopyMoveConstructor = Record.readInt();
1695 Data.HasDefaultedDefaultConstructor = Record.readInt();
1696 Data.DefaultedDefaultConstructorIsConstexpr = Record.readInt();
1697 Data.HasConstexprDefaultConstructor = Record.readInt();
1698 Data.HasNonLiteralTypeFieldsOrBases = Record.readInt();
1699 Data.ComputedVisibleConversions = Record.readInt();
1700 Data.UserProvidedDefaultConstructor = Record.readInt();
1701 Data.DeclaredSpecialMembers = Record.readInt();
1702 Data.ImplicitCopyConstructorCanHaveConstParamForVBase = Record.readInt();
1703 Data.ImplicitCopyConstructorCanHaveConstParamForNonVBase = Record.readInt();
1704 Data.ImplicitCopyAssignmentHasConstParam = Record.readInt();
1705 Data.HasDeclaredCopyConstructorWithConstParam = Record.readInt();
1706 Data.HasDeclaredCopyAssignmentWithConstParam = Record.readInt();
1707 Data.ODRHash = Record.readInt();
1708 Data.HasODRHash =
true;
1710 if (Record.readInt())
1713 Data.NumBases = Record.readInt();
1715 Data.Bases = ReadGlobalOffset();
1716 Data.NumVBases = Record.readInt();
1718 Data.VBases = ReadGlobalOffset();
1720 Record.readUnresolvedSet(Data.Conversions);
1721 Record.readUnresolvedSet(Data.VisibleConversions);
1722 assert(Data.Definition &&
"Data.Definition should be already set!");
1723 Data.FirstFriend = ReadDeclID();
1725 if (Data.IsLambda) {
1728 auto &Lambda =
static_cast<CXXRecordDecl::LambdaDefinitionData &
>(Data);
1729 Lambda.Dependent = Record.readInt();
1730 Lambda.IsGenericLambda = Record.readInt();
1731 Lambda.CaptureDefault = Record.readInt();
1732 Lambda.NumCaptures = Record.readInt();
1733 Lambda.NumExplicitCaptures = Record.readInt();
1734 Lambda.ManglingNumber = Record.readInt();
1735 Lambda.ContextDecl = ReadDeclID();
1736 Lambda.Captures = (
Capture *)Reader.getContext().Allocate(
1737 sizeof(
Capture) * Lambda.NumCaptures);
1738 Capture *ToCapture = Lambda.Captures;
1739 Lambda.MethodTyInfo = GetTypeSourceInfo();
1740 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
1742 bool IsImplicit = Record.readInt();
1752 auto *Var = ReadDeclAs<VarDecl>();
1754 *ToCapture++ =
Capture(Loc, IsImplicit,
Kind, Var, EllipsisLoc);
1761 void ASTDeclReader::MergeDefinitionData(
1762 CXXRecordDecl *D,
struct CXXRecordDecl::DefinitionData &&MergeDD) {
1763 assert(D->DefinitionData &&
1764 "merging class definition into non-definition");
1765 auto &DD = *D->DefinitionData;
1767 if (DD.Definition != MergeDD.Definition) {
1769 Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition,
1771 Reader.PendingDefinitions.erase(MergeDD.Definition);
1772 MergeDD.Definition->setCompleteDefinition(
false);
1773 Reader.mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
1774 assert(Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() &&
1775 "already loaded pending lookups for merged definition");
1778 auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
1779 if (PFDI != Reader.PendingFakeDefinitionData.end() &&
1780 PFDI->second == ASTReader::PendingFakeDefinitionKind::Fake) {
1783 assert(!DD.IsLambda && !MergeDD.IsLambda &&
"faked up lambda definition?");
1784 PFDI->second = ASTReader::PendingFakeDefinitionKind::FakeLoaded;
1788 auto *Def = DD.Definition;
1789 DD = std::move(MergeDD);
1790 DD.Definition = Def;
1795 bool DetectedOdrViolation =
false;
1796 #define OR_FIELD(Field) DD.Field |= MergeDD.Field; 1797 #define MATCH_FIELD(Field) \ 1798 DetectedOdrViolation |= DD.Field != MergeDD.Field; \ 1822 MATCH_FIELD(NeedOverloadResolutionForCopyConstructor)
1823 MATCH_FIELD(NeedOverloadResolutionForMoveConstructor)
1824 MATCH_FIELD(NeedOverloadResolutionForMoveAssignment)
1831 OR_FIELD(HasTrivialSpecialMembersForCall)
1832 OR_FIELD(DeclaredNonTrivialSpecialMembers)
1833 OR_FIELD(DeclaredNonTrivialSpecialMembersForCall)
1835 OR_FIELD(HasConstexprNonCopyMoveConstructor)
1836 OR_FIELD(HasDefaultedDefaultConstructor)
1837 MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr)
1838 OR_FIELD(HasConstexprDefaultConstructor)
1843 MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForVBase)
1844 MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForNonVBase)
1846 OR_FIELD(HasDeclaredCopyConstructorWithConstParam)
1847 OR_FIELD(HasDeclaredCopyAssignmentWithConstParam)
1852 if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases)
1853 DetectedOdrViolation =
true;
1859 if (MergeDD.ComputedVisibleConversions && !DD.ComputedVisibleConversions) {
1860 DD.VisibleConversions = std::move(MergeDD.VisibleConversions);
1861 DD.ComputedVisibleConversions =
true;
1873 DetectedOdrViolation =
true;
1876 if (DetectedOdrViolation)
1877 Reader.PendingOdrMergeFailures[DD.Definition].push_back(
1878 {MergeDD.Definition, &MergeDD});
1882 struct CXXRecordDecl::DefinitionData *DD;
1887 bool IsLambda = Record.readInt();
1889 DD =
new (
C) CXXRecordDecl::LambdaDefinitionData(D,
nullptr,
false,
false,
1892 DD =
new (
C)
struct CXXRecordDecl::DefinitionData(D);
1898 if (!Canon->DefinitionData)
1899 Canon->DefinitionData = DD;
1900 D->DefinitionData = Canon->DefinitionData;
1901 ReadCXXDefinitionData(*DD, D);
1906 if (Canon->DefinitionData != DD) {
1907 MergeDefinitionData(Canon, std::move(*DD));
1917 if (Update || Canon != D)
1918 Reader.PendingDefinitions.insert(D);
1921 ASTDeclReader::RedeclarableResult
1923 RedeclarableResult Redecl = VisitRecordDeclImpl(D);
1928 CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1930 switch ((CXXRecKind)Record.readInt()) {
1931 case CXXRecNotTemplate:
1933 if (!isa<ClassTemplateSpecializationDecl>(D))
1934 mergeRedeclarable(D, Redecl);
1936 case CXXRecTemplate: {
1938 auto *Template = ReadDeclAs<ClassTemplateDecl>();
1939 D->TemplateOrInstantiation = Template;
1940 if (!Template->getTemplatedDecl()) {
1951 case CXXRecMemberSpecialization: {
1952 auto *RD = ReadDeclAs<CXXRecordDecl>();
1957 D->TemplateOrInstantiation = MSI;
1958 mergeRedeclarable(D, Redecl);
1963 bool WasDefinition = Record.readInt();
1965 ReadCXXRecordDefinition(D,
false);
1972 if (WasDefinition) {
1973 DeclID KeyFn = ReadDeclID();
1978 C.KeyFunctions[D] = KeyFn;
1985 D->setExplicitSpecifier(Record.readExplicitSpec());
1986 VisitFunctionDecl(D);
1991 VisitFunctionDecl(D);
1993 unsigned NumOverridenMethods = Record.readInt();
1995 while (NumOverridenMethods--) {
1998 if (
auto *MD = ReadDeclAs<CXXMethodDecl>())
2004 Record.skipInts(NumOverridenMethods);
2011 D->setExplicitSpecifier(Record.readExplicitSpec());
2013 auto *Shadow = ReadDeclAs<ConstructorUsingShadowDecl>();
2014 auto *Ctor = ReadDeclAs<CXXConstructorDecl>();
2019 VisitCXXMethodDecl(D);
2023 VisitCXXMethodDecl(D);
2025 if (
auto *OperatorDelete = ReadDeclAs<FunctionDecl>()) {
2027 auto *ThisArg = Record.readExpr();
2029 if (!Canon->OperatorDelete) {
2030 Canon->OperatorDelete = OperatorDelete;
2031 Canon->OperatorDeleteThisArg = ThisArg;
2037 D->setExplicitSpecifier(Record.readExplicitSpec());
2038 VisitCXXMethodDecl(D);
2043 D->ImportedAndComplete.setPointer(readModule());
2044 D->ImportedAndComplete.setInt(Record.readInt());
2046 for (
unsigned I = 0, N = Record.back(); I != N; ++I)
2047 StoredLocs[I] = ReadSourceLocation();
2058 if (Record.readInt())
2059 D->Friend = ReadDeclAs<NamedDecl>();
2061 D->Friend = GetTypeSourceInfo();
2062 for (
unsigned i = 0;
i != D->NumTPLists; ++
i)
2064 Record.readTemplateParameterList();
2065 D->NextFriend = ReadDeclID();
2066 D->UnsupportedFriend = (Record.readInt() != 0);
2067 D->FriendLoc = ReadSourceLocation();
2072 unsigned NumParams = Record.readInt();
2073 D->NumParams = NumParams;
2075 for (
unsigned i = 0;
i != NumParams; ++
i)
2076 D->Params[
i] = Record.readTemplateParameterList();
2077 if (Record.readInt())
2078 D->Friend = ReadDeclAs<NamedDecl>();
2080 D->Friend = GetTypeSourceInfo();
2081 D->FriendLoc = ReadSourceLocation();
2087 DeclID PatternID = ReadDeclID();
2088 auto *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
2091 D->
init(TemplatedDecl, TemplateParams);
2097 VisitTemplateDecl(D);
2102 ASTDeclReader::RedeclarableResult
2104 RedeclarableResult Redecl = VisitRedeclarable(D);
2111 Reader.PendingDefinitions.insert(CanonD);
2117 if (ThisDeclID == Redecl.getFirstID()) {
2118 if (
auto *RTD = ReadDeclAs<RedeclarableTemplateDecl>()) {
2119 assert(RTD->getKind() == D->
getKind() &&
2120 "InstantiatedFromMemberTemplate kind mismatch");
2122 if (Record.readInt())
2127 DeclID PatternID = VisitTemplateDecl(D);
2130 mergeRedeclarable(D, Redecl, PatternID);
2141 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2143 if (ThisDeclID == Redecl.getFirstID()) {
2147 ReadDeclIDList(SpecIDs);
2155 Reader.getContext().getInjectedClassNameType(
2161 llvm_unreachable(
"BuiltinTemplates are not serialized");
2168 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2170 if (ThisDeclID == Redecl.getFirstID()) {
2174 ReadDeclIDList(SpecIDs);
2179 ASTDeclReader::RedeclarableResult
2182 RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D);
2185 if (
Decl *InstD = ReadDecl()) {
2186 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
2187 D->SpecializedTemplate = CTD;
2190 Record.readTemplateArgumentList(TemplArgs);
2195 SpecializedPartialSpecialization();
2196 PS->PartialSpecialization
2197 = cast<ClassTemplatePartialSpecializationDecl>(InstD);
2198 PS->TemplateArgs = ArgList;
2199 D->SpecializedTemplate = PS;
2204 Record.readTemplateArgumentList(TemplArgs,
true);
2206 D->PointOfInstantiation = ReadSourceLocation();
2209 bool writtenAsCanonicalDecl = Record.readInt();
2210 if (writtenAsCanonicalDecl) {
2211 auto *CanonPattern = ReadDeclAs<ClassTemplateDecl>();
2215 if (
auto *Partial = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
2216 CanonSpec = CanonPattern->getCommonPtr()->PartialSpecializations
2217 .GetOrInsertNode(Partial);
2220 CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2223 if (CanonSpec != D) {
2224 mergeRedeclarable<TagDecl>(D, CanonSpec, Redecl);
2228 if (
auto *DDD = D->DefinitionData) {
2229 if (CanonSpec->DefinitionData)
2230 MergeDefinitionData(CanonSpec, std::move(*DDD));
2232 CanonSpec->DefinitionData = D->DefinitionData;
2234 D->DefinitionData = CanonSpec->DefinitionData;
2241 auto *ExplicitInfo =
2242 new (
C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
2243 ExplicitInfo->TypeAsWritten = TyInfo;
2244 ExplicitInfo->ExternLoc = ReadSourceLocation();
2245 ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation();
2246 D->ExplicitInfo = ExplicitInfo;
2254 RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
2256 D->TemplateParams = Record.readTemplateParameterList();
2257 D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2260 if (ThisDeclID == Redecl.getFirstID()) {
2261 D->InstantiatedFromMember.setPointer(
2262 ReadDeclAs<ClassTemplatePartialSpecializationDecl>());
2263 D->InstantiatedFromMember.setInt(Record.readInt());
2270 D->Specialization = ReadDeclAs<CXXMethodDecl>();
2271 if (Record.readInt())
2272 D->TemplateArgs = Record.readASTTemplateArgumentListInfo();
2276 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2278 if (ThisDeclID == Redecl.getFirstID()) {
2281 ReadDeclIDList(SpecIDs);
2291 ASTDeclReader::RedeclarableResult
2294 RedeclarableResult Redecl = VisitVarDeclImpl(D);
2297 if (
Decl *InstD = ReadDecl()) {
2298 if (
auto *VTD = dyn_cast<VarTemplateDecl>(InstD)) {
2299 D->SpecializedTemplate = VTD;
2302 Record.readTemplateArgumentList(TemplArgs);
2307 VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
2308 PS->PartialSpecialization =
2309 cast<VarTemplatePartialSpecializationDecl>(InstD);
2310 PS->TemplateArgs = ArgList;
2311 D->SpecializedTemplate = PS;
2317 auto *ExplicitInfo =
2318 new (
C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo;
2319 ExplicitInfo->TypeAsWritten = TyInfo;
2320 ExplicitInfo->ExternLoc = ReadSourceLocation();
2321 ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation();
2322 D->ExplicitInfo = ExplicitInfo;
2326 Record.readTemplateArgumentList(TemplArgs,
true);
2328 D->PointOfInstantiation = ReadSourceLocation();
2330 D->IsCompleteDefinition = Record.readInt();
2332 bool writtenAsCanonicalDecl = Record.readInt();
2333 if (writtenAsCanonicalDecl) {
2334 auto *CanonPattern = ReadDeclAs<VarTemplateDecl>();
2337 if (
auto *Partial = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
2338 CanonPattern->getCommonPtr()->PartialSpecializations
2339 .GetOrInsertNode(Partial);
2341 CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D);
2356 RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
2358 D->TemplateParams = Record.readTemplateParameterList();
2359 D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
2362 if (ThisDeclID == Redecl.getFirstID()) {
2363 D->InstantiatedFromMember.setPointer(
2364 ReadDeclAs<VarTemplatePartialSpecializationDecl>());
2365 D->InstantiatedFromMember.setInt(Record.readInt());
2374 if (Record.readInt())
2379 VisitDeclaratorDecl(D);
2384 auto TypesAndInfos =
2385 D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
2387 new (&TypesAndInfos[I].first)
QualType(Record.readType());
2388 TypesAndInfos[I].second = GetTypeSourceInfo();
2392 D->ParameterPack = Record.readInt();
2393 if (Record.readInt())
2399 VisitTemplateDecl(D);
2407 Data[I] = Record.readTemplateParameterList();
2410 D->ParameterPack = Record.readInt();
2411 if (Record.readInt())
2413 Record.readTemplateArgumentLoc());
2418 VisitRedeclarableTemplateDecl(D);
2423 D->AssertExprAndFailed.setPointer(Record.readExpr());
2424 D->AssertExprAndFailed.setInt(Record.readInt());
2425 D->Message = cast_or_null<StringLiteral>(Record.readExpr());
2426 D->RParenLoc = ReadSourceLocation();
2433 std::pair<uint64_t, uint64_t>
2435 uint64_t LexicalOffset = ReadLocalOffset();
2436 uint64_t VisibleOffset = ReadLocalOffset();
2437 return std::make_pair(LexicalOffset, VisibleOffset);
2440 template <
typename T>
2441 ASTDeclReader::RedeclarableResult
2443 DeclID FirstDeclID = ReadDeclID();
2444 Decl *MergeWith =
nullptr;
2446 bool IsKeyDecl = ThisDeclID == FirstDeclID;
2447 bool IsFirstLocalDecl =
false;
2449 uint64_t RedeclOffset = 0;
2453 if (FirstDeclID == 0) {
2454 FirstDeclID = ThisDeclID;
2456 IsFirstLocalDecl =
true;
2457 }
else if (
unsigned N = Record.readInt()) {
2461 IsFirstLocalDecl =
true;
2468 for (
unsigned I = 0; I != N - 1; ++I)
2469 MergeWith = ReadDecl();
2471 RedeclOffset = ReadLocalOffset();
2478 auto *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID));
2479 if (FirstDecl != D) {
2485 D->
First = FirstDecl->getCanonicalDecl();
2488 auto *DAsT =
static_cast<T *
>(D);
2494 if (IsFirstLocalDecl)
2495 Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset));
2497 return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl);
2502 template<
typename T>
2504 RedeclarableResult &Redecl,
2505 DeclID TemplatePatternID) {
2507 if (!Reader.getContext().getLangOpts().Modules)
2514 auto *D =
static_cast<T *
>(DBase);
2516 if (
auto *Existing = Redecl.getKnownMergeTarget())
2518 mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID);
2519 else if (FindExistingResult ExistingRes = findExisting(D))
2520 if (T *Existing = ExistingRes)
2521 mergeRedeclarable(D, Existing, Redecl, TemplatePatternID);
2529 llvm_unreachable(
"bad assert_cast");
2536 DeclID DsID,
bool IsKeyDecl) {
2539 RedeclarableResult Result( ExistingPattern,
2540 DPattern->getCanonicalDecl()->getGlobalID(),
2543 if (
auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) {
2546 auto *ExistingClass =
2548 if (
auto *DDD = DClass->DefinitionData) {
2549 if (ExistingClass->DefinitionData) {
2550 MergeDefinitionData(ExistingClass, std::move(*DDD));
2552 ExistingClass->DefinitionData = DClass->DefinitionData;
2555 Reader.PendingDefinitions.insert(DClass);
2558 DClass->DefinitionData = ExistingClass->DefinitionData;
2560 return mergeRedeclarable(DClass, cast<TagDecl>(ExistingPattern),
2563 if (
auto *DFunction = dyn_cast<FunctionDecl>(DPattern))
2564 return mergeRedeclarable(DFunction, cast<FunctionDecl>(ExistingPattern),
2566 if (
auto *DVar = dyn_cast<VarDecl>(DPattern))
2567 return mergeRedeclarable(DVar, cast<VarDecl>(ExistingPattern), Result);
2568 if (
auto *DAlias = dyn_cast<TypeAliasDecl>(DPattern))
2569 return mergeRedeclarable(DAlias, cast<TypedefNameDecl>(ExistingPattern),
2571 llvm_unreachable(
"merged an unknown kind of redeclarable template");
2576 template<
typename T>
2578 RedeclarableResult &Redecl,
2579 DeclID TemplatePatternID) {
2580 auto *D =
static_cast<T *
>(DBase);
2583 if (ExistingCanon != DCanon) {
2584 assert(DCanon->getGlobalID() == Redecl.getFirstID() &&
2585 "already merged this declaration");
2591 D->
First = ExistingCanon;
2592 ExistingCanon->Used |= D->Used;
2598 if (
auto *Namespace = dyn_cast<NamespaceDecl>(D))
2599 Namespace->AnonOrFirstNamespaceAndInline.setPointer(
2600 assert_cast<NamespaceDecl*>(ExistingCanon));
2603 if (
auto *DTemplate = dyn_cast<RedeclarableTemplateDecl>(D))
2604 mergeTemplatePattern(
2605 DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon),
2606 TemplatePatternID, Redecl.isKeyDecl());
2609 if (Redecl.isKeyDecl())
2610 Reader.KeyDecls[ExistingCanon].push_back(Redecl.getFirstID());
2623 if (isa<EnumConstantDecl>(ND))
2632 template<
typename T>
2635 if (!Reader.getContext().getLangOpts().Modules)
2642 if (!Reader.getContext().getLangOpts().CPlusPlus &&
2646 if (FindExistingResult ExistingRes = findExisting(static_cast<T*>(D)))
2647 if (T *Existing = ExistingRes)
2648 Reader.getContext().setPrimaryMergedDecl(static_cast<T *>(D),
2649 Existing->getCanonicalDecl());
2656 Vars.reserve(NumVars);
2657 for (
unsigned i = 0;
i != NumVars; ++
i) {
2658 Vars.push_back(Record.readExpr());
2668 Vars.reserve(NumVars);
2669 for (
unsigned i = 0;
i != NumVars; ++
i) {
2670 Vars.push_back(Record.readExpr());
2674 Clauses.reserve(NumClauses);
2676 for (
unsigned I = 0; I != NumClauses; ++I)
2677 Clauses.push_back(ClauseReader.
readClause());
2678 D->setClauses(Clauses);
2685 Clauses.reserve(NumClauses);
2687 for (
unsigned I = 0; I != NumClauses; ++I)
2688 Clauses.push_back(ClauseReader.
readClause());
2689 D->setClauses(Clauses);
2695 Expr *In = Record.readExpr();
2696 Expr *Out = Record.readExpr();
2698 Expr *Combiner = Record.readExpr();
2700 Expr *Orig = Record.readExpr();
2701 Expr *Priv = Record.readExpr();
2703 Expr *Init = Record.readExpr();
2706 D->PrevDeclInScope = ReadDeclID();
2712 Expr *MapperVarRefE = Record.readExpr();
2714 D->VarName = Record.readDeclarationName();
2715 D->PrevDeclInScope = ReadDeclID();
2718 Clauses.reserve(NumClauses);
2720 for (
unsigned I = 0; I != NumClauses; ++I)
2721 Clauses.push_back(ClauseReader.
readClause());
2722 D->setClauses(Clauses);
2743 : F(&F), Reader(&Reader), Record(Record), Idx(Idx) {}
2745 const uint64_t &readInt() {
return Record[Idx++]; }
2753 std::string readString() {
2765 VersionTuple readVersionTuple() {
2769 template <
typename T> T *GetLocalDeclAs(uint32_t LocalID) {
2770 return cast_or_null<T>(Reader->
GetLocalDecl(*F, LocalID));
2777 AttrReader Record(M, *
this, Rec, Idx);
2778 auto V = Record.readInt();
2782 Attr *New =
nullptr;
2789 #include "clang/Serialization/AttrPCHRead.inc" 2791 assert(New &&
"Unable to decode attribute?");
2797 for (
unsigned I = 0, E = Record.
readInt(); I != E; ++I)
2798 Attrs.push_back(Record.
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");
3915 Error(
"attempt to read a C++ base-specifier record as a declaration");
3918 Error(
"attempt to read a C++ ctor initializer record as a declaration");
3929 unsigned NumVars = Record.
readInt();
3930 unsigned NumClauses = Record.
readInt();
3961 assert(D &&
"Unknown declaration reading AST file");
3962 LoadedDecl(Index, D);
3971 if (
auto *DC = dyn_cast<DeclContext>(D)) {
3973 if (Offsets.first &&
3974 ReadLexicalDeclContextStorage(*Loc.F, DeclsCursor, Offsets.first, DC))
3976 if (Offsets.second &&
3977 ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID))
3983 PendingUpdateRecords.push_back(
3984 PendingUpdateRecord(ID, D,
true));
3987 if (
auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
3990 if (Class->isThisDeclarationADefinition() ||
3991 PendingDefinitions.count(Class))
3992 loadObjCCategories(ID, Class);
3998 PotentiallyInterestingDecls.push_back(
4004 void ASTReader::PassInterestingDeclsToConsumer() {
4007 if (PassingDeclsToConsumer)
4017 for (
auto ID : EagerlyDeserializedDecls)
4019 EagerlyDeserializedDecls.clear();
4021 while (!PotentiallyInterestingDecls.empty()) {
4022 InterestingDecl D = PotentiallyInterestingDecls.front();
4023 PotentiallyInterestingDecls.pop_front();
4025 PassInterestingDeclToConsumer(D.getDecl());
4029 void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
4035 ProcessingUpdatesRAIIObj ProcessingUpdates(*
this);
4036 DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
4040 if (UpdI != DeclUpdateOffsets.end()) {
4041 auto UpdateOffsets = std::move(UpdI->second);
4042 DeclUpdateOffsets.erase(UpdI);
4048 bool WasInteresting =
4050 for (
auto &FileAndOffset : UpdateOffsets) {
4052 uint64_t
Offset = FileAndOffset.second;
4055 if (
llvm::Error JumpFailed = Cursor.JumpToBit(Offset))
4057 llvm::report_fatal_error(
4058 "ASTReader::loadDeclUpdateRecords failed jumping: " +
4062 llvm::report_fatal_error(
4063 "ASTReader::loadDeclUpdateRecords failed reading code: " +
4065 unsigned Code = MaybeCode.get();
4069 "Expected DECL_UPDATES record!");
4071 llvm::report_fatal_error(
4072 "ASTReader::loadDeclUpdateRecords failed reading rec code: " +
4075 ASTDeclReader Reader(*
this, Record, RecordLocation(F, Offset), ID,
4077 Reader.
UpdateDecl(D, PendingLazySpecializationIDs);
4081 if (!WasInteresting &&
4083 PotentiallyInterestingDecls.push_back(
4085 WasInteresting =
true;
4090 assert((PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) ||
4091 isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) &&
4092 "Must not have pending specializations");
4093 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(D))
4095 else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
4097 else if (
auto *VTD = dyn_cast<VarTemplateDecl>(D))
4099 PendingLazySpecializationIDs.clear();
4102 auto I = PendingVisibleUpdates.find(ID);
4103 if (I != PendingVisibleUpdates.end()) {
4104 auto VisibleUpdates = std::move(I->second);
4105 PendingVisibleUpdates.erase(I);
4107 auto *DC = cast<DeclContext>(D)->getPrimaryContext();
4108 for (
const auto &
Update : VisibleUpdates)
4109 Lookups[DC].Table.add(
4116 void ASTReader::loadPendingDeclChain(
Decl *FirstLocal, uint64_t LocalOffset) {
4119 if (FirstLocal != CanonDecl) {
4122 *
this, FirstLocal, PrevMostRecent ? PrevMostRecent : CanonDecl,
4132 ModuleFile *M = getOwningModuleFile(FirstLocal);
4133 assert(M &&
"imported decl from no module file");
4137 if (
llvm::Error JumpFailed = Cursor.JumpToBit(LocalOffset))
4138 llvm::report_fatal_error(
4139 "ASTReader::loadPendingDeclChain failed jumping: " +
4145 llvm::report_fatal_error(
4146 "ASTReader::loadPendingDeclChain failed reading code: " +
4148 unsigned Code = MaybeCode.get();
4151 "expected LOCAL_REDECLARATIONS record!");
4153 llvm::report_fatal_error(
4154 "ASTReader::loadPendingDeclChain failed reading rec code: " +
4159 Decl *MostRecent = FirstLocal;
4160 for (
unsigned I = 0, N = Record.size(); I != N; ++I) {
4161 auto *D = GetLocalDecl(*M, Record[N - I - 1]);
4172 class ObjCCategoriesVisitor {
4175 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized;
4177 llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap;
4179 unsigned PreviousGeneration;
4183 if (!Deserialized.erase(Cat))
4206 }
else if (!Existing) {
4221 ObjCCategoriesVisitor(
ASTReader &Reader,
4223 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
4225 unsigned PreviousGeneration)
4226 : Reader(Reader), Interface(Interface), Deserialized(Deserialized),
4227 InterfaceID(InterfaceID), PreviousGeneration(PreviousGeneration) {
4270 for (
unsigned I = 0; I != N; ++I)
4271 add(cast_or_null<ObjCCategoryDecl>(
4281 unsigned PreviousGeneration) {
4282 ObjCCategoriesVisitor Visitor(*
this, D, CategoriesDeserialized,
ID,
4283 PreviousGeneration);
4284 ModuleMgr.visit(Visitor);
4287 template<
typename DeclT,
typename Fn>
4294 auto *MostRecent = D->getMostRecentDecl();
4296 for (
auto *Redecl = MostRecent; Redecl && !Found;
4297 Redecl = Redecl->getPreviousDecl())
4298 Found = (Redecl == D);
4302 for (
auto *Redecl = MostRecent; Redecl != D;
4303 Redecl = Redecl->getPreviousDecl())
4310 while (Record.getIdx() < Record.size()) {
4313 auto *RD = cast<CXXRecordDecl>(D);
4316 Decl *MD = Record.readDecl();
4317 assert(MD &&
"couldn't read decl from update record");
4320 RD->addedMember(MD);
4326 PendingLazySpecializationIDs.push_back(ReadDeclID());
4330 auto *Anon = ReadDeclAs<NamespaceDecl>();
4335 if (!Record.isModule()) {
4336 if (
auto *TU = dyn_cast<TranslationUnitDecl>(D))
4337 TU->setAnonymousNamespace(Anon);
4339 cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
4345 auto *VD = cast<VarDecl>(D);
4346 VD->NonParmVarDeclBits.IsInline = Record.readInt();
4347 VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
4348 uint64_t Val = Record.readInt();
4349 if (Val && !VD->getInit()) {
4350 VD->setInit(Record.readExpr());
4354 Eval->
IsICE = Val == 3;
4362 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D)) {
4363 VTSD->setPointOfInstantiation(POI);
4364 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
4365 VD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
4367 auto *FD = cast<FunctionDecl>(D);
4368 if (
auto *FTSInfo = FD->TemplateOrSpecialization
4370 FTSInfo->setPointOfInstantiation(POI);
4373 ->setPointOfInstantiation(POI);
4379 auto *Param = cast<ParmVarDecl>(D);
4384 auto *DefaultArg = Record.readExpr();
4388 if (Param->hasUninstantiatedDefaultArg())
4389 Param->setDefaultArg(DefaultArg);
4394 auto *FD = cast<FieldDecl>(D);
4395 auto *DefaultInit = Record.readExpr();
4399 if (FD->hasInClassInitializer() && !FD->getInClassInitializer()) {
4401 FD->setInClassInitializer(DefaultInit);
4405 FD->removeInClassInitializer();
4411 auto *FD = cast<FunctionDecl>(D);
4412 if (Reader.PendingBodies[FD]) {
4418 if (Record.readInt()) {
4426 FD->setInnerLocStart(ReadSourceLocation());
4427 ReadFunctionDefinition(FD);
4428 assert(Record.getIdx() == Record.size() &&
"lazy body must be last");
4433 auto *RD = cast<CXXRecordDecl>(D);
4434 auto *OldDD = RD->getCanonicalDecl()->DefinitionData;
4435 bool HadRealDefinition =
4436 OldDD && (OldDD->Definition != RD ||
4437 !Reader.PendingFakeDefinitionData.count(OldDD));
4438 RD->setParamDestroyedInCallee(Record.readInt());
4439 RD->setArgPassingRestrictions(
4441 ReadCXXRecordDefinition(RD,
true);
4444 uint64_t LexicalOffset = ReadLocalOffset();
4445 if (!HadRealDefinition && LexicalOffset) {
4446 Record.readLexicalDeclContextStorage(LexicalOffset, RD);
4447 Reader.PendingFakeDefinitionData.erase(OldDD);
4453 RD->getMemberSpecializationInfo()) {
4454 MSInfo->setTemplateSpecializationKind(TSK);
4455 MSInfo->setPointOfInstantiation(POI);
4457 auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
4458 Spec->setTemplateSpecializationKind(TSK);
4459 Spec->setPointOfInstantiation(POI);
4461 if (Record.readInt()) {
4463 ReadDeclAs<ClassTemplatePartialSpecializationDecl>();
4465 Record.readTemplateArgumentList(TemplArgs);
4471 if (!Spec->getSpecializedTemplateOrPartial()
4473 Spec->setInstantiationOf(PartialSpec, TemplArgList);
4478 RD->setLocation(ReadSourceLocation());
4479 RD->setLocStart(ReadSourceLocation());
4480 RD->setBraceRange(ReadSourceRange());
4482 if (Record.readInt()) {
4484 Record.readAttributes(Attrs);
4496 auto *Del = ReadDeclAs<FunctionDecl>();
4498 auto *ThisArg = Record.readExpr();
4500 if (!First->OperatorDelete) {
4501 First->OperatorDelete = Del;
4502 First->OperatorDeleteThisArg = ThisArg;
4510 Record.readExceptionSpec(ExceptionStorage, ESI);
4513 auto *FD = cast<FunctionDecl>(D);
4519 FPT->getReturnType(), FPT->getParamTypes(),
4520 FPT->getExtProtoInfo().withExceptionSpec(ESI)));
4524 Reader.PendingExceptionSpecUpdates.insert(
4525 std::make_pair(FD->getCanonicalDecl(), FD));
4531 auto *FD = cast<FunctionDecl>(D);
4532 QualType DeducedResultType = Record.readType();
4533 Reader.PendingDeducedTypeUpdates.insert(
4534 {FD->getCanonicalDecl(), DeducedResultType});
4555 ReadSourceRange()));
4559 auto AllocatorKind =
4560 static_cast<OMPAllocateDeclAttr::AllocatorTypeTy
>(Record.readInt());
4561 Expr *Allocator = Record.readExpr();
4563 D->
addAttr(OMPAllocateDeclAttr::CreateImplicit(
4564 Reader.
getContext(), AllocatorKind, Allocator, SR));
4570 auto *Exported = cast<NamedDecl>(D);
4573 Reader.PendingMergedDefinitionsToDeduplicate.insert(Exported);
4578 D->
addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(
4580 static_cast<OMPDeclareTargetDeclAttr::MapTypeTy
>(Record.readInt()),
4581 ReadSourceRange()));
4586 Record.readAttributes(Attrs);
4587 assert(Attrs.size() == 1);
const uint64_t & readInt()
Returns the current value in this record, and advances to the next value.
RedeclarableResult VisitTypedefNameDecl(TypedefNameDecl *TD)
void VisitTypeDecl(TypeDecl *TD)
void setCategoryNameLoc(SourceLocation Loc)
A FriendTemplateDecl record.
void setHasSkippedBody(bool Skipped=true)
Defines the clang::ASTContext interface.
A NonTypeTemplateParmDecl record.
static bool isUndeducedReturnType(QualType T)
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
SourceLocation readSourceLocation()
Read a source location, advancing Idx.
void VisitClassScopeFunctionSpecializationDecl(ClassScopeFunctionSpecializationDecl *D)
static const Decl * getCanonicalDecl(const Decl *D)
void setImplicit(bool I=true)
Represents a function declaration or definition.
void setInitializerData(Expr *OrigE, Expr *PrivE)
Set initializer Orig and Priv vars.
void setNonTrivialToPrimitiveDestroy(bool V)
void VisitVarDecl(VarDecl *VD)
#define MATCH_FIELD(Field)
void setAnonymousStructOrUnion(bool Anon)
A class which contains all the information about a particular captured value.
static ImportDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
void VisitImportDecl(ImportDecl *D)
A (possibly-)qualified type.
void mergeMergeable(Mergeable< T > *D)
Attempts to merge the given declaration (D) with another declaration of the same entity, for the case where the entity is not actually redeclarable.
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
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...
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.
Defines the clang::Module class, which describes a module in the source code.
Decl - This represents one declaration (or definition), e.g.
static NamedDecl * getDeclForMerging(NamedDecl *Found, bool IsTypedefNameForLinkage)
Find the declaration that should be merged into, given the declaration found by name lookup...
A VarTemplatePartialSpecializationDecl record.
void setArgPassingRestrictions(ArgPassingKind Kind)
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
void setPure(bool P=true)
static Decl * getMostRecentDecl(Decl *D)
known_categories_range known_categories() const
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
A record that stores the set of declarations that are lexically stored within a given DeclContext...
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
Represents an empty-declaration.
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
Class that performs name lookup into a DeclContext stored in an AST file.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
Represent a C++ namespace.
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 readQualifierInfo(QualifierInfo &Info)
void setPropertyAccessor(bool isAccessor)
static void inheritDefaultTemplateArguments(ASTContext &Context, TemplateDecl *From, TemplateDecl *To)
ASTDeclReader(ASTReader &Reader, ASTRecordReader &Record, ASTReader::RecordLocation Loc, DeclID thisDeclID, SourceLocation ThisDeclLoc)
Describes the capture of a variable or of this, or of a C++1y init-capture.
An OMPRequiresDecl record.
Represents a C++ constructor within a class.
This is a module that was defined by a module map and built out of header files.
static CapturedDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumParams)
QualType getElementType() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
A ClassTemplateDecl record.
void VisitStaticAssertDecl(StaticAssertDecl *D)
A PragmaDetectMismatchDecl record.
An UnresolvedUsingTypenameDecl record.
An identifier, stored as an IdentifierInfo*.
void setNothrow(bool Nothrow=true)
void setRAngleLoc(SourceLocation Loc)
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Represents a variable declaration or definition.
void VisitNamedDecl(NamedDecl *ND)
Declaration of a redeclarable template.
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...
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.
static OMPThreadPrivateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
void setManglingNumber(const NamedDecl *ND, unsigned Number)
void setUninstantiatedDefaultArg(Expr *arg)
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
bool CheckedICE
Whether we already checked whether this statement was an integral constant expression.
void VisitFriendTemplateDecl(FriendTemplateDecl *D)
void setLanguage(LanguageIDs L)
Set the language specified by this linkage specification.
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)
static CXXRecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
ArgPassingKind
Enum that represents the different ways arguments are passed to and returned from function calls...
RedeclarableResult VisitVarTemplateSpecializationDeclImpl(VarTemplateSpecializationDecl *D)
TODO: Unify with ClassTemplateSpecializationDecl version? May require unifying ClassTemplate(Partial)...
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Helper class that saves the current stream position and then restores it when destroyed.
static NamespaceDecl * getNamespace(const NestedNameSpecifier *X)
void setOwningModuleID(unsigned ID)
Set the owning module ID.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD)
This declaration is definitely a definition.
unsigned FromASTFile
Whether this declaration was loaded from an AST file.
void Profile(llvm::FoldingSetNodeID &ID)
Defines the clang::attr::Kind enum.
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Represents an access specifier followed by colon ':'.
void setReturnType(QualType T)
Declaration of a function specialization at template class scope.
static StaticAssertDecl * CreateDeserialized(ASTContext &C, unsigned ID)
TypeSourceInfo * getTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
void VisitLabelDecl(LabelDecl *LD)
static NamespaceDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setDeclImplementation(ImplementationControl ic)
Describes a module or submodule.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
A IndirectFieldDecl record.
size_t size() const
The length of this record.
static OMPCapturedExprDecl * CreateDeserialized(ASTContext &C, unsigned ID)
iterator end()
end - Returns an iterator that has 'finished'.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Represents a C++ using-declaration.
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
static llvm::iterator_range< MergedRedeclIterator< DeclT > > merged_redecls(DeclT *D)
ObjCContainerDecl - Represents a container for method declarations.
void setAccessControl(AccessControl ac)
static void attachLatestDecl(Decl *D, Decl *latest)
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
< Capturing the *this object by copy
RedeclarableResult VisitVarDeclImpl(VarDecl *D)
DeclLink RedeclLink
Points to the next redeclaration in the chain.
An AccessSpecDecl record.
void setAtLoc(SourceLocation L)
A convenient class for passing around template argument information.
void setDepth(unsigned D)
void setParamDestroyedInCallee(bool V)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
A ConstructorUsingShadowDecl record.
A UsingDirecitveDecl record.
void ReadFunctionDefinition(FunctionDecl *FD)
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitCXXRecordDecl(CXXRecordDecl *D)
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setSuperClass(ObjCInterfaceDecl *superCls)
A DecompositionDecl record.
Represents a declaration of a type.
void setHasObjectMember(bool val)
void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D)
void VisitMSPropertyDecl(MSPropertyDecl *FD)
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
DeclID VisitTemplateDecl(TemplateDecl *D)
SourceRange readSourceRange()
Read a source range, advancing Idx.
void setClassInterface(ObjCInterfaceDecl *D)
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.
static std::string ReadString(const RecordData &Record, unsigned &Idx)
void setGetterCXXConstructor(Expr *getterCXXConstructor)
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
void setInline(bool Inline)
Set whether this is an inline namespace declaration.
static CXXDeductionGuideDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
IdentifierInfo * GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx)
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
void setVariadic(bool isVar)
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
unsigned varlist_size() const
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.
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()
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
A record containing CXXCtorInitializers.
A VarTemplateDecl record.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl *> typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
void setMemberSpecialization()
Note that this member template is a specialization.
Decl * readDecl()
Reads a declaration from the given position in a record in the given module, advancing Idx...
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
void setDefined(bool isDefined)
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
void 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.
A namespace alias, stored as a NamespaceAliasDecl*.
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
static void attachPreviousDecl(ASTReader &Reader, Decl *D, Decl *Previous, Decl *Canon)
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
const uint64_t & back() const
The last element in this record.
A CXXDestructorDecl record.
void VisitOMPRequiresDecl(OMPRequiresDecl *D)
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isFunctionOrMethod() const
StorageClass
Storage classes.
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody)
Determine whether the consumer will be interested in seeing this declaration (via HandleTopLevelDecl)...
This declaration has an owning module, and is visible when that module is imported.
A NamespaceAliasDecl record.
void setTypename(bool TN)
Sets whether the using declaration has 'typename'.
Declaration of an alias template.
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
void setLocation(SourceLocation L)
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
An ImplicitParamDecl record.
void setIvarRBraceLoc(SourceLocation Loc)
void VisitDecompositionDecl(DecompositionDecl *DD)
void setIsRedeclaration(bool RD)
Represents a C++ deduction guide declaration.
Represents a C++ conversion function within a class.
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, unsigned ID)
An EnumConstantDecl record.
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, unsigned ID)
std::string readString()
Read a string, advancing Idx.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
void setHasSkippedBody(bool Skipped=true)
An ImportDecl recording a module import.
A ObjCCategoryDecl record.
void setDoesNotEscape(bool B=true)
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
This file defines OpenMP AST classes for clauses.
static void AddLazySpecializations(T *D, SmallVectorImpl< serialization::DeclID > &IDs)
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
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...
Attr * ReadAttr(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Reads one attribute from the current stream position.
void VisitPragmaCommentDecl(PragmaCommentDecl *D)
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
void setIsVariadic(bool value)
static bool isSameQualifier(const NestedNameSpecifier *X, const NestedNameSpecifier *Y)
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize)
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Represents a C++ Modules TS module export declaration.
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
void setIsConversionFromLambda(bool val=true)
void setColonLoc(SourceLocation CLoc)
Sets the location of the colon.
An UnresolvedUsingValueDecl record.
void VisitDeclaratorDecl(DeclaratorDecl *DD)
static ObjCProtocolDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static EnumConstantDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static UsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
static void markIncompleteDeclChainImpl(Redeclarable< DeclT > *D)
static CXXDestructorDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Encodes a location in the source.
static EmptyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
QualType getReturnType() const
void setTopLevelDeclInObjCContainer(bool V=true)
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
This represents '#pragma omp declare reduction ...' directive.
A record that stores the set of declarations that are visible from a given DeclContext.
Pseudo declaration for capturing expressions.
void setIvarLBraceLoc(SourceLocation Loc)
void setBraceRange(SourceRange R)
void setAtStartLoc(SourceLocation Loc)
void VisitEmptyDecl(EmptyDecl *D)
void setAnonymousNamespace(NamespaceDecl *D)
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
void setObjCDeclQualifier(ObjCDeclQualifier QV)
Represents the declaration of a struct/union/class/enum.
ASTContext & getASTContext() const LLVM_READONLY
static DecompositionDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumBindings)
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
void setReferenced(bool R=true)
Represents the declaration of a label.
void mergeTemplatePattern(RedeclarableTemplateDecl *D, RedeclarableTemplateDecl *Existing, DeclID DsID, bool IsKeyDecl)
Merge together the pattern declarations from two template declarations.
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal)
Represents a dependent using declaration which was not marked with typename.
void setPosition(unsigned P)
void setIsCopyDeductionCandidate(bool isCDC=true)
void VisitObjCImplDecl(ObjCImplDecl *D)
Represents a static or instance method of a struct/union/class.
void setDefaulted(bool D=true)
void setHasFlexibleArrayMember(bool V)
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void VisitBindingDecl(BindingDecl *BD)
A TemplateTypeParmDecl record.
This file defines OpenMP nodes for declarative directives.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Data that is common to all of the declarations of a given function template.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
ObjCCategoryDecl - Represents a category declaration.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
static ConceptDecl * CreateDeserialized(ASTContext &C, unsigned ID)
FunctionDecl * getFunction() const
Retrieve the declaration of the function template specialization.
void readDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name)
void addDecl(NamedDecl *D)
void setDeclName(DeclarationName N)
Set the name of this declaration.
static MSPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
SourceLocation getLocation() const
void setOverriding(bool IsOver)
static ConstructorUsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Describes the categories of an Objective-C class.
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
void init(NamedDecl *templatedDecl, TemplateParameterList *templateParams)
Initialize the underlying templated declaration and template parameters.
void setTagKind(TagKind TK)
unsigned getIdx() const
The current position in this record.
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
static FunctionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Represents one property declaration in an Objective-C interface.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
uint32_t TypeID
An ID number that refers to a type in an AST file.
void setInitializer(Expr *E, InitKind IK)
Set initializer expression for the declare reduction construct.
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.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void setSetterCXXAssignment(Expr *setterCXXAssignment)
void VisitEnumDecl(EnumDecl *ED)
static TypedefDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Base class for declarations which introduce a typedef-name.
void setPropertyDecl(ObjCPropertyDecl *Prop)
A CXXConversionDecl record.
TagTypeKind
The kind of a tag type.
ObjCTypeParamList * ReadObjCTypeParamList()
Dataflow Directional Tag Classes.
void VisitCXXConversionDecl(CXXConversionDecl *D)
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
void setBody(CompoundStmt *B)
static CXXConversionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
static bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y)
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
void setHasVolatileMember(bool val)
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
The base class of all kinds of template declarations (e.g., class, function, etc.).
void VisitFunctionDecl(FunctionDecl *FD)
Reads an AST files chain containing the contents of a translation unit.
Represents a field injected from an anonymous union/struct into the parent scope. ...
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
A ClassTemplatePartialSpecializationDecl record.
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
DeclCode
Record codes for each kind of declaration.
A decomposition declaration.
RedeclarableResult VisitCXXRecordDeclImpl(CXXRecordDecl *D)
void setIvarList(ObjCIvarDecl *ivar)
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Represents a dependent using declaration which was marked with typename.
A ClassScopeFunctionSpecializationDecl record a class scope function specialization.
The name of a declaration.
Represents the declaration of an Objective-C type parameter.
void VisitObjCMethodDecl(ObjCMethodDecl *D)
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
A LinkageSpecDecl record.
RedeclarableResult VisitRecordDeclImpl(RecordDecl *RD)
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ParmVarDeclBitfields ParmVarDeclBits
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
static bool allowODRLikeMergeInC(NamedDecl *ND)
ODR-like semantics for C/ObjC allow us to merge tag types and a structural check in Sema guarantees t...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
static void forAllLaterRedecls(DeclT *D, Fn F)
void setExternLoc(SourceLocation L)
static bool inheritDefaultTemplateArgument(ASTContext &Context, ParmDecl *From, Decl *ToD)
Inherit the default template argument from From to To.
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
A type that was preceded by the 'template' keyword, stored as a Type*.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static LabelDecl * CreateDeserialized(ASTContext &C, unsigned ID)
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
All of the names in this module are visible.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
Capturing variable-length array type.
SmallVector< uint64_t, 64 > RecordData
A PragmaCommentDecl record.
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
bool isIncompleteArrayType() const
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
static ExportDecl * CreateDeserialized(ASTContext &C, unsigned ID)
NonParmVarDeclBitfields NonParmVarDeclBits
void 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)
Get the global offset corresponding to a local offset.
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)
Holds information about the various types of exception specification.
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
Capturing the *this object by reference.
unsigned clauselist_size() const
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
Attr * readAttr()
Reads one attribute from the current stream position, advancing Idx.
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 setInstanceMethod(bool isInst)
void setHasRedeclaration(bool HRD) const
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.
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
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U)
Determine whether two function types are the same, ignoring exception specifications in cases where t...
An object for streaming information from a record.
void VisitBlockDecl(BlockDecl *BD)
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
void VisitIndirectFieldDecl(IndirectFieldDecl *FD)
unsigned varlist_size() const
VarDeclBitfields VarDeclBits
static UsingPackDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions)
virtual CommonBase * newCommon(ASTContext &C) const =0
The top declaration context.
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
void ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs)
Reads attributes from the current stream position.
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D)
A FunctionTemplateDecl record.
std::pair< uint64_t, uint64_t > VisitDeclContext(DeclContext *DC)
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
A TypeAliasTemplateDecl record.
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
An instance of this class represents the declaration of a property member.
void setAtLoc(SourceLocation Loc)
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
A trivial tuple used to represent a source range.
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
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.