28 #include "llvm/Support/SaveAndRestore.h"
29 using namespace clang;
30 using namespace clang::serialization;
41 const unsigned RawLocation;
46 unsigned AnonymousDeclNumber;
52 uint64_t GetCurrentCursorOffset();
55 return Reader.ReadSourceLocation(F, R, I);
59 return Reader.ReadSourceRange(F, R, I);
63 return Reader.GetTypeSourceInfo(F, R, I);
67 return Reader.ReadDeclID(F, R, I);
71 for (
unsigned I = 0, Size = Record[Idx++]; I != Size; ++I)
72 IDs.push_back(ReadDeclID(Record, Idx));
76 return Reader.ReadDecl(F, R, I);
80 T *ReadDeclAs(
const RecordData &R,
unsigned &I) {
81 return Reader.ReadDeclAs<T>(F, R, I);
86 Reader.ReadQualifierInfo(F, Info, R, I);
91 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
96 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
104 return Reader.getGlobalSubmoduleID(F, R[I++]);
108 return Reader.getSubmodule(readSubmoduleID(R, I));
112 void ReadCXXDefinitionData(
struct CXXRecordDecl::DefinitionData &Data,
115 struct CXXRecordDecl::DefinitionData &&NewDD);
126 class RedeclarableResult {
134 void operator=(RedeclarableResult &) =
delete;
140 : Reader(Reader), FirstID(FirstID), MergeWith(MergeWith),
141 Owning(
true), IsKeyDecl(IsKeyDecl), DeclKind(DeclKind) {}
143 RedeclarableResult(RedeclarableResult &&Other)
144 : Reader(Other.Reader), FirstID(Other.FirstID),
145 MergeWith(Other.MergeWith), Owning(Other.Owning),
146 IsKeyDecl(Other.IsKeyDecl), DeclKind(Other.DeclKind) {
147 Other.Owning =
false;
150 ~RedeclarableResult() {
153 if (Reader.PendingDeclChainsKnown.insert(Canon).second)
154 Reader.PendingDeclChains.push_back(Canon);
162 bool isKeyDecl()
const {
return IsKeyDecl; }
166 Decl *getKnownMergeTarget()
const {
return MergeWith; }
174 class FindExistingResult {
178 mutable bool AddResult;
180 unsigned AnonymousDeclNumber;
183 void operator=(FindExistingResult&) =
delete;
187 : Reader(Reader), New(
nullptr), Existing(
nullptr), AddResult(
false),
188 AnonymousDeclNumber(0), TypedefNameForLinkage(0) {}
191 unsigned AnonymousDeclNumber,
193 : Reader(Reader), New(New), Existing(Existing), AddResult(
true),
194 AnonymousDeclNumber(AnonymousDeclNumber),
195 TypedefNameForLinkage(TypedefNameForLinkage) {}
197 FindExistingResult(
const FindExistingResult &Other)
198 : Reader(Other.Reader), New(Other.New), Existing(Other.Existing),
199 AddResult(Other.AddResult),
200 AnonymousDeclNumber(Other.AnonymousDeclNumber),
201 TypedefNameForLinkage(Other.TypedefNameForLinkage) {
202 Other.AddResult =
false;
205 ~FindExistingResult();
209 void suppress() { AddResult =
false; }
211 operator NamedDecl*()
const {
return Existing; }
214 operator T*()
const {
return dyn_cast_or_null<T>(Existing); }
219 FindExistingResult findExisting(
NamedDecl *D);
223 unsigned RawLocation,
const RecordData &Record,
unsigned &Idx)
224 : Reader(Reader), F(F), ThisDeclID(thisDeclID),
225 RawLocation(RawLocation), Record(Record), Idx(Idx),
226 TypeIDForTypeDecl(0), NamedDeclForTagDecl(0),
227 TypedefNameForLinkage(nullptr), HasPendingBody(
false) {}
229 template <
typename DeclT>
231 static Decl *getMostRecentDeclImpl(...);
232 static Decl *getMostRecentDecl(
Decl *D);
234 template <
typename DeclT>
235 static void attachPreviousDeclImpl(
ASTReader &Reader,
238 static void attachPreviousDeclImpl(
ASTReader &Reader, ...);
242 template <
typename DeclT>
244 static void attachLatestDeclImpl(...);
245 static void attachLatestDecl(
Decl *D,
Decl *latest);
247 template <
typename DeclT>
249 static void markIncompleteDeclChainImpl(...);
256 void UpdateDecl(
Decl *D, ModuleFile &ModuleFile,
257 const RecordData &Record);
261 Cat->NextClassCategory =
Next;
264 void VisitDecl(
Decl *D);
276 RedeclarableResult VisitTagDecl(
TagDecl *TD);
278 RedeclarableResult VisitRecordDeclImpl(
RecordDecl *RD);
282 RedeclarableResult VisitClassTemplateSpecializationDeclImpl(
286 VisitClassTemplateSpecializationDeclImpl(D);
288 void VisitClassTemplatePartialSpecializationDecl(
290 void VisitClassScopeFunctionSpecializationDecl(
295 VisitVarTemplateSpecializationDeclImpl(D);
297 void VisitVarTemplatePartialSpecializationDecl(
312 RedeclarableResult VisitVarDeclImpl(
VarDecl *D);
337 std::pair<uint64_t, uint64_t> VisitDeclContext(
DeclContext *DC);
344 DeclID TemplatePatternID = 0);
348 RedeclarableResult &Redecl,
349 DeclID TemplatePatternID = 0);
356 DeclID DsID,
bool IsKeyDecl);
389 Reader.PendingMergedDefinitionsToDeduplicate.insert(Def);
392 assert(
SubmoduleID &&
"hidden definition in no module");
403 template<
typename DeclT>
404 class MergedRedeclIterator {
405 DeclT *Start, *Canonical, *
Current;
407 MergedRedeclIterator() :
Current(nullptr) {}
408 MergedRedeclIterator(DeclT *Start)
409 : Start(Start), Canonical(nullptr),
Current(Start) {}
413 MergedRedeclIterator &operator++() {
429 friend bool operator!=(
const MergedRedeclIterator &A,
430 const MergedRedeclIterator &B) {
431 return A.Current != B.Current;
435 template<
typename DeclT>
437 return llvm::iterator_range<MergedRedeclIterator<DeclT>>(
438 MergedRedeclIterator<DeclT>(D),
439 MergedRedeclIterator<DeclT>());
442 uint64_t ASTDeclReader::GetCurrentCursorOffset() {
443 return F.DeclsCursor.GetCurrentBitNo() + F.GlobalBitOffset;
451 DeclaratorDecl::ExtInfo *Info =
452 DD->DeclInfo.get<DeclaratorDecl::ExtInfo *>();
454 GetTypeSourceInfo(Record, Idx);
457 DD->DeclInfo = GetTypeSourceInfo(Record, Idx);
461 if (
TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
463 TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull());
467 if (NamedDeclForTagDecl)
468 cast<TagDecl>(D)->NamedDeclOrQualifier =
469 cast<NamedDecl>(Reader.GetDecl(NamedDeclForTagDecl));
472 ID->TypeForDecl = Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull();
473 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
479 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
480 CD->NumCtorInitializers = Record[Idx++];
481 if (CD->NumCtorInitializers)
482 CD->CtorInitializers =
483 Reader.ReadCXXCtorInitializersRef(F, Record, Idx);
485 Reader.PendingBodies[FD] = GetCurrentCursorOffset();
486 HasPendingBody =
true;
493 isa<ParmVarDecl>(D)) {
500 GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID(Record, Idx);
501 GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID(Record, Idx);
502 Reader.addPendingDeclContextInfo(D,
503 SemaDCIDForTemplateParmDecl,
504 LexicalDCIDForTemplateParmDecl);
507 DeclContext *SemaDC = ReadDeclAs<DeclContext>(Record, Idx);
508 DeclContext *LexicalDC = ReadDeclAs<DeclContext>(Record, Idx);
512 D->setDeclContextsImpl(MergedSemaDC ? MergedSemaDC : SemaDC, LexicalDC,
513 Reader.getContext());
515 D->
setLocation(Reader.ReadSourceLocation(F, RawLocation));
519 Reader.ReadAttributes(F, Attrs, Record, Idx);
522 D->setAttrsImpl(Attrs, Reader.getContext());
525 D->Used = Record[Idx++];
535 if (
unsigned SubmoduleID = readSubmoduleID(Record, Idx)) {
541 }
else if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
553 Reader.HiddenNamesMap[Owner].push_back(D);
560 llvm_unreachable(
"Translation units are not serialized");
565 ND->
setDeclName(Reader.ReadDeclarationName(F, Record, Idx));
566 AnonymousDeclNumber = Record[Idx++];
573 TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]);
576 ASTDeclReader::RedeclarableResult
578 RedeclarableResult Redecl = VisitRedeclarable(TD);
582 QualType modedT = Reader.readType(F, Record, Idx);
590 RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
591 mergeRedeclarable(TD, Redecl);
595 RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
596 if (
auto *Template = ReadDeclAs<TypeAliasTemplateDecl>(Record, Idx))
600 mergeRedeclarable(TD, Redecl);
604 RedeclarableResult Redecl = VisitRedeclarable(TD);
609 if (!isa<CXXRecordDecl>(TD))
616 switch (Record[Idx++]) {
621 ReadQualifierInfo(*Info, Record, Idx);
622 TD->NamedDeclOrQualifier = Info;
626 NamedDeclForTagDecl = ReadDeclID(Record, Idx);
627 TypedefNameForLinkage = Reader.GetIdentifierInfo(F, Record, Idx);
630 NamedDeclForTagDecl = ReadDeclID(Record, Idx);
633 llvm_unreachable(
"unexpected tag info kind");
636 if (!isa<CXXRecordDecl>(TD))
637 mergeRedeclarable(TD, Redecl);
643 if (
TypeSourceInfo *TI = Reader.GetTypeSourceInfo(F, Record, Idx))
656 if (ED->IsCompleteDefinition &&
657 Reader.getContext().getLangOpts().Modules &&
658 Reader.getContext().getLangOpts().CPlusPlus) {
664 if (!D->isFromASTFile() && D->isCompleteDefinition()) {
671 Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
672 ED->IsCompleteDefinition =
false;
673 mergeDefinitionVisibility(OldDef, ED);
679 if (
EnumDecl *InstED = ReadDeclAs<EnumDecl>(Record, Idx)) {
682 ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK);
687 ASTDeclReader::RedeclarableResult
689 RedeclarableResult Redecl = VisitTagDecl(RD);
699 VD->
setType(Reader.readType(F, Record, Idx));
706 ECD->
setInitVal(Reader.ReadAPSInt(Record, Idx));
714 DeclaratorDecl::ExtInfo *Info
715 =
new (Reader.getContext()) DeclaratorDecl::ExtInfo();
716 ReadQualifierInfo(*Info, Record, Idx);
722 RedeclarableResult Redecl = VisitRedeclarable(FD);
723 VisitDeclaratorDecl(FD);
725 ReadDeclarationNameLoc(FD->DNLoc, FD->
getDeclName(), Record, Idx);
732 FD->IsInline = Record[Idx++];
733 FD->IsInlineSpecified = Record[Idx++];
734 FD->IsVirtualAsWritten = Record[Idx++];
735 FD->IsPure = Record[Idx++];
736 FD->HasInheritedPrototype = Record[Idx++];
737 FD->HasWrittenPrototype = Record[Idx++];
738 FD->IsDeleted = Record[Idx++];
739 FD->IsTrivial = Record[Idx++];
740 FD->IsDefaulted = Record[Idx++];
741 FD->IsExplicitlyDefaulted = Record[Idx++];
742 FD->HasImplicitReturnZero = Record[Idx++];
743 FD->IsConstexpr = Record[Idx++];
744 FD->HasSkippedBody = Record[Idx++];
745 FD->IsLateTemplateParsed = Record[Idx++];
747 FD->EndRangeLoc = ReadSourceLocation(Record, Idx);
751 mergeRedeclarable(FD, Redecl);
759 FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>(Record, Idx);
762 FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
764 mergeRedeclarable(FD, Redecl);
774 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
779 bool HasTemplateArgumentsAsWritten = Record[Idx++];
780 if (HasTemplateArgumentsAsWritten) {
781 unsigned NumTemplateArgLocs = Record[Idx++];
782 TemplArgLocs.reserve(NumTemplateArgLocs);
783 for (
unsigned i=0; i != NumTemplateArgLocs; ++i)
784 TemplArgLocs.push_back(
785 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
787 LAngleLoc = ReadSourceLocation(Record, Idx);
788 RAngleLoc = ReadSourceLocation(Record, Idx);
797 for (
unsigned i=0, e = TemplArgLocs.size(); i != e; ++i)
798 TemplArgsInfo.addArgument(TemplArgLocs[i]);
802 HasTemplateArgumentsAsWritten ? &TemplArgsInfo
805 FD->TemplateOrSpecialization = FTInfo;
811 = ReadDeclAs<FunctionTemplateDecl>(Record, Idx);
817 llvm::FoldingSetNodeID
ID;
819 void *InsertPos =
nullptr;
826 assert(Reader.getContext().getLangOpts().Modules &&
827 "already deserialized this template specialization");
828 mergeRedeclarable(FD, ExistingInfo->
Function, Redecl);
836 unsigned NumTemplates = Record[Idx++];
837 while (NumTemplates--)
838 TemplDecls.
addDecl(ReadDeclAs<NamedDecl>(Record, Idx));
842 unsigned NumArgs = Record[Idx++];
844 TemplArgs.
addArgument(Reader.ReadTemplateArgumentLoc(F, Record, Idx));
845 TemplArgs.
setLAngleLoc(ReadSourceLocation(Record, Idx));
846 TemplArgs.
setRAngleLoc(ReadSourceLocation(Record, Idx));
849 TemplDecls, TemplArgs);
857 unsigned NumParams = Record[Idx++];
859 Params.reserve(NumParams);
860 for (
unsigned I = 0; I != NumParams; ++I)
861 Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
862 FD->setParams(Reader.getContext(), Params);
870 Reader.PendingBodies[MD] = GetCurrentCursorOffset();
871 HasPendingBody =
true;
872 MD->
setSelfDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
873 MD->
setCmdDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
879 MD->IsOverriding = Record[Idx++];
880 MD->HasSkippedBody = Record[Idx++];
882 MD->IsRedeclaration = Record[Idx++];
883 MD->HasRedeclaration = Record[Idx++];
884 if (MD->HasRedeclaration)
885 Reader.getContext().setObjCMethodRedeclaration(MD,
886 ReadDeclAs<ObjCMethodDecl>(Record, Idx));
893 MD->DeclEndLoc = ReadSourceLocation(Record, Idx);
894 unsigned NumParams = Record[Idx++];
896 Params.reserve(NumParams);
897 for (
unsigned I = 0; I != NumParams; ++I)
898 Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
900 MD->SelLocsKind = Record[Idx++];
901 unsigned NumStoredSelLocs = Record[Idx++];
903 SelLocs.reserve(NumStoredSelLocs);
904 for (
unsigned i = 0; i != NumStoredSelLocs; ++i)
905 SelLocs.push_back(ReadSourceLocation(Record, Idx));
907 MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs);
911 VisitTypedefNameDecl(D);
912 D->Variance = Record[Idx++];
913 D->Index = Record[Idx++];
914 D->VarianceLoc = ReadSourceLocation(Record, Idx);
915 D->ColonLoc = ReadSourceLocation(Record, Idx);
925 unsigned numParams = Record[Idx++];
930 typeParams.reserve(numParams);
931 for (
unsigned i = 0; i != numParams; ++i) {
932 auto typeParam = ReadDeclAs<ObjCTypeParamDecl>(Record, Idx);
936 typeParams.push_back(typeParam);
943 typeParams, rAngleLoc);
947 RedeclarableResult Redecl = VisitRedeclarable(ID);
948 VisitObjCContainerDecl(ID);
949 TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]);
950 mergeRedeclarable(ID, Redecl);
952 ID->TypeParamList = ReadObjCTypeParamList();
955 ID->allocateDefinitionData();
961 ObjCInterfaceDecl::DefinitionData &Data = ID->data();
964 Data.SuperClassTInfo = GetTypeSourceInfo(Record, Idx);
966 Data.EndLoc = ReadSourceLocation(Record, Idx);
967 Data.HasDesignatedInitializers = Record[Idx++];
970 unsigned NumProtocols = Record[Idx++];
972 Protocols.reserve(NumProtocols);
973 for (
unsigned I = 0; I != NumProtocols; ++I)
974 Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
976 ProtoLocs.reserve(NumProtocols);
977 for (
unsigned I = 0; I != NumProtocols; ++I)
978 ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
980 Reader.getContext());
983 NumProtocols = Record[Idx++];
985 Protocols.reserve(NumProtocols);
986 for (
unsigned I = 0; I != NumProtocols; ++I)
987 Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
988 ID->data().AllReferencedProtocols.set(Protocols.data(), NumProtocols,
989 Reader.getContext());
995 Reader.PendingDefinitions.insert(ID);
998 Reader.ObjCClassesLoaded.push_back(ID);
1005 VisitFieldDecl(IVD);
1009 bool synth = Record[Idx++];
1014 RedeclarableResult Redecl = VisitRedeclarable(PD);
1015 VisitObjCContainerDecl(PD);
1016 mergeRedeclarable(PD, Redecl);
1018 if (Record[Idx++]) {
1020 PD->allocateDefinitionData();
1026 unsigned NumProtoRefs = Record[Idx++];
1028 ProtoRefs.reserve(NumProtoRefs);
1029 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1030 ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
1032 ProtoLocs.reserve(NumProtoRefs);
1033 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1034 ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
1036 Reader.getContext());
1039 Reader.PendingDefinitions.insert(PD);
1050 VisitObjCContainerDecl(CD);
1058 Reader.CategoriesDeserialized.insert(CD);
1060 CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>(Record, Idx);
1061 CD->TypeParamList = ReadObjCTypeParamList();
1062 unsigned NumProtoRefs = Record[Idx++];
1064 ProtoRefs.reserve(NumProtoRefs);
1065 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1066 ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
1068 ProtoLocs.reserve(NumProtoRefs);
1069 for (
unsigned I = 0; I != NumProtoRefs; ++I)
1070 ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
1072 Reader.getContext());
1076 VisitNamedDecl(CAD);
1082 D->
setAtLoc(ReadSourceLocation(Record, Idx));
1084 QualType T = Reader.readType(F, Record, Idx);
1093 D->
setGetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector());
1094 D->
setSetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector());
1101 VisitObjCContainerDecl(D);
1106 VisitObjCImplDecl(D);
1108 D->CategoryNameLoc = ReadSourceLocation(Record, Idx);
1112 VisitObjCImplDecl(D);
1113 D->
setSuperClass(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
1114 D->SuperLoc = ReadSourceLocation(Record, Idx);
1119 D->NumIvarInitializers = Record[Idx++];
1120 if (D->NumIvarInitializers)
1121 D->IvarInitializers = Reader.ReadCXXCtorInitializersRef(F, Record, Idx);
1127 D->
setAtLoc(ReadSourceLocation(Record, Idx));
1129 D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>(Record, Idx);
1130 D->IvarLoc = ReadSourceLocation(Record, Idx);
1136 VisitDeclaratorDecl(FD);
1137 FD->Mutable = Record[Idx++];
1138 if (
int BitWidthOrInitializer = Record[Idx++]) {
1139 FD->InitStorage.setInt(
1140 static_cast<FieldDecl::InitStorageKind>(BitWidthOrInitializer - 1));
1141 if (FD->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
1143 FD->InitStorage.setPointer(
1144 Reader.readType(F, Record, Idx).getAsOpaquePtr());
1146 FD->InitStorage.setPointer(Reader.ReadExpr(F));
1150 if (
FieldDecl *Tmpl = ReadDeclAs<FieldDecl>(Record, Idx))
1151 Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
1157 VisitDeclaratorDecl(PD);
1158 PD->GetterId = Reader.GetIdentifierInfo(F, Record, Idx);
1159 PD->SetterId = Reader.GetIdentifierInfo(F, Record, Idx);
1165 FD->ChainingSize = Record[Idx++];
1166 assert(FD->ChainingSize >= 2 &&
"Anonymous chaining must be >= 2");
1167 FD->Chaining =
new (Reader.getContext())
NamedDecl*[FD->ChainingSize];
1169 for (
unsigned I = 0; I != FD->ChainingSize; ++I)
1170 FD->Chaining[I] = ReadDeclAs<NamedDecl>(Record, Idx);
1174 RedeclarableResult Redecl = VisitRedeclarable(VD);
1175 VisitDeclaratorDecl(VD);
1180 if (!isa<ParmVarDecl>(VD)) {
1197 if (uint64_t Val = Record[Idx++]) {
1198 VD->
setInit(Reader.ReadExpr(F));
1202 Eval->
IsICE = Val == 3;
1207 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1209 switch ((VarKind)Record[Idx++]) {
1210 case VarNotTemplate:
1212 if (VD->
getKind() != Decl::ParmVar && VD->
getKind() != Decl::ImplicitParam &&
1213 !isa<VarTemplateSpecializationDecl>(VD))
1214 mergeRedeclarable(VD, Redecl);
1220 case StaticDataMemberSpecialization: {
1221 VarDecl *Tmpl = ReadDeclAs<VarDecl>(Record, Idx);
1224 Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
1225 mergeRedeclarable(VD, Redecl);
1239 unsigned isObjCMethodParam = Record[Idx++];
1240 unsigned scopeDepth = Record[Idx++];
1241 unsigned scopeIndex = Record[Idx++];
1242 unsigned declQualifier = Record[Idx++];
1243 if (isObjCMethodParam) {
1244 assert(scopeDepth == 0);
1261 AD->
setAsmString(cast<StringLiteral>(Reader.ReadExpr(F)));
1267 BD->
setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(F)));
1269 unsigned NumParams = Record[Idx++];
1271 Params.reserve(NumParams);
1272 for (
unsigned I = 0; I != NumParams; ++I)
1273 Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
1280 bool capturesCXXThis = Record[Idx++];
1281 unsigned numCaptures = Record[Idx++];
1283 captures.reserve(numCaptures);
1284 for (
unsigned i = 0; i != numCaptures; ++i) {
1286 unsigned flags = Record[Idx++];
1287 bool byRef = (flags & 1);
1288 bool nested = (flags & 2);
1289 Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) :
nullptr);
1293 BD->
setCaptures(Reader.getContext(), captures.begin(),
1294 captures.end(), capturesCXXThis);
1299 unsigned ContextParamPos = Record[Idx++];
1302 for (
unsigned I = 0; I < CD->NumParams; ++I) {
1303 if (I != ContextParamPos)
1304 CD->
setParam(I, ReadDeclAs<ImplicitParamDecl>(Record, Idx));
1324 RedeclarableResult Redecl = VisitRedeclarable(D);
1327 D->LocStart = ReadSourceLocation(Record, Idx);
1328 D->RBraceLoc = ReadSourceLocation(Record, Idx);
1335 if (Redecl.getFirstID() == ThisDeclID) {
1336 AnonNamespace = ReadDeclID(Record, Idx);
1340 D->AnonOrFirstNamespaceAndInline.setPointer(D->
getFirstDecl());
1343 mergeRedeclarable(D, Redecl);
1345 if (AnonNamespace) {
1349 NamespaceDecl *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
1356 RedeclarableResult Redecl = VisitRedeclarable(D);
1358 D->NamespaceLoc = ReadSourceLocation(Record, Idx);
1359 D->IdentLoc = ReadSourceLocation(Record, Idx);
1360 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1361 D->Namespace = ReadDeclAs<NamedDecl>(Record, Idx);
1362 mergeRedeclarable(D, Redecl);
1368 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1369 ReadDeclarationNameLoc(D->DNLoc, D->
getDeclName(), Record, Idx);
1370 D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>(Record, Idx));
1372 if (
NamedDecl *Pattern = ReadDeclAs<NamedDecl>(Record, Idx))
1373 Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
1378 RedeclarableResult Redecl = VisitRedeclarable(D);
1381 D->UsingOrNextShadow = ReadDeclAs<NamedDecl>(Record, Idx);
1384 Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern);
1385 mergeRedeclarable(D, Redecl);
1390 D->UsingLoc = ReadSourceLocation(Record, Idx);
1391 D->NamespaceLoc = ReadSourceLocation(Record, Idx);
1392 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1393 D->NominatedNamespace = ReadDeclAs<NamedDecl>(Record, Idx);
1394 D->CommonAncestor = ReadDeclAs<DeclContext>(Record, Idx);
1400 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1401 ReadDeclarationNameLoc(D->DNLoc, D->
getDeclName(), Record, Idx);
1408 D->TypenameLocation = ReadSourceLocation(Record, Idx);
1409 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1413 void ASTDeclReader::ReadCXXDefinitionData(
1414 struct CXXRecordDecl::DefinitionData &Data,
1415 const RecordData &Record,
unsigned &Idx) {
1417 Data.UserDeclaredConstructor = Record[Idx++];
1418 Data.UserDeclaredSpecialMembers = Record[Idx++];
1419 Data.Aggregate = Record[Idx++];
1420 Data.PlainOldData = Record[Idx++];
1421 Data.Empty = Record[Idx++];
1422 Data.Polymorphic = Record[Idx++];
1423 Data.Abstract = Record[Idx++];
1424 Data.IsStandardLayout = Record[Idx++];
1425 Data.HasNoNonEmptyBases = Record[Idx++];
1426 Data.HasPrivateFields = Record[Idx++];
1427 Data.HasProtectedFields = Record[Idx++];
1428 Data.HasPublicFields = Record[Idx++];
1429 Data.HasMutableFields = Record[Idx++];
1430 Data.HasVariantMembers = Record[Idx++];
1431 Data.HasOnlyCMembers = Record[Idx++];
1432 Data.HasInClassInitializer = Record[Idx++];
1433 Data.HasUninitializedReferenceMember = Record[Idx++];
1434 Data.NeedOverloadResolutionForMoveConstructor = Record[Idx++];
1435 Data.NeedOverloadResolutionForMoveAssignment = Record[Idx++];
1436 Data.NeedOverloadResolutionForDestructor = Record[Idx++];
1437 Data.DefaultedMoveConstructorIsDeleted = Record[Idx++];
1438 Data.DefaultedMoveAssignmentIsDeleted = Record[Idx++];
1439 Data.DefaultedDestructorIsDeleted = Record[Idx++];
1440 Data.HasTrivialSpecialMembers = Record[Idx++];
1441 Data.DeclaredNonTrivialSpecialMembers = Record[Idx++];
1442 Data.HasIrrelevantDestructor = Record[Idx++];
1443 Data.HasConstexprNonCopyMoveConstructor = Record[Idx++];
1444 Data.DefaultedDefaultConstructorIsConstexpr = Record[Idx++];
1445 Data.HasConstexprDefaultConstructor = Record[Idx++];
1446 Data.HasNonLiteralTypeFieldsOrBases = Record[Idx++];
1447 Data.ComputedVisibleConversions = Record[Idx++];
1448 Data.UserProvidedDefaultConstructor = Record[Idx++];
1449 Data.DeclaredSpecialMembers = Record[Idx++];
1450 Data.ImplicitCopyConstructorHasConstParam = Record[Idx++];
1451 Data.ImplicitCopyAssignmentHasConstParam = Record[Idx++];
1452 Data.HasDeclaredCopyConstructorWithConstParam = Record[Idx++];
1453 Data.HasDeclaredCopyAssignmentWithConstParam = Record[Idx++];
1455 Data.NumBases = Record[Idx++];
1457 Data.Bases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
1458 Data.NumVBases = Record[Idx++];
1460 Data.VBases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
1462 Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx);
1463 Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx);
1464 assert(Data.Definition &&
"Data.Definition should be already set!");
1465 Data.FirstFriend = ReadDeclID(Record, Idx);
1467 if (Data.IsLambda) {
1469 CXXRecordDecl::LambdaDefinitionData &Lambda
1470 =
static_cast<CXXRecordDecl::LambdaDefinitionData &
>(Data);
1471 Lambda.Dependent = Record[Idx++];
1472 Lambda.IsGenericLambda = Record[Idx++];
1473 Lambda.CaptureDefault = Record[Idx++];
1474 Lambda.NumCaptures = Record[Idx++];
1475 Lambda.NumExplicitCaptures = Record[Idx++];
1476 Lambda.ManglingNumber = Record[Idx++];
1477 Lambda.ContextDecl = ReadDecl(Record, Idx);
1479 = (Capture*)Reader.Context.Allocate(
sizeof(Capture)*Lambda.NumCaptures);
1480 Capture *ToCapture = Lambda.Captures;
1481 Lambda.MethodTyInfo = GetTypeSourceInfo(Record, Idx);
1482 for (
unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
1484 bool IsImplicit = Record[Idx++];
1489 *ToCapture++ = Capture(Loc, IsImplicit, Kind,
nullptr,
SourceLocation());
1493 VarDecl *Var = ReadDeclAs<VarDecl>(Record, Idx);
1495 *ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
1502 void ASTDeclReader::MergeDefinitionData(
1503 CXXRecordDecl *D,
struct CXXRecordDecl::DefinitionData &&MergeDD) {
1505 "merging class definition into non-definition");
1508 if (DD.Definition != MergeDD.Definition) {
1515 Reader.MergedLookups[DD.Definition].push_back(MergeDD.Definition);
1516 DD.Definition->setHasExternalVisibleStorage();
1519 Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition,
1521 Reader.PendingDefinitions.erase(MergeDD.Definition);
1522 MergeDD.Definition->IsCompleteDefinition =
false;
1523 mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
1526 auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
1527 if (PFDI != Reader.PendingFakeDefinitionData.end() &&
1531 assert(!DD.IsLambda && !MergeDD.IsLambda &&
"faked up lambda definition?");
1536 auto *Def = DD.Definition;
1537 DD = std::move(MergeDD);
1538 DD.Definition = Def;
1543 bool DetectedOdrViolation =
false;
1544 #define OR_FIELD(Field) DD.Field |= MergeDD.Field;
1545 #define MATCH_FIELD(Field) \
1546 DetectedOdrViolation |= DD.Field != MergeDD.Field; \
1565 MATCH_FIELD(NeedOverloadResolutionForMoveConstructor)
1566 MATCH_FIELD(NeedOverloadResolutionForMoveAssignment)
1572 OR_FIELD(DeclaredNonTrivialSpecialMembers)
1574 OR_FIELD(HasConstexprNonCopyMoveConstructor)
1575 MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr)
1576 OR_FIELD(HasConstexprDefaultConstructor)
1583 OR_FIELD(HasDeclaredCopyConstructorWithConstParam)
1584 OR_FIELD(HasDeclaredCopyAssignmentWithConstParam)
1589 if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases)
1590 DetectedOdrViolation =
true;
1596 if (MergeDD.ComputedVisibleConversions && !DD.ComputedVisibleConversions) {
1597 DD.VisibleConversions = std::move(MergeDD.VisibleConversions);
1598 DD.ComputedVisibleConversions =
true;
1609 if (DetectedOdrViolation)
1610 Reader.PendingOdrMergeFailures[DD.Definition].push_back(MergeDD.Definition);
1613 void ASTDeclReader::ReadCXXRecordDefinition(
CXXRecordDecl *D,
bool Update) {
1614 struct CXXRecordDecl::DefinitionData *DD;
1619 bool IsLambda = Record[Idx++];
1621 DD =
new (
C) CXXRecordDecl::LambdaDefinitionData(D,
nullptr,
false,
false,
1624 DD =
new (
C)
struct CXXRecordDecl::DefinitionData(D);
1626 ReadCXXDefinitionData(*DD, Record, Idx);
1633 MergeDefinitionData(Canon, std::move(*DD));
1634 D->DefinitionData = Canon->DefinitionData;
1639 D->IsCompleteDefinition =
true;
1640 D->DefinitionData = DD;
1645 if (Update || Canon != D) {
1646 Canon->DefinitionData = D->DefinitionData;
1647 Reader.PendingDefinitions.insert(D);
1651 ASTDeclReader::RedeclarableResult
1653 RedeclarableResult Redecl = VisitRecordDeclImpl(D);
1658 CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1660 switch ((CXXRecKind)Record[Idx++]) {
1661 case CXXRecNotTemplate:
1663 if (!isa<ClassTemplateSpecializationDecl>(D))
1664 mergeRedeclarable(D, Redecl);
1666 case CXXRecTemplate: {
1669 D->TemplateOrInstantiation = Template;
1677 TypeIDForTypeDecl = 0;
1681 case CXXRecMemberSpecialization: {
1687 D->TemplateOrInstantiation = MSI;
1688 mergeRedeclarable(D, Redecl);
1693 bool WasDefinition = Record[Idx++];
1695 ReadCXXRecordDefinition(D,
false);
1702 if (WasDefinition) {
1703 DeclID KeyFn = ReadDeclID(Record, Idx);
1704 if (KeyFn && D->IsCompleteDefinition)
1708 C.KeyFunctions[D] = KeyFn;
1715 VisitFunctionDecl(D);
1717 unsigned NumOverridenMethods = Record[Idx++];
1719 while (NumOverridenMethods--) {
1722 if (
CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>(Record, Idx))
1728 Idx += NumOverridenMethods;
1733 VisitCXXMethodDecl(D);
1735 if (
auto *CD = ReadDeclAs<CXXConstructorDecl>(Record, Idx))
1738 D->IsExplicitSpecified = Record[Idx++];
1742 VisitCXXMethodDecl(D);
1744 if (
auto *OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx)) {
1747 if (!Canon->OperatorDelete)
1748 Canon->OperatorDelete = OperatorDelete;
1753 VisitCXXMethodDecl(D);
1754 D->IsExplicitSpecified = Record[Idx++];
1759 D->ImportedAndComplete.setPointer(readModule(Record, Idx));
1760 D->ImportedAndComplete.setInt(Record[Idx++]);
1762 for (
unsigned I = 0, N = Record.back(); I != N; ++I)
1763 StoredLocs[I] = ReadSourceLocation(Record, Idx);
1775 D->Friend = ReadDeclAs<NamedDecl>(Record, Idx);
1777 D->Friend = GetTypeSourceInfo(Record, Idx);
1778 for (
unsigned i = 0; i != D->NumTPLists; ++i)
1779 D->getTPLists()[i] = Reader.ReadTemplateParameterList(F, Record, Idx);
1780 D->NextFriend = ReadDeclID(Record, Idx);
1781 D->UnsupportedFriend = (Record[Idx++] != 0);
1782 D->FriendLoc = ReadSourceLocation(Record, Idx);
1787 unsigned NumParams = Record[Idx++];
1788 D->NumParams = NumParams;
1790 for (
unsigned i = 0; i != NumParams; ++i)
1791 D->Params[i] = Reader.ReadTemplateParameterList(F, Record, Idx);
1793 D->Friend = ReadDeclAs<NamedDecl>(Record, Idx);
1795 D->Friend = GetTypeSourceInfo(Record, Idx);
1796 D->FriendLoc = ReadSourceLocation(Record, Idx);
1802 DeclID PatternID = ReadDeclID(Record, Idx);
1803 NamedDecl *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
1805 = Reader.ReadTemplateParameterList(F, Record, Idx);
1806 D->
init(TemplatedDecl, TemplateParams);
1811 ASTDeclReader::RedeclarableResult
1813 RedeclarableResult Redecl = VisitRedeclarable(D);
1820 Reader.PendingDefinitions.insert(CanonD);
1826 if (ThisDeclID == Redecl.getFirstID()) {
1828 = ReadDeclAs<RedeclarableTemplateDecl>(Record, Idx)) {
1829 assert(RTD->getKind() == D->
getKind() &&
1830 "InstantiatedFromMemberTemplate kind mismatch");
1837 DeclID PatternID = VisitTemplateDecl(D);
1840 mergeRedeclarable(D, Redecl, PatternID);
1852 assert(!IDs.empty() &&
"no IDs to add to list");
1854 IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
1855 std::sort(IDs.begin(), IDs.end());
1856 IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
1861 std::copy(IDs.begin(), IDs.end(),
Result + 1);
1866 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
1868 if (ThisDeclID == Redecl.getFirstID()) {
1872 ReadDeclIDList(SpecIDs);
1874 if (!SpecIDs.empty()) {
1877 Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
1885 Reader.Context.getInjectedClassNameType(
1894 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
1896 if (ThisDeclID == Redecl.getFirstID()) {
1900 ReadDeclIDList(SpecIDs);
1902 if (!SpecIDs.empty()) {
1905 Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
1910 ASTDeclReader::RedeclarableResult
1913 RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D);
1916 if (
Decl *InstD = ReadDecl(Record, Idx)) {
1918 D->SpecializedTemplate = CTD;
1921 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
1925 ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
1927 SpecializedPartialSpecialization();
1928 PS->PartialSpecialization
1929 = cast<ClassTemplatePartialSpecializationDecl>(InstD);
1930 PS->TemplateArgs = ArgList;
1931 D->SpecializedTemplate = PS;
1936 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
1939 D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
1942 bool writtenAsCanonicalDecl = Record[Idx++];
1943 if (writtenAsCanonicalDecl) {
1949 dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
1951 .GetOrInsertNode(Partial);
1957 if (CanonSpec != D) {
1958 mergeRedeclarable<TagDecl>(D, CanonSpec, Redecl);
1962 if (
auto *DDD = D->DefinitionData.getNotUpdated()) {
1963 if (CanonSpec->DefinitionData.getNotUpdated())
1964 MergeDefinitionData(CanonSpec, std::move(*DDD));
1966 CanonSpec->DefinitionData = D->DefinitionData;
1968 D->DefinitionData = CanonSpec->DefinitionData;
1975 ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo
1976 =
new (
C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
1977 ExplicitInfo->TypeAsWritten = TyInfo;
1978 ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx);
1979 ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx);
1980 D->ExplicitInfo = ExplicitInfo;
1988 RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
1990 D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx);
1991 D->ArgsAsWritten = Reader.ReadASTTemplateArgumentListInfo(F, Record, Idx);
1994 if (ThisDeclID == Redecl.getFirstID()) {
1995 D->InstantiatedFromMember.setPointer(
1996 ReadDeclAs<ClassTemplatePartialSpecializationDecl>(Record, Idx));
1997 D->InstantiatedFromMember.setInt(Record[Idx++]);
2004 D->Specialization = ReadDeclAs<CXXMethodDecl>(Record, Idx);
2008 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
2010 if (ThisDeclID == Redecl.getFirstID()) {
2013 ReadDeclIDList(SpecIDs);
2015 if (!SpecIDs.empty()) {
2018 Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
2028 ASTDeclReader::RedeclarableResult
2031 RedeclarableResult Redecl = VisitVarDeclImpl(D);
2034 if (
Decl *InstD = ReadDecl(Record, Idx)) {
2036 D->SpecializedTemplate = VTD;
2039 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
2041 C, TemplArgs.data(), TemplArgs.size());
2042 VarTemplateSpecializationDecl::SpecializedPartialSpecialization *PS =
2044 VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
2045 PS->PartialSpecialization =
2046 cast<VarTemplatePartialSpecializationDecl>(InstD);
2047 PS->TemplateArgs = ArgList;
2048 D->SpecializedTemplate = PS;
2054 VarTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo =
2055 new (
C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo;
2056 ExplicitInfo->TypeAsWritten = TyInfo;
2057 ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx);
2058 ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx);
2059 D->ExplicitInfo = ExplicitInfo;
2063 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
2066 D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
2069 bool writtenAsCanonicalDecl = Record[Idx++];
2070 if (writtenAsCanonicalDecl) {
2071 VarTemplateDecl *CanonPattern = ReadDeclAs<VarTemplateDecl>(Record, Idx);
2074 dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
2076 .GetOrInsertNode(Partial);
2093 RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
2095 D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx);
2096 D->ArgsAsWritten = Reader.ReadASTTemplateArgumentListInfo(F, Record, Idx);
2099 if (ThisDeclID == Redecl.getFirstID()) {
2100 D->InstantiatedFromMember.setPointer(
2101 ReadDeclAs<VarTemplatePartialSpecializationDecl>(Record, Idx));
2102 D->InstantiatedFromMember.setInt(Record[Idx++]);
2116 VisitDeclaratorDecl(D);
2121 void **Data =
reinterpret_cast<void **
>(D + 1);
2123 Data[2*I] = Reader.readType(F, Record, Idx).getAsOpaquePtr();
2124 Data[2*I + 1] = GetTypeSourceInfo(Record, Idx);
2128 D->ParameterPack = Record[Idx++];
2135 VisitTemplateDecl(D);
2140 void **Data =
reinterpret_cast<void **
>(D + 1);
2143 Data[I] = Reader.ReadTemplateParameterList(F, Record, Idx);
2146 D->ParameterPack = Record[Idx++];
2149 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
2154 VisitRedeclarableTemplateDecl(D);
2159 D->AssertExprAndFailed.setPointer(Reader.ReadExpr(F));
2160 D->AssertExprAndFailed.setInt(Record[Idx++]);
2161 D->Message = cast<StringLiteral>(Reader.ReadExpr(F));
2162 D->RParenLoc = ReadSourceLocation(Record, Idx);
2169 std::pair<uint64_t, uint64_t>
2171 uint64_t LexicalOffset = Record[Idx++];
2172 uint64_t VisibleOffset = Record[Idx++];
2173 return std::make_pair(LexicalOffset, VisibleOffset);
2176 template <
typename T>
2177 ASTDeclReader::RedeclarableResult
2179 DeclID FirstDeclID = ReadDeclID(Record, Idx);
2180 Decl *MergeWith =
nullptr;
2181 bool IsKeyDecl = ThisDeclID == FirstDeclID;
2185 if (FirstDeclID == 0) {
2186 FirstDeclID = ThisDeclID;
2188 }
else if (
unsigned N = Record[Idx++]) {
2196 for (
unsigned I = 0; I != N; ++I)
2197 MergeWith = ReadDecl(Record, Idx);
2200 T *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID));
2201 if (FirstDecl != D) {
2207 D->
First = FirstDecl->getCanonicalDecl();
2211 Reader.RedeclsDeserialized.insert(static_cast<T *>(D));
2215 return RedeclarableResult(Reader, FirstDeclID, MergeWith,
2216 static_cast<T *>(D)->
getKind(), IsKeyDecl);
2221 template<
typename T>
2223 RedeclarableResult &Redecl,
2224 DeclID TemplatePatternID) {
2225 T *D =
static_cast<T*
>(DBase);
2228 if (!Reader.getContext().getLangOpts().Modules)
2235 if (
auto *Existing = Redecl.getKnownMergeTarget())
2237 mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID);
2238 else if (FindExistingResult ExistingRes = findExisting(D))
2239 if (T *Existing = ExistingRes)
2240 mergeRedeclarable(D, Existing, Redecl, TemplatePatternID);
2248 llvm_unreachable(
"bad assert_cast");
2255 DeclID DsID,
bool IsKeyDecl) {
2258 RedeclarableResult
Result(Reader, DPattern->getCanonicalDecl()->getGlobalID(),
2259 ExistingPattern, DPattern->getKind(),
2262 if (
auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) {
2265 auto *ExistingClass =
2266 cast<CXXRecordDecl>(ExistingPattern)->getCanonicalDecl();
2267 if (
auto *DDD = DClass->DefinitionData.getNotUpdated()) {
2268 if (ExistingClass->DefinitionData.getNotUpdated()) {
2269 MergeDefinitionData(ExistingClass, std::move(*DDD));
2271 ExistingClass->DefinitionData = DClass->DefinitionData;
2274 Reader.PendingDefinitions.insert(DClass);
2277 DClass->DefinitionData = ExistingClass->DefinitionData;
2279 return mergeRedeclarable(DClass, cast<TagDecl>(ExistingPattern),
2282 if (
auto *DFunction = dyn_cast<FunctionDecl>(DPattern))
2283 return mergeRedeclarable(DFunction, cast<FunctionDecl>(ExistingPattern),
2285 if (
auto *DVar = dyn_cast<VarDecl>(DPattern))
2286 return mergeRedeclarable(DVar, cast<VarDecl>(ExistingPattern),
Result);
2287 if (
auto *DAlias = dyn_cast<TypeAliasDecl>(DPattern))
2288 return mergeRedeclarable(DAlias, cast<TypedefNameDecl>(ExistingPattern),
2290 llvm_unreachable(
"merged an unknown kind of redeclarable template");
2295 template<
typename T>
2297 RedeclarableResult &Redecl,
2298 DeclID TemplatePatternID) {
2299 T *D =
static_cast<T*
>(DBase);
2302 if (ExistingCanon != DCanon) {
2303 assert(DCanon->getGlobalID() == Redecl.getFirstID() &&
2304 "already merged this declaration");
2310 D->First = ExistingCanon;
2315 if (
auto *Namespace = dyn_cast<NamespaceDecl>(D))
2316 Namespace->AnonOrFirstNamespaceAndInline.setPointer(
2317 assert_cast<NamespaceDecl*>(ExistingCanon));
2320 if (
auto *DTemplate = dyn_cast<RedeclarableTemplateDecl>(D))
2321 mergeTemplatePattern(
2322 DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon),
2323 TemplatePatternID, Redecl.isKeyDecl());
2326 if (Redecl.isKeyDecl()) {
2327 Reader.KeyDecls[ExistingCanon].push_back(Redecl.getFirstID());
2328 if (Reader.PendingDeclChainsKnown.insert(ExistingCanon).second)
2329 Reader.PendingDeclChains.push_back(ExistingCanon);
2338 template<
typename T>
2341 if (!Reader.getContext().getLangOpts().Modules)
2347 if (!Reader.getContext().getLangOpts().CPlusPlus)
2350 if (FindExistingResult ExistingRes = findExisting(static_cast<T*>(D)))
2351 if (T *Existing = ExistingRes)
2352 Reader.Context.setPrimaryMergedDecl(static_cast<T*>(D),
2353 Existing->getCanonicalDecl());
2360 Vars.reserve(NumVars);
2361 for (
unsigned i = 0; i != NumVars; ++i) {
2362 Vars.push_back(Reader.ReadExpr(F));
2374 for (
unsigned i = 0, e = Record[Idx++]; i != e; ++i) {
2375 Attr *New =
nullptr;
2377 SourceRange Range = ReadSourceRange(F, Record, Idx);
2379 #include "clang/Serialization/AttrPCHRead.inc"
2381 assert(New &&
"Unable to decode attribute?");
2382 Attrs.push_back(New);
2396 inline void ASTReader::LoadedDecl(
unsigned Index,
Decl *D) {
2397 assert(!DeclsLoaded[Index] &&
"Decl loaded twice?");
2398 DeclsLoaded[Index] = D;
2412 if (isa<FileScopeAsmDecl>(D) ||
2413 isa<ObjCProtocolDecl>(D) ||
2414 isa<ObjCImplDecl>(D) ||
2415 isa<ImportDecl>(D) ||
2416 isa<OMPThreadPrivateDecl>(D))
2418 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
2419 return Var->isFileVarDecl() &&
2422 return Func->doesThisDeclarationHaveABody() || HasBody;
2428 ASTReader::RecordLocation
2429 ASTReader::DeclCursorForID(
DeclID ID,
unsigned &RawLocation) {
2431 DeclReplacementMap::iterator It = ReplacedDecls.find(ID);
2432 if (It != ReplacedDecls.end()) {
2433 RawLocation = It->second.RawLoc;
2434 return RecordLocation(It->second.Mod, It->second.Offset);
2437 GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID);
2438 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
2442 RawLocation = DOffs.
Loc;
2443 return RecordLocation(M, DOffs.
BitOffset);
2446 ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
2448 = GlobalBitOffsetsMap.find(GlobalOffset);
2450 assert(I != GlobalBitOffsetsMap.
end() &&
"Corrupted global bit offsets map");
2451 return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
2454 uint64_t ASTReader::getGlobalBitOffset(
ModuleFile &M, uint32_t LocalOffset) {
2476 TX->getASTContext().hasSameType(TX->getType(), TY->
getType());
2483 TY->getTemplateParameters());
2490 return NAS->getNamespace();
2498 if (!NSY || NSX->getCanonicalDecl() != NSY->getCanonicalDecl())
2540 for (
unsigned I = 0, N = X->
size(); I != N; ++I)
2564 TypedefY->getUnderlyingType());
2571 if (isa<ObjCInterfaceDecl>(X) || isa<ObjCProtocolDecl>(
X))
2574 if (isa<ClassTemplateSpecializationDecl>(X)) {
2581 if (
TagDecl *TagX = dyn_cast<TagDecl>(X)) {
2582 TagDecl *TagY = cast<TagDecl>(Y);
2583 return (TagX->getTagKind() == TagY->
getTagKind()) ||
2600 if (
VarDecl *VarX = dyn_cast<VarDecl>(X)) {
2601 VarDecl *VarY = cast<VarDecl>(Y);
2607 if (
NamespaceDecl *NamespaceX = dyn_cast<NamespaceDecl>(X)) {
2614 if (
TemplateDecl *TemplateX = dyn_cast<TemplateDecl>(X)) {
2623 if (
FieldDecl *FDX = dyn_cast<FieldDecl>(X)) {
2630 if (isa<EnumConstantDecl>(X))
2642 if (
auto *UX = dyn_cast<UsingDecl>(X)) {
2643 auto *UY = cast<UsingDecl>(Y);
2645 UX->hasTypename() == UY->hasTypename() &&
2646 UX->isAccessDeclaration() == UY->isAccessDeclaration();
2648 if (
auto *UX = dyn_cast<UnresolvedUsingValueDecl>(X)) {
2649 auto *UY = cast<UnresolvedUsingValueDecl>(Y);
2651 UX->isAccessDeclaration() == UY->isAccessDeclaration();
2653 if (
auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(X))
2656 cast<UnresolvedUsingTypenameDecl>(Y)->getQualifier());
2659 if (
auto *NAX = dyn_cast<NamespaceAliasDecl>(X)) {
2660 auto *NAY = cast<NamespaceAliasDecl>(Y);
2661 return NAX->getNamespace()->Equals(NAY->getNamespace());
2672 return ND->getOriginalNamespace();
2676 auto *DD = RD->DefinitionData.getNotUpdated();
2678 DD = RD->getCanonicalDecl()->DefinitionData.getNotUpdated();
2685 DD =
new (Reader.Context)
struct CXXRecordDecl::DefinitionData(RD);
2686 RD->IsCompleteDefinition =
true;
2687 RD->DefinitionData = DD;
2688 RD->getCanonicalDecl()->DefinitionData = DD;
2691 Reader.PendingFakeDefinitionData.insert(
2695 return DD->Definition;
2698 if (
EnumDecl *ED = dyn_cast<EnumDecl>(DC))
2699 return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition()
2704 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2710 ASTDeclReader::FindExistingResult::~FindExistingResult() {
2713 if (TypedefNameForLinkage) {
2715 Reader.ImportedTypedefNamesForLinkage.insert(
2716 std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New));
2720 if (!AddResult || Existing)
2726 setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
2727 AnonymousDeclNumber, New);
2733 }
else if (
DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
2736 MergeDC->makeDeclVisibleInContextImpl(New,
true);
2744 bool IsTypedefNameForLinkage) {
2745 if (!IsTypedefNameForLinkage)
2754 if (
auto *TND = dyn_cast<TypedefNameDecl>(Found))
2755 return TND->getAnonDeclWithTypedefName();
2765 if (
auto *Merged = Reader.MergedDeclContexts.lookup(DC))
2769 auto &
Previous = Reader.AnonymousDeclarationsForMerging[DC];
2775 if (!cast<Decl>(DC)->isFromASTFile()) {
2787 void ASTDeclReader::setAnonymousDeclForMerging(
ASTReader &Reader,
2790 if (
auto *Merged = Reader.MergedDeclContexts.lookup(DC))
2793 auto &
Previous = Reader.AnonymousDeclarationsForMerging[DC];
2800 ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(
NamedDecl *D) {
2807 FindExistingResult
Result(Reader, D,
nullptr,
2808 AnonymousDeclNumber, TypedefNameForLinkage);
2814 if (TypedefNameForLinkage) {
2815 auto It = Reader.ImportedTypedefNamesForLinkage.find(
2816 std::make_pair(DC, TypedefNameForLinkage));
2817 if (It != Reader.ImportedTypedefNamesForLinkage.end())
2819 return FindExistingResult(Reader, D, It->second, AnonymousDeclNumber,
2820 TypedefNameForLinkage);
2828 if (
auto *Existing = getAnonymousDeclForMerging(
2831 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
2832 TypedefNameForLinkage);
2839 class UpToDateIdentifierRAII {
2845 : II(II), WasOutToDate(
false)
2854 ~UpToDateIdentifierRAII() {
2861 IEnd = IdResolver.
end();
2865 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
2866 TypedefNameForLinkage);
2868 }
else if (
DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
2873 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
2874 TypedefNameForLinkage);
2878 return FindExistingResult(Reader);
2887 if (MergedDCIt != Reader.MergedDeclContexts.end() &&
2889 Reader.PendingOdrMergeChecks.push_back(D);
2891 return FindExistingResult(Reader, D,
nullptr,
2892 AnonymousDeclNumber, TypedefNameForLinkage);
2895 template<
typename DeclT>
2900 llvm_unreachable(
"getMostRecentDecl on non-redeclarable declaration");
2907 #define ABSTRACT_DECL(TYPE)
2908 #define DECL(TYPE, BASE) \
2910 return getMostRecentDeclImpl(cast<TYPE##Decl>(D));
2911 #include "clang/AST/DeclNodes.inc"
2913 llvm_unreachable(
"unknown decl kind");
2916 Decl *ASTReader::getMostRecentExistingDecl(
Decl *D) {
2920 template<
typename DeclT>
2924 D->
RedeclLink.setPrevious(cast<DeclT>(Previous));
2940 if (PrevFD->IsInline != FD->IsInline) {
2956 FD->IsInline =
true;
2963 if (FPT && PrevFPT) {
2965 bool WasUnresolved =
2967 if (IsUnresolved != WasUnresolved)
2968 Reader.PendingExceptionSpecUpdates.insert(
2969 std::make_pair(Canon, IsUnresolved ? PrevFD : FD));
2974 llvm_unreachable(
"attachPreviousDecl on non-redeclarable declaration");
2979 template <
typename ParmDecl>
2982 auto *To = cast<ParmDecl>(ToD);
2983 if (!From->hasDefaultArgument())
2985 To->setInheritedDefaultArgument(Context, From);
2994 assert(FromTP->size() == ToTP->size() &&
"merged mismatched templates?");
2996 for (
unsigned I = 0, N = FromTP->size(); I != N; ++I) {
2997 NamedDecl *FromParam = FromTP->getParam(N - I - 1);
2998 NamedDecl *ToParam = ToTP->getParam(N - I - 1);
3000 if (
auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam)) {
3003 }
else if (
auto *FNTTP = dyn_cast<NonTypeTemplateParmDecl>(FromParam)) {
3008 Context, cast<TemplateTemplateParmDecl>(FromParam), ToParam))
3016 assert(D && Previous);
3019 #define ABSTRACT_DECL(TYPE)
3020 #define DECL(TYPE, BASE) \
3022 attachPreviousDeclImpl(Reader, cast<TYPE##Decl>(D), Previous, Canon); \
3024 #include "clang/AST/DeclNodes.inc"
3048 template<
typename DeclT>
3050 D->
RedeclLink.setLatest(cast<DeclT>(Latest));
3053 llvm_unreachable(
"attachLatestDecl on non-redeclarable declaration");
3057 assert(D && Latest);
3060 #define ABSTRACT_DECL(TYPE)
3061 #define DECL(TYPE, BASE) \
3063 attachLatestDeclImpl(cast<TYPE##Decl>(D), Latest); \
3065 #include "clang/AST/DeclNodes.inc"
3069 template<
typename DeclT>
3074 llvm_unreachable(
"markIncompleteDeclChain on non-redeclarable declaration");
3077 void ASTReader::markIncompleteDeclChain(
Decl *D) {
3079 #define ABSTRACT_DECL(TYPE)
3080 #define DECL(TYPE, BASE) \
3082 ASTDeclReader::markIncompleteDeclChainImpl(cast<TYPE##Decl>(D)); \
3084 #include "clang/AST/DeclNodes.inc"
3091 unsigned RawLocation = 0;
3092 RecordLocation Loc = DeclCursorForID(ID, RawLocation);
3093 llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
3098 ReadingKindTracker ReadingKind(Read_Decl, *
this);
3101 Deserializing ADecl(
this);
3103 DeclsCursor.JumpToBit(Loc.Offset);
3105 unsigned Code = DeclsCursor.ReadCode();
3107 ASTDeclReader Reader(*
this, *Loc.F, ID, RawLocation, Record,Idx);
3110 switch ((
DeclCode)DeclsCursor.readRecord(Code, Record)) {
3113 llvm_unreachable(
"Record cannot be de-serialized with ReadDeclRecord");
3290 Error(
"attempt to read a C++ base-specifier record as a declaration");
3293 Error(
"attempt to read a C++ ctor initializer record as a declaration");
3311 assert(D &&
"Unknown declaration reading AST file");
3312 LoadedDecl(Index, D);
3326 if (isa<NamespaceDecl>(DC))
3328 std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC);
3329 if (Offsets.first || Offsets.second) {
3330 if (Offsets.first != 0)
3332 if (Offsets.second != 0)
3334 if (ReadDeclContextStorage(*Loc.F, DeclsCursor, Offsets,
3335 Loc.F->DeclContextInfos[DC]))
3340 DeclContextVisibleUpdatesPending::iterator I =
3341 PendingVisibleUpdates.
find(ID);
3342 if (I != PendingVisibleUpdates.end()) {
3346 for (
const auto &Update : I->second) {
3351 PendingVisibleUpdates.erase(I);
3354 assert(Idx == Record.size());
3357 PendingUpdateRecords.push_back(std::make_pair(ID, D));
3361 if (Class->isThisDeclarationADefinition())
3362 loadObjCCategories(ID, Class);
3369 InterestingDecls.push_back(D);
3378 DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
3379 if (UpdI != DeclUpdateOffsets.end()) {
3380 FileOffsetsTy &UpdateOffsets = UpdI->second;
3382 for (FileOffsetsTy::iterator
3383 I = UpdateOffsets.begin(), E = UpdateOffsets.end(); I != E; ++I) {
3385 uint64_t
Offset = I->second;
3388 Cursor.JumpToBit(Offset);
3390 unsigned Code = Cursor.ReadCode();
3391 unsigned RecCode = Cursor.readRecord(Code, Record);
3393 assert(RecCode ==
DECL_UPDATES &&
"Expected DECL_UPDATES record!");
3397 Reader.UpdateDecl(D, *F, Record);
3401 if (!WasInteresting &&
3403 InterestingDecls.push_back(D);
3404 WasInteresting =
true;
3413 class RedeclChainVisitor {
3416 llvm::SmallPtrSetImpl<Decl *> &Deserialized;
3422 llvm::SmallPtrSetImpl<Decl *> &Deserialized,
3424 : Reader(Reader), SearchDecls(SearchDecls), Deserialized(Deserialized),
3427 addToChain(Reader.
GetDecl(CanonID));
3431 visitPreorder(
ModuleFile &M,
void *UserData) {
3432 return static_cast<RedeclChainVisitor *
>(UserData)->visitPreorder(M);
3435 static bool visitPostorder(
ModuleFile &M,
void *UserData) {
3436 return static_cast<RedeclChainVisitor *
>(UserData)->visitPostorder(M);
3439 void addToChain(
Decl *D) {
3443 if (Deserialized.erase(D))
3458 addToChain(Reader.
GetDecl(GlobalID));
3472 unsigned Offset = Result->
Offset;
3475 for (
unsigned I = 0; I != N; ++I)
3492 unsigned Offset = Result->
Offset;
3500 for (
unsigned I = 0, N = SearchDecls.size(); I != N; ++I) {
3501 if (needsToVisitImports(M, SearchDecls[I]))
3509 for (
unsigned I = 0, N = SearchDecls.size(); I != N; ++I)
3510 searchForID(M, SearchDecls[I]);
3520 void ASTReader::loadPendingDeclChain(
Decl *CanonDecl) {
3531 KeyDeclsMap::iterator KeyPos = KeyDecls.find(CanonDecl);
3532 if (KeyPos != KeyDecls.end())
3533 SearchDecls.append(KeyPos->second.begin(), KeyPos->second.end());
3536 RedeclChainVisitor Visitor(*
this, SearchDecls, RedeclsDeserialized, CanonID);
3537 ModuleMgr.visitDepthFirst(&RedeclChainVisitor::visitPreorder,
3538 &RedeclChainVisitor::visitPostorder, &Visitor);
3542 if (Chain.empty() || (Chain.size() == 1 && Chain[0] == CanonDecl))
3551 MostRecent = CanonDecl;
3552 for (
unsigned I = 0, N = Chain.size(); I != N; ++I) {
3553 if (Chain[I] == CanonDecl)
3557 MostRecent = Chain[I];
3565 class ObjCCategoriesVisitor {
3569 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized;
3570 unsigned PreviousGeneration;
3572 llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap;
3576 if (!Deserialized.erase(Cat))
3597 << Interface->getDeclName() << Cat->
getDeclName();
3599 }
else if (!Existing) {
3609 Interface->setCategoryListRaw(Cat);
3614 ObjCCategoriesVisitor(
ASTReader &Reader,
3617 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
3618 unsigned PreviousGeneration)
3619 : Reader(Reader), InterfaceID(InterfaceID), Interface(Interface),
3620 Deserialized(Deserialized), PreviousGeneration(PreviousGeneration),
3633 static bool visit(
ModuleFile &M,
void *UserData) {
3634 return static_cast<ObjCCategoriesVisitor *
>(UserData)->visit(M);
3666 unsigned Offset = Result->
Offset;
3669 for (
unsigned I = 0; I != N; ++I)
3670 add(cast_or_null<ObjCCategoryDecl>(
3679 unsigned PreviousGeneration) {
3680 ObjCCategoriesVisitor Visitor(*
this, ID, D, CategoriesDeserialized,
3681 PreviousGeneration);
3682 ModuleMgr.visit(ObjCCategoriesVisitor::visit, &Visitor);
3685 template<
typename DeclT,
typename Fn>
3694 for (
auto *Redecl = MostRecent; Redecl && !Found;
3696 Found = (Redecl == D);
3700 for (
auto *Redecl = MostRecent; Redecl != D;
3708 while (Idx < Record.size()) {
3711 auto *RD = cast<CXXRecordDecl>(D);
3715 assert(MD &&
"couldn't read decl from update record");
3718 RD->addedMember(MD);
3723 auto *DD = RD->DefinitionData.getNotUpdated();
3724 if (DD && DD->Definition != RD) {
3725 auto &Merged = Reader.MergedLookups[DD->Definition];
3727 if (std::find(Merged.begin(), Merged.end(), RD) == Merged.end())
3728 Merged.push_back(RD);
3735 (void)Reader.
ReadDecl(ModuleFile, Record, Idx);
3750 cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
3756 cast<VarDecl>(D)->getMemberSpecializationInfo()->setPointOfInstantiation(
3762 if (Reader.PendingBodies[FD]) {
3768 if (Record[Idx++]) {
3777 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3778 CD->NumCtorInitializers = Record[Idx++];
3779 if (CD->NumCtorInitializers)
3780 CD->CtorInitializers =
3784 Reader.PendingBodies[FD] = GetCurrentCursorOffset();
3785 HasPendingBody =
true;
3786 assert(Idx == Record.size() &&
"lazy body must be last");
3791 auto *RD = cast<CXXRecordDecl>(D);
3792 auto *OldDD = RD->DefinitionData.getNotUpdated();
3793 bool HadRealDefinition =
3794 OldDD && (OldDD->Definition != RD ||
3795 !Reader.PendingFakeDefinitionData.count(OldDD));
3796 ReadCXXRecordDefinition(RD,
true);
3799 uint64_t LexicalOffset = Record[Idx++];
3800 if (!HadRealDefinition && LexicalOffset) {
3801 RD->setHasExternalLexicalStorage(
true);
3802 Reader.ReadDeclContextStorage(ModuleFile, ModuleFile.DeclsCursor,
3803 std::make_pair(LexicalOffset, 0),
3804 ModuleFile.DeclContextInfos[RD]);
3805 Reader.PendingFakeDefinitionData.erase(OldDD);
3811 RD->getMemberSpecializationInfo()) {
3812 MSInfo->setTemplateSpecializationKind(TSK);
3813 MSInfo->setPointOfInstantiation(POI);
3816 cast<ClassTemplateSpecializationDecl>(RD);
3820 if (Record[Idx++]) {
3822 ReadDeclAs<ClassTemplatePartialSpecializationDecl>(Record, Idx);
3826 Reader.
getContext(), TemplArgs.data(), TemplArgs.size());
3841 if (Record[Idx++]) {
3855 if (!First->OperatorDelete)
3856 First->OperatorDelete = Del;
3863 Reader.readExceptionSpec(ModuleFile, ExceptionStorage, ESI, Record, Idx);
3866 auto *FD = cast<FunctionDecl>(D);
3872 FPT->getReturnType(), FPT->getParamTypes(),
3873 FPT->getExtProtoInfo().withExceptionSpec(ESI)));
3877 Reader.PendingExceptionSpecUpdates.insert(
3878 std::make_pair(FD->getCanonicalDecl(), FD));
3912 D->
addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(
3913 Reader.Context, ReadSourceRange(Record, Idx)));
3917 unsigned SubmoduleID = readSubmoduleID(Record, Idx);
3918 auto *Exported = cast<NamedDecl>(D);
3919 if (
auto *TD = dyn_cast<TagDecl>(Exported))
3920 Exported = TD->getDefinition();
3926 cast<NamedDecl>(Exported), Owner,
3928 Reader.PendingMergedDefinitionsToDeduplicate.insert(
3929 cast<NamedDecl>(Exported));
3933 Reader.HiddenNamesMap[Owner].push_back(Exported);
3936 Exported->Hidden =
false;
3944 assert(Attrs.size() == 1);
RedeclarableResult VisitTypedefNameDecl(TypedefNameDecl *TD)
void VisitTypeDecl(TypeDecl *TD)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
void setCategoryNameLoc(SourceLocation Loc)
A FriendTemplateDecl record.
Defines the clang::ASTContext interface.
A NonTypeTemplateParmDecl record.
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.
bool hasPendingBody() const
Determine whether this declaration has a pending body.
void VisitClassScopeFunctionSpecializationDecl(ClassScopeFunctionSpecializationDecl *D)
void setImplicit(bool I=true)
bool isTemplateParameter() const
void setNothrow(bool Nothrow=true)
void VisitVarDecl(VarDecl *VD)
#define MATCH_FIELD(Field)
void setAnonymousStructOrUnion(bool Anon)
static ImportDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
void VisitImportDecl(ImportDecl *D)
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
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. This happens, for instance, when merging the fields of identical class definitions from two different modules.
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
FunctionDecl * Function
The function template specialization that this structure describes.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
void 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)
An OMPThreadPrivateDecl record.
void VisitObjCIvarDecl(ObjCIvarDecl *D)
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
bool isParameterPack() const
Returns whether this is a parameter pack.
static void setNextObjCCategory(ObjCCategoryDecl *Cat, ObjCCategoryDecl *Next)
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const
Read a source location from raw form.
bool IsICE
Whether this statement is an integral constant expression, or in C++11, whether the statement is a co...
const serialization::LocalRedeclarationsInfo * RedeclarationsMap
Array of redeclaration chain location information within this module file, sorted by the first declar...
RedeclarableResult VisitClassTemplateSpecializationDeclImpl(ClassTemplateSpecializationDecl *D)
void setEmbeddedInDeclarator(bool isInDeclarator)
No linkage, which means that the entity is unique and can only be referred to from within its scope...
unsigned Generation
The generation of which this module file is a part.
static AccessSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setParam(unsigned i, ImplicitParamDecl *P)
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
void VisitEnumConstantDecl(EnumConstantDecl *ECD)
static void attachLatestDeclImpl(Redeclarable< DeclT > *D, Decl *Latest)
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
void setInheritedConstructor(const CXXConstructorDecl *BaseCtor)
Set the constructor that this inheriting constructor is based on.
static NamedDecl * getDeclForMerging(NamedDecl *Found, bool IsTypedefNameForLinkage)
A VarTemplatePartialSpecializationDecl record.
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.
void setModulePrivate(bool MP=true)
Specify whether this declaration was marked as being private to the module in which it was defined...
static Decl * getMostRecentDecl(Decl *D)
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
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)
IdentifierInfo * getAsIdentifierInfo() const
Represents an empty-declaration.
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Declaration of a variable template.
NamespaceDecl - Represent a C++ namespace.
A ObjCPropertyDecl record.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
void setPropertyImplementation(PropertyControl pc)
NamedDecl * getParam(unsigned Idx)
static FriendDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned FriendTypeNumTPLists)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
void setPropertyAccessor(bool isAccessor)
static void inheritDefaultTemplateArguments(ASTContext &Context, TemplateDecl *From, TemplateDecl *To)
Describes the capture of a variable or of this, or of a C++1y init-capture.
Represents a C++ constructor within a class.
llvm::OnDiskIterableChainedHashTable< reader::ASTDeclContextNameLookupTrait > * NameLookupTableData
static CapturedDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumParams)
A ClassTemplateDecl record.
void VisitStaticAssertDecl(StaticAssertDecl *D)
An UnresolvedUsingTypenameDecl record.
An identifier, stored as an IdentifierInfo*.
void setRAngleLoc(SourceLocation Loc)
void VisitNamedDecl(NamedDecl *ND)
Declaration of a redeclarable template.
void setUninstantiatedDefaultArg(Expr *arg)
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...
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
A namespace, stored as a NamespaceDecl*.
void VisitClassTemplateDecl(ClassTemplateDecl *D)
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
Stores a list of template parameters for a TemplateDecl and its derived classes.
void setSelfDecl(ImplicitParamDecl *SD)
void VisitTypeAliasDecl(TypeAliasDecl *TD)
A TemplateTemplateParmDecl record.
ParmVarDecl - Represents a parameter to a function.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
A ObjCInterfaceDecl record.
T * ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
void setHasExternalVisibleStorage(bool ES=true)
State whether this DeclContext has external storage for declarations visible in this context...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
RedeclarableResult VisitTagDecl(TagDecl *TD)
EvaluatedStmt * ensureEvaluatedStmt() const
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
static void attachPreviousDeclImpl(ASTReader &Reader, Redeclarable< DeclT > *D, Decl *Previous, Decl *Canon)
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...
void setIntegerType(QualType T)
Set the underlying integer type.
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 setCompleteDefinition(bool V)
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. This is either a single result (with no stable stora...
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.
Common * getCommonPtr() const
LambdaCaptureKind
The different capture forms in a lambda introducer.
void setBlockMissingReturnType(bool val)
void setLocStart(SourceLocation L)
static CXXRecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
RedeclarableResult VisitVarTemplateSpecializationDeclImpl(VarTemplateSpecializationDecl *D)
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
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.
bool isTranslationUnit() const
void setCaptures(ASTContext &Context, const Capture *begin, const Capture *end, bool capturesCXXThis)
TagKind getTagKind() const
static NamespaceDecl * getNamespace(const NestedNameSpecifier *X)
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
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)
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
void setNumPositiveBits(unsigned Num)
Represents an access specifier followed by colon ':'.
void setReturnType(QualType T)
Declaration of a function specialization at template class scope.
static StaticAssertDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitLabelDecl(LabelDecl *LD)
static NamespaceDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setDeclImplementation(ImplementationControl ic)
Describes a module or submodule.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
StorageClass getStorageClass() const
Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
A IndirectFieldDecl record.
iterator end()
end - Returns an iterator that has 'finished'.
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.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
static TemplateArgumentList * CreateCopy(ASTContext &Context, const TemplateArgument *Args, unsigned NumArgs)
Create a new template argument list that copies the given set of template arguments.
Stop the visitation immediately.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
void setAccessControl(AccessControl ac)
const LangOptions & getLangOpts() const
static void attachLatestDecl(Decl *D, Decl *latest)
Capturing by copy (a.k.a., by value)
bool isInline() const
Returns true if this is an inline namespace declaration.
RedeclarableResult VisitVarDeclImpl(VarDecl *D)
DeclLink RedeclLink
Points to the next redeclaration in the chain.
An AccessSpecDecl record.
void setAtLoc(SourceLocation L)
void setDepth(unsigned D)
uint32_t * LazySpecializations
If non-null, points to an array of specializations (including partial specializations) known ownly by...
A UsingDirecitveDecl record.
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
void VisitCXXRecordDecl(CXXRecordDecl *D)
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setSuperClass(ObjCInterfaceDecl *superCls)
void setHasObjectMember(bool val)
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
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.
unsigned LocalNumRedeclarationsInMap
The number of redeclaration info entries in RedeclarationsMap.
DeclID VisitTemplateDecl(TemplateDecl *D)
void setClassInterface(ObjCInterfaceDecl *D)
void setIdentifier(IdentifierInfo *II)
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
llvm::iterator_range< MergedRedeclIterator< DeclT > > merged_redecls(DeclT *D)
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitCXXMethodDecl(CXXMethodDecl *D)
static TypeAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
A ClassTemplateSpecializationDecl record.
Represents an Objective-C protocol declaration.
DeclContext * getLexicalDeclContext()
void setNumNegativeBits(unsigned Num)
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
static bool isSameEntity(NamedDecl *X, NamedDecl *Y)
Determine whether the two declarations refer to the same entity.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI)
This 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 setInitVal(const llvm::APSInt &V)
known_categories_range known_categories() const
QualType getCanonicalTypeInternal() const
void setInitExpr(Expr *E)
void setLocStart(SourceLocation L)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
void setGetterCXXConstructor(Expr *getterCXXConstructor)
void setInline(bool Inline)
Set whether this is an inline namespace declaration.
bool isTemplateParameterPack() const
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
void setVariadic(bool isVar)
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
RedeclarableResult VisitRedeclarable(Redeclarable< T > *D)
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
void setHasDestructors(bool val)
void VisitObjCContainerDecl(ObjCContainerDecl *D)
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
Represents a ValueDecl that came out of a declarator. Contains type source information through TypeSo...
void VisitParmVarDecl(ParmVarDecl *PD)
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
Decl * ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
void setIvarRBraceLoc(SourceLocation Loc)
A StaticAssertDecl record.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
ID
Defines the set of possible language-specific address spaces.
A VarTemplateSpecializationDecl record.
void VisitUsingShadowDecl(UsingShadowDecl *D)
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
void setNextIvar(ObjCIvarDecl *ivar)
void setSynthesize(bool synth)
void VisitFriendDecl(FriendDecl *D)
An ObjCTypeParamDecl record.
A record containing CXXBaseSpecifiers.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
void setType(QualType T, TypeSourceInfo *TSI)
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
A ObjCCategoryImplDecl record.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
static LinkageSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
DiagnosticBuilder Diag(unsigned DiagID)
Report a diagnostic.
A ObjCPropertyImplDecl record.
QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a type from the current position in the given record, which was read from the given AST file...
Declaration of a template type parameter.
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
Represents a C++ destructor within a class.
void setInvalidDecl(bool Invalid=true)
TranslationUnitDecl * getTranslationUnitDecl() const
A CXXConstructorDecl record.
void VisitTypedefDecl(TypedefDecl *TD)
void setContextParam(unsigned i, ImplicitParamDecl *P)
void setAtEndRange(SourceRange atEnd)
void setRBraceLoc(SourceLocation L)
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
static DeclLink PreviousDeclLink(decl_type *D)
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
DeclContext * getDeclContext()
A record containing CXXCtorInitializers.
A VarTemplateDecl record.
void setGetterName(Selector Sel)
void setMemberSpecialization()
Note that this member template is a specialization.
void setDefined(bool isDefined)
void setCompleteDefinitionRequired(bool V=true)
RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D)
Information about a module that has been loaded by the ASTReader.
DFSPreorderControl
Control DFS behavior during preorder visitation.
A namespace alias, stored as a NamespaceAliasDecl*.
static void attachPreviousDecl(ASTReader &Reader, Decl *D, Decl *Previous, Decl *Canon)
A CXXDestructorDecl record.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
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...
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
StorageClass
Storage classes.
bool isFunctionOrMethod() const
A NamespaceAliasDecl record.
void setTypename(bool TN)
Sets whether the using declaration has 'typename'.
Declaration of an alias template.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
void UpdateDecl(Decl *D, ModuleFile &ModuleFile, const RecordData &Record)
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
void setLocation(SourceLocation L)
DeclarationName getDeclName() const
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
An ImplicitParamDecl record.
void setIvarRBraceLoc(SourceLocation Loc)
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has. This is not the linkage as defined by the standard or...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Represents a C++ conversion function within a class.
The result type of a method or function.
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, unsigned ID)
An EnumConstantDecl record.
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, unsigned ID)
A type, stored as a Type*.
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
An ImportDecl recording a module import.
A ObjCCategoryDecl record.
void setDeclContext(DeclContext *DC)
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
void VisitObjCProtocolDecl(ObjCProtocolDecl *D)
A FileScopeAsmDecl record.
A ObjCCompatibleAliasDecl record.
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)
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
void setColonLoc(SourceLocation CLoc)
Sets the location of the colon.
An UnresolvedUsingValueDecl record.
Representation::iterator iterator
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)
void setIsConversionFromLambda(bool val)
static void markIncompleteDeclChainImpl(Redeclarable< DeclT > *D)
static CXXDestructorDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
static EmptyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setTopLevelDeclInObjCContainer(bool V=true)
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
A record that stores the set of declarations that are visible from a given DeclContext.
void setIvarLBraceLoc(SourceLocation Loc)
void setAtStartLoc(SourceLocation Loc)
void VisitEmptyDecl(EmptyDecl *D)
void setAnonymousNamespace(NamespaceDecl *D)
NameVisibilityKind NameVisibility
The visibility of names within this particular module.
void setFreeStanding(bool isFreeStanding=true)
void setObjCDeclQualifier(ObjCDeclQualifier QV)
TagDecl - Represents the declaration of a struct/union/class/enum.
ASTContext & getASTContext() const LLVM_READONLY
File is an implicitly-loaded module.
void setReferenced(bool R=true)
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 VisitObjCImplDecl(ObjCImplDecl *D)
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
Represents a static or instance method of a struct/union/class.
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 setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
A TemplateTypeParmDecl record.
Data that is common to all of the declarations of a given function template.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
void addDecl(NamedDecl *D)
void setDeclName(DeclarationName N)
Set the name of this declaration.
void setCachedLinkage(Linkage L) const
static MSPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ASTDeclReader(ASTReader &Reader, ModuleFile &F, DeclID thisDeclID, unsigned RawLocation, const RecordData &Record, unsigned &Idx)
Information about the contents of a DeclContext.
Describes the categories of an Objective-C class.
void init(NamedDecl *templatedDecl, TemplateParameterList *templateParams)
Initialize the underlying templated declaration and template parameters.
void setPointOfInstantiation(SourceLocation Loc)
void setTagKind(TagKind TK)
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)
A simple visitor class that helps create declaration visitors.
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
void VisitRecordDecl(RecordDecl *RD)
lookup_result lookup(DeclarationName Name) const
static T assert_cast(T t)
"Cast" to type T, asserting if we don't have an implicit conversion. We use this to put code in a t...
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
Represents a C++11 static_assert declaration.
uint32_t BitOffset
Offset in the AST file.
void setLAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
unsigned varlist_size() const
Describes a module import declaration, which makes the contents of the named module visible in the cu...
void VisitValueDecl(ValueDecl *VD)
A ObjCProtocolDecl record.
void setDeclaredWithTypename(bool withTypename)
Set whether this template type parameter was declared with the 'typename' or 'class' keyword...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
void setSetterCXXAssignment(Expr *setterCXXAssignment)
void VisitEnumDecl(EnumDecl *ED)
static TypedefDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Base class for declarations which introduce a typedef-name.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
void setPropertyDecl(ObjCPropertyDecl *Prop)
A CXXConversionDecl record.
TagTypeKind
The kind of a tag type.
ObjCTypeParamList * ReadObjCTypeParamList()
void VisitCXXConversionDecl(CXXConversionDecl *D)
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
void setBody(CompoundStmt *B)
void setImplicitlyInline()
Flag that this function is implicitly inline.
static CXXConversionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
llvm::BitstreamCursor DeclsCursor
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)
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)
SmallVector< uint64_t, 1 > RedeclarationChains
The redeclaration chains for declarations local to this module file.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Reads an AST files chain containing the contents of a translation unit.
File is an explicitly-loaded module.
A ClassTemplatePartialSpecializationDecl record.
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
DeclCode
Record codes for each kind of declaration.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
RedeclarableResult VisitCXXRecordDeclImpl(CXXRecordDecl *D)
void setIvarList(ObjCIvarDecl *ivar)
uint64_t ReadCXXCtorInitializersRef(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializers ID from the given record and return its global bit offset.
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. (Microsoft extension).
Record of updates for a declaration that was modified after being deserialized.
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)
for(auto typeArg:T->getTypeArgsAsWritten())
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
IdentifierResolver IdResolver
static void forAllLaterRedecls(DeclT *D, Fn F)
void setExternLoc(SourceLocation L)
static bool inheritDefaultTemplateArgument(ASTContext &Context, ParmDecl *From, Decl *ToD)
A type that was preceded by the 'template' keyword, stored as a Type*.
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
uint32_t * LazySpecializations
If non-null, points to an array of specializations (including partial specializations) known only by ...
static LabelDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setHasExternalLexicalStorage(bool ES=true)
State whether this DeclContext has external storage for declarations lexically in this context...
All of the names in this module are visible.
bool IsScopedUsingClassTag
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
Capturing variable-length array type.
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Common * getCommonPtr() const
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
NonParmVarDeclBitfields NonParmVarDeclBits
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
void setHasNonZeroConstructors(bool val)
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
LanguageIDs
Represents the language in a linkage specification.
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static RecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
static CXXMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
static EnumDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setSetterName(Selector Sel)
DeclContext * getRedeclContext()
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.
Capturing the this pointer.
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
void setInnerLocStart(SourceLocation L)
void setObjCMethodScopeInfo(unsigned parameterIndex)
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...
static bool isConsumerInterestedIn(Decl *D, bool HasBody)
Determine whether the consumer will be interested in seeing this declaration (via HandleTopLevelDecl)...
unsigned Hidden
Whether this declaration is hidden from normal name lookup, e.g., because it is was loaded from an AS...
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(...).
static Decl * getMostRecentDeclImpl(Redeclarable< DeclT > *D)
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Represents a C++ struct/union/class.
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setDescribedVarTemplate(VarTemplateDecl *Template)
void setInstanceMethod(bool isInst)
void SetRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template argument array.
void setClassInterface(ObjCInterfaceDecl *IFace)
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
bool operator!=(CanQual< T > x, CanQual< U > y)
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Provides information a specialization of a member of a class template, which may be a member function...
A ObjCImplementationDecl record.
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source...
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
void setReturnTypeSourceInfo(TypeSourceInfo *TInfo)
A ObjCAtDefsFieldDecl record.
Declaration of a class template.
void setIvarLBraceLoc(SourceLocation Loc)
void VisitAccessSpecDecl(AccessSpecDecl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
void setPropertyAttributes(PropertyAttributeKind PRVal)
static BlockDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void VisitClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl *D)
uint32_t * LazySpecializations
If non-null, points to an array of specializations known only by their external declaration IDs...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
static DeclID * newDeclIDList(ASTContext &Context, DeclID *Old, SmallVectorImpl< DeclID > &IDs)
Describes the redeclarations of a declaration.
void VisitBlockDecl(BlockDecl *BD)
Kind
Lists the kind of concrete classes of Decl.
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
void ReadAttributes(ModuleFile &F, AttrVec &Attrs, const RecordData &Record, unsigned &Idx)
Reads attributes from the current stream position.
void VisitIndirectFieldDecl(IndirectFieldDecl *FD)
static Decl::Kind getKind(const Decl *D)
Common * getCommonPtr() const
VarDeclBitfields VarDeclBits
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
virtual CommonBase * newCommon(ASTContext &C) const =0
TranslationUnitDecl - The top declaration context.
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
DeclContext * getPrimaryContext()
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 setAtLoc(SourceLocation Loc)
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
uint32_t TypeID
An ID number that refers to a type in an AST file.
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where in the...
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
void VisitVarTemplateDecl(VarTemplateDecl *D)
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.
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.
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)
void setType(QualType newType)
void setCmdDecl(ImplicitParamDecl *CD)
This represents '#pragma omp threadprivate ...' directive. For example, in the following, both 'a' and 'A::b' are threadprivate:
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
Declaration of a template function.
void setTargetDecl(NamedDecl *ND)
Sets the underlying declaration which has been brought into the local scope.
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
Source range/offset of a preprocessed entity.
unsigned Loc
Raw source location.
Attr - This represents one attribute.
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.
void setRBraceLoc(SourceLocation L)
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
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.