28 #include "llvm/Support/SaveAndRestore.h"
30 using namespace clang;
31 using namespace clang::serialization;
42 const unsigned RawLocation;
47 unsigned AnonymousDeclNumber;
53 uint64_t GetCurrentCursorOffset();
56 return Reader.ReadSourceLocation(F, R, I);
60 return Reader.ReadSourceRange(F, R, I);
64 return Reader.GetTypeSourceInfo(F, R, I);
68 return Reader.ReadDeclID(F, R, I);
72 for (
unsigned I = 0, Size = Record[Idx++]; I != Size; ++
I)
73 IDs.push_back(ReadDeclID(Record, Idx));
77 return Reader.ReadDecl(F, R, I);
81 T *ReadDeclAs(
const RecordData &R,
unsigned &I) {
82 return Reader.ReadDeclAs<T>(F, R,
I);
87 Reader.ReadQualifierInfo(F, Info, R, I);
92 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
97 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
105 return Reader.getGlobalSubmoduleID(F, R[I++]);
109 return Reader.getSubmodule(readSubmoduleID(R, I));
113 void ReadCXXDefinitionData(
struct CXXRecordDecl::DefinitionData &Data,
116 struct CXXRecordDecl::DefinitionData &&NewDD);
125 class RedeclarableResult {
132 : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl) {}
138 bool isKeyDecl()
const {
return IsKeyDecl; }
142 Decl *getKnownMergeTarget()
const {
return MergeWith; }
150 class FindExistingResult {
154 mutable bool AddResult;
156 unsigned AnonymousDeclNumber;
159 void operator=(FindExistingResult&) =
delete;
163 : Reader(Reader), New(
nullptr), Existing(
nullptr), AddResult(
false),
164 AnonymousDeclNumber(0), TypedefNameForLinkage(
nullptr) {}
167 unsigned AnonymousDeclNumber,
169 : Reader(Reader), New(New), Existing(Existing), AddResult(
true),
170 AnonymousDeclNumber(AnonymousDeclNumber),
171 TypedefNameForLinkage(TypedefNameForLinkage) {}
173 FindExistingResult(
const FindExistingResult &Other)
174 : Reader(Other.Reader), New(Other.New), Existing(Other.Existing),
175 AddResult(Other.AddResult),
176 AnonymousDeclNumber(Other.AnonymousDeclNumber),
177 TypedefNameForLinkage(Other.TypedefNameForLinkage) {
178 Other.AddResult =
false;
181 ~FindExistingResult();
185 void suppress() { AddResult =
false; }
187 operator NamedDecl*()
const {
return Existing; }
190 operator T*()
const {
return dyn_cast_or_null<T>(Existing); }
195 FindExistingResult findExisting(
NamedDecl *D);
199 unsigned RawLocation,
const RecordData &Record,
unsigned &Idx)
200 : Reader(Reader), F(F), ThisDeclID(thisDeclID),
201 RawLocation(RawLocation), Record(Record), Idx(Idx),
202 TypeIDForTypeDecl(0), NamedDeclForTagDecl(0),
203 TypedefNameForLinkage(nullptr), HasPendingBody(
false) {}
205 template <
typename DeclT>
207 static Decl *getMostRecentDeclImpl(...);
208 static Decl *getMostRecentDecl(
Decl *D);
210 template <
typename DeclT>
211 static void attachPreviousDeclImpl(
ASTReader &Reader,
214 static void attachPreviousDeclImpl(
ASTReader &Reader, ...);
218 template <
typename DeclT>
220 static void attachLatestDeclImpl(...);
221 static void attachLatestDecl(
Decl *D,
Decl *latest);
223 template <
typename DeclT>
225 static void markIncompleteDeclChainImpl(...);
232 void UpdateDecl(
Decl *D, ModuleFile &ModuleFile,
233 const RecordData &Record);
237 Cat->NextClassCategory =
Next;
240 void VisitDecl(
Decl *D);
252 RedeclarableResult VisitTagDecl(
TagDecl *TD);
254 RedeclarableResult VisitRecordDeclImpl(
RecordDecl *RD);
258 RedeclarableResult VisitClassTemplateSpecializationDeclImpl(
262 VisitClassTemplateSpecializationDeclImpl(D);
264 void VisitClassTemplatePartialSpecializationDecl(
266 void VisitClassScopeFunctionSpecializationDecl(
271 VisitVarTemplateSpecializationDeclImpl(D);
273 void VisitVarTemplatePartialSpecializationDecl(
288 RedeclarableResult VisitVarDeclImpl(
VarDecl *D);
314 std::pair<uint64_t, uint64_t> VisitDeclContext(
DeclContext *DC);
321 DeclID TemplatePatternID = 0);
325 RedeclarableResult &Redecl,
326 DeclID TemplatePatternID = 0);
333 DeclID DsID,
bool IsKeyDecl);
366 Reader.PendingMergedDefinitionsToDeduplicate.insert(Def);
369 assert(
SubmoduleID &&
"hidden definition in no module");
380 template<
typename DeclT>
381 class MergedRedeclIterator {
382 DeclT *Start, *Canonical, *
Current;
384 MergedRedeclIterator() :
Current(nullptr) {}
385 MergedRedeclIterator(DeclT *Start)
386 : Start(Start), Canonical(nullptr),
Current(Start) {}
390 MergedRedeclIterator &operator++() {
406 friend bool operator!=(
const MergedRedeclIterator &A,
407 const MergedRedeclIterator &B) {
408 return A.Current != B.Current;
413 template<
typename DeclT>
415 return llvm::make_range(MergedRedeclIterator<DeclT>(D),
416 MergedRedeclIterator<DeclT>());
419 uint64_t ASTDeclReader::GetCurrentCursorOffset() {
420 return F.DeclsCursor.GetCurrentBitNo() + F.GlobalBitOffset;
431 GetTypeSourceInfo(Record, Idx);
434 DD->DeclInfo = GetTypeSourceInfo(Record, Idx);
438 if (
TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
440 TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull());
444 if (NamedDeclForTagDecl)
445 cast<TagDecl>(D)->TypedefNameDeclOrQualifier =
446 cast<TypedefNameDecl>(Reader.GetDecl(NamedDeclForTagDecl));
449 ID->TypeForDecl = Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull();
450 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
456 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
457 CD->NumCtorInitializers = Record[Idx++];
458 if (CD->NumCtorInitializers)
459 CD->CtorInitializers =
460 Reader.ReadCXXCtorInitializersRef(F, Record, Idx);
462 Reader.PendingBodies[FD] = GetCurrentCursorOffset();
463 HasPendingBody =
true;
470 isa<ParmVarDecl>(D)) {
477 GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID(Record, Idx);
478 GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID(Record, Idx);
479 if (!LexicalDCIDForTemplateParmDecl)
480 LexicalDCIDForTemplateParmDecl = SemaDCIDForTemplateParmDecl;
481 Reader.addPendingDeclContextInfo(D,
482 SemaDCIDForTemplateParmDecl,
483 LexicalDCIDForTemplateParmDecl);
486 DeclContext *SemaDC = ReadDeclAs<DeclContext>(Record, Idx);
487 DeclContext *LexicalDC = ReadDeclAs<DeclContext>(Record, Idx);
493 D->setDeclContextsImpl(MergedSemaDC ? MergedSemaDC : SemaDC, LexicalDC,
494 Reader.getContext());
496 D->
setLocation(Reader.ReadSourceLocation(F, RawLocation));
500 Reader.ReadAttributes(F, Attrs, Record, Idx);
503 D->setAttrsImpl(Attrs, Reader.getContext());
506 D->Used = Record[Idx++];
516 if (
unsigned SubmoduleID = readSubmoduleID(Record, Idx)) {
522 }
else if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
534 Reader.HiddenNamesMap[Owner].push_back(D);
541 llvm_unreachable(
"Translation units are not serialized");
546 ND->
setDeclName(Reader.ReadDeclarationName(F, Record, Idx));
547 AnonymousDeclNumber = Record[Idx++];
554 TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]);
557 ASTDeclReader::RedeclarableResult
559 RedeclarableResult Redecl = VisitRedeclarable(TD);
563 QualType modedT = Reader.readType(F, Record, Idx);
571 RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
572 mergeRedeclarable(TD, Redecl);
576 RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
577 if (
auto *Template = ReadDeclAs<TypeAliasTemplateDecl>(Record, Idx))
581 mergeRedeclarable(TD, Redecl);
585 RedeclarableResult Redecl = VisitRedeclarable(TD);
590 if (!isa<CXXRecordDecl>(TD))
597 switch (Record[Idx++]) {
602 ReadQualifierInfo(*Info, Record, Idx);
603 TD->TypedefNameDeclOrQualifier = Info;
607 NamedDeclForTagDecl = ReadDeclID(Record, Idx);
608 TypedefNameForLinkage = Reader.GetIdentifierInfo(F, Record, Idx);
611 llvm_unreachable(
"unexpected tag info kind");
614 if (!isa<CXXRecordDecl>(TD))
615 mergeRedeclarable(TD, Redecl);
621 if (
TypeSourceInfo *TI = Reader.GetTypeSourceInfo(F, Record, Idx))
634 if (ED->IsCompleteDefinition &&
635 Reader.getContext().getLangOpts().Modules &&
636 Reader.getContext().getLangOpts().CPlusPlus) {
642 if (!D->isFromASTFile() && D->isCompleteDefinition()) {
649 Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
650 ED->IsCompleteDefinition =
false;
651 mergeDefinitionVisibility(OldDef, ED);
657 if (
EnumDecl *InstED = ReadDeclAs<EnumDecl>(Record, Idx)) {
660 ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK);
665 ASTDeclReader::RedeclarableResult
667 RedeclarableResult Redecl = VisitTagDecl(RD);
677 VD->
setType(Reader.readType(F, Record, Idx));
684 ECD->
setInitVal(Reader.ReadAPSInt(Record, Idx));
694 ReadQualifierInfo(*Info, Record, Idx);
700 RedeclarableResult Redecl = VisitRedeclarable(FD);
701 VisitDeclaratorDecl(FD);
703 ReadDeclarationNameLoc(FD->DNLoc, FD->
getDeclName(), Record, Idx);
710 FD->IsInline = Record[Idx++];
711 FD->IsInlineSpecified = Record[Idx++];
712 FD->IsVirtualAsWritten = Record[Idx++];
713 FD->IsPure = Record[Idx++];
714 FD->HasInheritedPrototype = Record[Idx++];
715 FD->HasWrittenPrototype = Record[Idx++];
716 FD->IsDeleted = Record[Idx++];
717 FD->IsTrivial = Record[Idx++];
718 FD->IsDefaulted = Record[Idx++];
719 FD->IsExplicitlyDefaulted = Record[Idx++];
720 FD->HasImplicitReturnZero = Record[Idx++];
721 FD->IsConstexpr = Record[Idx++];
722 FD->HasSkippedBody = Record[Idx++];
723 FD->IsLateTemplateParsed = Record[Idx++];
725 FD->EndRangeLoc = ReadSourceLocation(Record, Idx);
729 mergeRedeclarable(FD, Redecl);
737 FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>(Record, Idx);
740 FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
742 mergeRedeclarable(FD, Redecl);
752 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
758 bool HasTemplateArgumentsAsWritten = Record[Idx++];
759 if (HasTemplateArgumentsAsWritten) {
760 unsigned NumTemplateArgLocs = Record[Idx++];
761 TemplArgLocs.reserve(NumTemplateArgLocs);
762 for (
unsigned i=0; i != NumTemplateArgLocs; ++i)
763 TemplArgLocs.push_back(
764 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
766 LAngleLoc = ReadSourceLocation(Record, Idx);
767 RAngleLoc = ReadSourceLocation(Record, Idx);
776 for (
unsigned i=0, e = TemplArgLocs.size(); i != e; ++i)
777 TemplArgsInfo.addArgument(TemplArgLocs[i]);
781 HasTemplateArgumentsAsWritten ? &TemplArgsInfo
784 FD->TemplateOrSpecialization = FTInfo;
790 = ReadDeclAs<FunctionTemplateDecl>(Record, Idx);
796 llvm::FoldingSetNodeID
ID;
798 void *InsertPos =
nullptr;
805 assert(Reader.getContext().getLangOpts().Modules &&
806 "already deserialized this template specialization");
807 mergeRedeclarable(FD, ExistingInfo->
Function, Redecl);
815 unsigned NumTemplates = Record[Idx++];
816 while (NumTemplates--)
817 TemplDecls.
addDecl(ReadDeclAs<NamedDecl>(Record, Idx));
821 unsigned NumArgs = Record[Idx++];
823 TemplArgs.
addArgument(Reader.ReadTemplateArgumentLoc(F, Record, Idx));
824 TemplArgs.
setLAngleLoc(ReadSourceLocation(Record, Idx));
825 TemplArgs.
setRAngleLoc(ReadSourceLocation(Record, Idx));
828 TemplDecls, TemplArgs);
836 unsigned NumParams = Record[Idx++];
838 Params.reserve(NumParams);
839 for (
unsigned I = 0;
I != NumParams; ++
I)
840 Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
841 FD->setParams(Reader.getContext(), Params);
849 Reader.PendingBodies[MD] = GetCurrentCursorOffset();
850 HasPendingBody =
true;
851 MD->
setSelfDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
852 MD->
setCmdDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
858 MD->IsOverriding = Record[Idx++];
859 MD->HasSkippedBody = Record[Idx++];
861 MD->IsRedeclaration = Record[Idx++];
862 MD->HasRedeclaration = Record[Idx++];
863 if (MD->HasRedeclaration)
864 Reader.getContext().setObjCMethodRedeclaration(MD,
865 ReadDeclAs<ObjCMethodDecl>(Record, Idx));
872 MD->DeclEndLoc = ReadSourceLocation(Record, Idx);
873 unsigned NumParams = Record[Idx++];
875 Params.reserve(NumParams);
876 for (
unsigned I = 0;
I != NumParams; ++
I)
877 Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
879 MD->SelLocsKind = Record[Idx++];
880 unsigned NumStoredSelLocs = Record[Idx++];
882 SelLocs.reserve(NumStoredSelLocs);
883 for (
unsigned i = 0; i != NumStoredSelLocs; ++i)
884 SelLocs.push_back(ReadSourceLocation(Record, Idx));
886 MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs);
890 VisitTypedefNameDecl(D);
892 D->Variance = Record[Idx++];
893 D->Index = Record[Idx++];
894 D->VarianceLoc = ReadSourceLocation(Record, Idx);
895 D->ColonLoc = ReadSourceLocation(Record, Idx);
905 unsigned numParams = Record[Idx++];
910 typeParams.reserve(numParams);
911 for (
unsigned i = 0; i != numParams; ++i) {
912 auto typeParam = ReadDeclAs<ObjCTypeParamDecl>(Record, Idx);
916 typeParams.push_back(typeParam);
923 typeParams, rAngleLoc);
927 RedeclarableResult Redecl = VisitRedeclarable(ID);
928 VisitObjCContainerDecl(ID);
929 TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]);
930 mergeRedeclarable(ID, Redecl);
932 ID->TypeParamList = ReadObjCTypeParamList();
935 ID->allocateDefinitionData();
941 ObjCInterfaceDecl::DefinitionData &Data = ID->data();
944 Data.SuperClassTInfo = GetTypeSourceInfo(Record, Idx);
946 Data.EndLoc = ReadSourceLocation(Record, Idx);
947 Data.HasDesignatedInitializers = Record[Idx++];
950 unsigned NumProtocols = Record[Idx++];
952 Protocols.reserve(NumProtocols);
953 for (
unsigned I = 0;
I != NumProtocols; ++
I)
954 Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
956 ProtoLocs.reserve(NumProtocols);
957 for (
unsigned I = 0;
I != NumProtocols; ++
I)
958 ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
960 Reader.getContext());
963 NumProtocols = Record[Idx++];
965 Protocols.reserve(NumProtocols);
966 for (
unsigned I = 0;
I != NumProtocols; ++
I)
967 Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
968 ID->data().AllReferencedProtocols.set(Protocols.data(), NumProtocols,
969 Reader.getContext());
975 Reader.PendingDefinitions.insert(ID);
978 Reader.ObjCClassesLoaded.push_back(ID);
989 bool synth = Record[Idx++];
994 RedeclarableResult Redecl = VisitRedeclarable(PD);
995 VisitObjCContainerDecl(PD);
996 mergeRedeclarable(PD, Redecl);
1000 PD->allocateDefinitionData();
1006 unsigned NumProtoRefs = Record[Idx++];
1008 ProtoRefs.reserve(NumProtoRefs);
1009 for (
unsigned I = 0;
I != NumProtoRefs; ++
I)
1010 ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
1012 ProtoLocs.reserve(NumProtoRefs);
1013 for (
unsigned I = 0;
I != NumProtoRefs; ++
I)
1014 ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
1016 Reader.getContext());
1019 Reader.PendingDefinitions.insert(PD);
1030 VisitObjCContainerDecl(CD);
1038 Reader.CategoriesDeserialized.insert(CD);
1040 CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>(Record, Idx);
1041 CD->TypeParamList = ReadObjCTypeParamList();
1042 unsigned NumProtoRefs = Record[Idx++];
1044 ProtoRefs.reserve(NumProtoRefs);
1045 for (
unsigned I = 0;
I != NumProtoRefs; ++
I)
1046 ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
1048 ProtoLocs.reserve(NumProtoRefs);
1049 for (
unsigned I = 0;
I != NumProtoRefs; ++
I)
1050 ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
1052 Reader.getContext());
1056 VisitNamedDecl(CAD);
1062 D->
setAtLoc(ReadSourceLocation(Record, Idx));
1064 QualType T = Reader.readType(F, Record, Idx);
1073 D->
setGetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector());
1074 D->
setSetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector());
1081 VisitObjCContainerDecl(D);
1086 VisitObjCImplDecl(D);
1088 D->CategoryNameLoc = ReadSourceLocation(Record, Idx);
1092 VisitObjCImplDecl(D);
1093 D->
setSuperClass(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
1094 D->SuperLoc = ReadSourceLocation(Record, Idx);
1099 D->NumIvarInitializers = Record[Idx++];
1100 if (D->NumIvarInitializers)
1101 D->IvarInitializers = Reader.ReadCXXCtorInitializersRef(F, Record, Idx);
1106 D->
setAtLoc(ReadSourceLocation(Record, Idx));
1108 D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>(Record, Idx);
1109 D->IvarLoc = ReadSourceLocation(Record, Idx);
1115 VisitDeclaratorDecl(FD);
1116 FD->Mutable = Record[Idx++];
1117 if (
int BitWidthOrInitializer = Record[Idx++]) {
1118 FD->InitStorage.setInt(
1119 static_cast<FieldDecl::InitStorageKind>(BitWidthOrInitializer - 1));
1120 if (FD->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
1122 FD->InitStorage.setPointer(
1123 Reader.readType(F, Record, Idx).getAsOpaquePtr());
1125 FD->InitStorage.setPointer(Reader.ReadExpr(F));
1129 if (
FieldDecl *Tmpl = ReadDeclAs<FieldDecl>(Record, Idx))
1130 Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
1136 VisitDeclaratorDecl(PD);
1137 PD->GetterId = Reader.GetIdentifierInfo(F, Record, Idx);
1138 PD->SetterId = Reader.GetIdentifierInfo(F, Record, Idx);
1144 FD->ChainingSize = Record[Idx++];
1145 assert(FD->ChainingSize >= 2 &&
"Anonymous chaining must be >= 2");
1146 FD->Chaining =
new (Reader.getContext())
NamedDecl*[FD->ChainingSize];
1148 for (
unsigned I = 0;
I != FD->ChainingSize; ++
I)
1149 FD->Chaining[
I] = ReadDeclAs<NamedDecl>(Record, Idx);
1155 RedeclarableResult Redecl = VisitRedeclarable(VD);
1156 VisitDeclaratorDecl(VD);
1161 if (!isa<ParmVarDecl>(VD)) {
1178 if (uint64_t Val = Record[Idx++]) {
1179 VD->
setInit(Reader.ReadExpr(F));
1183 Eval->
IsICE = Val == 3;
1188 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1190 switch ((VarKind)Record[Idx++]) {
1191 case VarNotTemplate:
1194 if (!isa<ParmVarDecl>(VD) && !isa<ImplicitParamDecl>(VD) &&
1195 !isa<VarTemplateSpecializationDecl>(VD))
1196 mergeRedeclarable(VD, Redecl);
1202 case StaticDataMemberSpecialization: {
1203 VarDecl *Tmpl = ReadDeclAs<VarDecl>(Record, Idx);
1206 Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
1207 mergeRedeclarable(VD, Redecl);
1221 unsigned isObjCMethodParam = Record[Idx++];
1222 unsigned scopeDepth = Record[Idx++];
1223 unsigned scopeIndex = Record[Idx++];
1224 unsigned declQualifier = Record[Idx++];
1225 if (isObjCMethodParam) {
1226 assert(scopeDepth == 0);
1243 AD->
setAsmString(cast<StringLiteral>(Reader.ReadExpr(F)));
1249 BD->
setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(F)));
1251 unsigned NumParams = Record[Idx++];
1253 Params.reserve(NumParams);
1254 for (
unsigned I = 0;
I != NumParams; ++
I)
1255 Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
1262 bool capturesCXXThis = Record[Idx++];
1263 unsigned numCaptures = Record[Idx++];
1265 captures.reserve(numCaptures);
1266 for (
unsigned i = 0; i != numCaptures; ++i) {
1268 unsigned flags = Record[Idx++];
1269 bool byRef = (flags & 1);
1270 bool nested = (flags & 2);
1271 Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) :
nullptr);
1275 BD->
setCaptures(Reader.getContext(), captures, capturesCXXThis);
1280 unsigned ContextParamPos = Record[Idx++];
1283 for (
unsigned I = 0;
I < CD->NumParams; ++
I) {
1284 if (
I != ContextParamPos)
1285 CD->
setParam(
I, ReadDeclAs<ImplicitParamDecl>(Record, Idx));
1304 RedeclarableResult Redecl = VisitRedeclarable(D);
1307 D->LocStart = ReadSourceLocation(Record, Idx);
1308 D->RBraceLoc = ReadSourceLocation(Record, Idx);
1315 if (Redecl.getFirstID() == ThisDeclID) {
1316 AnonNamespace = ReadDeclID(Record, Idx);
1320 D->AnonOrFirstNamespaceAndInline.setPointer(D->
getFirstDecl());
1323 mergeRedeclarable(D, Redecl);
1325 if (AnonNamespace) {
1329 NamespaceDecl *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
1336 RedeclarableResult Redecl = VisitRedeclarable(D);
1338 D->NamespaceLoc = ReadSourceLocation(Record, Idx);
1339 D->IdentLoc = ReadSourceLocation(Record, Idx);
1340 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1341 D->Namespace = ReadDeclAs<NamedDecl>(Record, Idx);
1342 mergeRedeclarable(D, Redecl);
1348 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1349 ReadDeclarationNameLoc(D->DNLoc, D->
getDeclName(), Record, Idx);
1350 D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>(Record, Idx));
1352 if (
NamedDecl *Pattern = ReadDeclAs<NamedDecl>(Record, Idx))
1353 Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
1358 RedeclarableResult Redecl = VisitRedeclarable(D);
1361 D->UsingOrNextShadow = ReadDeclAs<NamedDecl>(Record, Idx);
1364 Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern);
1365 mergeRedeclarable(D, Redecl);
1370 D->UsingLoc = ReadSourceLocation(Record, Idx);
1371 D->NamespaceLoc = ReadSourceLocation(Record, Idx);
1372 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1373 D->NominatedNamespace = ReadDeclAs<NamedDecl>(Record, Idx);
1374 D->CommonAncestor = ReadDeclAs<DeclContext>(Record, Idx);
1380 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1381 ReadDeclarationNameLoc(D->DNLoc, D->
getDeclName(), Record, Idx);
1388 D->TypenameLocation = ReadSourceLocation(Record, Idx);
1389 D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1393 void ASTDeclReader::ReadCXXDefinitionData(
1394 struct CXXRecordDecl::DefinitionData &Data,
1395 const RecordData &Record,
unsigned &Idx) {
1397 Data.UserDeclaredConstructor = Record[Idx++];
1398 Data.UserDeclaredSpecialMembers = Record[Idx++];
1399 Data.Aggregate = Record[Idx++];
1400 Data.PlainOldData = Record[Idx++];
1401 Data.Empty = Record[Idx++];
1402 Data.Polymorphic = Record[Idx++];
1403 Data.Abstract = Record[Idx++];
1404 Data.IsStandardLayout = Record[Idx++];
1405 Data.HasNoNonEmptyBases = Record[Idx++];
1406 Data.HasPrivateFields = Record[Idx++];
1407 Data.HasProtectedFields = Record[Idx++];
1408 Data.HasPublicFields = Record[Idx++];
1409 Data.HasMutableFields = Record[Idx++];
1410 Data.HasVariantMembers = Record[Idx++];
1411 Data.HasOnlyCMembers = Record[Idx++];
1412 Data.HasInClassInitializer = Record[Idx++];
1413 Data.HasUninitializedReferenceMember = Record[Idx++];
1414 Data.NeedOverloadResolutionForMoveConstructor = Record[Idx++];
1415 Data.NeedOverloadResolutionForMoveAssignment = Record[Idx++];
1416 Data.NeedOverloadResolutionForDestructor = Record[Idx++];
1417 Data.DefaultedMoveConstructorIsDeleted = Record[Idx++];
1418 Data.DefaultedMoveAssignmentIsDeleted = Record[Idx++];
1419 Data.DefaultedDestructorIsDeleted = Record[Idx++];
1420 Data.HasTrivialSpecialMembers = Record[Idx++];
1421 Data.DeclaredNonTrivialSpecialMembers = Record[Idx++];
1422 Data.HasIrrelevantDestructor = Record[Idx++];
1423 Data.HasConstexprNonCopyMoveConstructor = Record[Idx++];
1424 Data.DefaultedDefaultConstructorIsConstexpr = Record[Idx++];
1425 Data.HasConstexprDefaultConstructor = Record[Idx++];
1426 Data.HasNonLiteralTypeFieldsOrBases = Record[Idx++];
1427 Data.ComputedVisibleConversions = Record[Idx++];
1428 Data.UserProvidedDefaultConstructor = Record[Idx++];
1429 Data.DeclaredSpecialMembers = Record[Idx++];
1430 Data.ImplicitCopyConstructorHasConstParam = Record[Idx++];
1431 Data.ImplicitCopyAssignmentHasConstParam = Record[Idx++];
1432 Data.HasDeclaredCopyConstructorWithConstParam = Record[Idx++];
1433 Data.HasDeclaredCopyAssignmentWithConstParam = Record[Idx++];
1435 Data.NumBases = Record[Idx++];
1437 Data.Bases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
1438 Data.NumVBases = Record[Idx++];
1440 Data.VBases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
1442 Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx);
1443 Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx);
1444 assert(Data.Definition &&
"Data.Definition should be already set!");
1445 Data.FirstFriend = ReadDeclID(Record, Idx);
1447 if (Data.IsLambda) {
1449 CXXRecordDecl::LambdaDefinitionData &Lambda
1450 =
static_cast<CXXRecordDecl::LambdaDefinitionData &
>(Data);
1451 Lambda.Dependent = Record[Idx++];
1452 Lambda.IsGenericLambda = Record[Idx++];
1453 Lambda.CaptureDefault = Record[Idx++];
1454 Lambda.NumCaptures = Record[Idx++];
1455 Lambda.NumExplicitCaptures = Record[Idx++];
1456 Lambda.ManglingNumber = Record[Idx++];
1457 Lambda.ContextDecl = ReadDecl(Record, Idx);
1459 = (Capture*)Reader.Context.Allocate(
sizeof(Capture)*Lambda.NumCaptures);
1460 Capture *ToCapture = Lambda.Captures;
1461 Lambda.MethodTyInfo = GetTypeSourceInfo(Record, Idx);
1462 for (
unsigned I = 0, N = Lambda.NumCaptures;
I != N; ++
I) {
1464 bool IsImplicit = Record[Idx++];
1469 *ToCapture++ = Capture(Loc, IsImplicit, Kind,
nullptr,
SourceLocation());
1473 VarDecl *Var = ReadDeclAs<VarDecl>(Record, Idx);
1475 *ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
1482 void ASTDeclReader::MergeDefinitionData(
1483 CXXRecordDecl *D,
struct CXXRecordDecl::DefinitionData &&MergeDD) {
1485 "merging class definition into non-definition");
1488 if (DD.Definition != MergeDD.Definition) {
1490 Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition,
1492 Reader.PendingDefinitions.erase(MergeDD.Definition);
1493 MergeDD.Definition->IsCompleteDefinition =
false;
1494 mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
1495 assert(Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() &&
1496 "already loaded pending lookups for merged definition");
1499 auto PFDI = Reader.PendingFakeDefinitionData.find(&DD);
1500 if (PFDI != Reader.PendingFakeDefinitionData.end() &&
1504 assert(!DD.IsLambda && !MergeDD.IsLambda &&
"faked up lambda definition?");
1509 auto *Def = DD.Definition;
1510 DD = std::move(MergeDD);
1511 DD.Definition = Def;
1516 bool DetectedOdrViolation =
false;
1517 #define OR_FIELD(Field) DD.Field |= MergeDD.Field;
1518 #define MATCH_FIELD(Field) \
1519 DetectedOdrViolation |= DD.Field != MergeDD.Field; \
1538 MATCH_FIELD(NeedOverloadResolutionForMoveConstructor)
1539 MATCH_FIELD(NeedOverloadResolutionForMoveAssignment)
1545 OR_FIELD(DeclaredNonTrivialSpecialMembers)
1547 OR_FIELD(HasConstexprNonCopyMoveConstructor)
1548 MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr)
1549 OR_FIELD(HasConstexprDefaultConstructor)
1556 OR_FIELD(HasDeclaredCopyConstructorWithConstParam)
1557 OR_FIELD(HasDeclaredCopyAssignmentWithConstParam)
1562 if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases)
1563 DetectedOdrViolation =
true;
1569 if (MergeDD.ComputedVisibleConversions && !DD.ComputedVisibleConversions) {
1570 DD.VisibleConversions = std::move(MergeDD.VisibleConversions);
1571 DD.ComputedVisibleConversions =
true;
1582 if (DetectedOdrViolation)
1583 Reader.PendingOdrMergeFailures[DD.Definition].push_back(MergeDD.Definition);
1586 void ASTDeclReader::ReadCXXRecordDefinition(
CXXRecordDecl *D,
bool Update) {
1587 struct CXXRecordDecl::DefinitionData *DD;
1592 bool IsLambda = Record[Idx++];
1594 DD =
new (
C) CXXRecordDecl::LambdaDefinitionData(D,
nullptr,
false,
false,
1597 DD =
new (
C)
struct CXXRecordDecl::DefinitionData(D);
1599 ReadCXXDefinitionData(*DD, Record, Idx);
1606 MergeDefinitionData(Canon, std::move(*DD));
1607 D->DefinitionData = Canon->DefinitionData;
1612 D->IsCompleteDefinition =
true;
1613 D->DefinitionData = DD;
1618 if (Update || Canon != D) {
1619 Canon->DefinitionData = D->DefinitionData;
1620 Reader.PendingDefinitions.insert(D);
1624 ASTDeclReader::RedeclarableResult
1626 RedeclarableResult Redecl = VisitRecordDeclImpl(D);
1631 CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
1633 switch ((CXXRecKind)Record[Idx++]) {
1634 case CXXRecNotTemplate:
1636 if (!isa<ClassTemplateSpecializationDecl>(D))
1637 mergeRedeclarable(D, Redecl);
1639 case CXXRecTemplate: {
1642 D->TemplateOrInstantiation = Template;
1650 TypeIDForTypeDecl = 0;
1654 case CXXRecMemberSpecialization: {
1660 D->TemplateOrInstantiation = MSI;
1661 mergeRedeclarable(D, Redecl);
1666 bool WasDefinition = Record[Idx++];
1668 ReadCXXRecordDefinition(D,
false);
1675 if (WasDefinition) {
1676 DeclID KeyFn = ReadDeclID(Record, Idx);
1677 if (KeyFn && D->IsCompleteDefinition)
1681 C.KeyFunctions[D] = KeyFn;
1688 VisitFunctionDecl(D);
1690 unsigned NumOverridenMethods = Record[Idx++];
1692 while (NumOverridenMethods--) {
1695 if (
CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>(Record, Idx))
1701 Idx += NumOverridenMethods;
1706 VisitCXXMethodDecl(D);
1708 if (
auto *CD = ReadDeclAs<CXXConstructorDecl>(Record, Idx))
1711 D->IsExplicitSpecified = Record[Idx++];
1715 VisitCXXMethodDecl(D);
1717 if (
auto *OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx)) {
1720 if (!Canon->OperatorDelete)
1721 Canon->OperatorDelete = OperatorDelete;
1726 VisitCXXMethodDecl(D);
1727 D->IsExplicitSpecified = Record[Idx++];
1732 D->ImportedAndComplete.setPointer(readModule(Record, Idx));
1733 D->ImportedAndComplete.setInt(Record[Idx++]);
1735 for (
unsigned I = 0, N = Record.back();
I != N; ++
I)
1736 StoredLocs[
I] = ReadSourceLocation(Record, Idx);
1748 D->Friend = ReadDeclAs<NamedDecl>(Record, Idx);
1750 D->Friend = GetTypeSourceInfo(Record, Idx);
1751 for (
unsigned i = 0; i != D->NumTPLists; ++i)
1753 Reader.ReadTemplateParameterList(F, Record, Idx);
1754 D->NextFriend = ReadDeclID(Record, Idx);
1755 D->UnsupportedFriend = (Record[Idx++] != 0);
1756 D->FriendLoc = ReadSourceLocation(Record, Idx);
1761 unsigned NumParams = Record[Idx++];
1762 D->NumParams = NumParams;
1764 for (
unsigned i = 0; i != NumParams; ++i)
1765 D->Params[i] = Reader.ReadTemplateParameterList(F, Record, Idx);
1767 D->Friend = ReadDeclAs<NamedDecl>(Record, Idx);
1769 D->Friend = GetTypeSourceInfo(Record, Idx);
1770 D->FriendLoc = ReadSourceLocation(Record, Idx);
1776 DeclID PatternID = ReadDeclID(Record, Idx);
1777 NamedDecl *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
1779 = Reader.ReadTemplateParameterList(F, Record, Idx);
1780 D->
init(TemplatedDecl, TemplateParams);
1785 ASTDeclReader::RedeclarableResult
1787 RedeclarableResult Redecl = VisitRedeclarable(D);
1794 Reader.PendingDefinitions.insert(CanonD);
1800 if (ThisDeclID == Redecl.getFirstID()) {
1802 = ReadDeclAs<RedeclarableTemplateDecl>(Record, Idx)) {
1803 assert(RTD->getKind() == D->
getKind() &&
1804 "InstantiatedFromMemberTemplate kind mismatch");
1811 DeclID PatternID = VisitTemplateDecl(D);
1814 mergeRedeclarable(D, Redecl, PatternID);
1826 assert(!IDs.empty() &&
"no IDs to add to list");
1828 IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
1829 std::sort(IDs.begin(), IDs.end());
1830 IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
1835 std::copy(IDs.begin(), IDs.end(),
Result + 1);
1840 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
1842 if (ThisDeclID == Redecl.getFirstID()) {
1846 ReadDeclIDList(SpecIDs);
1848 if (!SpecIDs.empty()) {
1851 Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
1859 Reader.Context.getInjectedClassNameType(
1865 llvm_unreachable(
"BuiltinTemplates are not serialized");
1872 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
1874 if (ThisDeclID == Redecl.getFirstID()) {
1878 ReadDeclIDList(SpecIDs);
1880 if (!SpecIDs.empty()) {
1883 Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
1888 ASTDeclReader::RedeclarableResult
1891 RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D);
1894 if (
Decl *InstD = ReadDecl(Record, Idx)) {
1896 D->SpecializedTemplate = CTD;
1899 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
1903 ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
1905 SpecializedPartialSpecialization();
1906 PS->PartialSpecialization
1907 = cast<ClassTemplatePartialSpecializationDecl>(InstD);
1908 PS->TemplateArgs = ArgList;
1909 D->SpecializedTemplate = PS;
1914 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
1918 D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
1921 bool writtenAsCanonicalDecl = Record[Idx++];
1922 if (writtenAsCanonicalDecl) {
1928 dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
1930 .GetOrInsertNode(Partial);
1936 if (CanonSpec != D) {
1937 mergeRedeclarable<TagDecl>(D, CanonSpec, Redecl);
1941 if (
auto *DDD = D->DefinitionData.getNotUpdated()) {
1942 if (CanonSpec->DefinitionData.getNotUpdated())
1943 MergeDefinitionData(CanonSpec, std::move(*DDD));
1945 CanonSpec->DefinitionData = D->DefinitionData;
1947 D->DefinitionData = CanonSpec->DefinitionData;
1954 ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo
1955 =
new (
C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
1956 ExplicitInfo->TypeAsWritten = TyInfo;
1957 ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx);
1958 ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx);
1959 D->ExplicitInfo = ExplicitInfo;
1967 RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
1969 D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx);
1970 D->ArgsAsWritten = Reader.ReadASTTemplateArgumentListInfo(F, Record, Idx);
1973 if (ThisDeclID == Redecl.getFirstID()) {
1974 D->InstantiatedFromMember.setPointer(
1975 ReadDeclAs<ClassTemplatePartialSpecializationDecl>(Record, Idx));
1976 D->InstantiatedFromMember.setInt(Record[Idx++]);
1983 D->Specialization = ReadDeclAs<CXXMethodDecl>(Record, Idx);
1987 RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
1989 if (ThisDeclID == Redecl.getFirstID()) {
1992 ReadDeclIDList(SpecIDs);
1994 if (!SpecIDs.empty()) {
1997 Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
2007 ASTDeclReader::RedeclarableResult
2010 RedeclarableResult Redecl = VisitVarDeclImpl(D);
2013 if (
Decl *InstD = ReadDecl(Record, Idx)) {
2015 D->SpecializedTemplate = VTD;
2018 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
2020 C, TemplArgs.data(), TemplArgs.size());
2021 VarTemplateSpecializationDecl::SpecializedPartialSpecialization *PS =
2023 VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
2024 PS->PartialSpecialization =
2025 cast<VarTemplatePartialSpecializationDecl>(InstD);
2026 PS->TemplateArgs = ArgList;
2027 D->SpecializedTemplate = PS;
2033 VarTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo =
2034 new (
C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo;
2035 ExplicitInfo->TypeAsWritten = TyInfo;
2036 ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx);
2037 ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx);
2038 D->ExplicitInfo = ExplicitInfo;
2042 Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
2046 D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
2049 bool writtenAsCanonicalDecl = Record[Idx++];
2050 if (writtenAsCanonicalDecl) {
2051 VarTemplateDecl *CanonPattern = ReadDeclAs<VarTemplateDecl>(Record, Idx);
2055 dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
2057 .GetOrInsertNode(Partial);
2074 RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
2076 D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx);
2077 D->ArgsAsWritten = Reader.ReadASTTemplateArgumentListInfo(F, Record, Idx);
2080 if (ThisDeclID == Redecl.getFirstID()) {
2081 D->InstantiatedFromMember.setPointer(
2082 ReadDeclAs<VarTemplatePartialSpecializationDecl>(Record, Idx));
2083 D->InstantiatedFromMember.setInt(Record[Idx++]);
2097 VisitDeclaratorDecl(D);
2102 auto TypesAndInfos =
2103 D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
2105 new (&TypesAndInfos[
I].first)
QualType(Reader.readType(F, Record, Idx));
2106 TypesAndInfos[
I].second = GetTypeSourceInfo(Record, Idx);
2110 D->ParameterPack = Record[Idx++];
2117 VisitTemplateDecl(D);
2126 Data[
I] = Reader.ReadTemplateParameterList(F, Record, Idx);
2129 D->ParameterPack = Record[Idx++];
2132 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
2137 VisitRedeclarableTemplateDecl(D);
2142 D->AssertExprAndFailed.setPointer(Reader.ReadExpr(F));
2143 D->AssertExprAndFailed.setInt(Record[Idx++]);
2144 D->Message = cast<StringLiteral>(Reader.ReadExpr(F));
2145 D->RParenLoc = ReadSourceLocation(Record, Idx);
2152 std::pair<uint64_t, uint64_t>
2154 uint64_t LexicalOffset = Record[Idx++];
2155 uint64_t VisibleOffset = Record[Idx++];
2156 return std::make_pair(LexicalOffset, VisibleOffset);
2159 template <
typename T>
2160 ASTDeclReader::RedeclarableResult
2162 DeclID FirstDeclID = ReadDeclID(Record, Idx);
2163 Decl *MergeWith =
nullptr;
2165 bool IsKeyDecl = ThisDeclID == FirstDeclID;
2166 bool IsFirstLocalDecl =
false;
2168 uint64_t RedeclOffset = 0;
2172 if (FirstDeclID == 0) {
2173 FirstDeclID = ThisDeclID;
2175 IsFirstLocalDecl =
true;
2176 }
else if (
unsigned N = Record[Idx++]) {
2180 IsFirstLocalDecl =
true;
2187 for (
unsigned I = 0;
I != N - 1; ++
I)
2188 MergeWith = ReadDecl(Record, Idx);
2190 RedeclOffset = Record[Idx++];
2194 (void)ReadDecl(Record, Idx);
2197 T *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID));
2198 if (FirstDecl != D) {
2204 D->
First = FirstDecl->getCanonicalDecl();
2207 T *DAsT =
static_cast<T*
>(D);
2213 if (IsFirstLocalDecl)
2214 Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset));
2216 return RedeclarableResult(FirstDeclID, MergeWith, 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(DPattern->getCanonicalDecl()->getGlobalID(),
2259 ExistingPattern, IsKeyDecl);
2261 if (
auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) {
2264 auto *ExistingClass =
2265 cast<CXXRecordDecl>(ExistingPattern)->getCanonicalDecl();
2266 if (
auto *DDD = DClass->DefinitionData.getNotUpdated()) {
2267 if (ExistingClass->DefinitionData.getNotUpdated()) {
2268 MergeDefinitionData(ExistingClass, std::move(*DDD));
2270 ExistingClass->DefinitionData = DClass->DefinitionData;
2273 Reader.PendingDefinitions.insert(DClass);
2276 DClass->DefinitionData = ExistingClass->DefinitionData;
2278 return mergeRedeclarable(DClass, cast<TagDecl>(ExistingPattern),
2281 if (
auto *DFunction = dyn_cast<FunctionDecl>(DPattern))
2282 return mergeRedeclarable(DFunction, cast<FunctionDecl>(ExistingPattern),
2284 if (
auto *DVar = dyn_cast<VarDecl>(DPattern))
2285 return mergeRedeclarable(DVar, cast<VarDecl>(ExistingPattern),
Result);
2286 if (
auto *DAlias = dyn_cast<TypeAliasDecl>(DPattern))
2287 return mergeRedeclarable(DAlias, cast<TypedefNameDecl>(ExistingPattern),
2289 llvm_unreachable(
"merged an unknown kind of redeclarable template");
2294 template<
typename T>
2296 RedeclarableResult &Redecl,
2297 DeclID TemplatePatternID) {
2298 T *D =
static_cast<T*
>(DBase);
2301 if (ExistingCanon != DCanon) {
2302 assert(DCanon->getGlobalID() == Redecl.getFirstID() &&
2303 "already merged this declaration");
2309 D->First = ExistingCanon;
2314 if (
auto *Namespace = dyn_cast<NamespaceDecl>(D))
2315 Namespace->AnonOrFirstNamespaceAndInline.setPointer(
2316 assert_cast<NamespaceDecl*>(ExistingCanon));
2319 if (
auto *DTemplate = dyn_cast<RedeclarableTemplateDecl>(D))
2320 mergeTemplatePattern(
2321 DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon),
2322 TemplatePatternID, Redecl.isKeyDecl());
2325 if (Redecl.isKeyDecl())
2326 Reader.KeyDecls[ExistingCanon].push_back(Redecl.getFirstID());
2334 template<
typename T>
2337 if (!Reader.getContext().getLangOpts().Modules)
2343 if (!Reader.getContext().getLangOpts().CPlusPlus)
2346 if (FindExistingResult ExistingRes = findExisting(static_cast<T*>(D)))
2347 if (T *Existing = ExistingRes)
2348 Reader.Context.setPrimaryMergedDecl(static_cast<T*>(D),
2349 Existing->getCanonicalDecl());
2356 Vars.reserve(NumVars);
2357 for (
unsigned i = 0; i != NumVars; ++i) {
2358 Vars.push_back(Reader.ReadExpr(F));
2370 for (
unsigned i = 0, e = Record[Idx++]; i != e; ++i) {
2371 Attr *New =
nullptr;
2373 SourceRange Range = ReadSourceRange(F, Record, Idx);
2375 #include "clang/Serialization/AttrPCHRead.inc"
2377 assert(New &&
"Unable to decode attribute?");
2378 Attrs.push_back(New);
2392 inline void ASTReader::LoadedDecl(
unsigned Index,
Decl *D) {
2393 assert(!DeclsLoaded[Index] &&
"Decl loaded twice?");
2394 DeclsLoaded[Index] = D;
2408 if (isa<FileScopeAsmDecl>(D) ||
2409 isa<ObjCProtocolDecl>(D) ||
2410 isa<ObjCImplDecl>(D) ||
2411 isa<ImportDecl>(D) ||
2412 isa<OMPThreadPrivateDecl>(D))
2414 if (
VarDecl *Var = dyn_cast<VarDecl>(D))
2415 return Var->isFileVarDecl() &&
2418 return Func->doesThisDeclarationHaveABody() || HasBody;
2424 ASTReader::RecordLocation
2425 ASTReader::DeclCursorForID(
DeclID ID,
unsigned &RawLocation) {
2428 if (It != ReplacedDecls.end()) {
2429 RawLocation = It->second.RawLoc;
2430 return RecordLocation(It->second.Mod, It->second.Offset);
2434 assert(I != GlobalDeclMap.end() &&
"Corrupted global declaration map");
2438 RawLocation = DOffs.
Loc;
2439 return RecordLocation(M, DOffs.
BitOffset);
2442 ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
2444 = GlobalBitOffsetsMap.find(GlobalOffset);
2446 assert(I != GlobalBitOffsetsMap.
end() &&
"Corrupted global bit offsets map");
2447 return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
2450 uint64_t ASTReader::getGlobalBitOffset(
ModuleFile &M, uint32_t LocalOffset) {
2472 TX->getASTContext().hasSameType(TX->getType(), TY->
getType());
2479 TY->getTemplateParameters());
2486 return NAS->getNamespace();
2494 if (!NSY || NSX->getCanonicalDecl() != NSY->getCanonicalDecl())
2536 for (
unsigned I = 0, N = X->
size(); I != N; ++
I)
2560 TypedefY->getUnderlyingType());
2567 if (isa<ObjCInterfaceDecl>(X) || isa<ObjCProtocolDecl>(
X))
2570 if (isa<ClassTemplateSpecializationDecl>(X)) {
2577 if (
TagDecl *TagX = dyn_cast<TagDecl>(X)) {
2578 TagDecl *TagY = cast<TagDecl>(Y);
2579 return (TagX->getTagKind() == TagY->
getTagKind()) ||
2596 if (
VarDecl *VarX = dyn_cast<VarDecl>(X)) {
2597 VarDecl *VarY = cast<VarDecl>(Y);
2603 if (
NamespaceDecl *NamespaceX = dyn_cast<NamespaceDecl>(X)) {
2610 if (
TemplateDecl *TemplateX = dyn_cast<TemplateDecl>(X)) {
2619 if (
FieldDecl *FDX = dyn_cast<FieldDecl>(X)) {
2626 if (
auto *IFDX = dyn_cast<IndirectFieldDecl>(X)) {
2627 auto *IFDY = cast<IndirectFieldDecl>(Y);
2628 return IFDX->getAnonField()->getCanonicalDecl() ==
2629 IFDY->getAnonField()->getCanonicalDecl();
2633 if (isa<EnumConstantDecl>(X))
2645 if (
auto *UX = dyn_cast<UsingDecl>(X)) {
2646 auto *UY = cast<UsingDecl>(Y);
2648 UX->hasTypename() == UY->hasTypename() &&
2649 UX->isAccessDeclaration() == UY->isAccessDeclaration();
2651 if (
auto *UX = dyn_cast<UnresolvedUsingValueDecl>(X)) {
2652 auto *UY = cast<UnresolvedUsingValueDecl>(Y);
2654 UX->isAccessDeclaration() == UY->isAccessDeclaration();
2656 if (
auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(X))
2662 if (
auto *NAX = dyn_cast<NamespaceAliasDecl>(X)) {
2663 auto *NAY = cast<NamespaceAliasDecl>(Y);
2664 return NAX->getNamespace()->Equals(NAY->getNamespace());
2675 return ND->getOriginalNamespace();
2679 auto *DD = RD->DefinitionData.getNotUpdated();
2681 DD = RD->getCanonicalDecl()->DefinitionData.getNotUpdated();
2688 DD =
new (Reader.Context)
struct CXXRecordDecl::DefinitionData(RD);
2689 RD->IsCompleteDefinition =
true;
2690 RD->DefinitionData = DD;
2691 RD->getCanonicalDecl()->DefinitionData = DD;
2694 Reader.PendingFakeDefinitionData.insert(
2698 return DD->Definition;
2701 if (
EnumDecl *ED = dyn_cast<EnumDecl>(DC))
2702 return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition()
2707 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2713 ASTDeclReader::FindExistingResult::~FindExistingResult() {
2716 if (TypedefNameForLinkage) {
2718 Reader.ImportedTypedefNamesForLinkage.insert(
2719 std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New));
2723 if (!AddResult || Existing)
2729 setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
2730 AnonymousDeclNumber, New);
2736 }
else if (
DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
2739 MergeDC->makeDeclVisibleInContextImpl(New,
true);
2747 bool IsTypedefNameForLinkage) {
2748 if (!IsTypedefNameForLinkage)
2757 if (
auto *TND = dyn_cast<TypedefNameDecl>(Found))
2758 return TND->getAnonDeclWithTypedefName();
2768 if (
auto *Merged = Reader.MergedDeclContexts.lookup(DC))
2772 auto &
Previous = Reader.AnonymousDeclarationsForMerging[DC];
2778 if (!cast<Decl>(DC)->isFromASTFile()) {
2790 void ASTDeclReader::setAnonymousDeclForMerging(
ASTReader &Reader,
2793 if (
auto *Merged = Reader.MergedDeclContexts.lookup(DC))
2796 auto &
Previous = Reader.AnonymousDeclarationsForMerging[DC];
2803 ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(
NamedDecl *D) {
2810 FindExistingResult
Result(Reader, D,
nullptr,
2811 AnonymousDeclNumber, TypedefNameForLinkage);
2817 if (TypedefNameForLinkage) {
2818 auto It = Reader.ImportedTypedefNamesForLinkage.find(
2819 std::make_pair(DC, TypedefNameForLinkage));
2820 if (It != Reader.ImportedTypedefNamesForLinkage.end())
2822 return FindExistingResult(Reader, D, It->second, AnonymousDeclNumber,
2823 TypedefNameForLinkage);
2831 if (
auto *Existing = getAnonymousDeclForMerging(
2834 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
2835 TypedefNameForLinkage);
2842 class UpToDateIdentifierRAII {
2848 : II(II), WasOutToDate(
false)
2857 ~UpToDateIdentifierRAII() {
2864 IEnd = IdResolver.
end();
2868 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
2869 TypedefNameForLinkage);
2871 }
else if (
DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
2876 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
2877 TypedefNameForLinkage);
2881 return FindExistingResult(Reader);
2890 if (MergedDCIt != Reader.MergedDeclContexts.end() &&
2892 Reader.PendingOdrMergeChecks.push_back(D);
2894 return FindExistingResult(Reader, D,
nullptr,
2895 AnonymousDeclNumber, TypedefNameForLinkage);
2898 template<
typename DeclT>
2903 llvm_unreachable(
"getMostRecentDecl on non-redeclarable declaration");
2910 #define ABSTRACT_DECL(TYPE)
2911 #define DECL(TYPE, BASE) \
2913 return getMostRecentDeclImpl(cast<TYPE##Decl>(D));
2914 #include "clang/AST/DeclNodes.inc"
2916 llvm_unreachable(
"unknown decl kind");
2919 Decl *ASTReader::getMostRecentExistingDecl(
Decl *D) {
2923 template<
typename DeclT>
2927 D->
RedeclLink.setPrevious(cast<DeclT>(Previous));
2944 if (PrevFD->IsInline != FD->IsInline) {
2960 FD->IsInline =
true;
2967 if (FPT && PrevFPT) {
2969 bool WasUnresolved =
2971 if (IsUnresolved != WasUnresolved)
2972 Reader.PendingExceptionSpecUpdates.insert(
2973 std::make_pair(Canon, IsUnresolved ? PrevFD : FD));
2979 llvm_unreachable(
"attachPreviousDecl on non-redeclarable declaration");
2984 template <
typename ParmDecl>
2987 auto *To = cast<ParmDecl>(ToD);
2988 if (!From->hasDefaultArgument())
2990 To->setInheritedDefaultArgument(Context, From);
2999 assert(FromTP->size() == ToTP->size() &&
"merged mismatched templates?");
3001 for (
unsigned I = 0, N = FromTP->size(); I != N; ++
I) {
3002 NamedDecl *FromParam = FromTP->getParam(N - I - 1);
3003 NamedDecl *ToParam = ToTP->getParam(N - I - 1);
3005 if (
auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam)) {
3008 }
else if (
auto *FNTTP = dyn_cast<NonTypeTemplateParmDecl>(FromParam)) {
3013 Context, cast<TemplateTemplateParmDecl>(FromParam), ToParam))
3021 assert(D && Previous);
3024 #define ABSTRACT_DECL(TYPE)
3025 #define DECL(TYPE, BASE) \
3027 attachPreviousDeclImpl(Reader, cast<TYPE##Decl>(D), Previous, Canon); \
3029 #include "clang/AST/DeclNodes.inc"
3053 template<
typename DeclT>
3055 D->
RedeclLink.setLatest(cast<DeclT>(Latest));
3058 llvm_unreachable(
"attachLatestDecl on non-redeclarable declaration");
3062 assert(D && Latest);
3065 #define ABSTRACT_DECL(TYPE)
3066 #define DECL(TYPE, BASE) \
3068 attachLatestDeclImpl(cast<TYPE##Decl>(D), Latest); \
3070 #include "clang/AST/DeclNodes.inc"
3074 template<
typename DeclT>
3079 llvm_unreachable(
"markIncompleteDeclChain on non-redeclarable declaration");
3082 void ASTReader::markIncompleteDeclChain(
Decl *D) {
3084 #define ABSTRACT_DECL(TYPE)
3085 #define DECL(TYPE, BASE) \
3087 ASTDeclReader::markIncompleteDeclChainImpl(cast<TYPE##Decl>(D)); \
3089 #include "clang/AST/DeclNodes.inc"
3096 unsigned RawLocation = 0;
3097 RecordLocation Loc = DeclCursorForID(ID, RawLocation);
3098 llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
3103 ReadingKindTracker ReadingKind(Read_Decl, *
this);
3106 Deserializing ADecl(
this);
3108 DeclsCursor.JumpToBit(Loc.Offset);
3110 unsigned Code = DeclsCursor.ReadCode();
3112 ASTDeclReader Reader(*
this, *Loc.F, ID, RawLocation, Record,Idx);
3115 switch ((
DeclCode)DeclsCursor.readRecord(Code, Record)) {
3118 llvm_unreachable(
"Record cannot be de-serialized with ReadDeclRecord");
3295 Error(
"attempt to read a C++ base-specifier record as a declaration");
3298 Error(
"attempt to read a C++ ctor initializer record as a declaration");
3316 assert(D &&
"Unknown declaration reading AST file");
3317 LoadedDecl(Index, D);
3327 std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC);
3328 if (Offsets.first &&
3329 ReadLexicalDeclContextStorage(*Loc.F, DeclsCursor, Offsets.first, DC))
3331 if (Offsets.second &&
3332 ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID))
3335 assert(Idx == Record.size());
3338 PendingUpdateRecords.push_back(std::make_pair(ID, D));
3342 if (Class->isThisDeclarationADefinition())
3343 loadObjCCategories(ID, Class);
3350 InterestingDecls.push_back(D);
3357 auto I = PendingVisibleUpdates.
find(ID);
3358 if (I != PendingVisibleUpdates.
end()) {
3359 auto VisibleUpdates = std::move(I->second);
3360 PendingVisibleUpdates.erase(I);
3362 auto *DC = cast<DeclContext>(D)->getPrimaryContext();
3363 for (
const PendingVisibleUpdate &Update : VisibleUpdates)
3364 Lookups[DC].Table.add(
3365 Update.Mod, Update.Data,
3374 if (UpdI != DeclUpdateOffsets.end()) {
3375 auto UpdateOffsets = std::move(UpdI->second);
3376 DeclUpdateOffsets.erase(UpdI);
3379 for (
auto &FileAndOffset : UpdateOffsets) {
3381 uint64_t
Offset = FileAndOffset.second;
3384 Cursor.JumpToBit(Offset);
3386 unsigned Code = Cursor.ReadCode();
3387 unsigned RecCode = Cursor.readRecord(Code, Record);
3389 assert(RecCode ==
DECL_UPDATES &&
"Expected DECL_UPDATES record!");
3393 Reader.UpdateDecl(D, *F, Record);
3397 if (!WasInteresting &&
3399 InterestingDecls.push_back(D);
3400 WasInteresting =
true;
3406 void ASTReader::loadPendingDeclChain(
Decl *FirstLocal, uint64_t LocalOffset) {
3409 if (FirstLocal != CanonDecl) {
3412 *
this, FirstLocal, PrevMostRecent ? PrevMostRecent : CanonDecl,
3422 ModuleFile *M = getOwningModuleFile(FirstLocal);
3423 assert(M &&
"imported decl from no module file");
3427 Cursor.JumpToBit(LocalOffset);
3430 unsigned Code = Cursor.ReadCode();
3431 unsigned RecCode = Cursor.readRecord(Code, Record);
3437 Decl *MostRecent = FirstLocal;
3438 for (
unsigned I = 0, N = Record.size(); I != N; ++
I) {
3439 auto *D = GetLocalDecl(*M, Record[N - I - 1]);
3449 class ObjCCategoriesVisitor {
3453 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized;
3454 unsigned PreviousGeneration;
3456 llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap;
3460 if (!Deserialized.erase(Cat))
3481 << Interface->getDeclName() << Cat->
getDeclName();
3483 }
else if (!Existing) {
3493 Interface->setCategoryListRaw(Cat);
3498 ObjCCategoriesVisitor(
ASTReader &Reader,
3501 llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
3502 unsigned PreviousGeneration)
3503 : Reader(Reader), InterfaceID(InterfaceID), Interface(Interface),
3504 Deserialized(Deserialized), PreviousGeneration(PreviousGeneration),
3546 unsigned Offset = Result->
Offset;
3549 for (
unsigned I = 0; I != N; ++
I)
3550 add(cast_or_null<ObjCCategoryDecl>(
3559 unsigned PreviousGeneration) {
3560 ObjCCategoriesVisitor Visitor(*
this, ID, D, CategoriesDeserialized,
3561 PreviousGeneration);
3562 ModuleMgr.visit(Visitor);
3565 template<
typename DeclT,
typename Fn>
3574 for (
auto *Redecl = MostRecent; Redecl && !Found;
3576 Found = (Redecl == D);
3580 for (
auto *Redecl = MostRecent; Redecl != D;
3588 while (Idx < Record.size()) {
3591 auto *RD = cast<CXXRecordDecl>(D);
3595 assert(MD &&
"couldn't read decl from update record");
3598 RD->addedMember(MD);
3604 (void)Reader.
ReadDecl(ModuleFile, Record, Idx);
3619 cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
3625 cast<VarDecl>(D)->getMemberSpecializationInfo()->setPointOfInstantiation(
3630 auto Param = cast<ParmVarDecl>(D);
3635 auto DefaultArg = Reader.
ReadExpr(F);
3639 if (Param->hasUninstantiatedDefaultArg())
3640 Param->setDefaultArg(DefaultArg);
3646 if (Reader.PendingBodies[FD]) {
3652 if (Record[Idx++]) {
3661 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3662 CD->NumCtorInitializers = Record[Idx++];
3663 if (CD->NumCtorInitializers)
3664 CD->CtorInitializers =
3668 Reader.PendingBodies[FD] = GetCurrentCursorOffset();
3669 HasPendingBody =
true;
3670 assert(Idx == Record.size() &&
"lazy body must be last");
3675 auto *RD = cast<CXXRecordDecl>(D);
3676 auto *OldDD = RD->DefinitionData.getNotUpdated();
3677 bool HadRealDefinition =
3678 OldDD && (OldDD->Definition != RD ||
3679 !Reader.PendingFakeDefinitionData.count(OldDD));
3680 ReadCXXRecordDefinition(RD,
true);
3683 uint64_t LexicalOffset = Record[Idx++];
3684 if (!HadRealDefinition && LexicalOffset) {
3685 Reader.ReadLexicalDeclContextStorage(ModuleFile, ModuleFile.DeclsCursor,
3687 Reader.PendingFakeDefinitionData.erase(OldDD);
3693 RD->getMemberSpecializationInfo()) {
3694 MSInfo->setTemplateSpecializationKind(TSK);
3695 MSInfo->setPointOfInstantiation(POI);
3698 cast<ClassTemplateSpecializationDecl>(RD);
3702 if (Record[Idx++]) {
3704 ReadDeclAs<ClassTemplatePartialSpecializationDecl>(Record, Idx);
3708 Reader.
getContext(), TemplArgs.data(), TemplArgs.size());
3723 if (Record[Idx++]) {
3737 if (!First->OperatorDelete)
3738 First->OperatorDelete = Del;
3745 Reader.readExceptionSpec(ModuleFile, ExceptionStorage, ESI, Record, Idx);
3748 auto *FD = cast<FunctionDecl>(D);
3754 FPT->getReturnType(), FPT->getParamTypes(),
3755 FPT->getExtProtoInfo().withExceptionSpec(ESI)));
3759 Reader.PendingExceptionSpecUpdates.insert(
3760 std::make_pair(FD->getCanonicalDecl(), FD));
3794 D->
addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(
3795 Reader.Context, ReadSourceRange(Record, Idx)));
3799 unsigned SubmoduleID = readSubmoduleID(Record, Idx);
3800 auto *Exported = cast<NamedDecl>(D);
3801 if (
auto *TD = dyn_cast<TagDecl>(Exported))
3802 Exported = TD->getDefinition();
3808 cast<NamedDecl>(Exported), Owner,
3810 Reader.PendingMergedDefinitionsToDeduplicate.insert(
3811 cast<NamedDecl>(Exported));
3815 Reader.HiddenNamesMap[Owner].push_back(Exported);
3818 Exported->Hidden =
false;
3826 assert(Attrs.size() == 1);
RedeclarableResult VisitTypedefNameDecl(TypedefNameDecl *TD)
void VisitTypeDecl(TypeDecl *TD)
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)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
void VisitVarDecl(VarDecl *VD)
#define MATCH_FIELD(Field)
void setAnonymousStructOrUnion(bool Anon)
A class which contains all the information about a particular captured value.
static ImportDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
void VisitImportDecl(ImportDecl *D)
A (possibly-)qualified type.
void mergeMergeable(Mergeable< T > *D)
Attempts to merge the given declaration (D) with another declaration of the same entity, for the case where the entity is not actually redeclarable.
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
FunctionDecl * Function
The function template specialization that this structure describes.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
void 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...
RedeclarableResult VisitClassTemplateSpecializationDeclImpl(ClassTemplateSpecializationDecl *D)
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
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)
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
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.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
Decl - This represents one declaration (or definition), e.g.
void setInheritedConstructor(const CXXConstructorDecl *BaseCtor)
Set the constructor that this inheriting constructor is based on.
static NamedDecl * getDeclForMerging(NamedDecl *Found, bool IsTypedefNameForLinkage)
Find the declaration that should be merged into, given the declaration found by name lookup...
A VarTemplatePartialSpecializationDecl record.
void 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
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
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.
Class that performs name lookup into a DeclContext stored in an AST file.
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.
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 setNothrow(bool Nothrow=true)
void setRAngleLoc(SourceLocation Loc)
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
void VisitNamedDecl(NamedDecl *ND)
Declaration of a redeclarable template.
A UsingShadowDecl record.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
The "__interface" keyword.
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack...
A namespace, stored as a NamespaceDecl*.
void VisitClassTemplateDecl(ClassTemplateDecl *D)
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...
Represents the builtin template declaration which is used to implement __make_integer_seq.
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
RedeclarableResult VisitTagDecl(TagDecl *TD)
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
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)
Types, declared with 'struct foo', typedefs, etc.
RecordDecl - Represents a struct/union/class.
Provides common interface for the Decls that can be redeclared.
ObjCProtocolDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C protocol.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
void setIntegerType(QualType T)
Set the underlying integer type.
void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D)
void mergeRedeclarable(Redeclarable< T > *D, RedeclarableResult &Redecl, DeclID TemplatePatternID=0)
Attempts to merge the given declaration (D) with another declaration of the same entity.
static OMPThreadPrivateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
void setManglingNumber(const NamedDecl *ND, unsigned Number)
void setCompleteDefinition(bool V)
void setUninstantiatedDefaultArg(Expr *arg)
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
bool CheckedICE
Whether we already checked whether this statement was an integral constant expression.
void VisitFriendTemplateDecl(FriendTemplateDecl *D)
void setLanguage(LanguageIDs L)
Set the language specified by this linkage specification.
Common * getCommonPtr() const
LambdaCaptureKind
The different capture forms in a lambda introducer.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
void setBlockMissingReturnType(bool val)
void setLocStart(SourceLocation L)
static CXXRecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
RedeclarableResult VisitVarTemplateSpecializationDeclImpl(VarTemplateSpecializationDecl *D)
TODO: Unify with ClassTemplateSpecializationDecl version? May require unifying ClassTemplate(Partial)...
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
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.
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.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
ObjCContainerDecl - Represents a container for method declarations.
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)
A convenient class for passing around template argument information.
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)
We've merged the definition MergedDef into the existing definition Def.
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)
TypeDecl - Represents a declaration of a type.
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.
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()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
void setNumNegativeBits(unsigned Num)
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
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)
detail::InMemoryDirectory::const_iterator I
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
isTemplateParameter - Determines whether this declaration is a template parameter pack...
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
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)
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
Represents a prototype with parameter type info, e.g.
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.
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)
TODO: Unify with ClassTemplatePartialSpecializationDecl version? May require unifying ClassTemplate(P...
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)
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
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)
setInvalidDecl - Indicates the Decl had a semantic error.
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)
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
void setMemberSpecialization()
Note that this member template is a specialization.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
void setDefined(bool isDefined)
void setCompleteDefinitionRequired(bool V=true)
RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D)
Information about a module that has been loaded by the ASTReader.
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
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
An ImplicitParamDecl record.
void setIvarRBraceLoc(SourceLocation Loc)
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
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)
setDeclContext - Set both the semantic and lexical DeclContext to 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.
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
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.
static EmptyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setTopLevelDeclInObjCContainer(bool V=true)
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
const TemplateArgument * iterator
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)
bool IsScoped
IsScoped - True if this tag declaration is a scoped enumeration.
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)
LabelDecl - Represents the declaration of a label.
void mergeTemplatePattern(RedeclarableTemplateDecl *D, RedeclarableTemplateDecl *Existing, DeclID DsID, bool IsKeyDecl)
Merge together the pattern declarations from two template declarations.
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal)
Represents a dependent using declaration which was not marked with typename.
void setPosition(unsigned P)
void 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)
setProtocolList - Set the list of protocols that this interface implements.
A TemplateTypeParmDecl record.
Data that is common to all of the declarations of a given function template.
ObjCCategoryDecl - Represents a category declaration.
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)
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)
setProtocolList - Set the list of protocols that this interface implements.
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
lookup - Find the declarations (if any) with the given Name in this context.
static T assert_cast(T t)
"Cast" to type T, asserting if we don't have an implicit conversion.
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.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void setSetterCXXAssignment(Expr *setterCXXAssignment)
void VisitEnumDecl(EnumDecl *ED)
static TypedefDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Base class for declarations which introduce a typedef-name.
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
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
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)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
The base class of all kinds of template declarations (e.g., class, function, etc.).
void VisitFunctionDecl(FunctionDecl *FD)
bool 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.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
A ClassTemplatePartialSpecializationDecl record.
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
DeclCode
Record codes for each kind of declaration.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
RedeclarableResult VisitCXXRecordDeclImpl(CXXRecordDecl *D)
void setIvarList(ObjCIvarDecl *ivar)
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
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.
DeclarationName - The name of a declaration.
Represents the declaration of an Objective-C type parameter.
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)
EnumDecl - Represents an enum.
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
detail::InMemoryDirectory::const_iterator E
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)
Inherit the default template argument from From to To.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
A type that was preceded by the 'template' keyword, stored as a Type*.
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)
All of the names in this module are visible.
bool IsScopedUsingClassTag
IsScopedUsingClassTag - If this tag declaration is a scoped enum, then this is true if the scoped enu...
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)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
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
const T * getAs() const
Member-template getAs<specific type>'.
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
void setHasNonZeroConstructors(bool val)
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
LanguageIDs
Represents the language in a linkage specification.
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static RecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument array.
static CXXMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
NestedNameSpecifier * getQualifier() const
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
static EnumDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setSetterName(Selector Sel)
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
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...
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
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)
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
void setDescribedVarTemplate(VarTemplateDecl *Template)
void setInstanceMethod(bool isInst)
void SetRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
void setClassInterface(ObjCInterfaceDecl *IFace)
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
ObjCIvarDecl - Represents an ObjC instance variable.
bool operator!=(CanQual< T > x, CanQual< U > y)
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Provides information a specialization of a member of a class template, which may be a member function...
A ObjCImplementationDecl record.
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source...
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
void setReturnTypeSourceInfo(TypeSourceInfo *TInfo)
A ObjCAtDefsFieldDecl record.
Declaration of a class template.
void setIvarLBraceLoc(SourceLocation Loc)
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
void VisitAccessSpecDecl(AccessSpecDecl *D)
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)
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
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)
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 setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
void ReadAttributes(ModuleFile &F, AttrVec &Attrs, const RecordData &Record, unsigned &Idx)
Reads attributes from the current stream position.
bool IsFixed
IsFixed - True if this is an enumeration with fixed underlying type.
void VisitIndirectFieldDecl(IndirectFieldDecl *FD)
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)
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.
An instance of this class represents the declaration of a property member.
void setAtLoc(SourceLocation Loc)
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
uint32_t TypeID
An ID number that refers to a type in an AST file.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
NamedDecl - This represents a decl with a name.
void VisitVarTemplateDecl(VarTemplateDecl *D)
TODO: Unify with ClassTemplateDecl version? May require unifying ClassTemplateDecl and VarTemplateDec...
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.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
Declaration of a template function.
iterator - Iterate over the decls of a specified declaration name.
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)
ObjCCompatibleAliasDecl - Represents alias of a class.
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.