68#include "llvm/ADT/APFixedPoint.h"
69#include "llvm/ADT/APInt.h"
70#include "llvm/ADT/APSInt.h"
71#include "llvm/ADT/ArrayRef.h"
72#include "llvm/ADT/DenseMap.h"
73#include "llvm/ADT/DenseSet.h"
74#include "llvm/ADT/FoldingSet.h"
75#include "llvm/ADT/PointerUnion.h"
76#include "llvm/ADT/STLExtras.h"
77#include "llvm/ADT/SmallPtrSet.h"
78#include "llvm/ADT/SmallVector.h"
79#include "llvm/ADT/StringExtras.h"
80#include "llvm/ADT/StringRef.h"
81#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
82#include "llvm/Support/Capacity.h"
83#include "llvm/Support/Casting.h"
84#include "llvm/Support/Compiler.h"
85#include "llvm/Support/ErrorHandling.h"
86#include "llvm/Support/MD5.h"
87#include "llvm/Support/MathExtras.h"
88#include "llvm/Support/SipHash.h"
89#include "llvm/Support/raw_ostream.h"
90#include "llvm/TargetParser/AArch64TargetParser.h"
91#include "llvm/TargetParser/Triple.h"
104using namespace clang;
128 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
133 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
134 if (VD->isStaticDataMember() &&
139 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(D)) {
144 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
151 if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
155 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
158 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
190 Locations.emplace_back(BaseLocation);
203 Locations.emplace_back(SourceMgr.getExpansionLoc(BaseLocation));
210 Locations.emplace_back(SourceMgr.getSpellingLoc(D->
getBeginLoc()));
218 const std::map<unsigned, RawComment *> &CommentsInTheFile)
const {
221 if (RepresentativeLocForDecl.
isInvalid() ||
222 !RepresentativeLocForDecl.
isFileID())
226 if (CommentsInTheFile.empty())
232 SourceMgr.getDecomposedLoc(RepresentativeLocForDecl);
235 auto OffsetCommentBehindDecl =
236 CommentsInTheFile.lower_bound(DeclLocDecomp.second);
239 if (OffsetCommentBehindDecl != CommentsInTheFile.end()) {
240 RawComment *CommentBehindDecl = OffsetCommentBehindDecl->second;
242 LangOpts.CommentOpts.ParseAllComments) &&
249 if (SourceMgr.getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second) ==
250 Comments.getCommentBeginLine(CommentBehindDecl, DeclLocDecomp.first,
251 OffsetCommentBehindDecl->first)) {
252 return CommentBehindDecl;
259 if (OffsetCommentBehindDecl == CommentsInTheFile.begin())
262 auto OffsetCommentBeforeDecl = --OffsetCommentBehindDecl;
263 RawComment *CommentBeforeDecl = OffsetCommentBeforeDecl->second;
267 LangOpts.CommentOpts.ParseAllComments) ||
272 const unsigned CommentEndOffset =
273 Comments.getCommentEndOffset(CommentBeforeDecl);
277 const char *Buffer = SourceMgr.getBufferData(DeclLocDecomp.first,
283 StringRef
Text(Buffer + CommentEndOffset,
284 DeclLocDecomp.second - CommentEndOffset);
288 if (
Text.find_last_of(
";{}#@") != StringRef::npos)
291 return CommentBeforeDecl;
297 for (
const auto DeclLoc : DeclLocs) {
300 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
311 const FileID File = SourceMgr.getDecomposedLoc(DeclLoc).first;
315 const auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
316 if (!CommentsInThisFile || CommentsInThisFile->empty())
328 assert(LangOpts.RetainCommentsFromSystemHeaders ||
330 Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
337 if (
const auto *FD = dyn_cast<FunctionDecl>(&D)) {
357 if (
const auto *VD = dyn_cast<VarDecl>(&D)) {
360 if (VD->isStaticDataMember())
366 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(&D)) {
373 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(CRD)) {
381 : *
static_cast<const Decl *
>(
387 CRD->getMemberSpecializationInfo())
388 return *Info->getInstantiatedFrom();
392 if (
const auto *ED = dyn_cast<EnumDecl>(&D)) {
405 const Decl **OriginalDecl)
const {
408 OriginalDecl =
nullptr;
420 return DeclComment->second;
433 *OriginalDecl = RedeclComment->second;
436 "This decl is supposed to have comment attached.");
437 return CommentAtRedecl->second;
442 const Decl *LastCheckedRedecl = [&]() {
444 bool CanUseCommentlessCache =
false;
446 for (
auto *Redecl : CanonicalD->
redecls()) {
448 CanUseCommentlessCache =
true;
451 if (Redecl == LastChecked)
458 return CanUseCommentlessCache ? LastChecked :
nullptr;
464 if (LastCheckedRedecl) {
465 if (LastCheckedRedecl == Redecl) {
466 LastCheckedRedecl =
nullptr;
474 *OriginalDecl = Redecl;
475 return RedeclComment;
481 *OriginalDecl =
nullptr;
487 assert(Comment.
isDocumentation() || LangOpts.CommentOpts.ParseAllComments);
497 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(DC)) {
502 for (
const auto *Ext : ID->known_extensions()) {
506 Redeclared.push_back(RedeclaredMethod);
513 if (
Comments.empty() || Decls.empty())
517 for (
const Decl *D : Decls) {
518 if (D->isInvalidDecl())
526 File = SourceMgr.getDecomposedLoc(Loc).first;
531 if (
File.isInvalid())
534 auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
535 if (!CommentsInThisFile || CommentsInThisFile->empty() ||
536 CommentsInThisFile->rbegin()->second->isAttached())
546 for (
const Decl *D : Decls) {
548 if (D->isInvalidDecl())
558 for (
const auto DeclLoc : DeclLocs) {
559 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
563 D, DeclLoc, *CommentsInThisFile)) {
574 const Decl *D)
const {
577 ThisDeclInfo->IsFilled =
false;
578 ThisDeclInfo->fill();
579 ThisDeclInfo->CommentDecl = FC->
getDecl();
580 if (!ThisDeclInfo->TemplateParameters)
590 return RC ? RC->
parse(*
this,
nullptr, D) :
nullptr;
601 llvm::DenseMap<const Decl *, comments::FullComment *>::iterator Pos =
605 if (Canonical != D) {
613 const Decl *OriginalDecl =
nullptr;
619 const auto *OMD = dyn_cast<ObjCMethodDecl>(D);
620 if (OMD && OMD->isPropertyAccessor())
627 for (
unsigned i = 0, e = Overridden.size(); i < e; i++)
631 else if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
634 QualType QT = TD->getUnderlyingType();
635 if (
const auto *TT = QT->
getAs<TagType>())
640 else if (
const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
641 while (IC->getSuperClass()) {
642 IC = IC->getSuperClass();
647 else if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(D)) {
652 else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
653 if (!(RD = RD->getDefinition()))
656 for (
const auto &I : RD->bases()) {
657 if (I.isVirtual() || (I.getAccessSpecifier() !=
AS_public))
671 for (
const auto &I : RD->vbases()) {
692 if (D != OriginalDecl && OriginalDecl)
700void ASTContext::CanonicalTemplateTemplateParm::Profile(
709 ID.AddInteger(Params->
size());
711 PEnd = Params->
end();
713 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
715 ID.AddBoolean(TTP->isParameterPack());
717 TTP->getNumExpansionParameters().toInternalRepresentation());
721 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
723 ID.AddBoolean(NTTP->isParameterPack());
724 ID.AddPointer(
C.getUnconstrainedType(
C.getCanonicalType(NTTP->getType()))
726 if (NTTP->isExpandedParameterPack()) {
728 ID.AddInteger(NTTP->getNumExpansionTypes());
729 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
731 ID.AddPointer(
T.getCanonicalType().getAsOpaquePtr());
734 ID.AddBoolean(
false);
744TemplateTemplateParmDecl *
748 llvm::FoldingSetNodeID ID;
749 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
750 void *InsertPos =
nullptr;
751 CanonicalTemplateTemplateParm *Canonical
752 = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
754 return Canonical->getParam();
759 CanonParams.reserve(Params->
size());
761 PEnd = Params->
end();
765 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
770 TTP->getNumExpansionParameters());
771 CanonParams.push_back(NewTTP);
772 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
776 if (NTTP->isExpandedParameterPack()) {
779 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
781 ExpandedTInfos.push_back(
789 NTTP->getPosition(),
nullptr,
799 NTTP->getPosition(),
nullptr,
801 NTTP->isParameterPack(),
804 CanonParams.push_back(Param);
820 Canonical = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
821 assert(!Canonical &&
"Shouldn't be in the map!");
825 Canonical =
new (*this) CanonicalTemplateTemplateParm(CanonTTP);
826 CanonTemplateTemplateParms.InsertNode(Canonical, InsertPos);
833 llvm::FoldingSetNodeID ID;
834 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
835 void *InsertPos =
nullptr;
836 CanonicalTemplateTemplateParm *Canonical =
837 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
838 return Canonical ? Canonical->getParam() :
nullptr;
844 llvm::FoldingSetNodeID ID;
845 CanonicalTemplateTemplateParm::Profile(ID, *
this, CanonTTP);
846 void *InsertPos =
nullptr;
848 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos))
849 return Existing->getParam();
850 CanonTemplateTemplateParms.InsertNode(
851 new (*
this) CanonicalTemplateTemplateParm(CanonTTP), InsertPos);
860 return NoSanitizeL->containsType(Mask, TyName);
869 if (!LangOpts.CPlusPlus)
return nullptr;
872 case TargetCXXABI::AppleARM64:
873 case TargetCXXABI::Fuchsia:
874 case TargetCXXABI::GenericARM:
875 case TargetCXXABI::iOS:
876 case TargetCXXABI::WatchOS:
877 case TargetCXXABI::GenericAArch64:
878 case TargetCXXABI::GenericMIPS:
879 case TargetCXXABI::GenericItanium:
880 case TargetCXXABI::WebAssembly:
881 case TargetCXXABI::XL:
883 case TargetCXXABI::Microsoft:
886 llvm_unreachable(
"Invalid CXXABI type!");
890 if (!InterpContext) {
893 return *InterpContext;
899 return *ParentMapCtx;
904 switch (LangOpts.getAddressSpaceMapMangling()) {
912 llvm_unreachable(
"getAddressSpaceMapMangling() doesn't cover anything.");
918 : ConstantArrayTypes(this_(), ConstantArrayTypesLog2InitSize),
919 DependentSizedArrayTypes(this_()), DependentSizedExtVectorTypes(this_()),
920 DependentAddressSpaceTypes(this_()), DependentVectorTypes(this_()),
921 DependentSizedMatrixTypes(this_()),
922 FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
923 DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
924 DependentPackIndexingTypes(this_()), TemplateSpecializationTypes(this_()),
925 DependentBitIntTypes(this_()), SubstTemplateTemplateParmPacks(this_()),
926 DeducedTemplates(this_()), ArrayParameterTypes(this_()),
927 CanonTemplateTemplateParms(this_()), SourceMgr(
SM), LangOpts(LOpts),
930 LangOpts.XRayNeverInstrumentFiles,
931 LangOpts.XRayAttrListFiles,
SM)),
935 Comments(
SM), CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
943 ReleaseDeclContextMaps();
946 for (
auto &Pair : Deallocations)
947 (Pair.first)(Pair.second);
948 Deallocations.clear();
954 I = ObjCLayouts.begin(),
955 E = ObjCLayouts.end();
962 for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
963 I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
968 ASTRecordLayouts.clear();
970 for (llvm::DenseMap<const Decl*, AttrVec*>::iterator A = DeclAttrs.begin(),
971 AEnd = DeclAttrs.end();
973 A->second->~AttrVec();
976 for (
const auto &
Value : ModuleInitializers)
977 Value.second->~PerModuleInitializers();
978 ModuleInitializers.
clear();
984 TraversalScope = TopLevelDecls;
989 Deallocations.push_back({Callback,
Data});
998 llvm::errs() <<
"\n*** AST Context Stats:\n";
999 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
1001 unsigned counts[] = {
1002#define TYPE(Name, Parent) 0,
1003#define ABSTRACT_TYPE(Name, Parent)
1004#include "clang/AST/TypeNodes.inc"
1008 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
1014 unsigned TotalBytes = 0;
1015#define TYPE(Name, Parent) \
1017 llvm::errs() << " " << counts[Idx] << " " << #Name \
1018 << " types, " << sizeof(Name##Type) << " each " \
1019 << "(" << counts[Idx] * sizeof(Name##Type) \
1021 TotalBytes += counts[Idx] * sizeof(Name##Type); \
1023#define ABSTRACT_TYPE(Name, Parent)
1024#include "clang/AST/TypeNodes.inc"
1026 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
1031 <<
" implicit default constructors created\n";
1034 <<
" implicit copy constructors created\n";
1038 <<
" implicit move constructors created\n";
1041 <<
" implicit copy assignment operators created\n";
1045 <<
" implicit move assignment operators created\n";
1048 <<
" implicit destructors created\n";
1051 llvm::errs() <<
"\n";
1055 BumpAlloc.PrintStats();
1059 bool NotifyListeners) {
1060 if (NotifyListeners)
1063 Listener->RedefinedHiddenDefinition(ND, M);
1070 if (It == MergedDefModules.end())
1073 auto &Merged = It->second;
1074 llvm::DenseSet<Module*>
Found;
1075 for (
Module *&M : Merged)
1076 if (!
Found.insert(M).second)
1078 llvm::erase(Merged,
nullptr);
1085 if (MergedIt == MergedDefModules.end())
1087 return MergedIt->second;
1090void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1091 if (LazyInitializers.empty())
1095 assert(Source &&
"lazy initializers but no external source");
1097 auto LazyInits = std::move(LazyInitializers);
1098 LazyInitializers.clear();
1100 for (
auto ID : LazyInits)
1101 Initializers.push_back(Source->GetExternalDecl(ID));
1103 assert(LazyInitializers.empty() &&
1104 "GetExternalDecl for lazy module initializer added more inits");
1110 if (
const auto *ID = dyn_cast<ImportDecl>(D)) {
1111 auto It = ModuleInitializers.find(ID->getImportedModule());
1114 if (It == ModuleInitializers.end())
1118 auto &Imported = *It->second;
1119 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1120 Imported.resolve(*
this);
1121 auto *OnlyDecl = Imported.Initializers.front();
1127 auto *&Inits = ModuleInitializers[M];
1129 Inits =
new (*this) PerModuleInitializers;
1130 Inits->Initializers.push_back(D);
1135 auto *&Inits = ModuleInitializers[M];
1137 Inits =
new (*this) PerModuleInitializers;
1138 Inits->LazyInitializers.insert(Inits->LazyInitializers.end(),
1139 IDs.begin(), IDs.end());
1143 auto It = ModuleInitializers.find(M);
1144 if (It == ModuleInitializers.end())
1147 auto *Inits = It->second;
1148 Inits->resolve(*
this);
1149 return Inits->Initializers;
1154 assert(!CurrentCXXNamedModule &&
1155 "We should set named module for ASTContext for only once");
1156 CurrentCXXNamedModule = M;
1168 auto GetRepresentativeModule = [
this](
const Module *M) {
1169 auto Iter = SameModuleLookupSet.find(M);
1170 if (Iter != SameModuleLookupSet.end())
1171 return Iter->second;
1173 const Module *RepresentativeModule =
1174 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1176 SameModuleLookupSet[M] = RepresentativeModule;
1177 return RepresentativeModule;
1180 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1181 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1185 if (!ExternCContext)
1188 return ExternCContext;
1202#define BuiltinTemplate(BTName) \
1203 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1204 if (!Decl##BTName) \
1206 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1207 return Decl##BTName; \
1209#include "clang/Basic/BuiltinTemplates.inc"
1222 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1223 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1228 StringRef Name)
const {
1252 Types.push_back(Ty);
1257 assert((!this->Target || this->Target == &Target) &&
1258 "Incorrect target reinitialization");
1259 assert(
VoidTy.isNull() &&
"Context reinitialized?");
1261 this->Target = &Target;
1262 this->AuxTarget = AuxTarget;
1264 ABI.reset(createCXXABI(Target));
1268 InitBuiltinType(
VoidTy, BuiltinType::Void);
1271 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1273 if (LangOpts.CharIsSigned)
1274 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1276 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1279 InitBuiltinType(
ShortTy, BuiltinType::Short);
1280 InitBuiltinType(
IntTy, BuiltinType::Int);
1281 InitBuiltinType(
LongTy, BuiltinType::Long);
1282 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1292 InitBuiltinType(
FloatTy, BuiltinType::Float);
1293 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1294 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1297 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1300 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1303 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1306 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1307 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1308 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1312 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1313 InitBuiltinType(
FractTy, BuiltinType::Fract);
1314 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1319 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1325 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1332 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1337 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1339 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1340 if (LangOpts.CPlusPlus && LangOpts.WChar)
1344 WideCharTy = getFromTargetType(Target.getWCharType());
1347 WIntTy = getFromTargetType(Target.getWIntType());
1350 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1352 if (LangOpts.CPlusPlus)
1353 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1355 Char16Ty = getFromTargetType(Target.getChar16Type());
1357 if (LangOpts.CPlusPlus)
1358 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1360 Char32Ty = getFromTargetType(Target.getChar32Type());
1367 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1370 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1382 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1388 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1391 if (LangOpts.OpenMP) {
1398 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1401 if (LangOpts.MatrixTypes)
1409 if (LangOpts.OpenCL) {
1410#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1411 InitBuiltinType(SingletonId, BuiltinType::Id);
1412#include "clang/Basic/OpenCLImageTypes.def"
1414 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1415 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1417 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1420#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1421 InitBuiltinType(Id##Ty, BuiltinType::Id);
1422#include "clang/Basic/OpenCLExtensionTypes.def"
1425 if (LangOpts.HLSL) {
1426#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1427 InitBuiltinType(SingletonId, BuiltinType::Id);
1428#include "clang/Basic/HLSLIntangibleTypes.def"
1431 if (Target.hasAArch64ACLETypes() ||
1432 (AuxTarget && AuxTarget->hasAArch64ACLETypes())) {
1433#define SVE_TYPE(Name, Id, SingletonId) \
1434 InitBuiltinType(SingletonId, BuiltinType::Id);
1435#include "clang/Basic/AArch64ACLETypes.def"
1438 if (Target.getTriple().isPPC64()) {
1439#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1440 InitBuiltinType(Id##Ty, BuiltinType::Id);
1441#include "clang/Basic/PPCTypes.def"
1442#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1443 InitBuiltinType(Id##Ty, BuiltinType::Id);
1444#include "clang/Basic/PPCTypes.def"
1447 if (Target.hasRISCVVTypes()) {
1448#define RVV_TYPE(Name, Id, SingletonId) \
1449 InitBuiltinType(SingletonId, BuiltinType::Id);
1450#include "clang/Basic/RISCVVTypes.def"
1453 if (Target.getTriple().isWasm() && Target.hasFeature(
"reference-types")) {
1454#define WASM_TYPE(Name, Id, SingletonId) \
1455 InitBuiltinType(SingletonId, BuiltinType::Id);
1456#include "clang/Basic/WebAssemblyReferenceTypes.def"
1459 if (Target.getTriple().isAMDGPU() ||
1460 (AuxTarget && AuxTarget->getTriple().isAMDGPU())) {
1461#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1462 InitBuiltinType(SingletonId, BuiltinType::Id);
1463#include "clang/Basic/AMDGPUTypes.def"
1470 ObjCConstantStringType =
QualType();
1475 if (LangOpts.OpenCLGenericAddressSpace) {
1476 auto Q =
VoidTy.getQualifiers();
1485 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1488 InitBuiltinType(
HalfTy, BuiltinType::Half);
1490 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1496 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1503 return SourceMgr.getDiagnostics();
1518 llvm::DenseMap<const Decl*, AttrVec*>::iterator Pos = DeclAttrs.find(D);
1519 if (Pos != DeclAttrs.end()) {
1520 Pos->second->~AttrVec();
1521 DeclAttrs.erase(Pos);
1535 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1536 TemplateOrInstantiation.find(Var);
1537 if (Pos == TemplateOrInstantiation.end())
1550 Tmpl, TSK, PointOfInstantiation));
1556 assert(!TemplateOrInstantiation[Inst] &&
1557 "Already noted what the variable was instantiated from");
1558 TemplateOrInstantiation[Inst] = TSI;
1563 return InstantiatedFromUsingDecl.lookup(UUD);
1571 "pattern decl is not a using decl");
1575 "instantiation did not produce a using decl");
1576 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1577 InstantiatedFromUsingDecl[Inst] = Pattern;
1582 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1587 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1588 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1593 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1599 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1600 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1605 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1611 "Instantiated field decl is not unnamed");
1613 "Template field decl is not unnamed");
1614 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1615 "Already noted what unnamed field was instantiated from");
1617 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1633 return Range.end() - Range.begin();
1638 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1639 OverriddenMethods.find(
Method->getCanonicalDecl());
1640 if (Pos == OverriddenMethods.end())
1648 OverriddenMethods[
Method].push_back(Overridden);
1656 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1662 const auto *
Method = dyn_cast<ObjCMethodDecl>(D);
1667 Method->getOverriddenMethods(OverDecls);
1668 Overridden.append(OverDecls.begin(), OverDecls.end());
1671std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1675 auto it = RelocatableClasses.find(D);
1676 if (it != RelocatableClasses.end())
1677 return it->getSecond();
1678 return std::nullopt;
1685 assert(RelocatableClasses.find(D) == RelocatableClasses.end());
1686 RelocatableClasses.insert({D, Info});
1691 if (!Class->isPolymorphic())
1693 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
1694 using AuthAttr = VTablePointerAuthenticationAttr;
1695 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1697 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1698 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1699 ExplicitAuth->getAddressDiscrimination();
1700 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1701 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1702 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1705ASTContext::PointerAuthContent
1706ASTContext::findPointerAuthContent(QualType
T)
const {
1707 assert(isPointerAuthenticationAvailable());
1709 T =
T.getCanonicalType();
1711 return PointerAuthContent::None;
1713 if (
T.hasAddressDiscriminatedPointerAuth())
1714 return PointerAuthContent::AddressDiscriminatedData;
1717 return PointerAuthContent::None;
1719 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1720 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1721 return Existing->second;
1723 PointerAuthContent
Result = PointerAuthContent::None;
1725 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1726 auto [ResultIter, DidAdd] =
1727 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1733 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1734 static_assert(PointerAuthContent::None <
1735 PointerAuthContent::AddressDiscriminatedVTable);
1736 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1737 PointerAuthContent::AddressDiscriminatedData);
1740 return Result != PointerAuthContent::AddressDiscriminatedData;
1742 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1744 !ShouldContinueAfterUpdate(
1745 PointerAuthContent::AddressDiscriminatedVTable))
1746 return SaveResultAndReturn();
1747 for (
auto Base : CXXRD->bases()) {
1748 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1749 return SaveResultAndReturn();
1752 for (
auto *FieldDecl : RD->
fields()) {
1753 if (!ShouldContinueAfterUpdate(
1754 findPointerAuthContent(FieldDecl->getType())))
1755 return SaveResultAndReturn();
1757 return SaveResultAndReturn();
1761 assert(!Import->getNextLocalImport() &&
1762 "Import declaration already in the chain");
1763 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1764 if (!FirstLocalImport) {
1765 FirstLocalImport = Import;
1766 LastLocalImport = Import;
1770 LastLocalImport->setNextLocalImport(Import);
1771 LastLocalImport = Import;
1783 llvm_unreachable(
"Not a floating point type!");
1784 case BuiltinType::BFloat16:
1785 return Target->getBFloat16Format();
1786 case BuiltinType::Float16:
1787 return Target->getHalfFormat();
1788 case BuiltinType::Half:
1789 return Target->getHalfFormat();
1790 case BuiltinType::Float:
return Target->getFloatFormat();
1791 case BuiltinType::Double:
return Target->getDoubleFormat();
1792 case BuiltinType::Ibm128:
1793 return Target->getIbm128Format();
1794 case BuiltinType::LongDouble:
1796 return AuxTarget->getLongDoubleFormat();
1797 return Target->getLongDoubleFormat();
1798 case BuiltinType::Float128:
1800 return AuxTarget->getFloat128Format();
1801 return Target->getFloat128Format();
1806 unsigned Align = Target->getCharWidth();
1810 Align = AlignFromAttr;
1818 bool UseAlignAttrOnly;
1819 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1821 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1823 UseAlignAttrOnly = AlignFromAttr != 0;
1826 if (UseAlignAttrOnly) {
1828 }
else if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
1832 T = RT->getPointeeType();
1837 if (
T->isFunctionType())
1838 Align = getTypeInfoImpl(
T.getTypePtr()).Align;
1843 unsigned MinWidth = Target->getLargeArrayMinWidth();
1844 if (!ForAlignof && MinWidth) {
1846 Align = std::max(Align, Target->getLargeArrayAlign());
1849 Align = std::max(Align, Target->getLargeArrayAlign());
1854 Align = Target->getCharWidth();
1858 if (
const auto *VD = dyn_cast<VarDecl>(D))
1859 if (VD->hasGlobalStorage() && !ForAlignof) {
1870 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1884 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1885 if (LowBitOfOffset < FieldAlign)
1886 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1889 Align = std::min(Align, FieldAlign);
1897 const auto *VD = dyn_cast<VarDecl>(D);
1898 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1899 Align = std::min(Align, MaxAlignedAttr);
1919 if (
const auto *RD =
T->getAsCXXRecordDecl(); RD && !RD->
isInvalidDecl()) {
1936 (uint64_t)(-1)/Size) &&
1937 "Overflow in array type char size evaluation");
1940 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
1942 Width = llvm::alignTo(Width, Align);
1949 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
1967 switch (BT->getKind()) {
1968 case BuiltinType::Bool:
1969 case BuiltinType::Char_S:
1970 case BuiltinType::Char_U:
1971 case BuiltinType::SChar:
1972 case BuiltinType::UChar:
1973 case BuiltinType::Short:
1974 case BuiltinType::UShort:
1975 case BuiltinType::WChar_S:
1976 case BuiltinType::WChar_U:
1977 case BuiltinType::Char8:
1978 case BuiltinType::Char16:
1979 case BuiltinType::Char32:
1987 if (
const auto *ED =
T->getAsEnumDecl()) {
1988 if (
T->isDependentType() || ED->getPromotionType().isNull() ||
2007 bool NeedsPreferredAlignment)
const {
2010 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2015 if (!
T->isIncompleteType())
2021 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2025 if (
const auto *TD =
T->getAsTagDecl())
2026 return TD->getMaxAlignment();
2032 TypeInfoMap::iterator I = MemoizedTypeInfo.find(
T);
2033 if (I != MemoizedTypeInfo.end())
2038 MemoizedTypeInfo[
T] = TI;
2053 switch (
T->getTypeClass()) {
2054#define TYPE(Class, Base)
2055#define ABSTRACT_TYPE(Class, Base)
2056#define NON_CANONICAL_TYPE(Class, Base)
2057#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2058#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
2060 assert(!T->isDependentType() && "should not see dependent types here"); \
2061 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
2062#include "clang/AST/TypeNodes.inc"
2063 llvm_unreachable(
"Should not see dependent types");
2065 case Type::FunctionNoProto:
2066 case Type::FunctionProto:
2072 case Type::IncompleteArray:
2073 case Type::VariableArray:
2074 case Type::ConstantArray:
2075 case Type::ArrayParameter: {
2078 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2079 Size = CAT->getZExtSize();
2082 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2083 "Overflow in array type bit size evaluation");
2084 Width = EltInfo.
Width * Size;
2085 Align = EltInfo.
Align;
2089 Width = llvm::alignTo(Width, Align);
2093 case Type::ExtVector:
2094 case Type::Vector: {
2097 Width = VT->isPackedVectorBoolType(*
this)
2098 ? VT->getNumElements()
2099 : EltInfo.
Width * VT->getNumElements();
2101 Width = std::max<unsigned>(8, Width);
2102 Align = std::max<unsigned>(8, Width);
2106 if (Align & (Align-1)) {
2107 Align = llvm::bit_ceil(Align);
2108 Width = llvm::alignTo(Width, Align);
2111 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
2112 if (TargetVectorAlign && TargetVectorAlign < Align)
2113 Align = TargetVectorAlign;
2127 Align = std::min<unsigned>(64, Width);
2131 case Type::ConstantMatrix: {
2133 TypeInfo ElementInfo =
getTypeInfo(MT->getElementType());
2137 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2138 Align = ElementInfo.
Align;
2144 default: llvm_unreachable(
"Unknown builtin type!");
2145 case BuiltinType::Void:
2150 case BuiltinType::Bool:
2151 Width = Target->getBoolWidth();
2152 Align = Target->getBoolAlign();
2154 case BuiltinType::Char_S:
2155 case BuiltinType::Char_U:
2156 case BuiltinType::UChar:
2157 case BuiltinType::SChar:
2158 case BuiltinType::Char8:
2159 Width = Target->getCharWidth();
2160 Align = Target->getCharAlign();
2162 case BuiltinType::WChar_S:
2163 case BuiltinType::WChar_U:
2164 Width = Target->getWCharWidth();
2165 Align = Target->getWCharAlign();
2167 case BuiltinType::Char16:
2168 Width = Target->getChar16Width();
2169 Align = Target->getChar16Align();
2171 case BuiltinType::Char32:
2172 Width = Target->getChar32Width();
2173 Align = Target->getChar32Align();
2175 case BuiltinType::UShort:
2176 case BuiltinType::Short:
2177 Width = Target->getShortWidth();
2178 Align = Target->getShortAlign();
2180 case BuiltinType::UInt:
2181 case BuiltinType::Int:
2182 Width = Target->getIntWidth();
2183 Align = Target->getIntAlign();
2185 case BuiltinType::ULong:
2186 case BuiltinType::Long:
2187 Width = Target->getLongWidth();
2188 Align = Target->getLongAlign();
2190 case BuiltinType::ULongLong:
2191 case BuiltinType::LongLong:
2192 Width = Target->getLongLongWidth();
2193 Align = Target->getLongLongAlign();
2195 case BuiltinType::Int128:
2196 case BuiltinType::UInt128:
2198 Align = Target->getInt128Align();
2200 case BuiltinType::ShortAccum:
2201 case BuiltinType::UShortAccum:
2202 case BuiltinType::SatShortAccum:
2203 case BuiltinType::SatUShortAccum:
2204 Width = Target->getShortAccumWidth();
2205 Align = Target->getShortAccumAlign();
2207 case BuiltinType::Accum:
2208 case BuiltinType::UAccum:
2209 case BuiltinType::SatAccum:
2210 case BuiltinType::SatUAccum:
2211 Width = Target->getAccumWidth();
2212 Align = Target->getAccumAlign();
2214 case BuiltinType::LongAccum:
2215 case BuiltinType::ULongAccum:
2216 case BuiltinType::SatLongAccum:
2217 case BuiltinType::SatULongAccum:
2218 Width = Target->getLongAccumWidth();
2219 Align = Target->getLongAccumAlign();
2221 case BuiltinType::ShortFract:
2222 case BuiltinType::UShortFract:
2223 case BuiltinType::SatShortFract:
2224 case BuiltinType::SatUShortFract:
2225 Width = Target->getShortFractWidth();
2226 Align = Target->getShortFractAlign();
2228 case BuiltinType::Fract:
2229 case BuiltinType::UFract:
2230 case BuiltinType::SatFract:
2231 case BuiltinType::SatUFract:
2232 Width = Target->getFractWidth();
2233 Align = Target->getFractAlign();
2235 case BuiltinType::LongFract:
2236 case BuiltinType::ULongFract:
2237 case BuiltinType::SatLongFract:
2238 case BuiltinType::SatULongFract:
2239 Width = Target->getLongFractWidth();
2240 Align = Target->getLongFractAlign();
2242 case BuiltinType::BFloat16:
2243 if (Target->hasBFloat16Type()) {
2244 Width = Target->getBFloat16Width();
2245 Align = Target->getBFloat16Align();
2249 AuxTarget->hasBFloat16Type()) {
2250 Width = AuxTarget->getBFloat16Width();
2251 Align = AuxTarget->getBFloat16Align();
2254 case BuiltinType::Float16:
2255 case BuiltinType::Half:
2256 if (Target->hasFloat16Type() || !
getLangOpts().OpenMP ||
2258 Width = Target->getHalfWidth();
2259 Align = Target->getHalfAlign();
2262 "Expected OpenMP device compilation.");
2263 Width = AuxTarget->getHalfWidth();
2264 Align = AuxTarget->getHalfAlign();
2267 case BuiltinType::Float:
2268 Width = Target->getFloatWidth();
2269 Align = Target->getFloatAlign();
2271 case BuiltinType::Double:
2272 Width = Target->getDoubleWidth();
2273 Align = Target->getDoubleAlign();
2275 case BuiltinType::Ibm128:
2276 Width = Target->getIbm128Width();
2277 Align = Target->getIbm128Align();
2279 case BuiltinType::LongDouble:
2281 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2282 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2283 Width = AuxTarget->getLongDoubleWidth();
2284 Align = AuxTarget->getLongDoubleAlign();
2286 Width = Target->getLongDoubleWidth();
2287 Align = Target->getLongDoubleAlign();
2290 case BuiltinType::Float128:
2291 if (Target->hasFloat128Type() || !
getLangOpts().OpenMP ||
2293 Width = Target->getFloat128Width();
2294 Align = Target->getFloat128Align();
2297 "Expected OpenMP device compilation.");
2298 Width = AuxTarget->getFloat128Width();
2299 Align = AuxTarget->getFloat128Align();
2302 case BuiltinType::NullPtr:
2307 case BuiltinType::ObjCId:
2308 case BuiltinType::ObjCClass:
2309 case BuiltinType::ObjCSel:
2313 case BuiltinType::OCLSampler:
2314 case BuiltinType::OCLEvent:
2315 case BuiltinType::OCLClkEvent:
2316 case BuiltinType::OCLQueue:
2317 case BuiltinType::OCLReserveID:
2318#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2319 case BuiltinType::Id:
2320#include "clang/Basic/OpenCLImageTypes.def"
2321#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2322 case BuiltinType::Id:
2323#include "clang/Basic/OpenCLExtensionTypes.def"
2325 Width = Target->getPointerWidth(AS);
2326 Align = Target->getPointerAlign(AS);
2336#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2337 case BuiltinType::Id: \
2341#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2342 case BuiltinType::Id: \
2346#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2347 case BuiltinType::Id: \
2351#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2352 case BuiltinType::Id: \
2356#include "clang/Basic/AArch64ACLETypes.def"
2357#define PPC_VECTOR_TYPE(Name, Id, Size) \
2358 case BuiltinType::Id: \
2362#include "clang/Basic/PPCTypes.def"
2363#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2365 case BuiltinType::Id: \
2369#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2370 case BuiltinType::Id: \
2374#include "clang/Basic/RISCVVTypes.def"
2375#define WASM_TYPE(Name, Id, SingletonId) \
2376 case BuiltinType::Id: \
2380#include "clang/Basic/WebAssemblyReferenceTypes.def"
2381#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2382 case BuiltinType::ID: \
2386#include "clang/Basic/AMDGPUTypes.def"
2387#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2388#include "clang/Basic/HLSLIntangibleTypes.def"
2394 case Type::ObjCObjectPointer:
2398 case Type::BlockPointer:
2400 Width = Target->getPointerWidth(AS);
2401 Align = Target->getPointerAlign(AS);
2403 case Type::LValueReference:
2404 case Type::RValueReference:
2408 Width = Target->getPointerWidth(AS);
2409 Align = Target->getPointerAlign(AS);
2413 Width = Target->getPointerWidth(AS);
2414 Align = Target->getPointerAlign(AS);
2416 case Type::MemberPointer: {
2418 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2423 case Type::Complex: {
2427 Width = EltInfo.
Width * 2;
2428 Align = EltInfo.
Align;
2431 case Type::ObjCObject:
2433 case Type::Adjusted:
2436 case Type::ObjCInterface: {
2438 if (ObjCI->getDecl()->isInvalidDecl()) {
2448 case Type::BitInt: {
2450 Align = Target->getBitIntAlign(EIT->getNumBits());
2451 Width = Target->getBitIntWidth(EIT->getNumBits());
2457 const TagDecl *TD = TT->getOriginalDecl()->getDefinitionOrSelf();
2470 Info.
Align = AttrAlign;
2480 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2486 case Type::SubstTemplateTypeParm:
2488 getReplacementType().getTypePtr());
2491 case Type::DeducedTemplateSpecialization: {
2493 assert(!A->getDeducedType().isNull() &&
2494 "cannot request the size of an undeduced or dependent auto type");
2495 return getTypeInfo(A->getDeducedType().getTypePtr());
2501 case Type::MacroQualified:
2505 case Type::ObjCTypeParam:
2511 case Type::Typedef: {
2513 TypeInfo Info =
getTypeInfo(TT->desugar().getTypePtr());
2517 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2528 case Type::Attributed:
2532 case Type::CountAttributed:
2535 case Type::BTFTagAttributed:
2539 case Type::HLSLAttributedResource:
2543 case Type::HLSLInlineSpirv: {
2546 Width = ST->getSize() * 8;
2547 Align = ST->getAlignment();
2548 if (Width == 0 && Align == 0) {
2556 case Type::Atomic: {
2565 Width = Target->getCharWidth();
2567 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2573 Width = llvm::bit_ceil(Width);
2576 Align =
static_cast<unsigned>(Width);
2581 case Type::PredefinedSugar:
2590 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2591 return TypeInfo(Width, Align, AlignRequirement);
2595 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(
T);
2596 if (I != MemoizedUnadjustedAlign.end())
2599 unsigned UnadjustedAlign;
2600 if (
const auto *RT =
T->getAsCanonical<RecordType>()) {
2607 UnadjustedAlign =
getTypeAlign(
T->getUnqualifiedDesugaredType());
2610 MemoizedUnadjustedAlign[
T] = UnadjustedAlign;
2611 return UnadjustedAlign;
2615 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2665 unsigned ABIAlign = TI.
Align;
2667 T =
T->getBaseElementTypeUnsafe();
2670 if (
T->isMemberPointerType())
2673 if (!Target->allowsLargerPreferedTypeAlignment())
2676 if (
const auto *RD =
T->getAsRecordDecl()) {
2685 unsigned PreferredAlign =
static_cast<unsigned>(
2687 assert(PreferredAlign >= ABIAlign &&
2688 "PreferredAlign should be at least as large as ABIAlign.");
2689 return PreferredAlign;
2696 T = CT->getElementType().getTypePtr();
2697 if (
const auto *ED =
T->getAsEnumDecl())
2698 T = ED->getIntegerType().getTypePtr();
2699 if (
T->isSpecificBuiltinType(BuiltinType::Double) ||
2700 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2701 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2702 (
T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2703 Target->defaultsToAIXPowerAlignment()))
2758 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
2762 std::swap(
Base, Derived);
2782 llvm::append_range(Ivars, OI->
ivars());
2785 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2787 Ivars.push_back(Iv);
2795 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2798 for (
auto *Proto : OI->all_referenced_protocols()) {
2803 for (
const auto *Cat : OI->visible_categories())
2809 SD = SD->getSuperClass();
2811 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2812 for (
auto *Proto : OC->protocols()) {
2815 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2817 if (!Protocols.insert(
2821 for (
auto *Proto : OP->protocols())
2828 bool CheckIfTriviallyCopyable) {
2829 assert(RD->
isUnion() &&
"Must be union type");
2831 Context.getTypeSizeInChars(Context.getCanonicalTagType(RD));
2833 for (
const auto *Field : RD->
fields()) {
2834 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2835 CheckIfTriviallyCopyable))
2837 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2838 if (FieldSize != UnionSize)
2847 return Context.getFieldOffset(Field);
2856static std::optional<int64_t>
2858 const RecordDecl *RD,
2859 bool CheckIfTriviallyCopyable);
2861static std::optional<int64_t>
2863 bool CheckIfTriviallyCopyable) {
2864 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2867 CheckIfTriviallyCopyable);
2871 bool IsBitIntType = Field->getType()->isBitIntType();
2872 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2873 !Context.hasUniqueObjectRepresentations(Field->getType(),
2874 CheckIfTriviallyCopyable))
2875 return std::nullopt;
2877 int64_t FieldSizeInBits =
2878 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2879 if (Field->isBitField()) {
2882 if (Field->isUnnamedBitField())
2885 int64_t BitfieldSize = Field->getBitWidthValue();
2887 if ((
unsigned)BitfieldSize >
2889 return std::nullopt;
2890 }
else if (BitfieldSize > FieldSizeInBits) {
2891 return std::nullopt;
2893 FieldSizeInBits = BitfieldSize;
2894 }
else if (IsBitIntType && !Context.hasUniqueObjectRepresentations(
2895 Field->getType(), CheckIfTriviallyCopyable)) {
2896 return std::nullopt;
2898 return FieldSizeInBits;
2901static std::optional<int64_t>
2903 bool CheckIfTriviallyCopyable) {
2905 CheckIfTriviallyCopyable);
2908template <
typename RangeT>
2910 const RangeT &Subobjects, int64_t CurOffsetInBits,
2912 bool CheckIfTriviallyCopyable) {
2913 for (
const auto *Subobject : Subobjects) {
2914 std::optional<int64_t> SizeInBits =
2917 return std::nullopt;
2918 if (*SizeInBits != 0) {
2920 if (Offset != CurOffsetInBits)
2921 return std::nullopt;
2922 CurOffsetInBits += *SizeInBits;
2925 return CurOffsetInBits;
2928static std::optional<int64_t>
2931 bool CheckIfTriviallyCopyable) {
2932 assert(!RD->
isUnion() &&
"Must be struct/class type");
2933 const auto &Layout = Context.getASTRecordLayout(RD);
2935 int64_t CurOffsetInBits = 0;
2936 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
2937 if (ClassDecl->isDynamicClass())
2938 return std::nullopt;
2941 for (
const auto &
Base : ClassDecl->bases()) {
2944 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
2948 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
2951 std::optional<int64_t> OffsetAfterBases =
2953 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
2954 if (!OffsetAfterBases)
2955 return std::nullopt;
2956 CurOffsetInBits = *OffsetAfterBases;
2959 std::optional<int64_t> OffsetAfterFields =
2961 RD->
fields(), CurOffsetInBits, Context, Layout,
2962 CheckIfTriviallyCopyable);
2963 if (!OffsetAfterFields)
2964 return std::nullopt;
2965 CurOffsetInBits = *OffsetAfterFields;
2967 return CurOffsetInBits;
2971 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
2988 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
2993 CheckIfTriviallyCopyable);
2996 "hasUniqueObjectRepresentations should not be called with an "
3020 return !ABI->getMemberPointerInfo(MPT).HasPadding;
3023 if (
Record->isInvalidDecl())
3028 CheckIfTriviallyCopyable);
3031 *
this,
Record, CheckIfTriviallyCopyable);
3033 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
3054 count += Ext->ivar_size();
3059 count += ImplDecl->ivar_size();
3085 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3086 I = ObjCImpls.find(D);
3087 if (I != ObjCImpls.end())
3095 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3096 I = ObjCImpls.find(D);
3097 if (I != ObjCImpls.end())
3105 assert(IFaceD && ImplD &&
"Passed null params");
3106 ObjCImpls[IFaceD] = ImplD;
3112 assert(CatD && ImplD &&
"Passed null params");
3113 ObjCImpls[CatD] = ImplD;
3118 return ObjCMethodRedecls.
lookup(MD);
3124 ObjCMethodRedecls[MD] = Redecl;
3129 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3131 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3132 return CD->getClassInterface();
3133 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3134 return IMD->getClassInterface();
3142 assert(VD &&
"Passed null params");
3143 assert(VD->
hasAttr<BlocksAttr>() &&
3144 "getBlockVarCopyInits - not __block var");
3145 auto I = BlockVarCopyInits.find(VD);
3146 if (I != BlockVarCopyInits.end())
3148 return {
nullptr,
false};
3154 assert(VD && CopyExpr &&
"Passed null params");
3155 assert(VD->
hasAttr<BlocksAttr>() &&
3156 "setBlockVarCopyInits - not __block var");
3157 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3161 unsigned DataSize)
const {
3166 "incorrect data size provided to CreateTypeSourceInfo!");
3183 return getObjCLayout(D);
3188 bool &AnyNonCanonArgs) {
3190 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3196 bool AnyNonCanonArgs =
false;
3197 for (
auto &Arg : Args) {
3200 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3202 return AnyNonCanonArgs;
3210ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3215 llvm::FoldingSetNodeID ID;
3217 void *insertPos =
nullptr;
3218 if (
ExtQuals *eq = ExtQualNodes.FindNodeOrInsertPos(ID, insertPos)) {
3219 assert(eq->getQualifiers() == quals);
3228 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3231 (void) ExtQualNodes.FindNodeOrInsertPos(ID, insertPos);
3234 auto *eq =
new (*
this,
alignof(ExtQuals)) ExtQuals(baseType, canon, quals);
3235 ExtQualNodes.InsertNode(eq, insertPos);
3236 return QualType(eq, fastQuals);
3240 LangAS AddressSpace)
const {
3253 "Type cannot be in multiple addr spaces!");
3256 return getExtQualType(TypeNode, Quals);
3262 if (!
T.hasAddressSpace())
3266 const Type *TypeNode;
3269 if (
T.getTypePtr()->isArrayType()) {
3271 TypeNode =
T.getTypePtr();
3275 while (
T.hasAddressSpace()) {
3276 TypeNode = Quals.
strip(
T);
3280 if (!
QualType(TypeNode, 0).hasAddressSpace())
3284 T =
T.getSingleStepDesugaredType(*
this);
3294 return getExtQualType(TypeNode, Quals);
3302 "Attempted to get vtable pointer discriminator on a monomorphic type");
3305 llvm::raw_svector_ostream Out(Str);
3306 MC->mangleCXXVTable(RD, Out);
3307 return llvm::getPointerAuthStableSipHash(Str);
3333 switch (
T->getTypeClass()) {
3338 case Type::LValueReference:
3343 case Type::RValueReference:
3357 case Type::ObjCObjectPointer:
3358 case Type::BlockPointer:
3367 case Type::VariableArray:
3368 case Type::ConstantArray:
3369 case Type::IncompleteArray:
3370 case Type::ArrayParameter:
3383 case Type::ObjCInterface:
3384 case Type::ObjCObject:
3385 OS <<
"<objc_object>";
3394 QualType UnderlyingType =
T->castAsEnumDecl()->getIntegerType();
3396 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3399 case Type::FunctionNoProto:
3400 case Type::FunctionProto: {
3416 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3417 for (
QualType Param : FPT->param_types()) {
3421 if (FPT->isVariadic())
3428 case Type::MemberPointer: {
3432 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3436 case Type::ExtVector:
3444 case Type::ConstantMatrix:
3448 case Type::Builtin: {
3450 switch (BTy->getKind()) {
3451#define SIGNED_TYPE(Id, SingletonId) \
3452 case BuiltinType::Id: \
3455#define UNSIGNED_TYPE(Id, SingletonId) \
3456 case BuiltinType::Id: \
3459#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3460#define BUILTIN_TYPE(Id, SingletonId)
3461#include "clang/AST/BuiltinTypes.def"
3462 llvm_unreachable(
"placeholder types should not appear here.");
3464 case BuiltinType::Half:
3467 case BuiltinType::Float:
3470 case BuiltinType::Double:
3473 case BuiltinType::LongDouble:
3476 case BuiltinType::Float16:
3479 case BuiltinType::Float128:
3483 case BuiltinType::Void:
3487 case BuiltinType::ObjCId:
3488 case BuiltinType::ObjCClass:
3489 case BuiltinType::ObjCSel:
3490 case BuiltinType::NullPtr:
3495 case BuiltinType::OCLSampler:
3496 case BuiltinType::OCLEvent:
3497 case BuiltinType::OCLClkEvent:
3498 case BuiltinType::OCLQueue:
3499 case BuiltinType::OCLReserveID:
3500 case BuiltinType::BFloat16:
3501 case BuiltinType::VectorQuad:
3502 case BuiltinType::VectorPair:
3503 case BuiltinType::DMR1024:
3508 case BuiltinType::Ibm128:
3510#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3511 case BuiltinType::Id: \
3513#include "clang/Basic/OpenCLImageTypes.def"
3514#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3515 case BuiltinType::Id: \
3517#include "clang/Basic/OpenCLExtensionTypes.def"
3518#define SVE_TYPE(Name, Id, SingletonId) \
3519 case BuiltinType::Id: \
3521#include "clang/Basic/AArch64ACLETypes.def"
3522#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3523 case BuiltinType::Id: \
3525#include "clang/Basic/HLSLIntangibleTypes.def"
3526 case BuiltinType::Dependent:
3527 llvm_unreachable(
"should never get here");
3528#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3529#include "clang/Basic/AMDGPUTypes.def"
3530 case BuiltinType::WasmExternRef:
3531#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3532#include "clang/Basic/RISCVVTypes.def"
3533 llvm_unreachable(
"not yet implemented");
3535 llvm_unreachable(
"should never get here");
3537 case Type::Record: {
3538 const RecordDecl *RD =
T->castAsCanonical<RecordType>()->getOriginalDecl();
3558 II = Typedef->getDeclName().getAsIdentifierInfo();
3561 OS <<
"<anonymous_record>";
3567 case Type::HLSLAttributedResource:
3568 case Type::HLSLInlineSpirv:
3569 llvm_unreachable(
"should never get here");
3571 case Type::DeducedTemplateSpecialization:
3573#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3574#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3575#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3576#define ABSTRACT_TYPE(Class, Base)
3577#define TYPE(Class, Base)
3578#include "clang/AST/TypeNodes.inc"
3579 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3585 assert(!
T->isDependentType() &&
3586 "cannot compute type discriminator of a dependent type");
3589 llvm::raw_svector_ostream Out(Str);
3591 if (
T->isFunctionPointerType() ||
T->isFunctionReferenceType())
3592 T =
T->getPointeeType();
3594 if (
T->isFunctionType()) {
3597 T =
T.getUnqualifiedType();
3618 if (MPT->isMemberFunctionPointer()) {
3624 MPT->getMostRecentCXXRecordDecl());
3628 MC->mangleCanonicalTypeName(
T, Out);
3631 return llvm::getPointerAuthStableSipHash(Str);
3656 "Type cannot have multiple ObjCGCs!");
3659 return getExtQualType(TypeNode, Quals);
3673 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3677 llvm::FoldingSetNodeID ID;
3680 void *InsertPos =
nullptr;
3682 CountAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
3687 size_t Size = CountAttributedType::totalSizeToAlloc<TypeCoupledDeclRefInfo>(
3688 DependentDecls.size());
3691 OrNull, DependentDecls);
3692 Types.push_back(CATy);
3693 CountAttributedTypes.InsertNode(CATy, InsertPos);
3702 case Type::Attributed: {
3710 case Type::BTFTagAttributed: {
3711 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3720 case Type::Adjusted: {
3726 case Type::MacroQualified: {
3729 MQT->getMacroIdentifier());
3733 return Adjust(Orig);
3739 if (
T->getExtInfo() == Info)
3743 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(
T)) {
3763 FPT->getExtProtoInfo());
3778 L->DeducedReturnType(FD, ResultType);
3789 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3790 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3806 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
3829 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
3855 if (TSInfo->getType() != FD->
getType())
3863 "TypeLoc size mismatch from updating exception specification");
3864 TSInfo->overrideType(Updated);
3873 llvm::FoldingSetNodeID ID;
3876 void *InsertPos =
nullptr;
3877 if (
ComplexType *CT = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos))
3883 if (!
T.isCanonical()) {
3887 ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos);
3888 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3891 Types.push_back(
New);
3892 ComplexTypes.InsertNode(
New, InsertPos);
3901 llvm::FoldingSetNodeID ID;
3904 void *InsertPos =
nullptr;
3905 if (
PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos))
3911 if (!
T.isCanonical()) {
3915 PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos);
3916 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3919 Types.push_back(
New);
3920 PointerTypes.InsertNode(
New, InsertPos);
3925 llvm::FoldingSetNodeID ID;
3927 void *InsertPos =
nullptr;
3928 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3935 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3936 assert(!AT &&
"Shouldn't be in the map!");
3940 Types.push_back(AT);
3941 AdjustedTypes.InsertNode(AT, InsertPos);
3946 llvm::FoldingSetNodeID ID;
3948 void *InsertPos =
nullptr;
3949 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3956 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3957 assert(!AT &&
"Shouldn't be in the map!");
3960 Types.push_back(AT);
3961 AdjustedTypes.InsertNode(AT, InsertPos);
3966 assert((
T->isArrayType() ||
T->isFunctionType()) &&
"T does not decay");
3975 if (
T->isArrayType())
3982 if (
T->isFunctionType())
3994 llvm::FoldingSetNodeID ID;
3995 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
3996 ATy->getSizeExpr(), ATy->getSizeModifier(),
3997 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
3998 void *InsertPos =
nullptr;
4000 ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
4009 AT = ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
4010 assert(!AT &&
"Shouldn't be in the map!");
4015 Types.push_back(AT);
4016 ArrayParameterTypes.InsertNode(AT, InsertPos);
4023 assert(
T->isFunctionType() &&
"block of function types only");
4026 llvm::FoldingSetNodeID ID;
4029 void *InsertPos =
nullptr;
4031 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4037 if (!
T.isCanonical()) {
4042 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4043 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4047 Types.push_back(
New);
4048 BlockPointerTypes.InsertNode(
New, InsertPos);
4056 assert((!
T->isPlaceholderType() ||
4057 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4058 "Unresolved placeholder type");
4062 llvm::FoldingSetNodeID ID;
4065 void *InsertPos =
nullptr;
4067 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4075 if (!SpelledAsLValue || InnerRef || !
T.isCanonical()) {
4076 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4081 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4082 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4087 Types.push_back(
New);
4088 LValueReferenceTypes.InsertNode(
New, InsertPos);
4096 assert((!
T->isPlaceholderType() ||
4097 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4098 "Unresolved placeholder type");
4102 llvm::FoldingSetNodeID ID;
4105 void *InsertPos =
nullptr;
4107 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4115 if (InnerRef || !
T.isCanonical()) {
4116 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4121 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4122 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4127 Types.push_back(
New);
4128 RValueReferenceTypes.InsertNode(
New, InsertPos);
4136 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4139 Cls = Qualifier.getAsRecordDecl();
4143 llvm::FoldingSetNodeID ID;
4146 void *InsertPos =
nullptr;
4148 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4153 return Qualifier.getCanonical();
4161 if (!
T.isCanonical() || Qualifier != CanonicalQualifier) {
4167 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4168 assert(!NewIP &&
"Shouldn't be in the map!");
4172 Types.push_back(
New);
4173 MemberPointerTypes.InsertNode(
New, InsertPos);
4180 const llvm::APInt &ArySizeIn,
4181 const Expr *SizeExpr,
4183 unsigned IndexTypeQuals)
const {
4186 "Constant array of VLAs is illegal!");
4194 llvm::APInt ArySize(ArySizeIn);
4195 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
4197 llvm::FoldingSetNodeID ID;
4199 ASM, IndexTypeQuals);
4201 void *InsertPos =
nullptr;
4203 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
4214 ASM, IndexTypeQuals);
4219 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
4220 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4223 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4224 ASM, IndexTypeQuals);
4225 ConstantArrayTypes.InsertNode(
New, InsertPos);
4226 Types.push_back(
New);
4235 if (!
type->isVariablyModifiedType())
return type;
4240 const Type *ty = split.
Ty;
4242#define TYPE(Class, Base)
4243#define ABSTRACT_TYPE(Class, Base)
4244#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4245#include "clang/AST/TypeNodes.inc"
4246 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4252 case Type::DependentVector:
4253 case Type::ExtVector:
4254 case Type::DependentSizedExtVector:
4255 case Type::ConstantMatrix:
4256 case Type::DependentSizedMatrix:
4257 case Type::DependentAddressSpace:
4258 case Type::ObjCObject:
4259 case Type::ObjCInterface:
4260 case Type::ObjCObjectPointer:
4263 case Type::UnresolvedUsing:
4264 case Type::TypeOfExpr:
4266 case Type::Decltype:
4267 case Type::UnaryTransform:
4268 case Type::DependentName:
4269 case Type::InjectedClassName:
4270 case Type::TemplateSpecialization:
4271 case Type::TemplateTypeParm:
4272 case Type::SubstTemplateTypeParmPack:
4273 case Type::SubstBuiltinTemplatePack:
4275 case Type::DeducedTemplateSpecialization:
4276 case Type::PackExpansion:
4277 case Type::PackIndexing:
4279 case Type::DependentBitInt:
4280 case Type::ArrayParameter:
4281 case Type::HLSLAttributedResource:
4282 case Type::HLSLInlineSpirv:
4283 llvm_unreachable(
"type should never be variably-modified");
4287 case Type::FunctionNoProto:
4288 case Type::FunctionProto:
4289 case Type::BlockPointer:
4290 case Type::MemberPointer:
4303 case Type::LValueReference: {
4307 lv->isSpelledAsLValue());
4311 case Type::RValueReference: {
4318 case Type::Atomic: {
4324 case Type::ConstantArray: {
4330 cat->getSizeModifier(),
4331 cat->getIndexTypeCVRQualifiers());
4335 case Type::DependentSizedArray: {
4339 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4344 case Type::IncompleteArray: {
4349 iat->getIndexTypeCVRQualifiers());
4354 case Type::VariableArray: {
4359 vat->getIndexTypeCVRQualifiers());
4372 unsigned IndexTypeQuals)
const {
4389 VariableArrayTypes.push_back(
New);
4390 Types.push_back(
New);
4400 unsigned elementTypeQuals)
const {
4403 "Size must be type- or value-dependent!");
4407 void *insertPos =
nullptr;
4408 llvm::FoldingSetNodeID ID;
4410 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4411 ASM, elementTypeQuals, numElements);
4415 DependentSizedArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4427 DependentSizedArrayTypes.InsertNode(newType, insertPos);
4428 Types.push_back(newType);
4436 numElements, ASM, elementTypeQuals);
4437 DependentSizedArrayTypes.InsertNode(canonTy, insertPos);
4438 Types.push_back(canonTy);
4443 canonElementType.
Quals);
4447 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4456 Types.push_back(sugaredType);
4462 unsigned elementTypeQuals)
const {
4463 llvm::FoldingSetNodeID ID;
4466 void *insertPos =
nullptr;
4468 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos))
4480 ASM, elementTypeQuals);
4485 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4486 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4492 IncompleteArrayTypes.InsertNode(newType, insertPos);
4493 Types.push_back(newType);
4499#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4500 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4503#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4504 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4508 llvm_unreachable(
"Unsupported builtin vector type");
4510#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4511 ElBits, NF, IsSigned) \
4512 case BuiltinType::Id: \
4513 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4514 llvm::ElementCount::getScalable(NumEls), NF};
4515#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4517 case BuiltinType::Id: \
4518 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4519 llvm::ElementCount::getScalable(NumEls), NF};
4520#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4522 case BuiltinType::Id: \
4523 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4524#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4526 case BuiltinType::Id: \
4527 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4528#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4529 case BuiltinType::Id: \
4530 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4531#include "clang/Basic/AArch64ACLETypes.def"
4533#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4535 case BuiltinType::Id: \
4536 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4537 llvm::ElementCount::getScalable(NumEls), NF};
4538#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4539 case BuiltinType::Id: \
4540 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4541 llvm::ElementCount::getScalable(NumEls), NF};
4542#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4543 case BuiltinType::Id: \
4544 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4545#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4546 case BuiltinType::Id: \
4547 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4548#include "clang/Basic/RISCVVTypes.def"
4555 if (Target->getTriple().isWasm() && Target->hasFeature(
"reference-types")) {
4556#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4557 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4559#include "clang/Basic/WebAssemblyReferenceTypes.def"
4562 "shouldn't try to generate type externref outside WebAssembly target");
4569 unsigned NumFields)
const {
4571 if (
auto It = ScalableVecTyMap.find(K); It != ScalableVecTyMap.end())
4574 if (Target->hasAArch64ACLETypes()) {
4577#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4578 ElBits, NF, IsSigned) \
4579 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4580 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4581 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4582 return ScalableVecTyMap[K] = SingletonId; \
4584#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4586 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4587 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4588 return ScalableVecTyMap[K] = SingletonId; \
4590#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4592 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4593 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4594 return ScalableVecTyMap[K] = SingletonId; \
4596#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4598 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4599 NumElts == (NumEls * NF) && NumFields == 1) { \
4600 return ScalableVecTyMap[K] = SingletonId; \
4602#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4603 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4604 return ScalableVecTyMap[K] = SingletonId;
4605#include "clang/Basic/AArch64ACLETypes.def"
4606 }
else if (Target->hasRISCVVTypes()) {
4608#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4610 if (!EltTy->isBooleanType() && \
4611 ((EltTy->hasIntegerRepresentation() && \
4612 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4613 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4615 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4616 IsBF && !IsFP)) && \
4617 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4618 return ScalableVecTyMap[K] = SingletonId;
4619#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4620 if (EltTy->isBooleanType() && NumElts == NumEls) \
4621 return ScalableVecTyMap[K] = SingletonId;
4622#include "clang/Basic/RISCVVTypes.def"
4637 llvm::FoldingSetNodeID ID;
4640 void *InsertPos =
nullptr;
4641 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4651 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4652 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4655 VectorType(vecType, NumElts, Canonical, VecKind);
4656 VectorTypes.InsertNode(
New, InsertPos);
4657 Types.push_back(
New);
4664 llvm::FoldingSetNodeID ID;
4667 void *InsertPos =
nullptr;
4669 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4674 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4677 if (CanonVecTy == VecType) {
4682 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4683 assert(!CanonCheck &&
4684 "Dependent-sized vector_size canonical type broken");
4686 DependentVectorTypes.InsertNode(
New, InsertPos);
4695 Types.push_back(
New);
4702 unsigned NumElts)
const {
4709 llvm::FoldingSetNodeID ID;
4712 void *InsertPos =
nullptr;
4713 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4723 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4724 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4728 VectorTypes.InsertNode(
New, InsertPos);
4729 Types.push_back(
New);
4737 llvm::FoldingSetNodeID ID;
4741 void *InsertPos =
nullptr;
4743 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4753 if (CanonVecTy == vecType) {
4758 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4759 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4761 DependentSizedExtVectorTypes.InsertNode(
New, InsertPos);
4770 Types.push_back(
New);
4775 unsigned NumColumns)
const {
4776 llvm::FoldingSetNodeID ID;
4778 Type::ConstantMatrix);
4781 "need a valid element type");
4784 "need valid matrix dimensions");
4785 void *InsertPos =
nullptr;
4795 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4801 MatrixTypes.InsertNode(
New, InsertPos);
4802 Types.push_back(
New);
4811 llvm::FoldingSetNodeID ID;
4815 void *InsertPos =
nullptr;
4817 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4822 ColumnExpr, AttrLoc);
4825 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4826 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4828 DependentSizedMatrixTypes.InsertNode(Canon, InsertPos);
4829 Types.push_back(Canon);
4842 ColumnExpr, AttrLoc);
4843 Types.push_back(
New);
4848 Expr *AddrSpaceExpr,
4854 void *insertPos =
nullptr;
4855 llvm::FoldingSetNodeID ID;
4860 DependentAddressSpaceTypes.FindNodeOrInsertPos(ID, insertPos);
4866 DependentAddressSpaceTypes.InsertNode(canonTy, insertPos);
4867 Types.push_back(canonTy);
4870 if (canonPointeeType == PointeeType &&
4876 AddrSpaceExpr, AttrLoc);
4877 Types.push_back(sugaredType);
4883 return T.isCanonical() &&
4901 llvm::FoldingSetNodeID ID;
4904 void *InsertPos =
nullptr;
4906 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
4916 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
4917 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4922 Types.push_back(
New);
4923 FunctionNoProtoTypes.InsertNode(
New, InsertPos);
4939 return CanResultType;
4946 if (!NoexceptInType)
4963 bool AnyPackExpansions =
false;
4967 if (ET->
getAs<PackExpansionType>())
4968 AnyPackExpansions =
true;
4970 return AnyPackExpansions;
4976QualType ASTContext::getFunctionTypeInternal(
4977 QualType ResultTy, ArrayRef<QualType> ArgArray,
4978 const FunctionProtoType::ExtProtoInfo &EPI,
bool OnlyWantCanonical)
const {
4979 size_t NumArgs = ArgArray.size();
4983 llvm::FoldingSetNodeID
ID;
4988 bool Unique =
false;
4990 void *InsertPos =
nullptr;
4991 if (FunctionProtoType *FPT =
4992 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos)) {
4993 QualType Existing = QualType(FPT, 0);
5012 bool IsCanonicalExceptionSpec =
5016 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
5018 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
5019 if (!ArgArray[i].isCanonicalAsParam())
5020 isCanonical =
false;
5022 if (OnlyWantCanonical)
5023 assert(isCanonical &&
5024 "given non-canonical parameters constructing canonical type");
5029 if (!isCanonical && Canonical.
isNull()) {
5030 SmallVector<QualType, 16> CanonicalArgs;
5031 CanonicalArgs.reserve(NumArgs);
5032 for (
unsigned i = 0; i != NumArgs; ++i)
5035 llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
5036 FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
5039 if (IsCanonicalExceptionSpec) {
5041 }
else if (NoexceptInType) {
5054 bool AnyPacks =
false;
5056 if (ET->
getAs<PackExpansionType>())
5077 llvm_unreachable(
"dependent noexcept is already canonical");
5080 CanonicalEPI.
ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
5086 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5089 FunctionProtoType *NewIP =
5090 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
5091 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5096 auto ESH = FunctionProtoType::getExceptionSpecSize(
5098 size_t Size = FunctionProtoType::totalSizeToAlloc<
5099 QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
5100 FunctionType::FunctionTypeExtraAttributeInfo,
5101 FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
5102 Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, Qualifiers,
5103 FunctionEffect, EffectConditionExpr>(
5107 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5112 auto *FTP = (FunctionProtoType *)
Allocate(Size,
alignof(FunctionProtoType));
5113 FunctionProtoType::ExtProtoInfo newEPI = EPI;
5114 new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
5115 Types.push_back(FTP);
5117 FunctionProtoTypes.InsertNode(FTP, InsertPos);
5119 AnyFunctionEffects =
true;
5120 return QualType(FTP, 0);
5123QualType ASTContext::getPipeType(QualType
T,
bool ReadOnly)
const {
5124 llvm::FoldingSetNodeID
ID;
5127 void *InsertPos =
nullptr;
5128 if (PipeType *PT = PipeTypes.FindNodeOrInsertPos(ID, InsertPos))
5129 return QualType(PT, 0);
5134 if (!
T.isCanonical()) {
5138 PipeType *NewIP = PipeTypes.FindNodeOrInsertPos(ID, InsertPos);
5139 assert(!NewIP &&
"Shouldn't be in the map!");
5142 auto *
New =
new (*
this,
alignof(PipeType)) PipeType(
T, Canonical, ReadOnly);
5143 Types.push_back(
New);
5144 PipeTypes.InsertNode(
New, InsertPos);
5145 return QualType(
New, 0);
5155 return getPipeType(
T,
true);
5159 return getPipeType(
T,
false);
5163 llvm::FoldingSetNodeID ID;
5166 void *InsertPos =
nullptr;
5167 if (
BitIntType *EIT = BitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5171 BitIntTypes.InsertNode(
New, InsertPos);
5172 Types.push_back(
New);
5177 Expr *NumBitsExpr)
const {
5179 llvm::FoldingSetNodeID ID;
5182 void *InsertPos =
nullptr;
5184 DependentBitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5189 DependentBitIntTypes.InsertNode(
New, InsertPos);
5191 Types.push_back(
New);
5199 if (
auto *Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5211 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5212 case Kind::SignedSizeT:
5214 case Kind::PtrdiffT:
5217 llvm_unreachable(
"unexpected kind");
5222 Types.push_back(
New);
5223 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5230 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5233 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5235 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5244 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5246 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5248 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5250 assert(TD->TypeForDecl);
5255 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5257 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5258 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5261 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5264 assert(
Decl->TypeForDecl);
5274 std::optional<bool> TypeMatchesDeclOrNone)
const {
5275 if (!TypeMatchesDeclOrNone) {
5276 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5277 assert(!DeclUnderlyingType.
isNull());
5278 if (UnderlyingType.
isNull())
5279 UnderlyingType = DeclUnderlyingType;
5281 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5282 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5286 assert(!UnderlyingType.
isNull());
5290 *TypeMatchesDeclOrNone) {
5291 if (
Decl->TypeForDecl)
5296 !*TypeMatchesDeclOrNone);
5298 Types.push_back(NewType);
5299 Decl->TypeForDecl = NewType;
5303 llvm::FoldingSetNodeID ID;
5305 *TypeMatchesDeclOrNone ?
QualType() : UnderlyingType);
5307 void *InsertPos =
nullptr;
5309 TypedefTypes.FindNodeOrInsertPos(ID, InsertPos))
5310 return QualType(Placeholder->getType(), 0);
5315 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5319 UnderlyingType, !*TypeMatchesDeclOrNone);
5320 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5322 TypedefTypes.InsertNode(Placeholder, InsertPos);
5323 Types.push_back(NewType);
5332 if (UnderlyingType.
isNull()) {
5340 llvm::FoldingSetNodeID ID;
5343 void *InsertPos =
nullptr;
5344 if (
const UsingType *
T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5354 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5358 UsingTypes.InsertNode(
T, InsertPos);
5364 const TagDecl *TD,
bool OwnsTag,
5366 const Type *CanonicalType,
5367 bool WithFoldingSetNode)
const {
5368 auto [TC, Size] = [&] {
5371 static_assert(
alignof(EnumType) ==
alignof(TagType));
5372 return std::make_tuple(Type::Enum,
sizeof(EnumType));
5373 case Decl::ClassTemplatePartialSpecialization:
5374 case Decl::ClassTemplateSpecialization:
5375 case Decl::CXXRecord:
5376 static_assert(
alignof(RecordType) ==
alignof(TagType));
5377 static_assert(
alignof(InjectedClassNameType) ==
alignof(TagType));
5379 return std::make_tuple(Type::InjectedClassName,
5380 sizeof(InjectedClassNameType));
5383 return std::make_tuple(Type::Record,
sizeof(RecordType));
5385 llvm_unreachable(
"unexpected decl kind");
5395 if (WithFoldingSetNode) {
5403 sizeof(TagTypeFoldingSetPlaceholder) +
5404 TagTypeFoldingSetPlaceholder::getOffset() + Size,
5405 std::max(
alignof(TagTypeFoldingSetPlaceholder),
alignof(TagType)));
5406 auto *
T =
new (Mem) TagTypeFoldingSetPlaceholder();
5407 Mem =
T->getTagType();
5409 Mem =
Allocate(Size,
alignof(TagType));
5412 auto *
T = [&, TC = TC]() -> TagType * {
5416 auto *
T =
new (Mem) EnumType(TC,
Keyword, Qualifier, TD, OwnsTag,
5417 IsInjected, CanonicalType);
5418 assert(
reinterpret_cast<void *
>(
T) ==
5419 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5420 "TagType must be the first base of EnumType");
5423 case Type::Record: {
5425 auto *
T =
new (Mem) RecordType(TC,
Keyword, Qualifier, TD, OwnsTag,
5426 IsInjected, CanonicalType);
5427 assert(
reinterpret_cast<void *
>(
T) ==
5428 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5429 "TagType must be the first base of RecordType");
5432 case Type::InjectedClassName: {
5433 auto *
T =
new (Mem) InjectedClassNameType(
Keyword, Qualifier, TD,
5434 IsInjected, CanonicalType);
5435 assert(
reinterpret_cast<void *
>(
T) ==
5436 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5437 "TagType must be the first base of InjectedClassNameType");
5441 llvm_unreachable(
"unexpected type class");
5444 assert(
T->getKeyword() ==
Keyword);
5445 assert(
T->getQualifier() == Qualifier);
5446 assert(
T->getOriginalDecl() == TD);
5447 assert(
T->isInjected() == IsInjected);
5448 assert(
T->isTagOwned() == OwnsTag);
5457 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5458 RD && RD->isInjectedClassName())
5465 if (TD->TypeForDecl)
5466 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5468 const Type *CanonicalType = getTagTypeInternal(
5471 false,
false,
nullptr,
5473 TD->TypeForDecl = CanonicalType;
5479 const TagDecl *TD,
bool OwnsTag)
const {
5482 bool IsInjected = TD != NonInjectedTD;
5489 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5490 if (
const Type *
T = TD->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5496 std::nullopt, NonInjectedTD,
5497 false, IsInjected, CanonicalType,
5499 TD->TypeForDecl =
T;
5503 llvm::FoldingSetNodeID ID;
5504 TagTypeFoldingSetPlaceholder::Profile(ID,
Keyword, Qualifier, NonInjectedTD,
5505 OwnsTag, IsInjected);
5507 void *InsertPos =
nullptr;
5508 if (TagTypeFoldingSetPlaceholder *
T =
5509 TagTypes.FindNodeOrInsertPos(ID, InsertPos))
5514 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5515 CanonicalType,
true);
5516 TagTypes.InsertNode(TagTypeFoldingSetPlaceholder::fromTagType(
T), InsertPos);
5521 unsigned NumPositiveBits,
5524 unsigned IntWidth = Target->getIntWidth();
5525 unsigned CharWidth = Target->getCharWidth();
5526 unsigned ShortWidth = Target->getShortWidth();
5527 bool EnumTooLarge =
false;
5529 if (NumNegativeBits) {
5533 if (IsPacked && NumNegativeBits <= CharWidth &&
5534 NumPositiveBits < CharWidth) {
5536 BestWidth = CharWidth;
5537 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5538 NumPositiveBits < ShortWidth) {
5540 BestWidth = ShortWidth;
5541 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5543 BestWidth = IntWidth;
5545 BestWidth = Target->getLongWidth();
5547 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5550 BestWidth = Target->getLongLongWidth();
5552 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5553 EnumTooLarge =
true;
5557 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5562 if (IsPacked && NumPositiveBits <= CharWidth) {
5564 BestPromotionType =
IntTy;
5565 BestWidth = CharWidth;
5566 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5568 BestPromotionType =
IntTy;
5569 BestWidth = ShortWidth;
5570 }
else if (NumPositiveBits <= IntWidth) {
5572 BestWidth = IntWidth;
5573 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5576 }
else if (NumPositiveBits <= (BestWidth = Target->getLongWidth())) {
5578 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5582 BestWidth = Target->getLongLongWidth();
5583 if (NumPositiveBits > BestWidth) {
5588 EnumTooLarge =
true;
5591 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5596 return EnumTooLarge;
5600 assert((
T->isIntegralType(*
this) ||
T->isEnumeralType()) &&
5601 "Integral type required!");
5604 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5605 if (
T->isSignedIntegerOrEnumerationType())
5607 return Value.getActiveBits() <= BitWidth;
5609 return Value.getSignificantBits() <= BitWidth;
5615 const Type *CanonicalType)
const {
5617 UnresolvedUsingType::totalSizeToAlloc<
5619 !!InsertPos, !!Qualifier),
5623 auto *Placeholder =
new (
T->getFoldingSetPlaceholder())
5625 TypedefTypes.InsertNode(Placeholder, InsertPos);
5635 return D->TypeForDecl->getCanonicalTypeUnqualified();
5637 const Type *CanonicalType = getUnresolvedUsingTypeInternal(
5641 D->TypeForDecl = CanonicalType;
5650 if (
const Type *
T = D->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5657 nullptr, CanonicalType);
5662 llvm::FoldingSetNodeID ID;
5665 void *InsertPos =
nullptr;
5667 UnresolvedUsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5668 return QualType(Placeholder->getType(), 0);
5672 const Type *
T = getUnresolvedUsingTypeInternal(
Keyword, Qualifier, D,
5673 InsertPos, CanonicalType);
5681 llvm::FoldingSetNodeID id;
5682 AttributedType::Profile(
id, attrKind, modifiedType, equivalentType,
attr);
5684 void *insertPos =
nullptr;
5685 AttributedType *
type = AttributedTypes.FindNodeOrInsertPos(
id, insertPos);
5688 assert(!
attr ||
attr->getKind() == attrKind);
5691 type =
new (*
this,
alignof(AttributedType))
5692 AttributedType(canon, attrKind,
attr, modifiedType, equivalentType);
5694 Types.push_back(
type);
5695 AttributedTypes.InsertNode(
type, insertPos);
5708 switch (nullability) {
5724 llvm_unreachable(
"Unknown nullability kind");
5729 llvm::FoldingSetNodeID ID;
5730 BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
5732 void *InsertPos =
nullptr;
5733 BTFTagAttributedType *Ty =
5734 BTFTagAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
5739 Ty =
new (*
this,
alignof(BTFTagAttributedType))
5740 BTFTagAttributedType(Canon, Wrapped, BTFAttr);
5742 Types.push_back(Ty);
5743 BTFTagAttributedTypes.InsertNode(Ty, InsertPos);
5750 const HLSLAttributedResourceType::Attributes &Attrs) {
5752 llvm::FoldingSetNodeID ID;
5753 HLSLAttributedResourceType::Profile(ID, Wrapped, Contained, Attrs);
5755 void *InsertPos =
nullptr;
5756 HLSLAttributedResourceType *Ty =
5757 HLSLAttributedResourceTypes.FindNodeOrInsertPos(ID, InsertPos);
5761 Ty =
new (*
this,
alignof(HLSLAttributedResourceType))
5762 HLSLAttributedResourceType(Wrapped, Contained, Attrs);
5764 Types.push_back(Ty);
5765 HLSLAttributedResourceTypes.InsertNode(Ty, InsertPos);
5773 llvm::FoldingSetNodeID ID;
5774 HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
5776 void *InsertPos =
nullptr;
5777 HLSLInlineSpirvType *Ty =
5778 HLSLInlineSpirvTypes.FindNodeOrInsertPos(ID, InsertPos);
5783 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5784 alignof(HLSLInlineSpirvType));
5786 Ty =
new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
5788 Types.push_back(Ty);
5789 HLSLInlineSpirvTypes.InsertNode(Ty, InsertPos);
5796 Decl *AssociatedDecl,
5800 llvm::FoldingSetNodeID ID;
5801 SubstTemplateTypeParmType::Profile(ID, Replacement, AssociatedDecl, Index,
5803 void *InsertPos =
nullptr;
5804 SubstTemplateTypeParmType *SubstParm =
5805 SubstTemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5808 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5809 !Replacement.isCanonical()),
5810 alignof(SubstTemplateTypeParmType));
5811 SubstParm =
new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
5812 Index, PackIndex, Final);
5813 Types.push_back(SubstParm);
5814 SubstTemplateTypeParmTypes.InsertNode(SubstParm, InsertPos);
5822 unsigned Index,
bool Final,
5829 llvm::FoldingSetNodeID ID;
5830 SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
5832 void *InsertPos =
nullptr;
5833 if (SubstTemplateTypeParmPackType *SubstParm =
5834 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos))
5844 [[maybe_unused]]
const auto *Nothing =
5845 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos);
5850 auto *SubstParm =
new (*
this,
alignof(SubstTemplateTypeParmPackType))
5851 SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
5853 Types.push_back(SubstParm);
5854 SubstTemplateTypeParmPackTypes.InsertNode(SubstParm, InsertPos);
5862 return P.getKind() == TemplateArgument::Type;
5864 "Pack contains a non-type");
5866 llvm::FoldingSetNodeID ID;
5867 SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
5869 void *InsertPos =
nullptr;
5871 SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos))
5879 auto *PackType =
new (*
this,
alignof(SubstBuiltinTemplatePackType))
5880 SubstBuiltinTemplatePackType(Canon, ArgPack);
5881 Types.push_back(PackType);
5882 SubstBuiltinTemplatePackTypes.InsertNode(PackType, InsertPos);
5892 llvm::FoldingSetNodeID ID;
5893 TemplateTypeParmType::Profile(ID, Depth, Index, ParameterPack, TTPDecl);
5894 void *InsertPos =
nullptr;
5895 TemplateTypeParmType *TypeParm
5896 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5903 TypeParm =
new (*
this,
alignof(TemplateTypeParmType))
5904 TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
5906 TemplateTypeParmType *TypeCheck
5907 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5908 assert(!TypeCheck &&
"Template type parameter canonical type broken");
5911 TypeParm =
new (*
this,
alignof(TemplateTypeParmType)) TemplateTypeParmType(
5912 Depth, Index, ParameterPack,
nullptr,
QualType());
5914 Types.push_back(TypeParm);
5915 TemplateTypeParmTypes.InsertNode(TypeParm, InsertPos);
5941 llvm_unreachable(
"unexpected keyword kind");
5955 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
5965 SpecifiedArgVec.reserve(SpecifiedArgs.size());
5967 SpecifiedArgVec.push_back(Arg.getArgument());
5970 CanonicalArgs, Underlying);
5973[[maybe_unused]]
static bool
5976 if (Arg.isPackExpansion())
5987 Template.getAsDependentTemplateName()));
5989 for (
const auto &Arg : Args)
5993 llvm::FoldingSetNodeID ID;
5996 void *InsertPos =
nullptr;
5997 if (
auto *
T = TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
6000 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6002 alignof(TemplateSpecializationType));
6006 assert(Spec->isDependentType() &&
6007 "canonical template specialization must be dependent");
6008 Types.push_back(Spec);
6009 TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
6017 const auto *TD =
Template.getAsTemplateDecl(
true);
6018 bool IsTypeAlias = TD && TD->isTypeAlias();
6019 if (Underlying.
isNull()) {
6026 bool NonCanonical =
Template != CanonTemplate ||
Keyword != CanonKeyword;
6028 if (CanonicalArgs.empty()) {
6031 CanonicalArgs = CanonArgsVec;
6033 NonCanonical |= !llvm::equal(
6034 SpecifiedArgs, CanonicalArgs,
6043 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
6045 "Caller must compute aliased type");
6046 IsTypeAlias =
false;
6049 CanonKeyword, CanonTemplate, CanonicalArgs);
6053 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6055 (IsTypeAlias ?
sizeof(
QualType) : 0),
6056 alignof(TemplateSpecializationType));
6057 auto *Spec =
new (Mem) TemplateSpecializationType(
6059 Types.push_back(Spec);
6065 llvm::FoldingSetNodeID ID;
6068 void *InsertPos =
nullptr;
6069 ParenType *
T = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6076 ParenType *CheckT = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6077 assert(!CheckT &&
"Paren canonical type broken");
6083 ParenTypes.InsertNode(
T, InsertPos);
6096 Types.push_back(newType);
6103 llvm::FoldingSetNodeID ID;
6104 DependentNameType::Profile(ID,
Keyword, NNS, Name);
6106 void *InsertPos =
nullptr;
6107 if (DependentNameType *
T =
6108 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos))
6116 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6118 [[maybe_unused]] DependentNameType *
T =
6119 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos);
6120 assert(!
T &&
"broken canonicalization");
6124 DependentNameType *
T =
new (*
this,
alignof(DependentNameType))
6125 DependentNameType(
Keyword, NNS, Name, Canon);
6127 DependentNameTypes.InsertNode(
T, InsertPos);
6133 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6135 if (TTP->isParameterPack())
6139 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6141 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6147 if (
T->isRecordType()) {
6156 Expr *E =
new (*this)
6158 T,
VK, NTTP->getLocation());
6160 if (NTTP->isParameterPack())
6166 std::nullopt,
false,
6168 if (TTP->isParameterPack())
6174 if (Param->isTemplateParameterPack())
6183 bool ExpectPackInType)
const {
6185 "Pack expansions must expand one or more parameter packs");
6187 llvm::FoldingSetNodeID ID;
6188 PackExpansionType::Profile(ID, Pattern, NumExpansions);
6190 void *InsertPos =
nullptr;
6191 PackExpansionType *
T = PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
6202 PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
6205 T =
new (*
this,
alignof(PackExpansionType))
6206 PackExpansionType(Pattern, Canon, NumExpansions);
6208 PackExpansionTypes.InsertNode(
T, InsertPos);
6220 if (Protocols.empty())
return true;
6225 for (
unsigned i = 1; i != Protocols.size(); ++i)
6235 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6239 P = P->getCanonicalDecl();
6242 auto ProtocolsEnd = llvm::unique(Protocols);
6243 Protocols.erase(ProtocolsEnd, Protocols.end());
6248 unsigned NumProtocols)
const {
6257 bool isKindOf)
const {
6260 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6265 llvm::FoldingSetNodeID ID;
6266 ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
6267 void *InsertPos =
nullptr;
6268 if (
ObjCObjectType *QT = ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos))
6275 if (effectiveTypeArgs.empty()) {
6277 effectiveTypeArgs = baseObject->getTypeArgs();
6284 bool typeArgsAreCanonical = llvm::all_of(
6287 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6291 if (!typeArgsAreCanonical) {
6292 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6293 for (
auto typeArg : effectiveTypeArgs)
6295 canonTypeArgs = canonTypeArgsVec;
6297 canonTypeArgs = effectiveTypeArgs;
6302 if (!protocolsSorted) {
6303 canonProtocolsVec.append(protocols.begin(), protocols.end());
6305 canonProtocols = canonProtocolsVec;
6307 canonProtocols = protocols;
6311 canonProtocols, isKindOf);
6314 ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos);
6317 unsigned size =
sizeof(ObjCObjectTypeImpl);
6318 size += typeArgs.size() *
sizeof(
QualType);
6320 void *mem =
Allocate(size,
alignof(ObjCObjectTypeImpl));
6322 new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
6326 ObjCObjectTypes.InsertNode(
T, InsertPos);
6336 bool allowOnPointerType)
const {
6339 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6344 if (allowOnPointerType) {
6345 if (
const auto *objPtr =
6346 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6350 protocolsVec.append(objT->qual_begin(),
6352 protocolsVec.append(protocols.begin(), protocols.end());
6355 objT->getBaseType(),
6356 objT->getTypeArgsAsWritten(),
6358 objT->isKindOfTypeAsWritten());
6364 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6369 objT->getTypeArgsAsWritten(),
6371 objT->isKindOfTypeAsWritten());
6375 if (
type->isObjCObjectType()) {
6385 if (
type->isObjCIdType()) {
6388 objPtr->isKindOfType());
6393 if (
type->isObjCClassType()) {
6396 objPtr->isKindOfType());
6408 llvm::FoldingSetNodeID ID;
6409 ObjCTypeParamType::Profile(ID,
Decl,
Decl->getUnderlyingType(), protocols);
6410 void *InsertPos =
nullptr;
6411 if (ObjCTypeParamType *TypeParam =
6412 ObjCTypeParamTypes.FindNodeOrInsertPos(ID, InsertPos))
6417 if (!protocols.empty()) {
6421 Canonical, protocols, hasError,
true ));
6422 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6425 unsigned size =
sizeof(ObjCTypeParamType);
6427 void *mem =
Allocate(size,
alignof(ObjCTypeParamType));
6428 auto *newType =
new (mem) ObjCTypeParamType(
Decl, Canonical, protocols);
6430 Types.push_back(newType);
6431 ObjCTypeParamTypes.InsertNode(newType, InsertPos);
6441 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6456 for (
auto *Proto : OPT->quals()) {
6479 if (InheritedProtocols.empty())
6483 bool Conforms =
false;
6484 for (
auto *Proto : OPT->quals()) {
6486 for (
auto *PI : InheritedProtocols) {
6498 for (
auto *PI : InheritedProtocols) {
6500 bool Adopts =
false;
6501 for (
auto *Proto : OPT->quals()) {
6515 llvm::FoldingSetNodeID ID;
6518 void *InsertPos =
nullptr;
6520 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
6529 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
6538 Types.push_back(QType);
6539 ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
6547 if (
Decl->TypeForDecl)
6551 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6552 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6553 return QualType(PrevDecl->TypeForDecl, 0);
6562 Decl->TypeForDecl =
T;
6575 llvm::FoldingSetNodeID ID;
6579 void *InsertPos =
nullptr;
6581 DependentTypeOfExprTypes.FindNodeOrInsertPos(ID, InsertPos);
6591 DependentTypeOfExprTypes.InsertNode(Canon, InsertPos);
6599 Types.push_back(toe);
6610 auto *tot =
new (*
this,
alignof(TypeOfType))
6611 TypeOfType(*
this, tofType, Canonical, Kind);
6612 Types.push_back(tot);
6636 llvm_unreachable(
"Unknown value kind");
6651 }
else if (!UnderlyingType.
isNull()) {
6654 llvm::FoldingSetNodeID ID;
6655 DependentDecltypeType::Profile(ID, *
this, E);
6657 void *InsertPos =
nullptr;
6658 if (DependentDecltypeType *Canon =
6659 DependentDecltypeTypes.FindNodeOrInsertPos(ID, InsertPos))
6664 new (*
this,
alignof(DependentDecltypeType)) DependentDecltypeType(E);
6665 DependentDecltypeTypes.InsertNode(DT, InsertPos);
6666 Types.push_back(DT);
6669 auto *DT =
new (*
this,
alignof(DecltypeType))
6670 DecltypeType(E, UnderlyingType, CanonType);
6671 Types.push_back(DT);
6676 bool FullySubstituted,
6680 if (FullySubstituted && Index) {
6683 llvm::FoldingSetNodeID ID;
6684 PackIndexingType::Profile(ID, *
this, Pattern.
getCanonicalType(), IndexExpr,
6685 FullySubstituted, Expansions);
6686 void *InsertPos =
nullptr;
6687 PackIndexingType *Canon =
6688 DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos);
6691 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6695 IndexExpr, FullySubstituted, Expansions);
6696 DependentPackIndexingTypes.InsertNode(Canon, InsertPos);
6702 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6704 auto *
T =
new (Mem) PackIndexingType(Canonical, Pattern, IndexExpr,
6705 FullySubstituted, Expansions);
6714 UnaryTransformType::UTTKind Kind)
const {
6716 llvm::FoldingSetNodeID ID;
6717 UnaryTransformType::Profile(ID, BaseType, UnderlyingType, Kind);
6719 void *InsertPos =
nullptr;
6720 if (UnaryTransformType *UT =
6721 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos))
6725 if (!BaseType->isDependentType()) {
6728 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6731 BaseType != CanonBase) {
6736 [[maybe_unused]] UnaryTransformType *UT =
6737 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos);
6738 assert(!UT &&
"broken canonicalization");
6742 auto *UT =
new (*
this,
alignof(UnaryTransformType))
6743 UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
6744 UnaryTransformTypes.InsertNode(UT, InsertPos);
6745 Types.push_back(UT);
6749QualType ASTContext::getAutoTypeInternal(
6754 !TypeConstraintConcept && !IsDependent)
6758 llvm::FoldingSetNodeID ID;
6759 bool IsDeducedDependent =
6760 isa_and_nonnull<TemplateTemplateParmDecl>(TypeConstraintConcept) ||
6762 AutoType::Profile(ID, *
this, DeducedType,
Keyword,
6763 IsDependent || IsDeducedDependent, TypeConstraintConcept,
6764 TypeConstraintArgs);
6765 if (
auto const AT_iter = AutoTypes.find(ID); AT_iter != AutoTypes.end())
6766 return QualType(AT_iter->getSecond(), 0);
6770 if (!DeducedType.
isNull()) {
6772 }
else if (TypeConstraintConcept) {
6773 bool AnyNonCanonArgs =
false;
6774 auto *CanonicalConcept =
6777 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6778 if (CanonicalConcept != TypeConstraintConcept || AnyNonCanonArgs) {
6780 CanonicalConcept, CanonicalConceptArgs,
6786 void *Mem =
Allocate(
sizeof(AutoType) +
6787 sizeof(TemplateArgument) * TypeConstraintArgs.size(),
6789 auto *AT =
new (Mem) AutoType(
6791 (IsDependent ? TypeDependence::DependentInstantiation
6792 : TypeDependence::None) |
6793 (IsPack ? TypeDependence::UnexpandedPack : TypeDependence::None),
6794 Canon, TypeConstraintConcept, TypeConstraintArgs);
6796 llvm::FoldingSetNodeID InsertedID;
6797 AT->Profile(InsertedID, *
this);
6798 assert(InsertedID == ID &&
"ID does not match");
6800 Types.push_back(AT);
6801 AutoTypes.try_emplace(ID, AT);
6802 return QualType(AT, 0);
6810 bool IsDependent,
bool IsPack,
6813 assert((!IsPack || IsDependent) &&
"only use IsPack for a dependent pack");
6814 assert((!IsDependent || DeducedType.
isNull()) &&
6815 "A dependent auto should be undeduced");
6816 return getAutoTypeInternal(DeducedType,
Keyword, IsDependent, IsPack,
6817 TypeConstraintConcept, TypeConstraintArgs);
6821 QualType CanonT =
T.getNonPackExpansionType().getCanonicalType();
6824 if (
auto *AT = CanonT->
getAs<AutoType>()) {
6825 if (!AT->isConstrained())
6829 AT->containsUnexpandedParameterPack()),
6841QualType ASTContext::getDeducedTemplateSpecializationTypeInternal(
6843 bool IsDependent,
QualType Canon)
const {
6845 void *InsertPos =
nullptr;
6846 llvm::FoldingSetNodeID ID;
6847 DeducedTemplateSpecializationType::Profile(ID,
Keyword,
Template, DeducedType,
6849 if (DeducedTemplateSpecializationType *DTST =
6850 DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
6853 auto *DTST =
new (*
this,
alignof(DeducedTemplateSpecializationType))
6855 IsDependent, Canon);
6858 llvm::FoldingSetNodeID TempID;
6859 DTST->Profile(TempID);
6860 assert(ID == TempID &&
"ID does not match");
6862 Types.push_back(DTST);
6863 DeducedTemplateSpecializationTypes.InsertNode(DTST, InsertPos);
6872 bool IsDependent)
const {
6879 ? getDeducedTemplateSpecializationTypeInternal(
6883 return getDeducedTemplateSpecializationTypeInternal(
6892 llvm::FoldingSetNodeID ID;
6895 void *InsertPos =
nullptr;
6896 if (
AtomicType *AT = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos))
6902 if (!
T.isCanonical()) {
6906 AtomicType *NewIP = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos);
6907 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
6910 Types.push_back(
New);
6911 AtomicTypes.InsertNode(
New, InsertPos);
6942 return getFromTargetType(Target->getSizeType());
6961 return getFromTargetType(Target->getUnsignedPtrDiffType(
LangAS::Default));
6966 return getFromTargetType(Target->getIntMaxType());
6971 return getFromTargetType(Target->getUIntMaxType());
6989 return getFromTargetType(Target->getIntPtrType());
6999 return getFromTargetType(Target->getProcessIDType());
7011 const Type *Ty =
T.getTypePtr();
7039 quals = splitType.
Quals;
7044 QualType elementType = AT->getElementType();
7049 if (elementType == unqualElementType) {
7050 assert(quals.
empty());
7051 quals = splitType.
Quals;
7059 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7061 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7064 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7068 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7070 VAT->getSizeModifier(),
7071 VAT->getIndexTypeCVRQualifiers());
7076 DSAT->getSizeModifier(), 0);
7086 bool AllowPiMismatch)
const {
7101 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7102 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7103 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7116 T1 = AT1->getElementType();
7117 T2 = AT2->getElementType();
7137 bool AllowPiMismatch)
const {
7142 if (T1PtrType && T2PtrType) {
7150 T1MPType && T2MPType) {
7151 if (
auto *RD1 = T1MPType->getMostRecentCXXRecordDecl(),
7152 *RD2 = T2MPType->getMostRecentCXXRecordDecl();
7153 RD1 != RD2 && RD1->getCanonicalDecl() != RD2->getCanonicalDecl())
7155 if (T1MPType->getQualifier().getCanonical() !=
7156 T2MPType->getQualifier().getCanonical())
7166 if (T1OPType && T2OPType) {
7198 if (Quals1 != Quals2)
7268 llvm_unreachable(
"bad template name kind!");
7274 if (!TP->hasDefaultArgument())
7276 return &TP->getDefaultArgument().getArgument();
7279 case NamedDecl::TemplateTypeParm:
7281 case NamedDecl::NonTypeTemplateParm:
7283 case NamedDecl::TemplateTemplateParm:
7286 llvm_unreachable(
"Unexpected template parameter kind");
7291 bool IgnoreDeduced)
const {
7292 while (std::optional<TemplateName> UnderlyingOrNone =
7294 Name = *UnderlyingOrNone;
7299 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7308 llvm_unreachable(
"cannot canonicalize unresolved template");
7312 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7331 assert(IgnoreDeduced ==
false);
7338 bool NonCanonical = CanonUnderlying != Underlying;
7344 assert(CanonArgs.size() <= Params.size());
7350 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7359 if (I ==
int(CanonArgs.size() - 1))
7360 CanonArgs.pop_back();
7361 NonCanonical =
true;
7371 llvm_unreachable(
"always sugar node");
7374 llvm_unreachable(
"bad template name!");
7379 bool IgnoreDeduced)
const {
7400 llvm::FoldingSetNodeID XCEID, YCEID;
7401 XCE->
Profile(XCEID, *
this,
true,
true);
7402 YCE->
Profile(YCEID, *
this,
true,
true);
7403 return XCEID == YCEID;
7452 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7454 if (TX->isParameterPack() != TY->isParameterPack())
7456 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7459 TY->getTypeConstraint());
7462 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7464 return TX->isParameterPack() == TY->isParameterPack() &&
7465 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7467 TY->getPlaceholderTypeConstraint());
7472 return TX->isParameterPack() == TY->isParameterPack() &&
7474 TY->getTemplateParameters());
7479 if (
X->size() != Y->
size())
7482 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7496 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7498 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7501 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7502 TTPY->getDefaultArgument().getArgument().getAsType());
7505 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7507 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7510 Expr *DefaultArgumentX =
7511 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7512 Expr *DefaultArgumentY =
7513 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7514 llvm::FoldingSetNodeID XID, YID;
7515 DefaultArgumentX->
Profile(XID, *
this,
true);
7516 DefaultArgumentY->
Profile(YID, *
this,
true);
7523 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7538 auto Kind =
X.getKind();
7546 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7549 NamespaceY->getNamespace()))
7554 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7555 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7564 llvm_unreachable(
"unhandled qualifier kind");
7570 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7572 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7584 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7588 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7589 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7590 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7593 if (!Cand1A || !Cand2A)
7599 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7600 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7604 if (Cand1ID != Cand2ID)
7638 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7639 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7641 TypedefY->getUnderlyingType());
7658 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7660 return (TagX->getTagKind() == TagY->getTagKind()) ||
7672 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7674 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7676 if (CtorX->getInheritedConstructor() &&
7677 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7678 CtorY->getInheritedConstructor().getConstructor()))
7682 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7687 if (FuncX->isMultiVersion()) {
7688 const auto *TAX = FuncX->getAttr<TargetAttr>();
7689 const auto *TAY = FuncY->getAttr<TargetAttr>();
7690 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7692 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7698 if ((FuncX->isMemberLikeConstrainedFriend() ||
7699 FuncY->isMemberLikeConstrainedFriend()) &&
7700 !FuncX->getLexicalDeclContext()->Equals(
7701 FuncY->getLexicalDeclContext())) {
7706 FuncY->getTrailingRequiresClause()))
7714 FD = FD->getCanonicalDecl();
7715 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7718 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7733 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7738 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7740 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7743 if (VarX->getType().isNull() || VarY->getType().isNull())
7746 if (
hasSameType(VarX->getType(), VarY->getType()))
7756 if (!VarXTy || !VarYTy)
7765 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7767 return NamespaceX->isInline() == NamespaceY->isInline();
7772 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7776 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7779 ConceptY->getConstraintExpr()))
7784 TemplateY->getTemplatedDecl()) &&
7786 TemplateY->getTemplateParameters());
7790 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7793 return hasSameType(FDX->getType(), FDY->getType());
7797 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7799 return IFDX->getAnonField()->getCanonicalDecl() ==
7800 IFDY->getAnonField()->getCanonicalDecl();
7809 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7816 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7819 UX->hasTypename() == UY->hasTypename() &&
7820 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7822 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7825 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7827 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7835 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
7837 UX->getInstantiatedFromUsingDecl(),
7842 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
7844 return NAX->getNamespace()->Equals(NAY->getNamespace());
7892 bool AnyNonCanonArgs =
false;
7895 if (!AnyNonCanonArgs)
7905 llvm_unreachable(
"Unhandled template argument kind");
7915 llvm_unreachable(
"Comparing NULL template argument");
7940 llvm::FoldingSetNodeID ID1, ID2;
7950 return isSameTemplateArgument(Arg1, Arg2);
7954 llvm_unreachable(
"Unhandled template argument kind");
7959 if (!
T.hasLocalQualifiers()) {
7961 if (
const auto *AT = dyn_cast<ArrayType>(
T))
7981 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
7982 if (!ATy || qs.
empty())
7989 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
7992 CAT->getSizeModifier(),
7993 CAT->getIndexTypeCVRQualifiers()));
7994 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
7996 IAT->getSizeModifier(),
7997 IAT->getIndexTypeCVRQualifiers()));
7999 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
8001 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
8002 DSAT->getIndexTypeCVRQualifiers()));
8007 VAT->getIndexTypeCVRQualifiers()));
8013 if (
T->isArrayType() ||
T->isFunctionType())
8021 return T.getUnqualifiedType();
8032 if (
T->isArrayType() ||
T->isFunctionType())
8034 return T.getUnqualifiedType();
8049 assert(PrettyArrayType &&
"Not an array type!");
8086 uint64_t ElementCount = 1;
8089 CA = dyn_cast_or_null<ConstantArrayType>(
8092 return ElementCount;
8100 uint64_t ElementCount = 1;
8104 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8107 return ElementCount;
8117 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8119 case BuiltinType::Half:
return HalfRank;
8120 case BuiltinType::Float:
return FloatRank;
8153unsigned ASTContext::getIntegerRank(
const Type *
T)
const {
8154 assert(
T->isCanonicalUnqualified() &&
"T should be canonicalized");
8158 if (
const auto *EIT = dyn_cast<BitIntType>(
T))
8159 return 0 + (EIT->getNumBits() << 3);
8162 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8163 case BuiltinType::Bool:
8165 case BuiltinType::Char_S:
8166 case BuiltinType::Char_U:
8167 case BuiltinType::SChar:
8168 case BuiltinType::UChar:
8170 case BuiltinType::Short:
8171 case BuiltinType::UShort:
8173 case BuiltinType::Int:
8174 case BuiltinType::UInt:
8176 case BuiltinType::Long:
8177 case BuiltinType::ULong:
8179 case BuiltinType::LongLong:
8180 case BuiltinType::ULongLong:
8182 case BuiltinType::Int128:
8183 case BuiltinType::UInt128:
8188 case BuiltinType::Char8:
8190 case BuiltinType::Char16:
8191 return getIntegerRank(
8193 case BuiltinType::Char32:
8194 return getIntegerRank(
8196 case BuiltinType::WChar_S:
8197 case BuiltinType::WChar_U:
8198 return getIntegerRank(
8228 uint64_t BitWidth = Field->getBitWidthValue();
8254 if (BitWidth < IntSize)
8257 if (BitWidth == IntSize)
8272 assert(!Promotable.
isNull());
8275 return ED->getPromotionType();
8284 if (BT->getKind() == BuiltinType::WChar_S ||
8285 BT->getKind() == BuiltinType::WChar_U ||
8286 BT->getKind() == BuiltinType::Char8 ||
8287 BT->getKind() == BuiltinType::Char16 ||
8288 BT->getKind() == BuiltinType::Char32) {
8289 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8293 for (
const auto &PT : PromoteTypes) {
8295 if (FromSize < ToSize ||
8296 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8299 llvm_unreachable(
"char type should fit into long long");
8306 uint64_t PromotableSize =
getIntWidth(Promotable);
8315 while (!
T.isNull()) {
8317 return T.getObjCLifetime();
8318 if (
T->isArrayType())
8321 T = PT->getPointeeType();
8323 T = RT->getPointeeType();
8348 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8350 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8353 if (LHSC == RHSC)
return 0;
8358 unsigned LHSRank = getIntegerRank(LHSC);
8359 unsigned RHSRank = getIntegerRank(RHSC);
8361 if (LHSUnsigned == RHSUnsigned) {
8362 if (LHSRank == RHSRank)
return 0;
8363 return LHSRank > RHSRank ? 1 : -1;
8369 if (LHSRank >= RHSRank)
8379 if (RHSRank >= LHSRank)
8389 if (CFConstantStringTypeDecl)
8390 return CFConstantStringTypeDecl;
8392 assert(!CFConstantStringTagDecl &&
8393 "tag and typedef should be initialized together");
8395 CFConstantStringTagDecl->startDefinition();
8433 if (
static_cast<unsigned>(CFRuntime) <
8436 Fields[Count++] = {
IntTy,
"flags" };
8438 Fields[Count++] = {
LongTy,
"length" };
8442 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()),
"_swift_rc" };
8446 Fields[Count++] = {
IntTy,
"_ptr" };
8452 for (
unsigned i = 0; i < Count; ++i) {
8456 Fields[i].Type,
nullptr,
8459 CFConstantStringTagDecl->addDecl(Field);
8462 CFConstantStringTagDecl->completeDefinition();
8466 CFConstantStringTypeDecl =
8469 return CFConstantStringTypeDecl;
8473 if (!CFConstantStringTagDecl)
8475 return CFConstantStringTagDecl;
8485 if (ObjCSuperType.isNull()) {
8490 return ObjCSuperType;
8496 CFConstantStringTagDecl = TT->castAsRecordDecl();
8500 if (BlockDescriptorType)
8513 static const char *
const FieldNames[] = {
8518 for (
size_t i = 0; i < 2; ++i) {
8521 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8529 BlockDescriptorType = RD;
8535 if (BlockDescriptorExtendedType)
8550 static const char *
const FieldNames[] = {
8557 for (
size_t i = 0; i < 4; ++i) {
8560 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8569 BlockDescriptorExtendedType = RD;
8574 const auto *BT = dyn_cast<BuiltinType>(
T);
8583 switch (BT->getKind()) {
8584#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8585 case BuiltinType::Id: \
8587#include "clang/Basic/OpenCLImageTypes.def"
8589 case BuiltinType::OCLClkEvent:
8592 case BuiltinType::OCLEvent:
8595 case BuiltinType::OCLQueue:
8598 case BuiltinType::OCLReserveID:
8601 case BuiltinType::OCLSampler:
8620 if (!copyExpr && record->hasTrivialDestructor())
return false;
8651 llvm_unreachable(
"impossible");
8653 llvm_unreachable(
"fell out of lifetime switch!");
8661 bool &HasByrefExtendedLayout)
const {
8666 HasByrefExtendedLayout =
false;
8668 HasByrefExtendedLayout =
true;
8682 assert(Target &&
"Expected target to be initialized");
8683 const llvm::Triple &
T = Target->getTriple();
8685 if (
T.isOSWindows() &&
T.isArch64Bit())
8691 assert(Target &&
"Expected target to be initialized");
8692 const llvm::Triple &
T = Target->getTriple();
8694 if (
T.isOSWindows() &&
T.isArch64Bit())
8700 if (!ObjCInstanceTypeDecl)
8701 ObjCInstanceTypeDecl =
8703 return ObjCInstanceTypeDecl;
8709 if (
const auto *TT = dyn_cast<TypedefType>(
T))
8711 return II->isStr(
"BOOL");
8719 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8728 else if (
type->isArrayType())
8747 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8754 !D->isInlineSpecified() && (D->isConstexpr() ||
First->isConstexpr()))
8785 for (
auto *PI :
Decl->parameters()) {
8790 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8799 ParmOffset = PtrSize;
8800 for (
auto *PVDecl :
Decl->parameters()) {
8801 QualType PType = PVDecl->getOriginalType();
8802 if (
const auto *AT =
8807 PType = PVDecl->getType();
8809 PType = PVDecl->getType();
8829 for (
auto *PI :
Decl->parameters()) {
8836 "getObjCEncodingForFunctionDecl - Incomplete param type");
8843 for (
auto *PVDecl :
Decl->parameters()) {
8844 QualType PType = PVDecl->getOriginalType();
8845 if (
const auto *AT =
8850 PType = PVDecl->getType();
8852 PType = PVDecl->getType();
8866 bool Extended)
const {
8870 ObjCEncOptions Options = ObjCEncOptions()
8871 .setExpandPointedToStructures()
8872 .setExpandStructures()
8873 .setIsOutermostType();
8875 Options.setEncodeBlockParameters().setEncodeClassNames();
8876 getObjCEncodingForTypeImpl(
T, S, Options,
nullptr);
8882 bool Extended)
const {
8887 Decl->getReturnType(), S, Extended);
8896 E =
Decl->sel_param_end(); PI != E; ++PI) {
8903 "getObjCEncodingForMethodDecl - Incomplete param type");
8911 ParmOffset = 2 * PtrSize;
8913 E =
Decl->sel_param_end(); PI != E; ++PI) {
8916 if (
const auto *AT =
8925 PType, S, Extended);
8936 const Decl *Container)
const {
8939 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
8940 for (
auto *PID : CID->property_impls())
8941 if (PID->getPropertyDecl() == PD)
8945 for (
auto *PID : OID->property_impls())
8946 if (PID->getPropertyDecl() == PD)
8980 const Decl *Container)
const {
8982 bool Dynamic =
false;
8990 SynthesizePID = PropertyImpDecl;
8994 std::string S =
"T";
9039 if (SynthesizePID) {
9056 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9059 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9072 getObjCEncodingForTypeImpl(
T, S,
9074 .setExpandPointedToStructures()
9075 .setExpandStructures()
9076 .setIsOutermostType(),
9077 Field, NotEncodedT);
9081 std::string& S)
const {
9085 getObjCEncodingForTypeImpl(
T, S,
9087 .setExpandPointedToStructures()
9088 .setExpandStructures()
9089 .setIsOutermostType()
9090 .setEncodingProperty(),
9098 case BuiltinType::Void:
return 'v';
9099 case BuiltinType::Bool:
return 'B';
9100 case BuiltinType::Char8:
9101 case BuiltinType::Char_U:
9102 case BuiltinType::UChar:
return 'C';
9103 case BuiltinType::Char16:
9104 case BuiltinType::UShort:
return 'S';
9105 case BuiltinType::Char32:
9106 case BuiltinType::UInt:
return 'I';
9107 case BuiltinType::ULong:
9108 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9109 case BuiltinType::UInt128:
return 'T';
9110 case BuiltinType::ULongLong:
return 'Q';
9111 case BuiltinType::Char_S:
9112 case BuiltinType::SChar:
return 'c';
9113 case BuiltinType::Short:
return 's';
9114 case BuiltinType::WChar_S:
9115 case BuiltinType::WChar_U:
9116 case BuiltinType::Int:
return 'i';
9117 case BuiltinType::Long:
9118 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9119 case BuiltinType::LongLong:
return 'q';
9120 case BuiltinType::Int128:
return 't';
9121 case BuiltinType::Float:
return 'f';
9122 case BuiltinType::Double:
return 'd';
9123 case BuiltinType::LongDouble:
return 'D';
9124 case BuiltinType::NullPtr:
return '*';
9126 case BuiltinType::BFloat16:
9127 case BuiltinType::Float16:
9128 case BuiltinType::Float128:
9129 case BuiltinType::Ibm128:
9130 case BuiltinType::Half:
9131 case BuiltinType::ShortAccum:
9132 case BuiltinType::Accum:
9133 case BuiltinType::LongAccum:
9134 case BuiltinType::UShortAccum:
9135 case BuiltinType::UAccum:
9136 case BuiltinType::ULongAccum:
9137 case BuiltinType::ShortFract:
9138 case BuiltinType::Fract:
9139 case BuiltinType::LongFract:
9140 case BuiltinType::UShortFract:
9141 case BuiltinType::UFract:
9142 case BuiltinType::ULongFract:
9143 case BuiltinType::SatShortAccum:
9144 case BuiltinType::SatAccum:
9145 case BuiltinType::SatLongAccum:
9146 case BuiltinType::SatUShortAccum:
9147 case BuiltinType::SatUAccum:
9148 case BuiltinType::SatULongAccum:
9149 case BuiltinType::SatShortFract:
9150 case BuiltinType::SatFract:
9151 case BuiltinType::SatLongFract:
9152 case BuiltinType::SatUShortFract:
9153 case BuiltinType::SatUFract:
9154 case BuiltinType::SatULongFract:
9158#define SVE_TYPE(Name, Id, SingletonId) \
9159 case BuiltinType::Id:
9160#include "clang/Basic/AArch64ACLETypes.def"
9161#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9162#include "clang/Basic/RISCVVTypes.def"
9163#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9164#include "clang/Basic/WebAssemblyReferenceTypes.def"
9165#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9166#include "clang/Basic/AMDGPUTypes.def"
9170 "cannot yet @encode type %0");
9175 case BuiltinType::ObjCId:
9176 case BuiltinType::ObjCClass:
9177 case BuiltinType::ObjCSel:
9178 llvm_unreachable(
"@encoding ObjC primitive type");
9181#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9182 case BuiltinType::Id:
9183#include "clang/Basic/OpenCLImageTypes.def"
9184#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9185 case BuiltinType::Id:
9186#include "clang/Basic/OpenCLExtensionTypes.def"
9187 case BuiltinType::OCLEvent:
9188 case BuiltinType::OCLClkEvent:
9189 case BuiltinType::OCLQueue:
9190 case BuiltinType::OCLReserveID:
9191 case BuiltinType::OCLSampler:
9192 case BuiltinType::Dependent:
9193#define PPC_VECTOR_TYPE(Name, Id, Size) \
9194 case BuiltinType::Id:
9195#include "clang/Basic/PPCTypes.def"
9196#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9197#include "clang/Basic/HLSLIntangibleTypes.def"
9198#define BUILTIN_TYPE(KIND, ID)
9199#define PLACEHOLDER_TYPE(KIND, ID) \
9200 case BuiltinType::KIND:
9201#include "clang/AST/BuiltinTypes.def"
9202 llvm_unreachable(
"invalid builtin type for @encode");
9204 llvm_unreachable(
"invalid BuiltinType::Kind value");
9211 if (!
Enum->isFixed())
9221 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9241 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9249 S += llvm::utostr(Offset);
9251 if (
const auto *ET =
T->getAsCanonical<EnumType>())
9264 bool VisitBasesAndFields) {
9265 T =
T->getBaseElementTypeUnsafe();
9269 PT->getPointeeType().getTypePtr(),
false);
9271 auto *CXXRD =
T->getAsCXXRecordDecl();
9279 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9282 for (
const auto &B : CXXRD->bases())
9287 for (
auto *FD : CXXRD->fields())
9296void ASTContext::getObjCEncodingForTypeImpl(QualType
T, std::string &S,
9297 const ObjCEncOptions Options,
9298 const FieldDecl *FD,
9299 QualType *NotEncodedT)
const {
9301 switch (CT->getTypeClass()) {
9306 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9314 getObjCEncodingForTypeImpl(
T->
castAs<ComplexType>()->getElementType(), S,
9321 getObjCEncodingForTypeImpl(
T->
castAs<AtomicType>()->getValueType(), S,
9328 case Type::LValueReference:
9329 case Type::RValueReference: {
9332 const auto *PT =
T->
castAs<PointerType>();
9333 if (PT->isObjCSelType()) {
9342 bool isReadOnly =
false;
9347 if (
T->
getAs<TypedefType>()) {
9348 if (Options.IsOutermostType() &&
T.isConstQualified()) {
9352 }
else if (Options.IsOutermostType()) {
9353 QualType P = PointeeTy;
9354 while (
auto PT = P->
getAs<PointerType>())
9365 if (StringRef(S).ends_with(
"nr"))
9366 S.replace(S.end()-2, S.end(),
"rn");
9376 }
else if (
const auto *RTy = PointeeTy->
getAsCanonical<RecordType>()) {
9377 const IdentifierInfo *II = RTy->getOriginalDecl()->getIdentifier();
9379 if (II == &
Idents.get(
"objc_class")) {
9384 if (II == &
Idents.get(
"objc_object")) {
9393 RTy, Options.ExpandPointedToStructures()))) {
9402 ObjCEncOptions NewOptions;
9403 if (Options.ExpandPointedToStructures())
9404 NewOptions.setExpandStructures();
9405 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9406 nullptr, NotEncodedT);
9410 case Type::ConstantArray:
9411 case Type::IncompleteArray:
9412 case Type::VariableArray: {
9419 getObjCEncodingForTypeImpl(
9420 AT->getElementType(), S,
9421 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9425 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9426 S += llvm::utostr(CAT->getZExtSize());
9430 "Unknown array type!");
9434 getObjCEncodingForTypeImpl(
9435 AT->getElementType(), S,
9436 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9443 case Type::FunctionNoProto:
9444 case Type::FunctionProto:
9448 case Type::Record: {
9450 S += RDecl->
isUnion() ?
'(' :
'{';
9454 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9455 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
9456 llvm::raw_string_ostream
OS(S);
9457 printTemplateArgumentList(OS, TemplateArgs.
asArray(),
9463 if (Options.ExpandStructures()) {
9466 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9468 for (
const auto *Field : RDecl->
fields()) {
9471 S +=
Field->getNameAsString();
9476 if (
Field->isBitField()) {
9477 getObjCEncodingForTypeImpl(
Field->getType(), S,
9478 ObjCEncOptions().setExpandStructures(),
9481 QualType qt =
Field->getType();
9483 getObjCEncodingForTypeImpl(
9485 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9491 S += RDecl->
isUnion() ?
')' :
'}';
9495 case Type::BlockPointer: {
9496 const auto *BT =
T->
castAs<BlockPointerType>();
9498 if (Options.EncodeBlockParameters()) {
9499 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
9503 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9504 Options.forComponentType(), FD, NotEncodedT);
9508 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9509 for (
const auto &I : FPT->param_types())
9510 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9518 case Type::ObjCObject: {
9522 S +=
"{objc_object=}";
9526 S +=
"{objc_class=}";
9533 case Type::ObjCInterface: {
9536 ObjCInterfaceDecl *OI =
T->
castAs<ObjCObjectType>()->getInterface();
9539 if (Options.ExpandStructures()) {
9541 SmallVector<const ObjCIvarDecl*, 32> Ivars;
9543 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9544 const FieldDecl *
Field = Ivars[i];
9545 if (
Field->isBitField())
9546 getObjCEncodingForTypeImpl(
Field->getType(), S,
9547 ObjCEncOptions().setExpandStructures(),
9550 getObjCEncodingForTypeImpl(
Field->getType(), S,
9551 ObjCEncOptions().setExpandStructures(), FD,
9559 case Type::ObjCObjectPointer: {
9560 const auto *OPT =
T->
castAs<ObjCObjectPointerType>();
9561 if (OPT->isObjCIdType()) {
9566 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9574 if (OPT->isObjCQualifiedIdType()) {
9575 getObjCEncodingForTypeImpl(
9577 Options.keepingOnly(ObjCEncOptions()
9578 .setExpandPointedToStructures()
9579 .setExpandStructures()),
9581 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9585 for (
const auto *I : OPT->quals()) {
9587 S += I->getObjCRuntimeNameAsString();
9596 if (OPT->getInterfaceDecl() &&
9597 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9599 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9600 for (
const auto *I : OPT->quals()) {
9602 S += I->getObjCRuntimeNameAsString();
9612 case Type::MemberPointer:
9616 case Type::ExtVector:
9622 case Type::ConstantMatrix:
9635 case Type::DeducedTemplateSpecialization:
9638 case Type::HLSLAttributedResource:
9639 case Type::HLSLInlineSpirv:
9640 llvm_unreachable(
"unexpected type");
9642 case Type::ArrayParameter:
9644#define ABSTRACT_TYPE(KIND, BASE)
9645#define TYPE(KIND, BASE)
9646#define DEPENDENT_TYPE(KIND, BASE) \
9648#define NON_CANONICAL_TYPE(KIND, BASE) \
9650#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9652#include "clang/AST/TypeNodes.inc"
9653 llvm_unreachable(
"@encode for dependent type!");
9655 llvm_unreachable(
"bad type kind!");
9658void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
9660 const FieldDecl *FD,
9662 QualType *NotEncodedT)
const {
9663 assert(RDecl &&
"Expected non-null RecordDecl");
9664 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9668 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9669 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9673 for (
const auto &BI : CXXRec->bases()) {
9674 if (!BI.isVirtual()) {
9679 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9680 std::make_pair(offs, base));
9685 for (FieldDecl *Field : RDecl->
fields()) {
9686 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9689 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9690 std::make_pair(offs, Field));
9693 if (CXXRec && includeVBases) {
9694 for (
const auto &BI : CXXRec->vbases()) {
9700 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9701 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9702 std::make_pair(offs, base));
9716 std::multimap<uint64_t, NamedDecl *>::iterator
9717 CurLayObj = FieldOrBaseOffsets.begin();
9719 if (CXXRec && CXXRec->isDynamicClass() &&
9720 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9723 std::string recname = CXXRec->getNameAsString();
9724 if (recname.empty()) recname =
"?";
9737 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9738 std::make_pair(offs,
nullptr));
9741 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9743 assert(CurOffs <= CurLayObj->first);
9744 if (CurOffs < CurLayObj->first) {
9745 uint64_t padding = CurLayObj->first - CurOffs;
9757 NamedDecl *dcl = CurLayObj->second;
9761 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9766 getObjCEncodingForStructureImpl(base, S, FD,
false,
9776 S += field->getNameAsString();
9780 if (field->isBitField()) {
9783 CurOffs += field->getBitWidthValue();
9786 QualType qt = field->getType();
9788 getObjCEncodingForTypeImpl(
9789 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9800 std::string& S)
const {
9833 if (!ObjCClassDecl) {
9838 return ObjCClassDecl;
9842 if (!ObjCProtocolClassDecl) {
9843 ObjCProtocolClassDecl
9852 return ObjCProtocolClassDecl;
9873 QualType T = Context->getPointerType(Context->CharTy);
9874 return Context->buildImplicitTypedef(
T, Name);
9887 QualType T = Context->getPointerType(Context->VoidTy);
9888 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
9895 if (Context->getLangOpts().CPlusPlus) {
9900 &Context->Idents.get(
"std"),
9908 const size_t NumFields = 5;
9910 const char *FieldNames[NumFields];
9913 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
9914 FieldNames[0] =
"__stack";
9917 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
9918 FieldNames[1] =
"__gr_top";
9921 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
9922 FieldNames[2] =
"__vr_top";
9925 FieldTypes[3] = Context->IntTy;
9926 FieldNames[3] =
"__gr_offs";
9929 FieldTypes[4] = Context->IntTy;
9930 FieldNames[4] =
"__vr_offs";
9933 for (
unsigned i = 0; i < NumFields; ++i) {
9938 &Context->Idents.get(FieldNames[i]),
9939 FieldTypes[i],
nullptr,
9951 return Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
9958 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
9961 const size_t NumFields = 5;
9963 const char *FieldNames[NumFields];
9966 FieldTypes[0] = Context->UnsignedCharTy;
9967 FieldNames[0] =
"gpr";
9970 FieldTypes[1] = Context->UnsignedCharTy;
9971 FieldNames[1] =
"fpr";
9974 FieldTypes[2] = Context->UnsignedShortTy;
9975 FieldNames[2] =
"reserved";
9978 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
9979 FieldNames[3] =
"overflow_arg_area";
9982 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
9983 FieldNames[4] =
"reg_save_area";
9986 for (
unsigned i = 0; i < NumFields; ++i) {
9990 &Context->Idents.get(FieldNames[i]),
9991 FieldTypes[i],
nullptr,
10004 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10008 std::nullopt, VaListTagTypedefDecl);
10011 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10012 QualType VaListTagArrayType = Context->getConstantArrayType(
10014 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10017static TypedefDecl *
10021 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10024 const size_t NumFields = 4;
10026 const char *FieldNames[NumFields];
10029 FieldTypes[0] = Context->UnsignedIntTy;
10030 FieldNames[0] =
"gp_offset";
10033 FieldTypes[1] = Context->UnsignedIntTy;
10034 FieldNames[1] =
"fp_offset";
10037 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10038 FieldNames[2] =
"overflow_arg_area";
10041 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10042 FieldNames[3] =
"reg_save_area";
10045 for (
unsigned i = 0; i < NumFields; ++i) {
10050 &Context->Idents.get(FieldNames[i]),
10051 FieldTypes[i],
nullptr,
10065 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10066 QualType VaListTagArrayType = Context->getConstantArrayType(
10068 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10071static TypedefDecl *
10074 RecordDecl *VaListDecl = Context->buildImplicitRecord(
"__va_list");
10075 if (Context->getLangOpts().CPlusPlus) {
10094 &Context->Idents.get(
"__ap"),
10095 Context->getPointerType(Context->VoidTy),
10105 Context->VaListTagDecl = VaListDecl;
10108 CanQualType T = Context->getCanonicalTagType(VaListDecl);
10109 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10112static TypedefDecl *
10116 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10119 const size_t NumFields = 4;
10121 const char *FieldNames[NumFields];
10124 FieldTypes[0] = Context->LongTy;
10125 FieldNames[0] =
"__gpr";
10128 FieldTypes[1] = Context->LongTy;
10129 FieldNames[1] =
"__fpr";
10132 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10133 FieldNames[2] =
"__overflow_arg_area";
10136 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10137 FieldNames[3] =
"__reg_save_area";
10140 for (
unsigned i = 0; i < NumFields; ++i) {
10145 &Context->Idents.get(FieldNames[i]),
10146 FieldTypes[i],
nullptr,
10160 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10161 QualType VaListTagArrayType = Context->getConstantArrayType(
10164 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10170 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10173 const size_t NumFields = 3;
10175 const char *FieldNames[NumFields];
10178 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10179 FieldNames[0] =
"__current_saved_reg_area_pointer";
10182 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10183 FieldNames[1] =
"__saved_reg_area_end_pointer";
10186 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10187 FieldNames[2] =
"__overflow_area_pointer";
10190 for (
unsigned i = 0; i < NumFields; ++i) {
10193 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
10206 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10210 std::nullopt, VaListTagTypedefDecl);
10213 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10214 QualType VaListTagArrayType = Context->getConstantArrayType(
10217 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10220static TypedefDecl *
10230 constexpr size_t NumFields = 3;
10231 QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
10232 Context->getPointerType(Context->IntTy),
10234 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10237 for (
unsigned i = 0; i < NumFields; ++i) {
10240 &Context->Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
10252 Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10254 return VaListTagTypedefDecl;
10280 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10284 if (!BuiltinVaListDecl) {
10285 BuiltinVaListDecl =
CreateVaListDecl(
this, Target->getBuiltinVaListKind());
10286 assert(BuiltinVaListDecl->isImplicit());
10289 return BuiltinVaListDecl;
10302 if (!BuiltinMSVaListDecl)
10305 return BuiltinMSVaListDecl;
10322 assert(ObjCConstantStringType.isNull() &&
10323 "'NSConstantString' type already set!");
10333 unsigned size = End - Begin;
10334 assert(size > 1 &&
"set is not overloaded!");
10340 NamedDecl **Storage = OT->getStorage();
10363 bool TemplateKeyword,
10368 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10369 assert(!Qualifier &&
"unexpected qualified template template parameter");
10370 assert(TemplateKeyword ==
false);
10375 llvm::FoldingSetNodeID ID;
10378 void *InsertPos =
nullptr;
10380 QualifiedTemplateNames.FindNodeOrInsertPos(ID, InsertPos);
10384 QualifiedTemplateNames.InsertNode(QTN, InsertPos);
10394 llvm::FoldingSetNodeID ID;
10397 void *InsertPos =
nullptr;
10399 DependentTemplateNames.FindNodeOrInsertPos(ID, InsertPos))
10404 DependentTemplateNames.InsertNode(QTN, InsertPos);
10409 Decl *AssociatedDecl,
10412 bool Final)
const {
10413 llvm::FoldingSetNodeID ID;
10415 Index, PackIndex, Final);
10417 void *insertPos =
nullptr;
10419 = SubstTemplateTemplateParms.FindNodeOrInsertPos(ID, insertPos);
10423 Replacement, AssociatedDecl, Index, PackIndex, Final);
10424 SubstTemplateTemplateParms.InsertNode(subst, insertPos);
10432 Decl *AssociatedDecl,
10433 unsigned Index,
bool Final)
const {
10435 llvm::FoldingSetNodeID ID;
10437 AssociatedDecl, Index, Final);
10439 void *InsertPos =
nullptr;
10441 = SubstTemplateTemplateParmPacks.FindNodeOrInsertPos(ID, InsertPos);
10446 SubstTemplateTemplateParmPacks.InsertNode(Subst, InsertPos);
10460 llvm::FoldingSetNodeID ID;
10463 void *InsertPos =
nullptr;
10465 DeducedTemplates.FindNodeOrInsertPos(ID, InsertPos);
10471 DeducedTemplates.InsertNode(DTS, InsertPos);
10494 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10524 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10525 CT = AT->getElementType();
10557 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10558 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10595 auto VScale = Context.getTargetInfo().getVScaleRange(
10602 uint64_t EltSize = Context.getTypeSize(Info.
ElementType);
10606 uint64_t MinElts = Info.
EC.getKnownMinValue();
10607 return VScale->first * MinElts * EltSize;
10615 "Expected RVV builtin type and vector type!");
10655 return IsValidCast(FirstType, SecondType) ||
10656 IsValidCast(SecondType, FirstType);
10664 "Expected RVV builtin type and vector type!");
10671 if (!BT->isRVVVLSBuiltinType())
10691 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10698 return IsLaxCompatible(FirstType, SecondType) ||
10699 IsLaxCompatible(SecondType, FirstType);
10705 if (
const AttributedType *
Attr = dyn_cast<AttributedType>(Ty)) {
10706 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10709 Ty =
Attr->getModifiedType();
10713 Ty =
Paren->getInnerType();
10745 for (
auto *lhsProto : lhs->
quals()) {
10746 bool match =
false;
10747 for (
auto *rhsProto : rhs->
quals()) {
10778 for (
auto *I : lhs->
quals()) {
10782 if (!rhsID->ClassImplementsProtocol(I,
true))
10790 for (
auto *lhsProto : lhs->
quals()) {
10791 bool match =
false;
10796 for (
auto *rhsProto : rhs->
quals()) {
10806 for (
auto *I : lhs->
quals()) {
10810 if (rhsID->ClassImplementsProtocol(I,
true)) {
10827 for (
auto *lhsProto : lhs->
quals()) {
10828 bool match =
false;
10835 for (
auto *rhsProto : rhs->
quals()) {
10854 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
10856 for (
auto *lhsProto : LHSInheritedProtocols) {
10857 bool match =
false;
10858 for (
auto *rhsProto : rhs->
quals()) {
10883 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
10888 auto finish = [&](
bool succeeded) ->
bool {
10892 if (!RHS->isKindOfType())
10903 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
10908 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
10913 if (LHS->isObjCClass() && RHS->isObjCClass()) {
10918 if (LHS->getInterface() && RHS->getInterface()) {
10933 bool BlockReturnType) {
10937 auto finish = [&](
bool succeeded) ->
bool {
10962 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
10966 (!BlockReturnType &&
10970 (BlockReturnType ? LHSOPT : RHSOPT),
10971 (BlockReturnType ? RHSOPT : LHSOPT),
false));
10979 return finish(BlockReturnType);
10981 return finish(!BlockReturnType);
10993 return (*lhs)->getName().compare((*rhs)->getName());
11010 assert(LHS->getInterface() &&
"LHS must have an interface base");
11011 assert(RHS->getInterface() &&
"RHS must have an interface base");
11017 for (
auto *proto : LHS->quals()) {
11018 Context.CollectInheritedProtocols(proto, LHSProtocolSet);
11022 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
11028 for (
auto *proto : RHS->quals()) {
11029 Context.CollectInheritedProtocols(proto, RHSProtocolSet);
11033 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
11036 for (
auto *proto : LHSProtocolSet) {
11037 if (RHSProtocolSet.count(proto))
11038 IntersectionSet.push_back(proto);
11044 Context.CollectInheritedProtocols(CommonBase, ImpliedProtocols);
11047 if (!ImpliedProtocols.empty()) {
11049 return ImpliedProtocols.contains(proto);
11054 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11064 if (lhsOPT && rhsOPT)
11070 if (lhsBlock && rhsBlock)
11075 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11087 bool stripKindOf) {
11088 if (lhsArgs.size() != rhsArgs.size())
11095 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11101 if (!stripKindOf ||
11102 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11103 rhsArgs[i].stripObjCKindOfType(ctx))) {
11131 if (!LDecl || !RDecl)
11137 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
11141 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11146 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
11151 bool anyChanges =
false;
11152 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11155 LHS->getTypeArgs(), RHS->getTypeArgs(),
11158 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11169 if (!Protocols.empty())
11175 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
11178 anyKindOf || LHS->isKindOfType());
11186 QualType LHSSuperType = LHS->getSuperClassType();
11187 if (LHSSuperType.
isNull())
11196 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
11197 if (KnownLHS != LHSAncestors.end()) {
11198 LHS = KnownLHS->second;
11202 bool anyChanges =
false;
11203 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11206 LHS->getTypeArgs(), RHS->getTypeArgs(),
11209 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11220 if (!Protocols.empty())
11225 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
11228 anyKindOf || RHS->isKindOfType());
11236 QualType RHSSuperType = RHS->getSuperClassType();
11237 if (RHSSuperType.
isNull())
11248 assert(LHS->getInterface() &&
"LHS is not an interface type");
11249 assert(RHS->getInterface() &&
"RHS is not an interface type");
11254 bool IsSuperClass = LHSInterface->
isSuperClassOf(RHS->getInterface());
11261 if (LHS->getNumProtocols() > 0) {
11270 for (
auto *RHSPI : RHS->quals())
11273 if (SuperClassInheritedProtocols.empty())
11276 for (
const auto *LHSProto : LHS->quals()) {
11277 bool SuperImplementsProtocol =
false;
11278 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11279 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11280 SuperImplementsProtocol =
true;
11283 if (!SuperImplementsProtocol)
11289 if (LHS->isSpecialized()) {
11294 RHSSuper = RHSSuper->getSuperClassType()->castAs<
ObjCObjectType>();
11297 if (RHSSuper->isSpecialized() &&
11299 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
11313 if (!LHSOPT || !RHSOPT)
11331 bool CompareUnqualified) {
11350 bool OfBlockPointer,
11352 if (
const RecordType *UT =
T->getAsUnionType()) {
11354 if (UD->
hasAttr<TransparentUnionAttr>()) {
11355 for (
const auto *I : UD->
fields()) {
11356 QualType ET = I->getType().getUnqualifiedType();
11370 bool OfBlockPointer,
11391 bool IsConditionalOperator) {
11394 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11395 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11396 bool allLTypes =
true;
11397 bool allRTypes =
true;
11401 if (OfBlockPointer) {
11403 QualType LHS = lbase->getReturnType();
11405 if (!UnqualifiedResult)
11407 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11472 bool NoReturn = IsConditionalOperator
11482 std::optional<FunctionEffectSet> MergedFX;
11484 if (lproto && rproto) {
11485 assert((AllowCXX ||
11486 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11487 "C++ shouldn't be here");
11489 if (lproto->getNumParams() != rproto->getNumParams())
11493 if (lproto->isVariadic() != rproto->isVariadic())
11496 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11500 if (lproto->getExtraAttributeInfo().CFISalt !=
11501 rproto->getExtraAttributeInfo().CFISalt)
11507 if (LHSFX != RHSFX) {
11508 if (IsConditionalOperator)
11517 if (*MergedFX != LHSFX)
11519 if (*MergedFX != RHSFX)
11524 bool canUseLeft, canUseRight;
11536 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11537 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11538 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11540 lParamType, rParamType, OfBlockPointer,
Unqualified);
11547 types.push_back(paramType);
11559 if (allLTypes)
return lhs;
11560 if (allRTypes)
return rhs;
11565 newParamInfos.empty() ?
nullptr : newParamInfos.data();
11571 if (lproto) allRTypes =
false;
11572 if (rproto) allLTypes =
false;
11576 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11584 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11590 paramTy = ED->getIntegerType();
11600 if (allLTypes)
return lhs;
11601 if (allRTypes)
return rhs;
11610 if (allLTypes)
return lhs;
11611 if (allRTypes)
return rhs;
11617 QualType other,
bool isBlockReturnType) {
11623 ET->getOriginalDecl()->getDefinitionOrSelf()->getIntegerType();
11624 if (underlyingType.
isNull())
11626 if (Context.hasSameType(underlyingType, other))
11632 Context.getTypeSize(underlyingType) == Context.getTypeSize(other))
11641 if (LangOpts.CPlusPlus || !LangOpts.C23)
11656 bool IsConditionalOperator) {
11667 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11671 if (LHSRefTy || RHSRefTy)
11683 if (LHSCan == RHSCan)
11688 Qualifiers RQuals = RHSCan.getLocalQualifiers();
11689 if (LQuals != RQuals) {
11706 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
11727 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
11728 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
11731 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
11732 LHSClass = Type::ConstantArray;
11733 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
11734 RHSClass = Type::ConstantArray;
11737 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
11738 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
11741 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
11742 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
11745 if (LHSClass != RHSClass) {
11755 if (OfBlockPointer && !BlockReturnType) {
11763 if (
const auto *AT = LHS->
getAs<AutoType>()) {
11764 if (!AT->isDeduced() && AT->isGNUAutoType())
11767 if (
const auto *AT = RHS->
getAs<AutoType>()) {
11768 if (!AT->isDeduced() && AT->isGNUAutoType())
11775 switch (LHSClass) {
11776#define TYPE(Class, Base)
11777#define ABSTRACT_TYPE(Class, Base)
11778#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
11779#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
11780#define DEPENDENT_TYPE(Class, Base) case Type::Class:
11781#include "clang/AST/TypeNodes.inc"
11782 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
11785 case Type::DeducedTemplateSpecialization:
11786 case Type::LValueReference:
11787 case Type::RValueReference:
11788 case Type::MemberPointer:
11789 llvm_unreachable(
"C++ should never be in mergeTypes");
11791 case Type::ObjCInterface:
11792 case Type::IncompleteArray:
11793 case Type::VariableArray:
11794 case Type::FunctionProto:
11795 case Type::ExtVector:
11796 llvm_unreachable(
"Types are eliminated above");
11798 case Type::Pointer:
11809 if (ResultType.
isNull())
11817 case Type::BlockPointer:
11842 if (ResultType.
isNull())
11861 if (ResultType.
isNull())
11869 case Type::ConstantArray:
11884 if (ResultType.
isNull())
11892 if (LVAT || RVAT) {
11895 -> std::pair<bool,llvm::APInt> {
11897 std::optional<llvm::APSInt> TheInt;
11900 return std::make_pair(
true, *TheInt);
11901 return std::make_pair(
false, llvm::APSInt());
11904 return std::make_pair(
true, CAT->getSize());
11905 return std::make_pair(
false, llvm::APInt());
11908 bool HaveLSize, HaveRSize;
11909 llvm::APInt LSize, RSize;
11910 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
11911 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
11912 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
11946 case Type::FunctionNoProto:
11948 false, IsConditionalOperator);
11952 case Type::Builtin:
11955 case Type::Complex:
11964 case Type::ConstantMatrix:
11969 case Type::ObjCObject: {
11978 case Type::ObjCObjectPointer:
11979 if (OfBlockPointer) {
11991 assert(LHS != RHS &&
11992 "Equivalent pipe types should have already been handled!");
11994 case Type::ArrayParameter:
11995 assert(LHS != RHS &&
11996 "Equivalent ArrayParameter types should have already been handled!");
11998 case Type::BitInt: {
12006 if (LHSUnsigned != RHSUnsigned)
12009 if (LHSBits != RHSBits)
12013 case Type::HLSLAttributedResource: {
12014 const HLSLAttributedResourceType *LHSTy =
12015 LHS->
castAs<HLSLAttributedResourceType>();
12016 const HLSLAttributedResourceType *RHSTy =
12017 RHS->
castAs<HLSLAttributedResourceType>();
12018 assert(LHSTy->getWrappedType() == RHSTy->getWrappedType() &&
12019 LHSTy->getWrappedType()->isHLSLResourceType() &&
12020 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
12022 if (LHSTy->getAttrs() == RHSTy->getAttrs() &&
12023 LHSTy->getContainedType() == RHSTy->getContainedType())
12027 case Type::HLSLInlineSpirv:
12028 const HLSLInlineSpirvType *LHSTy = LHS->
castAs<HLSLInlineSpirvType>();
12029 const HLSLInlineSpirvType *RHSTy = RHS->
castAs<HLSLInlineSpirvType>();
12031 if (LHSTy->getOpcode() == RHSTy->getOpcode() &&
12032 LHSTy->getSize() == RHSTy->getSize() &&
12033 LHSTy->getAlignment() == RHSTy->getAlignment()) {
12034 for (
size_t I = 0; I < LHSTy->getOperands().size(); I++)
12035 if (LHSTy->getOperands()[I] != RHSTy->getOperands()[I])
12043 llvm_unreachable(
"Invalid Type::Class!");
12048 bool &CanUseFirst,
bool &CanUseSecond,
12050 assert(NewParamInfos.empty() &&
"param info list not empty");
12051 CanUseFirst = CanUseSecond =
true;
12057 if (!FirstHasInfo && !SecondHasInfo)
12060 bool NeedParamInfo =
false;
12064 for (
size_t I = 0; I < E; ++I) {
12075 bool FirstNoEscape = FirstParam.
isNoEscape();
12076 bool SecondNoEscape = SecondParam.
isNoEscape();
12077 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12079 if (NewParamInfos.back().getOpaqueValue())
12080 NeedParamInfo =
true;
12081 if (FirstNoEscape != IsNoEscape)
12082 CanUseFirst =
false;
12083 if (SecondNoEscape != IsNoEscape)
12084 CanUseSecond =
false;
12087 if (!NeedParamInfo)
12088 NewParamInfos.clear();
12094 if (
auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
12095 It->second =
nullptr;
12096 for (
auto *SubClass : ObjCSubClasses[D])
12108 if (LHSCan == RHSCan)
12110 if (RHSCan->isFunctionType()) {
12119 if (ResReturnType.
isNull())
12121 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12138 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12139 if (LQuals != RQuals) {
12152 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12168 if (ResQT == LHSBaseQT)
12170 if (ResQT == RHSBaseQT)
12181 if (
const auto *ED =
T->getAsEnumDecl())
12182 T = ED->getIntegerType();
12183 if (
T->isBooleanType())
12186 return EIT->getNumBits();
12192 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12193 T->isFixedPointType()) &&
12194 "Unexpected type");
12199 VTy->getNumElements(), VTy->getVectorKind());
12207 if (
const auto *ED =
T->getAsEnumDecl())
12208 T = ED->getIntegerType();
12211 case BuiltinType::Char_U:
12213 case BuiltinType::Char_S:
12214 case BuiltinType::SChar:
12215 case BuiltinType::Char8:
12217 case BuiltinType::Short:
12219 case BuiltinType::Int:
12221 case BuiltinType::Long:
12223 case BuiltinType::LongLong:
12225 case BuiltinType::Int128:
12230 case BuiltinType::WChar_S:
12233 case BuiltinType::ShortAccum:
12235 case BuiltinType::Accum:
12237 case BuiltinType::LongAccum:
12239 case BuiltinType::SatShortAccum:
12241 case BuiltinType::SatAccum:
12243 case BuiltinType::SatLongAccum:
12245 case BuiltinType::ShortFract:
12247 case BuiltinType::Fract:
12249 case BuiltinType::LongFract:
12251 case BuiltinType::SatShortFract:
12253 case BuiltinType::SatFract:
12255 case BuiltinType::SatLongFract:
12258 assert((
T->hasUnsignedIntegerRepresentation() ||
12259 T->isUnsignedFixedPointType()) &&
12260 "Unexpected signed integer or fixed point type");
12266 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12267 T->isFixedPointType()) &&
12268 "Unexpected type");
12273 VTy->getNumElements(), VTy->getVectorKind());
12281 if (
const auto *ED =
T->getAsEnumDecl())
12282 T = ED->getIntegerType();
12285 case BuiltinType::Char_S:
12287 case BuiltinType::Char_U:
12288 case BuiltinType::UChar:
12289 case BuiltinType::Char8:
12291 case BuiltinType::UShort:
12293 case BuiltinType::UInt:
12295 case BuiltinType::ULong:
12297 case BuiltinType::ULongLong:
12299 case BuiltinType::UInt128:
12304 case BuiltinType::WChar_U:
12307 case BuiltinType::UShortAccum:
12309 case BuiltinType::UAccum:
12311 case BuiltinType::ULongAccum:
12313 case BuiltinType::SatUShortAccum:
12315 case BuiltinType::SatUAccum:
12317 case BuiltinType::SatULongAccum:
12319 case BuiltinType::UShortFract:
12321 case BuiltinType::UFract:
12323 case BuiltinType::ULongFract:
12325 case BuiltinType::SatUShortFract:
12327 case BuiltinType::SatUFract:
12329 case BuiltinType::SatULongFract:
12333 (
T->hasSignedIntegerRepresentation() ||
T->isSignedFixedPointType()) &&
12334 "Unexpected signed integer or fixed point type");
12359 bool AllowTypeModifiers) {
12363 RequiresICE =
false;
12368 bool IsSpecial =
false;
12372 default: Done =
true; --Str;
break;
12374 RequiresICE =
true;
12377 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12378 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12382 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12383 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12387 assert(!IsSpecial &&
"Can't use 'L' with 'W', 'N', 'Z' or 'O' modifiers");
12388 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12393 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12394 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12398 if (Context.getTargetInfo().getLongWidth() == 32)
12403 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12404 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12408 switch (Context.getTargetInfo().getInt64Type()) {
12410 llvm_unreachable(
"Unexpected integer type");
12421 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12422 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12426 switch (Context.getTargetInfo().getIntTypeByWidth(32,
true)) {
12428 llvm_unreachable(
"Unexpected integer type");
12441 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12442 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12446 if (Context.getLangOpts().OpenCL)
12458 default: llvm_unreachable(
"Unknown builtin type letter!");
12461 "Bad modifiers used with 'x'!");
12462 Type = Context.Float16Ty;
12466 "Bad modifiers used with 'y'!");
12467 Type = Context.BFloat16Ty;
12471 "Bad modifiers used with 'v'!");
12472 Type = Context.VoidTy;
12476 "Bad modifiers used with 'h'!");
12477 Type = Context.HalfTy;
12481 "Bad modifiers used with 'f'!");
12482 Type = Context.FloatTy;
12486 "Bad modifiers used with 'd'!");
12488 Type = Context.LongDoubleTy;
12489 else if (HowLong == 2)
12490 Type = Context.Float128Ty;
12492 Type = Context.DoubleTy;
12495 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12497 Type = Context.UnsignedShortTy;
12499 Type = Context.ShortTy;
12503 Type =
Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
12504 else if (HowLong == 2)
12505 Type =
Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
12506 else if (HowLong == 1)
12507 Type =
Unsigned ? Context.UnsignedLongTy : Context.LongTy;
12509 Type =
Unsigned ? Context.UnsignedIntTy : Context.IntTy;
12512 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12514 Type = Context.SignedCharTy;
12516 Type = Context.UnsignedCharTy;
12518 Type = Context.CharTy;
12521 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12522 Type = Context.BoolTy;
12525 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12526 Type = Context.getSizeType();
12529 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12530 Type = Context.getWideCharType();
12533 Type = Context.getCFConstantStringType();
12536 Type = Context.getObjCIdType();
12539 Type = Context.getObjCSelType();
12542 Type = Context.getObjCSuperType();
12545 Type = Context.getBuiltinVaListType();
12546 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12557 Type = Context.getBuiltinVaListType();
12558 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12560 Type = Context.getArrayDecayedType(
Type);
12562 Type = Context.getLValueReferenceType(
Type);
12566 unsigned NumElements = strtoul(Str, &End, 10);
12567 assert(End != Str &&
"Missing vector size");
12571 RequiresICE,
false);
12572 assert(!RequiresICE &&
"Can't require vector ICE");
12574 Type = Context.getScalableVectorType(ElementType, NumElements);
12580 Type = Context.SveCountTy;
12584 Type = Context.AMDGPUBufferRsrcTy;
12588 llvm_unreachable(
"Unexpected target builtin type");
12594 unsigned NumElements = strtoul(Str, &End, 10);
12595 assert(End != Str &&
"Missing vector size");
12599 RequiresICE,
false);
12600 assert(!RequiresICE &&
"Can't require vector ICE");
12609 unsigned NumElements = strtoul(Str, &End, 10);
12610 assert(End != Str &&
"Missing vector size");
12616 Type = Context.getExtVectorType(ElementType, NumElements);
12622 assert(!RequiresICE &&
"Can't require complex ICE");
12623 Type = Context.getComplexType(ElementType);
12627 Type = Context.getPointerDiffType();
12630 Type = Context.getFILEType();
12631 if (
Type.isNull()) {
12638 Type = Context.getsigjmp_bufType();
12640 Type = Context.getjmp_bufType();
12642 if (
Type.isNull()) {
12648 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
12649 Type = Context.getucontext_tType();
12651 if (
Type.isNull()) {
12657 Type = Context.getProcessIDType();
12660 Type = Context.MFloat8Ty;
12665 Done = !AllowTypeModifiers;
12667 switch (
char c = *Str++) {
12668 default: Done =
true; --Str;
break;
12674 unsigned AddrSpace = strtoul(Str, &End, 10);
12677 Type = Context.getAddrSpaceQualType(
12679 Context.getLangASForBuiltinAddressSpace(AddrSpace));
12683 Type = Context.getPointerType(
Type);
12685 Type = Context.getLValueReferenceType(
Type);
12693 Type = Context.getVolatileType(
Type);
12702 "Integer constant 'I' type must be an integer");
12715 bool AllowTypeModifiers)
const {
12722 unsigned *IntegerConstantArgs)
const {
12723 const char *TypeStr =
BuiltinInfo.getTypeString(Id);
12724 if (TypeStr[0] ==
'\0') {
12731 bool RequiresICE =
false;
12734 RequiresICE,
true);
12738 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
12740 while (TypeStr[0] && TypeStr[0] !=
'.') {
12747 if (RequiresICE && IntegerConstantArgs)
12748 *IntegerConstantArgs |= 1 << ArgTypes.size();
12754 ArgTypes.push_back(Ty);
12757 if (Id == Builtin::BI__GetExceptionInfo)
12760 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
12761 "'.' should only occur at end of builtin type list!");
12763 bool Variadic = (TypeStr[0] ==
'.');
12770 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
12820 if ((!Context.getLangOpts().CPlusPlus &&
12821 !Context.getTargetInfo().getCXXABI().isMicrosoft() &&
12822 !FD->
hasAttr<DLLExportAttr>()) ||
12823 FD->
hasAttr<GNUInlineAttr>()) {
12841 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
12856 if (D->
hasAttr<DLLImportAttr>()) {
12859 }
else if (D->
hasAttr<DLLExportAttr>()) {
12862 }
else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice) {
12865 if (D->
hasAttr<CUDAGlobalAttr>() &&
12874 if (Context.shouldExternalize(D))
12889 switch (Source->hasExternalDefinitions(D)) {
12916 if (Context.getLangOpts().CPlusPlus &&
12917 Context.getLangOpts().IncrementalExtensions &&
12933 if (!LexicalContext)
12938 auto StaticLocalLinkage =
12950 return StaticLocalLinkage;
12956 if (Context.isMSStaticDataMemberInlineDefinition(VD))
12962 switch (Context.getInlineVariableDefinitionKind(VD)) {
12977 return StrongLinkage;
12980 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
12995 llvm_unreachable(
"Invalid Linkage!");
13005 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13006 if (!VD->isFileVarDecl())
13011 if (VD->getDescribedVarTemplate() ||
13014 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13040 if (D->
hasAttr<WeakRefAttr>())
13047 if (LangOpts.SYCLIsDevice)
13049 D->
hasAttr<SYCLExternalAttr>());
13055 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13057 if (!FD->doesThisDeclarationHaveABody())
13058 return FD->doesDeclarationForceExternallyVisibleDefinition();
13061 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13066 if (
getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
13067 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13086 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13090 if (LangOpts.OpenMP &&
13091 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13098 if (VD->shouldEmitInExternalSource())
13111 if (VD->needsDestruction(*
this))
13115 if (VD->hasInitWithSideEffects())
13120 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13121 for (
const auto *BD : DD->flat_bindings())
13122 if (
const auto *BindingVD = BD->getHoldingVar())
13132 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13133 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13134 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13139 for (
auto *CurDecl :
13143 SeenDecls.insert(CurFD).second) {
13150 bool IsCXXMethod)
const {
13153 return ABI->getDefaultMethodCallConv(IsVariadic);
13155 switch (LangOpts.getDefaultCallingConv()) {
13183 return Target->getDefaultCallingConv();
13188 return ABI->isNearlyEmpty(RD);
13193 auto ABI = Target->getCXXABI();
13194 if (ABI.isMicrosoft())
13197 auto ComponentLayout =
getLangOpts().RelativeCXXABIVTables
13203 return VTContext.get();
13209 switch (
T->getCXXABI().getKind()) {
13210 case TargetCXXABI::AppleARM64:
13211 case TargetCXXABI::Fuchsia:
13212 case TargetCXXABI::GenericAArch64:
13213 case TargetCXXABI::GenericItanium:
13214 case TargetCXXABI::GenericARM:
13215 case TargetCXXABI::GenericMIPS:
13216 case TargetCXXABI::iOS:
13217 case TargetCXXABI::WebAssembly:
13218 case TargetCXXABI::WatchOS:
13219 case TargetCXXABI::XL:
13221 case TargetCXXABI::Microsoft:
13224 llvm_unreachable(
"Unsupported ABI");
13228 assert(
T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13229 "Device mangle context does not support Microsoft mangling.");
13230 switch (
T.getCXXABI().getKind()) {
13231 case TargetCXXABI::AppleARM64:
13232 case TargetCXXABI::Fuchsia:
13233 case TargetCXXABI::GenericAArch64:
13234 case TargetCXXABI::GenericItanium:
13235 case TargetCXXABI::GenericARM:
13236 case TargetCXXABI::GenericMIPS:
13237 case TargetCXXABI::iOS:
13238 case TargetCXXABI::WebAssembly:
13239 case TargetCXXABI::WatchOS:
13240 case TargetCXXABI::XL:
13244 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13245 return RD->getDeviceLambdaManglingNumber();
13246 return std::nullopt;
13249 case TargetCXXABI::Microsoft:
13253 llvm_unreachable(
"Unsupported ABI");
13259 return ASTRecordLayouts.getMemorySize() +
13260 llvm::capacity_in_bytes(ObjCLayouts) +
13261 llvm::capacity_in_bytes(KeyFunctions) +
13262 llvm::capacity_in_bytes(ObjCImpls) +
13263 llvm::capacity_in_bytes(BlockVarCopyInits) +
13264 llvm::capacity_in_bytes(DeclAttrs) +
13265 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13266 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13267 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13268 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13269 llvm::capacity_in_bytes(OverriddenMethods) +
13270 llvm::capacity_in_bytes(Types) +
13271 llvm::capacity_in_bytes(VariableArrayTypes);
13279 unsigned Signed)
const {
13282 if (!QualTy && DestWidth == 128)
13311 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13318 MangleNumbers[ND] = Number;
13321 Listener->AddedManglingNumber(ND, Number);
13325 bool ForAuxTarget)
const {
13326 auto I = MangleNumbers.find(ND);
13327 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13330 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13331 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13333 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13334 "number for aux target");
13336 return Res > 1 ? Res : 1;
13343 StaticLocalNumbers[VD] = Number;
13346 Listener->AddedStaticLocalNumbers(VD, Number);
13350 auto I = StaticLocalNumbers.find(VD);
13351 return I != StaticLocalNumbers.end() ? I->second : 1;
13355 bool IsDestroying) {
13356 if (!IsDestroying) {
13368 bool IsTypeAware) {
13369 if (!IsTypeAware) {
13382 assert(LangOpts.CPlusPlus);
13383 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13391 assert(LangOpts.CPlusPlus);
13392 std::unique_ptr<MangleNumberingContext> &MCtx =
13393 ExtraMangleNumberingContexts[D];
13399std::unique_ptr<MangleNumberingContext>
13401 return ABI->createMangleNumberingContext();
13406 return ABI->getCopyConstructorForExceptionObject(
13412 return ABI->addCopyConstructorForExceptionObject(
13419 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13424 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13429 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13433 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13437 ParamIndices[D] =
index;
13441 ParameterIndexTable::const_iterator I = ParamIndices.find(D);
13442 assert(I != ParamIndices.end() &&
13443 "ParmIndices lacks entry set by ParmVarDecl");
13448 unsigned Length)
const {
13474 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13476 llvm::FoldingSetNodeID ID;
13480 if (
MSGuidDecl *Existing = MSGuidDecls.FindNodeOrInsertPos(ID, InsertPos))
13484 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
13485 MSGuidDecls.InsertNode(
New, InsertPos);
13491 const APValue &APVal)
const {
13492 llvm::FoldingSetNodeID ID;
13497 UnnamedGlobalConstantDecls.FindNodeOrInsertPos(ID, InsertPos))
13501 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
13502 UnnamedGlobalConstantDecls.InsertNode(
New, InsertPos);
13508 assert(
T->isRecordType() &&
"template param object of unexpected type");
13514 llvm::FoldingSetNodeID ID;
13519 TemplateParamObjectDecls.FindNodeOrInsertPos(ID, InsertPos))
13523 TemplateParamObjectDecls.InsertNode(
New, InsertPos);
13529 if (!
T.isOSDarwin())
13532 if (!(
T.isiOS() &&
T.isOSVersionLT(7)) &&
13533 !(
T.isMacOSX() &&
T.isOSVersionLT(10, 9)))
13542 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
13549 if (MethodDecl->
hasAttr<UnavailableAttr>()
13550 || MethodDecl->
hasAttr<DeprecatedAttr>())
13564 IM != EM && IF != EF; ++IM, ++IF) {
13595 llvm::FoldingSetNodeID IDX, IDY;
13596 X->Profile(IDX, *
this,
true);
13597 Y->
Profile(IDY, *
this,
true);
13611 for (
const Decl *DX :
X->redecls()) {
13616 if (DX->isFirstDecl())
13619 llvm_unreachable(
"Corrupt redecls chain");
13622template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
13624 return cast_or_null<T>(
13626 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
13629template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
13637 bool IgnoreDeduced =
false) {
13652 bool IgnoreDeduced) {
13660 assert(Xs.size() == Ys.size());
13662 for (
size_t I = 0; I < Rs.size(); ++I)
13669 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
13679 switch (
X.getKind()) {
13709 auto NExpX =
X.getNumTemplateExpansions();
13723 if (Xs.size() != Ys.size())
13725 R.resize(Xs.size());
13726 for (
size_t I = 0; I < R.size(); ++I) {
13739 assert(!Different);
13767 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
13769 return std::nullopt;
13774 assert(Kind == NNS2.
getKind());
13779 auto Kind = Namespace1->getKind();
13780 if (Kind != Namespace2->getKind() ||
13781 (Kind == Decl::NamespaceAlias &&
13786 Namespace2->getNamespace()),
13820 llvm_unreachable(
"singletons did not compare equal");
13828 const T *Y,
bool IsSame) {
13829 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
13842 QualType EX =
X->getElementType(), EY = Y->getElementType();
13851 QY += EY.getQualifiers() - RQ;
13863 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
13864 return X->getSizeExpr();
13869 return X->getSizeModifier();
13875 return X->getIndexTypeCVRQualifiers();
13885 llvm::DenseMap<QualType, unsigned>
Found;
13886 for (
auto Ts : {
X, Y}) {
13893 Out.emplace_back(
T);
13899FunctionProtoType::ExceptionSpecInfo
13903 bool AcceptDependent)
const {
13929 assert(AcceptDependent &&
13930 "computing composite pointer type of dependent types");
13945 llvm_unreachable(
"These ESTs should be handled above");
13950 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
13954 Result.Exceptions = ExceptionTypeStorage;
13961 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
13964 llvm_unreachable(
"invalid ExceptionSpecificationType");
13973#define UNEXPECTED_TYPE(Class, Kind) \
13974 case Type::Class: \
13975 llvm_unreachable("Unexpected " Kind ": " #Class);
13977#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
13978#define TYPE(Class, Base)
13979#include "clang/AST/TypeNodes.inc"
13981#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
13992#undef SUGAR_FREE_TYPE
13993#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
13996#undef NON_UNIQUE_TYPE
14000#undef UNEXPECTED_TYPE
14004 assert(AX->getDeducedType().isNull());
14005 assert(AY->getDeducedType().isNull());
14006 assert(AX->getKeyword() == AY->getKeyword());
14007 assert(AX->isInstantiationDependentType() ==
14008 AY->isInstantiationDependentType());
14010 AY->getTypeConstraintArguments());
14013 AX->containsUnexpandedParameterPack(),
14015 AY->getTypeConstraintConcept()),
14018 case Type::IncompleteArray: {
14025 case Type::DependentSizedArray: {
14033 case Type::ConstantArray: {
14036 assert(AX->getSize() == AY->getSize());
14037 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14038 ? AX->getSizeExpr()
14044 case Type::ArrayParameter: {
14047 assert(AX->getSize() == AY->getSize());
14048 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14049 ? AX->getSizeExpr()
14056 case Type::Atomic: {
14061 case Type::Complex: {
14065 case Type::Pointer: {
14069 case Type::BlockPointer: {
14073 case Type::ObjCObjectPointer: {
14078 case Type::MemberPointer: {
14082 PY->getMostRecentCXXRecordDecl()));
14086 PX->getMostRecentCXXRecordDecl());
14088 case Type::LValueReference: {
14093 PX->isSpelledAsLValue() ||
14094 PY->isSpelledAsLValue());
14096 case Type::RValueReference: {
14102 case Type::DependentAddressSpace: {
14105 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14107 PX->getAddrSpaceExpr(),
14110 case Type::FunctionNoProto: {
14113 assert(FX->getExtInfo() == FY->getExtInfo());
14118 case Type::FunctionProto: {
14122 EPIY = FY->getExtProtoInfo();
14123 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14130 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14131 assert(EPIX.
Variadic == EPIY.Variadic);
14140 auto P =
getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
14148 case Type::ObjCObject: {
14151 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14152 OY->getProtocols().begin(), OY->getProtocols().end(),
14154 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14156 "protocol lists must be the same");
14158 OY->getTypeArgsAsWritten());
14161 OX->getProtocols(),
14162 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14164 case Type::ConstantMatrix: {
14167 assert(MX->getNumRows() == MY->getNumRows());
14168 assert(MX->getNumColumns() == MY->getNumColumns());
14170 MX->getNumRows(), MX->getNumColumns());
14172 case Type::DependentSizedMatrix: {
14175 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14176 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14181 case Type::Vector: {
14183 assert(VX->getNumElements() == VY->getNumElements());
14184 assert(VX->getVectorKind() == VY->getVectorKind());
14186 VX->getNumElements(), VX->getVectorKind());
14188 case Type::ExtVector: {
14190 assert(VX->getNumElements() == VY->getNumElements());
14192 VX->getNumElements());
14194 case Type::DependentSizedExtVector: {
14201 case Type::DependentVector: {
14204 assert(VX->getVectorKind() == VY->getVectorKind());
14211 case Type::InjectedClassName: {
14219 case Type::TemplateSpecialization: {
14223 TY->template_arguments());
14227 TY->getTemplateName(),
14229 As, {},
X->getCanonicalTypeInternal());
14231 case Type::Decltype: {
14234 assert(DX->isDependentType());
14235 assert(DY->isDependentType());
14236 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14240 case Type::PackIndexing: {
14243 assert(DX->isDependentType());
14244 assert(DY->isDependentType());
14245 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14248 case Type::DependentName: {
14251 assert(NX->getIdentifier() == NY->getIdentifier());
14256 case Type::UnaryTransform: {
14259 assert(TX->getUTTKind() == TY->getUTTKind());
14263 TY->getUnderlyingType()),
14266 case Type::PackExpansion: {
14269 assert(PX->getNumExpansions() == PY->getNumExpansions());
14272 PX->getNumExpansions(),
false);
14276 assert(PX->isReadOnly() == PY->isReadOnly());
14281 case Type::TemplateTypeParm: {
14284 assert(TX->getDepth() == TY->getDepth());
14285 assert(TX->getIndex() == TY->getIndex());
14286 assert(TX->isParameterPack() == TY->isParameterPack());
14288 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14292 llvm_unreachable(
"Unknown Type Class");
14302#define UNEXPECTED_TYPE(Class, Kind) \
14303 case Type::Class: \
14304 llvm_unreachable("Unexpected " Kind ": " #Class);
14305#define TYPE(Class, Base)
14306#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14307#include "clang/AST/TypeNodes.inc"
14309#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14335#undef CANONICAL_TYPE
14337#undef UNEXPECTED_TYPE
14339 case Type::Adjusted: {
14341 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14348 case Type::Decayed: {
14350 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14357 case Type::Attributed: {
14359 AttributedType::Kind Kind = AX->getAttrKind();
14360 if (Kind != AY->getAttrKind())
14362 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14370 case Type::BTFTagAttributed: {
14372 const BTFTypeTagAttr *AX = BX->getAttr();
14374 if (AX->getBTFTypeTag() !=
14383 if (KW != AY->getKeyword())
14387 AY->getTypeConstraintConcept());
14391 AY->getTypeConstraintArguments())) {
14399 false,
false, CD, As);
14401 case Type::PackIndexing:
14402 case Type::Decltype:
14404 case Type::DeducedTemplateSpecialization:
14407 case Type::MacroQualified: {
14411 if (IX != MY->getMacroIdentifier())
14415 case Type::SubstTemplateTypeParm: {
14422 unsigned Index = SX->getIndex();
14423 if (Index != SY->getIndex())
14425 auto PackIndex = SX->getPackIndex();
14426 if (PackIndex != SY->getPackIndex())
14429 CD, Index, PackIndex,
14430 SX->getFinal() && SY->getFinal());
14432 case Type::ObjCTypeParam:
14438 case Type::TemplateSpecialization: {
14443 TY->getTemplateName(),
true);
14448 TY->template_arguments()))
14454 case Type::Typedef: {
14464 case Type::TypeOf: {
14475 case Type::TypeOfExpr:
14478 case Type::UnaryTransform: {
14481 UnaryTransformType::UTTKind KX = UX->getUTTKind();
14482 if (KX != UY->getUTTKind())
14484 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
14491 case Type::Using: {
14500 case Type::MemberPointer: {
14504 assert(Cls == PY->getMostRecentCXXRecordDecl());
14509 case Type::CountAttributed: {
14512 if (DX->isCountInBytes() != DY->isCountInBytes())
14514 if (DX->isOrNull() != DY->isOrNull())
14516 Expr *CEX = DX->getCountExpr();
14517 Expr *CEY = DY->getCountExpr();
14521 DX->isCountInBytes(), DX->isOrNull(),
14532 DX->isCountInBytes(), DX->isOrNull(),
14535 case Type::PredefinedSugar:
14540 llvm_unreachable(
"Unhandled Type Class");
14547 QualType NT =
T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
14562 if (
X.isCanonical())
14591 if (SX.
Ty != SY.Ty) {
14599 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
14602 SX = Xs.pop_back_val();
14603 SY = Ys.pop_back_val();
14606 if (KeepCommonQualifiers)
14613 while (!Xs.empty() && !Ys.empty()) {
14616 SX = Xs.pop_back_val();
14617 SY = Ys.pop_back_val();
14622 SX.
Ty = Underlying.Ty;
14625 QX -= Underlying.Quals;
14643 llvm_unreachable(
"Not a saturated fixed point type!");
14644 case BuiltinType::SatShortAccum:
14646 case BuiltinType::SatAccum:
14648 case BuiltinType::SatLongAccum:
14650 case BuiltinType::SatUShortAccum:
14652 case BuiltinType::SatUAccum:
14654 case BuiltinType::SatULongAccum:
14656 case BuiltinType::SatShortFract:
14658 case BuiltinType::SatFract:
14660 case BuiltinType::SatLongFract:
14662 case BuiltinType::SatUShortFract:
14664 case BuiltinType::SatUFract:
14666 case BuiltinType::SatULongFract:
14678 llvm_unreachable(
"Not a fixed point type!");
14679 case BuiltinType::ShortAccum:
14681 case BuiltinType::Accum:
14683 case BuiltinType::LongAccum:
14685 case BuiltinType::UShortAccum:
14687 case BuiltinType::UAccum:
14689 case BuiltinType::ULongAccum:
14691 case BuiltinType::ShortFract:
14693 case BuiltinType::Fract:
14695 case BuiltinType::LongFract:
14697 case BuiltinType::UShortFract:
14699 case BuiltinType::UFract:
14701 case BuiltinType::ULongFract:
14707 if (LangOpts.OpenCL)
14731 llvm_unreachable(
"Not a fixed point type!");
14732 case BuiltinType::ShortAccum:
14733 case BuiltinType::SatShortAccum:
14734 return Target.getShortAccumScale();
14735 case BuiltinType::Accum:
14736 case BuiltinType::SatAccum:
14737 return Target.getAccumScale();
14738 case BuiltinType::LongAccum:
14739 case BuiltinType::SatLongAccum:
14740 return Target.getLongAccumScale();
14741 case BuiltinType::UShortAccum:
14742 case BuiltinType::SatUShortAccum:
14743 return Target.getUnsignedShortAccumScale();
14744 case BuiltinType::UAccum:
14745 case BuiltinType::SatUAccum:
14746 return Target.getUnsignedAccumScale();
14747 case BuiltinType::ULongAccum:
14748 case BuiltinType::SatULongAccum:
14749 return Target.getUnsignedLongAccumScale();
14750 case BuiltinType::ShortFract:
14751 case BuiltinType::SatShortFract:
14752 return Target.getShortFractScale();
14753 case BuiltinType::Fract:
14754 case BuiltinType::SatFract:
14755 return Target.getFractScale();
14756 case BuiltinType::LongFract:
14757 case BuiltinType::SatLongFract:
14758 return Target.getLongFractScale();
14759 case BuiltinType::UShortFract:
14760 case BuiltinType::SatUShortFract:
14761 return Target.getUnsignedShortFractScale();
14762 case BuiltinType::UFract:
14763 case BuiltinType::SatUFract:
14764 return Target.getUnsignedFractScale();
14765 case BuiltinType::ULongFract:
14766 case BuiltinType::SatULongFract:
14767 return Target.getUnsignedLongFractScale();
14777 llvm_unreachable(
"Not a fixed point type!");
14778 case BuiltinType::ShortAccum:
14779 case BuiltinType::SatShortAccum:
14780 return Target.getShortAccumIBits();
14781 case BuiltinType::Accum:
14782 case BuiltinType::SatAccum:
14783 return Target.getAccumIBits();
14784 case BuiltinType::LongAccum:
14785 case BuiltinType::SatLongAccum:
14786 return Target.getLongAccumIBits();
14787 case BuiltinType::UShortAccum:
14788 case BuiltinType::SatUShortAccum:
14789 return Target.getUnsignedShortAccumIBits();
14790 case BuiltinType::UAccum:
14791 case BuiltinType::SatUAccum:
14792 return Target.getUnsignedAccumIBits();
14793 case BuiltinType::ULongAccum:
14794 case BuiltinType::SatULongAccum:
14795 return Target.getUnsignedLongAccumIBits();
14796 case BuiltinType::ShortFract:
14797 case BuiltinType::SatShortFract:
14798 case BuiltinType::Fract:
14799 case BuiltinType::SatFract:
14800 case BuiltinType::LongFract:
14801 case BuiltinType::SatLongFract:
14802 case BuiltinType::UShortFract:
14803 case BuiltinType::SatUShortFract:
14804 case BuiltinType::UFract:
14805 case BuiltinType::SatUFract:
14806 case BuiltinType::ULongFract:
14807 case BuiltinType::SatULongFract:
14812llvm::FixedPointSemantics
14815 "Can only get the fixed point semantics for a "
14816 "fixed point or integer type.");
14818 return llvm::FixedPointSemantics::GetIntegerSemantics(
14822 return llvm::FixedPointSemantics(
14825 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
14840 "Expected unsigned fixed point type");
14843 case BuiltinType::UShortAccum:
14845 case BuiltinType::UAccum:
14847 case BuiltinType::ULongAccum:
14849 case BuiltinType::SatUShortAccum:
14851 case BuiltinType::SatUAccum:
14853 case BuiltinType::SatULongAccum:
14855 case BuiltinType::UShortFract:
14857 case BuiltinType::UFract:
14859 case BuiltinType::ULongFract:
14861 case BuiltinType::SatUShortFract:
14863 case BuiltinType::SatUFract:
14865 case BuiltinType::SatULongFract:
14868 llvm_unreachable(
"Unexpected unsigned fixed point type");
14876 std::vector<std::string> BackendFeats;
14877 llvm::AArch64::ExtensionSet FeatureBits;
14878 for (StringRef F : FMVFeatStrings)
14879 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
14881 FeatureBits.enable(*FMVExt->ID);
14882 FeatureBits.toLLVMFeatureList(BackendFeats);
14883 return BackendFeats;
14888 assert(TD !=
nullptr);
14891 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
14892 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
14903 Target->getTargetOpts().CPU,
14904 Target->getTargetOpts().Features);
14911 StringRef TargetCPU = Target->getTargetOpts().CPU;
14913 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
14919 if (!Target->getTriple().isAArch64())
14922 Target->getTargetOpts().FeaturesAsWritten.begin(),
14923 Target->getTargetOpts().FeaturesAsWritten.end());
14934 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
14936 Target->getCPUSpecificCPUDispatchFeatures(
14938 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
14939 Features.insert(Features.begin(),
14940 Target->getTargetOpts().FeaturesAsWritten.begin(),
14941 Target->getTargetOpts().FeaturesAsWritten.end());
14942 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
14943 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
14944 if (Target->getTriple().isAArch64()) {
14948 Features.insert(Features.begin(),
14949 Target->getTargetOpts().FeaturesAsWritten.begin(),
14950 Target->getTargetOpts().FeaturesAsWritten.end());
14951 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
14952 }
else if (Target->getTriple().isRISCV()) {
14954 std::vector<std::string> Features;
14955 if (VersionStr !=
"default") {
14957 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
14960 Features.insert(Features.begin(),
14961 Target->getTargetOpts().FeaturesAsWritten.begin(),
14962 Target->getTargetOpts().FeaturesAsWritten.end());
14963 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
14965 std::vector<std::string> Features;
14967 if (VersionStr.starts_with(
"arch="))
14968 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
14969 else if (VersionStr !=
"default")
14970 Features.push_back((StringRef{
"+"} + VersionStr).str());
14971 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
14973 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
14974 std::vector<std::string> Features;
14975 if (Target->getTriple().isRISCV()) {
14977 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
14980 assert(Target->getTriple().isAArch64());
14982 TV->getFeatures(Feats);
14985 Features.insert(Features.begin(),
14986 Target->getTargetOpts().FeaturesAsWritten.begin(),
14987 Target->getTargetOpts().FeaturesAsWritten.end());
14988 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
14990 FeatureMap = Target->getTargetOpts().FeatureMap;
15001 auto DeviceDiscriminatorOverrider =
15003 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15005 return RD->getDeviceLambdaManglingNumber();
15006 return std::nullopt;
15009 Context, Context.getDiagnostics(), DeviceDiscriminatorOverrider)};
15017 std::string Buffer;
15018 Buffer.reserve(128);
15019 llvm::raw_string_ostream Out(Buffer);
15020 MC->mangleCanonicalTypeName(KernelNameType, Out);
15021 std::string KernelName = Out.str();
15023 return {KernelNameType, FD, KernelName};
15032 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15033 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15042 "SYCL kernel name conflict");
15057 return &IT->second;
15063 return *OMPTraitInfoVector.back();
15070 return DB << Section.
Decl;
15071 return DB <<
"a prior #pragma section";
15075 bool IsInternalVar =
15078 bool IsExplicitDeviceVar = (D->
hasAttr<CUDADeviceAttr>() &&
15079 !D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15080 (D->
hasAttr<CUDAConstantAttr>() &&
15081 !D->
getAttr<CUDAConstantAttr>()->isImplicit());
15085 return (IsInternalVar &&
15086 (D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15087 (D->
hasAttr<CUDAGlobalAttr>() &&
15094 (D->
hasAttr<HIPManagedAttr>() || D->
hasAttr<CUDAGlobalAttr>() ||
15099 if (!CUIDHash.empty())
15101 if (LangOpts.CUID.empty())
15102 return StringRef();
15103 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.CUID),
true);
15113 assert(PrimaryBase);
15116 auto Base = Layout.getPrimaryBase();
15117 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15119 PrimaryBase =
Base;
15121 return PrimaryBase;
15125 StringRef MangledName) {
15127 assert(
Method->isVirtual());
15128 bool DefaultIncludesPointerAuth =
15129 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15131 if (!DefaultIncludesPointerAuth)
15134 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15135 if (Existing != ThunksToBeAbbreviated.end())
15136 return Existing->second.contains(MangledName.str());
15139 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15141 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15143 for (
const auto &Thunk : *ThunkInfos) {
15145 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15151 Mangler->mangleThunk(
Method, Thunk,
true,
15154 llvm::raw_svector_ostream mangledNameStream(MangledName);
15158 mangledNameStream);
15160 Mangler->mangleThunk(
Method, Thunk,
false,
15161 mangledNameStream);
15163 Thunks[ElidedName].push_back(std::string(MangledName));
15166 llvm::StringSet<> SimplifiedThunkNames;
15167 for (
auto &ThunkList : Thunks) {
15168 llvm::sort(ThunkList.second);
15169 SimplifiedThunkNames.insert(ThunkList.second[0]);
15171 bool Result = SimplifiedThunkNames.contains(MangledName);
15172 ThunksToBeAbbreviated[VirtualMethodDecl] = std::move(SimplifiedThunkNames);
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 const TemplateArgument * getDefaultTemplateArgumentOrNone(const NamedDecl *P)
static QualType getCommonArrayElementType(const ASTContext &Ctx, const T *X, Qualifiers &QX, const T *Y, Qualifiers &QY)
#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 bool hasSameCudaAttrs(const FunctionDecl *A, const FunctionDecl *B)
static const Decl & adjustDeclToTemplate(const Decl &D)
If we have a 'templated' declaration for a template, adjust 'D' to refer to the actual template.
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 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 std::string charUnitsToString(const CharUnits &CU)
static const TagDecl * getNonInjectedClassName(const TagDecl *TD)
static bool hasAnyPackExpansions(ArrayRef< TemplateArgument > Args)
static char ObjCEncodingForEnumDecl(const ASTContext *C, const EnumDecl *ED)
static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod, SmallVectorImpl< const NamedDecl * > &Redeclared)
static SmallVector< SourceLocation, 2 > getDeclLocsForCommentSearch(const Decl *D, SourceManager &SourceMgr)
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)
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::Record Record
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.
Defines types useful for describing an Objective-C runtime.
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.
__device__ __2f16 float c
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
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>
RawComment * getRawCommentForDeclNoCacheImpl(const Decl *D, const SourceLocation RepresentativeLocForDecl, const std::map< unsigned, RawComment * > &CommentsInFile) const
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.
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
MemberSpecializationInfo * getInstantiatedFromStaticDataMember(const VarDecl *Var)
If this variable is an instantiated static data member of a class template specialization,...
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.
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...
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 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.
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.
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
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.
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.
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,...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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 hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
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...
CanQualType UnsignedLongFractTy
QualType mergeTagDefinitions(QualType, QualType)
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
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
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 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...
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.
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 cacheRawCommentForDecl(const Decl &OriginalD, const RawComment &Comment) const
Attaches Comment to OriginalD and to its redeclaration chain and removes the redeclaration chain from...
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.
void eraseDeclAttrs(const Decl *D)
Erase the attributes corresponding to the given declaration.
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
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
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
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
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
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 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.
llvm::DenseSet< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
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
unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const
Return the alignment in bits that should be given to a global variable with type T.
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.
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.
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.
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
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...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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)
llvm::DenseMap< const Decl *, const RawComment * > DeclRawComments
Mapping from declaration to directly attached comment.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
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
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...
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
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.
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 ...
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
RawComment * getRawCommentForDeclNoCache(const Decl *D) const
Return the documentation comment attached to a given declaration, without looking into cache.
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 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.
DiagnosticsEngine & getDiagnostics() const
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
interp::Context & getInterpContext()
Returns the clang bytecode interpreter context.
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)
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.
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
QualType getDeducedTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
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.
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
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.
uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE) const
Return number of elements initialized in an ArrayInitLoopExpr.
unsigned getTargetAddressSpace(LangAS AS) const
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
InlineVariableDefinitionKind getInlineVariableDefinitionKind(const VarDecl *VD) const
Determine whether a definition of this inline variable should be treated as a weak or strong definiti...
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>.
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers in instanc...
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...
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.
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 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)
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
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.
AttrVec & getDeclAttrs(const Decl *D)
Retrieve the attributes for the given declaration.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
RawComment * getRawCommentForDeclNoCacheImpl(const Decl *D, const SourceLocation RepresentativeLocForDecl, const std::map< unsigned, RawComment * > &CommentsInFile) const
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)
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/...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
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 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.
void Profile(llvm::FoldingSetNodeID &ID)
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,...
void Profile(llvm::FoldingSetNodeID &ID)
Attr - This represents one attribute.
A fixed int type of a specified bitwidth.
void Profile(llvm::FoldingSetNodeID &ID) const
unsigned getNumBits() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
void Profile(llvm::FoldingSetNodeID &ID)
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'.
StringRef getName(const PrintingPolicy &Policy) const
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Implements C++ ABI-specific semantic analysis functions.
Represents a C++ constructor 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.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isPositive() const
isPositive - Test whether the quantity is greater than zero.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Declaration of a class template.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this.
Complex values, per C99 6.2.5p11.
void Profile(llvm::FoldingSetNodeID &ID)
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.
static constexpr bool isDimensionValid(size_t NumElements)
Returns true if NumElements is a valid matrix dimension.
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.
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
SourceLocation getLocation() const
void setImplicit(bool I=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
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.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
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.
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
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.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
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.
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.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
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.
virtual void CompleteRedeclChain(const Decl *D)
Gives the external AST source an opportunity to complete the redeclaration chain for a declaration.
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.
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.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
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)
@ Relative
Components in the vtable are relative offsets between the vtable and the other structs/functions.
@ Pointer
Components in the vtable are pointers to other structs/functions.
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.
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
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...
QualType getElementType() const
Returns type of the elements being stored in the matrix.
static bool isValidElementType(QualType T)
Valid elements types are the following:
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
bool isCanonical() const
Whether this nested name specifier is canonical.
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, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
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.
void Profile(llvm::FoldingSetNodeID &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...
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
Sugar for parentheses used when specifying types.
void Profile(llvm::FoldingSetNodeID &ID)
void clear()
Clear parent maps.
Represents a parameter to a function.
ObjCDeclQualifier getObjCDeclQualifier() const
QualType getOriginalType() const
ParsedAttr - Represents a syntactic attribute.
void Profile(llvm::FoldingSetNodeID &ID)
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
void Profile(llvm::FoldingSetNodeID &ID)
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
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
void Profile(llvm::FoldingSetNodeID &ID)
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.
TargetOptions & getTargetOpts() const
Retrieve the target options.
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
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
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...
llvm::StringMap< bool > FeatureMap
The map of which features have been enabled disabled based on the command line.
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.
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.
@ 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.
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.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
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.
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, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
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,...
TemplateDecl * 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
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,...
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
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 isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
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 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
std::optional< NullabilityKind > 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)
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.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
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,...
The JSON file list parser is used to communicate input to InstallAPI.
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.
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.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
CXXABI * CreateItaniumCXXABI(ASTContext &Ctx)
Creates an instance of a C++ ABI class.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
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.
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
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.
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.
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
@ RVVFixedLengthData
is RISC-V RVV fixed-length data vector
@ RVVFixedLengthMask
is RISC-V RVV fixed-length mask vector
@ SveFixedLengthPredicate
is AArch64 SVE fixed-length predicate vector
U cast(CodeGen::Address addr)
LangAS getLangASFromTargetAS(unsigned TargetAS)
@ 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.
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)
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 lazy value (of type T) that is within an AST node of type Owner, where the value might change in la...
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