71#include "llvm/ADT/APFixedPoint.h"
72#include "llvm/ADT/APInt.h"
73#include "llvm/ADT/APSInt.h"
74#include "llvm/ADT/ArrayRef.h"
75#include "llvm/ADT/DenseMap.h"
76#include "llvm/ADT/DenseSet.h"
77#include "llvm/ADT/FoldingSet.h"
78#include "llvm/ADT/PointerUnion.h"
79#include "llvm/ADT/STLExtras.h"
80#include "llvm/ADT/SmallPtrSet.h"
81#include "llvm/ADT/SmallVector.h"
82#include "llvm/ADT/StringExtras.h"
83#include "llvm/ADT/StringRef.h"
84#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
85#include "llvm/Support/Capacity.h"
86#include "llvm/Support/Casting.h"
87#include "llvm/Support/Compiler.h"
88#include "llvm/Support/ErrorHandling.h"
89#include "llvm/Support/MD5.h"
90#include "llvm/Support/MathExtras.h"
91#include "llvm/Support/SipHash.h"
92#include "llvm/Support/raw_ostream.h"
93#include "llvm/TargetParser/AArch64TargetParser.h"
94#include "llvm/TargetParser/RISCVTargetParser.h"
95#include "llvm/TargetParser/Triple.h"
108using namespace clang;
126 if (
const auto *MI = dyn_cast<const MacroInfo *>(Key)) {
140 StringRef Buffer = SourceMgr.getBufferData(Decomposed.first, &
Invalid);
143 unsigned Offset = Decomposed.second;
144 if (
size_t Found = Buffer.find_last_of(
"#\n", Offset);
145 Found != StringRef::npos)
147 return {SourceMgr.getLocForStartOfFile(Decomposed.first)
148 .getLocWithOffset(Offset)};
159 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
164 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
165 if (VD->isStaticDataMember() &&
170 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(D)) {
175 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
182 if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
186 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
189 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
216 BaseLocation = D->getBeginLoc();
218 BaseLocation = D->getLocation();
220 if (!D->getLocation().isMacroID()) {
221 Locations.emplace_back(BaseLocation);
223 const auto *DeclCtx = D->getDeclContext();
234 Locations.emplace_back(SourceMgr.getExpansionLoc(BaseLocation));
241 Locations.emplace_back(SourceMgr.getSpellingLoc(D->getBeginLoc()));
249 const std::map<unsigned, RawComment *> &CommentsInTheFile)
const {
256 if (CommentsInTheFile.empty())
259 const auto *D = dyn_cast<const Decl *>(Key);
265 SourceMgr.getDecomposedLoc(RepresentativeLoc);
268 auto OffsetCommentBehindDecl =
269 CommentsInTheFile.lower_bound(LocDecomp.second);
272 if (OffsetCommentBehindDecl != CommentsInTheFile.end()) {
273 RawComment *CommentBehindDecl = OffsetCommentBehindDecl->second;
275 LangOpts.CommentOpts.ParseAllComments) &&
283 if (SourceMgr.getLineNumber(LocDecomp.first, LocDecomp.second) ==
284 Comments.getCommentBeginLine(CommentBehindDecl, LocDecomp.first,
285 OffsetCommentBehindDecl->first)) {
286 return CommentBehindDecl;
293 if (OffsetCommentBehindDecl == CommentsInTheFile.begin())
296 auto OffsetCommentBeforeDecl = --OffsetCommentBehindDecl;
297 RawComment *CommentBeforeDecl = OffsetCommentBeforeDecl->second;
301 LangOpts.CommentOpts.ParseAllComments) ||
306 const unsigned CommentEndOffset =
307 Comments.getCommentEndOffset(CommentBeforeDecl);
312 SourceMgr.getBufferData(LocDecomp.first, &
Invalid).data();
317 StringRef
Text(Buffer + CommentEndOffset,
318 LocDecomp.second - CommentEndOffset);
322 if (
Text.find_last_of(
";{}#@") != StringRef::npos)
325 return CommentBeforeDecl;
331 for (
const auto Loc : Locs) {
334 if (Loc.isInvalid() || !Loc.isFileID())
345 const FileID File = SourceMgr.getDecomposedLoc(Loc).first;
349 const auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
350 if (!CommentsInThisFile || CommentsInThisFile->empty())
362 assert(LangOpts.CommentOpts.RetainCommentsFromSystemHeaders ||
364 Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
369 const Decl **OriginalDecl)
const {
372 *OriginalDecl =
nullptr;
378 if (
const auto *MI = dyn_cast<const MacroInfo *>(Key)) {
380 *OriginalDecl =
nullptr;
383 return Existing->second;
400 return DeclComment->second;
413 *OriginalDecl = RedeclComment->second;
414 auto CommentAtRedecl =
RawComments.find(RedeclComment->second);
416 "This decl is supposed to have comment attached.");
417 return CommentAtRedecl->second;
422 const Decl *LastCheckedRedecl = [&]() {
424 bool CanUseCommentlessCache =
false;
426 for (
auto *Redecl : CanonicalD->
redecls()) {
428 CanUseCommentlessCache =
true;
431 if (Redecl == LastChecked)
438 return CanUseCommentlessCache ? LastChecked :
nullptr;
444 if (LastCheckedRedecl) {
445 if (LastCheckedRedecl == Redecl) {
446 LastCheckedRedecl =
nullptr;
454 *OriginalDecl = Redecl;
455 return RedeclComment;
461 *OriginalDecl =
nullptr;
467 assert(Comment.
isDocumentation() || LangOpts.CommentOpts.ParseAllComments);
469 if (
const auto *D = dyn_cast<const Decl *>(Original)) {
479 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(DC)) {
484 for (
const auto *Ext : ID->known_extensions()) {
488 Redeclared.push_back(RedeclaredMethod);
495 if (
Comments.empty() || Decls.empty())
499 for (
const Decl *D : Decls) {
500 if (D->isInvalidDecl())
508 File = SourceMgr.getDecomposedLoc(Loc).first;
513 if (
File.isInvalid())
516 auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
517 if (!CommentsInThisFile || CommentsInThisFile->empty() ||
518 CommentsInThisFile->rbegin()->second->isAttached())
528 for (
const Decl *D : Decls) {
530 if (D->isInvalidDecl())
540 for (
const auto DeclLoc : DeclLocs) {
541 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
556 const Decl *D)
const {
559 ThisDeclInfo->IsFilled =
false;
560 ThisDeclInfo->fill();
561 ThisDeclInfo->CommentDecl = FC->
getDecl();
562 if (!ThisDeclInfo->TemplateParameters)
572 return RC ? RC->
parse(*
this,
nullptr, D) :
nullptr;
583 llvm::DenseMap<const Decl *, comments::FullComment *>::iterator Pos =
587 if (Canonical != D) {
595 const Decl *OriginalDecl =
nullptr;
601 const auto *OMD = dyn_cast<ObjCMethodDecl>(D);
602 if (OMD && OMD->isPropertyAccessor())
609 for (
unsigned i = 0, e = Overridden.size(); i < e; i++)
613 else if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
616 QualType QT = TD->getUnderlyingType();
617 if (
const auto *TT = QT->
getAs<TagType>())
621 else if (
const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
622 while (IC->getSuperClass()) {
623 IC = IC->getSuperClass();
628 else if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(D)) {
633 else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
634 if (!(RD = RD->getDefinition()))
637 for (
const auto &I : RD->bases()) {
638 if (I.isVirtual() || (I.getAccessSpecifier() !=
AS_public))
652 for (
const auto &I : RD->vbases()) {
673 if (D != OriginalDecl && OriginalDecl)
681void ASTContext::CanonicalTemplateTemplateParm::Profile(
690 ID.AddInteger(Params->
size());
692 PEnd = Params->
end();
694 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
696 ID.AddBoolean(TTP->isParameterPack());
698 TTP->getNumExpansionParameters().toInternalRepresentation());
702 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
704 ID.AddBoolean(NTTP->isParameterPack());
705 ID.AddPointer(
C.getUnconstrainedType(
C.getCanonicalType(NTTP->getType()))
707 if (NTTP->isExpandedParameterPack()) {
709 ID.AddInteger(NTTP->getNumExpansionTypes());
710 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
712 ID.AddPointer(
T.getCanonicalType().getAsOpaquePtr());
715 ID.AddBoolean(
false);
725TemplateTemplateParmDecl *
729 llvm::FoldingSetNodeID ID;
730 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
731 llvm::FoldingSetInsertToken
Token;
732 CanonicalTemplateTemplateParm *Canonical =
733 CanonTemplateTemplateParms.lookup(ID,
Token);
735 return Canonical->getParam();
740 CanonParams.reserve(Params->
size());
742 PEnd = Params->
end();
746 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
751 TTP->getNumExpansionParameters());
752 CanonParams.push_back(NewTTP);
753 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
757 if (NTTP->isExpandedParameterPack()) {
760 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
762 ExpandedTInfos.push_back(
770 NTTP->getPosition(),
nullptr,
780 NTTP->getPosition(),
nullptr,
782 NTTP->isParameterPack(),
785 CanonParams.push_back(Param);
801 Canonical = CanonTemplateTemplateParms.lookup(ID,
Token);
802 assert(!Canonical &&
"Shouldn't be in the map!");
806 Canonical =
new (*this) CanonicalTemplateTemplateParm(CanonTTP);
807 CanonTemplateTemplateParms.insert(Canonical,
Token);
814 llvm::FoldingSetNodeID ID;
815 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
816 llvm::FoldingSetInsertToken
Token;
817 CanonicalTemplateTemplateParm *Canonical =
818 CanonTemplateTemplateParms.lookup(ID,
Token);
819 return Canonical ? Canonical->getParam() :
nullptr;
825 llvm::FoldingSetNodeID ID;
826 CanonicalTemplateTemplateParm::Profile(ID, *
this, CanonTTP);
827 llvm::FoldingSetInsertToken
Token;
828 if (
auto *Existing = CanonTemplateTemplateParms.lookup(ID,
Token))
829 return Existing->getParam();
830 CanonTemplateTemplateParms.insert(
831 new (*
this) CanonicalTemplateTemplateParm(CanonTTP),
Token);
852 [](
const DynTypedNode &P) { return P.get<WhileStmt>() != nullptr; });
876 return NoSanitizeL->containsType(Mask, TyName);
885 if (!LangOpts.CPlusPlus)
return nullptr;
888 case TargetCXXABI::AppleARM64:
889 case TargetCXXABI::Fuchsia:
890 case TargetCXXABI::GenericARM:
891 case TargetCXXABI::iOS:
892 case TargetCXXABI::WatchOS:
893 case TargetCXXABI::GenericAArch64:
894 case TargetCXXABI::GenericMIPS:
895 case TargetCXXABI::GenericItanium:
896 case TargetCXXABI::WebAssembly:
897 case TargetCXXABI::XL:
899 case TargetCXXABI::Microsoft:
902 llvm_unreachable(
"Invalid CXXABI type!");
906 if (!InterpContext) {
909 return *InterpContext;
914 switch (LangOpts.getAddressSpaceMapMangling()) {
922 llvm_unreachable(
"getAddressSpaceMapMangling() doesn't cover anything.");
928 : ConstantArrayTypes(this_(), ConstantArrayTypesLog2InitSize),
929 DependentSizedArrayTypes(this_()), DependentSizedExtVectorTypes(this_()),
930 DependentAddressSpaceTypes(this_()), DependentVectorTypes(this_()),
931 DependentSizedMatrixTypes(this_()),
932 FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
933 DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
934 DependentPackIndexingTypes(this_()), TemplateSpecializationTypes(this_()),
935 AttributedTypes(this_()), DependentBitIntTypes(this_()),
936 HLSLAttributedResourceTypes(this_()),
937 SubstTemplateTemplateParmPacks(this_()), DeducedTemplates(this_()),
938 PackIndexingTemplates(this_()), ArrayParameterTypes(this_()),
939 CanonTemplateTemplateParms(this_()), SourceMgr(SM), LangOpts(LOpts),
942 LangOpts.XRayNeverInstrumentFiles,
943 LangOpts.XRayAttrListFiles, SM)),
944 ProfList(new
ProfileList(LangOpts.ProfileListFiles, SM)),
948 CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
956 ReleaseDeclContextMaps();
959 for (
auto &Pair : Deallocations)
960 (Pair.first)(Pair.second);
961 Deallocations.clear();
967 I = ObjCLayouts.begin(),
968 E = ObjCLayouts.end();
975 for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
976 I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
981 ASTRecordLayouts.clear();
983 CtorClosureDefaultArgs.clear();
985 for (
const auto &
Value : ModuleInitializers)
986 Value.second->~PerModuleInitializers();
987 ModuleInitializers.
clear();
997 TraversalScope = TopLevelDecls;
1011 llvm::errs() <<
"\n*** AST Context Stats:\n";
1012 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
1014 unsigned counts[] = {
1015#define TYPE(Name, Parent) 0,
1016#define ABSTRACT_TYPE(Name, Parent)
1017#include "clang/AST/TypeNodes.inc"
1021 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
1027 unsigned TotalBytes = 0;
1028#define TYPE(Name, Parent) \
1030 llvm::errs() << " " << counts[Idx] << " " << #Name \
1031 << " types, " << sizeof(Name##Type) << " each " \
1032 << "(" << counts[Idx] * sizeof(Name##Type) \
1034 TotalBytes += counts[Idx] * sizeof(Name##Type); \
1036#define ABSTRACT_TYPE(Name, Parent)
1037#include "clang/AST/TypeNodes.inc"
1039 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
1044 <<
" implicit default constructors created\n";
1047 <<
" implicit copy constructors created\n";
1051 <<
" implicit move constructors created\n";
1054 <<
" implicit copy assignment operators created\n";
1058 <<
" implicit move assignment operators created\n";
1061 <<
" implicit destructors created\n";
1064 llvm::errs() <<
"\n";
1068 BumpAlloc.PrintStats();
1072 bool NotifyListeners) {
1073 if (NotifyListeners)
1076 Listener->RedefinedHiddenDefinition(ND, M);
1083 if (It == MergedDefModules.end())
1086 auto &Merged = It->second;
1087 llvm::DenseSet<Module*>
Found;
1088 for (
Module *&M : Merged)
1089 if (!
Found.insert(M).second)
1091 llvm::erase(Merged,
nullptr);
1098 if (MergedIt == MergedDefModules.end())
1100 return MergedIt->second;
1103void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1104 if (LazyInitializers.empty())
1108 assert(Source &&
"lazy initializers but no external source");
1110 auto LazyInits = std::move(LazyInitializers);
1111 LazyInitializers.clear();
1113 for (
auto ID : LazyInits)
1114 Initializers.push_back(Source->GetExternalDecl(ID));
1116 assert(LazyInitializers.empty() &&
1117 "GetExternalDecl for lazy module initializer added more inits");
1123 if (
const auto *ID = dyn_cast<ImportDecl>(D)) {
1124 auto It = ModuleInitializers.find(ID->getImportedModule());
1127 if (It == ModuleInitializers.end())
1131 auto &Imported = *It->second;
1132 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1133 Imported.resolve(*
this);
1134 auto *OnlyDecl = Imported.Initializers.front();
1140 auto *&
Inits = ModuleInitializers[M];
1142 Inits =
new (*this) PerModuleInitializers;
1143 Inits->Initializers.push_back(D);
1148 auto *&
Inits = ModuleInitializers[M];
1150 Inits =
new (*this) PerModuleInitializers;
1151 Inits->LazyInitializers.insert(
Inits->LazyInitializers.end(),
1152 IDs.begin(), IDs.end());
1156 auto It = ModuleInitializers.find(M);
1157 if (It == ModuleInitializers.end())
1160 auto *
Inits = It->second;
1161 Inits->resolve(*
this);
1162 return Inits->Initializers;
1167 assert(!CurrentCXXNamedModule &&
1168 "We should set named module for ASTContext for only once");
1169 CurrentCXXNamedModule = M;
1181 auto GetRepresentativeModule = [
this](
const Module *M) {
1182 auto Iter = SameModuleLookupSet.find(M);
1183 if (Iter != SameModuleLookupSet.end())
1184 return Iter->second;
1186 const Module *RepresentativeModule =
1187 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1189 SameModuleLookupSet[M] = RepresentativeModule;
1190 return RepresentativeModule;
1193 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1194 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1198 if (!ExternCContext)
1201 return ExternCContext;
1215#define BuiltinTemplate(BTName) \
1216 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1217 if (!Decl##BTName) \
1219 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1220 return Decl##BTName; \
1222#include "clang/Basic/BuiltinTemplates.inc"
1235 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1236 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1241 StringRef Name)
const {
1265 Types.push_back(Ty);
1270 assert((!this->Target || this->Target == &Target) &&
1271 "Incorrect target reinitialization");
1272 assert(
VoidTy.isNull() &&
"Context reinitialized?");
1274 this->Target = &Target;
1275 this->AuxTarget = AuxTarget;
1277 ABI.reset(createCXXABI(Target));
1281 InitBuiltinType(
VoidTy, BuiltinType::Void);
1284 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1286 if (LangOpts.CharIsSigned)
1287 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1289 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1292 InitBuiltinType(
ShortTy, BuiltinType::Short);
1293 InitBuiltinType(
IntTy, BuiltinType::Int);
1294 InitBuiltinType(
LongTy, BuiltinType::Long);
1295 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1305 InitBuiltinType(
FloatTy, BuiltinType::Float);
1306 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1307 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1310 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1313 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1316 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1319 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1320 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1321 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1325 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1326 InitBuiltinType(
FractTy, BuiltinType::Fract);
1327 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1332 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1338 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1345 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1350 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1352 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1353 if (LangOpts.CPlusPlus && LangOpts.WChar)
1357 WideCharTy = getFromTargetType(Target.getWCharType());
1360 WIntTy = getFromTargetType(Target.getWIntType());
1363 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1365 if (LangOpts.CPlusPlus)
1366 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1368 Char16Ty = getFromTargetType(Target.getChar16Type());
1370 if (LangOpts.CPlusPlus)
1371 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1373 Char32Ty = getFromTargetType(Target.getChar32Type());
1380 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1383 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1395 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1401 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1404 if (LangOpts.OpenMP) {
1411 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1414 if (LangOpts.MatrixTypes)
1422 if (LangOpts.OpenCL) {
1423#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1424 InitBuiltinType(SingletonId, BuiltinType::Id);
1425#include "clang/Basic/OpenCLImageTypes.def"
1427 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1428 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1430 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1433#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1434 InitBuiltinType(Id##Ty, BuiltinType::Id);
1435#include "clang/Basic/OpenCLExtensionTypes.def"
1438 if (LangOpts.HLSL) {
1439#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1440 InitBuiltinType(SingletonId, BuiltinType::Id);
1441#include "clang/Basic/HLSLIntangibleTypes.def"
1443#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
1444 InitBuiltinType(SingletonId, BuiltinType::Id);
1445#include "clang/Basic/HLSLPackedTypes.def"
1448 if (Target.hasAArch64ACLETypes() ||
1449 (AuxTarget && AuxTarget->hasAArch64ACLETypes())) {
1450#define SVE_TYPE(Name, Id, SingletonId) \
1451 InitBuiltinType(SingletonId, BuiltinType::Id);
1452#include "clang/Basic/AArch64ACLETypes.def"
1455 if (Target.getTriple().isPPC64()) {
1456#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1457 InitBuiltinType(Id##Ty, BuiltinType::Id);
1458#include "clang/Basic/PPCTypes.def"
1459#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1460 InitBuiltinType(Id##Ty, BuiltinType::Id);
1461#include "clang/Basic/PPCTypes.def"
1464 if (Target.hasRISCVVTypes()) {
1465#define RVV_TYPE(Name, Id, SingletonId) \
1466 InitBuiltinType(SingletonId, BuiltinType::Id);
1467#include "clang/Basic/RISCVVTypes.def"
1470 if (Target.getTriple().isWasm() && Target.hasFeature(
"reference-types")) {
1471#define WASM_TYPE(Name, Id, SingletonId) \
1472 InitBuiltinType(SingletonId, BuiltinType::Id);
1473#include "clang/Basic/WebAssemblyReferenceTypes.def"
1476 if (Target.hasAMDGPUTypes() || (AuxTarget && (AuxTarget->hasAMDGPUTypes()))) {
1477#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1478 InitBuiltinType(SingletonId, BuiltinType::Id);
1479#include "clang/Basic/AMDGPUTypes.def"
1482 if (Target.getTriple().isSPIRV() ||
1483 (AuxTarget && AuxTarget->getTriple().isSPIRV())) {
1484#define SPIRV_TYPE(Name, Id, SingletonId) \
1485 InitBuiltinType(SingletonId, BuiltinType::Id);
1486#include "clang/Basic/SPIRVTypes.def"
1493 ObjCConstantStringType =
QualType();
1498 if (LangOpts.OpenCLGenericAddressSpace) {
1499 auto Q =
VoidTy.getQualifiers();
1508 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1511 InitBuiltinType(
MetaInfoTy, BuiltinType::MetaInfo);
1514 InitBuiltinType(
HalfTy, BuiltinType::Half);
1516 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1522 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1529 return SourceMgr.getDiagnostics();
1533 return new (DeclAttrAllocator.Allocate())
AttrVec;
1538 return CtorClosureDefaultArgs.lookup(CD);
1543 assert(!CtorClosureDefaultArgs.contains(CD));
1544 CtorClosureDefaultArgs[CD] = Args;
1551 if (It != ExplicitInstantiations.end())
1564 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1565 TemplateOrInstantiation.find(Var);
1566 if (Pos == TemplateOrInstantiation.end())
1579 Tmpl, TSK, PointOfInstantiation));
1585 assert(!TemplateOrInstantiation[Inst] &&
1586 "Already noted what the variable was instantiated from");
1587 TemplateOrInstantiation[Inst] = TSI;
1592 return InstantiatedFromUsingDecl.lookup(UUD);
1600 "pattern decl is not a using decl");
1604 "instantiation did not produce a using decl");
1605 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1606 InstantiatedFromUsingDecl[Inst] = Pattern;
1611 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1616 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1617 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1622 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1628 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1629 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1634 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1640 "Instantiated field decl is not unnamed");
1642 "Template field decl is not unnamed");
1643 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1644 "Already noted what unnamed field was instantiated from");
1646 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1662 return Range.end() - Range.begin();
1667 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1668 OverriddenMethods.find(
Method->getCanonicalDecl());
1669 if (Pos == OverriddenMethods.end())
1677 OverriddenMethods[
Method].push_back(Overridden);
1685 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1691 const auto *
Method = dyn_cast<ObjCMethodDecl>(D);
1696 Method->getOverriddenMethods(OverDecls);
1697 Overridden.append(OverDecls.begin(), OverDecls.end());
1700std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1704 auto it = RelocatableClasses.find(D);
1705 if (it != RelocatableClasses.end())
1706 return it->getSecond();
1707 return std::nullopt;
1714 assert(RelocatableClasses.find(D) == RelocatableClasses.end());
1715 RelocatableClasses.insert({D, Info});
1720 if (!Class->isPolymorphic())
1722 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
1723 using AuthAttr = VTablePointerAuthenticationAttr;
1724 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1726 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1727 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1728 ExplicitAuth->getAddressDiscrimination();
1729 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1730 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1731 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1734ASTContext::PointerAuthContent
1735ASTContext::findPointerAuthContent(QualType
T)
const {
1736 assert(isPointerAuthenticationAvailable());
1738 T =
T.getCanonicalType();
1740 return PointerAuthContent::None;
1742 if (
T.hasAddressDiscriminatedPointerAuth())
1743 return PointerAuthContent::AddressDiscriminatedData;
1746 return PointerAuthContent::None;
1749 return PointerAuthContent::None;
1751 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1752 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1753 return Existing->second;
1755 PointerAuthContent
Result = PointerAuthContent::None;
1757 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1758 auto [ResultIter, DidAdd] =
1759 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1765 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1766 static_assert(PointerAuthContent::None <
1767 PointerAuthContent::AddressDiscriminatedVTable);
1768 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1769 PointerAuthContent::AddressDiscriminatedData);
1772 return Result != PointerAuthContent::AddressDiscriminatedData;
1774 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1776 !ShouldContinueAfterUpdate(
1777 PointerAuthContent::AddressDiscriminatedVTable))
1778 return SaveResultAndReturn();
1779 for (
auto Base : CXXRD->bases()) {
1780 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1781 return SaveResultAndReturn();
1784 for (
auto *FieldDecl : RD->
fields()) {
1785 if (!ShouldContinueAfterUpdate(
1786 findPointerAuthContent(FieldDecl->getType())))
1787 return SaveResultAndReturn();
1789 return SaveResultAndReturn();
1793 assert(!Import->getNextLocalImport() &&
1794 "Import declaration already in the chain");
1795 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1796 if (!FirstLocalImport) {
1797 FirstLocalImport = Import;
1798 LastLocalImport = Import;
1802 LastLocalImport->setNextLocalImport(Import);
1803 LastLocalImport = Import;
1815 llvm_unreachable(
"Not a floating point type!");
1816 case BuiltinType::BFloat16:
1817 return Target->getBFloat16Format();
1818 case BuiltinType::Float16:
1819 return Target->getHalfFormat();
1820 case BuiltinType::Half:
1821 return Target->getHalfFormat();
1822 case BuiltinType::Float:
return Target->getFloatFormat();
1823 case BuiltinType::Double:
return Target->getDoubleFormat();
1824 case BuiltinType::Ibm128:
1825 return Target->getIbm128Format();
1826 case BuiltinType::LongDouble:
1828 return AuxTarget->getLongDoubleFormat();
1829 return Target->getLongDoubleFormat();
1830 case BuiltinType::Float128:
1832 return AuxTarget->getFloat128Format();
1833 return Target->getFloat128Format();
1838 unsigned Align = Target->getCharWidth();
1842 Align = AlignFromAttr;
1850 bool UseAlignAttrOnly;
1851 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1853 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1855 UseAlignAttrOnly = AlignFromAttr != 0;
1858 if (UseAlignAttrOnly) {
1860 }
else if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
1864 T = RT->getPointeeType();
1869 if (
T->isFunctionType())
1870 Align = getTypeInfoImpl(
T.getTypePtr()).Align;
1875 unsigned MinWidth = Target->getLargeArrayMinWidth();
1876 if (!ForAlignof && MinWidth) {
1878 Align = std::max(Align, Target->getLargeArrayAlign());
1881 Align = std::max(Align, Target->getLargeArrayAlign());
1886 Align = Target->getCharWidth();
1890 if (
const auto *VD = dyn_cast<VarDecl>(D))
1891 if (VD->hasGlobalStorage() && !ForAlignof) {
1902 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1916 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1917 if (LowBitOfOffset < FieldAlign)
1918 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1921 Align = std::min(Align, FieldAlign);
1929 const auto *VD = dyn_cast<VarDecl>(D);
1930 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1931 Align = std::min(Align, MaxAlignedAttr);
1951 if (
const auto *RD =
T->getAsCXXRecordDecl(); RD && !RD->
isInvalidDecl()) {
1968 (uint64_t)(-1)/Size) &&
1969 "Overflow in array type char size evaluation");
1972 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
1974 Width = llvm::alignTo(Width, Align);
1981 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
1999 switch (BT->getKind()) {
2000 case BuiltinType::Bool:
2001 case BuiltinType::Char_S:
2002 case BuiltinType::Char_U:
2003 case BuiltinType::SChar:
2004 case BuiltinType::UChar:
2005 case BuiltinType::Short:
2006 case BuiltinType::UShort:
2007 case BuiltinType::WChar_S:
2008 case BuiltinType::WChar_U:
2009 case BuiltinType::Char8:
2010 case BuiltinType::Char16:
2011 case BuiltinType::Char32:
2019 if (
const auto *ED =
T->getAsEnumDecl()) {
2020 if (
T->isDependentType() || ED->getPromotionType().isNull() ||
2028 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>()) {
2044 bool NeedsPreferredAlignment)
const {
2047 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2052 if (!
T->isIncompleteType())
2058 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2062 if (
const auto *TD =
T->getAsTagDecl())
2063 return TD->getMaxAlignment();
2069 TypeInfoMap::iterator I = MemoizedTypeInfo.find(
T);
2070 if (I != MemoizedTypeInfo.end())
2075 MemoizedTypeInfo[
T] = TI;
2090 switch (
T->getTypeClass()) {
2091#define TYPE(Class, Base)
2092#define ABSTRACT_TYPE(Class, Base)
2093#define NON_CANONICAL_TYPE(Class, Base)
2094#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2095#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
2097 assert(!T->isDependentType() && "should not see dependent types here"); \
2098 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
2099#include "clang/AST/TypeNodes.inc"
2100 llvm_unreachable(
"Should not see dependent types");
2102 case Type::FunctionNoProto:
2103 case Type::FunctionProto:
2109 case Type::IncompleteArray:
2110 case Type::VariableArray:
2111 case Type::ConstantArray:
2112 case Type::ArrayParameter: {
2115 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2116 Size = CAT->getZExtSize();
2119 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2120 "Overflow in array type bit size evaluation");
2121 Width = EltInfo.
Width * Size;
2122 Align = EltInfo.
Align;
2126 Width = llvm::alignTo(Width, Align);
2130 case Type::ExtVector:
2131 case Type::Vector: {
2134 Width = VT->isPackedVectorBoolType(*
this)
2135 ? VT->getNumElements()
2136 : EltInfo.
Width * VT->getNumElements();
2138 Width = std::max<unsigned>(8, Width);
2139 Align = std::max<unsigned>(
2140 8,
Target->vectorsAreElementAligned() ? EltInfo.
Width : Width);
2144 if (Align & (Align-1)) {
2145 Align = llvm::bit_ceil(Align);
2146 Width = llvm::alignTo(Width, Align);
2149 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
2150 if (TargetVectorAlign && TargetVectorAlign < Align)
2151 Align = TargetVectorAlign;
2161 Align = std::min<unsigned>(64, Width);
2168 case Type::ConstantMatrix: {
2170 TypeInfo ElementInfo =
getTypeInfo(MT->getElementType());
2174 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2175 Align = ElementInfo.
Align;
2181 default: llvm_unreachable(
"Unknown builtin type!");
2182 case BuiltinType::Void:
2187 case BuiltinType::Bool:
2188 Width = Target->getBoolWidth();
2189 Align = Target->getBoolAlign();
2191 case BuiltinType::Char_S:
2192 case BuiltinType::Char_U:
2193 case BuiltinType::UChar:
2194 case BuiltinType::SChar:
2195 case BuiltinType::Char8:
2196 Width = Target->getCharWidth();
2197 Align = Target->getCharAlign();
2199 case BuiltinType::WChar_S:
2200 case BuiltinType::WChar_U:
2201 Width = Target->getWCharWidth();
2202 Align = Target->getWCharAlign();
2204 case BuiltinType::Char16:
2205 Width = Target->getChar16Width();
2206 Align = Target->getChar16Align();
2208 case BuiltinType::Char32:
2209 Width = Target->getChar32Width();
2210 Align = Target->getChar32Align();
2212 case BuiltinType::UShort:
2213 case BuiltinType::Short:
2214 Width = Target->getShortWidth();
2215 Align = Target->getShortAlign();
2217 case BuiltinType::UInt:
2218 case BuiltinType::Int:
2219 Width = Target->getIntWidth();
2220 Align = Target->getIntAlign();
2222 case BuiltinType::ULong:
2223 case BuiltinType::Long:
2224 Width = Target->getLongWidth();
2225 Align = Target->getLongAlign();
2227 case BuiltinType::ULongLong:
2228 case BuiltinType::LongLong:
2229 Width = Target->getLongLongWidth();
2230 Align = Target->getLongLongAlign();
2232 case BuiltinType::Int128:
2233 case BuiltinType::UInt128:
2235 Align = Target->getInt128Align();
2237 case BuiltinType::ShortAccum:
2238 case BuiltinType::UShortAccum:
2239 case BuiltinType::SatShortAccum:
2240 case BuiltinType::SatUShortAccum:
2241 Width = Target->getShortAccumWidth();
2242 Align = Target->getShortAccumAlign();
2244 case BuiltinType::Accum:
2245 case BuiltinType::UAccum:
2246 case BuiltinType::SatAccum:
2247 case BuiltinType::SatUAccum:
2248 Width = Target->getAccumWidth();
2249 Align = Target->getAccumAlign();
2251 case BuiltinType::LongAccum:
2252 case BuiltinType::ULongAccum:
2253 case BuiltinType::SatLongAccum:
2254 case BuiltinType::SatULongAccum:
2255 Width = Target->getLongAccumWidth();
2256 Align = Target->getLongAccumAlign();
2258 case BuiltinType::ShortFract:
2259 case BuiltinType::UShortFract:
2260 case BuiltinType::SatShortFract:
2261 case BuiltinType::SatUShortFract:
2262 Width = Target->getShortFractWidth();
2263 Align = Target->getShortFractAlign();
2265 case BuiltinType::Fract:
2266 case BuiltinType::UFract:
2267 case BuiltinType::SatFract:
2268 case BuiltinType::SatUFract:
2269 Width = Target->getFractWidth();
2270 Align = Target->getFractAlign();
2272 case BuiltinType::LongFract:
2273 case BuiltinType::ULongFract:
2274 case BuiltinType::SatLongFract:
2275 case BuiltinType::SatULongFract:
2276 Width = Target->getLongFractWidth();
2277 Align = Target->getLongFractAlign();
2279 case BuiltinType::BFloat16:
2280 if (Target->hasBFloat16Type()) {
2281 Width = Target->getBFloat16Width();
2282 Align = Target->getBFloat16Align();
2286 AuxTarget->hasBFloat16Type()) {
2287 Width = AuxTarget->getBFloat16Width();
2288 Align = AuxTarget->getBFloat16Align();
2291 case BuiltinType::Float16:
2292 case BuiltinType::Half:
2293 if (Target->hasFloat16Type() || !
getLangOpts().OpenMP ||
2295 Width = Target->getHalfWidth();
2296 Align = Target->getHalfAlign();
2299 "Expected OpenMP device compilation.");
2300 Width = AuxTarget->getHalfWidth();
2301 Align = AuxTarget->getHalfAlign();
2304 case BuiltinType::Float:
2305 Width = Target->getFloatWidth();
2306 Align = Target->getFloatAlign();
2308 case BuiltinType::Double:
2309 Width = Target->getDoubleWidth();
2310 Align = Target->getDoubleAlign();
2312 case BuiltinType::Ibm128:
2313 Width = Target->getIbm128Width();
2314 Align = Target->getIbm128Align();
2316 case BuiltinType::LongDouble:
2318 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2319 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2320 Width = AuxTarget->getLongDoubleWidth();
2321 Align = AuxTarget->getLongDoubleAlign();
2323 Width = Target->getLongDoubleWidth();
2324 Align = Target->getLongDoubleAlign();
2328 if (&Target->getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended())
2331 case BuiltinType::Float128:
2332 if (Target->hasFloat128Type() || !
getLangOpts().OpenMP ||
2334 Width = Target->getFloat128Width();
2335 Align = Target->getFloat128Align();
2338 "Expected OpenMP device compilation.");
2339 Width = AuxTarget->getFloat128Width();
2340 Align = AuxTarget->getFloat128Align();
2343 case BuiltinType::NullPtr:
2348 case BuiltinType::MetaInfo:
2354 case BuiltinType::ObjCId:
2355 case BuiltinType::ObjCClass:
2356 case BuiltinType::ObjCSel:
2360 case BuiltinType::OCLSampler:
2361 case BuiltinType::OCLEvent:
2362 case BuiltinType::OCLClkEvent:
2363 case BuiltinType::OCLQueue:
2364 case BuiltinType::OCLReserveID:
2365#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2366 case BuiltinType::Id:
2367#include "clang/Basic/OpenCLImageTypes.def"
2368#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2369 case BuiltinType::Id:
2370#include "clang/Basic/OpenCLExtensionTypes.def"
2372 Width = Target->getPointerWidth(AS);
2373 Align = Target->getPointerAlign(AS);
2383#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2384 case BuiltinType::Id: \
2388#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2389 case BuiltinType::Id: \
2393#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2394 case BuiltinType::Id: \
2398#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2399 case BuiltinType::Id: \
2403#include "clang/Basic/AArch64ACLETypes.def"
2404#define PPC_VECTOR_TYPE(Name, Id, Size) \
2405 case BuiltinType::Id: \
2409#include "clang/Basic/PPCTypes.def"
2410#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2412 case BuiltinType::Id: \
2416#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2417 case BuiltinType::Id: \
2421#include "clang/Basic/RISCVVTypes.def"
2422#define WASM_TYPE(Name, Id, SingletonId) \
2423 case BuiltinType::Id: \
2427#include "clang/Basic/WebAssemblyReferenceTypes.def"
2428#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2429 case BuiltinType::ID: \
2433#include "clang/Basic/AMDGPUTypes.def"
2434#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2435#include "clang/Basic/HLSLIntangibleTypes.def"
2439#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2440#include "clang/Basic/HLSLPackedTypes.def"
2444#define SPIRV_TYPE(Name, Id, SingletonId) \
2445 case BuiltinType::Id: \
2446 Width = Target->getPointerWidth(LangAS::Default); \
2447 Align = Target->getPointerAlign(LangAS::Default); \
2449#include "clang/Basic/SPIRVTypes.def"
2452 case Type::ObjCObjectPointer:
2456 case Type::BlockPointer:
2458 Width = Target->getPointerWidth(AS);
2459 Align = Target->getPointerAlign(AS);
2461 case Type::LValueReference:
2462 case Type::RValueReference:
2466 Width = Target->getPointerWidth(AS);
2467 Align = Target->getPointerAlign(AS);
2471 Width = Target->getPointerWidth(AS);
2472 Align = Target->getPointerAlign(AS);
2474 case Type::MemberPointer: {
2476 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2481 case Type::Complex: {
2485 Width = EltInfo.
Width * 2;
2486 Align = EltInfo.
Align;
2489 case Type::ObjCObject:
2491 case Type::Adjusted:
2494 case Type::ObjCInterface: {
2496 if (ObjCI->getDecl()->isInvalidDecl()) {
2506 case Type::BitInt: {
2508 Align = Target->getBitIntAlign(EIT->getNumBits());
2509 Width = Target->getBitIntWidth(EIT->getNumBits());
2515 const TagDecl *TD = TT->getDecl()->getDefinitionOrSelf();
2528 Info.
Align = AttrAlign;
2538 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2544 case Type::SubstTemplateTypeParm:
2546 getReplacementType().getTypePtr());
2549 case Type::DeducedTemplateSpecialization: {
2551 assert(!A->getDeducedType().isNull() &&
2552 "cannot request the size of an undeduced or dependent auto type");
2553 return getTypeInfo(A->getDeducedType().getTypePtr());
2559 case Type::MacroQualified:
2563 case Type::ObjCTypeParam:
2569 case Type::Typedef: {
2571 TypeInfo Info =
getTypeInfo(TT->desugar().getTypePtr());
2575 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2586 case Type::Attributed:
2590 case Type::CountAttributed:
2593 case Type::LateParsedAttr:
2596 case Type::BTFTagAttributed:
2600 case Type::OverflowBehavior:
2604 case Type::HLSLAttributedResource:
2608 case Type::HLSLInlineSpirv: {
2611 Width = ST->getSize() * 8;
2612 Align = ST->getAlignment();
2613 if (Width == 0 && Align == 0) {
2621 case Type::Atomic: {
2630 Width = Target->getCharWidth();
2632 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2638 Width = llvm::bit_ceil(Width);
2641 Align =
static_cast<unsigned>(Width);
2646 case Type::PredefinedSugar:
2655 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2656 return TypeInfo(Width, Align, AlignRequirement);
2660 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(
T);
2661 if (I != MemoizedUnadjustedAlign.end())
2664 unsigned UnadjustedAlign;
2665 if (
const auto *RT =
T->getAsCanonical<RecordType>()) {
2672 UnadjustedAlign =
getTypeAlign(
T->getUnqualifiedDesugaredType());
2675 MemoizedUnadjustedAlign[
T] = UnadjustedAlign;
2676 return UnadjustedAlign;
2680 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2730 unsigned ABIAlign = TI.
Align;
2732 T =
T->getBaseElementTypeUnsafe();
2735 if (
T->isMemberPointerType())
2738 if (!Target->allowsLargerPreferedTypeAlignment())
2741 if (
const auto *RD =
T->getAsRecordDecl()) {
2750 unsigned PreferredAlign =
static_cast<unsigned>(
2752 assert(PreferredAlign >= ABIAlign &&
2753 "PreferredAlign should be at least as large as ABIAlign.");
2754 return PreferredAlign;
2761 T = CT->getElementType().getTypePtr();
2762 if (
const auto *ED =
T->getAsEnumDecl())
2763 T = ED->getIntegerType().getTypePtr();
2764 if (
T->isSpecificBuiltinType(BuiltinType::Double) ||
2765 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2766 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2767 (
T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2768 Target->defaultsToAIXPowerAlignment()))
2823 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
2827 std::swap(
Base, Derived);
2847 llvm::append_range(Ivars, OI->
ivars());
2850 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2852 Ivars.push_back(Iv);
2860 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2863 for (
auto *Proto : OI->all_referenced_protocols()) {
2868 for (
const auto *Cat : OI->visible_categories())
2874 SD = SD->getSuperClass();
2876 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2877 for (
auto *Proto : OC->protocols()) {
2880 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2882 if (!Protocols.insert(
2886 for (
auto *Proto : OP->protocols())
2893 bool CheckIfTriviallyCopyable) {
2894 assert(RD->
isUnion() &&
"Must be union type");
2896 Context.getTypeSizeInChars(Context.getCanonicalTagType(RD));
2898 for (
const auto *Field : RD->
fields()) {
2899 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2900 CheckIfTriviallyCopyable))
2902 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2903 if (FieldSize != UnionSize)
2912 return Context.getFieldOffset(Field);
2921static std::optional<int64_t>
2923 const RecordDecl *RD,
2924 bool CheckIfTriviallyCopyable);
2926static std::optional<int64_t>
2928 bool CheckIfTriviallyCopyable) {
2929 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2932 CheckIfTriviallyCopyable);
2936 bool IsBitIntType = Field->getType()->isBitIntType();
2937 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2938 !Context.hasUniqueObjectRepresentations(Field->getType(),
2939 CheckIfTriviallyCopyable))
2940 return std::nullopt;
2943 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2944 if (Field->isBitField()) {
2947 if (Field->isUnnamedBitField())
2950 int64_t BitfieldSize = Field->getBitWidthValue();
2952 if ((
unsigned)BitfieldSize >
2954 return std::nullopt;
2955 }
else if (BitfieldSize > FieldSizeInBits) {
2956 return std::nullopt;
2958 FieldSizeInBits = BitfieldSize;
2959 }
else if (IsBitIntType && !Context.hasUniqueObjectRepresentations(
2960 Field->getType(), CheckIfTriviallyCopyable)) {
2961 return std::nullopt;
2963 return FieldSizeInBits;
2966static std::optional<int64_t>
2968 bool CheckIfTriviallyCopyable) {
2970 CheckIfTriviallyCopyable);
2973template <
typename RangeT>
2975 const RangeT &Subobjects,
int64_t CurOffsetInBits,
2977 bool CheckIfTriviallyCopyable) {
2978 for (
const auto *Subobject : Subobjects) {
2979 std::optional<int64_t> SizeInBits =
2982 return std::nullopt;
2983 if (*SizeInBits != 0) {
2985 if (Offset != CurOffsetInBits)
2986 return std::nullopt;
2987 CurOffsetInBits += *SizeInBits;
2990 return CurOffsetInBits;
2993static std::optional<int64_t>
2996 bool CheckIfTriviallyCopyable) {
2997 assert(!RD->
isUnion() &&
"Must be struct/class type");
2998 const auto &Layout = Context.getASTRecordLayout(RD);
3001 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3002 if (ClassDecl->isDynamicClass())
3003 return std::nullopt;
3006 for (
const auto &
Base : ClassDecl->bases()) {
3009 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
3013 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
3016 std::optional<int64_t> OffsetAfterBases =
3018 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
3019 if (!OffsetAfterBases)
3020 return std::nullopt;
3021 CurOffsetInBits = *OffsetAfterBases;
3024 std::optional<int64_t> OffsetAfterFields =
3026 RD->
fields(), CurOffsetInBits, Context, Layout,
3027 CheckIfTriviallyCopyable);
3028 if (!OffsetAfterFields)
3029 return std::nullopt;
3030 CurOffsetInBits = *OffsetAfterFields;
3032 return CurOffsetInBits;
3036 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
3053 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
3058 CheckIfTriviallyCopyable);
3061 "hasUniqueObjectRepresentations should not be called with an "
3070 CheckIfTriviallyCopyable);
3093 return !ABI->getMemberPointerInfo(MPT).HasPadding;
3096 if (
Record->isInvalidDecl())
3101 CheckIfTriviallyCopyable);
3104 *
this,
Record, CheckIfTriviallyCopyable);
3106 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
3126 count += Ext->ivar_size();
3131 count += ImplDecl->ivar_size();
3157 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3158 I = ObjCImpls.find(D);
3159 if (I != ObjCImpls.end())
3167 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3168 I = ObjCImpls.find(D);
3169 if (I != ObjCImpls.end())
3177 assert(IFaceD && ImplD &&
"Passed null params");
3178 ObjCImpls[IFaceD] = ImplD;
3184 assert(CatD && ImplD &&
"Passed null params");
3185 ObjCImpls[CatD] = ImplD;
3190 return ObjCMethodRedecls.
lookup(MD);
3196 ObjCMethodRedecls[MD] = Redecl;
3201 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3203 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3204 return CD->getClassInterface();
3205 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3206 return IMD->getClassInterface();
3214 assert(VD &&
"Passed null params");
3215 assert(VD->
hasAttr<BlocksAttr>() &&
3216 "getBlockVarCopyInits - not __block var");
3217 auto I = BlockVarCopyInits.find(VD);
3218 if (I != BlockVarCopyInits.end())
3220 return {
nullptr,
false};
3226 assert(VD && CopyExpr &&
"Passed null params");
3227 assert(VD->
hasAttr<BlocksAttr>() &&
3228 "setBlockVarCopyInits - not __block var");
3229 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3233 unsigned DataSize)
const {
3238 "incorrect data size provided to CreateTypeSourceInfo!");
3255 return getObjCLayout(D);
3260 bool &AnyNonCanonArgs) {
3262 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3268 bool AnyNonCanonArgs =
false;
3269 for (
auto &Arg : Args) {
3272 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3274 return AnyNonCanonArgs;
3282ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3287 llvm::FoldingSetNodeID ID;
3289 llvm::FoldingSetInsertToken
Token;
3291 assert(eq->getQualifiers() == quals);
3300 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3303 (void)ExtQualNodes.lookup(ID,
Token);
3306 auto *eq =
new (*
this,
alignof(ExtQuals)) ExtQuals(baseType, canon, quals);
3307 ExtQualNodes.insert(eq, Token);
3308 return QualType(eq, fastQuals);
3312 LangAS AddressSpace)
const {
3325 "Type cannot be in multiple addr spaces!");
3328 return getExtQualType(TypeNode, Quals);
3334 if (!
T.hasAddressSpace())
3338 const Type *TypeNode;
3341 if (
T.getTypePtr()->isArrayType()) {
3343 TypeNode =
T.getTypePtr();
3347 while (
T.hasAddressSpace()) {
3348 TypeNode = Quals.
strip(
T);
3352 if (!
QualType(TypeNode, 0).hasAddressSpace())
3356 T =
T.getSingleStepDesugaredType(*
this);
3366 return getExtQualType(TypeNode, Quals);
3375 "Attempted to get vtable pointer discriminator on a monomorphic type");
3379 llvm::raw_svector_ostream Out(Str);
3380 MC->mangleCXXVTable(RD, Out);
3383 return llvm::getPointerAuthStableSipHash(Str);
3409 switch (
T->getTypeClass()) {
3414 case Type::LValueReference:
3419 case Type::RValueReference:
3433 case Type::ObjCObjectPointer:
3434 case Type::BlockPointer:
3443 case Type::VariableArray:
3444 case Type::ConstantArray:
3445 case Type::IncompleteArray:
3446 case Type::ArrayParameter:
3459 case Type::ObjCInterface:
3460 case Type::ObjCObject:
3461 OS <<
"<objc_object>";
3470 QualType UnderlyingType =
T->castAsEnumDecl()->getIntegerType();
3472 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3475 case Type::FunctionNoProto:
3476 case Type::FunctionProto: {
3492 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3493 for (
QualType Param : FPT->param_types()) {
3497 if (FPT->isVariadic())
3504 case Type::MemberPointer: {
3508 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3512 case Type::ExtVector:
3520 case Type::ConstantMatrix:
3524 case Type::Builtin: {
3526 switch (BTy->getKind()) {
3527#define SIGNED_TYPE(Id, SingletonId) \
3528 case BuiltinType::Id: \
3531#define UNSIGNED_TYPE(Id, SingletonId) \
3532 case BuiltinType::Id: \
3535#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3536#define BUILTIN_TYPE(Id, SingletonId)
3537#include "clang/AST/BuiltinTypes.def"
3538 llvm_unreachable(
"placeholder types should not appear here.");
3540 case BuiltinType::Half:
3543 case BuiltinType::Float:
3546 case BuiltinType::Double:
3549 case BuiltinType::LongDouble:
3552 case BuiltinType::Float16:
3555 case BuiltinType::Float128:
3559 case BuiltinType::Void:
3563 case BuiltinType::ObjCId:
3564 case BuiltinType::ObjCClass:
3565 case BuiltinType::ObjCSel:
3566 case BuiltinType::NullPtr:
3571 case BuiltinType::OCLSampler:
3572 case BuiltinType::OCLEvent:
3573 case BuiltinType::OCLClkEvent:
3574 case BuiltinType::OCLQueue:
3575 case BuiltinType::OCLReserveID:
3576 case BuiltinType::BFloat16:
3577 case BuiltinType::VectorQuad:
3578 case BuiltinType::VectorPair:
3579 case BuiltinType::DMR1024:
3580 case BuiltinType::DMR2048:
3581 case BuiltinType::MetaInfo:
3586 case BuiltinType::Ibm128:
3588#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3589 case BuiltinType::Id: \
3591#include "clang/Basic/OpenCLImageTypes.def"
3592#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3593 case BuiltinType::Id: \
3595#include "clang/Basic/OpenCLExtensionTypes.def"
3596#define SVE_TYPE(Name, Id, SingletonId) \
3597 case BuiltinType::Id: \
3599#include "clang/Basic/AArch64ACLETypes.def"
3600#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3601 case BuiltinType::Id: \
3603#include "clang/Basic/HLSLIntangibleTypes.def"
3604#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
3605 case BuiltinType::Id: \
3607#include "clang/Basic/HLSLPackedTypes.def"
3608 case BuiltinType::Dependent:
3609 llvm_unreachable(
"should never get here");
3610#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3611#include "clang/Basic/AMDGPUTypes.def"
3612 case BuiltinType::WasmExternRef:
3613#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3614#include "clang/Basic/RISCVVTypes.def"
3615#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3616#include "clang/Basic/SPIRVTypes.def"
3617 llvm_unreachable(
"not yet implemented");
3619 llvm_unreachable(
"should never get here");
3621 case Type::Record: {
3622 const RecordDecl *RD =
T->castAsCanonical<RecordType>()->getDecl();
3642 II = Typedef->getDeclName().getAsIdentifierInfo();
3645 OS <<
"<anonymous_record>";
3651 case Type::HLSLAttributedResource:
3652 case Type::HLSLInlineSpirv:
3653 llvm_unreachable(
"should never get here");
3655 case Type::OverflowBehavior:
3656 llvm_unreachable(
"should never get here");
3658 case Type::DeducedTemplateSpecialization:
3660#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3661#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3662#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3663#define ABSTRACT_TYPE(Class, Base)
3664#define TYPE(Class, Base)
3665#include "clang/AST/TypeNodes.inc"
3666 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3672 assert(!
T->isDependentType() &&
3673 "cannot compute type discriminator of a dependent type");
3675 llvm::raw_svector_ostream Out(Str);
3677 if (
T->isFunctionPointerType() ||
T->isFunctionReferenceType())
3678 T =
T->getPointeeType();
3680 if (
T->isFunctionType()) {
3683 T =
T.getUnqualifiedType();
3704 if (MPT->isMemberFunctionPointer()) {
3710 MPT->getMostRecentCXXRecordDecl());
3714 MC->mangleCanonicalTypeName(
T, Out);
3717 return llvm::getPointerAuthStableSipHash(Str);
3742 "Type cannot have multiple ObjCGCs!");
3745 return getExtQualType(TypeNode, Quals);
3750 QualType Pointee = Ptr->getPointeeType();
3759 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3762 assert(CountExpr &&
"use getIncompleteCountAttributedType for a null count");
3769 llvm::FoldingSetNodeID ID;
3772 llvm::FoldingSetInsertToken
Token;
3778 CATy = CountAttributedType::Create(*
this, WrappedTy, CanonTy, CountExpr,
3779 CountInBytes, OrNull, DependentDecls);
3780 Types.push_back(CATy);
3781 CountAttributedTypes.insert(CATy,
Token);
3787 QualType WrappedTy,
bool CountInBytes,
bool OrNull)
const {
3802 return CountAttributedType::Create(
3804 nullptr, CountInBytes, OrNull,
3811 CATy->complete(*
this, CountExpr, DependentDecls);
3822 Types.push_back(CATy);
3832 Types.push_back(LPATy);
3840 case Type::Attributed: {
3848 case Type::BTFTagAttributed: {
3849 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3854 case Type::OverflowBehavior: {
3855 const auto *OB = dyn_cast<OverflowBehaviorType>(Orig);
3857 adjustType(OB->getUnderlyingType(), Adjust));
3864 case Type::Adjusted: {
3870 case Type::MacroQualified: {
3873 MQT->getMacroIdentifier());
3877 return Adjust(Orig);
3883 if (
T->getExtInfo() == Info)
3887 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(
T)) {
3907 FPT->getExtProtoInfo());
3922 L->DeducedReturnType(FD, ResultType);
3933 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3934 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3950 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
3973 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
3999 if (TSInfo->getType() != FD->
getType())
4007 "TypeLoc size mismatch from updating exception specification");
4008 TSInfo->overrideType(Updated);
4017 llvm::FoldingSetInsertToken
Token;
4024 if (!
T.isCanonical()) {
4027 assert(!ComplexTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4030 Types.push_back(
New);
4040 llvm::FoldingSetInsertToken
Token;
4047 if (!
T.isCanonical()) {
4050 assert(!PointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4053 Types.push_back(
New);
4059 llvm::FoldingSetInsertToken
Token;
4068 Types.push_back(AT);
4069 AdjustedTypes.insert(AT,
Token);
4074 llvm::FoldingSetInsertToken
Token;
4082 Types.push_back(AT);
4083 AdjustedTypes.insert(AT,
Token);
4088 assert((
T->isArrayType() ||
T->isFunctionType()) &&
"T does not decay");
4097 if (
T->isArrayType())
4104 if (
T->isFunctionType())
4116 llvm::FoldingSetNodeID ID;
4117 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
4118 ATy->getSizeExpr(), ATy->getSizeModifier(),
4119 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
4120 llvm::FoldingSetInsertToken
Token;
4130 AT = ArrayParameterTypes.lookup(ID,
Token);
4131 assert(!AT &&
"Shouldn't be in the map!");
4136 Types.push_back(AT);
4137 ArrayParameterTypes.insert(AT,
Token);
4144 assert(
T->isFunctionType() &&
"block of function types only");
4147 llvm::FoldingSetInsertToken
Token;
4154 if (!
T.isCanonical()) {
4157 assert(!BlockPointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4161 Types.push_back(
New);
4162 BlockPointerTypes.insert(
New,
Token);
4170 assert((!
T->isPlaceholderType() ||
4171 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4172 "Unresolved placeholder type");
4176 llvm::FoldingSetInsertToken
Token;
4178 LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token))
4186 if (!SpelledAsLValue || InnerRef || !
T.isCanonical()) {
4187 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4190 assert(!LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token) &&
4191 "Shouldn't be in the map!");
4196 Types.push_back(
New);
4197 LValueReferenceTypes.insert(
New,
Token);
4205 assert((!
T->isPlaceholderType() ||
4206 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4207 "Unresolved placeholder type");
4211 llvm::FoldingSetInsertToken
Token;
4220 if (InnerRef || !
T.isCanonical()) {
4221 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4224 assert(!RValueReferenceTypes.lookup({T, false},
Token) &&
4225 "Shouldn't be in the map!");
4230 Types.push_back(
New);
4231 RValueReferenceTypes.insert(
New,
Token);
4239 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4242 Cls = Qualifier.getAsRecordDecl();
4246 llvm::FoldingSetNodeID ID;
4249 llvm::FoldingSetInsertToken
Token;
4255 return Qualifier.getCanonical();
4257 assert(R.isCanonical());
4263 if (!
T.isCanonical() || Qualifier != CanonicalQualifier) {
4269 MemberPointerTypes.lookup(ID,
Token);
4270 assert(!NewIP &&
"Shouldn't be in the map!");
4274 Types.push_back(
New);
4275 MemberPointerTypes.insert(
New,
Token);
4282 const llvm::APInt &ArySizeIn,
4283 const Expr *SizeExpr,
4285 unsigned IndexTypeQuals)
const {
4288 "Constant array of VLAs is illegal!");
4296 llvm::APInt ArySize(ArySizeIn);
4297 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
4299 llvm::FoldingSetNodeID ID;
4301 ASM, IndexTypeQuals);
4303 llvm::FoldingSetInsertToken
Token;
4315 ASM, IndexTypeQuals);
4320 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4323 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4324 ASM, IndexTypeQuals);
4325 ConstantArrayTypes.insert(
New,
Token);
4326 Types.push_back(
New);
4335 if (!
type->isVariablyModifiedType())
return type;
4340 const Type *ty = split.
Ty;
4342#define TYPE(Class, Base)
4343#define ABSTRACT_TYPE(Class, Base)
4344#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4345#include "clang/AST/TypeNodes.inc"
4346 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4352 case Type::DependentVector:
4353 case Type::ExtVector:
4354 case Type::DependentSizedExtVector:
4355 case Type::ConstantMatrix:
4356 case Type::DependentSizedMatrix:
4357 case Type::DependentAddressSpace:
4358 case Type::ObjCObject:
4359 case Type::ObjCInterface:
4360 case Type::ObjCObjectPointer:
4363 case Type::UnresolvedUsing:
4364 case Type::TypeOfExpr:
4366 case Type::Decltype:
4367 case Type::UnaryTransform:
4368 case Type::DependentName:
4369 case Type::InjectedClassName:
4370 case Type::TemplateSpecialization:
4371 case Type::TemplateTypeParm:
4372 case Type::SubstTemplateTypeParmPack:
4373 case Type::SubstBuiltinTemplatePack:
4375 case Type::DeducedTemplateSpecialization:
4376 case Type::PackExpansion:
4377 case Type::PackIndexing:
4379 case Type::DependentBitInt:
4380 case Type::ArrayParameter:
4381 case Type::HLSLAttributedResource:
4382 case Type::HLSLInlineSpirv:
4383 case Type::OverflowBehavior:
4384 llvm_unreachable(
"type should never be variably-modified");
4388 case Type::FunctionNoProto:
4389 case Type::FunctionProto:
4390 case Type::BlockPointer:
4391 case Type::MemberPointer:
4404 case Type::LValueReference: {
4408 lv->isSpelledAsLValue());
4412 case Type::RValueReference: {
4419 case Type::Atomic: {
4425 case Type::ConstantArray: {
4431 cat->getSizeModifier(),
4432 cat->getIndexTypeCVRQualifiers());
4436 case Type::DependentSizedArray: {
4440 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4445 case Type::IncompleteArray: {
4450 iat->getIndexTypeCVRQualifiers());
4455 case Type::VariableArray: {
4460 vat->getIndexTypeCVRQualifiers());
4473 unsigned IndexTypeQuals)
const {
4490 VariableArrayTypes.push_back(
New);
4491 Types.push_back(
New);
4501 unsigned elementTypeQuals)
const {
4504 "Size must be type- or value-dependent!");
4508 llvm::FoldingSetInsertToken
Token;
4509 llvm::FoldingSetNodeID ID;
4511 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4512 ASM, elementTypeQuals, numElements);
4527 DependentSizedArrayTypes.insert(newType,
Token);
4528 Types.push_back(newType);
4536 numElements, ASM, elementTypeQuals);
4537 DependentSizedArrayTypes.insert(canonTy,
Token);
4538 Types.push_back(canonTy);
4543 canonElementType.
Quals);
4547 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4556 Types.push_back(sugaredType);
4562 unsigned elementTypeQuals)
const {
4563 llvm::FoldingSetNodeID ID;
4566 llvm::FoldingSetInsertToken
Token;
4579 ASM, elementTypeQuals);
4584 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4590 IncompleteArrayTypes.insert(newType,
Token);
4591 Types.push_back(newType);
4597#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4598 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4601#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4602 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4606 llvm_unreachable(
"Unsupported builtin vector type");
4608#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4609 ElBits, NF, IsSigned) \
4610 case BuiltinType::Id: \
4611 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4612 llvm::ElementCount::getScalable(NumEls), NF};
4613#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4615 case BuiltinType::Id: \
4616 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4617 llvm::ElementCount::getScalable(NumEls), NF};
4618#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4620 case BuiltinType::Id: \
4621 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4622#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4624 case BuiltinType::Id: \
4625 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4626#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4627 case BuiltinType::Id: \
4628 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4629#include "clang/Basic/AArch64ACLETypes.def"
4631#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4633 case BuiltinType::Id: \
4634 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4635 llvm::ElementCount::getScalable(NumEls), NF};
4636#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4637 case BuiltinType::Id: \
4638 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4639 llvm::ElementCount::getScalable(NumEls), NF};
4640#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4641 case BuiltinType::Id: \
4642 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4643#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4644 case BuiltinType::Id: \
4645 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4646#include "clang/Basic/RISCVVTypes.def"
4653 if (Target->getTriple().isWasm() && Target->hasFeature(
"reference-types")) {
4654#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4655 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4657#include "clang/Basic/WebAssemblyReferenceTypes.def"
4660 "shouldn't try to generate type externref outside WebAssembly target");
4667 unsigned NumFields)
const {
4669 if (
auto It = ScalableVecTyMap.find(K); It != ScalableVecTyMap.end())
4672 if (Target->hasAArch64ACLETypes()) {
4675#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4676 ElBits, NF, IsSigned) \
4677 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4678 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4679 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4680 return ScalableVecTyMap[K] = SingletonId; \
4682#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4684 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4685 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4686 return ScalableVecTyMap[K] = SingletonId; \
4688#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4690 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4691 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4692 return ScalableVecTyMap[K] = SingletonId; \
4694#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4696 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4697 NumElts == (NumEls * NF) && NumFields == 1) { \
4698 return ScalableVecTyMap[K] = SingletonId; \
4700#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4701 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4702 return ScalableVecTyMap[K] = SingletonId;
4703#include "clang/Basic/AArch64ACLETypes.def"
4704 }
else if (Target->hasRISCVVTypes()) {
4706#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4708 if (!EltTy->isBooleanType() && \
4709 ((EltTy->hasIntegerRepresentation() && \
4710 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4711 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4713 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4714 IsBF && !IsFP)) && \
4715 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4716 return ScalableVecTyMap[K] = SingletonId;
4717#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4718 if (EltTy->isBooleanType() && NumElts == NumEls) \
4719 return ScalableVecTyMap[K] = SingletonId;
4720#include "clang/Basic/RISCVVTypes.def"
4735 llvm::FoldingSetNodeID ID;
4738 llvm::FoldingSetInsertToken
Token;
4750 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4753 VectorType(vecType, NumElts, Canonical, VecKind);
4755 Types.push_back(
New);
4762 llvm::FoldingSetNodeID ID;
4765 llvm::FoldingSetInsertToken
Token;
4771 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4774 if (CanonVecTy == VecType) {
4779 assert(!CanonCheck &&
4780 "Dependent-sized vector_size canonical type broken");
4782 DependentVectorTypes.insert(
New,
Token);
4791 Types.push_back(
New);
4798 unsigned NumElts)
const {
4805 llvm::FoldingSetNodeID ID;
4808 llvm::FoldingSetInsertToken
Token;
4820 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4825 Types.push_back(
New);
4833 llvm::FoldingSetNodeID ID;
4837 llvm::FoldingSetInsertToken
Token;
4839 DependentSizedExtVectorTypes.lookup(ID,
Token);
4849 if (CanonVecTy == vecType) {
4854 DependentSizedExtVectorTypes.lookup(ID,
Token);
4855 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4857 DependentSizedExtVectorTypes.insert(
New,
Token);
4866 Types.push_back(
New);
4871 QualType ElementTy,
unsigned NumRows,
unsigned NumColumns,
4872 std::optional<MatrixType::LayoutKind> Layout)
const {
4873 llvm::FoldingSetNodeID ID;
4875 Type::ConstantMatrix);
4878 "need a valid element type");
4879 assert(NumRows > 0 && NumRows <= LangOpts.MaxMatrixDimension &&
4880 NumColumns > 0 && NumColumns <= LangOpts.MaxMatrixDimension &&
4881 "need valid matrix dimensions");
4882 llvm::FoldingSetInsertToken
Token;
4889 NumColumns, std::nullopt);
4892 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4899 Types.push_back(
New);
4908 llvm::FoldingSetNodeID ID;
4912 llvm::FoldingSetInsertToken
Token;
4918 ColumnExpr, AttrLoc);
4921 DependentSizedMatrixTypes.lookup(ID,
Token);
4922 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4924 DependentSizedMatrixTypes.insert(Canon,
Token);
4925 Types.push_back(Canon);
4938 ColumnExpr, AttrLoc);
4939 Types.push_back(
New);
4947 const Type *Ty =
T->getUnqualifiedDesugaredType();
4949 if (
const auto *MT = dyn_cast<ConstantMatrixType>(Ty))
4952 MT->getNumColumns(), Layout),
4955 const auto *CAT = dyn_cast<ConstantArrayType>(Ty);
4961 CAT->getSizeExpr(), CAT->getSizeModifier(),
4962 CAT->getIndexTypeCVRQualifiers());
4970 Expr *AddrSpaceExpr,
4976 llvm::FoldingSetInsertToken
Token;
4977 llvm::FoldingSetNodeID ID;
4982 DependentAddressSpaceTypes.lookup(ID,
Token);
4988 DependentAddressSpaceTypes.insert(canonTy,
Token);
4989 Types.push_back(canonTy);
4992 if (canonPointeeType == PointeeType &&
4998 AddrSpaceExpr, AttrLoc);
4999 Types.push_back(sugaredType);
5005 return T.isCanonical() &&
5023 llvm::FoldingSetNodeID ID;
5026 llvm::FoldingSetInsertToken
Token;
5037 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5042 Types.push_back(
New);
5043 FunctionNoProtoTypes.insert(
New,
Token);
5059 return CanResultType;
5066 if (!NoexceptInType)
5083 bool AnyPackExpansions =
false;
5087 if (ET->
getAs<PackExpansionType>())
5088 AnyPackExpansions =
true;
5090 return AnyPackExpansions;
5096QualType ASTContext::getFunctionTypeInternal(
5097 QualType ResultTy, ArrayRef<QualType> ArgArray,
5098 const FunctionProtoType::ExtProtoInfo &EPI,
bool OnlyWantCanonical)
const {
5099 size_t NumArgs = ArgArray.size();
5103 llvm::FoldingSetNodeID
ID;
5108 bool Unique =
false;
5110 llvm::FoldingSetInsertToken Token;
5111 if (FunctionProtoType *FPT = FunctionProtoTypes.lookup(ID, Token)) {
5112 QualType Existing = QualType(FPT, 0);
5131 bool IsCanonicalExceptionSpec =
5135 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
5137 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
5138 if (!ArgArray[i].isCanonicalAsParam())
5139 isCanonical =
false;
5141 if (OnlyWantCanonical)
5142 assert(isCanonical &&
5143 "given non-canonical parameters constructing canonical type");
5148 if (!isCanonical && Canonical.
isNull()) {
5149 SmallVector<QualType, 16> CanonicalArgs;
5150 CanonicalArgs.reserve(NumArgs);
5151 for (
unsigned i = 0; i != NumArgs; ++i)
5154 llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
5155 FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
5158 if (IsCanonicalExceptionSpec) {
5160 }
else if (NoexceptInType) {
5173 bool AnyPacks =
false;
5175 if (ET->
getAs<PackExpansionType>())
5196 llvm_unreachable(
"dependent noexcept is already canonical");
5199 CanonicalEPI.
ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
5205 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5208 FunctionProtoType *NewIP = FunctionProtoTypes.lookup(ID, Token);
5209 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5214 auto ESH = FunctionProtoType::getExceptionSpecSize(
5216 size_t Size = FunctionProtoType::totalSizeToAlloc<
5217 QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
5218 FunctionType::FunctionTypeExtraAttributeInfo,
5219 FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
5220 Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, Qualifiers,
5221 FunctionEffect, EffectConditionExpr>(
5225 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5230 auto *FTP = (FunctionProtoType *)
Allocate(Size,
alignof(FunctionProtoType));
5231 FunctionProtoType::ExtProtoInfo newEPI = EPI;
5232 new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
5233 Types.push_back(FTP);
5235 FunctionProtoTypes.insert(FTP, Token);
5237 AnyFunctionEffects =
true;
5238 return QualType(FTP, 0);
5241QualType ASTContext::getPipeType(QualType
T,
bool ReadOnly)
const {
5242 llvm::FoldingSetInsertToken Token;
5243 if (PipeType *PT = PipeTypes.lookup({T, ReadOnly}, Token))
5244 return QualType(PT, 0);
5249 if (!
T.isCanonical()) {
5252 assert(!PipeTypes.lookup({T, ReadOnly}, Token) &&
5253 "Shouldn't be in the map!");
5255 auto *
New =
new (*
this,
alignof(PipeType)) PipeType(
T, Canonical, ReadOnly);
5256 Types.push_back(
New);
5257 PipeTypes.insert(
New, Token);
5258 return QualType(
New, 0);
5268 return getPipeType(
T,
true);
5272 return getPipeType(
T,
false);
5276 auto Key = std::make_pair(
unsigned(IsUnsigned), NumBits);
5278 llvm::FoldingSetInsertToken
Token;
5284 Types.push_back(
New);
5289 Expr *NumBitsExpr)
const {
5291 llvm::FoldingSetNodeID ID;
5294 llvm::FoldingSetInsertToken
Token;
5300 DependentBitIntTypes.insert(
New,
Token);
5302 Types.push_back(
New);
5310 if (
auto *Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5322 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5323 case Kind::SignedSizeT:
5325 case Kind::PtrdiffT:
5328 llvm_unreachable(
"unexpected kind");
5333 Types.push_back(
New);
5334 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5341 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5344 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5346 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5355 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5357 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5359 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5361 assert(TD->TypeForDecl);
5366 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5368 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5369 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5372 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5375 assert(
Decl->TypeForDecl);
5385 std::optional<bool> TypeMatchesDeclOrNone)
const {
5386 if (!TypeMatchesDeclOrNone) {
5387 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5388 assert(!DeclUnderlyingType.
isNull());
5389 if (UnderlyingType.
isNull())
5390 UnderlyingType = DeclUnderlyingType;
5392 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5393 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5397 assert(!UnderlyingType.
isNull());
5401 *TypeMatchesDeclOrNone) {
5402 if (
Decl->TypeForDecl)
5407 !*TypeMatchesDeclOrNone);
5409 Types.push_back(NewType);
5410 Decl->TypeForDecl = NewType;
5414 llvm::FoldingSetNodeID ID;
5416 *TypeMatchesDeclOrNone ?
QualType() : UnderlyingType);
5418 llvm::FoldingSetInsertToken
Token;
5420 TypedefTypes.lookup(ID,
Token))
5421 return QualType(Placeholder->getType(), 0);
5426 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5430 UnderlyingType, !*TypeMatchesDeclOrNone);
5431 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5433 TypedefTypes.insert(Placeholder,
Token);
5434 Types.push_back(NewType);
5443 if (UnderlyingType.
isNull()) {
5451 llvm::FoldingSetNodeID ID;
5454 llvm::FoldingSetInsertToken
Token;
5465 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5469 UsingTypes.insert(
T,
Token);
5475 const TagDecl *TD,
bool OwnsTag,
5477 const Type *CanonicalType,
5478 bool WithFoldingSetNode)
const {
5479 auto [TC, Size] = [&] {
5482 static_assert(
alignof(EnumType) ==
alignof(TagType));
5483 return std::make_tuple(Type::Enum,
sizeof(EnumType));
5484 case Decl::ClassTemplatePartialSpecialization:
5485 case Decl::ClassTemplateSpecialization:
5486 case Decl::CXXRecord:
5487 static_assert(
alignof(RecordType) ==
alignof(TagType));
5488 static_assert(
alignof(InjectedClassNameType) ==
alignof(TagType));
5490 return std::make_tuple(Type::InjectedClassName,
5491 sizeof(InjectedClassNameType));
5494 return std::make_tuple(Type::Record,
sizeof(RecordType));
5496 llvm_unreachable(
"unexpected decl kind");
5506 if (WithFoldingSetNode) {
5514 sizeof(TagTypeFoldingSetPlaceholder) +
5515 TagTypeFoldingSetPlaceholder::getOffset() + Size,
5516 std::max(
alignof(TagTypeFoldingSetPlaceholder),
alignof(TagType)));
5517 auto *
T =
new (Mem) TagTypeFoldingSetPlaceholder();
5518 Mem =
T->getTagType();
5520 Mem =
Allocate(Size,
alignof(TagType));
5523 auto *
T = [&, TC = TC]() -> TagType * {
5527 auto *
T =
new (Mem) EnumType(TC,
Keyword, Qualifier, TD, OwnsTag,
5528 IsInjected, CanonicalType);
5529 assert(
reinterpret_cast<void *
>(
T) ==
5530 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5531 "TagType must be the first base of EnumType");
5534 case Type::Record: {
5536 auto *
T =
new (Mem) RecordType(TC,
Keyword, Qualifier, TD, OwnsTag,
5537 IsInjected, CanonicalType);
5538 assert(
reinterpret_cast<void *
>(
T) ==
5539 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5540 "TagType must be the first base of RecordType");
5543 case Type::InjectedClassName: {
5544 auto *
T =
new (Mem) InjectedClassNameType(
Keyword, Qualifier, TD,
5545 IsInjected, CanonicalType);
5546 assert(
reinterpret_cast<void *
>(
T) ==
5547 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5548 "TagType must be the first base of InjectedClassNameType");
5552 llvm_unreachable(
"unexpected type class");
5555 assert(
T->getKeyword() ==
Keyword);
5556 assert(
T->getQualifier() == Qualifier);
5557 assert(
T->getDecl() == TD);
5558 assert(
T->isInjected() == IsInjected);
5559 assert(
T->isTagOwned() == OwnsTag);
5568 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5569 RD && RD->isInjectedClassName())
5576 if (TD->TypeForDecl)
5577 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5579 const Type *CanonicalType = getTagTypeInternal(
5582 false,
false,
nullptr,
5584 TD->TypeForDecl = CanonicalType;
5590 const TagDecl *TD,
bool OwnsTag)
const {
5593 bool IsInjected = TD != NonInjectedTD;
5600 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5601 if (
const Type *
T = TD->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5607 std::nullopt, NonInjectedTD,
5608 false, IsInjected, CanonicalType,
5610 TD->TypeForDecl =
T;
5614 llvm::FoldingSetNodeID ID;
5615 TagTypeFoldingSetPlaceholder::Profile(ID,
Keyword, Qualifier, NonInjectedTD,
5616 OwnsTag, IsInjected);
5618 llvm::FoldingSetInsertToken
Token;
5619 if (TagTypeFoldingSetPlaceholder *
T = TagTypes.lookup(ID,
Token))
5624 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5625 CanonicalType,
true);
5626 TagTypes.insert(TagTypeFoldingSetPlaceholder::fromTagType(
T),
Token);
5631 unsigned NumPositiveBits,
5634 unsigned IntWidth = Target->getIntWidth();
5635 unsigned CharWidth = Target->getCharWidth();
5636 unsigned ShortWidth = Target->getShortWidth();
5637 bool EnumTooLarge =
false;
5639 if (NumNegativeBits) {
5643 if (IsPacked && NumNegativeBits <= CharWidth &&
5644 NumPositiveBits < CharWidth) {
5646 BestWidth = CharWidth;
5647 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5648 NumPositiveBits < ShortWidth) {
5650 BestWidth = ShortWidth;
5651 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5653 BestWidth = IntWidth;
5655 BestWidth = Target->getLongWidth();
5657 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5660 BestWidth = Target->getLongLongWidth();
5662 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5663 EnumTooLarge =
true;
5667 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5672 if (IsPacked && NumPositiveBits <= CharWidth) {
5674 BestPromotionType =
IntTy;
5675 BestWidth = CharWidth;
5676 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5678 BestPromotionType =
IntTy;
5679 BestWidth = ShortWidth;
5680 }
else if (NumPositiveBits <= IntWidth) {
5682 BestWidth = IntWidth;
5683 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5686 }
else if (NumPositiveBits <= (BestWidth = Target->getLongWidth())) {
5688 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5692 BestWidth = Target->getLongLongWidth();
5693 if (NumPositiveBits > BestWidth) {
5698 EnumTooLarge =
true;
5701 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5706 return EnumTooLarge;
5710 assert((
T->isIntegralType(*
this) ||
T->isEnumeralType()) &&
5711 "Integral type required!");
5714 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5715 if (
T->isSignedIntegerOrEnumerationType())
5717 return Value.getActiveBits() <= BitWidth;
5719 return Value.getSignificantBits() <= BitWidth;
5725 const Type *CanonicalType)
const {
5727 UnresolvedUsingType::totalSizeToAlloc<
5729 !!
Token, !!Qualifier),
5733 auto *Placeholder =
new (
T->getFoldingSetPlaceholder())
5735 UnresolvedUsingTypes.insert(Placeholder,
Token);
5745 return D->TypeForDecl->getCanonicalTypeUnqualified();
5747 const Type *CanonicalType =
5751 D->TypeForDecl = CanonicalType;
5760 if (
const Type *
T = D->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5772 llvm::FoldingSetNodeID ID;
5775 llvm::FoldingSetInsertToken
Token;
5777 UnresolvedUsingTypes.lookup(ID,
Token))
5778 return QualType(Placeholder->getType(), 0);
5791 llvm::FoldingSetNodeID id;
5792 AttributedType::Profile(
id, *
this, attrKind, modifiedType, equivalentType,
5795 llvm::FoldingSetInsertToken
Token;
5796 AttributedType *
type = AttributedTypes.lookup(
id,
Token);
5799 assert(!
attr ||
attr->getKind() == attrKind);
5802 type =
new (*
this,
alignof(AttributedType))
5803 AttributedType(canon, attrKind,
attr, modifiedType, equivalentType);
5805 Types.push_back(
type);
5819 switch (nullability) {
5835 llvm_unreachable(
"Unknown nullability kind");
5840 llvm::FoldingSetNodeID ID;
5841 BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
5843 llvm::FoldingSetInsertToken
Token;
5844 BTFTagAttributedType *Ty = BTFTagAttributedTypes.lookup(ID,
Token);
5849 Ty =
new (*
this,
alignof(BTFTagAttributedType))
5850 BTFTagAttributedType(Canon, Wrapped, BTFAttr);
5852 Types.push_back(Ty);
5853 BTFTagAttributedTypes.insert(Ty,
Token);
5861 StringRef IdentName = II->
getName();
5862 OverflowBehaviorType::OverflowBehaviorKind Kind;
5863 if (IdentName ==
"wrap") {
5864 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
5865 }
else if (IdentName ==
"trap") {
5866 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
5875 OverflowBehaviorType::OverflowBehaviorKind Kind,
5878 "Cannot have underlying types that are themselves OBTs");
5880 llvm::FoldingSetInsertToken
Token;
5881 if (OverflowBehaviorType *OBT =
5882 OverflowBehaviorTypes.lookup({Underlying, Kind},
Token)) {
5891 assert(!OverflowBehaviorTypes.lookup({Underlying, Kind},
Token) &&
5892 "Shouldn't be in the map");
5895 OverflowBehaviorType *Ty =
new (*
this,
alignof(OverflowBehaviorType))
5896 OverflowBehaviorType(*
this, Canonical, Underlying, Kind);
5898 Types.push_back(Ty);
5899 OverflowBehaviorTypes.insert(Ty,
Token);
5905 const HLSLAttributedResourceType::Attributes &Attrs) {
5907 llvm::FoldingSetNodeID ID;
5908 HLSLAttributedResourceType::Profile(ID, *
this, Wrapped, Contained, Attrs);
5910 llvm::FoldingSetInsertToken
Token;
5911 HLSLAttributedResourceType *Ty =
5912 HLSLAttributedResourceTypes.lookup(ID,
Token);
5916 Ty =
new (*
this,
alignof(HLSLAttributedResourceType))
5917 HLSLAttributedResourceType(Wrapped, Contained, Attrs);
5919 Types.push_back(Ty);
5920 HLSLAttributedResourceTypes.insert(Ty,
Token);
5928 llvm::FoldingSetNodeID ID;
5929 HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
5931 llvm::FoldingSetInsertToken
Token;
5932 HLSLInlineSpirvType *Ty = HLSLInlineSpirvTypes.lookup(ID,
Token);
5937 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5938 alignof(HLSLInlineSpirvType));
5940 Ty =
new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
5942 Types.push_back(Ty);
5943 HLSLInlineSpirvTypes.insert(Ty,
Token);
5950 Decl *AssociatedDecl,
5955 std::make_tuple(Replacement, AssociatedDecl, Index,
5956 PackIndex.toInternalRepresentation(),
unsigned(Final));
5957 llvm::FoldingSetInsertToken
Token;
5958 SubstTemplateTypeParmType *SubstParm =
5959 SubstTemplateTypeParmTypes.lookup(Key,
Token);
5962 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5963 !Replacement.isCanonical()),
5964 alignof(SubstTemplateTypeParmType));
5965 SubstParm =
new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
5967 Types.push_back(SubstParm);
5968 SubstTemplateTypeParmTypes.insert(SubstParm,
Token);
5976 unsigned Index,
bool Final,
5983 llvm::FoldingSetNodeID ID;
5984 SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
5986 llvm::FoldingSetInsertToken
Token;
5987 if (SubstTemplateTypeParmPackType *SubstParm =
5988 SubstTemplateTypeParmPackTypes.lookup(ID,
Token))
5998 [[maybe_unused]]
const auto *Nothing =
5999 SubstTemplateTypeParmPackTypes.lookup(ID,
Token);
6004 auto *SubstParm =
new (*
this,
alignof(SubstTemplateTypeParmPackType))
6005 SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
6007 Types.push_back(SubstParm);
6008 SubstTemplateTypeParmPackTypes.insert(SubstParm,
Token);
6016 return P.getKind() == TemplateArgument::Type;
6018 "Pack contains a non-type");
6020 llvm::FoldingSetNodeID ID;
6021 SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
6023 llvm::FoldingSetInsertToken
Token;
6024 if (
auto *
T = SubstBuiltinTemplatePackTypes.lookup(ID,
Token))
6033 [[maybe_unused]]
const auto *Nothing =
6034 SubstBuiltinTemplatePackTypes.lookup(ID,
Token);
6038 auto *PackType =
new (*
this,
alignof(SubstBuiltinTemplatePackType))
6039 SubstBuiltinTemplatePackType(Canon, ArgPack);
6040 Types.push_back(PackType);
6041 SubstBuiltinTemplatePackTypes.insert(PackType,
Token);
6051 assert(Depth >= 0 &&
"Depth must be non-negative");
6052 assert(Index >= 0 &&
"Index must be non-negative");
6054 auto Key = std::make_tuple(
unsigned(Depth),
unsigned(Index),
6055 unsigned(ParameterPack), TTPDecl);
6056 llvm::FoldingSetInsertToken
Token;
6057 TemplateTypeParmType *TypeParm = TemplateTypeParmTypes.lookup(Key,
Token);
6064 TypeParm =
new (*
this,
alignof(TemplateTypeParmType))
6065 TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
6067 TypeParm =
new (*
this,
alignof(TemplateTypeParmType)) TemplateTypeParmType(
6068 Depth, Index, ParameterPack,
nullptr,
QualType());
6070 Types.push_back(TypeParm);
6071 TemplateTypeParmTypes.insert(TypeParm,
Token);
6097 llvm_unreachable(
"unexpected keyword kind");
6111 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
6121 SpecifiedArgVec.reserve(SpecifiedArgs.size());
6123 SpecifiedArgVec.push_back(Arg.getArgument());
6126 CanonicalArgs, Underlying);
6129[[maybe_unused]]
static bool
6132 if (Arg.isPackExpansion())
6143 Template.getAsDependentTemplateName()));
6145 for (
const auto &Arg : Args)
6149 llvm::FoldingSetNodeID ID;
6152 llvm::FoldingSetInsertToken
Token;
6153 if (
auto *
T = TemplateSpecializationTypes.lookup(ID,
Token))
6156 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6158 alignof(TemplateSpecializationType));
6162 assert(Spec->isDependentType() &&
6163 "canonical template specialization must be dependent");
6164 Types.push_back(Spec);
6165 TemplateSpecializationTypes.insert(Spec,
Token);
6173 const auto *TD =
Template.getAsTemplateDecl(
true);
6174 bool IsTypeAlias = TD && TD->isTypeAlias();
6175 if (Underlying.
isNull()) {
6182 bool NonCanonical =
Template != CanonTemplate ||
Keyword != CanonKeyword;
6184 if (CanonicalArgs.empty()) {
6187 CanonicalArgs = CanonArgsVec;
6189 NonCanonical |= !llvm::equal(
6190 SpecifiedArgs, CanonicalArgs,
6199 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
6201 "Caller must compute aliased type");
6202 IsTypeAlias =
false;
6205 CanonKeyword, CanonTemplate, CanonicalArgs);
6209 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6211 (IsTypeAlias ?
sizeof(
QualType) : 0),
6212 alignof(TemplateSpecializationType));
6213 auto *Spec =
new (Mem) TemplateSpecializationType(
6215 Types.push_back(Spec);
6221 llvm::FoldingSetInsertToken
Token;
6229 assert(!ParenTypes.lookup(InnerType,
Token) &&
6230 "Paren canonical type broken");
6235 ParenTypes.insert(
T,
Token);
6248 Types.push_back(newType);
6255 llvm::FoldingSetNodeID ID;
6256 DependentNameType::Profile(ID,
Keyword, NNS, Name);
6258 llvm::FoldingSetInsertToken
Token;
6259 if (DependentNameType *
T = DependentNameTypes.lookup(ID,
Token))
6267 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6269 [[maybe_unused]] DependentNameType *
T =
6270 DependentNameTypes.lookup(ID,
Token);
6271 assert(!
T &&
"broken canonicalization");
6275 DependentNameType *
T =
new (*
this,
alignof(DependentNameType))
6276 DependentNameType(
Keyword, NNS, Name, Canon);
6278 DependentNameTypes.insert(
T,
Token);
6284 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6286 if (TTP->isParameterPack())
6290 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6292 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6298 if (NTTP->getType()->isReferenceType()) {
6302 }
else if (
T->isRecordType()) {
6309 Expr *E =
new (*this)
6311 T,
VK, NTTP->getLocation());
6313 if (NTTP->isParameterPack())
6319 std::nullopt,
false,
6321 if (TTP->isParameterPack())
6327 if (Param->isTemplateParameterPack())
6336 bool ExpectPackInType)
const {
6338 "Pack expansions must expand one or more parameter packs");
6342 llvm::FoldingSetInsertToken
Token;
6343 PackExpansionType *
T = PackExpansionTypes.lookup(Key,
Token);
6354 PackExpansionTypes.lookup(Key,
Token);
6357 T =
new (*
this,
alignof(PackExpansionType))
6358 PackExpansionType(Pattern, Canon, NumExpansions);
6360 PackExpansionTypes.insert(
T,
Token);
6372 if (Protocols.empty())
return true;
6377 for (
unsigned i = 1; i != Protocols.size(); ++i)
6387 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6391 P = P->getCanonicalDecl();
6394 auto ProtocolsEnd = llvm::unique(Protocols);
6395 Protocols.erase(ProtocolsEnd, Protocols.end());
6400 unsigned NumProtocols)
const {
6409 bool isKindOf)
const {
6412 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6417 llvm::FoldingSetNodeID ID;
6418 ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
6419 llvm::FoldingSetInsertToken
Token;
6427 if (effectiveTypeArgs.empty()) {
6429 effectiveTypeArgs = baseObject->getTypeArgs();
6436 bool typeArgsAreCanonical = llvm::all_of(
6439 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6443 if (!typeArgsAreCanonical) {
6444 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6445 for (
auto typeArg : effectiveTypeArgs)
6447 canonTypeArgs = canonTypeArgsVec;
6449 canonTypeArgs = effectiveTypeArgs;
6454 if (!protocolsSorted) {
6455 canonProtocolsVec.append(protocols.begin(), protocols.end());
6457 canonProtocols = canonProtocolsVec;
6459 canonProtocols = protocols;
6463 canonProtocols, isKindOf);
6466 ObjCObjectTypes.lookup(ID,
Token);
6469 unsigned size =
sizeof(ObjCObjectTypeImpl);
6470 size += typeArgs.size() *
sizeof(
QualType);
6472 void *mem =
Allocate(size,
alignof(ObjCObjectTypeImpl));
6474 new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
6478 ObjCObjectTypes.insert(
T,
Token);
6488 bool allowOnPointerType)
const {
6491 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6496 if (allowOnPointerType) {
6497 if (
const auto *objPtr =
6498 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6502 protocolsVec.append(objT->qual_begin(),
6504 protocolsVec.append(protocols.begin(), protocols.end());
6507 objT->getBaseType(),
6508 objT->getTypeArgsAsWritten(),
6510 objT->isKindOfTypeAsWritten());
6516 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6521 objT->getTypeArgsAsWritten(),
6523 objT->isKindOfTypeAsWritten());
6527 if (
type->isObjCObjectType()) {
6537 if (
type->isObjCIdType()) {
6540 objPtr->isKindOfType());
6545 if (
type->isObjCClassType()) {
6548 objPtr->isKindOfType());
6561 if (!protocols.empty()) {
6565 Canonical, protocols, hasError,
true ));
6566 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6571 auto Key = std::make_tuple(
Decl, Canonical, protocols);
6572 llvm::FoldingSetInsertToken
Token;
6573 if (ObjCTypeParamType *TypeParam = ObjCTypeParamTypes.lookup(Key,
Token))
6576 unsigned size =
sizeof(ObjCTypeParamType);
6578 void *mem =
Allocate(size,
alignof(ObjCTypeParamType));
6579 auto *newType =
new (mem) ObjCTypeParamType(
Decl, Canonical, protocols);
6581 Types.push_back(newType);
6582 ObjCTypeParamTypes.insert(newType,
Token);
6592 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6607 for (
auto *Proto : OPT->quals()) {
6630 if (InheritedProtocols.empty())
6634 bool Conforms =
false;
6635 for (
auto *Proto : OPT->quals()) {
6637 for (
auto *PI : InheritedProtocols) {
6649 for (
auto *PI : InheritedProtocols) {
6651 bool Adopts =
false;
6652 for (
auto *Proto : OPT->quals()) {
6666 llvm::FoldingSetInsertToken
Token;
6681 Types.push_back(QType);
6682 ObjCObjectPointerTypes.insert(QType,
Token);
6690 if (
Decl->TypeForDecl)
6694 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6695 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6696 return QualType(PrevDecl->TypeForDecl, 0);
6705 Decl->TypeForDecl =
T;
6718 llvm::FoldingSetNodeID ID;
6722 llvm::FoldingSetInsertToken
Token;
6733 DependentTypeOfExprTypes.insert(Canon,
Token);
6741 Types.push_back(toe);
6752 auto *tot =
new (*
this,
alignof(TypeOfType))
6753 TypeOfType(*
this, tofType, Canonical, Kind);
6754 Types.push_back(tot);
6778 llvm_unreachable(
"Unknown value kind");
6793 }
else if (!UnderlyingType.
isNull()) {
6796 llvm::FoldingSetNodeID ID;
6797 DependentDecltypeType::Profile(ID, *
this, E);
6799 llvm::FoldingSetInsertToken
Token;
6800 if (DependentDecltypeType *Canon = DependentDecltypeTypes.lookup(ID,
Token))
6805 new (*
this,
alignof(DependentDecltypeType)) DependentDecltypeType(E);
6806 DependentDecltypeTypes.insert(DT,
Token);
6807 Types.push_back(DT);
6810 auto *DT =
new (*
this,
alignof(DecltypeType))
6811 DecltypeType(E, UnderlyingType, CanonType);
6812 Types.push_back(DT);
6817 bool FullySubstituted,
6821 if (FullySubstituted && Index) {
6824 llvm::FoldingSetNodeID ID;
6825 PackIndexingType::Profile(ID, *
this, Pattern.
getCanonicalType(), IndexExpr,
6826 FullySubstituted, Expansions);
6827 llvm::FoldingSetInsertToken
Token;
6828 PackIndexingType *Canon = DependentPackIndexingTypes.lookup(ID,
Token);
6831 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6835 IndexExpr, FullySubstituted, Expansions);
6836 DependentPackIndexingTypes.insert(Canon,
Token);
6842 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6844 auto *
T =
new (Mem) PackIndexingType(Canonical, Pattern, IndexExpr,
6845 FullySubstituted, Expansions);
6854 UnaryTransformType::UTTKind Kind)
const {
6857 if (BaseType->isDependentType()) {
6858 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6862 auto Key = std::make_tuple(BaseType, UnderlyingType, Kind);
6864 llvm::FoldingSetInsertToken
Token;
6865 if (UnaryTransformType *UT = UnaryTransformTypes.lookup(Key,
Token))
6869 if (!BaseType->isDependentType()) {
6873 BaseType != CanonBase) {
6879 auto *UT =
new (*
this,
alignof(UnaryTransformType))
6880 UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
6881 UnaryTransformTypes.insert(UT,
Token);
6882 Types.push_back(UT);
6895 TypeConstraintConcept.
isNull()) {
6896 assert(DeducedAsType.
isNull() &&
"");
6897 assert(TypeConstraintArgs.empty() &&
"");
6902 llvm::FoldingSetNodeID ID;
6903 AutoType::Profile(ID, *
this, DK, DeducedAsType,
Keyword,
6904 TypeConstraintConcept, TypeConstraintArgs);
6905 if (
auto const AT_iter = AutoTypes.find_as(ID); AT_iter != AutoTypes.end())
6906 return QualType(AT_iter->getSecond(), 0);
6909 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6911 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6912 if (!TypeConstraintConcept.
isNull()) {
6913 bool AnyNonCanonArgs =
false;
6917 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6918 if (TypeConstraintConcept != CanonicalConcept || AnyNonCanonArgs)
6920 CanonicalConceptArgs);
6924 void *Mem =
Allocate(
sizeof(AutoType) +
6927 auto *AT =
new (Mem) AutoType(DK, DeducedAsType,
Keyword,
6928 TypeConstraintConcept, TypeConstraintArgs);
6930 llvm::FoldingSetNodeID InsertedID;
6931 AT->Profile(InsertedID, *
this);
6932 assert(InsertedID == ID &&
"ID does not match");
6934 Types.push_back(AT);
6935 AutoTypes.try_emplace(ID.Intern(BumpAlloc), AT);
6940 QualType CanonT =
T.getNonPackExpansionType().getCanonicalType();
6943 if (
auto *AT = CanonT->
getAs<AutoType>()) {
6944 if (!AT->isConstrained())
6966 llvm::FoldingSetInsertToken
Token;
6967 llvm::FoldingSetNodeID ID;
6968 DeducedTemplateSpecializationType::Profile(ID, DK, DeducedAsType,
Keyword,
6970 if (DeducedTemplateSpecializationType *DTST =
6971 DeducedTemplateSpecializationTypes.lookup(ID,
Token))
6975 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6977 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6986 [[maybe_unused]] DeducedTemplateSpecializationType *DTST =
6987 DeducedTemplateSpecializationTypes.lookup(ID,
Token);
6988 assert(!DTST &&
"broken canonicalization");
6992 auto *DTST =
new (*
this,
alignof(DeducedTemplateSpecializationType))
6993 DeducedTemplateSpecializationType(DK, DeducedAsType,
Keyword,
Template);
6996 llvm::FoldingSetNodeID TempID;
6997 DTST->Profile(TempID);
6998 assert(ID == TempID &&
"ID does not match");
7000 Types.push_back(DTST);
7001 DeducedTemplateSpecializationTypes.insert(DTST,
Token);
7010 llvm::FoldingSetInsertToken
Token;
7017 if (!
T.isCanonical()) {
7020 assert(!AtomicTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
7023 Types.push_back(
New);
7032 new (*
this,
alignof(AutoType))
7056 return getFromTargetType(Target->getSizeType());
7075 return getFromTargetType(Target->getUnsignedPtrDiffType(
LangAS::Default));
7080 return getFromTargetType(Target->getIntMaxType());
7085 return getFromTargetType(Target->getUIntMaxType());
7103 return getFromTargetType(Target->getIntPtrType());
7113 return getFromTargetType(Target->getProcessIDType());
7125 const Type *Ty =
T.getTypePtr();
7153 quals = splitType.
Quals;
7158 QualType elementType = AT->getElementType();
7163 if (elementType == unqualElementType) {
7164 assert(quals.
empty());
7165 quals = splitType.
Quals;
7173 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7175 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7178 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7182 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7184 VAT->getSizeModifier(),
7185 VAT->getIndexTypeCVRQualifiers());
7190 DSAT->getSizeModifier(), 0);
7200 bool AllowPiMismatch)
const {
7215 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7216 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7217 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7230 T1 = AT1->getElementType();
7231 T2 = AT2->getElementType();
7251 bool AllowPiMismatch)
const {
7256 if (T1PtrType && T2PtrType) {
7264 T1MPType && T2MPType) {
7267 if (T1MPType->getQualifier() != T2MPType->getQualifier())
7279 if (T1OPType && T2OPType) {
7311 if (Quals1 != Quals2)
7385 llvm_unreachable(
"bad template name kind!");
7391 if (!TP->hasDefaultArgument())
7393 return &TP->getDefaultArgument().getArgument();
7396 case NamedDecl::TemplateTypeParm:
7398 case NamedDecl::NonTypeTemplateParm:
7400 case NamedDecl::TemplateTemplateParm:
7403 llvm_unreachable(
"Unexpected template parameter kind");
7408 bool IgnoreDeduced)
const {
7409 while (std::optional<TemplateName> UnderlyingOrNone =
7411 Name = *UnderlyingOrNone;
7416 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7428 llvm_unreachable(
"cannot canonicalize overloaded template");
7432 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7461 assert(IgnoreDeduced ==
false);
7468 bool NonCanonical = CanonUnderlying != Underlying;
7474 assert(CanonArgs.size() <= Params.size());
7480 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7489 if (I ==
int(CanonArgs.size() - 1))
7490 CanonArgs.pop_back();
7491 NonCanonical =
true;
7501 llvm_unreachable(
"always sugar node");
7504 llvm_unreachable(
"bad template name!");
7509 bool IgnoreDeduced)
const {
7530 llvm::FoldingSetNodeID XCEID, YCEID;
7531 XCE->
Profile(XCEID, *
this,
true,
true);
7532 YCE->
Profile(YCEID, *
this,
true,
true);
7533 return XCEID == YCEID;
7582 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7584 if (TX->isParameterPack() != TY->isParameterPack())
7586 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7589 TY->getTypeConstraint());
7592 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7594 return TX->isParameterPack() == TY->isParameterPack() &&
7595 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7597 TY->getPlaceholderTypeConstraint());
7602 return TX->isParameterPack() == TY->isParameterPack() &&
7604 TY->getTemplateParameters());
7609 if (
X->size() != Y->
size())
7612 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7626 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7628 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7631 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7632 TTPY->getDefaultArgument().getArgument().getAsType());
7635 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7637 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7640 Expr *DefaultArgumentX =
7641 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7642 Expr *DefaultArgumentY =
7643 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7644 llvm::FoldingSetNodeID XID, YID;
7645 DefaultArgumentX->
Profile(XID, *
this,
true);
7646 DefaultArgumentY->
Profile(YID, *
this,
true);
7653 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7668 auto Kind =
X.getKind();
7676 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7679 NamespaceY->getNamespace()))
7684 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7685 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7694 llvm_unreachable(
"unhandled qualifier kind");
7700 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7702 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7714 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7718 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7719 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7720 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7723 if (!Cand1A || !Cand2A)
7729 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7730 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7734 if (Cand1ID != Cand2ID)
7768 auto *RD = dyn_cast<CXXRecordDecl>(
X->getDeclContext());
7776 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7777 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7779 TypedefY->getUnderlyingType());
7796 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7798 return (TagX->getTagKind() == TagY->getTagKind()) ||
7810 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7812 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7814 if (CtorX->getInheritedConstructor() &&
7815 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7816 CtorY->getInheritedConstructor().getConstructor()))
7820 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7825 if (FuncX->isMultiVersion()) {
7826 const auto *TAX = FuncX->getAttr<TargetAttr>();
7827 const auto *TAY = FuncY->getAttr<TargetAttr>();
7828 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7830 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7836 if ((FuncX->isMemberLikeConstrainedFriend() ||
7837 FuncY->isMemberLikeConstrainedFriend()) &&
7838 !FuncX->getLexicalDeclContext()->Equals(
7839 FuncY->getLexicalDeclContext())) {
7844 FuncY->getTrailingRequiresClause()))
7852 FD = FD->getCanonicalDecl();
7853 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7856 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7871 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7876 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7878 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7881 if (VarX->getType().isNull() || VarY->getType().isNull())
7884 if (
hasSameType(VarX->getType(), VarY->getType()))
7894 if (!VarXTy || !VarYTy)
7903 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7905 return NamespaceX->isInline() == NamespaceY->isInline();
7910 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7914 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7917 ConceptY->getConstraintExpr()))
7922 TemplateY->getTemplatedDecl()) &&
7924 TemplateY->getTemplateParameters());
7928 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7931 return hasSameType(FDX->getType(), FDY->getType());
7935 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7937 return IFDX->getAnonField()->getCanonicalDecl() ==
7938 IFDY->getAnonField()->getCanonicalDecl();
7947 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7954 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7957 UX->hasTypename() == UY->hasTypename() &&
7958 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7960 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7963 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7965 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7973 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
7975 UX->getInstantiatedFromUsingDecl(),
7980 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
7982 return NAX->getNamespace()->Equals(NAY->getNamespace());
7985 if (
const auto *UX = dyn_cast<UsingEnumDecl>(
X)) {
8036 bool AnyNonCanonArgs =
false;
8039 if (!AnyNonCanonArgs)
8049 llvm_unreachable(
"Unhandled template argument kind");
8059 llvm_unreachable(
"Comparing NULL template argument");
8084 llvm::FoldingSetNodeID ID1, ID2;
8094 return isSameTemplateArgument(Arg1, Arg2);
8098 llvm_unreachable(
"Unhandled template argument kind");
8103 if (!
T.hasLocalQualifiers()) {
8105 if (
const auto *AT = dyn_cast<ArrayType>(
T))
8125 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
8126 if (!ATy || qs.
empty())
8133 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
8136 CAT->getSizeModifier(),
8137 CAT->getIndexTypeCVRQualifiers()));
8138 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
8140 IAT->getSizeModifier(),
8141 IAT->getIndexTypeCVRQualifiers()));
8143 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
8145 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
8146 DSAT->getIndexTypeCVRQualifiers()));
8151 VAT->getIndexTypeCVRQualifiers()));
8159 if (
T->isArrayType() ||
T->isFunctionType())
8167 return T.getUnqualifiedType();
8178 if (
T->isArrayType() ||
T->isFunctionType())
8180 return T.getUnqualifiedType();
8195 assert(PrettyArrayType &&
"Not an array type!");
8229 uint64_t ElementCount = 1;
8232 CA = dyn_cast_if_present<ConstantArrayType>(
8235 return ElementCount;
8243 uint64_t ElementCount = 1;
8247 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8250 return ElementCount;
8260 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8262 case BuiltinType::Half:
return HalfRank;
8263 case BuiltinType::Float:
return FloatRank;
8296unsigned ASTContext::getIntegerRank(
const Type *
T)
const {
8297 assert(
T->isCanonicalUnqualified() &&
"T should be canonicalized");
8301 if (
const auto *EIT = dyn_cast<BitIntType>(
T))
8302 return 0 + (EIT->getNumBits() << 3);
8304 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(
T))
8305 return getIntegerRank(OBT->getUnderlyingType().getTypePtr());
8308 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8309 case BuiltinType::Bool:
8311 case BuiltinType::Char_S:
8312 case BuiltinType::Char_U:
8313 case BuiltinType::SChar:
8314 case BuiltinType::UChar:
8316 case BuiltinType::Short:
8317 case BuiltinType::UShort:
8319 case BuiltinType::Int:
8320 case BuiltinType::UInt:
8322 case BuiltinType::Long:
8323 case BuiltinType::ULong:
8325 case BuiltinType::LongLong:
8326 case BuiltinType::ULongLong:
8328 case BuiltinType::Int128:
8329 case BuiltinType::UInt128:
8334 case BuiltinType::Char8:
8336 case BuiltinType::Char16:
8337 return getIntegerRank(
8339 case BuiltinType::Char32:
8340 return getIntegerRank(
8342 case BuiltinType::WChar_S:
8343 case BuiltinType::WChar_U:
8344 return getIntegerRank(
8374 uint64_t BitWidth = Field->getBitWidthValue();
8400 if (BitWidth < IntSize)
8403 if (BitWidth == IntSize)
8418 assert(!Promotable.
isNull());
8421 return ED->getPromotionType();
8425 if (
const auto *OBT = Promotable->
getAs<OverflowBehaviorType>()) {
8438 if (BT->getKind() == BuiltinType::WChar_S ||
8439 BT->getKind() == BuiltinType::WChar_U ||
8440 BT->getKind() == BuiltinType::Char8 ||
8441 BT->getKind() == BuiltinType::Char16 ||
8442 BT->getKind() == BuiltinType::Char32) {
8443 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8447 for (
const auto &PT : PromoteTypes) {
8449 if (FromSize < ToSize ||
8450 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8453 llvm_unreachable(
"char type should fit into long long");
8460 uint64_t PromotableSize =
getIntWidth(Promotable);
8469 while (!
T.isNull()) {
8471 return T.getObjCLifetime();
8472 if (
T->isArrayType())
8475 T = PT->getPointeeType();
8477 T = RT->getPointeeType();
8502 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8504 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8507 if (LHSC == RHSC)
return 0;
8512 unsigned LHSRank = getIntegerRank(LHSC);
8513 unsigned RHSRank = getIntegerRank(RHSC);
8515 if (LHSUnsigned == RHSUnsigned) {
8516 if (LHSRank == RHSRank)
return 0;
8517 return LHSRank > RHSRank ? 1 : -1;
8523 if (LHSRank >= RHSRank)
8533 if (RHSRank >= LHSRank)
8543 if (CFConstantStringTypeDecl)
8544 return CFConstantStringTypeDecl;
8546 assert(!CFConstantStringTagDecl &&
8547 "tag and typedef should be initialized together");
8549 CFConstantStringTagDecl->startDefinition();
8587 if (
static_cast<unsigned>(CFRuntime) <
8590 Fields[Count++] = {
IntTy,
"flags" };
8592 Fields[Count++] = {
LongTy,
"length" };
8596 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()),
"_swift_rc" };
8600 Fields[Count++] = {
IntTy,
"_ptr" };
8606 for (
unsigned i = 0; i < Count; ++i) {
8610 Fields[i].Type,
nullptr,
8613 CFConstantStringTagDecl->addDecl(Field);
8616 CFConstantStringTagDecl->completeDefinition();
8620 CFConstantStringTypeDecl =
8623 return CFConstantStringTypeDecl;
8627 if (!CFConstantStringTagDecl)
8629 return CFConstantStringTagDecl;
8639 if (ObjCSuperType.isNull()) {
8644 return ObjCSuperType;
8650 CFConstantStringTagDecl = TT->castAsRecordDecl();
8654 if (BlockDescriptorType)
8667 static const char *
const FieldNames[] = {
8672 for (
size_t i = 0; i < 2; ++i) {
8675 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8683 BlockDescriptorType = RD;
8689 if (BlockDescriptorExtendedType)
8704 static const char *
const FieldNames[] = {
8711 for (
size_t i = 0; i < 4; ++i) {
8714 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8723 BlockDescriptorExtendedType = RD;
8728 const auto *BT = dyn_cast<BuiltinType>(
T);
8737 switch (BT->getKind()) {
8738#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8739 case BuiltinType::Id: \
8741#include "clang/Basic/OpenCLImageTypes.def"
8743 case BuiltinType::OCLClkEvent:
8746 case BuiltinType::OCLEvent:
8749 case BuiltinType::OCLQueue:
8752 case BuiltinType::OCLReserveID:
8755 case BuiltinType::OCLSampler:
8774 if (!copyExpr && record->hasTrivialDestructor())
return false;
8805 llvm_unreachable(
"impossible");
8807 llvm_unreachable(
"fell out of lifetime switch!");
8815 bool &HasByrefExtendedLayout)
const {
8820 HasByrefExtendedLayout =
false;
8822 HasByrefExtendedLayout =
true;
8836 assert(Target &&
"Expected target to be initialized");
8837 const llvm::Triple &
T = Target->getTriple();
8839 if (
T.isOSWindows() &&
T.isArch64Bit())
8845 assert(Target &&
"Expected target to be initialized");
8846 const llvm::Triple &
T = Target->getTriple();
8848 if (
T.isOSWindows() &&
T.isArch64Bit())
8854 if (!ObjCInstanceTypeDecl)
8855 ObjCInstanceTypeDecl =
8857 return ObjCInstanceTypeDecl;
8863 if (
const auto *TT = dyn_cast<TypedefType>(
T))
8865 return II->isStr(
"BOOL");
8873 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8882 else if (
type->isArrayType())
8901 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8908 !D->isInlineSpecified() && (D->isConstexpr() ||
First->isConstexpr()))
8939 for (
auto *PI :
Decl->parameters()) {
8944 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8953 ParmOffset = PtrSize;
8954 for (
auto *PVDecl :
Decl->parameters()) {
8955 QualType PType = PVDecl->getOriginalType();
8956 if (
const auto *AT =
8961 PType = PVDecl->getType();
8963 PType = PVDecl->getType();
8983 for (
auto *PI :
Decl->parameters()) {
8990 "getObjCEncodingForFunctionDecl - Incomplete param type");
8997 for (
auto *PVDecl :
Decl->parameters()) {
8998 QualType PType = PVDecl->getOriginalType();
8999 if (
const auto *AT =
9004 PType = PVDecl->getType();
9006 PType = PVDecl->getType();
9020 bool Extended)
const {
9024 ObjCEncOptions Options = ObjCEncOptions()
9025 .setExpandPointedToStructures()
9026 .setExpandStructures()
9027 .setIsOutermostType();
9029 Options.setEncodeBlockParameters().setEncodeClassNames();
9030 getObjCEncodingForTypeImpl(
T, S, Options,
nullptr);
9036 bool Extended)
const {
9041 Decl->getReturnType(), S, Extended);
9050 E =
Decl->sel_param_end(); PI != E; ++PI) {
9057 "getObjCEncodingForMethodDecl - Incomplete param type");
9065 ParmOffset = 2 * PtrSize;
9067 E =
Decl->sel_param_end(); PI != E; ++PI) {
9070 if (
const auto *AT =
9079 PType, S, Extended);
9090 const Decl *Container)
const {
9093 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
9094 for (
auto *PID : CID->property_impls())
9095 if (PID->getPropertyDecl() == PD)
9099 for (
auto *PID : OID->property_impls())
9100 if (PID->getPropertyDecl() == PD)
9134 const Decl *Container)
const {
9136 bool Dynamic =
false;
9144 SynthesizePID = PropertyImpDecl;
9148 std::string S =
"T";
9193 if (SynthesizePID) {
9210 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9213 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9226 getObjCEncodingForTypeImpl(
T, S,
9228 .setExpandPointedToStructures()
9229 .setExpandStructures()
9230 .setIsOutermostType(),
9231 Field, NotEncodedT);
9235 std::string& S)
const {
9239 getObjCEncodingForTypeImpl(
T, S,
9241 .setExpandPointedToStructures()
9242 .setExpandStructures()
9243 .setIsOutermostType()
9244 .setEncodingProperty(),
9252 case BuiltinType::Void:
return 'v';
9253 case BuiltinType::Bool:
return 'B';
9254 case BuiltinType::Char8:
9255 case BuiltinType::Char_U:
9256 case BuiltinType::UChar:
return 'C';
9257 case BuiltinType::Char16:
9258 case BuiltinType::UShort:
return 'S';
9259 case BuiltinType::Char32:
9260 case BuiltinType::UInt:
return 'I';
9261 case BuiltinType::ULong:
9262 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9263 case BuiltinType::UInt128:
return 'T';
9264 case BuiltinType::ULongLong:
return 'Q';
9265 case BuiltinType::Char_S:
9266 case BuiltinType::SChar:
return 'c';
9267 case BuiltinType::Short:
return 's';
9268 case BuiltinType::WChar_S:
9269 case BuiltinType::WChar_U:
9270 case BuiltinType::Int:
return 'i';
9271 case BuiltinType::Long:
9272 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9273 case BuiltinType::LongLong:
return 'q';
9274 case BuiltinType::Int128:
return 't';
9275 case BuiltinType::Float:
return 'f';
9276 case BuiltinType::Double:
return 'd';
9277 case BuiltinType::LongDouble:
return 'D';
9278 case BuiltinType::NullPtr:
return '*';
9280 case BuiltinType::BFloat16:
9281 case BuiltinType::Float16:
9282 case BuiltinType::Float128:
9283 case BuiltinType::Ibm128:
9284 case BuiltinType::Half:
9285 case BuiltinType::ShortAccum:
9286 case BuiltinType::Accum:
9287 case BuiltinType::LongAccum:
9288 case BuiltinType::UShortAccum:
9289 case BuiltinType::UAccum:
9290 case BuiltinType::ULongAccum:
9291 case BuiltinType::ShortFract:
9292 case BuiltinType::Fract:
9293 case BuiltinType::LongFract:
9294 case BuiltinType::UShortFract:
9295 case BuiltinType::UFract:
9296 case BuiltinType::ULongFract:
9297 case BuiltinType::SatShortAccum:
9298 case BuiltinType::SatAccum:
9299 case BuiltinType::SatLongAccum:
9300 case BuiltinType::SatUShortAccum:
9301 case BuiltinType::SatUAccum:
9302 case BuiltinType::SatULongAccum:
9303 case BuiltinType::SatShortFract:
9304 case BuiltinType::SatFract:
9305 case BuiltinType::SatLongFract:
9306 case BuiltinType::SatUShortFract:
9307 case BuiltinType::SatUFract:
9308 case BuiltinType::SatULongFract:
9312#define SVE_TYPE(Name, Id, SingletonId) \
9313 case BuiltinType::Id:
9314#include "clang/Basic/AArch64ACLETypes.def"
9315#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9316#include "clang/Basic/RISCVVTypes.def"
9317#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9318#include "clang/Basic/WebAssemblyReferenceTypes.def"
9319#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9320#include "clang/Basic/AMDGPUTypes.def"
9321#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9322#include "clang/Basic/SPIRVTypes.def"
9325 Diags.
Report(diag::err_unsupported_objc_primitive_encoding)
9330 case BuiltinType::ObjCId:
9331 case BuiltinType::ObjCClass:
9332 case BuiltinType::ObjCSel:
9333 llvm_unreachable(
"@encoding ObjC primitive type");
9336#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9337 case BuiltinType::Id:
9338#include "clang/Basic/OpenCLImageTypes.def"
9339#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9340 case BuiltinType::Id:
9341#include "clang/Basic/OpenCLExtensionTypes.def"
9342 case BuiltinType::OCLEvent:
9343 case BuiltinType::OCLClkEvent:
9344 case BuiltinType::OCLQueue:
9345 case BuiltinType::OCLReserveID:
9346 case BuiltinType::OCLSampler:
9347 case BuiltinType::Dependent:
9348 case BuiltinType::MetaInfo:
9349#define PPC_VECTOR_TYPE(Name, Id, Size) \
9350 case BuiltinType::Id:
9351#include "clang/Basic/PPCTypes.def"
9352#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9353#include "clang/Basic/HLSLIntangibleTypes.def"
9354#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9355#include "clang/Basic/HLSLPackedTypes.def"
9356#define BUILTIN_TYPE(KIND, ID)
9357#define PLACEHOLDER_TYPE(KIND, ID) \
9358 case BuiltinType::KIND:
9359#include "clang/AST/BuiltinTypes.def"
9360 llvm_unreachable(
"invalid builtin type for @encode");
9362 llvm_unreachable(
"invalid BuiltinType::Kind value");
9369 if (!
Enum->isFixed())
9379 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9399 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9407 S += llvm::utostr(Offset);
9409 if (
const auto *ET =
T->getAsCanonical<EnumType>())
9422 bool VisitBasesAndFields) {
9423 T =
T->getBaseElementTypeUnsafe();
9427 PT->getPointeeType().getTypePtr(),
false);
9429 auto *CXXRD =
T->getAsCXXRecordDecl();
9437 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9440 for (
const auto &B : CXXRD->bases())
9445 for (
auto *FD : CXXRD->fields())
9454void ASTContext::getObjCEncodingForTypeImpl(QualType
T, std::string &S,
9455 const ObjCEncOptions Options,
9456 const FieldDecl *FD,
9457 QualType *NotEncodedT)
const {
9459 switch (CT->getTypeClass()) {
9464 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9472 getObjCEncodingForTypeImpl(
T->
castAs<ComplexType>()->getElementType(), S,
9479 getObjCEncodingForTypeImpl(
T->
castAs<AtomicType>()->getValueType(), S,
9486 case Type::LValueReference:
9487 case Type::RValueReference: {
9490 const auto *PT =
T->
castAs<PointerType>();
9491 if (PT->isObjCSelType()) {
9500 bool isReadOnly =
false;
9505 if (
T->
getAs<TypedefType>()) {
9506 if (Options.IsOutermostType() &&
T.isConstQualified()) {
9510 }
else if (Options.IsOutermostType()) {
9511 QualType P = PointeeTy;
9512 while (
auto PT = P->
getAs<PointerType>())
9523 if (StringRef(S).ends_with(
"nr"))
9524 S.replace(S.end()-2, S.end(),
"rn");
9534 }
else if (
const auto *RTy = PointeeTy->
getAsCanonical<RecordType>()) {
9535 const IdentifierInfo *II = RTy->getDecl()->getIdentifier();
9537 if (II == &
Idents.get(
"objc_class")) {
9542 if (II == &
Idents.get(
"objc_object")) {
9551 RTy, Options.ExpandPointedToStructures()))) {
9560 ObjCEncOptions NewOptions;
9561 if (Options.ExpandPointedToStructures())
9562 NewOptions.setExpandStructures();
9563 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9564 nullptr, NotEncodedT);
9568 case Type::ConstantArray:
9569 case Type::IncompleteArray:
9570 case Type::VariableArray: {
9577 getObjCEncodingForTypeImpl(
9578 AT->getElementType(), S,
9579 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9583 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9584 S += llvm::utostr(CAT->getZExtSize());
9588 "Unknown array type!");
9592 getObjCEncodingForTypeImpl(
9593 AT->getElementType(), S,
9594 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9601 case Type::FunctionNoProto:
9602 case Type::FunctionProto:
9606 case Type::Record: {
9608 S += RDecl->
isUnion() ?
'(' :
'{';
9612 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9613 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
9614 llvm::raw_string_ostream
OS(S);
9615 printTemplateArgumentList(OS, TemplateArgs.
asArray(),
9621 if (Options.ExpandStructures()) {
9624 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9626 for (
const auto *Field : RDecl->
fields()) {
9629 S +=
Field->getNameAsString();
9634 if (
Field->isBitField()) {
9635 getObjCEncodingForTypeImpl(
Field->getType(), S,
9636 ObjCEncOptions().setExpandStructures(),
9639 QualType qt =
Field->getType();
9641 getObjCEncodingForTypeImpl(
9643 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9649 S += RDecl->
isUnion() ?
')' :
'}';
9653 case Type::BlockPointer: {
9654 const auto *BT =
T->
castAs<BlockPointerType>();
9656 if (Options.EncodeBlockParameters()) {
9657 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
9661 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9662 Options.forComponentType(), FD, NotEncodedT);
9666 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9667 for (
const auto &I : FPT->param_types())
9668 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9676 case Type::ObjCObject: {
9680 S +=
"{objc_object=}";
9684 S +=
"{objc_class=}";
9691 case Type::ObjCInterface: {
9694 ObjCInterfaceDecl *OI =
T->
castAs<ObjCObjectType>()->getInterface();
9697 if (Options.ExpandStructures()) {
9699 SmallVector<const ObjCIvarDecl*, 32> Ivars;
9701 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9702 const FieldDecl *
Field = Ivars[i];
9703 if (
Field->isBitField())
9704 getObjCEncodingForTypeImpl(
Field->getType(), S,
9705 ObjCEncOptions().setExpandStructures(),
9708 getObjCEncodingForTypeImpl(
Field->getType(), S,
9709 ObjCEncOptions().setExpandStructures(), FD,
9717 case Type::ObjCObjectPointer: {
9718 const auto *OPT =
T->
castAs<ObjCObjectPointerType>();
9719 if (OPT->isObjCIdType()) {
9724 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9732 if (OPT->isObjCQualifiedIdType()) {
9733 getObjCEncodingForTypeImpl(
9735 Options.keepingOnly(ObjCEncOptions()
9736 .setExpandPointedToStructures()
9737 .setExpandStructures()),
9739 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9743 for (
const auto *I : OPT->quals()) {
9745 S += I->getObjCRuntimeNameAsString();
9754 if (OPT->getInterfaceDecl() &&
9755 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9757 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9758 for (
const auto *I : OPT->quals()) {
9760 S += I->getObjCRuntimeNameAsString();
9770 case Type::MemberPointer:
9774 case Type::ExtVector:
9780 case Type::ConstantMatrix:
9793 case Type::DeducedTemplateSpecialization:
9796 case Type::HLSLAttributedResource:
9797 case Type::HLSLInlineSpirv:
9798 case Type::OverflowBehavior:
9799 llvm_unreachable(
"unexpected type");
9801 case Type::ArrayParameter:
9803#define ABSTRACT_TYPE(KIND, BASE)
9804#define TYPE(KIND, BASE)
9805#define DEPENDENT_TYPE(KIND, BASE) \
9807#define NON_CANONICAL_TYPE(KIND, BASE) \
9809#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9811#include "clang/AST/TypeNodes.inc"
9812 llvm_unreachable(
"@encode for dependent type!");
9814 llvm_unreachable(
"bad type kind!");
9817void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
9819 const FieldDecl *FD,
9821 QualType *NotEncodedT)
const {
9822 assert(RDecl &&
"Expected non-null RecordDecl");
9823 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9827 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9828 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9832 for (
const auto &BI : CXXRec->bases()) {
9833 if (!BI.isVirtual()) {
9838 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9839 std::make_pair(offs, base));
9844 for (FieldDecl *Field : RDecl->
fields()) {
9845 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9848 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9849 std::make_pair(offs, Field));
9852 if (CXXRec && includeVBases) {
9853 for (
const auto &BI : CXXRec->vbases()) {
9859 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9860 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9861 std::make_pair(offs, base));
9875 std::multimap<uint64_t, NamedDecl *>::iterator
9876 CurLayObj = FieldOrBaseOffsets.begin();
9878 if (CXXRec && CXXRec->isDynamicClass() &&
9879 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9882 std::string recname = CXXRec->getNameAsString();
9883 if (recname.empty()) recname =
"?";
9896 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9897 std::make_pair(offs,
nullptr));
9900 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9902 assert(CurOffs <= CurLayObj->first);
9903 if (CurOffs < CurLayObj->first) {
9904 uint64_t padding = CurLayObj->first - CurOffs;
9916 NamedDecl *dcl = CurLayObj->second;
9920 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9925 getObjCEncodingForStructureImpl(base, S, FD,
false,
9935 S += field->getNameAsString();
9939 if (field->isBitField()) {
9942 CurOffs += field->getBitWidthValue();
9945 QualType qt = field->getType();
9947 getObjCEncodingForTypeImpl(
9948 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9959 std::string& S)
const {
9992 if (!ObjCClassDecl) {
9997 return ObjCClassDecl;
10001 if (!ObjCProtocolClassDecl) {
10002 ObjCProtocolClassDecl
10005 &
Idents.get(
"Protocol"),
10011 return ObjCProtocolClassDecl;
10032 QualType T = Context->getPointerType(Context->CharTy);
10033 return Context->buildImplicitTypedef(
T, Name);
10042 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 2);
10043 QualType T = Context->getPointerType(Context->CharTy);
10046 return Context->buildImplicitTypedef(
ArrayType,
"__builtin_zos_va_list");
10055 QualType T = Context->getPointerType(Context->VoidTy);
10056 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10059static TypedefDecl *
10063 if (Context->getLangOpts().CPlusPlus) {
10068 &Context->Idents.get(
"std"),
10076 const size_t NumFields = 5;
10078 const char *FieldNames[NumFields];
10081 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10082 FieldNames[0] =
"__stack";
10085 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10086 FieldNames[1] =
"__gr_top";
10089 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10090 FieldNames[2] =
"__vr_top";
10093 FieldTypes[3] = Context->IntTy;
10094 FieldNames[3] =
"__gr_offs";
10097 FieldTypes[4] = Context->IntTy;
10098 FieldNames[4] =
"__vr_offs";
10101 for (
unsigned i = 0; i < NumFields; ++i) {
10106 &Context->Idents.get(FieldNames[i]),
10107 FieldTypes[i],
nullptr,
10119 return Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10126 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10129 const size_t NumFields = 5;
10131 const char *FieldNames[NumFields];
10134 FieldTypes[0] = Context->UnsignedCharTy;
10135 FieldNames[0] =
"gpr";
10138 FieldTypes[1] = Context->UnsignedCharTy;
10139 FieldNames[1] =
"fpr";
10142 FieldTypes[2] = Context->UnsignedShortTy;
10143 FieldNames[2] =
"reserved";
10146 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10147 FieldNames[3] =
"overflow_arg_area";
10150 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
10151 FieldNames[4] =
"reg_save_area";
10154 for (
unsigned i = 0; i < NumFields; ++i) {
10158 &Context->Idents.get(FieldNames[i]),
10159 FieldTypes[i],
nullptr,
10172 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10176 std::nullopt, VaListTagTypedefDecl);
10179 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10180 QualType VaListTagArrayType = Context->getConstantArrayType(
10182 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10185static TypedefDecl *
10189 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10192 const size_t NumFields = 4;
10194 const char *FieldNames[NumFields];
10197 FieldTypes[0] = Context->UnsignedIntTy;
10198 FieldNames[0] =
"gp_offset";
10201 FieldTypes[1] = Context->UnsignedIntTy;
10202 FieldNames[1] =
"fp_offset";
10205 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10206 FieldNames[2] =
"overflow_arg_area";
10209 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10210 FieldNames[3] =
"reg_save_area";
10213 for (
unsigned i = 0; i < NumFields; ++i) {
10218 &Context->Idents.get(FieldNames[i]),
10219 FieldTypes[i],
nullptr,
10233 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10234 QualType VaListTagArrayType = Context->getConstantArrayType(
10236 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10239static TypedefDecl *
10242 RecordDecl *VaListDecl = Context->buildImplicitRecord(
"__va_list");
10243 if (Context->getLangOpts().CPlusPlus) {
10262 &Context->Idents.get(
"__ap"),
10263 Context->getPointerType(Context->VoidTy),
10273 Context->VaListTagDecl = VaListDecl;
10276 CanQualType T = Context->getCanonicalTagType(VaListDecl);
10277 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10280static TypedefDecl *
10284 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10287 const size_t NumFields = 4;
10289 const char *FieldNames[NumFields];
10292 FieldTypes[0] = Context->LongTy;
10293 FieldNames[0] =
"__gpr";
10296 FieldTypes[1] = Context->LongTy;
10297 FieldNames[1] =
"__fpr";
10300 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10301 FieldNames[2] =
"__overflow_arg_area";
10304 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10305 FieldNames[3] =
"__reg_save_area";
10308 for (
unsigned i = 0; i < NumFields; ++i) {
10313 &Context->Idents.get(FieldNames[i]),
10314 FieldTypes[i],
nullptr,
10328 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10329 QualType VaListTagArrayType = Context->getConstantArrayType(
10332 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10338 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10341 const size_t NumFields = 3;
10343 const char *FieldNames[NumFields];
10346 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10347 FieldNames[0] =
"__current_saved_reg_area_pointer";
10350 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10351 FieldNames[1] =
"__saved_reg_area_end_pointer";
10354 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10355 FieldNames[2] =
"__overflow_area_pointer";
10358 for (
unsigned i = 0; i < NumFields; ++i) {
10361 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
10374 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10378 std::nullopt, VaListTagTypedefDecl);
10381 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10382 QualType VaListTagArrayType = Context->getConstantArrayType(
10385 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10388static TypedefDecl *
10398 constexpr size_t NumFields = 3;
10399 QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
10400 Context->getPointerType(Context->IntTy),
10402 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10405 for (
unsigned i = 0; i < NumFields; ++i) {
10408 &Context->Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
10420 Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10422 return VaListTagTypedefDecl;
10448 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10452 if (!BuiltinVaListDecl) {
10453 BuiltinVaListDecl =
CreateVaListDecl(
this, Target->getBuiltinVaListKind());
10454 assert(BuiltinVaListDecl->isImplicit());
10457 return BuiltinVaListDecl;
10470 if (!BuiltinMSVaListDecl)
10473 return BuiltinMSVaListDecl;
10477 if (!BuiltinZOSVaListDecl)
10480 return BuiltinZOSVaListDecl;
10497 assert(ObjCConstantStringType.isNull() &&
10498 "'NSConstantString' type already set!");
10508 unsigned size = End - Begin;
10509 assert(size > 1 &&
"set is not overloaded!");
10515 NamedDecl **Storage = OT->getStorage();
10538 bool TemplateKeyword,
10543 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10544 assert(!Qualifier &&
"unexpected qualified template template parameter");
10545 assert(TemplateKeyword ==
false);
10550 llvm::FoldingSetNodeID ID;
10553 llvm::FoldingSetInsertToken
Token;
10558 QualifiedTemplateNames.insert(QTN,
Token);
10568 llvm::FoldingSetNodeID ID;
10571 llvm::FoldingSetInsertToken
Token;
10577 DependentTemplateNames.insert(QTN,
Token);
10582 Decl *AssociatedDecl,
10585 bool Final)
const {
10586 llvm::FoldingSetNodeID ID;
10590 llvm::FoldingSetInsertToken
Token;
10592 SubstTemplateTemplateParms.lookup(ID,
Token);
10596 Replacement, AssociatedDecl, Index,
PackIndex, Final);
10597 SubstTemplateTemplateParms.insert(subst,
Token);
10605 Decl *AssociatedDecl,
10606 unsigned Index,
bool Final)
const {
10608 llvm::FoldingSetNodeID ID;
10610 AssociatedDecl, Index, Final);
10612 llvm::FoldingSetInsertToken
Token;
10614 SubstTemplateTemplateParmPacks.lookup(ID,
Token);
10619 SubstTemplateTemplateParmPacks.insert(Subst,
Token);
10633 llvm::FoldingSetNodeID ID;
10636 llvm::FoldingSetInsertToken
Token;
10643 DeducedTemplates.insert(DTS,
Token);
10652 llvm::FoldingSetNodeID ID;
10654 FullySubstituted, Expansions);
10656 llvm::FoldingSetInsertToken
Token;
10660 Allocate(PackIndexingTemplateStorage::totalSizeToAlloc<TemplateName>(
10661 Expansions.size()),
10664 FullySubstituted, Expansions);
10665 PackIndexingTemplates.insert(PI,
Token);
10688 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10718 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10719 CT = AT->getElementType();
10751 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10752 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10801 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
10802 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
10804 if (!LHSOBT && !RHSOBT)
10807 if (LHSOBT && RHSOBT) {
10808 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
10813 QualType LHSUnderlying = LHSOBT ? LHSOBT->desugar() : LHS;
10814 QualType RHSUnderlying = RHSOBT ? RHSOBT->desugar() : RHS;
10816 if (RHSOBT && !LHSOBT) {
10827 auto VScale = Context.getTargetInfo().getVScaleRange(
10834 uint64_t EltSize = Context.getTypeSize(Info.
ElementType);
10838 uint64_t MinElts = Info.
EC.getKnownMinValue();
10839 return VScale->first * MinElts * EltSize;
10847 "Expected RVV builtin type and vector type!");
10859 (llvm::RISCV::RVVBitsPerBlock >>
10861 Info.
EC.getKnownMinValue() &&
10875 return IsValidCast(FirstType, SecondType) ||
10876 IsValidCast(SecondType, FirstType);
10884 "Expected RVV builtin type and vector type!");
10891 if (!BT->isRVVVLSBuiltinType())
10911 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10918 return IsLaxCompatible(FirstType, SecondType) ||
10919 IsLaxCompatible(SecondType, FirstType);
10925 if (
const AttributedType *
Attr = dyn_cast<AttributedType>(Ty)) {
10926 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10929 Ty =
Attr->getModifiedType();
10933 Ty =
Paren->getInnerType();
10965 for (
auto *lhsProto : lhs->
quals()) {
10966 bool match =
false;
10967 for (
auto *rhsProto : rhs->
quals()) {
10998 for (
auto *I : lhs->
quals()) {
11002 if (!rhsID->ClassImplementsProtocol(I,
true))
11010 for (
auto *lhsProto : lhs->
quals()) {
11011 bool match =
false;
11016 for (
auto *rhsProto : rhs->
quals()) {
11026 for (
auto *I : lhs->
quals()) {
11030 if (rhsID->ClassImplementsProtocol(I,
true)) {
11047 for (
auto *lhsProto : lhs->
quals()) {
11048 bool match =
false;
11055 for (
auto *rhsProto : rhs->
quals()) {
11074 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
11076 for (
auto *lhsProto : LHSInheritedProtocols) {
11077 bool match =
false;
11078 for (
auto *rhsProto : rhs->
quals()) {
11103 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
11108 auto finish = [&](
bool succeeded) ->
bool {
11112 if (!RHS->isKindOfType())
11123 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
11128 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
11133 if (LHS->isObjCClass() && RHS->isObjCClass()) {
11138 if (LHS->getInterface() && RHS->getInterface()) {
11153 bool BlockReturnType) {
11157 auto finish = [&](
bool succeeded) ->
bool {
11182 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
11186 (!BlockReturnType &&
11190 (BlockReturnType ? LHSOPT : RHSOPT),
11191 (BlockReturnType ? RHSOPT : LHSOPT),
false));
11199 return finish(BlockReturnType);
11201 return finish(!BlockReturnType);
11213 return (*lhs)->getName().compare((*rhs)->getName());
11230 assert(LHS->getInterface() &&
"LHS must have an interface base");
11231 assert(RHS->getInterface() &&
"RHS must have an interface base");
11237 for (
auto *proto : LHS->quals()) {
11238 Context.CollectInheritedProtocols(proto, LHSProtocolSet);
11242 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
11248 for (
auto *proto : RHS->quals()) {
11249 Context.CollectInheritedProtocols(proto, RHSProtocolSet);
11253 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
11256 for (
auto *proto : LHSProtocolSet) {
11257 if (RHSProtocolSet.count(proto))
11258 IntersectionSet.push_back(proto);
11264 Context.CollectInheritedProtocols(CommonBase, ImpliedProtocols);
11267 if (!ImpliedProtocols.empty()) {
11269 return ImpliedProtocols.contains(proto);
11274 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11284 if (lhsOPT && rhsOPT)
11290 if (lhsBlock && rhsBlock)
11295 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11307 bool stripKindOf) {
11308 if (lhsArgs.size() != rhsArgs.size())
11315 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11321 if (!stripKindOf ||
11322 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11323 rhsArgs[i].stripObjCKindOfType(ctx))) {
11351 if (!LDecl || !RDecl)
11357 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
11361 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11366 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
11371 bool anyChanges =
false;
11372 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11375 LHS->getTypeArgs(), RHS->getTypeArgs(),
11378 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11389 if (!Protocols.empty())
11395 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
11398 anyKindOf || LHS->isKindOfType());
11406 QualType LHSSuperType = LHS->getSuperClassType();
11407 if (LHSSuperType.
isNull())
11416 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
11417 if (KnownLHS != LHSAncestors.end()) {
11418 LHS = KnownLHS->second;
11422 bool anyChanges =
false;
11423 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11426 LHS->getTypeArgs(), RHS->getTypeArgs(),
11429 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11440 if (!Protocols.empty())
11445 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
11448 anyKindOf || RHS->isKindOfType());
11456 QualType RHSSuperType = RHS->getSuperClassType();
11457 if (RHSSuperType.
isNull())
11468 assert(LHS->getInterface() &&
"LHS is not an interface type");
11469 assert(RHS->getInterface() &&
"RHS is not an interface type");
11474 bool IsSuperClass = LHSInterface->
isSuperClassOf(RHS->getInterface());
11481 if (LHS->getNumProtocols() > 0) {
11490 for (
auto *RHSPI : RHS->quals())
11493 if (SuperClassInheritedProtocols.empty())
11496 for (
const auto *LHSProto : LHS->quals()) {
11497 bool SuperImplementsProtocol =
false;
11498 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11499 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11500 SuperImplementsProtocol =
true;
11503 if (!SuperImplementsProtocol)
11509 if (LHS->isSpecialized()) {
11514 RHSSuper = RHSSuper->getSuperClassType()->castAs<
ObjCObjectType>();
11517 if (RHSSuper->isSpecialized() &&
11519 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
11533 if (!LHSOPT || !RHSOPT)
11551 bool CompareUnqualified) {
11570 bool OfBlockPointer,
11572 if (
const RecordType *UT =
T->getAsUnionType()) {
11574 if (UD->
hasAttr<TransparentUnionAttr>()) {
11575 for (
const auto *I : UD->
fields()) {
11576 QualType ET = I->getType().getUnqualifiedType();
11590 bool OfBlockPointer,
11611 bool IsConditionalOperator) {
11614 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11615 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11616 bool allLTypes =
true;
11617 bool allRTypes =
true;
11621 if (OfBlockPointer) {
11623 QualType LHS = lbase->getReturnType();
11625 if (!UnqualifiedResult)
11627 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11692 bool NoReturn = IsConditionalOperator
11702 std::optional<FunctionEffectSet> MergedFX;
11704 if (lproto && rproto) {
11705 assert((AllowCXX ||
11706 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11707 "C++ shouldn't be here");
11709 if (lproto->getNumParams() != rproto->getNumParams())
11713 if (lproto->isVariadic() != rproto->isVariadic())
11716 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11720 if (lproto->getExtraAttributeInfo().CFISalt !=
11721 rproto->getExtraAttributeInfo().CFISalt)
11727 if (LHSFX != RHSFX) {
11728 if (IsConditionalOperator)
11737 if (*MergedFX != LHSFX)
11739 if (*MergedFX != RHSFX)
11744 bool canUseLeft, canUseRight;
11756 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11757 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11758 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11760 lParamType, rParamType, OfBlockPointer,
Unqualified);
11767 types.push_back(paramType);
11779 if (allLTypes)
return lhs;
11780 if (allRTypes)
return rhs;
11785 newParamInfos.empty() ?
nullptr : newParamInfos.data();
11791 if (lproto) allRTypes =
false;
11792 if (rproto) allLTypes =
false;
11796 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11804 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11810 paramTy = ED->getIntegerType();
11820 if (allLTypes)
return lhs;
11821 if (allRTypes)
return rhs;
11830 if (allLTypes)
return lhs;
11831 if (allRTypes)
return rhs;
11837 QualType other,
bool isBlockReturnType) {
11843 ET->getDecl()->getDefinitionOrSelf()->getIntegerType();
11844 if (underlyingType.
isNull())
11846 if (Context.hasSameType(underlyingType, other))
11852 Context.getTypeSize(underlyingType) == Context.getTypeSize(other))
11861 if (LangOpts.CPlusPlus || !LangOpts.C23)
11882 bool BlockReturnType,
bool IsConditionalOperator) {
11883 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
11884 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
11886 if (!LHSOBT && !RHSOBT)
11887 return std::nullopt;
11891 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
11895 LHSOBT->getUnderlyingType(), RHSOBT->getUnderlyingType(),
11896 OfBlockPointer,
Unqualified, BlockReturnType, IsConditionalOperator);
11898 if (MergedUnderlying.
isNull())
11902 if (LHSOBT->getUnderlyingType() == RHSOBT->getUnderlyingType())
11905 LHSOBT->getBehaviorKind(),
11914 return mergeTypes(LHSOBT->getUnderlyingType(), RHS, OfBlockPointer,
11915 Unqualified, BlockReturnType, IsConditionalOperator);
11918 return mergeTypes(LHS, RHSOBT->getUnderlyingType(), OfBlockPointer,
11919 Unqualified, BlockReturnType, IsConditionalOperator);
11924 bool IsConditionalOperator) {
11935 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11939 if (LHSRefTy || RHSRefTy)
11942 if (std::optional<QualType> MergedOBT =
11944 BlockReturnType, IsConditionalOperator))
11956 if (LHSCan == RHSCan)
11961 Qualifiers RQuals = RHSCan.getLocalQualifiers();
11962 if (LQuals != RQuals) {
11979 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12000 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
12001 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
12004 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
12005 LHSClass = Type::ConstantArray;
12006 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
12007 RHSClass = Type::ConstantArray;
12010 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
12011 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
12014 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
12015 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
12018 if (LHSClass != RHSClass) {
12028 if (OfBlockPointer && !BlockReturnType) {
12036 if (
const auto *AT = LHS->
getAs<AutoType>()) {
12037 if (!AT->isDeduced() && AT->isGNUAutoType())
12040 if (
const auto *AT = RHS->
getAs<AutoType>()) {
12041 if (!AT->isDeduced() && AT->isGNUAutoType())
12048 switch (LHSClass) {
12049#define TYPE(Class, Base)
12050#define ABSTRACT_TYPE(Class, Base)
12051#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
12052#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
12053#define DEPENDENT_TYPE(Class, Base) case Type::Class:
12054#include "clang/AST/TypeNodes.inc"
12055 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
12058 case Type::DeducedTemplateSpecialization:
12059 case Type::LValueReference:
12060 case Type::RValueReference:
12061 case Type::MemberPointer:
12062 llvm_unreachable(
"C++ should never be in mergeTypes");
12064 case Type::ObjCInterface:
12065 case Type::IncompleteArray:
12066 case Type::VariableArray:
12067 case Type::FunctionProto:
12068 case Type::ExtVector:
12069 case Type::OverflowBehavior:
12070 llvm_unreachable(
"Types are eliminated above");
12072 case Type::Pointer:
12083 if (ResultType.
isNull())
12091 case Type::BlockPointer:
12116 if (ResultType.
isNull())
12135 if (ResultType.
isNull())
12143 case Type::ConstantArray:
12158 if (ResultType.
isNull())
12166 if (LVAT || RVAT) {
12169 -> std::pair<bool,llvm::APInt> {
12171 std::optional<llvm::APSInt> TheInt;
12174 return std::make_pair(
true, *TheInt);
12175 return std::make_pair(
false, llvm::APSInt());
12178 return std::make_pair(
true, CAT->getSize());
12179 return std::make_pair(
false, llvm::APInt());
12182 bool HaveLSize, HaveRSize;
12183 llvm::APInt LSize, RSize;
12184 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
12185 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
12186 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
12220 case Type::FunctionNoProto:
12222 false, IsConditionalOperator);
12226 case Type::Builtin:
12229 case Type::Complex:
12238 case Type::ConstantMatrix:
12243 case Type::ObjCObject: {
12252 case Type::ObjCObjectPointer:
12253 if (OfBlockPointer) {
12265 assert(LHS != RHS &&
12266 "Equivalent pipe types should have already been handled!");
12268 case Type::ArrayParameter:
12269 assert(LHS != RHS &&
12270 "Equivalent ArrayParameter types should have already been handled!");
12272 case Type::BitInt: {
12280 if (LHSUnsigned != RHSUnsigned)
12283 if (LHSBits != RHSBits)
12287 case Type::HLSLAttributedResource: {
12288 const HLSLAttributedResourceType *LHSTy =
12289 LHS->
castAs<HLSLAttributedResourceType>();
12290 const HLSLAttributedResourceType *RHSTy =
12291 RHS->
castAs<HLSLAttributedResourceType>();
12292 assert(LHSTy->getWrappedType() == RHSTy->getWrappedType() &&
12293 LHSTy->getWrappedType()->isHLSLResourceType() &&
12294 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
12296 if (LHSTy->getAttrs() == RHSTy->getAttrs() &&
12297 LHSTy->getContainedType() == RHSTy->getContainedType())
12301 case Type::HLSLInlineSpirv:
12302 const HLSLInlineSpirvType *LHSTy = LHS->
castAs<HLSLInlineSpirvType>();
12303 const HLSLInlineSpirvType *RHSTy = RHS->
castAs<HLSLInlineSpirvType>();
12305 if (LHSTy->getOpcode() == RHSTy->getOpcode() &&
12306 LHSTy->getSize() == RHSTy->getSize() &&
12307 LHSTy->getAlignment() == RHSTy->getAlignment()) {
12308 for (
size_t I = 0; I < LHSTy->getOperands().size(); I++)
12309 if (LHSTy->getOperands()[I] != RHSTy->getOperands()[I])
12317 llvm_unreachable(
"Invalid Type::Class!");
12322 bool &CanUseFirst,
bool &CanUseSecond,
12324 assert(NewParamInfos.empty() &&
"param info list not empty");
12325 CanUseFirst = CanUseSecond =
true;
12331 if (!FirstHasInfo && !SecondHasInfo)
12334 bool NeedParamInfo =
false;
12338 for (
size_t I = 0; I < E; ++I) {
12349 bool FirstNoEscape = FirstParam.
isNoEscape();
12350 bool SecondNoEscape = SecondParam.
isNoEscape();
12351 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12353 if (NewParamInfos.back().getOpaqueValue())
12354 NeedParamInfo =
true;
12355 if (FirstNoEscape != IsNoEscape)
12356 CanUseFirst =
false;
12357 if (SecondNoEscape != IsNoEscape)
12358 CanUseSecond =
false;
12361 if (!NeedParamInfo)
12362 NewParamInfos.clear();
12368 if (
auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
12369 It->second =
nullptr;
12370 for (
auto *SubClass : ObjCSubClasses.lookup(D))
12382 if (LHSCan == RHSCan)
12384 if (RHSCan->isFunctionType()) {
12393 if (ResReturnType.
isNull())
12395 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12412 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12419 if (LQuals != RQuals) {
12427 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12443 if (ResQT == LHSBaseQT)
12445 if (ResQT == RHSBaseQT)
12456 if (
const auto *ED =
T->getAsEnumDecl())
12457 T = ED->getIntegerType();
12458 if (
T->isBooleanType())
12461 return EIT->getNumBits();
12467 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12468 T->isFixedPointType()) &&
12469 "Unexpected type");
12474 VTy->getNumElements(), VTy->getVectorKind());
12481 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>())
12483 OBT->getBehaviorKind(),
12488 if (
const auto *ED =
T->getAsEnumDecl())
12489 T = ED->getIntegerType();
12492 case BuiltinType::Char_U:
12494 case BuiltinType::Char_S:
12495 case BuiltinType::SChar:
12496 case BuiltinType::Char8:
12498 case BuiltinType::Short:
12500 case BuiltinType::Int:
12502 case BuiltinType::Long:
12504 case BuiltinType::LongLong:
12506 case BuiltinType::Int128:
12511 case BuiltinType::WChar_S:
12514 case BuiltinType::ShortAccum:
12516 case BuiltinType::Accum:
12518 case BuiltinType::LongAccum:
12520 case BuiltinType::SatShortAccum:
12522 case BuiltinType::SatAccum:
12524 case BuiltinType::SatLongAccum:
12526 case BuiltinType::ShortFract:
12528 case BuiltinType::Fract:
12530 case BuiltinType::LongFract:
12532 case BuiltinType::SatShortFract:
12534 case BuiltinType::SatFract:
12536 case BuiltinType::SatLongFract:
12539 assert((
T->hasUnsignedIntegerRepresentation() ||
12540 T->isUnsignedFixedPointType()) &&
12541 "Unexpected signed integer or fixed point type");
12547 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12548 T->isFixedPointType()) &&
12549 "Unexpected type");
12554 VTy->getNumElements(), VTy->getVectorKind());
12562 if (
const auto *ED =
T->getAsEnumDecl())
12563 T = ED->getIntegerType();
12566 case BuiltinType::Char_S:
12568 case BuiltinType::Char_U:
12569 case BuiltinType::UChar:
12570 case BuiltinType::Char8:
12572 case BuiltinType::UShort:
12574 case BuiltinType::UInt:
12576 case BuiltinType::ULong:
12578 case BuiltinType::ULongLong:
12580 case BuiltinType::UInt128:
12585 case BuiltinType::WChar_U:
12588 case BuiltinType::UShortAccum:
12590 case BuiltinType::UAccum:
12592 case BuiltinType::ULongAccum:
12594 case BuiltinType::SatUShortAccum:
12596 case BuiltinType::SatUAccum:
12598 case BuiltinType::SatULongAccum:
12600 case BuiltinType::UShortFract:
12602 case BuiltinType::UFract:
12604 case BuiltinType::ULongFract:
12606 case BuiltinType::SatUShortFract:
12608 case BuiltinType::SatUFract:
12610 case BuiltinType::SatULongFract:
12614 (
T->hasSignedIntegerRepresentation() ||
T->isSignedFixedPointType()) &&
12615 "Unexpected signed integer or fixed point type");
12640 bool AllowTypeModifiers) {
12644 bool IsChar =
false, IsShort =
false;
12645 bool IsLeast =
false;
12646 RequiresICE =
false;
12651 bool IsSpecial =
false;
12655 default: Done =
true; --Str;
break;
12657 RequiresICE =
true;
12660 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12661 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12665 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12666 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12671 assert(!IsLeast &&
"Can't use 'l' modifier multiple times!");
12676 assert(!IsSpecial &&
12677 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12678 assert(HowLong == 0 &&
"Can't use both 'L' and 'B' modifiers!");
12686 assert(!IsSpecial &&
12687 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12688 assert(HowLong == 0 &&
"Can't use both 'L' and 'T' modifiers!");
12695 assert(!IsSpecial &&
12696 "Can't use 'L' with 'W', 'N', 'Z', 'O', 'B', or 'T' modifiers");
12697 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12702 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12703 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12707 if (Context.getTargetInfo().getLongWidth() == 32)
12712 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12713 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12717 switch (Context.getTargetInfo().getInt64Type()) {
12719 llvm_unreachable(
"Unexpected integer type");
12730 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12731 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12735 switch (Context.getTargetInfo().getIntTypeByWidth(32,
true)) {
12737 llvm_unreachable(
"Unexpected integer type");
12750 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12751 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12755 if (Context.getLangOpts().OpenCL)
12768 llvm_unreachable(
"Unknown builtin type letter!");
12771 "Bad modifiers used with 'x'!");
12772 Type = Context.Float16Ty;
12776 "Bad modifiers used with 'y'!");
12777 Type = Context.BFloat16Ty;
12781 "Bad modifiers used with 'v'!");
12782 Type = Context.VoidTy;
12786 "Bad modifiers used with 'h'!");
12787 Type = Context.HalfTy;
12791 "Bad modifiers used with 'f'!");
12792 Type = Context.FloatTy;
12796 "Bad modifiers used with 'd'!");
12798 Type = Context.LongDoubleTy;
12799 else if (HowLong == 2)
12800 Type = Context.Float128Ty;
12802 Type = Context.DoubleTy;
12805 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12807 Type = Context.UnsignedShortTy;
12809 Type = Context.ShortTy;
12813 Type =
Unsigned ? Context.UnsignedCharTy : Context.SignedCharTy;
12815 Type =
Unsigned ? Context.UnsignedShortTy : Context.ShortTy;
12816 else if (HowLong == 3)
12817 Type =
Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
12818 else if (HowLong == 2)
12819 Type =
Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
12820 else if (HowLong == 1)
12821 Type =
Unsigned ? Context.UnsignedLongTy : Context.LongTy;
12823 Type =
Unsigned ? Context.UnsignedIntTy : Context.IntTy;
12825 Type = Context.getLeastIntTypeForBitwidth(Context.getIntWidth(
Type),
12829 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12831 Type = Context.SignedCharTy;
12833 Type = Context.UnsignedCharTy;
12835 Type = Context.CharTy;
12838 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12839 Type = Context.BoolTy;
12842 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12843 Type = Context.getSizeType();
12846 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12847 Type = Context.getWideCharType();
12850 Type = Context.getCFConstantStringType();
12853 Type = Context.getObjCIdType();
12856 Type = Context.getObjCSelType();
12859 Type = Context.getObjCSuperType();
12862 Type = Context.MetaInfoTy;
12865 Type = Context.getBuiltinVaListType();
12866 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12877 Type = Context.getBuiltinVaListType();
12878 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12880 Type = Context.getArrayDecayedType(
Type);
12882 Type = Context.getLValueReferenceType(
Type);
12886 unsigned NumElements = strtoul(Str, &End, 10);
12887 assert(End != Str &&
"Missing vector size");
12891 RequiresICE,
false);
12892 assert(!RequiresICE &&
"Can't require vector ICE");
12894 Type = Context.getScalableVectorType(ElementType, NumElements);
12900 Type = Context.SveCountTy;
12904 Type = Context.AMDGPUBufferRsrcTy;
12908 Type = Context.AMDGPUFeaturePredicateTy;
12912 Type = Context.AMDGPUTextureTy;
12916 Type = Context.HLSLResourceTy;
12920 llvm_unreachable(
"Unexpected target builtin type");
12926 unsigned NumElements = strtoul(Str, &End, 10);
12927 assert(End != Str &&
"Missing vector size");
12931 RequiresICE,
false);
12932 assert(!RequiresICE &&
"Can't require vector ICE");
12941 unsigned NumElements = strtoul(Str, &End, 10);
12942 assert(End != Str &&
"Missing vector size");
12948 Type = Context.getExtVectorType(ElementType, NumElements);
12954 assert(!RequiresICE &&
"Can't require complex ICE");
12955 Type = Context.getComplexType(ElementType);
12959 Type = Context.getPointerDiffType();
12962 Type = Context.getFILEType();
12963 if (
Type.isNull()) {
12970 Type = Context.getsigjmp_bufType();
12972 Type = Context.getjmp_bufType();
12974 if (
Type.isNull()) {
12980 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
12981 Type = Context.getucontext_tType();
12983 if (
Type.isNull()) {
12989 Type = Context.getProcessIDType();
12992 Type = Context.MFloat8Ty;
12997 Done = !AllowTypeModifiers;
12999 switch (
char c = *Str++) {
13000 default: Done =
true; --Str;
break;
13006 unsigned AddrSpace = strtoul(Str, &End, 10);
13009 Type = Context.getAddrSpaceQualType(
13011 Context.getLangASForBuiltinAddressSpace(AddrSpace));
13015 Type = Context.getPointerType(
Type);
13017 Type = Context.getLValueReferenceType(
Type);
13025 Type = Context.getVolatileType(
Type);
13034 "Integer constant 'I' type must be an integer");
13047 bool AllowTypeModifiers)
const {
13054 unsigned *IntegerConstantArgs)
const {
13055 const char *TypeStr =
BuiltinInfo.getTypeString(Id);
13056 if (TypeStr[0] ==
'\0') {
13063 bool RequiresICE =
false;
13066 RequiresICE,
true);
13070 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
13072 while (TypeStr[0] && TypeStr[0] !=
'.') {
13079 if (RequiresICE && IntegerConstantArgs)
13080 *IntegerConstantArgs |= 1 << ArgTypes.size();
13086 ArgTypes.push_back(Ty);
13089 if (Id == Builtin::BI__GetExceptionInfo)
13092 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
13093 "'.' should only occur at end of builtin type list!");
13095 bool Variadic = (TypeStr[0] ==
'.');
13102 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
13152 if ((!Context.getLangOpts().CPlusPlus &&
13153 !Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13154 !FD->
hasAttr<DLLExportAttr>()) ||
13155 FD->
hasAttr<GNUInlineAttr>()) {
13174 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13177 !FD->
hasAttr<DLLExportAttr>()) {
13198 if (D->
hasAttr<DLLImportAttr>()) {
13201 }
else if (D->
hasAttr<DLLExportAttr>()) {
13204 }
else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice) {
13207 if (D->
hasAttr<CUDAGlobalAttr>() &&
13216 if (Context.shouldExternalize(D))
13231 switch (Source->hasExternalDefinitions(D)) {
13258 if (Context.getLangOpts().CPlusPlus &&
13259 Context.getLangOpts().IncrementalExtensions &&
13275 if (!LexicalContext)
13280 auto StaticLocalLinkage =
13292 return StaticLocalLinkage;
13298 if (Context.isMSStaticDataMemberInlineDefinition(VD))
13304 switch (Context.getInlineVariableDefinitionKind(VD)) {
13319 return StrongLinkage;
13322 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13337 llvm_unreachable(
"Invalid Linkage!");
13347 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13348 if (!VD->isFileVarDecl())
13353 if (VD->getDescribedVarTemplate() ||
13356 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13382 if (D->
hasAttr<WeakRefAttr>())
13389 if (LangOpts.SYCLIsDevice)
13391 D->
hasAttr<SYCLExternalAttr>());
13397 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13399 if (!FD->doesThisDeclarationHaveABody())
13400 return FD->doesDeclarationForceExternallyVisibleDefinition();
13403 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13408 if (
getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
13409 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13428 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13432 if (LangOpts.OpenMP &&
13433 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13440 if (VD->shouldEmitInExternalSource())
13453 if (VD->needsDestruction(*
this))
13457 if (VD->hasInitWithSideEffects())
13462 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13463 for (
const auto *BD : DD->flat_bindings())
13464 if (
const auto *BindingVD = BD->getHoldingVar())
13473 if (
auto *A = D->
getAttr<AttrT>())
13474 return A->isImplicit();
13479 assert(LangOpts.CUDA &&
"Should not be called by non-CUDA languages");
13481 "Expected Variable or Function");
13483 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13487 return !LangOpts.CUDAIsDevice || VD->hasAttr<CUDADeviceAttr>() ||
13488 VD->hasAttr<CUDAConstantAttr>() || VD->hasAttr<CUDASharedAttr>() ||
13489 VD->getType()->isCUDADeviceBuiltinSurfaceType() ||
13490 VD->getType()->isCUDADeviceBuiltinTextureType();
13495 if (!LangOpts.CUDAIsDevice)
13496 return FD->
hasAttr<CUDAHostAttr>() || !FD->
hasAttr<CUDADeviceAttr>();
13500 return (FD->
hasAttr<CUDADeviceAttr>() &&
13501 !(LangOpts.OffloadImplicitHostDeviceTemplates &&
13506 FD->
hasAttr<CUDAGlobalAttr>() ||
13507 (LangOpts.HIPStdPar && !FD->
hasAttr<CUDAHostAttr>());
13512 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13513 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13514 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13519 for (
auto *CurDecl :
13523 SeenDecls.insert(CurFD).second) {
13530 bool IsCXXMethod)
const {
13533 return ABI->getDefaultMethodCallConv(IsVariadic);
13535 switch (LangOpts.getDefaultCallingConv()) {
13563 return Target->getDefaultCallingConv();
13568 return ABI->isNearlyEmpty(RD);
13573 auto ABI = Target->getCXXABI();
13574 if (ABI.isMicrosoft())
13580 return VTContext.get();
13586 switch (
T->getCXXABI().getKind()) {
13587 case TargetCXXABI::AppleARM64:
13588 case TargetCXXABI::Fuchsia:
13589 case TargetCXXABI::GenericAArch64:
13590 case TargetCXXABI::GenericItanium:
13591 case TargetCXXABI::GenericARM:
13592 case TargetCXXABI::GenericMIPS:
13593 case TargetCXXABI::iOS:
13594 case TargetCXXABI::WebAssembly:
13595 case TargetCXXABI::WatchOS:
13596 case TargetCXXABI::XL:
13598 case TargetCXXABI::Microsoft:
13601 llvm_unreachable(
"Unsupported ABI");
13605 assert(
T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13606 "Device mangle context does not support Microsoft mangling.");
13607 switch (
T.getCXXABI().getKind()) {
13608 case TargetCXXABI::AppleARM64:
13609 case TargetCXXABI::Fuchsia:
13610 case TargetCXXABI::GenericAArch64:
13611 case TargetCXXABI::GenericItanium:
13612 case TargetCXXABI::GenericARM:
13613 case TargetCXXABI::GenericMIPS:
13614 case TargetCXXABI::iOS:
13615 case TargetCXXABI::WebAssembly:
13616 case TargetCXXABI::WatchOS:
13617 case TargetCXXABI::XL:
13621 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13622 return RD->getDeviceLambdaManglingNumber();
13623 return std::nullopt;
13626 case TargetCXXABI::Microsoft:
13630 llvm_unreachable(
"Unsupported ABI");
13648 return ASTRecordLayouts.getMemorySize() +
13649 llvm::capacity_in_bytes(ObjCLayouts) +
13650 llvm::capacity_in_bytes(KeyFunctions) +
13651 llvm::capacity_in_bytes(ObjCImpls) +
13652 llvm::capacity_in_bytes(BlockVarCopyInits) +
13653 DeclAttrAllocator.getTotalMemory() +
13654 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13655 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13656 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13657 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13658 llvm::capacity_in_bytes(OverriddenMethods) +
13659 llvm::capacity_in_bytes(Types) +
13660 llvm::capacity_in_bytes(VariableArrayTypes);
13668 unsigned Signed)
const {
13671 if (!QualTy && DestWidth == 128)
13677 unsigned Signed)
const {
13678 return getFromTargetType(
13706 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13713 MangleNumbers[ND] = Number;
13716 Listener->AddedManglingNumber(ND, Number);
13720 bool ForAuxTarget)
const {
13721 auto I = MangleNumbers.find(ND);
13722 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13725 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13726 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13728 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13729 "number for aux target");
13731 return Res > 1 ? Res : 1;
13738 StaticLocalNumbers[VD] = Number;
13741 Listener->AddedStaticLocalNumbers(VD, Number);
13745 auto I = StaticLocalNumbers.find(VD);
13746 return I != StaticLocalNumbers.end() ? I->second : 1;
13750 bool IsDestroying) {
13751 if (!IsDestroying) {
13763 bool IsTypeAware) {
13764 if (!IsTypeAware) {
13780 OperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] = OperatorDelete;
13783 GlobalOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13787 ArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13791 GlobalArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13801 return OperatorDeletesForVirtualDtor.contains(Dtor->getCanonicalDecl());
13803 return GlobalOperatorDeletesForVirtualDtor.contains(
13804 Dtor->getCanonicalDecl());
13806 return ArrayOperatorDeletesForVirtualDtor.contains(
13807 Dtor->getCanonicalDecl());
13809 return GlobalArrayOperatorDeletesForVirtualDtor.contains(
13810 Dtor->getCanonicalDecl());
13821 if (OperatorDeletesForVirtualDtor.contains(Canon))
13822 return OperatorDeletesForVirtualDtor[Canon];
13825 if (GlobalOperatorDeletesForVirtualDtor.contains(Canon))
13826 return GlobalOperatorDeletesForVirtualDtor[Canon];
13829 if (ArrayOperatorDeletesForVirtualDtor.contains(Canon))
13830 return ArrayOperatorDeletesForVirtualDtor[Canon];
13833 if (GlobalArrayOperatorDeletesForVirtualDtor.contains(Canon))
13834 return GlobalArrayOperatorDeletesForVirtualDtor[Canon];
13845 return MaybeRequireVectorDeletingDtor.count(RD);
13853 MaybeRequireVectorDeletingDtor.insert(RD);
13858 assert(LangOpts.CPlusPlus);
13862 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13870 assert(LangOpts.CPlusPlus);
13871 std::unique_ptr<MangleNumberingContext> &MCtx =
13872 ExtraMangleNumberingContexts[D];
13878std::unique_ptr<MangleNumberingContext>
13880 return ABI->createMangleNumberingContext();
13885 return ABI->getCopyConstructorForExceptionObject(
13891 return ABI->addCopyConstructorForExceptionObject(
13898 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13903 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13908 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13912 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13916 ParamIndices[D] =
index;
13920 ParameterIndexTable::const_iterator I = ParamIndices.find(D);
13921 assert(I != ParamIndices.end() &&
13922 "ParmIndices lacks entry set by ParmVarDecl");
13927 unsigned Length)
const {
13953 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13955 llvm::FoldingSetNodeID ID;
13958 llvm::FoldingSetInsertToken
Token;
13963 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
13970 const APValue &APVal)
const {
13971 llvm::FoldingSetNodeID ID;
13974 llvm::FoldingSetInsertToken
Token;
13976 UnnamedGlobalConstantDecls.lookup(ID,
Token))
13980 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
13981 UnnamedGlobalConstantDecls.insert(
New,
Token);
13987 assert(
T->isRecordType() &&
"template param object of unexpected type");
13993 llvm::FoldingSetNodeID ID;
13996 llvm::FoldingSetInsertToken
Token;
13998 TemplateParamObjectDecls.lookup(ID,
Token))
14002 TemplateParamObjectDecls.insert(
New,
Token);
14008 if (!
T.isOSDarwin())
14011 if (!(
T.isiOS() &&
T.isOSVersionLT(7)) &&
14012 !(
T.isMacOSX() &&
T.isOSVersionLT(10, 9)))
14021 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
14028 if (MethodDecl->
hasAttr<UnavailableAttr>()
14029 || MethodDecl->
hasAttr<DeprecatedAttr>())
14043 IM != EM && IF != EF; ++IM, ++IF) {
14074 llvm::FoldingSetNodeID IDX, IDY;
14075 X->Profile(IDX, *
this,
true);
14076 Y->
Profile(IDY, *
this,
true);
14090 for (
const Decl *DX :
X->redecls()) {
14095 if (DX->isFirstDecl())
14098 llvm_unreachable(
"Corrupt redecls chain");
14101template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14103 return cast_or_null<T>(
14105 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
14108template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14116 bool IgnoreDeduced =
false) {
14131 bool IgnoreDeduced) {
14133 assert(R.getAsVoidPointer() !=
nullptr);
14139 assert(Xs.size() == Ys.size());
14141 for (
size_t I = 0; I < Rs.size(); ++I)
14148 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
14158 switch (
X.getKind()) {
14188 auto NExpX =
X.getNumTemplateExpansions();
14202 if (Xs.size() != Ys.size())
14204 R.resize(Xs.size());
14205 for (
size_t I = 0; I < R.size(); ++I) {
14218 assert(!Different);
14246 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
14248 return std::nullopt;
14253 assert(Kind == NNS2.
getKind());
14258 auto Kind = Namespace1->getKind();
14259 if (Kind != Namespace2->getKind() ||
14260 (Kind == Decl::NamespaceAlias &&
14265 Namespace2->getNamespace()),
14299 llvm_unreachable(
"singletons did not compare equal");
14301 assert(R.getCanonical() == Canon);
14307 const T *Y,
bool IsSame) {
14308 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
14328 QX +=
X.getQualifiers() - RQ;
14338 Y->getElementType(), QX, QY);
14349 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
14350 return X->getSizeExpr();
14355 return X->getSizeModifier();
14361 return X->getIndexTypeCVRQualifiers();
14371 llvm::DenseMap<QualType, unsigned>
Found;
14372 for (
auto Ts : {
X, Y}) {
14379 Out.emplace_back(
T);
14385FunctionProtoType::ExceptionSpecInfo
14389 bool AcceptDependent)
const {
14415 assert(AcceptDependent &&
14416 "computing composite pointer type of dependent types");
14431 llvm_unreachable(
"These ESTs should be handled above");
14436 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
14440 Result.Exceptions = ExceptionTypeStorage;
14447 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
14450 llvm_unreachable(
"invalid ExceptionSpecificationType");
14459#define UNEXPECTED_TYPE(Class, Kind) \
14460 case Type::Class: \
14461 llvm_unreachable("Unexpected " Kind ": " #Class);
14463#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
14464#define TYPE(Class, Base)
14465#include "clang/AST/TypeNodes.inc"
14467#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
14478#undef SUGAR_FREE_TYPE
14479#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
14482#undef NON_UNIQUE_TYPE
14486#undef UNEXPECTED_TYPE
14490 assert(AX->getDeducedKind() == AY->getDeducedKind());
14492 assert(AX->getKeyword() == AY->getKeyword());
14495 AY->getTypeConstraintConcept().getAsTemplateDecl());
14499 AY->getTypeConstraintArguments())) {
14506 case Type::IncompleteArray: {
14513 case Type::DependentSizedArray: {
14521 case Type::ConstantArray: {
14524 assert(AX->getSize() == AY->getSize());
14525 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14526 ? AX->getSizeExpr()
14532 case Type::ArrayParameter: {
14535 assert(AX->getSize() == AY->getSize());
14536 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14537 ? AX->getSizeExpr()
14544 case Type::Atomic: {
14549 case Type::Complex: {
14553 case Type::Pointer: {
14557 case Type::BlockPointer: {
14561 case Type::ObjCObjectPointer: {
14566 case Type::MemberPointer: {
14570 PY->getMostRecentCXXRecordDecl()));
14574 PX->getMostRecentCXXRecordDecl());
14576 case Type::LValueReference: {
14581 PX->isSpelledAsLValue() ||
14582 PY->isSpelledAsLValue());
14584 case Type::RValueReference: {
14590 case Type::DependentAddressSpace: {
14593 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14595 PX->getAddrSpaceExpr(),
14598 case Type::FunctionNoProto: {
14601 assert(FX->getExtInfo() == FY->getExtInfo());
14606 case Type::FunctionProto: {
14610 EPIY = FY->getExtProtoInfo();
14611 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14618 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14619 assert(EPIX.
Variadic == EPIY.Variadic);
14628 auto P =
getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
14636 case Type::ObjCObject: {
14639 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14640 OY->getProtocols().begin(), OY->getProtocols().end(),
14642 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14644 "protocol lists must be the same");
14646 OY->getTypeArgsAsWritten());
14649 OX->getProtocols(),
14650 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14652 case Type::ConstantMatrix: {
14655 assert(MX->getNumRows() == MY->getNumRows());
14656 assert(MX->getNumColumns() == MY->getNumColumns());
14658 MX->getNumRows(), MX->getNumColumns());
14660 case Type::DependentSizedMatrix: {
14663 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14664 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14669 case Type::Vector: {
14671 assert(VX->getNumElements() == VY->getNumElements());
14672 assert(VX->getVectorKind() == VY->getVectorKind());
14674 VX->getNumElements(), VX->getVectorKind());
14676 case Type::ExtVector: {
14678 assert(VX->getNumElements() == VY->getNumElements());
14680 VX->getNumElements());
14682 case Type::DependentSizedExtVector: {
14689 case Type::DependentVector: {
14692 assert(VX->getVectorKind() == VY->getVectorKind());
14699 case Type::InjectedClassName: {
14706 case Type::TemplateSpecialization: {
14710 TY->template_arguments());
14714 TY->getTemplateName(),
14716 As, {},
X->getCanonicalTypeInternal());
14718 case Type::Decltype: {
14721 assert(DX->isDependentType());
14722 assert(DY->isDependentType());
14723 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14727 case Type::PackIndexing: {
14730 assert(DX->isDependentType());
14731 assert(DY->isDependentType());
14732 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14735 case Type::DependentName: {
14738 assert(NX->getIdentifier() == NY->getIdentifier());
14743 case Type::OverflowBehavior: {
14746 assert(NX->getBehaviorKind() == NY->getBehaviorKind());
14748 NX->getBehaviorKind(),
14750 NY->getUnderlyingType(), QX, QY));
14752 case Type::UnaryTransform: {
14755 assert(TX->getUTTKind() == TY->getUTTKind());
14759 TY->getUnderlyingType()),
14762 case Type::PackExpansion: {
14765 assert(PX->getNumExpansions() == PY->getNumExpansions());
14768 PX->getNumExpansions(),
false);
14772 assert(PX->isReadOnly() == PY->isReadOnly());
14777 case Type::TemplateTypeParm: {
14780 assert(TX->getDepth() == TY->getDepth());
14781 assert(TX->getIndex() == TY->getIndex());
14782 assert(TX->isParameterPack() == TY->isParameterPack());
14784 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14788 llvm_unreachable(
"Unknown Type Class");
14798#define UNEXPECTED_TYPE(Class, Kind) \
14799 case Type::Class: \
14800 llvm_unreachable("Unexpected " Kind ": " #Class);
14801#define TYPE(Class, Base)
14802#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14803#include "clang/AST/TypeNodes.inc"
14805#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14832#undef CANONICAL_TYPE
14834#undef UNEXPECTED_TYPE
14836 case Type::Adjusted: {
14838 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14845 case Type::Decayed: {
14847 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14854 case Type::Attributed: {
14856 AttributedType::Kind Kind = AX->getAttrKind();
14857 if (Kind != AY->getAttrKind())
14859 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14867 case Type::BTFTagAttributed: {
14869 const BTFTypeTagAttr *AX = BX->getAttr();
14871 if (AX->getBTFTypeTag() !=
14882 if (KW != AY->getKeyword())
14887 AY->getTypeConstraintConcept().getAsTemplateDecl());
14891 AY->getTypeConstraintArguments())) {
14902 case Type::PackIndexing:
14903 case Type::Decltype:
14905 case Type::DeducedTemplateSpecialization:
14908 case Type::MacroQualified: {
14912 if (IX != MY->getMacroIdentifier())
14916 case Type::SubstTemplateTypeParm: {
14923 unsigned Index = SX->getIndex();
14924 if (Index != SY->getIndex())
14931 SX->getFinal() && SY->getFinal());
14933 case Type::ObjCTypeParam:
14939 case Type::TemplateSpecialization: {
14944 TY->getTemplateName(),
true);
14949 TY->template_arguments()))
14955 case Type::Typedef: {
14965 case Type::TypeOf: {
14976 case Type::TypeOfExpr:
14979 case Type::UnaryTransform: {
14982 UnaryTransformType::UTTKind KX = UX->getUTTKind();
14983 if (KX != UY->getUTTKind())
14985 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
14992 case Type::Using: {
15001 case Type::MemberPointer: {
15005 assert(Cls == PY->getMostRecentCXXRecordDecl());
15010 case Type::CountAttributed: {
15013 if (DX->isCountInBytes() != DY->isCountInBytes())
15015 if (DX->isOrNull() != DY->isOrNull())
15017 Expr *CEX = DX->getCountExpr();
15018 Expr *CEY = DY->getCountExpr();
15022 DX->isCountInBytes(), DX->isOrNull(),
15033 DX->isCountInBytes(), DX->isOrNull(),
15037 case Type::LateParsedAttr:
15040 case Type::PredefinedSugar:
15045 llvm_unreachable(
"Unhandled Type Class");
15052 QualType NT =
T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
15067 if (
X.isCanonical())
15094 bool KeepCommonQualifiers =
15097 if (SX.
Ty != SY.Ty) {
15105 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
15108 SX = Xs.pop_back_val();
15109 SY = Ys.pop_back_val();
15112 if (KeepCommonQualifiers)
15119 while (!Xs.empty() && !Ys.empty()) {
15122 SX = Xs.pop_back_val();
15123 SY = Ys.pop_back_val();
15128 SX.
Ty = Underlying.Ty;
15131 QX -= Underlying.Quals;
15149 llvm_unreachable(
"Not a saturated fixed point type!");
15150 case BuiltinType::SatShortAccum:
15152 case BuiltinType::SatAccum:
15154 case BuiltinType::SatLongAccum:
15156 case BuiltinType::SatUShortAccum:
15158 case BuiltinType::SatUAccum:
15160 case BuiltinType::SatULongAccum:
15162 case BuiltinType::SatShortFract:
15164 case BuiltinType::SatFract:
15166 case BuiltinType::SatLongFract:
15168 case BuiltinType::SatUShortFract:
15170 case BuiltinType::SatUFract:
15172 case BuiltinType::SatULongFract:
15184 llvm_unreachable(
"Not a fixed point type!");
15185 case BuiltinType::ShortAccum:
15187 case BuiltinType::Accum:
15189 case BuiltinType::LongAccum:
15191 case BuiltinType::UShortAccum:
15193 case BuiltinType::UAccum:
15195 case BuiltinType::ULongAccum:
15197 case BuiltinType::ShortFract:
15199 case BuiltinType::Fract:
15201 case BuiltinType::LongFract:
15203 case BuiltinType::UShortFract:
15205 case BuiltinType::UFract:
15207 case BuiltinType::ULongFract:
15213 if (LangOpts.OpenCL)
15228 llvm_unreachable(
"Not a fixed point type!");
15229 case BuiltinType::ShortAccum:
15230 case BuiltinType::SatShortAccum:
15231 return Target.getShortAccumScale();
15232 case BuiltinType::Accum:
15233 case BuiltinType::SatAccum:
15234 return Target.getAccumScale();
15235 case BuiltinType::LongAccum:
15236 case BuiltinType::SatLongAccum:
15237 return Target.getLongAccumScale();
15238 case BuiltinType::UShortAccum:
15239 case BuiltinType::SatUShortAccum:
15240 return Target.getUnsignedShortAccumScale();
15241 case BuiltinType::UAccum:
15242 case BuiltinType::SatUAccum:
15243 return Target.getUnsignedAccumScale();
15244 case BuiltinType::ULongAccum:
15245 case BuiltinType::SatULongAccum:
15246 return Target.getUnsignedLongAccumScale();
15247 case BuiltinType::ShortFract:
15248 case BuiltinType::SatShortFract:
15249 return Target.getShortFractScale();
15250 case BuiltinType::Fract:
15251 case BuiltinType::SatFract:
15252 return Target.getFractScale();
15253 case BuiltinType::LongFract:
15254 case BuiltinType::SatLongFract:
15255 return Target.getLongFractScale();
15256 case BuiltinType::UShortFract:
15257 case BuiltinType::SatUShortFract:
15258 return Target.getUnsignedShortFractScale();
15259 case BuiltinType::UFract:
15260 case BuiltinType::SatUFract:
15261 return Target.getUnsignedFractScale();
15262 case BuiltinType::ULongFract:
15263 case BuiltinType::SatULongFract:
15264 return Target.getUnsignedLongFractScale();
15274 llvm_unreachable(
"Not a fixed point type!");
15275 case BuiltinType::ShortAccum:
15276 case BuiltinType::SatShortAccum:
15277 return Target.getShortAccumIBits();
15278 case BuiltinType::Accum:
15279 case BuiltinType::SatAccum:
15280 return Target.getAccumIBits();
15281 case BuiltinType::LongAccum:
15282 case BuiltinType::SatLongAccum:
15283 return Target.getLongAccumIBits();
15284 case BuiltinType::UShortAccum:
15285 case BuiltinType::SatUShortAccum:
15286 return Target.getUnsignedShortAccumIBits();
15287 case BuiltinType::UAccum:
15288 case BuiltinType::SatUAccum:
15289 return Target.getUnsignedAccumIBits();
15290 case BuiltinType::ULongAccum:
15291 case BuiltinType::SatULongAccum:
15292 return Target.getUnsignedLongAccumIBits();
15293 case BuiltinType::ShortFract:
15294 case BuiltinType::SatShortFract:
15295 case BuiltinType::Fract:
15296 case BuiltinType::SatFract:
15297 case BuiltinType::LongFract:
15298 case BuiltinType::SatLongFract:
15299 case BuiltinType::UShortFract:
15300 case BuiltinType::SatUShortFract:
15301 case BuiltinType::UFract:
15302 case BuiltinType::SatUFract:
15303 case BuiltinType::ULongFract:
15304 case BuiltinType::SatULongFract:
15309llvm::FixedPointSemantics
15312 "Can only get the fixed point semantics for a "
15313 "fixed point or integer type.");
15315 return llvm::FixedPointSemantics::GetIntegerSemantics(
15319 return llvm::FixedPointSemantics(
15322 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
15337 "Expected unsigned fixed point type");
15340 case BuiltinType::UShortAccum:
15342 case BuiltinType::UAccum:
15344 case BuiltinType::ULongAccum:
15346 case BuiltinType::SatUShortAccum:
15348 case BuiltinType::SatUAccum:
15350 case BuiltinType::SatULongAccum:
15352 case BuiltinType::UShortFract:
15354 case BuiltinType::UFract:
15356 case BuiltinType::ULongFract:
15358 case BuiltinType::SatUShortFract:
15360 case BuiltinType::SatUFract:
15362 case BuiltinType::SatULongFract:
15365 llvm_unreachable(
"Unexpected unsigned fixed point type");
15373 std::vector<std::string> BackendFeats;
15374 llvm::AArch64::ExtensionSet FeatureBits;
15375 for (StringRef F : FMVFeatStrings)
15376 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
15378 FeatureBits.enable(*FMVExt->ID);
15379 FeatureBits.toLLVMFeatureList(BackendFeats);
15380 return BackendFeats;
15385 assert(TD !=
nullptr);
15388 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
15389 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
15400 Target->getTargetOpts().CPU,
15401 Target->getTargetOpts().Features);
15408 StringRef TargetCPU = Target->getTargetOpts().CPU;
15410 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
15416 if (!Target->getTriple().isAArch64())
15419 Target->getTargetOpts().FeaturesAsWritten.begin(),
15420 Target->getTargetOpts().FeaturesAsWritten.end());
15431 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
15433 Target->getCPUSpecificCPUDispatchFeatures(
15435 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
15436 Features.insert(Features.begin(),
15437 Target->getTargetOpts().FeaturesAsWritten.begin(),
15438 Target->getTargetOpts().FeaturesAsWritten.end());
15439 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15440 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
15441 if (Target->getTriple().isAArch64()) {
15445 Features.insert(Features.begin(),
15446 Target->getTargetOpts().FeaturesAsWritten.begin(),
15447 Target->getTargetOpts().FeaturesAsWritten.end());
15448 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15449 }
else if (Target->getTriple().isRISCV()) {
15451 std::vector<std::string> Features;
15452 if (VersionStr !=
"default") {
15454 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15457 Features.insert(Features.begin(),
15458 Target->getTargetOpts().FeaturesAsWritten.begin(),
15459 Target->getTargetOpts().FeaturesAsWritten.end());
15460 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15461 }
else if (Target->getTriple().isOSAIX()) {
15462 std::vector<std::string> Features;
15464 if (VersionStr.starts_with(
"cpu="))
15465 TargetCPU = VersionStr.drop_front(
sizeof(
"cpu=") - 1);
15466 else if (VersionStr !=
"default")
15467 Features = Target->parseTargetAttr(VersionStr).Features;
15468 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15470 std::vector<std::string> Features;
15472 if (VersionStr.starts_with(
"arch="))
15473 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
15474 else if (VersionStr !=
"default")
15475 Features.push_back((StringRef{
"+"} + VersionStr).str());
15476 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15478 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
15479 std::vector<std::string> Features;
15480 if (Target->getTriple().isRISCV()) {
15482 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15485 assert(Target->getTriple().isAArch64());
15487 TV->getFeatures(Feats);
15490 Features.insert(Features.begin(),
15491 Target->getTargetOpts().FeaturesAsWritten.begin(),
15492 Target->getTargetOpts().FeaturesAsWritten.end());
15493 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15495 FeatureMap = Target->getTargetOpts().FeatureMap;
15506 auto DeviceDiscriminatorOverrider =
15508 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15510 return RD->getDeviceLambdaManglingNumber();
15511 return std::nullopt;
15514 Context, Context.getDiagnostics(), DeviceDiscriminatorOverrider)};
15522 std::string Buffer;
15523 Buffer.reserve(128);
15524 llvm::raw_string_ostream Out(Buffer);
15525 MC->mangleCanonicalTypeName(KernelNameType, Out);
15526 std::string KernelName = Out.str();
15528 return {KernelNameType, FD, KernelName};
15537 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15538 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15547 "SYCL kernel name conflict");
15562 return &IT->second;
15568 return *OMPTraitInfoVector.back();
15575 return DB << Section.
Decl;
15576 return DB <<
"a prior #pragma section";
15580 bool IsInternalVar =
15583 bool IsExplicitDeviceVar = (D->
hasAttr<CUDADeviceAttr>() &&
15584 !D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15585 (D->
hasAttr<CUDAConstantAttr>() &&
15586 !D->
getAttr<CUDAConstantAttr>()->isImplicit());
15590 return (IsInternalVar &&
15591 (D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15592 (D->
hasAttr<CUDAGlobalAttr>() &&
15599 (D->
hasAttr<HIPManagedAttr>() || D->
hasAttr<CUDAGlobalAttr>() ||
15604 if (!CUIDHash.empty())
15606 if (LangOpts.CUID.empty())
15607 return StringRef();
15608 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.CUID),
true);
15618 assert(PrimaryBase);
15621 auto Base = Layout.getPrimaryBase();
15622 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15624 PrimaryBase =
Base;
15626 return PrimaryBase;
15630 StringRef MangledName) {
15632 assert(
Method->isVirtual());
15633 bool DefaultIncludesPointerAuth =
15634 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15636 if (!DefaultIncludesPointerAuth)
15639 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15640 if (Existing != ThunksToBeAbbreviated.end())
15641 return Existing->second.contains(MangledName.str());
15644 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15646 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15648 for (
const auto &Thunk : *ThunkInfos) {
15650 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15656 Mangler->mangleThunk(
Method, Thunk,
true,
15659 llvm::raw_svector_ostream mangledNameStream(MangledName);
15663 mangledNameStream);
15665 Mangler->mangleThunk(
Method, Thunk,
false,
15666 mangledNameStream);
15668 Thunks[ElidedName].push_back(std::string(MangledName));
15671 llvm::StringSet<> SimplifiedThunkNames;
15672 for (
auto &ThunkList : Thunks) {
15673 llvm::sort(ThunkList.second);
15674 SimplifiedThunkNames.insert(ThunkList.second[0]);
15676 bool Result = SimplifiedThunkNames.contains(MangledName);
15677 ThunksToBeAbbreviated[VirtualMethodDecl] = std::move(SimplifiedThunkNames);
15695 std::vector<PFPField> &Fields,
bool IncludeVBases) {
15697 if (
auto *ElemDecl = AT->getElementType()->getAsCXXRecordDecl()) {
15699 for (
unsigned i = 0; i != AT->getSize(); ++i)
15716 Fields.push_back({FieldOffset, Field});
15723 if (
Base.isVirtual())
15730 if (IncludeVBases) {
15741 std::vector<PFPField> PFPFields;
15751 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->
getParent()))
15753 !FD->
hasAttr<NoFieldProtectionAttr>();
15758 auto *FD = dyn_cast<FieldDecl>(VD);
15781struct PaddingCalculator {
15782 PaddingCalculator(
const ASTContext &Ctx) : Ctx(Ctx) {}
15785 OccuppiedIntervals.clear();
15791 while (!Stack.empty()) {
15792 Data Current = Stack.back();
15796 MergeOccuppiedIntervals();
15799 llvm::SmallVector<ASTContext::BitInterval> GetPaddingIntervals() {
15800 llvm::SmallVector<ASTContext::BitInterval> Results;
15801 if (OccuppiedIntervals.size() == 1 &&
15802 OccuppiedIntervals.front().First == 0 &&
15803 OccuppiedIntervals.front().Last == TySizeInBits) {
15806 Results.reserve(OccuppiedIntervals.size() + 1);
15808 for (
const ASTContext::BitInterval &OccupiedInterval : OccuppiedIntervals) {
15809 if (OccupiedInterval.First > CurrentPos) {
15811 ASTContext::BitInterval{CurrentPos, OccupiedInterval.First});
15813 CurrentPos = OccupiedInterval.Last;
15815 if (TySizeInBits > CurrentPos) {
15816 Results.push_back(ASTContext::BitInterval{CurrentPos, TySizeInBits});
15825 bool VisitVirtualBase;
15851 uint64_t getScalarOccupiedSizeInBits(QualType Ty)
const {
15852 if (
const auto *BIT = Ty->
getAs<BitIntType>())
15853 return BIT->getNumBits();
15855 if (
const auto *BT = Ty->
getAs<BuiltinType>()) {
15856 if (BT->getKind() == BuiltinType::LongDouble &&
15858 &llvm::APFloat::x87DoubleExtended())
15859 return llvm::APFloat::getSizeInBits(
15866 void Visit(
const Data &D) {
15867 if (
auto *AT = dyn_cast<ConstantArrayType>(D.Ty)) {
15868 VisitArray(AT, D.StartBitOffset);
15872 if (
auto *
Record = D.Ty->getAsRecordDecl()) {
15873 VisitStruct(
Record, D.StartBitOffset, D.VisitVirtualBase);
15877 if (D.Ty->isAtomicType()) {
15878 auto Unwrapped = D;
15879 Unwrapped.Ty = D.Ty.getAtomicUnqualifiedType().getCanonicalType();
15880 Stack.push_back(Unwrapped);
15884 if (
const auto *
Complex = D.Ty->getAs<ComplexType>()) {
15885 VisitComplex(
Complex, D.StartBitOffset);
15889 if (
const auto *VT = D.Ty->getAs<clang::VectorType>()) {
15890 VisitVector(VT, D.StartBitOffset);
15894 if (
const auto *BITy = D.Ty->getAs<BitIntType>()) {
15895 VisitBitInt(BITy, D.StartBitOffset);
15899 uint64_t SizeBit = getScalarOccupiedSizeInBits(D.Ty);
15900 OccuppiedIntervals.push_back(
15901 ASTContext::BitInterval{D.StartBitOffset, D.StartBitOffset + SizeBit});
15904 void VisitArray(
const ConstantArrayType *AT, uint64_t StartBitOffset) {
15905 for (uint64_t ArrIndex = 0; ArrIndex < AT->
getSize().getLimitedValue();
15911 auto Offset = ElementSize.
alignTo(ElementAlign);
15913 Stack.push_back(
Data{
15914 StartBitOffset + ArrIndex * Offset.getQuantity() * Ctx.
getCharWidth(),
15919 void VisitStruct(
const RecordDecl *R, uint64_t StartBitOffset,
15920 bool VisitVirtualBase) {
15922 auto *
CXXRecord = dyn_cast<CXXRecordDecl>(R);
15928 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15929 StartBitOffset, StartBitOffset + PointerSizeInBits});
15934 auto StartVBPtr = StartBitOffset + Offset * Ctx.
getCharWidth();
15935 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15936 StartVBPtr, StartVBPtr + PointerSizeInBits});
15939 const auto VisitBase = [&ASTLayout, StartBitOffset,
this](
15940 const CXXBaseSpecifier &
Base,
auto GetOffset) {
15941 auto *BaseRecord =
Base.getType()->getAsCXXRecordDecl();
15946 std::invoke(GetOffset, ASTLayout, BaseRecord).getQuantity();
15950 Base.getType().getCanonicalType(),
15955 if (!
Base.isVirtual()) {
15960 if (VisitVirtualBase) {
15961 for (
auto VBase :
CXXRecord->vbases()) {
15967 for (
auto *Field :
R->fields()) {
15969 if (
Field->isUnnamedBitField())
15973 if (
Field->isBitField()) {
15974 VisitBitfield(Field, StartBitOffset + FieldOffset);
15976 Stack.push_back(
Data{StartBitOffset + FieldOffset,
15977 Field->getType().getCanonicalType(),
15983 void VisitBitfield(
const FieldDecl *Field, uint64_t StartBitOffset) {
15984 assert(
Field->isBitField() && !
Field->isUnnamedBitField());
15985 if (
Field->isZeroLengthBitField())
15988 const uint64_t DeclaredSizeInBits =
Field->getBitWidthValue();
15997 const uint64_t OccupiedSizeInBits =
16001 OccuppiedIntervals.push_back(
16002 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16017 const uint64_t Start = StartBitOffset;
16018 const uint64_t End = Start + OccupiedSizeInBits;
16022 const uint64_t ByteStart = llvm::alignDown(Start, CharWidth);
16023 const uint64_t ByteEnd = llvm::alignTo(End, CharWidth);
16024 if (ByteStart == ByteEnd - CharWidth) {
16025 const uint64_t Length = End - Start;
16026 const uint64_t Offset = Start - ByteStart;
16027 OccuppiedIntervals.push_back(
16028 {ByteEnd - Offset - Length, ByteEnd - Offset});
16034 const uint64_t MiddleIntervalStart = llvm::alignTo(Start, CharWidth);
16035 const uint64_t MiddleIntervalEnd = llvm::alignDown(End, CharWidth);
16036 if (MiddleIntervalStart != MiddleIntervalEnd)
16037 OccuppiedIntervals.push_back({MiddleIntervalStart, MiddleIntervalEnd});
16041 if (Start != MiddleIntervalStart) {
16042 const uint64_t Length = MiddleIntervalStart - Start;
16043 OccuppiedIntervals.push_back({ByteStart, ByteStart + Length});
16048 if (End != MiddleIntervalEnd) {
16049 const uint64_t Length = End - MiddleIntervalEnd;
16050 OccuppiedIntervals.push_back({ByteEnd - Length, ByteEnd});
16054 void VisitComplex(
const ComplexType *CT, uint64_t StartBitOffset) {
16058 auto ImgOffset = ElementSize.
alignTo(ElementAlign);
16061 Data{StartBitOffset, ElementQualType,
true});
16064 ElementQualType,
true});
16067 void VisitVector(
const clang::VectorType *VT, uint64_t StartBitOffset) {
16069 VisitPackedBooleanVector(VT, StartBitOffset);
16075 OccuppiedIntervals.push_back(
16076 ASTContext::BitInterval{StartBitOffset, StartBitOffset + SizeBit});
16084 void VisitBitInt(
const BitIntType *Ty, uint64_t StartBitOffset) {
16088 OccuppiedIntervals.push_back(
16089 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16101 const uint64_t NumFullyPaddingBytes =
16102 (StorageSizeInBits - OccupiedSizeInBits) / CharWidth;
16103 const uint64_t NumFullyOccupiedBytes = OccupiedSizeInBits / CharWidth;
16104 const uint64_t NumRemainingOccupiedBits = OccupiedSizeInBits % CharWidth;
16107 if (NumRemainingOccupiedBits > 0)
16108 OccuppiedIntervals.push_back(
16109 {StartBitOffset + NumFullyPaddingBytes * CharWidth,
16110 StartBitOffset + NumFullyPaddingBytes * CharWidth +
16111 NumRemainingOccupiedBits});
16114 if (NumFullyOccupiedBytes > 0)
16115 OccuppiedIntervals.push_back({StartBitOffset + StorageSizeInBits -
16116 NumFullyOccupiedBytes * CharWidth,
16117 StartBitOffset + StorageSizeInBits});
16120 void VisitPackedBooleanVector(
const VectorType *VTy,
16121 uint64_t StartBitOffset) {
16123 assert(StartBitOffset % CharWidth == 0 &&
16124 "Expected aligned packed boolean vector");
16129 OccuppiedIntervals.push_back(
16130 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16138 const uint64_t NumFullyOccupiedBytes = OccupiedSizeInBits / CharWidth;
16139 const uint64_t NumRemainingOccupiedBits = OccupiedSizeInBits % CharWidth;
16143 if (NumRemainingOccupiedBits > 0) {
16144 const uint64_t ByteEnd = Start + CharWidth;
16145 OccuppiedIntervals.push_back({Start, Start + NumRemainingOccupiedBits});
16150 if (NumFullyOccupiedBytes > 0) {
16151 OccuppiedIntervals.push_back(
16152 {Start, Start + NumFullyOccupiedBytes * CharWidth});
16156 void MergeOccuppiedIntervals() {
16157 std::sort(OccuppiedIntervals.begin(), OccuppiedIntervals.end(),
16158 [](
const ASTContext::BitInterval &lhs,
16159 const ASTContext::BitInterval &rhs) {
16160 return std::tie(lhs.First, lhs.Last) <
16161 std::tie(rhs.First, rhs.Last);
16164 llvm::SmallVector<ASTContext::BitInterval> Merged;
16165 Merged.reserve(OccuppiedIntervals.size());
16167 for (
const ASTContext::BitInterval &NextInterval : OccuppiedIntervals) {
16168 if (Merged.empty()) {
16169 Merged.push_back(NextInterval);
16172 auto &LastInterval = Merged.back();
16174 if (NextInterval.First > LastInterval.Last) {
16175 Merged.push_back(NextInterval);
16177 LastInterval.Last = std::max(LastInterval.Last, NextInterval.Last);
16181 OccuppiedIntervals = Merged;
16184 const ASTContext &Ctx;
16187 llvm::SmallVector<Data> Stack;
16188 llvm::SmallVector<ASTContext::BitInterval> OccuppiedIntervals;
16192llvm::ArrayRef<ASTContext::BitInterval>
16195 auto cached = PaddingIntervalCache.find(Ty);
16196 if (cached != PaddingIntervalCache.end())
16197 return cached->second;
16199 PaddingCalculator pc{*
this};
16203 PaddingIntervalCache.insert_or_assign(Ty, pc.GetPaddingIntervals());
16204 assert(res &&
"Failed to insert?");
16206 return itr->second;
This file provides AST data structures related to concepts.
static void SortAndUniqueProtocols(SmallVectorImpl< ObjCProtocolDecl * > &Protocols)
static bool isCanonicalExceptionSpecification(const FunctionProtoType::ExceptionSpecInfo &ESI, bool NoexceptInType)
static SourceLocation getCommonAttrLoc(const T *X, const T *Y)
static auto getCanonicalTemplateArguments(const ASTContext &C, ArrayRef< TemplateArgument > Args, bool &AnyNonCanonArgs)
static char getObjCEncodingForPrimitiveType(const ASTContext *C, const BuiltinType *BT)
static bool isSameQualifier(const NestedNameSpecifier X, const NestedNameSpecifier Y)
static bool unionHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static TypedefDecl * CreateHexagonBuiltinVaListDecl(const ASTContext *Context)
#define CANONICAL_TYPE(Class)
static ElaboratedTypeKeyword getCommonTypeKeyword(const T *X, const T *Y, bool IsSame)
static Decl * getCommonDecl(Decl *X, Decl *Y)
static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context, const Decl *D, GVALinkage L)
static bool isTypeTypedefedAsBOOL(QualType T)
static void EncodeBitField(const ASTContext *Ctx, std::string &S, QualType T, const FieldDecl *FD)
static GVALinkage basicGVALinkageForVariable(const ASTContext &Context, const VarDecl *VD)
static QualType getCommonArrayElementType(const ASTContext &Ctx, const T *X, Qualifiers &QX, const T *Y, Qualifiers &QY)
static bool hasImplicitAttr(const ValueDecl *D)
#define SUGAR_FREE_TYPE(Class)
static SYCLKernelInfo BuildSYCLKernelInfo(ASTContext &Context, CanQualType KernelNameType, const FunctionDecl *FD)
static bool hasTemplateSpecializationInEncodedString(const Type *T, bool VisitBasesAndFields)
static void getIntersectionOfProtocols(ASTContext &Context, const ObjCInterfaceDecl *CommonBase, const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, SmallVectorImpl< ObjCProtocolDecl * > &IntersectionSet)
getIntersectionOfProtocols - This routine finds the intersection of set of protocols inherited from t...
static bool areCompatMatrixTypes(const ConstantMatrixType *LHS, const ConstantMatrixType *RHS)
areCompatMatrixTypes - Return true if the two specified matrix types are compatible.
static TypedefDecl * CreateAAPCSABIBuiltinVaListDecl(const ASTContext *Context)
static bool sameObjCTypeArgs(ASTContext &ctx, const ObjCInterfaceDecl *iface, ArrayRef< QualType > lhsArgs, ArrayRef< QualType > rhsArgs, bool stripKindOf)
static bool canAssignObjCObjectTypes(ASTContext &ctx, QualType lhs, QualType rhs)
Determine whether the first type is a subtype of the second.
static const Type * getIntegerTypeForEnum(const EnumType *ET)
static SmallVector< SourceLocation, 2 > getLocsForCommentSearch(ASTContext::RawCommentLookupKey Key, SourceManager &SourceMgr)
static bool hasSameCudaAttrs(const FunctionDecl *A, const FunctionDecl *B)
static TemplateName getCommonTemplateName(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced=false)
static int CmpProtocolNames(ObjCProtocolDecl *const *LHS, ObjCProtocolDecl *const *RHS)
CmpProtocolNames - Comparison predicate for sorting protocols alphabetically.
static auto * getCommonSizeExpr(const ASTContext &Ctx, T *X, T *Y)
static TypedefDecl * CreatePowerABIBuiltinVaListDecl(const ASTContext *Context)
static auto getCommonSizeModifier(const ArrayType *X, const ArrayType *Y)
static TemplateArgument getCommonTemplateArgument(const ASTContext &Ctx, const TemplateArgument &X, const TemplateArgument &Y)
static std::optional< int64_t > structHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static bool hasSameOverloadableAttrs(const FunctionDecl *A, const FunctionDecl *B)
Determine whether the attributes we can overload on are identical for A and B.
static T * getCommonDeclChecked(T *X, T *Y)
static NestedNameSpecifier getCommonNNS(const ASTContext &Ctx, NestedNameSpecifier NNS1, NestedNameSpecifier NNS2, bool IsSame)
Returns a NestedNameSpecifier which has only the common sugar present in both NNS1 and NNS2.
static TypedefDecl * CreateVoidPtrBuiltinVaListDecl(const ASTContext *Context)
static int64_t getSubobjectOffset(const FieldDecl *Field, const ASTContext &Context, const clang::ASTRecordLayout &)
static QualType getCommonSugarTypeNode(const ASTContext &Ctx, const Type *X, const Type *Y, SplitQualType Underlying)
static TypedefDecl * CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X, Qualifiers &QX, const Type *Y, Qualifiers &QY)
static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET, QualType other, bool isBlockReturnType)
Given that we have an enum type and a non-enum type, try to merge them.
static GVALinkage adjustGVALinkageForExternalDefinitionKind(const ASTContext &Ctx, const Decl *D, GVALinkage L)
Adjust the GVALinkage for a declaration based on what an external AST source knows about whether ther...
static TypedefDecl * CreateSystemZBuiltinVaListDecl(const ASTContext *Context)
static std::optional< int64_t > getSubobjectSizeInBits(const FieldDecl *Field, const ASTContext &Context, bool CheckIfTriviallyCopyable)
static GVALinkage basicGVALinkageForFunction(const ASTContext &Context, const FunctionDecl *FD)
#define NON_UNIQUE_TYPE(Class)
static TypedefDecl * CreateX86_64ABIBuiltinVaListDecl(const ASTContext *Context)
static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI, const LangOptions &LangOpts)
static ElaboratedTypeKeyword getCanonicalElaboratedTypeKeyword(ElaboratedTypeKeyword Keyword)
static QualType getCommonPointeeType(const ASTContext &Ctx, const T *X, const T *Y)
static auto getCommonIndexTypeCVRQualifiers(const ArrayType *X, const ArrayType *Y)
static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequiresICE, bool AllowTypeModifiers)
DecodeTypeFromStr - This decodes one type descriptor from Str, advancing the pointer over the consume...
static TypedefDecl * CreateCharPtrBuiltinVaListDecl(const ASTContext *Context)
static bool areSortedAndUniqued(ArrayRef< ObjCProtocolDecl * > Protocols)
static TypeInfoChars getConstantArrayInfoInChars(const ASTContext &Context, const ConstantArrayType *CAT)
getConstantArrayInfoInChars - Performing the computation in CharUnits instead of in bits prevents ove...
static FloatingRank getFloatingRank(QualType T)
getFloatingRank - Return a relative rank for floating point types.
static bool getCommonTemplateArguments(const ASTContext &Ctx, SmallVectorImpl< TemplateArgument > &R, ArrayRef< TemplateArgument > Xs, ArrayRef< TemplateArgument > Ys)
static TypedefDecl * CreateXtensaABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonElementType(const ASTContext &Ctx, const T *X, const T *Y)
static void mergeTypeLists(const ASTContext &Ctx, SmallVectorImpl< QualType > &Out, ArrayRef< QualType > X, ArrayRef< QualType > Y)
static bool matchesPostDecrInWhile(const UnaryOperator *UO, ASTContext &Ctx)
For the purposes of overflow pattern exclusion, does this match the while(i–) pattern?
static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx, raw_ostream &OS, QualType QT)
Encode a function type for use in the discriminator of a function pointer type.
static std::optional< int64_t > structSubobjectsHaveUniqueObjectRepresentations(const RangeT &Subobjects, int64_t CurOffsetInBits, const ASTContext &Context, const clang::ASTRecordLayout &Layout, bool CheckIfTriviallyCopyable)
static uint64_t getRVVTypeSize(ASTContext &Context, const BuiltinType *Ty)
getRVVTypeSize - Return RVV vector register size.
static auto unwrapSugar(SplitQualType &T, Qualifiers &QTotal)
static TemplateName getCommonTemplateNameChecked(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced)
static int compareObjCProtocolsByName(ObjCProtocolDecl *const *lhs, ObjCProtocolDecl *const *rhs)
Comparison routine for Objective-C protocols to be used with llvm::array_pod_sort.
static const TagDecl * getNonInjectedClassName(const TagDecl *TD)
static TypedefDecl * CreateZOSVaListDecl(const ASTContext *Context)
static bool hasAnyPackExpansions(ArrayRef< TemplateArgument > Args)
static char ObjCEncodingForEnumDecl(const ASTContext *C, const EnumDecl *ED)
static std::string charUnitsToString(CharUnits CU)
static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod, SmallVectorImpl< const NamedDecl * > &Redeclared)
static QualType getCommonTypeWithQualifierLifting(const ASTContext &Ctx, QualType X, QualType Y, Qualifiers &QX, Qualifiers &QY)
static auto getCommonTypes(const ASTContext &Ctx, ArrayRef< QualType > Xs, ArrayRef< QualType > Ys, bool Unqualified=false)
static bool isCanonicalResultType(QualType T)
Determine whether T is canonical as the result type of a function.
static TypedefDecl * CreateMSVaListDecl(const ASTContext *Context)
static bool areCompatVectorTypes(const VectorType *LHS, const VectorType *RHS)
areCompatVectorTypes - Return true if the two specified vector types are compatible.
static TypedefDecl * CreateCharPtrNamedVaListDecl(const ASTContext *Context, StringRef Name)
static NestedNameSpecifier getCommonQualifier(const ASTContext &Ctx, const T *X, const T *Y, bool IsSame)
#define UNEXPECTED_TYPE(Class, Kind)
static TypedefDecl * CreateVaListDecl(const ASTContext *Context, TargetInfo::BuiltinVaListKind Kind)
static bool primaryBaseHaseAddressDiscriminatedVTableAuthentication(const ASTContext &Context, const CXXRecordDecl *Class)
static std::vector< std::string > getFMVBackendFeaturesFor(const llvm::SmallVectorImpl< StringRef > &FMVFeatStrings)
Defines the clang::ASTContext interface.
#define BuiltinTemplate(BTName)
This file provides some common utility functions for processing Lambda related AST Constructs.
Provides definitions for the various language-specific address spaces.
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
Defines enum values for all the target-independent builtin functions.
static bool CanThrow(Expr *E, ASTContext &Ctx)
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static const Decl * getCanonicalDecl(const Decl *D)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
Defines the clang::Module class, which describes a module in the source code.
static StringRef getTriple(const Command &Job)
Defines types useful for describing an Objective-C runtime.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
static QualType getUnderlyingType(const SubRegion *R)
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
RawComment * getRawCommentNoCacheImpl(RawCommentLookupKey Key, const SourceLocation RepresentativeLoc, const std::map< unsigned, RawComment * > &CommentsInFile) const
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
bool isMemberPointerToDerivedMember() const
const ValueDecl * getMemberPointerDecl() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const
Returns true, if given type has a known lifetime.
MSGuidDecl * getMSGuidDecl(MSGuidDeclParts Parts) const
Return a declaration for the global GUID object representing the given GUID value.
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl, const ObjCMethodDecl *MethodImp)
CanQualType ObjCBuiltinSelTy
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
void InitBuiltinTypes(const TargetInfo &Target, const TargetInfo *AuxTarget=nullptr)
Initialize built-in types.
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
CanQualType ARCUnbridgedCastTy
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, QualType Wrapped) const
llvm::DenseMap< const Decl *, comments::FullComment * > ParsedComments
Mapping from declarations to parsed comments attached to any redeclaration.
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
unsigned getIntWidth(QualType T) const
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
InlineVariableDefinitionKind
@ None
Not an inline variable.
@ Weak
Weak definition of inline variable.
@ Strong
Strong definition.
@ WeakUnknown
Weak for now, might become strong later in this TU.
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
TypedefDecl * getCFConstantStringDecl() const
CanQualType SatUnsignedFractTy
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns, std::optional< MatrixType::LayoutKind > Layout=std::nullopt) const
Return the unique reference to the matrix type of the specified element type and size.
ExternCContextDecl * getExternCContextDecl() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
CanQualType UnsignedShortAccumTy
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
QualType adjustFunctionResultType(QualType FunctionType, QualType NewResultType)
Change the result type of a function type, preserving sugar such as attributed types.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
QualType getCanonicalTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateName TypeConstraintConcept=TemplateName(), ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type.
bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool AllowCXX=false, bool IsConditionalOperator=false)
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
CharUnits getObjCEncodingTypeSize(QualType T) const
Return the size of type T for Objective-C encoding purpose, in characters.
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
const TemplateArgument * getDefaultTemplateArgumentOrNone(const NamedDecl *P) const
Return the default argument of a template parameter, if one exists.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
void setCurrentNamedModule(Module *M)
Set the (C++20) module we are building.
QualType getProcessIDType() const
Return the unique type for "pid_t" defined in <sys/types.h>.
CharUnits getMemberPointerPathAdjustment(const APValue &MP) const
Find the 'this' offset for the member path in a pointer-to-member APValue.
bool mayExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel may be externalized.
std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const
ArrayRef< CXXDefaultArgExpr * > getCtorClosureDefaultArgs(const CXXConstructorDecl *CD)
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
bool hasSameExpr(const Expr *X, const Expr *Y) const
Determine whether the given expressions X and Y are equivalent.
TemplateName getPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< TemplateName > Expansions={}) const
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
RawComment * getRawCommentNoCache(RawCommentLookupKey Key) const
Return the documentation comment attached to a given declaration or macro, without looking into cache...
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
unsigned getTypeUnadjustedAlign(QualType T) const
Return the ABI-specified natural alignment of a (complete) type T, before alignment adjustments,...
unsigned char getFixedPointIBits(QualType Ty) const
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes, bool OrNull, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
bool ObjCQualifiedClassTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS)
ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and Class<pr1, ...>.
bool shouldExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel should be externalized.
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type.
CanQualType SatLongAccumTy
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
OpenCLTypeKind getOpenCLTypeKind(const Type *T) const
Map an AST Type to an OpenCLTypeKind enum value.
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const
Put the string version of the type qualifiers QT into S.
unsigned getPreferredTypeAlign(QualType T) const
Return the "preferred" alignment of the specified type T for the current target, in bits.
std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, bool Extended=false) const
Emit the encoded type for the method declaration Decl into S.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
CanQualType OMPArrayShapingTy
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
std::string getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
getObjCEncodingForPropertyDecl - Return the encoded type for this method declaration.
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
unsigned getStaticLocalNumber(const VarDecl *VD) const
void addComment(const RawComment &RC)
void getLegacyIntegralTypeEncoding(QualType &t) const
getLegacyIntegralTypeEncoding - Another legacy compatibility encoding: 32-bit longs are encoded as 'l...
bool isSameTypeConstraint(const TypeConstraint *XTC, const TypeConstraint *YTC) const
Determine whether two type contraint are similar enough that they could used in declarations of the s...
void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo)
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=RecordDecl::TagKind::Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
void completeCountAttributedType(CountAttributedType *CATy, Expr *CountExpr, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
Supply the count expression and coupled declarations for a type created by getIncompleteCountAttribut...
CanQualType UnsignedLongFractTy
QualType mergeTagDefinitions(QualType, QualType)
void setClassMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
void setIsTypeAwareOperatorNewOrDelete(const FunctionDecl *FD, bool IsTypeAware)
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const
Return a dependent bit-precise integer type with the specified signedness and bit count.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
StringRef getCUIDHash() const
bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const
Returns true if this is an inline-initialized static data member which is treated as a definition for...
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const
Determine whether two function types are the same, ignoring exception specifications in cases where t...
QualType getBlockDescriptorExtendedType() const
Gets the struct used to keep track of the extended descriptor for pointer to blocks.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent) const
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
void addLazyModuleInitializers(Module *M, ArrayRef< GlobalDeclID > IDs)
bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
QualType getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
std::optional< QualType > tryMergeOverflowBehaviorTypes(QualType LHS, QualType RHS, bool OfBlockPointer, bool Unqualified, bool BlockReturnType, bool IsConditionalOperator)
Attempts to merge two types that may be OverflowBehaviorTypes.
CanQualType OMPIteratorTy
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
SelectorTable & Selectors
bool isTypeIgnoredBySanitizer(const SanitizerMask &Mask, const QualType &Ty) const
Check if a type can have its sanitizer instrumentation elided based on its presence within an ignorel...
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const
Return the minimum alignment as specified by the target.
RawCommentList Comments
All comments in this translation unit.
bool isSameDefaultTemplateArgument(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two default template arguments are similar enough that they may be used in declarat...
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType getLateParsedAttrType(QualType Wrapped, LateParsedTypeAttribute *LateParsedAttr) const
Return a placeholder type for a late-parsed type attribute.
QualType removePtrSizeAddrSpace(QualType T) const
Remove the existing address space on the type if it is a pointer size address space and return the ty...
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
llvm::ArrayRef< BitInterval > getPaddingIntervals(QualType Ty) const
CanQualType SatShortFractTy
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
bool canBindObjCObjectType(QualType To, QualType From)
TemplateTemplateParmDecl * insertCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *CanonTTP) const
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const
Compare the rank of two floating point types as above, but compare equal if both types have the same ...
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
void setParameterIndex(const ParmVarDecl *D, unsigned index)
Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
CanQualType getCanonicalSizeType() const
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl, StringRef MangledName)
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::SetVector< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
CanQualType ArraySectionTy
CanQualType ObjCBuiltinIdTy
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const
ObjCPropertyImplDecl * getObjCPropertyImplDeclForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
bool isNearlyEmpty(const CXXRecordDecl *RD) const
PointerAuthQualifier getObjCMemberSelTypePtrAuth()
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.
UsingEnumDecl * getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst)
If the given using-enum decl Inst is an instantiation of another using-enum decl, return it.
RecordDecl * getCFConstantStringTagDecl() const
std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const
Emit the encoded type for the function Decl into S.
TypeSourceInfo * getTemplateSpecializationTypeInfo(ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Canon=QualType()) const
CanQualType UnsignedFractTy
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
QualType mergeFunctionParameterTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeFunctionParameterTypes - merge two types which appear as function parameter types
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
TemplateTemplateParmDecl * findCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *TTP) const
const TargetInfo * getAuxTargetInfo() const
CanQualType ObjCBuiltinClassTy
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
CanQualType UnresolvedTemplateTy
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
friend class CXXRecordDecl
CanQualType UnsignedLongTy
llvm::DenseSet< const FunctionDecl * > CUDAImplicitHostDeviceFunUsedByDevice
Keep track of CUDA/HIP implicit host device functions used on device side in device compilation.
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized,...
bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits, unsigned NumPositiveBits, QualType &BestType, QualType &BestPromotionType)
Compute BestType and BestPromotionType for an enum based on the highest number of negative and positi...
llvm::APFixedPoint getFixedPointMin(QualType Ty) const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType adjustType(QualType OldType, llvm::function_ref< QualType(QualType)> Adjust) const
Rebuild a type, preserving any existing type sugar.
void addedLocalImportDecl(ImportDecl *Import)
Notify the AST context that a new import declaration has been parsed or implicitly created within thi...
const TranslationUnitKind TUKind
CanQualType UnsignedLongAccumTy
QualType AutoRRefDeductTy
RawComment * getRawCommentNoCacheImpl(RawCommentLookupKey Key, const SourceLocation RepresentativeLoc, const std::map< unsigned, RawComment * > &CommentsInFile) const
CountAttributedType * getIncompleteCountAttributedType(QualType WrappedTy, bool CountInBytes, bool OrNull) const
Return a CountAttributedType whose count expression has not been parsed yet, for use by a late-parsed...
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length.
QualType getCorrespondingSaturatedType(QualType Ty) const
bool arePFPFieldsTriviallyCopyable(const RecordDecl *RD) const
Returns whether this record's PFP fields (if any) are trivially copyable (i.e.
bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const
Determine whether the two declarations refer to the same entity.
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl, unsigned Index, bool Final, const TemplateArgument &ArgPack)
CanQualType BoundMemberTy
CanQualType SatUnsignedShortFractTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
bool hasSameFunctionTypeIgnoringParamABI(QualType T, QualType U) const
Determine if two function types are the same, ignoring parameter ABI annotations.
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
unsigned getOpenMPDefaultSimdAlign(QualType T) const
Get default simd alignment of the specified complete type in bits.
QualType getObjCSuperType() const
Returns the C struct type for objc_super.
QualType getBlockDescriptorType() const
Gets the struct used to keep track of the descriptor for pointer to blocks.
bool CommentsLoaded
True if comments are already loaded from ExternalASTSource.
BlockVarCopyInit getBlockVarCopyInit(const VarDecl *VD) const
Get the copy initialization expression of the VarDecl VD, or nullptr if none exists.
QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size, uint32_t Alignment, ArrayRef< SpirvOperand > Operands)
unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
bool isInSameModule(const Module *M1, const Module *M2) const
If the two module M1 and M2 are in the same module.
unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
QualType getLeastIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
CanQualType PseudoObjectTy
QualType getWebAssemblyExternrefType() const
Return a WebAssembly externref type.
void setTraversalScope(const std::vector< Decl * > &)
CharUnits getTypeUnadjustedAlignInChars(QualType T) const
getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, in characters,...
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
friend class NestedNameSpecifier
MangleContext * cudaNVInitDeviceMC()
unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const
Return the alignment in bits that should be given to a global variable with type T.
bool areCompatibleOverflowBehaviorTypes(QualType LHS, QualType RHS)
Return true if two OverflowBehaviorTypes are compatible for assignment.
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
MangleContext * createDeviceMangleContext(const TargetInfo &T)
Creates a device mangle context to correctly mangle lambdas in a mixed architecture compile by settin...
CharUnits getExnObjectAlignment() const
Return the alignment (in bytes) of the thrown exception object.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ASTMutationListener * Listener
CanQualType ObjCBuiltinBoolTy
TypeInfoChars getTypeInfoInChars(const Type *T) const
QualType getPredefinedSugarType(PredefinedSugarType::Kind KD) const
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
TemplateParamObjectDecl * getTemplateParamObjectDecl(QualType T, const APValue &V) const
Return the template parameter object of the given type with the given value.
interp::Context & getInterpContext() const
Returns the clang bytecode interpreter context.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
TemplateTemplateParmDecl * getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const
Canonicalize the given TemplateTemplateParmDecl.
CanQualType OCLClkEventTy
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
bool hasPFPFields(QualType Ty) const
const clang::PrintingPolicy & getPrintingPolicy() const
void ResetObjCLayout(const ObjCInterfaceDecl *D)
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
void setCtorClosureDefaultArgs(const CXXConstructorDecl *CD, ArrayRef< CXXDefaultArgExpr * > Args)
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
CharUnits getAlignOfGlobalVarInChars(QualType T, const VarDecl *VD) const
Return the alignment in characters that should be given to a global variable with type T.
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists.
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, UnsignedOrNone Index=std::nullopt) const
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getObjCIdType() const
Represents the Objective-CC id type.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
QualType getFunctionTypeWithoutParamABIs(QualType T) const
Get or construct a function type that is equivalent to the input type except that the parameter ABI a...
QualType getCorrespondingUnsaturatedType(QualType Ty) const
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl) const
unsigned getTargetDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
llvm::DenseMap< CanQualType, SYCLKernelInfo > SYCLKernels
Map of SYCL kernels indexed by the unique type used to name the kernel.
bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y) const
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
bool isDestroyingOperatorDelete(const FunctionDecl *FD) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
CanQualType UnsignedCharTy
CanQualType UnsignedShortFractTy
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
void * Allocate(size_t Size, unsigned Align=8) const
ArrayRef< ExplicitInstantiationDecl * > getExplicitInstantiationDecls(const NamedDecl *Spec) const
Get all ExplicitInstantiationDecls for a given specialization.
bool canBuiltinBeRedeclared(const FunctionDecl *) const
Return whether a declaration to a builtin is allowed to be overloaded/redeclared.
CanQualType UnsignedIntTy
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols) const
void getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT, QualType T, std::string &S, bool Extended) const
getObjCEncodingForMethodParameter - Return the encoded type for a single method parameter or return t...
static bool isPFPField(const FieldDecl *Field)
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const
Return the encoded type for this block declaration.
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
bool isSameAssociatedConstraint(const AssociatedConstraint &ACX, const AssociatedConstraint &ACY) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
QualType getExceptionObjectType(QualType T) const
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Note that the static data member Inst is an instantiation of the static data member template Tmpl of ...
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl)
ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's protocol list adopt all protocols in Q...
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType OCLReserveIDTy
bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two template parameters are similar enough that they may be used in declarations of...
void registerSYCLEntryPointFunction(FunctionDecl *FD)
Generates and stores SYCL kernel metadata for the provided SYCL kernel entry point function.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
CanQualType UnsignedShortTy
FunctionDecl * getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
AttrVec * allocateAttrVec()
Allocate an empty attribute vector with the lifetime of this context.
unsigned getTypeAlignIfKnown(QualType T, bool NeedsPreferredAlignment=false) const
Return the alignment of a type, in bits, or 0 if the type is incomplete and we cannot determine the a...
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may both be array types with the same bound (or both be array types ...
bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
llvm::DenseMap< RawCommentLookupKey, const RawComment * > RawComments
Mapping from declaration or macro to directly attached comment.
const SYCLKernelInfo & getSYCLKernelInfo(QualType T) const
Given a type used as a SYCL kernel name, returns a reference to the metadata generated from the corre...
bool canAssignObjCInterfacesInBlockPointer(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, bool BlockReturnType)
canAssignObjCInterfacesInBlockPointer - This routine is specifically written for providing type-safet...
CanQualType SatUnsignedLongFractTy
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
CanQualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
const ObjCInterfaceDecl * getObjContainingInterface(const NamedDecl *ND) const
Returns the Objective-C interface that ND belongs to if it is an Objective-C method/property/ivar etc...
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
CanQualType getCanonicalUnresolvedUsingType(const UnresolvedUsingTypenameDecl *D) const
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
llvm::APFixedPoint getFixedPointMax(QualType Ty) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool classMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
QualType getTemplateTypeParmType(int Depth, int Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
void deduplicateMergedDefinitionsFor(NamedDecl *ND)
Clean up the merged definition list.
static uint64_t getConstantArrayElementCount(const ConstantArrayType *CA)
Return number of (potentially nested) constant array elements.
DiagnosticsEngine & getDiagnostics() const
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void recordOffsetOfEvaluation(const OffsetOfExpr *E)
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
QualType getUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D) const
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
void getOverriddenMethods(const NamedDecl *Method, SmallVectorImpl< const NamedDecl * > &Overridden) const
Return C++ or ObjC overridden methods for the given Method.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y, bool IgnoreDeduced=false) const
Determine whether the given template names refer to the same template.
CanQualType SatLongFractTy
const TargetInfo & getTargetInfo() const
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
OBTAssignResult checkOBTAssignmentCompatibility(QualType LHS, QualType RHS)
Check overflow behavior type compatibility for assignments.
CanQualType SatShortAccumTy
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
static uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE)
Return number of elements initialized in a (potentially nested) ArrayInitLoopExpr.
void addExplicitInstantiationDecl(const NamedDecl *Spec, ExplicitInstantiationDecl *EID)
Add an ExplicitInstantiationDecl for a given specialization.
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
CanQualType IncompleteMatrixIdxTy
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
CanQualType getNSIntegerType() const
QualType getCorrespondingUnsignedType(QualType T) const
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
bool shouldEmitCUDADecl(const ValueDecl *D) const
Determines if the global variable or function D is emitted on the side of the CUDA/HIP compilation,...
TargetCXXABI::Kind getCXXABIKind() const
Return the C++ ABI kind that should be used.
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
CanQualType SatUnsignedLongAccumTy
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
CanQualType getCanonicalTagType(const TagDecl *TD) const
bool isSameTemplateArgument(const TemplateArgument &Arg1, const TemplateArgument &Arg2) const
Determine whether the given template arguments Arg1 and Arg2 are equivalent.
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getCorrespondingSignedType(QualType T) const
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
llvm::DenseMap< const Decl *, const Decl * > CommentlessRedeclChains
Keeps track of redeclaration chains that don't have any comment attached.
unsigned getTargetAddressSpace(LangAS AS) const
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
std::vector< PFPField > findPFPFields(QualType Ty) const
Returns a list of PFP fields for the given type, including subfields in bases or other fields,...
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
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...
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
void addTranslationUnitDecl()
void getObjCEncodingForPropertyType(QualType T, std::string &S) const
Emit the Objective-C property type encoding for the given type T into S.
unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
CollectInheritedProtocols - Collect all protocols in current class and those inherited by it.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
llvm::DenseMap< const Decl *, const Decl * > RedeclChainComments
Mapping from canonical declaration to the first redeclaration in chain that has a comment attached.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
std::optional< CXXRecordDeclRelocationInfo > getRelocationInfoForCXXRecord(const CXXRecordDecl *) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
InlineVariableDefinitionKind getInlineVariableDefinitionKind(const VarDecl *VD) const
Determine whether a definition of this inline variable should be treated as a weak or strong definiti...
const RawComment * getRawCommentForAnyRedecl(RawCommentLookupKey Key, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration or macro.
TemplateName getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
CanQualType getUIntMaxType() const
Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in <stdint.h>.
CharUnits getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const
Loading virtual member pointers using the virtual inheritance model always results in an adjustment u...
LangAS getLangASForBuiltinAddressSpace(unsigned AS) const
bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U)
Determine whether two function types are the same, ignoring pointer sizes in the return type and para...
void addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, FunctionDecl *OperatorDelete, OperatorDeleteKind K) const
unsigned char getFixedPointScale(QualType Ty) const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
QualType DecodeTypeStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequireICE, bool AllowTypeModifiers) const
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
@ GE_Missing_type
Missing a type.
QualType adjustStringLiteralBaseType(QualType StrLTy) const
uint16_t getPointerAuthTypeDiscriminator(QualType T)
Return the "other" type-specific discriminator for the given type.
llvm::SetVector< const FieldDecl * > PFPFieldsWithEvaluatedOffset
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD, bool IsVTTEntry)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers using the ...
bool canonicalizeTemplateArguments(MutableArrayRef< TemplateArgument > Args) const
Canonicalize the given template argument list.
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
QualType getMatrixTypeWithLayout(QualType T, MatrixType::LayoutKind Layout) const
bool isUnaryOverflowPatternExcluded(const UnaryOperator *UO)
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
TemplateName getDeducedTemplateName(TemplateName Underlying, DefaultArguments DefaultArgs) const
Represents a TemplateName which had some of its default arguments deduced.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
CanQualType UnsignedAccumTy
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
void cacheRawComment(RawCommentLookupKey Original, const RawComment &Comment) const
Attaches Comment to Original (a declaration or macro), and to its redeclaration chain when Original i...
QualType getVariableArrayDecayedType(QualType Ty) const
Returns a vla type where known sizes are replaced with [*].
void setCFConstantStringType(QualType T)
const SYCLKernelInfo * findSYCLKernelInfo(QualType T) const
Returns a pointer to the metadata generated from the corresponding SYCLkernel entry point if the prov...
unsigned getParameterIndex(const ParmVarDecl *D) const
Used by ParmVarDecl to retrieve on the side the index of the parameter when it exceeds the size of th...
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false) const
void AddDeallocation(void(*Callback)(void *), void *Data) const
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
QualType getDeducedTemplateSpecializationType(DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword, TemplateName Template) const
C++17 deduced class template specialization type.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
QualType mergeTransparentUnionType(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeTransparentUnionType - if T is a transparent union type and a member of T is compatible with Sub...
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
bool isSentinelNullExpr(const Expr *E)
CanQualType getNSUIntegerType() const
void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying)
TypedefDecl * getBuiltinZOSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_zos_va_list type.
void recordMemberDataPointerEvaluation(const ValueDecl *VD)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
virtual ~ASTMutationListener()
virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType)
A function's return type has been deduced.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool hasOwnVFPtr() const
hasOwnVFPtr - Does this class provide its own virtual-function table pointer, rather than inheriting ...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
bool hasOwnVBPtr() const
hasOwnVBPtr - Does this class provide its own virtual-base table pointer, rather than inheriting one ...
CharUnits getSize() const
getSize - Get the record size in characters.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding,...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
CharUnits getUnadjustedAlignment() const
getUnadjustedAlignment - Get the record alignment in characters, before alignment adjustment.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Represents a loop initializing the elements of an array.
llvm::APInt getArraySize() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
A structure for storing the information associated with a name that has been assumed to be a template...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Attr - This represents one attribute.
A fixed int type of a specified bitwidth.
unsigned getNumBits() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
This class is used for builtin types like 'int'.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Implements C++ ABI-specific semantic analysis functions.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
CXXRecordDecl * getDefinition() const
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isDynamicClass() const
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
SplitQualType split() const
static CanQual< Type > CreateUnsafe(QualType Other)
QualType withConst() const
Retrieves a version of this type with const applied.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
This is an opaque type for sizes expressed in character units.
bool isPositive() const
Test whether the quantity is greater than zero.
bool isZero() const
Test whether the quantity equals zero.
CharUnits alignTo(CharUnits Align) const
Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is a multiple...
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
static CharUnits Zero()
Construct a CharUnits quantity of zero.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Represents the canonical version of C arrays with a specified constant size.
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
void Profile(llvm::FoldingSetNodeID &ID)
unsigned getNumRows() const
Returns the number of rows in the matrix.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Decl::Kind getDeclKind() const
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isModuleLocal() const
Whether this declaration was a local declaration to a C++20 named module.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl,...
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
static Decl * castFromDeclContext(const DeclContext *)
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setImplicit(bool I=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
DeclarationNameLoc - Additional source/type location info for a declaration name.
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc, SourceLocation EndLoc)
Construct location information for a non-literal C++ operator.
The name of a declaration.
static int compare(DeclarationName LHS, DeclarationName RHS)
Represents a ValueDecl that came out of a declarator.
TypeSourceInfo * getTypeSourceInfo() const
TemplateName getUnderlying() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
DefaultArguments getDefaultArguments() const
Represents an extended address space qualifier where the input address space value is dependent.
Expr * getAddrSpaceExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents an array type in C++ whose size is a value-dependent expression.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Expr * getSizeExpr() const
Represents an extended vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Expr * getRowExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a dependent template name that cannot be resolved prior to template instantiation.
void Profile(llvm::FoldingSetNodeID &ID) const
IdentifierOrOverloadedOperator getName() const
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
bool hasTemplateKeyword() const
Was this template name was preceeded by the template keyword?
Internal representation of canonical, dependent typeof(expr) types.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
A dynamically typed AST node container.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
bool isComplete() const
Returns true if this can be considered a complete type.
EnumDecl * getDefinitionOrSelf() const
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Represents an explicit instantiation of a template entity in source code.
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
We can encode up to four bits in the low bits of a type pointer, but there are many more type qualifi...
void Profile(llvm::FoldingSetNodeID &ID) const
ExtVectorType - Extended vector type.
Declaration context for names declared as extern "C" in C++.
static ExternCContextDecl * Create(const ASTContext &C, TranslationUnitDecl *TU)
Abstract interface for external sources of AST nodes.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
unsigned getBitWidthValue() const
Computes the bit width of this field, if this is a bit field.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool isMSExternInline() const
The combination of the extern and inline keywords under MSVC forces the function to be required.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
FunctionDecl * getDefinition()
Get the definition for this declaration.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
bool isInlineDefinitionExternallyVisible() const
For an inline function definition in C, or for a gnu_inline function in C++, determine whether the de...
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
SmallVector< Conflict > Conflicts
static FunctionEffectSet getIntersection(FunctionEffectsRef LHS, FunctionEffectsRef RHS)
static FunctionEffectSet getUnion(FunctionEffectsRef LHS, FunctionEffectsRef RHS, Conflicts &Errs)
An immutable set of FunctionEffects and possibly conditions attached to them.
ArrayRef< EffectConditionExpr > conditions() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
void Profile(llvm::FoldingSetNodeID &ID)
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
QualType getParamType(unsigned i) const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
CallingConv getCC() const
bool getNoCfCheck() const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
ExtInfo withNoReturn(bool noReturn) const
bool getHasRegParm() const
bool getProducesResult() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
ExtParameterInfo withIsNoEscape(bool NoEscape) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
QualType getReturnType() const
GlobalDecl - represents a global declaration.
unsigned getMultiVersionIndex() const
CXXDtorType getDtorType() const
const Decl * getDecl() const
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
StringRef getName() const
Return the actual identifier string.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Represents a C array with an unspecified size.
void Profile(llvm::FoldingSetNodeID &ID)
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
An lvalue reference type, per C++11 [dcl.ref].
@ Swift
Interoperability with the latest known version of the Swift runtime.
@ Swift4_2
Interoperability with the Swift 4.2 runtime.
@ Swift4_1
Interoperability with the Swift 4.1 runtime.
@ Integer
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
@ All
Permit vector bitcasts between all vectors with the same total bit-width.
@ PostDecrInWhile
while (count–)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::optional< TargetCXXABI::Kind > CXXABI
C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
clang::ObjCRuntime ObjCRuntime
CoreFoundationABI CFRuntime
bool isOverflowPatternExcluded(OverflowPatternExclusionKind Kind) const
Represents a placeholder type for late-parsed type attributes.
static void Profile(llvm::FoldingSetNodeID &ID, Parts P)
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
static bool isValidElementType(QualType T, const LangOptions &LangOpts)
Valid elements types are the following:
QualType getElementType() const
Returns type of the elements being stored in the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
void Profile(llvm::FoldingSetNodeID &ID)
Provides information a specialization of a member of a class template, which may be a member function...
static MicrosoftMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
Describes a module or submodule.
bool isNamedModule() const
Does this Module is a named module of a standard named module?
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isPlaceholderVar(const LangOptions &LangOpts) const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
bool isExternallyVisible() const
Represent a C++ namespace.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested)
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NestedNameSpecifier getCanonical() const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
CXXRecordDecl * getAsMicrosoftSuper() const
NamespaceAndPrefix getAsNamespaceAndPrefix() const
const Type * getAsType() const
Kind
The kind of specifier that completes this nested name specifier.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, int D, int P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
ObjCCategoryDecl - Represents a category declaration.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, const IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
bool hasDefinition() const
Determine whether this class has been defined.
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class,...
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
ObjCImplementationDecl * getImplementation() const
ObjCInterfaceDecl * getSuperClass() const
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
known_extensions_range known_extensions() const
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCIvarDecl * getNextIvar()
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCDeclQualifier getObjCDeclQualifier() const
unsigned param_size() const
param_const_iterator param_end() const
param_const_iterator param_begin() const
const ParmVarDecl *const * param_const_iterator
Selector getSelector() const
bool isInstanceMethod() const
QualType getReturnType() const
Represents a pointer to an Objective C object.
bool isObjCQualifiedClassType() const
True if this is equivalent to 'Class.
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
Represents one property declaration in an Objective-C interface.
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
SetterKind getSetterKind() const
getSetterKind - Return the method used for doing assignment in the property setter.
Selector getSetterName() const
Selector getGetterName() const
ObjCPropertyAttribute::Kind getPropertyAttributes() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
ObjCIvarDecl * getPropertyIvarDecl() const
Represents an Objective-C protocol declaration.
protocol_range protocols() const
bool isGNUFamily() const
Is this runtime basically of the GNU family of runtimes?
Represents the declaration of an Objective-C type parameter.
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
const OffsetOfNode & getComponent(unsigned Idx) const
unsigned getNumComponents() const
Helper class for OffsetOfExpr.
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
A structure for storing a pack-index-template-name ([temp.names]).
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
bool isFullySubstituted() const
TemplateName getPattern() const
Expr * getIndexExpr() const
ArrayRef< TemplateName > getExpansions() const
Sugar for parentheses used when specifying types.
void clear()
Clear parent maps.
DynTypedNodeList getParents(const NodeT &Node)
Returns the parents of the given node (within the traversal scope).
Represents a parameter to a function.
ObjCDeclQualifier getObjCDeclQualifier() const
QualType getOriginalType() const
ParsedAttr - Represents a syntactic attribute.
Pointer-authentication qualifiers.
static PointerAuthQualifier Create(unsigned Key, bool IsAddressDiscriminated, unsigned ExtraDiscriminator, PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer, bool AuthenticatesNullValues)
bool isEquivalent(PointerAuthQualifier Other) const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A (possibly-)qualified type.
bool hasAddressDiscriminatedPointerAuth() const
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
Qualifiers::GC getObjCGCAttr() const
Returns gc attribute of this type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
QualType withConst() const
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
bool isConstQualified() const
Determine whether this type is const-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
const Type * getTypePtrOrNull() const
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Represents a template name as written in source code.
void Profile(llvm::FoldingSetNodeID &ID)
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void removeCVRQualifiers(unsigned mask)
void addAddressSpace(LangAS space)
static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
Returns the common set of qualifiers while removing them from the given sets.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
void removeFastQualifiers(unsigned mask)
bool hasUnaligned() const
bool hasAddressSpace() const
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
unsigned getFastQualifiers() const
void removeAddressSpace()
PointerAuthQualifier getPointerAuth() const
bool hasObjCGCAttr() const
uint64_t getAsOpaqueValue() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCGCAttr() const
void addObjCGCAttr(GC type)
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
bool hasFlexibleArrayMember() const
field_range fields() const
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
RecordDecl * getMostRecentDecl()
virtual void completeDefinition()
Note that the definition of this type is now complete.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
This table allows us to fully hide how we implement multi-keyword caching.
std::string getAsString() const
Derive the full selector name (e.g.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
StringLiteral - This represents a string literal expression, e.g.
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
A structure for storing an already-substituted template template parameter pack.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context)
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
A structure for storing the information associated with a substituted template template parameter.
void Profile(llvm::FoldingSetNodeID &ID)
TemplateTemplateParmDecl * getParameter() const
Represents the declaration of a struct/union/class/enum.
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TagKind getTagKind() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Kind
The basic C++ ABI kind.
static Kind getKind(StringRef Name)
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
unsigned getMaxAtomicInlineWidth() const
Return the maximum width lock-free atomic operation which can be inlined given the supported features...
virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
unsigned getDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
@ AArch64ABIBuiltinVaList
__builtin_va_list as defined by the AArch64 ABI http://infocenter.arm.com/help/topic/com....
@ PowerABIBuiltinVaList
__builtin_va_list as defined by the Power ABI: https://www.power.org /resources/downloads/Power-Arch-...
@ AAPCSABIBuiltinVaList
__builtin_va_list as defined by ARM AAPCS ABI http://infocenter.arm.com
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
@ X86_64ABIBuiltinVaList
__builtin_va_list as defined by the x86-64 ABI: http://refspecs.linuxbase.org/elf/x86_64-abi-0....
virtual uint64_t getNullPointerValue(LangAS AddrSpace) const
Get integer value for null pointer.
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
IntType getPtrDiffType(LangAS AddrSpace) const
bool isLittleEndian() const
IntType getSizeType() const
FloatModeKind getRealTypeByWidth(unsigned BitWidth, FloatModeKind ExplicitType) const
Return floating point type with specified width.
virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return integer type with specified width.
unsigned getMaxAlignedAttribute() const
Get the maximum alignment in bits for a static variable with aligned attribute.
virtual unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
unsigned getTargetAddressSpace(LangAS AS) const
IntType getSignedSizeType() const
const llvm::fltSemantics & getLongDoubleFormat() const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool useAddressSpaceMapMangling() const
Specify if mangling based on address space map should be used or not for language specific address sp...
A convenient class for passing around template argument information.
ArrayRef< TemplateArgumentLoc > arguments() const
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
UnsignedOrNone getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DeducedTemplateStorage * getAsDeducedTemplateName() const
Retrieve the deduced template info, if any.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
std::optional< TemplateName > desugar(bool IgnoreDeduced) const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ PackIndexingTemplate
A pack-index-template-name.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
PackIndexingTemplateStorage * getAsPackIndexingTemplate() const
Retrieve the pack-index-template-name storage, if any.
A template parameter object.
static void Profile(llvm::FoldingSetNodeID &ID, QualType T, const APValue &V)
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
ArrayRef< NamedDecl * > asArray()
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TemplateNameKind templateParameterKind() const
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, int D, int P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
unsigned getDepth() const
Get the nesting depth of the template parameter.
Declaration of a template type parameter.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, int D, int P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
Token - This structure provides full information about a lexed token.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
TemplateName getNamedConcept() const
ConceptReference * getConceptReference() const
Represents a declaration of a type.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location.
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
The base class of the type hierarchy.
bool isBlockPointerType() const
bool isObjCBuiltinType() const
bool isPackedVectorBoolType(const ASTContext &ctx) const
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isFloat16Type() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
bool isPointerType() const
TagDecl * castAsTagDecl() const
bool isArrayParameterType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isSignedFixedPointType() const
Return true if this is a fixed point type that is signed according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isEnumeralType() const
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isSaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
QualType getCanonicalTypeInternal() const
@ PtrdiffT
The "ptrdiff_t" type.
@ SizeT
The "size_t" type.
@ SignedSizeT
The signed integer type corresponding to "size_t".
bool isObjCIdType() const
bool isOverflowBehaviorType() const
bool isUnsaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isUnsignedFixedPointType() const
Return true if this is a fixed point type that is unsigned according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isVectorType() const
bool isObjCClassType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isRecordType() const
bool isObjCRetainableType() const
NullabilityKindOrNone getNullability() const
Determine the nullability of the given type.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType Underlying)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
static void Profile(llvm::FoldingSetNodeID &ID, QualType Ty, const APValue &APVal)
The iterator over UnresolvedSets.
Represents the dependent type named by a dependently-scoped typename using declaration,...
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D)
Represents a dependent using declaration which was marked with typename.
UnresolvedUsingTypenameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Represents a C++ using-enum-declaration.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
bool isStaticDataMember() const
Determines whether this is a static data member.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
bool isInline() const
Whether this variable is (C++1z) inline.
@ DeclarationOnly
This declaration is only a declaration.
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
void Profile(llvm::FoldingSetNodeID &ID)
VectorKind getVectorKind() const
QualType getElementType() const
Holds all information required to evaluate constexpr code in a module.
Defines the Linkage enumeration and various utility functions.
Defines the clang::TargetInfo interface.
mlir::Type getBaseType(mlir::Value varPtr)
const AstTypeMatcher< TagType > tagType
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
GVALinkage
A more specific kind of linkage than enum Linkage.
@ GVA_AvailableExternally
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
OpenCLTypeKind
OpenCL type kinds.
bool isRVVFixedLengthDataVectorKind(VectorKind VK)
True if VK is one of the RVV fixed-length data vector kinds, i.e.
constexpr llvm::StringLiteral VTTVTablePointerDiscriminatorSuffix
FunctionType::ExtInfo getFunctionExtInfo(const Type &t)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
@ ICIS_NoInit
No in-class initializer.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
std::pair< FileID, unsigned > FileIDAndOffset
CXXABI * CreateMicrosoftCXXABI(ASTContext &Ctx)
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
TypeOfKind
The kind of 'typeof' expression we're after.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
unsigned getRVVFixedLengthMaskRatioLog2(VectorKind VK)
Return log2 of the R of the vbool<R>_t type recorded in an RVV fixed-length mask vector kind: Ratio1 ...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool isRVVFixedLengthVectorKind(VectorKind VK)
True if VK is one of the RVV fixed-length data or mask vector kinds.
CXXABI * CreateItaniumCXXABI(ASTContext &Ctx)
Creates an instance of a C++ ABI class.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
constexpr uint16_t SelPointerConstantDiscriminator
Constant discriminator to be used with objective-c sel pointers.
bool isDiscardableGVALinkage(GVALinkage L)
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
@ Keyword
The name has been typo-corrected to a keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
TranslationUnitKind
Describes the kind of translation unit being processed.
@ Deduced
The normal deduced case.
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
const Decl & adjustDeclToTemplate(const Decl &D)
If we have a 'templated' declaration for a template, adjust 'D' to refer to the actual template.
bool isPtrSizeAddressSpace(LangAS AS)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ Invariant
The parameter is invariant: must match exactly.
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
@ AltiVecBool
is AltiVec 'vector bool ...'
@ SveFixedLengthData
is AArch64 SVE fixed-length data vector
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ Generic
not a target-specific vector type
@ SveFixedLengthPredicate
is AArch64 SVE fixed-length predicate vector
U cast(CodeGen::Address addr)
LangAS getLangASFromTargetAS(unsigned TargetAS)
@ ResistPragmaPack
The type's natural alignment is preserved under pragma pack in MSVC record layout (e....
@ None
The alignment was not explicit in code.
@ RequiredByEnum
The alignment comes from an alignment attribute on a enum type.
@ RequiredByTypedef
The alignment comes from an alignment attribute on a typedef.
@ RequiredByRecord
The alignment comes from an alignment attribute on a record type.
@ PackIndex
Index of a pack indexing expression or specifier.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
bool isRVVFixedLengthMaskVectorKind(VectorKind VK)
True if VK is one of the RVV fixed-length mask vector kinds, i.e.
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 int64_t
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
const Expr * ConstraintExpr
UnsignedOrNone ArgPackSubstIndex
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Expr * getCopyExpr() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
ArrayRef< TemplateArgument > Args
Holds information about the various types of exception specification.
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
bool requiresFunctionProtoTypeArmAttributes() const
FunctionEffectsRef FunctionEffects
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
bool requiresFunctionProtoTypeExtraAttributeInfo() const
unsigned HasTrailingReturn
bool requiresFunctionProtoTypeExtraBitfields() const
FunctionType::ExtInfo ExtInfo
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
A late-parsed attribute that will be applied as a type attribute.
constexpr underlying_type toInternalRepresentation() const
Contains information gathered from parsing the contents of TargetAttr.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
Store declaration pairs already found to be non-equivalent.
bool IsEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
A this pointer adjustment.
IntType
===-— Target Data Type Query Methods ----------------------------—===//
AlignRequirementKind AlignRequirement
AlignRequirementKind AlignRequirement