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;
117template <>
struct llvm::DenseMapInfo<
llvm::FoldingSetNodeID> {
118 static FoldingSetNodeID
getEmptyKey() {
return FoldingSetNodeID{}; }
122 for (
size_t i = 0; i <
sizeof(id) /
sizeof(
unsigned); ++i) {
123 id.AddInteger(std::numeric_limits<unsigned>::max());
129 return Val.ComputeHash();
132 static bool isEqual(
const FoldingSetNodeID &LHS,
133 const FoldingSetNodeID &RHS) {
149 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
154 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
155 if (VD->isStaticDataMember() &&
160 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(
D)) {
165 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(
D)) {
172 if (
const auto *ED = dyn_cast<EnumDecl>(
D)) {
176 if (
const auto *TD = dyn_cast<TagDecl>(
D)) {
179 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
183 if (isa<ParmVarDecl>(
D))
188 if (isa<TemplateTypeParmDecl>(
D) ||
189 isa<NonTypeTemplateParmDecl>(
D) ||
190 isa<TemplateTemplateParmDecl>(
D))
201 if (isa<ObjCMethodDecl>(
D) || isa<ObjCContainerDecl>(
D) ||
202 isa<ObjCPropertyDecl>(
D) || isa<RedeclarableTemplateDecl>(
D) ||
203 isa<ClassTemplateSpecializationDecl>(
D) ||
211 Locations.emplace_back(BaseLocation);
239 const std::map<unsigned, RawComment *> &CommentsInTheFile)
const {
242 if (RepresentativeLocForDecl.
isInvalid() ||
243 !RepresentativeLocForDecl.
isFileID())
247 if (CommentsInTheFile.empty())
256 auto OffsetCommentBehindDecl =
257 CommentsInTheFile.lower_bound(DeclLocDecomp.second);
260 if (OffsetCommentBehindDecl != CommentsInTheFile.end()) {
261 RawComment *CommentBehindDecl = OffsetCommentBehindDecl->second;
265 (isa<FieldDecl>(
D) || isa<EnumConstantDecl>(
D) || isa<VarDecl>(
D) ||
266 isa<ObjCMethodDecl>(
D) || isa<ObjCPropertyDecl>(
D))) {
270 if (SourceMgr.
getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second) ==
272 OffsetCommentBehindDecl->first)) {
273 return CommentBehindDecl;
280 if (OffsetCommentBehindDecl == CommentsInTheFile.begin())
283 auto OffsetCommentBeforeDecl = --OffsetCommentBehindDecl;
284 RawComment *CommentBeforeDecl = OffsetCommentBeforeDecl->second;
293 const unsigned CommentEndOffset =
298 const char *Buffer = SourceMgr.
getBufferData(DeclLocDecomp.first,
304 StringRef
Text(Buffer + CommentEndOffset,
305 DeclLocDecomp.second - CommentEndOffset);
309 if (
Text.find_last_of(
";{}#@") != StringRef::npos)
312 return CommentBeforeDecl;
318 for (
const auto DeclLoc : DeclLocs) {
321 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
337 if (!CommentsInThisFile || CommentsInThisFile->empty())
349 assert(LangOpts.RetainCommentsFromSystemHeaders ||
358 if (
const auto *FD = dyn_cast<FunctionDecl>(&
D)) {
378 if (
const auto *VD = dyn_cast<VarDecl>(&
D)) {
381 if (VD->isStaticDataMember())
387 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(&
D)) {
394 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(CRD)) {
400 return isa<ClassTemplateDecl *>(PU)
401 ? *
static_cast<const Decl *
>(cast<ClassTemplateDecl *>(PU))
402 : *
static_cast<const Decl *
>(
403 cast<ClassTemplatePartialSpecializationDecl *>(PU));
408 CRD->getMemberSpecializationInfo())
409 return *Info->getInstantiatedFrom();
413 if (
const auto *ED = dyn_cast<EnumDecl>(&
D)) {
426 const Decl **OriginalDecl)
const {
429 OriginalDecl =
nullptr;
441 return DeclComment->second;
454 *OriginalDecl = RedeclComment->second;
457 "This decl is supposed to have comment attached.");
458 return CommentAtRedecl->second;
463 const Decl *LastCheckedRedecl = [&]() {
465 bool CanUseCommentlessCache =
false;
467 for (
auto *Redecl : CanonicalD->
redecls()) {
469 CanUseCommentlessCache =
true;
472 if (Redecl == LastChecked)
479 return CanUseCommentlessCache ? LastChecked :
nullptr;
485 if (LastCheckedRedecl) {
486 if (LastCheckedRedecl == Redecl) {
487 LastCheckedRedecl =
nullptr;
495 *OriginalDecl = Redecl;
496 return RedeclComment;
502 *OriginalDecl =
nullptr;
518 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(DC)) {
523 for (
const auto *Ext : ID->known_extensions()) {
527 Redeclared.push_back(RedeclaredMethod);
538 for (
const Decl *
D : Decls) {
552 if (
File.isInvalid())
556 if (!CommentsInThisFile || CommentsInThisFile->empty() ||
557 CommentsInThisFile->rbegin()->second->isAttached())
567 for (
const Decl *
D : Decls) {
579 for (
const auto DeclLoc : DeclLocs) {
580 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
584 D, DeclLoc, *CommentsInThisFile)) {
595 const Decl *
D)
const {
598 ThisDeclInfo->IsFilled =
false;
599 ThisDeclInfo->fill();
600 ThisDeclInfo->CommentDecl = FC->
getDecl();
601 if (!ThisDeclInfo->TemplateParameters)
611 return RC ? RC->
parse(*
this,
nullptr,
D) :
nullptr;
622 llvm::DenseMap<const Decl *, comments::FullComment *>::iterator Pos =
626 if (Canonical !=
D) {
634 const Decl *OriginalDecl =
nullptr;
638 if (isa<ObjCMethodDecl>(
D) || isa<FunctionDecl>(
D)) {
640 const auto *OMD = dyn_cast<ObjCMethodDecl>(
D);
641 if (OMD && OMD->isPropertyAccessor())
648 for (
unsigned i = 0, e = Overridden.size(); i < e; i++)
652 else if (
const auto *TD = dyn_cast<TypedefNameDecl>(
D)) {
655 QualType QT = TD->getUnderlyingType();
661 else if (
const auto *IC = dyn_cast<ObjCInterfaceDecl>(
D)) {
662 while (IC->getSuperClass()) {
663 IC = IC->getSuperClass();
668 else if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(
D)) {
673 else if (
const auto *RD = dyn_cast<CXXRecordDecl>(
D)) {
674 if (!(RD = RD->getDefinition()))
677 for (
const auto &I : RD->bases()) {
678 if (I.isVirtual() || (I.getAccessSpecifier() !=
AS_public))
692 for (
const auto &I : RD->vbases()) {
713 if (
D != OriginalDecl && OriginalDecl)
721void ASTContext::CanonicalTemplateTemplateParm::Profile(
730 ID.AddInteger(Params->
size());
732 PEnd = Params->
end();
734 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*
P)) {
736 ID.AddBoolean(TTP->isParameterPack());
738 TTP->getNumExpansionParameters().toInternalRepresentation());
742 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
744 ID.AddBoolean(NTTP->isParameterPack());
745 ID.AddPointer(
C.getUnconstrainedType(
C.getCanonicalType(NTTP->getType()))
747 if (NTTP->isExpandedParameterPack()) {
749 ID.AddInteger(NTTP->getNumExpansionTypes());
750 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
752 ID.AddPointer(
T.getCanonicalType().getAsOpaquePtr());
755 ID.AddBoolean(
false);
759 auto *TTP = cast<TemplateTemplateParmDecl>(*
P);
769 llvm::FoldingSetNodeID ID;
770 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
771 void *InsertPos =
nullptr;
772 CanonicalTemplateTemplateParm *Canonical
773 = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
775 return Canonical->getParam();
780 CanonParams.reserve(Params->
size());
782 PEnd = Params->
end();
786 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*
P)) {
791 TTP->getNumExpansionParameters());
792 CanonParams.push_back(NewTTP);
793 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
797 if (NTTP->isExpandedParameterPack()) {
800 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
802 ExpandedTInfos.push_back(
810 NTTP->getPosition(),
nullptr,
820 NTTP->getPosition(),
nullptr,
822 NTTP->isParameterPack(),
825 CanonParams.push_back(Param);
828 cast<TemplateTemplateParmDecl>(*
P)));
841 Canonical = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
842 assert(!Canonical &&
"Shouldn't be in the map!");
846 Canonical =
new (*this) CanonicalTemplateTemplateParm(CanonTTP);
847 CanonTemplateTemplateParms.InsertNode(Canonical, InsertPos);
854 llvm::FoldingSetNodeID ID;
855 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
856 void *InsertPos =
nullptr;
857 CanonicalTemplateTemplateParm *Canonical =
858 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
859 return Canonical ? Canonical->getParam() :
nullptr;
865 llvm::FoldingSetNodeID ID;
866 CanonicalTemplateTemplateParm::Profile(ID, *
this, CanonTTP);
867 void *InsertPos =
nullptr;
869 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos))
870 return Existing->getParam();
871 CanonTemplateTemplateParms.InsertNode(
872 new (*
this) CanonicalTemplateTemplateParm(CanonTTP), InsertPos);
881 return NoSanitizeL->containsType(Mask, TyName);
890 if (!LangOpts.CPlusPlus)
return nullptr;
893 case TargetCXXABI::AppleARM64:
894 case TargetCXXABI::Fuchsia:
895 case TargetCXXABI::GenericARM:
896 case TargetCXXABI::iOS:
897 case TargetCXXABI::WatchOS:
898 case TargetCXXABI::GenericAArch64:
899 case TargetCXXABI::GenericMIPS:
900 case TargetCXXABI::GenericItanium:
901 case TargetCXXABI::WebAssembly:
902 case TargetCXXABI::XL:
904 case TargetCXXABI::Microsoft:
907 llvm_unreachable(
"Invalid CXXABI type!");
911 if (!InterpContext) {
914 return *InterpContext;
920 return *ParentMapCtx;
925 switch (LangOpts.getAddressSpaceMapMangling()) {
933 llvm_unreachable(
"getAddressSpaceMapMangling() doesn't cover anything.");
939 : ConstantArrayTypes(this_(), ConstantArrayTypesLog2InitSize),
940 DependentSizedArrayTypes(this_()), DependentSizedExtVectorTypes(this_()),
941 DependentAddressSpaceTypes(this_()), DependentVectorTypes(this_()),
942 DependentSizedMatrixTypes(this_()),
943 FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
944 DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
945 DependentPackIndexingTypes(this_()), TemplateSpecializationTypes(this_()),
946 DependentBitIntTypes(this_()), SubstTemplateTemplateParmPacks(this_()),
947 DeducedTemplates(this_()), ArrayParameterTypes(this_()),
948 CanonTemplateTemplateParms(this_()), SourceMgr(
SM), LangOpts(LOpts),
951 LangOpts.XRayNeverInstrumentFiles,
952 LangOpts.XRayAttrListFiles,
SM)),
955 BuiltinInfo(builtins), TUKind(TUKind), DeclarationNames(*this),
956 Comments(
SM), CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
957 CompCategories(this_()), LastSDM(nullptr, 0) {
964 ReleaseDeclContextMaps();
967 for (
auto &Pair : Deallocations)
968 (Pair.first)(Pair.second);
969 Deallocations.clear();
975 I = ObjCLayouts.begin(),
976 E = ObjCLayouts.end();
983 for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
984 I = ASTRecordLayouts.begin(),
E = ASTRecordLayouts.end(); I !=
E; ) {
989 ASTRecordLayouts.clear();
991 for (llvm::DenseMap<const Decl*, AttrVec*>::iterator A = DeclAttrs.begin(),
992 AEnd = DeclAttrs.end();
994 A->second->~AttrVec();
997 for (
const auto &
Value : ModuleInitializers)
998 Value.second->~PerModuleInitializers();
999 ModuleInitializers.
clear();
1005 TraversalScope = TopLevelDecls;
1010 Deallocations.push_back({Callback,
Data});
1019 llvm::errs() <<
"\n*** AST Context Stats:\n";
1020 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
1022 unsigned counts[] = {
1023#define TYPE(Name, Parent) 0,
1024#define ABSTRACT_TYPE(Name, Parent)
1025#include "clang/AST/TypeNodes.inc"
1029 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
1035 unsigned TotalBytes = 0;
1036#define TYPE(Name, Parent) \
1038 llvm::errs() << " " << counts[Idx] << " " << #Name \
1039 << " types, " << sizeof(Name##Type) << " each " \
1040 << "(" << counts[Idx] * sizeof(Name##Type) \
1042 TotalBytes += counts[Idx] * sizeof(Name##Type); \
1044#define ABSTRACT_TYPE(Name, Parent)
1045#include "clang/AST/TypeNodes.inc"
1047 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
1052 <<
" implicit default constructors created\n";
1055 <<
" implicit copy constructors created\n";
1059 <<
" implicit move constructors created\n";
1062 <<
" implicit copy assignment operators created\n";
1066 <<
" implicit move assignment operators created\n";
1069 <<
" implicit destructors created\n";
1072 llvm::errs() <<
"\n";
1076 BumpAlloc.PrintStats();
1080 bool NotifyListeners) {
1081 if (NotifyListeners)
1091 if (It == MergedDefModules.end())
1094 auto &Merged = It->second;
1095 llvm::DenseSet<Module*>
Found;
1096 for (
Module *&M : Merged)
1097 if (!
Found.insert(M).second)
1099 llvm::erase(Merged,
nullptr);
1106 if (MergedIt == MergedDefModules.end())
1108 return MergedIt->second;
1111void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1112 if (LazyInitializers.empty())
1116 assert(Source &&
"lazy initializers but no external source");
1118 auto LazyInits = std::move(LazyInitializers);
1119 LazyInitializers.clear();
1121 for (
auto ID : LazyInits)
1122 Initializers.push_back(Source->GetExternalDecl(ID));
1124 assert(LazyInitializers.empty() &&
1125 "GetExternalDecl for lazy module initializer added more inits");
1131 if (
const auto *ID = dyn_cast<ImportDecl>(
D)) {
1132 auto It = ModuleInitializers.find(ID->getImportedModule());
1135 if (It == ModuleInitializers.end())
1139 auto &Imported = *It->second;
1140 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1141 Imported.resolve(*
this);
1142 auto *OnlyDecl = Imported.Initializers.front();
1143 if (isa<ImportDecl>(OnlyDecl))
1148 auto *&Inits = ModuleInitializers[M];
1150 Inits =
new (*this) PerModuleInitializers;
1151 Inits->Initializers.push_back(
D);
1156 auto *&Inits = ModuleInitializers[M];
1158 Inits =
new (*this) PerModuleInitializers;
1159 Inits->LazyInitializers.insert(Inits->LazyInitializers.end(),
1160 IDs.begin(), IDs.end());
1164 auto It = ModuleInitializers.find(M);
1165 if (It == ModuleInitializers.end())
1168 auto *Inits = It->second;
1169 Inits->resolve(*
this);
1170 return Inits->Initializers;
1175 assert(!CurrentCXXNamedModule &&
1176 "We should set named module for ASTContext for only once");
1177 CurrentCXXNamedModule = M;
1189 auto GetRepresentativeModule = [
this](
const Module *M) {
1190 auto Iter = SameModuleLookupSet.find(M);
1191 if (
Iter != SameModuleLookupSet.end())
1192 return Iter->second;
1194 const Module *RepresentativeModule =
1195 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1197 SameModuleLookupSet[M] = RepresentativeModule;
1198 return RepresentativeModule;
1201 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1202 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1206 if (!ExternCContext)
1209 return ExternCContext;
1223#define BuiltinTemplate(BTName) \
1224 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1225 if (!Decl##BTName) \
1227 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1228 return Decl##BTName; \
1230#include "clang/Basic/BuiltinTemplates.inc"
1243 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1244 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1249 StringRef Name)
const {
1273 Types.push_back(Ty);
1278 assert((!this->Target || this->Target == &
Target) &&
1279 "Incorrect target reinitialization");
1283 this->AuxTarget = AuxTarget;
1285 ABI.reset(createCXXABI(
Target));
1289 InitBuiltinType(
VoidTy, BuiltinType::Void);
1292 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1294 if (LangOpts.CharIsSigned)
1295 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1297 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1300 InitBuiltinType(
ShortTy, BuiltinType::Short);
1301 InitBuiltinType(
IntTy, BuiltinType::Int);
1302 InitBuiltinType(
LongTy, BuiltinType::Long);
1303 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1313 InitBuiltinType(
FloatTy, BuiltinType::Float);
1314 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1315 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1318 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1321 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1324 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1327 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1328 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1329 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1333 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1334 InitBuiltinType(
FractTy, BuiltinType::Fract);
1335 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1340 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1346 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1353 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1358 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1360 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1361 if (LangOpts.CPlusPlus && LangOpts.WChar)
1371 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1373 if (LangOpts.CPlusPlus)
1374 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1378 if (LangOpts.CPlusPlus)
1379 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1388 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1391 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1403 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1409 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1412 if (LangOpts.OpenMP) {
1419 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1422 if (LangOpts.MatrixTypes)
1430 if (LangOpts.OpenCL) {
1431#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1432 InitBuiltinType(SingletonId, BuiltinType::Id);
1433#include "clang/Basic/OpenCLImageTypes.def"
1435 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1436 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1438 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1441#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1442 InitBuiltinType(Id##Ty, BuiltinType::Id);
1443#include "clang/Basic/OpenCLExtensionTypes.def"
1446 if (LangOpts.HLSL) {
1447#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1448 InitBuiltinType(SingletonId, BuiltinType::Id);
1449#include "clang/Basic/HLSLIntangibleTypes.def"
1452 if (
Target.hasAArch64ACLETypes() ||
1454#define SVE_TYPE(Name, Id, SingletonId) \
1455 InitBuiltinType(SingletonId, BuiltinType::Id);
1456#include "clang/Basic/AArch64ACLETypes.def"
1459 if (
Target.getTriple().isPPC64()) {
1460#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1461 InitBuiltinType(Id##Ty, BuiltinType::Id);
1462#include "clang/Basic/PPCTypes.def"
1463#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1464 InitBuiltinType(Id##Ty, BuiltinType::Id);
1465#include "clang/Basic/PPCTypes.def"
1468 if (
Target.hasRISCVVTypes()) {
1469#define RVV_TYPE(Name, Id, SingletonId) \
1470 InitBuiltinType(SingletonId, BuiltinType::Id);
1471#include "clang/Basic/RISCVVTypes.def"
1474 if (
Target.getTriple().isWasm() &&
Target.hasFeature(
"reference-types")) {
1475#define WASM_TYPE(Name, Id, SingletonId) \
1476 InitBuiltinType(SingletonId, BuiltinType::Id);
1477#include "clang/Basic/WebAssemblyReferenceTypes.def"
1480 if (
Target.getTriple().isAMDGPU() ||
1481 (AuxTarget && AuxTarget->
getTriple().isAMDGPU())) {
1482#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1483 InitBuiltinType(SingletonId, BuiltinType::Id);
1484#include "clang/Basic/AMDGPUTypes.def"
1491 ObjCConstantStringType =
QualType();
1496 if (LangOpts.OpenCLGenericAddressSpace) {
1506 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1509 InitBuiltinType(
HalfTy, BuiltinType::Half);
1511 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1517 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1539 llvm::DenseMap<const Decl*, AttrVec*>::iterator Pos = DeclAttrs.find(
D);
1540 if (Pos != DeclAttrs.end()) {
1541 Pos->second->~AttrVec();
1542 DeclAttrs.erase(Pos);
1556 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1557 TemplateOrInstantiation.find(Var);
1558 if (Pos == TemplateOrInstantiation.end())
1571 Tmpl, TSK, PointOfInstantiation));
1577 assert(!TemplateOrInstantiation[Inst] &&
1578 "Already noted what the variable was instantiated from");
1579 TemplateOrInstantiation[Inst] = TSI;
1584 return InstantiatedFromUsingDecl.lookup(UUD);
1589 assert((isa<UsingDecl>(Pattern) ||
1590 isa<UnresolvedUsingValueDecl>(Pattern) ||
1591 isa<UnresolvedUsingTypenameDecl>(Pattern)) &&
1592 "pattern decl is not a using decl");
1593 assert((isa<UsingDecl>(Inst) ||
1594 isa<UnresolvedUsingValueDecl>(Inst) ||
1595 isa<UnresolvedUsingTypenameDecl>(Inst)) &&
1596 "instantiation did not produce a using decl");
1597 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1598 InstantiatedFromUsingDecl[Inst] = Pattern;
1603 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1608 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1609 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1614 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1620 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1621 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1626 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1632 "Instantiated field decl is not unnamed");
1634 "Template field decl is not unnamed");
1635 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1636 "Already noted what unnamed field was instantiated from");
1638 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1659 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1660 OverriddenMethods.find(
Method->getCanonicalDecl());
1661 if (Pos == OverriddenMethods.end())
1669 OverriddenMethods[
Method].push_back(Overridden);
1677 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(
D)) {
1683 const auto *
Method = dyn_cast<ObjCMethodDecl>(
D);
1688 Method->getOverriddenMethods(OverDecls);
1689 Overridden.append(OverDecls.begin(), OverDecls.end());
1692std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1696 auto it = RelocatableClasses.find(
D);
1697 if (it != RelocatableClasses.end())
1698 return it->getSecond();
1699 return std::nullopt;
1706 assert(RelocatableClasses.find(
D) == RelocatableClasses.end());
1707 RelocatableClasses.insert({
D, Info});
1712 if (!
Class->isPolymorphic())
1715 using AuthAttr = VTablePointerAuthenticationAttr;
1716 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1718 return Context.
getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1719 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1720 ExplicitAuth->getAddressDiscrimination();
1721 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1722 return Context.
getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1723 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1726ASTContext::PointerAuthContent
1727ASTContext::findPointerAuthContent(
QualType T)
const {
1728 assert(isPointerAuthenticationAvailable());
1730 T =
T.getCanonicalType();
1731 if (
T.hasAddressDiscriminatedPointerAuth())
1732 return PointerAuthContent::AddressDiscriminatedData;
1735 return PointerAuthContent::None;
1737 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1738 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1739 return Existing->second;
1741 PointerAuthContent
Result = PointerAuthContent::None;
1743 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1744 auto [ResultIter, DidAdd] =
1745 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1751 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1752 static_assert(PointerAuthContent::None <
1753 PointerAuthContent::AddressDiscriminatedVTable);
1754 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1755 PointerAuthContent::AddressDiscriminatedData);
1758 return Result != PointerAuthContent::AddressDiscriminatedData;
1760 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1762 !ShouldContinueAfterUpdate(
1763 PointerAuthContent::AddressDiscriminatedVTable))
1764 return SaveResultAndReturn();
1765 for (
auto Base : CXXRD->bases()) {
1766 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1767 return SaveResultAndReturn();
1771 if (!ShouldContinueAfterUpdate(
1773 return SaveResultAndReturn();
1775 return SaveResultAndReturn();
1779 assert(!Import->getNextLocalImport() &&
1780 "Import declaration already in the chain");
1781 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1782 if (!FirstLocalImport) {
1783 FirstLocalImport = Import;
1784 LastLocalImport = Import;
1788 LastLocalImport->setNextLocalImport(Import);
1789 LastLocalImport = Import;
1801 llvm_unreachable(
"Not a floating point type!");
1802 case BuiltinType::BFloat16:
1803 return Target->getBFloat16Format();
1804 case BuiltinType::Float16:
1805 return Target->getHalfFormat();
1806 case BuiltinType::Half:
1807 return Target->getHalfFormat();
1808 case BuiltinType::Float:
return Target->getFloatFormat();
1809 case BuiltinType::Double:
return Target->getDoubleFormat();
1810 case BuiltinType::Ibm128:
1811 return Target->getIbm128Format();
1812 case BuiltinType::LongDouble:
1815 return Target->getLongDoubleFormat();
1816 case BuiltinType::Float128:
1819 return Target->getFloat128Format();
1824 unsigned Align =
Target->getCharWidth();
1828 Align = AlignFromAttr;
1836 bool UseAlignAttrOnly;
1837 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(
D))
1839 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1841 UseAlignAttrOnly = AlignFromAttr != 0;
1844 if (UseAlignAttrOnly) {
1846 }
else if (
const auto *VD = dyn_cast<ValueDecl>(
D)) {
1856 Align = getTypeInfoImpl(
T.getTypePtr()).
Align;
1861 unsigned MinWidth =
Target->getLargeArrayMinWidth();
1862 if (!ForAlignof && MinWidth) {
1864 Align = std::max(Align,
Target->getLargeArrayAlign());
1865 else if (isa<ConstantArrayType>(
arrayType) &&
1867 Align = std::max(Align,
Target->getLargeArrayAlign());
1872 Align =
Target->getCharWidth();
1876 if (
const auto *VD = dyn_cast<VarDecl>(
D))
1877 if (VD->hasGlobalStorage() && !ForAlignof) {
1888 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1891 if (!
Parent->isInvalidDecl()) {
1902 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1903 if (LowBitOfOffset < FieldAlign)
1904 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1907 Align = std::min(Align, FieldAlign);
1915 const auto *VD = dyn_cast<VarDecl>(
D);
1916 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1917 Align = std::min(Align, MaxAlignedAttr);
1954 (uint64_t)(-1)/Size) &&
1955 "Overflow in array type char size evaluation");
1960 Width = llvm::alignTo(Width, Align);
1967 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
1985 switch (BT->getKind()) {
1986 case BuiltinType::Bool:
1987 case BuiltinType::Char_S:
1988 case BuiltinType::Char_U:
1989 case BuiltinType::SChar:
1990 case BuiltinType::UChar:
1991 case BuiltinType::Short:
1992 case BuiltinType::UShort:
1993 case BuiltinType::WChar_S:
1994 case BuiltinType::WChar_U:
1995 case BuiltinType::Char8:
1996 case BuiltinType::Char16:
1997 case BuiltinType::Char32:
2025 bool NeedsPreferredAlignment)
const {
2028 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2039 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2044 return TD->getMaxAlignment();
2050 TypeInfoMap::iterator I = MemoizedTypeInfo.find(
T);
2051 if (I != MemoizedTypeInfo.end())
2056 MemoizedTypeInfo[
T] = TI;
2072#define TYPE(Class, Base)
2073#define ABSTRACT_TYPE(Class, Base)
2074#define NON_CANONICAL_TYPE(Class, Base)
2075#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2076#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
2078 assert(!T->isDependentType() && "should not see dependent types here"); \
2079 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
2080#include "clang/AST/TypeNodes.inc"
2081 llvm_unreachable(
"Should not see dependent types");
2083 case Type::FunctionNoProto:
2084 case Type::FunctionProto:
2090 case Type::IncompleteArray:
2091 case Type::VariableArray:
2092 case Type::ConstantArray:
2093 case Type::ArrayParameter: {
2096 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2097 Size = CAT->getZExtSize();
2100 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2101 "Overflow in array type bit size evaluation");
2102 Width = EltInfo.
Width * Size;
2103 Align = EltInfo.
Align;
2107 Width = llvm::alignTo(Width, Align);
2111 case Type::ExtVector:
2112 case Type::Vector: {
2113 const auto *VT = cast<VectorType>(
T);
2115 Width = VT->isPackedVectorBoolType(*
this)
2116 ? VT->getNumElements()
2117 : EltInfo.
Width * VT->getNumElements();
2119 Width = std::max<unsigned>(8, Width);
2120 Align = std::max<unsigned>(8, Width);
2124 if (Align & (Align-1)) {
2125 Align = llvm::bit_ceil(Align);
2126 Width = llvm::alignTo(Width, Align);
2130 if (TargetVectorAlign && TargetVectorAlign < Align)
2131 Align = TargetVectorAlign;
2145 Align = std::min<unsigned>(64, Width);
2149 case Type::ConstantMatrix: {
2150 const auto *MT = cast<ConstantMatrixType>(
T);
2155 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2156 Align = ElementInfo.
Align;
2161 switch (cast<BuiltinType>(
T)->
getKind()) {
2162 default: llvm_unreachable(
"Unknown builtin type!");
2163 case BuiltinType::Void:
2168 case BuiltinType::Bool:
2169 Width =
Target->getBoolWidth();
2170 Align =
Target->getBoolAlign();
2172 case BuiltinType::Char_S:
2173 case BuiltinType::Char_U:
2174 case BuiltinType::UChar:
2175 case BuiltinType::SChar:
2176 case BuiltinType::Char8:
2177 Width =
Target->getCharWidth();
2178 Align =
Target->getCharAlign();
2180 case BuiltinType::WChar_S:
2181 case BuiltinType::WChar_U:
2182 Width =
Target->getWCharWidth();
2183 Align =
Target->getWCharAlign();
2185 case BuiltinType::Char16:
2186 Width =
Target->getChar16Width();
2187 Align =
Target->getChar16Align();
2189 case BuiltinType::Char32:
2190 Width =
Target->getChar32Width();
2191 Align =
Target->getChar32Align();
2193 case BuiltinType::UShort:
2194 case BuiltinType::Short:
2195 Width =
Target->getShortWidth();
2196 Align =
Target->getShortAlign();
2198 case BuiltinType::UInt:
2199 case BuiltinType::Int:
2200 Width =
Target->getIntWidth();
2201 Align =
Target->getIntAlign();
2203 case BuiltinType::ULong:
2204 case BuiltinType::Long:
2205 Width =
Target->getLongWidth();
2206 Align =
Target->getLongAlign();
2208 case BuiltinType::ULongLong:
2209 case BuiltinType::LongLong:
2210 Width =
Target->getLongLongWidth();
2211 Align =
Target->getLongLongAlign();
2213 case BuiltinType::Int128:
2214 case BuiltinType::UInt128:
2216 Align =
Target->getInt128Align();
2218 case BuiltinType::ShortAccum:
2219 case BuiltinType::UShortAccum:
2220 case BuiltinType::SatShortAccum:
2221 case BuiltinType::SatUShortAccum:
2222 Width =
Target->getShortAccumWidth();
2223 Align =
Target->getShortAccumAlign();
2225 case BuiltinType::Accum:
2226 case BuiltinType::UAccum:
2227 case BuiltinType::SatAccum:
2228 case BuiltinType::SatUAccum:
2229 Width =
Target->getAccumWidth();
2230 Align =
Target->getAccumAlign();
2232 case BuiltinType::LongAccum:
2233 case BuiltinType::ULongAccum:
2234 case BuiltinType::SatLongAccum:
2235 case BuiltinType::SatULongAccum:
2236 Width =
Target->getLongAccumWidth();
2237 Align =
Target->getLongAccumAlign();
2239 case BuiltinType::ShortFract:
2240 case BuiltinType::UShortFract:
2241 case BuiltinType::SatShortFract:
2242 case BuiltinType::SatUShortFract:
2243 Width =
Target->getShortFractWidth();
2244 Align =
Target->getShortFractAlign();
2246 case BuiltinType::Fract:
2247 case BuiltinType::UFract:
2248 case BuiltinType::SatFract:
2249 case BuiltinType::SatUFract:
2250 Width =
Target->getFractWidth();
2251 Align =
Target->getFractAlign();
2253 case BuiltinType::LongFract:
2254 case BuiltinType::ULongFract:
2255 case BuiltinType::SatLongFract:
2256 case BuiltinType::SatULongFract:
2257 Width =
Target->getLongFractWidth();
2258 Align =
Target->getLongFractAlign();
2260 case BuiltinType::BFloat16:
2261 if (
Target->hasBFloat16Type()) {
2262 Width =
Target->getBFloat16Width();
2263 Align =
Target->getBFloat16Align();
2272 case BuiltinType::Float16:
2273 case BuiltinType::Half:
2276 Width =
Target->getHalfWidth();
2277 Align =
Target->getHalfAlign();
2280 "Expected OpenMP device compilation.");
2285 case BuiltinType::Float:
2286 Width =
Target->getFloatWidth();
2287 Align =
Target->getFloatAlign();
2289 case BuiltinType::Double:
2290 Width =
Target->getDoubleWidth();
2291 Align =
Target->getDoubleAlign();
2293 case BuiltinType::Ibm128:
2294 Width =
Target->getIbm128Width();
2295 Align =
Target->getIbm128Align();
2297 case BuiltinType::LongDouble:
2304 Width =
Target->getLongDoubleWidth();
2305 Align =
Target->getLongDoubleAlign();
2308 case BuiltinType::Float128:
2311 Width =
Target->getFloat128Width();
2312 Align =
Target->getFloat128Align();
2315 "Expected OpenMP device compilation.");
2320 case BuiltinType::NullPtr:
2325 case BuiltinType::ObjCId:
2326 case BuiltinType::ObjCClass:
2327 case BuiltinType::ObjCSel:
2331 case BuiltinType::OCLSampler:
2332 case BuiltinType::OCLEvent:
2333 case BuiltinType::OCLClkEvent:
2334 case BuiltinType::OCLQueue:
2335 case BuiltinType::OCLReserveID:
2336#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2337 case BuiltinType::Id:
2338#include "clang/Basic/OpenCLImageTypes.def"
2339#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2340 case BuiltinType::Id:
2341#include "clang/Basic/OpenCLExtensionTypes.def"
2343 Width =
Target->getPointerWidth(AS);
2344 Align =
Target->getPointerAlign(AS);
2354#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2355 case BuiltinType::Id: \
2359#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2360 case BuiltinType::Id: \
2364#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2365 case BuiltinType::Id: \
2369#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2370 case BuiltinType::Id: \
2374#include "clang/Basic/AArch64ACLETypes.def"
2375#define PPC_VECTOR_TYPE(Name, Id, Size) \
2376 case BuiltinType::Id: \
2380#include "clang/Basic/PPCTypes.def"
2381#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2383 case BuiltinType::Id: \
2387#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2388 case BuiltinType::Id: \
2392#include "clang/Basic/RISCVVTypes.def"
2393#define WASM_TYPE(Name, Id, SingletonId) \
2394 case BuiltinType::Id: \
2398#include "clang/Basic/WebAssemblyReferenceTypes.def"
2399#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2400 case BuiltinType::ID: \
2404#include "clang/Basic/AMDGPUTypes.def"
2405#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2406#include "clang/Basic/HLSLIntangibleTypes.def"
2412 case Type::ObjCObjectPointer:
2416 case Type::BlockPointer:
2417 AS = cast<BlockPointerType>(
T)->getPointeeType().getAddressSpace();
2418 Width =
Target->getPointerWidth(AS);
2419 Align =
Target->getPointerAlign(AS);
2421 case Type::LValueReference:
2422 case Type::RValueReference:
2425 AS = cast<ReferenceType>(
T)->getPointeeType().getAddressSpace();
2426 Width =
Target->getPointerWidth(AS);
2427 Align =
Target->getPointerAlign(AS);
2430 AS = cast<PointerType>(
T)->getPointeeType().getAddressSpace();
2431 Width =
Target->getPointerWidth(AS);
2432 Align =
Target->getPointerAlign(AS);
2434 case Type::MemberPointer: {
2435 const auto *MPT = cast<MemberPointerType>(
T);
2441 case Type::Complex: {
2445 Width = EltInfo.
Width * 2;
2446 Align = EltInfo.
Align;
2449 case Type::ObjCObject:
2451 case Type::Adjusted:
2454 case Type::ObjCInterface: {
2455 const auto *ObjCI = cast<ObjCInterfaceType>(
T);
2456 if (ObjCI->getDecl()->isInvalidDecl()) {
2466 case Type::BitInt: {
2467 const auto *EIT = cast<BitIntType>(
T);
2468 Align =
Target->getBitIntAlign(EIT->getNumBits());
2469 Width =
Target->getBitIntWidth(EIT->getNumBits());
2474 const auto *TT = cast<TagType>(
T);
2483 if (isa<EnumType>(TT)) {
2484 const EnumDecl *ED = cast<EnumDecl>(TD);
2488 Info.
Align = AttrAlign;
2494 const auto *RD = cast<RecordDecl>(TD);
2498 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2504 case Type::SubstTemplateTypeParm:
2505 return getTypeInfo(cast<SubstTemplateTypeParmType>(
T)->
2506 getReplacementType().getTypePtr());
2509 case Type::DeducedTemplateSpecialization: {
2510 const auto *A = cast<DeducedType>(
T);
2511 assert(!A->getDeducedType().isNull() &&
2512 "cannot request the size of an undeduced or dependent auto type");
2513 return getTypeInfo(A->getDeducedType().getTypePtr());
2517 return getTypeInfo(cast<ParenType>(
T)->getInnerType().getTypePtr());
2519 case Type::MacroQualified:
2523 case Type::ObjCTypeParam:
2524 return getTypeInfo(cast<ObjCTypeParamType>(
T)->desugar().getTypePtr());
2527 return getTypeInfo(cast<UsingType>(
T)->desugar().getTypePtr());
2529 case Type::Typedef: {
2530 const auto *TT = cast<TypedefType>(
T);
2535 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2546 case Type::Attributed:
2548 cast<AttributedType>(
T)->getEquivalentType().getTypePtr());
2550 case Type::CountAttributed:
2551 return getTypeInfo(cast<CountAttributedType>(
T)->desugar().getTypePtr());
2553 case Type::BTFTagAttributed:
2555 cast<BTFTagAttributedType>(
T)->getWrappedType().getTypePtr());
2557 case Type::HLSLAttributedResource:
2559 cast<HLSLAttributedResourceType>(
T)->getWrappedType().getTypePtr());
2561 case Type::HLSLInlineSpirv: {
2562 const auto *ST = cast<HLSLInlineSpirvType>(
T);
2564 Width = ST->getSize() * 8;
2565 Align = ST->getAlignment();
2566 if (Width == 0 && Align == 0) {
2574 case Type::Atomic: {
2583 Width =
Target->getCharWidth();
2585 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2591 Width = llvm::bit_ceil(Width);
2594 Align =
static_cast<unsigned>(Width);
2599 case Type::PredefinedSugar:
2600 return getTypeInfo(cast<PredefinedSugarType>(
T)->desugar().getTypePtr());
2608 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2609 return TypeInfo(Width, Align, AlignRequirement);
2613 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(
T);
2614 if (I != MemoizedUnadjustedAlign.end())
2617 unsigned UnadjustedAlign;
2628 MemoizedUnadjustedAlign[
T] = UnadjustedAlign;
2629 return UnadjustedAlign;
2633 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2683 unsigned ABIAlign = TI.
Align;
2691 if (!
Target->allowsLargerPreferedTypeAlignment())
2703 unsigned PreferredAlign =
static_cast<unsigned>(
2705 assert(PreferredAlign >= ABIAlign &&
2706 "PreferredAlign should be at least as large as ABIAlign.");
2707 return PreferredAlign;
2714 T = CT->getElementType().getTypePtr();
2716 T = ED->getIntegerType().getTypePtr();
2721 Target->defaultsToAIXPowerAlignment()))
2776 for (
unsigned I = 0, N =
Path.size(); I != N; ++I) {
2780 std::swap(
Base, Derived);
2800 llvm::append_range(Ivars, OI->
ivars());
2803 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2805 Ivars.push_back(Iv);
2813 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2816 for (
auto *Proto : OI->all_referenced_protocols()) {
2821 for (
const auto *Cat : OI->visible_categories())
2827 SD = SD->getSuperClass();
2829 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2830 for (
auto *Proto : OC->protocols()) {
2833 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2835 if (!Protocols.insert(
2839 for (
auto *Proto : OP->protocols())
2846 bool CheckIfTriviallyCopyable) {
2847 assert(RD->
isUnion() &&
"Must be union type");
2851 for (
const auto *Field : RD->
fields()) {
2853 CheckIfTriviallyCopyable))
2856 if (FieldSize != UnionSize)
2874static std::optional<int64_t>
2877 bool CheckIfTriviallyCopyable);
2879static std::optional<int64_t>
2881 bool CheckIfTriviallyCopyable) {
2882 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2885 CheckIfTriviallyCopyable);
2889 bool IsBitIntType = Field->getType()->isBitIntType();
2890 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2892 CheckIfTriviallyCopyable))
2893 return std::nullopt;
2895 int64_t FieldSizeInBits =
2897 if (Field->isBitField()) {
2900 if (Field->isUnnamedBitField())
2903 int64_t BitfieldSize = Field->getBitWidthValue();
2905 if ((
unsigned)BitfieldSize >
2906 cast<BitIntType>(Field->getType())->getNumBits())
2907 return std::nullopt;
2908 }
else if (BitfieldSize > FieldSizeInBits) {
2909 return std::nullopt;
2911 FieldSizeInBits = BitfieldSize;
2913 Field->getType(), CheckIfTriviallyCopyable)) {
2914 return std::nullopt;
2916 return FieldSizeInBits;
2919static std::optional<int64_t>
2921 bool CheckIfTriviallyCopyable) {
2923 CheckIfTriviallyCopyable);
2926template <
typename RangeT>
2928 const RangeT &Subobjects, int64_t CurOffsetInBits,
2930 bool CheckIfTriviallyCopyable) {
2931 for (
const auto *Subobject : Subobjects) {
2932 std::optional<int64_t> SizeInBits =
2935 return std::nullopt;
2936 if (*SizeInBits != 0) {
2938 if (Offset != CurOffsetInBits)
2939 return std::nullopt;
2940 CurOffsetInBits += *SizeInBits;
2943 return CurOffsetInBits;
2946static std::optional<int64_t>
2949 bool CheckIfTriviallyCopyable) {
2950 assert(!RD->
isUnion() &&
"Must be struct/class type");
2953 int64_t CurOffsetInBits = 0;
2954 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
2955 if (ClassDecl->isDynamicClass())
2956 return std::nullopt;
2959 for (
const auto &
Base : ClassDecl->bases()) {
2962 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
2966 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
2969 std::optional<int64_t> OffsetAfterBases =
2971 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
2972 if (!OffsetAfterBases)
2973 return std::nullopt;
2974 CurOffsetInBits = *OffsetAfterBases;
2977 std::optional<int64_t> OffsetAfterFields =
2979 RD->
fields(), CurOffsetInBits, Context, Layout,
2980 CheckIfTriviallyCopyable);
2981 if (!OffsetAfterFields)
2982 return std::nullopt;
2983 CurOffsetInBits = *OffsetAfterFields;
2985 return CurOffsetInBits;
2989 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
3006 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
3011 CheckIfTriviallyCopyable);
3014 "hasUniqueObjectRepresentations should not be called with an "
3038 return !ABI->getMemberPointerInfo(MPT).HasPadding;
3041 if (
Record->isInvalidDecl())
3046 CheckIfTriviallyCopyable);
3049 *
this,
Record, CheckIfTriviallyCopyable);
3051 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
3072 count += Ext->ivar_size();
3077 count += ImplDecl->ivar_size();
3095 if (isa<GNUNullExpr>(
E))
return true;
3103 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3104 I = ObjCImpls.find(
D);
3105 if (I != ObjCImpls.end())
3106 return cast<ObjCImplementationDecl>(I->second);
3113 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3114 I = ObjCImpls.find(
D);
3115 if (I != ObjCImpls.end())
3116 return cast<ObjCCategoryImplDecl>(I->second);
3123 assert(IFaceD && ImplD &&
"Passed null params");
3124 ObjCImpls[IFaceD] = ImplD;
3130 assert(CatD && ImplD &&
"Passed null params");
3131 ObjCImpls[CatD] = ImplD;
3136 return ObjCMethodRedecls.lookup(MD);
3142 ObjCMethodRedecls[MD] = Redecl;
3147 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3149 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3150 return CD->getClassInterface();
3151 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3152 return IMD->getClassInterface();
3160 assert(VD &&
"Passed null params");
3161 assert(VD->
hasAttr<BlocksAttr>() &&
3162 "getBlockVarCopyInits - not __block var");
3163 auto I = BlockVarCopyInits.find(VD);
3164 if (I != BlockVarCopyInits.end())
3166 return {
nullptr,
false};
3172 assert(VD && CopyExpr &&
"Passed null params");
3173 assert(VD->
hasAttr<BlocksAttr>() &&
3174 "setBlockVarCopyInits - not __block var");
3175 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3179 unsigned DataSize)
const {
3184 "incorrect data size provided to CreateTypeSourceInfo!");
3201 return getObjCLayout(
D);
3206 bool &AnyNonCanonArgs) {
3208 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3214 bool AnyNonCanonArgs =
false;
3215 for (
auto &Arg : Args) {
3218 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3220 return AnyNonCanonArgs;
3228ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3233 llvm::FoldingSetNodeID ID;
3235 void *insertPos =
nullptr;
3236 if (
ExtQuals *eq = ExtQualNodes.FindNodeOrInsertPos(ID, insertPos)) {
3237 assert(eq->getQualifiers() == quals);
3246 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3249 (void) ExtQualNodes.FindNodeOrInsertPos(ID, insertPos);
3252 auto *eq =
new (*
this,
alignof(
ExtQuals))
ExtQuals(baseType, canon, quals);
3253 ExtQualNodes.InsertNode(eq, insertPos);
3258 LangAS AddressSpace)
const {
3271 "Type cannot be in multiple addr spaces!");
3274 return getExtQualType(TypeNode, Quals);
3280 if (!
T.hasAddressSpace())
3284 const Type *TypeNode;
3289 TypeNode =
T.getTypePtr();
3293 while (
T.hasAddressSpace()) {
3294 TypeNode = Quals.
strip(
T);
3298 if (!
QualType(TypeNode, 0).hasAddressSpace())
3302 T =
T.getSingleStepDesugaredType(*
this);
3312 return getExtQualType(TypeNode, Quals);
3320 "Attempted to get vtable pointer discriminator on a monomorphic type");
3323 llvm::raw_svector_ostream Out(Str);
3324 MC->mangleCXXVTable(RD, Out);
3325 return llvm::getPointerAuthStableSipHash(Str);
3354 Ctx, OS, cast<AtomicType>(
T)->getValueType());
3356 case Type::LValueReference:
3361 case Type::RValueReference:
3375 case Type::ObjCObjectPointer:
3376 case Type::BlockPointer:
3383 Ctx, OS, cast<ComplexType>(
T)->getElementType());
3385 case Type::VariableArray:
3386 case Type::ConstantArray:
3387 case Type::IncompleteArray:
3388 case Type::ArrayParameter:
3399 Ctx, OS, cast<ArrayType>(
T)->getElementType());
3401 case Type::ObjCInterface:
3402 case Type::ObjCObject:
3403 OS <<
"<objc_object>";
3414 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3417 case Type::FunctionNoProto:
3418 case Type::FunctionProto: {
3432 const auto *FuncType = cast<FunctionType>(
T);
3434 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3435 for (
QualType Param : FPT->param_types()) {
3439 if (FPT->isVariadic())
3446 case Type::MemberPointer: {
3450 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3454 case Type::ExtVector:
3462 case Type::ConstantMatrix:
3466 case Type::Builtin: {
3468 switch (BTy->getKind()) {
3469#define SIGNED_TYPE(Id, SingletonId) \
3470 case BuiltinType::Id: \
3473#define UNSIGNED_TYPE(Id, SingletonId) \
3474 case BuiltinType::Id: \
3477#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3478#define BUILTIN_TYPE(Id, SingletonId)
3479#include "clang/AST/BuiltinTypes.def"
3480 llvm_unreachable(
"placeholder types should not appear here.");
3482 case BuiltinType::Half:
3485 case BuiltinType::Float:
3488 case BuiltinType::Double:
3491 case BuiltinType::LongDouble:
3494 case BuiltinType::Float16:
3497 case BuiltinType::Float128:
3501 case BuiltinType::Void:
3505 case BuiltinType::ObjCId:
3506 case BuiltinType::ObjCClass:
3507 case BuiltinType::ObjCSel:
3508 case BuiltinType::NullPtr:
3513 case BuiltinType::OCLSampler:
3514 case BuiltinType::OCLEvent:
3515 case BuiltinType::OCLClkEvent:
3516 case BuiltinType::OCLQueue:
3517 case BuiltinType::OCLReserveID:
3518 case BuiltinType::BFloat16:
3519 case BuiltinType::VectorQuad:
3520 case BuiltinType::VectorPair:
3521 case BuiltinType::DMR1024:
3526 case BuiltinType::Ibm128:
3528#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3529 case BuiltinType::Id: \
3531#include "clang/Basic/OpenCLImageTypes.def"
3532#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3533 case BuiltinType::Id: \
3535#include "clang/Basic/OpenCLExtensionTypes.def"
3536#define SVE_TYPE(Name, Id, SingletonId) \
3537 case BuiltinType::Id: \
3539#include "clang/Basic/AArch64ACLETypes.def"
3540#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3541 case BuiltinType::Id: \
3543#include "clang/Basic/HLSLIntangibleTypes.def"
3544 case BuiltinType::Dependent:
3545 llvm_unreachable(
"should never get here");
3546#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3547#include "clang/Basic/AMDGPUTypes.def"
3548 case BuiltinType::WasmExternRef:
3549#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3550#include "clang/Basic/RISCVVTypes.def"
3551 llvm_unreachable(
"not yet implemented");
3553 llvm_unreachable(
"should never get here");
3555 case Type::Record: {
3576 II =
Typedef->getDeclName().getAsIdentifierInfo();
3579 OS <<
"<anonymous_record>";
3585 case Type::HLSLAttributedResource:
3586 case Type::HLSLInlineSpirv:
3587 llvm_unreachable(
"should never get here");
3589 case Type::DeducedTemplateSpecialization:
3591#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3592#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3593#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3594#define ABSTRACT_TYPE(Class, Base)
3595#define TYPE(Class, Base)
3596#include "clang/AST/TypeNodes.inc"
3597 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3604 "cannot compute type discriminator of a dependent type");
3607 llvm::raw_svector_ostream Out(Str);
3615 T =
T.getUnqualifiedType();
3636 if (MPT->isMemberFunctionPointer()) {
3642 MPT->getMostRecentCXXRecordDecl());
3646 MC->mangleCanonicalTypeName(
T, Out);
3649 return llvm::getPointerAuthStableSipHash(Str);
3674 "Type cannot have multiple ObjCGCs!");
3677 return getExtQualType(TypeNode, Quals);
3691 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3695 llvm::FoldingSetNodeID ID;
3698 void *InsertPos =
nullptr;
3700 CountAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
3705 size_t Size = CountAttributedType::totalSizeToAlloc<TypeCoupledDeclRefInfo>(
3706 DependentDecls.size());
3709 OrNull, DependentDecls);
3710 Types.push_back(CATy);
3711 CountAttributedTypes.InsertNode(CATy, InsertPos);
3720 case Type::Attributed: {
3721 const auto *AT = cast<AttributedType>(Orig);
3728 case Type::BTFTagAttributed: {
3729 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3736 adjustType(cast<ParenType>(Orig)->getInnerType(), Adjust));
3738 case Type::Adjusted: {
3739 const auto *AT = cast<AdjustedType>(Orig);
3744 case Type::MacroQualified: {
3745 const auto *MQT = cast<MacroQualifiedType>(Orig);
3747 MQT->getMacroIdentifier());
3751 return Adjust(Orig);
3761 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(
T)) {
3764 const auto *FPT = cast<FunctionProtoType>(
T);
3770 return cast<FunctionType>(
Result.getTypePtr());
3781 FPT->getExtProtoInfo());
3796 L->DeducedReturnType(FD, ResultType);
3807 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3808 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3824 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
3847 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
3873 if (TSInfo->getType() != FD->
getType())
3881 "TypeLoc size mismatch from updating exception specification");
3882 TSInfo->overrideType(Updated);
3891 llvm::FoldingSetNodeID ID;
3894 void *InsertPos =
nullptr;
3895 if (
ComplexType *CT = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos))
3901 if (!
T.isCanonical()) {
3905 ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos);
3906 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3909 Types.push_back(
New);
3910 ComplexTypes.InsertNode(
New, InsertPos);
3919 llvm::FoldingSetNodeID ID;
3922 void *InsertPos =
nullptr;
3923 if (
PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos))
3929 if (!
T.isCanonical()) {
3933 PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos);
3934 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3937 Types.push_back(
New);
3938 PointerTypes.InsertNode(
New, InsertPos);
3943 llvm::FoldingSetNodeID ID;
3945 void *InsertPos =
nullptr;
3946 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3953 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3954 assert(!AT &&
"Shouldn't be in the map!");
3958 Types.push_back(AT);
3959 AdjustedTypes.InsertNode(AT, InsertPos);
3964 llvm::FoldingSetNodeID ID;
3966 void *InsertPos =
nullptr;
3967 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3974 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3975 assert(!AT &&
"Shouldn't be in the map!");
3978 Types.push_back(AT);
3979 AdjustedTypes.InsertNode(AT, InsertPos);
4011 const auto *ATy = cast<ConstantArrayType>(DTy);
4012 llvm::FoldingSetNodeID ID;
4013 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
4014 ATy->getSizeExpr(), ATy->getSizeModifier(),
4015 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
4016 void *InsertPos =
nullptr;
4018 ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
4027 AT = ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
4028 assert(!AT &&
"Shouldn't be in the map!");
4033 Types.push_back(AT);
4034 ArrayParameterTypes.InsertNode(AT, InsertPos);
4044 llvm::FoldingSetNodeID ID;
4047 void *InsertPos =
nullptr;
4049 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4055 if (!
T.isCanonical()) {
4060 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4061 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4065 Types.push_back(
New);
4066 BlockPointerTypes.InsertNode(
New, InsertPos);
4076 "Unresolved placeholder type");
4080 llvm::FoldingSetNodeID ID;
4083 void *InsertPos =
nullptr;
4085 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4093 if (!SpelledAsLValue || InnerRef || !
T.isCanonical()) {
4094 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4099 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4100 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4105 Types.push_back(
New);
4106 LValueReferenceTypes.InsertNode(
New, InsertPos);
4116 "Unresolved placeholder type");
4120 llvm::FoldingSetNodeID ID;
4123 void *InsertPos =
nullptr;
4125 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4133 if (InnerRef || !
T.isCanonical()) {
4134 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4139 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4140 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4145 Types.push_back(
New);
4146 RValueReferenceTypes.InsertNode(
New, InsertPos);
4154 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4157 Cls = Qualifier.getAsRecordDecl();
4161 llvm::FoldingSetNodeID ID;
4164 void *InsertPos =
nullptr;
4166 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4171 return Qualifier.getCanonical();
4179 if (!
T.isCanonical() || Qualifier != CanonicalQualifier) {
4182 assert(!cast<MemberPointerType>(Canonical)->isSugared());
4185 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4186 assert(!NewIP &&
"Shouldn't be in the map!");
4190 Types.push_back(
New);
4191 MemberPointerTypes.InsertNode(
New, InsertPos);
4198 const llvm::APInt &ArySizeIn,
4199 const Expr *SizeExpr,
4201 unsigned IndexTypeQuals)
const {
4204 "Constant array of VLAs is illegal!");
4212 llvm::APInt ArySize(ArySizeIn);
4213 ArySize = ArySize.zextOrTrunc(
Target->getMaxPointerWidth());
4215 llvm::FoldingSetNodeID ID;
4217 ASM, IndexTypeQuals);
4219 void *InsertPos =
nullptr;
4221 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
4232 ASM, IndexTypeQuals);
4237 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
4238 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4241 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4242 ASM, IndexTypeQuals);
4243 ConstantArrayTypes.InsertNode(
New, InsertPos);
4244 Types.push_back(
New);
4253 if (!
type->isVariablyModifiedType())
return type;
4258 const Type *ty = split.
Ty;
4260#define TYPE(Class, Base)
4261#define ABSTRACT_TYPE(Class, Base)
4262#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4263#include "clang/AST/TypeNodes.inc"
4264 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4270 case Type::DependentVector:
4271 case Type::ExtVector:
4272 case Type::DependentSizedExtVector:
4273 case Type::ConstantMatrix:
4274 case Type::DependentSizedMatrix:
4275 case Type::DependentAddressSpace:
4276 case Type::ObjCObject:
4277 case Type::ObjCInterface:
4278 case Type::ObjCObjectPointer:
4281 case Type::UnresolvedUsing:
4282 case Type::TypeOfExpr:
4284 case Type::Decltype:
4285 case Type::UnaryTransform:
4286 case Type::DependentName:
4287 case Type::InjectedClassName:
4288 case Type::TemplateSpecialization:
4289 case Type::DependentTemplateSpecialization:
4290 case Type::TemplateTypeParm:
4291 case Type::SubstTemplateTypeParmPack:
4292 case Type::SubstBuiltinTemplatePack:
4294 case Type::DeducedTemplateSpecialization:
4295 case Type::PackExpansion:
4296 case Type::PackIndexing:
4298 case Type::DependentBitInt:
4299 case Type::ArrayParameter:
4300 case Type::HLSLAttributedResource:
4301 case Type::HLSLInlineSpirv:
4302 llvm_unreachable(
"type should never be variably-modified");
4306 case Type::FunctionNoProto:
4307 case Type::FunctionProto:
4308 case Type::BlockPointer:
4309 case Type::MemberPointer:
4322 case Type::LValueReference: {
4323 const auto *lv = cast<LValueReferenceType>(ty);
4326 lv->isSpelledAsLValue());
4330 case Type::RValueReference: {
4331 const auto *lv = cast<RValueReferenceType>(ty);
4337 case Type::Atomic: {
4338 const auto *at = cast<AtomicType>(ty);
4343 case Type::ConstantArray: {
4344 const auto *cat = cast<ConstantArrayType>(ty);
4349 cat->getSizeModifier(),
4350 cat->getIndexTypeCVRQualifiers());
4354 case Type::DependentSizedArray: {
4355 const auto *dat = cast<DependentSizedArrayType>(ty);
4358 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4363 case Type::IncompleteArray: {
4364 const auto *iat = cast<IncompleteArrayType>(ty);
4368 iat->getIndexTypeCVRQualifiers());
4373 case Type::VariableArray: {
4374 const auto *vat = cast<VariableArrayType>(ty);
4378 vat->getIndexTypeCVRQualifiers());
4391 unsigned IndexTypeQuals)
const {
4408 VariableArrayTypes.push_back(
New);
4409 Types.push_back(
New);
4419 unsigned elementTypeQuals)
const {
4422 "Size must be type- or value-dependent!");
4426 void *insertPos =
nullptr;
4427 llvm::FoldingSetNodeID ID;
4429 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4430 ASM, elementTypeQuals, numElements);
4434 DependentSizedArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4446 DependentSizedArrayTypes.InsertNode(newType, insertPos);
4447 Types.push_back(newType);
4455 numElements, ASM, elementTypeQuals);
4456 DependentSizedArrayTypes.InsertNode(canonTy, insertPos);
4457 Types.push_back(canonTy);
4462 canonElementType.
Quals);
4466 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4475 Types.push_back(sugaredType);
4481 unsigned elementTypeQuals)
const {
4482 llvm::FoldingSetNodeID ID;
4485 void *insertPos =
nullptr;
4487 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos))
4499 ASM, elementTypeQuals);
4504 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4505 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4511 IncompleteArrayTypes.InsertNode(newType, insertPos);
4512 Types.push_back(newType);
4518#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4519 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4522#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4523 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4527 llvm_unreachable(
"Unsupported builtin vector type");
4529#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4530 ElBits, NF, IsSigned) \
4531 case BuiltinType::Id: \
4532 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4533 llvm::ElementCount::getScalable(NumEls), NF};
4534#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4536 case BuiltinType::Id: \
4537 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4538 llvm::ElementCount::getScalable(NumEls), NF};
4539#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4541 case BuiltinType::Id: \
4542 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4543#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4545 case BuiltinType::Id: \
4546 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4547#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4548 case BuiltinType::Id: \
4549 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4550#include "clang/Basic/AArch64ACLETypes.def"
4552#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4554 case BuiltinType::Id: \
4555 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4556 llvm::ElementCount::getScalable(NumEls), NF};
4557#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4558 case BuiltinType::Id: \
4559 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4560 llvm::ElementCount::getScalable(NumEls), NF};
4561#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4562 case BuiltinType::Id: \
4563 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4564#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4565 case BuiltinType::Id: \
4566 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4567#include "clang/Basic/RISCVVTypes.def"
4574 if (
Target->getTriple().isWasm() &&
Target->hasFeature(
"reference-types")) {
4575#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4576 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4578#include "clang/Basic/WebAssemblyReferenceTypes.def"
4581 "shouldn't try to generate type externref outside WebAssembly target");
4588 unsigned NumFields)
const {
4589 if (
Target->hasAArch64ACLETypes()) {
4592#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4593 ElBits, NF, IsSigned) \
4594 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4595 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4596 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4597 return SingletonId; \
4599#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4601 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4602 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4603 return SingletonId; \
4605#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4607 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4608 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4609 return SingletonId; \
4611#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4613 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4614 NumElts == (NumEls * NF) && NumFields == 1) { \
4615 return SingletonId; \
4617#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4618 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4620#include "clang/Basic/AArch64ACLETypes.def"
4621 }
else if (
Target->hasRISCVVTypes()) {
4623#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4625 if (!EltTy->isBooleanType() && \
4626 ((EltTy->hasIntegerRepresentation() && \
4627 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4628 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4630 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4631 IsBF && !IsFP)) && \
4632 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4634#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4635 if (EltTy->isBooleanType() && NumElts == NumEls) \
4637#include "clang/Basic/RISCVVTypes.def"
4652 llvm::FoldingSetNodeID ID;
4655 void *InsertPos =
nullptr;
4656 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4666 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4667 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4670 VectorType(vecType, NumElts, Canonical, VecKind);
4671 VectorTypes.InsertNode(
New, InsertPos);
4672 Types.push_back(
New);
4679 llvm::FoldingSetNodeID ID;
4682 void *InsertPos =
nullptr;
4684 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4689 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4692 if (CanonVecTy == VecType) {
4697 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4698 assert(!CanonCheck &&
4699 "Dependent-sized vector_size canonical type broken");
4701 DependentVectorTypes.InsertNode(
New, InsertPos);
4710 Types.push_back(
New);
4717 unsigned NumElts)
const {
4724 llvm::FoldingSetNodeID ID;
4727 void *InsertPos =
nullptr;
4728 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4738 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4739 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4743 VectorTypes.InsertNode(
New, InsertPos);
4744 Types.push_back(
New);
4752 llvm::FoldingSetNodeID ID;
4756 void *InsertPos =
nullptr;
4758 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4768 if (CanonVecTy == vecType) {
4773 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4774 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4776 DependentSizedExtVectorTypes.InsertNode(
New, InsertPos);
4785 Types.push_back(
New);
4790 unsigned NumColumns)
const {
4791 llvm::FoldingSetNodeID ID;
4793 Type::ConstantMatrix);
4796 "need a valid element type");
4799 "need valid matrix dimensions");
4800 void *InsertPos =
nullptr;
4810 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4816 MatrixTypes.InsertNode(
New, InsertPos);
4817 Types.push_back(
New);
4826 llvm::FoldingSetNodeID ID;
4830 void *InsertPos =
nullptr;
4832 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4837 ColumnExpr, AttrLoc);
4840 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4841 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4843 DependentSizedMatrixTypes.InsertNode(Canon, InsertPos);
4844 Types.push_back(Canon);
4857 ColumnExpr, AttrLoc);
4858 Types.push_back(
New);
4863 Expr *AddrSpaceExpr,
4869 void *insertPos =
nullptr;
4870 llvm::FoldingSetNodeID ID;
4875 DependentAddressSpaceTypes.FindNodeOrInsertPos(ID, insertPos);
4881 DependentAddressSpaceTypes.InsertNode(canonTy, insertPos);
4882 Types.push_back(canonTy);
4885 if (canonPointeeType == PointeeType &&
4891 AddrSpaceExpr, AttrLoc);
4892 Types.push_back(sugaredType);
4898 return T.isCanonical() &&
4916 llvm::FoldingSetNodeID ID;
4919 void *InsertPos =
nullptr;
4921 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
4931 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
4932 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4937 Types.push_back(
New);
4938 FunctionNoProtoTypes.InsertNode(
New, InsertPos);
4954 return CanResultType;
4961 if (!NoexceptInType)
4978 bool AnyPackExpansions =
false;
4983 AnyPackExpansions =
true;
4985 return AnyPackExpansions;
4991QualType ASTContext::getFunctionTypeInternal(
4994 size_t NumArgs = ArgArray.size();
4998 llvm::FoldingSetNodeID
ID;
5003 bool Unique =
false;
5005 void *InsertPos =
nullptr;
5007 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos)) {
5027 bool IsCanonicalExceptionSpec =
5031 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
5033 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
5034 if (!ArgArray[i].isCanonicalAsParam())
5035 isCanonical =
false;
5037 if (OnlyWantCanonical)
5038 assert(isCanonical &&
5039 "given non-canonical parameters constructing canonical type");
5044 if (!isCanonical && Canonical.
isNull()) {
5046 CanonicalArgs.reserve(NumArgs);
5047 for (
unsigned i = 0; i != NumArgs; ++i)
5054 if (IsCanonicalExceptionSpec) {
5056 }
else if (NoexceptInType) {
5069 bool AnyPacks =
false;
5092 llvm_unreachable(
"dependent noexcept is already canonical");
5101 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5105 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
5106 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5111 auto ESH = FunctionProtoType::getExceptionSpecSize(
5113 size_t Size = FunctionProtoType::totalSizeToAlloc<
5122 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5130 Types.push_back(FTP);
5132 FunctionProtoTypes.InsertNode(FTP, InsertPos);
5134 AnyFunctionEffects =
true;
5139 llvm::FoldingSetNodeID
ID;
5142 void *InsertPos =
nullptr;
5143 if (
PipeType *PT = PipeTypes.FindNodeOrInsertPos(ID, InsertPos))
5149 if (!
T.isCanonical()) {
5153 PipeType *NewIP = PipeTypes.FindNodeOrInsertPos(ID, InsertPos);
5154 assert(!NewIP &&
"Shouldn't be in the map!");
5158 Types.push_back(
New);
5159 PipeTypes.InsertNode(
New, InsertPos);
5170 return getPipeType(
T,
true);
5174 return getPipeType(
T,
false);
5178 llvm::FoldingSetNodeID ID;
5181 void *InsertPos =
nullptr;
5182 if (
BitIntType *EIT = BitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5186 BitIntTypes.InsertNode(
New, InsertPos);
5187 Types.push_back(
New);
5192 Expr *NumBitsExpr)
const {
5194 llvm::FoldingSetNodeID ID;
5197 void *InsertPos =
nullptr;
5199 DependentBitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5204 DependentBitIntTypes.InsertNode(
New, InsertPos);
5206 Types.push_back(
New);
5214 if (
auto *
Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5226 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5227 case Kind::SignedSizeT:
5229 case Kind::PtrdiffT:
5232 llvm_unreachable(
"unexpected kind");
5237 Types.push_back(
New);
5238 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5245 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5248 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5250 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5259 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5261 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5263 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5265 assert(TD->TypeForDecl);
5270 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5272 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5273 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5276 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5279 assert(
Decl->TypeForDecl);
5289 std::optional<bool> TypeMatchesDeclOrNone)
const {
5290 if (!TypeMatchesDeclOrNone) {
5291 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5292 assert(!DeclUnderlyingType.
isNull());
5293 if (UnderlyingType.
isNull())
5294 UnderlyingType = DeclUnderlyingType;
5296 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5297 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5301 assert(!UnderlyingType.
isNull());
5305 *TypeMatchesDeclOrNone) {
5306 if (
Decl->TypeForDecl)
5311 !*TypeMatchesDeclOrNone);
5313 Types.push_back(NewType);
5314 Decl->TypeForDecl = NewType;
5318 llvm::FoldingSetNodeID ID;
5321 void *InsertPos =
nullptr;
5323 TypedefTypes.FindNodeOrInsertPos(ID, InsertPos))
5324 return QualType(Placeholder->getType(), 0);
5329 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5333 UnderlyingType, !*TypeMatchesDeclOrNone);
5334 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5336 TypedefTypes.InsertNode(Placeholder, InsertPos);
5337 Types.push_back(NewType);
5346 if (UnderlyingType.
isNull()) {
5347 const auto *UD = cast<UsingDecl>(
D->getIntroducer());
5351 UD->getQualifier(), cast<TypeDecl>(
D->getTargetDecl()));
5354 llvm::FoldingSetNodeID ID;
5357 void *InsertPos =
nullptr;
5358 if (
const UsingType *
T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5368 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5372 UsingTypes.InsertNode(
T, InsertPos);
5378 const TagDecl *TD,
bool OwnsTag,
5380 const Type *CanonicalType,
5381 bool WithFoldingSetNode)
const {
5382 auto [TC, Size] = [&] {
5386 return std::make_tuple(Type::Enum,
sizeof(
EnumType));
5387 case Decl::ClassTemplatePartialSpecialization:
5388 case Decl::ClassTemplateSpecialization:
5389 case Decl::CXXRecord:
5392 if (cast<CXXRecordDecl>(TD)->hasInjectedClassType())
5393 return std::make_tuple(Type::InjectedClassName,
5397 return std::make_tuple(Type::Record,
sizeof(
RecordType));
5399 llvm_unreachable(
"unexpected decl kind");
5409 if (WithFoldingSetNode) {
5421 Mem =
T->getTagType();
5426 auto *
T = [&, TC = TC]() ->
TagType * {
5429 assert(isa<EnumDecl>(TD));
5431 IsInjected, CanonicalType);
5432 assert(
reinterpret_cast<void *
>(
T) ==
5433 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5434 "TagType must be the first base of EnumType");
5437 case Type::Record: {
5438 assert(isa<RecordDecl>(TD));
5440 IsInjected, CanonicalType);
5441 assert(
reinterpret_cast<void *
>(
T) ==
5442 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5443 "TagType must be the first base of RecordType");
5446 case Type::InjectedClassName: {
5448 IsInjected, CanonicalType);
5449 assert(
reinterpret_cast<void *
>(
T) ==
5450 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5451 "TagType must be the first base of InjectedClassNameType");
5455 llvm_unreachable(
"unexpected type class");
5458 assert(
T->getKeyword() ==
Keyword);
5459 assert(
T->getQualifier() == Qualifier);
5460 assert(
T->getOriginalDecl() == TD);
5461 assert(
T->isInjected() == IsInjected);
5462 assert(
T->isTagOwned() == OwnsTag);
5471 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5472 RD && RD->isInjectedClassName())
5479 if (TD->TypeForDecl)
5480 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5482 const Type *CanonicalType = getTagTypeInternal(
5485 false,
false,
nullptr,
5487 TD->TypeForDecl = CanonicalType;
5493 const TagDecl *TD,
bool OwnsTag)
const {
5496 bool IsInjected = TD != NonInjectedTD;
5503 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5510 std::nullopt, NonInjectedTD,
5511 false, IsInjected, CanonicalType,
5513 TD->TypeForDecl =
T;
5517 llvm::FoldingSetNodeID ID;
5519 OwnsTag, IsInjected);
5521 void *InsertPos =
nullptr;
5523 TagTypes.FindNodeOrInsertPos(ID, InsertPos))
5528 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5529 CanonicalType,
true);
5535 unsigned NumPositiveBits,
5538 unsigned IntWidth =
Target->getIntWidth();
5539 unsigned CharWidth =
Target->getCharWidth();
5540 unsigned ShortWidth =
Target->getShortWidth();
5541 bool EnumTooLarge =
false;
5543 if (NumNegativeBits) {
5547 if (IsPacked && NumNegativeBits <= CharWidth &&
5548 NumPositiveBits < CharWidth) {
5550 BestWidth = CharWidth;
5551 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5552 NumPositiveBits < ShortWidth) {
5554 BestWidth = ShortWidth;
5555 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5557 BestWidth = IntWidth;
5559 BestWidth =
Target->getLongWidth();
5561 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5564 BestWidth =
Target->getLongLongWidth();
5566 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5567 EnumTooLarge =
true;
5571 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5576 if (IsPacked && NumPositiveBits <= CharWidth) {
5578 BestPromotionType =
IntTy;
5579 BestWidth = CharWidth;
5580 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5582 BestPromotionType =
IntTy;
5583 BestWidth = ShortWidth;
5584 }
else if (NumPositiveBits <= IntWidth) {
5586 BestWidth = IntWidth;
5587 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5590 }
else if (NumPositiveBits <= (BestWidth =
Target->getLongWidth())) {
5592 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5596 BestWidth =
Target->getLongLongWidth();
5597 if (NumPositiveBits > BestWidth) {
5602 EnumTooLarge =
true;
5605 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5610 return EnumTooLarge;
5615 "Integral type required!");
5618 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5621 return Value.getActiveBits() <= BitWidth;
5623 return Value.getSignificantBits() <= BitWidth;
5629 const Type *CanonicalType)
const {
5631 UnresolvedUsingType::totalSizeToAlloc<
5633 !!InsertPos, !!Qualifier),
5637 auto *Placeholder =
new (
T->getFoldingSetPlaceholder())
5639 TypedefTypes.InsertNode(Placeholder, InsertPos);
5649 return D->TypeForDecl->getCanonicalTypeUnqualified();
5651 const Type *CanonicalType = getUnresolvedUsingTypeInternal(
5655 D->TypeForDecl = CanonicalType;
5671 nullptr, CanonicalType);
5676 llvm::FoldingSetNodeID ID;
5679 void *InsertPos =
nullptr;
5681 UnresolvedUsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5682 return QualType(Placeholder->getType(), 0);
5686 const Type *
T = getUnresolvedUsingTypeInternal(
Keyword, Qualifier,
D,
5687 InsertPos, CanonicalType);
5694 const Attr *attr)
const {
5695 llvm::FoldingSetNodeID id;
5698 void *insertPos =
nullptr;
5702 assert(!
attr ||
attr->getKind() == attrKind);
5708 Types.push_back(
type);
5709 AttributedTypes.InsertNode(
type, insertPos);
5722 switch (nullability) {
5738 llvm_unreachable(
"Unknown nullability kind");
5743 llvm::FoldingSetNodeID ID;
5746 void *InsertPos =
nullptr;
5748 BTFTagAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
5756 Types.push_back(Ty);
5757 BTFTagAttributedTypes.InsertNode(Ty, InsertPos);
5766 llvm::FoldingSetNodeID ID;
5769 void *InsertPos =
nullptr;
5771 HLSLAttributedResourceTypes.FindNodeOrInsertPos(ID, InsertPos);
5778 Types.push_back(Ty);
5779 HLSLAttributedResourceTypes.InsertNode(Ty, InsertPos);
5787 llvm::FoldingSetNodeID ID;
5790 void *InsertPos =
nullptr;
5792 HLSLInlineSpirvTypes.FindNodeOrInsertPos(ID, InsertPos);
5797 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5802 Types.push_back(Ty);
5803 HLSLInlineSpirvTypes.InsertNode(Ty, InsertPos);
5810 Decl *AssociatedDecl,
5814 llvm::FoldingSetNodeID ID;
5817 void *InsertPos =
nullptr;
5819 SubstTemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5822 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5823 !Replacement.isCanonical()),
5826 Index, PackIndex, Final);
5827 Types.push_back(SubstParm);
5828 SubstTemplateTypeParmTypes.InsertNode(SubstParm, InsertPos);
5836 unsigned Index,
bool Final,
5843 llvm::FoldingSetNodeID ID;
5846 void *InsertPos =
nullptr;
5848 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos))
5858 [[maybe_unused]]
const auto *Nothing =
5859 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos);
5867 Types.push_back(SubstParm);
5868 SubstTemplateTypeParmPackTypes.InsertNode(SubstParm, InsertPos);
5876 return P.getKind() == TemplateArgument::Type;
5878 "Pack contains a non-type");
5880 llvm::FoldingSetNodeID ID;
5883 void *InsertPos =
nullptr;
5885 SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos))
5895 Types.push_back(PackType);
5896 SubstBuiltinTemplatePackTypes.InsertNode(PackType, InsertPos);
5906 llvm::FoldingSetNodeID ID;
5908 void *InsertPos =
nullptr;
5910 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5921 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5922 assert(!TypeCheck &&
"Template type parameter canonical type broken");
5926 Depth, Index, ParameterPack,
nullptr,
QualType());
5928 Types.push_back(TypeParm);
5929 TemplateTypeParmTypes.InsertNode(TypeParm, InsertPos);
5945 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
5955 SpecifiedArgVec.reserve(SpecifiedArgs.size());
5957 SpecifiedArgVec.push_back(Arg.getArgument());
5960 CanonicalArgs, Underlying);
5963[[maybe_unused]]
static bool
5966 if (Arg.isPackExpansion())
5975 assert(!Args.empty());
5977 for (
const auto &Arg : Args)
5981 llvm::FoldingSetNodeID ID;
5983 void *InsertPos =
nullptr;
5984 if (
auto *
T = TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
5990 auto *Spec =
new (Mem)
5993 assert(Spec->isDependentType() &&
5994 "canonical template specialization must be dependent");
5995 Types.push_back(Spec);
5996 TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
6004 assert(!
Template.getUnderlying().getAsDependentTemplateName() &&
6005 "No dependent template names here!");
6007 const auto *TD =
Template.getAsTemplateDecl(
true);
6008 bool IsTypeAlias = TD && TD->isTypeAlias();
6009 if (Underlying.
isNull()) {
6015 if (CanonicalArgs.empty()) {
6018 CanonicalArgs = CanonArgsVec;
6020 NonCanonical |= !llvm::equal(
6021 SpecifiedArgs, CanonicalArgs,
6030 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
6032 "Caller must compute aliased type");
6033 IsTypeAlias =
false;
6042 (IsTypeAlias ?
sizeof(
QualType) : 0),
6046 Types.push_back(Spec);
6052 llvm::FoldingSetNodeID ID;
6055 void *InsertPos =
nullptr;
6056 ParenType *
T = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6063 ParenType *CheckT = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6064 assert(!CheckT &&
"Paren canonical type broken");
6070 ParenTypes.InsertNode(
T, InsertPos);
6083 Types.push_back(newType);
6108 llvm_unreachable(
"unexpected keyword kind");
6114 llvm::FoldingSetNodeID ID;
6117 void *InsertPos =
nullptr;
6119 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos))
6127 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6130 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos);
6131 assert(!
T &&
"broken canonicalization");
6138 DependentNameTypes.InsertNode(
T, InsertPos);
6147 for (
unsigned I = 0,
E = Args.size(); I !=
E; ++I)
6155 llvm::FoldingSetNodeID ID;
6158 if (
auto const T_iter = DependentTemplateSpecializationTypes.find(ID);
6159 T_iter != DependentTemplateSpecializationTypes.end())
6160 return QualType(T_iter->getSecond(), 0);
6169 bool AnyNonCanonArgs =
false;
6173 if (CanonKeyword !=
Keyword || AnyNonCanonArgs || CanonNNS != NNS ||
6174 !Name.hasTemplateKeyword()) {
6176 CanonKeyword, {CanonNNS, Name.getName(),
true},
6182 assert(Name.hasTemplateKeyword());
6185 for (
const auto &Arg : Args)
6195 llvm::FoldingSetNodeID InsertedID;
6197 assert(InsertedID == ID &&
"ID does not match");
6200 DependentTemplateSpecializationTypes.try_emplace(ID,
T);
6206 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6208 if (TTP->isParameterPack())
6212 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6214 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6229 Expr *
E =
new (*this)
6231 T,
VK, NTTP->getLocation());
6233 if (NTTP->isParameterPack())
6237 auto *TTP = cast<TemplateTemplateParmDecl>(Param);
6239 std::nullopt,
false,
6241 if (TTP->isParameterPack())
6256 bool ExpectPackInType)
const {
6258 "Pack expansions must expand one or more parameter packs");
6260 llvm::FoldingSetNodeID ID;
6263 void *InsertPos =
nullptr;
6275 PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
6281 PackExpansionTypes.InsertNode(
T, InsertPos);
6293 if (Protocols.empty())
return true;
6298 for (
unsigned i = 1; i != Protocols.size(); ++i)
6308 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6312 P =
P->getCanonicalDecl();
6315 auto ProtocolsEnd = llvm::unique(Protocols);
6316 Protocols.erase(ProtocolsEnd, Protocols.end());
6321 unsigned NumProtocols)
const {
6330 bool isKindOf)
const {
6333 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6334 isa<ObjCInterfaceType>(baseType))
6338 llvm::FoldingSetNodeID ID;
6340 void *InsertPos =
nullptr;
6341 if (
ObjCObjectType *QT = ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos))
6348 if (effectiveTypeArgs.empty()) {
6350 effectiveTypeArgs = baseObject->getTypeArgs();
6357 bool typeArgsAreCanonical = llvm::all_of(
6360 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6364 if (!typeArgsAreCanonical) {
6365 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6366 for (
auto typeArg : effectiveTypeArgs)
6368 canonTypeArgs = canonTypeArgsVec;
6370 canonTypeArgs = effectiveTypeArgs;
6375 if (!protocolsSorted) {
6376 canonProtocolsVec.append(protocols.begin(), protocols.end());
6378 canonProtocols = canonProtocolsVec;
6380 canonProtocols = protocols;
6384 canonProtocols, isKindOf);
6387 ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos);
6391 size += typeArgs.size() *
sizeof(
QualType);
6399 ObjCObjectTypes.InsertNode(
T, InsertPos);
6409 bool allowOnPointerType)
const {
6412 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6417 if (allowOnPointerType) {
6418 if (
const auto *objPtr =
6419 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6425 protocolsVec.append(protocols.begin(), protocols.end());
6437 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6442 objT->getTypeArgsAsWritten(),
6444 objT->isKindOfTypeAsWritten());
6448 if (
type->isObjCObjectType()) {
6458 if (
type->isObjCIdType()) {
6461 objPtr->isKindOfType());
6466 if (
type->isObjCClassType()) {
6469 objPtr->isKindOfType());
6481 llvm::FoldingSetNodeID ID;
6483 void *InsertPos =
nullptr;
6485 ObjCTypeParamTypes.FindNodeOrInsertPos(ID, InsertPos))
6490 if (!protocols.empty()) {
6494 Canonical, protocols, hasError,
true ));
6495 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6503 Types.push_back(newType);
6504 ObjCTypeParamTypes.InsertNode(newType, InsertPos);
6512 auto *NewTypeParamTy = cast<ObjCTypeParamType>(
New->TypeForDecl);
6514 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6529 for (
auto *Proto : OPT->quals()) {
6552 if (InheritedProtocols.empty())
6556 bool Conforms =
false;
6557 for (
auto *Proto : OPT->quals()) {
6559 for (
auto *PI : InheritedProtocols) {
6571 for (
auto *PI : InheritedProtocols) {
6573 bool Adopts =
false;
6574 for (
auto *Proto : OPT->quals()) {
6588 llvm::FoldingSetNodeID ID;
6591 void *InsertPos =
nullptr;
6593 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
6602 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
6611 Types.push_back(QType);
6612 ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
6620 if (
Decl->TypeForDecl)
6624 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6625 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6626 return QualType(PrevDecl->TypeForDecl, 0);
6635 Decl->TypeForDecl =
T;
6648 llvm::FoldingSetNodeID ID;
6652 void *InsertPos =
nullptr;
6654 DependentTypeOfExprTypes.FindNodeOrInsertPos(ID, InsertPos);
6664 DependentTypeOfExprTypes.InsertNode(Canon, InsertPos);
6672 Types.push_back(toe);
6685 Types.push_back(tot);
6709 llvm_unreachable(
"Unknown value kind");
6724 }
else if (!UnderlyingType.
isNull()) {
6727 llvm::FoldingSetNodeID ID;
6730 void *InsertPos =
nullptr;
6732 DependentDecltypeTypes.FindNodeOrInsertPos(ID, InsertPos))
6738 DependentDecltypeTypes.InsertNode(DT, InsertPos);
6739 Types.push_back(DT);
6744 Types.push_back(DT);
6749 bool FullySubstituted,
6753 if (FullySubstituted && Index) {
6756 llvm::FoldingSetNodeID ID;
6758 FullySubstituted, Expansions);
6759 void *InsertPos =
nullptr;
6761 DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos);
6764 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6768 IndexExpr, FullySubstituted, Expansions);
6769 DependentPackIndexingTypes.InsertNode(Canon, InsertPos);
6775 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6778 FullySubstituted, Expansions);
6789 llvm::FoldingSetNodeID ID;
6792 void *InsertPos =
nullptr;
6794 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos))
6801 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6804 BaseType != CanonBase) {
6810 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos);
6811 assert(!UT &&
"broken canonicalization");
6817 UnaryTransformTypes.InsertNode(UT, InsertPos);
6818 Types.push_back(UT);
6822QualType ASTContext::getAutoTypeInternal(
6827 !TypeConstraintConcept && !IsDependent)
6831 llvm::FoldingSetNodeID ID;
6832 bool IsDeducedDependent =
6833 isa_and_nonnull<TemplateTemplateParmDecl>(TypeConstraintConcept) ||
6836 IsDependent || IsDeducedDependent, TypeConstraintConcept,
6837 TypeConstraintArgs);
6838 if (
auto const AT_iter = AutoTypes.find(ID); AT_iter != AutoTypes.end())
6839 return QualType(AT_iter->getSecond(), 0);
6845 }
else if (TypeConstraintConcept) {
6846 bool AnyNonCanonArgs =
false;
6847 auto *CanonicalConcept =
6850 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6851 if (CanonicalConcept != TypeConstraintConcept || AnyNonCanonArgs) {
6853 CanonicalConcept, CanonicalConceptArgs,
6864 (IsDependent ? TypeDependence::DependentInstantiation
6865 : TypeDependence::None) |
6866 (IsPack ? TypeDependence::UnexpandedPack : TypeDependence::None),
6867 Canon, TypeConstraintConcept, TypeConstraintArgs);
6869 llvm::FoldingSetNodeID InsertedID;
6870 AT->
Profile(InsertedID, *
this);
6871 assert(InsertedID == ID &&
"ID does not match");
6873 Types.push_back(AT);
6874 AutoTypes.try_emplace(ID, AT);
6883 bool IsDependent,
bool IsPack,
6886 assert((!IsPack || IsDependent) &&
"only use IsPack for a dependent pack");
6888 "A dependent auto should be undeduced");
6890 TypeConstraintConcept, TypeConstraintArgs);
6894 QualType CanonT =
T.getNonPackExpansionType().getCanonicalType();
6898 if (!AT->isConstrained())
6902 AT->containsUnexpandedParameterPack()),
6914QualType ASTContext::getDeducedTemplateSpecializationTypeInternal(
6916 bool IsDependent,
QualType Canon)
const {
6918 void *InsertPos =
nullptr;
6919 llvm::FoldingSetNodeID ID;
6923 DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
6928 IsDependent, Canon);
6931 llvm::FoldingSetNodeID TempID;
6932 DTST->Profile(TempID);
6933 assert(ID == TempID &&
"ID does not match");
6935 Types.push_back(DTST);
6936 DeducedTemplateSpecializationTypes.InsertNode(DTST, InsertPos);
6945 bool IsDependent)
const {
6952 ? getDeducedTemplateSpecializationTypeInternal(
6956 return getDeducedTemplateSpecializationTypeInternal(
6965 llvm::FoldingSetNodeID ID;
6968 void *InsertPos =
nullptr;
6969 if (
AtomicType *AT = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos))
6975 if (!
T.isCanonical()) {
6979 AtomicType *NewIP = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos);
6980 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
6983 Types.push_back(
New);
6984 AtomicTypes.InsertNode(
New, InsertPos);
7015 return getFromTargetType(
Target->getSizeType());
7039 return getFromTargetType(
Target->getIntMaxType());
7044 return getFromTargetType(
Target->getUIntMaxType());
7062 return getFromTargetType(
Target->getIntPtrType());
7072 return getFromTargetType(
Target->getProcessIDType());
7084 const Type *Ty =
T.getTypePtr();
7088 }
else if (isa<ArrayType>(Ty)) {
7090 }
else if (isa<FunctionType>(Ty)) {
7112 quals = splitType.
Quals;
7117 QualType elementType = AT->getElementType();
7122 if (elementType == unqualElementType) {
7123 assert(quals.
empty());
7124 quals = splitType.
Quals;
7132 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7134 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7137 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7141 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7143 VAT->getSizeModifier(),
7144 VAT->getIndexTypeCVRQualifiers());
7147 const auto *DSAT = cast<DependentSizedArrayType>(AT);
7149 DSAT->getSizeModifier(), 0);
7159 bool AllowPiMismatch)
const {
7174 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7175 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7176 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7178 isa<IncompleteArrayType>(AT2))))
7180 }
else if (isa<IncompleteArrayType>(AT1)) {
7181 if (!(isa<IncompleteArrayType>(AT2) ||
7183 isa<ConstantArrayType>(AT2))))
7189 T1 = AT1->getElementType();
7190 T2 = AT2->getElementType();
7210 bool AllowPiMismatch)
const {
7215 if (T1PtrType && T2PtrType) {
7223 T1MPType && T2MPType) {
7224 if (
auto *RD1 = T1MPType->getMostRecentCXXRecordDecl(),
7225 *RD2 = T2MPType->getMostRecentCXXRecordDecl();
7226 RD1 != RD2 && RD1->getCanonicalDecl() != RD2->getCanonicalDecl())
7228 if (T1MPType->getQualifier().getCanonical() !=
7229 T2MPType->getQualifier().getCanonical())
7239 if (T1OPType && T2OPType) {
7271 if (Quals1 != Quals2)
7285 switch (Name.getKind()) {
7321 = Name.getAsSubstTemplateTemplateParm();
7328 = Name.getAsSubstTemplateTemplateParmPack();
7341 llvm_unreachable(
"bad template name kind!");
7347 if (!TP->hasDefaultArgument())
7349 return &TP->getDefaultArgument().getArgument();
7351 switch (
P->getKind()) {
7352 case NamedDecl::TemplateTypeParm:
7353 return handleParam(cast<TemplateTypeParmDecl>(
P));
7354 case NamedDecl::NonTypeTemplateParm:
7355 return handleParam(cast<NonTypeTemplateParmDecl>(
P));
7356 case NamedDecl::TemplateTemplateParm:
7357 return handleParam(cast<TemplateTemplateParmDecl>(
P));
7359 llvm_unreachable(
"Unexpected template parameter kind");
7364 bool IgnoreDeduced)
const {
7365 while (std::optional<TemplateName> UnderlyingOrNone =
7366 Name.desugar(IgnoreDeduced))
7367 Name = *UnderlyingOrNone;
7369 switch (Name.getKind()) {
7372 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7381 llvm_unreachable(
"cannot canonicalize unresolved template");
7385 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7396 Name.getAsSubstTemplateTemplateParmPack();
7404 assert(IgnoreDeduced ==
false);
7411 bool NonCanonical = CanonUnderlying != Underlying;
7417 assert(CanonArgs.size() <= Params.size());
7423 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7432 if (I ==
int(CanonArgs.size() - 1))
7433 CanonArgs.pop_back();
7434 NonCanonical =
true;
7444 llvm_unreachable(
"always sugar node");
7447 llvm_unreachable(
"bad template name!");
7452 bool IgnoreDeduced)
const {
7473 llvm::FoldingSetNodeID XCEID, YCEID;
7474 XCE->
Profile(XCEID, *
this,
true,
true);
7475 YCE->
Profile(YCEID, *
this,
true,
true);
7476 return XCEID == YCEID;
7525 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7526 auto *TY = cast<TemplateTypeParmDecl>(Y);
7527 if (TX->isParameterPack() != TY->isParameterPack())
7529 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7532 TY->getTypeConstraint());
7535 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7536 auto *TY = cast<NonTypeTemplateParmDecl>(Y);
7537 return TX->isParameterPack() == TY->isParameterPack() &&
7538 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7540 TY->getPlaceholderTypeConstraint());
7543 auto *TX = cast<TemplateTemplateParmDecl>(
X);
7544 auto *TY = cast<TemplateTemplateParmDecl>(Y);
7545 return TX->isParameterPack() == TY->isParameterPack() &&
7547 TY->getTemplateParameters());
7552 if (
X->size() != Y->
size())
7555 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7569 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7570 auto *TTPY = cast<TemplateTypeParmDecl>(Y);
7571 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7574 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7575 TTPY->getDefaultArgument().getArgument().getAsType());
7578 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7579 auto *NTTPY = cast<NonTypeTemplateParmDecl>(Y);
7580 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7583 Expr *DefaultArgumentX =
7584 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7585 Expr *DefaultArgumentY =
7586 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7587 llvm::FoldingSetNodeID XID, YID;
7588 DefaultArgumentX->
Profile(XID, *
this,
true);
7589 DefaultArgumentY->
Profile(YID, *
this,
true);
7593 auto *TTPX = cast<TemplateTemplateParmDecl>(
X);
7594 auto *TTPY = cast<TemplateTemplateParmDecl>(Y);
7596 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7611 auto Kind =
X.getKind();
7619 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7622 NamespaceY->getNamespace()))
7627 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7628 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7637 llvm_unreachable(
"unhandled qualifier kind");
7643 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7645 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7657 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7661 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7662 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7663 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7666 if (!Cand1A || !Cand2A)
7672 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7673 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7677 if (Cand1ID != Cand2ID)
7711 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7712 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7714 TypedefY->getUnderlyingType());
7721 if (isa<ObjCInterfaceDecl>(
X) || isa<ObjCProtocolDecl>(
X))
7724 if (isa<ClassTemplateSpecializationDecl>(
X)) {
7731 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7732 const auto *TagY = cast<TagDecl>(Y);
7733 return (TagX->getTagKind() == TagY->getTagKind()) ||
7745 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7746 const auto *FuncY = cast<FunctionDecl>(Y);
7747 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7748 const auto *CtorY = cast<CXXConstructorDecl>(Y);
7749 if (CtorX->getInheritedConstructor() &&
7750 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7751 CtorY->getInheritedConstructor().getConstructor()))
7755 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7760 if (FuncX->isMultiVersion()) {
7761 const auto *TAX = FuncX->getAttr<TargetAttr>();
7762 const auto *TAY = FuncY->getAttr<TargetAttr>();
7763 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7765 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7771 if ((FuncX->isMemberLikeConstrainedFriend() ||
7772 FuncY->isMemberLikeConstrainedFriend()) &&
7773 !FuncX->getLexicalDeclContext()->Equals(
7774 FuncY->getLexicalDeclContext())) {
7779 FuncY->getTrailingRequiresClause()))
7787 FD = FD->getCanonicalDecl();
7788 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7791 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7806 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7811 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7812 const auto *VarY = cast<VarDecl>(Y);
7813 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7816 if (VarX->getType().isNull() || VarY->getType().isNull())
7819 if (
hasSameType(VarX->getType(), VarY->getType()))
7829 if (!VarXTy || !VarYTy)
7838 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7839 const auto *NamespaceY = cast<NamespaceDecl>(Y);
7840 return NamespaceX->isInline() == NamespaceY->isInline();
7845 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7846 const auto *TemplateY = cast<TemplateDecl>(Y);
7849 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7850 const auto *ConceptY = cast<ConceptDecl>(Y);
7852 ConceptY->getConstraintExpr()))
7857 TemplateY->getTemplatedDecl()) &&
7859 TemplateY->getTemplateParameters());
7863 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7864 const auto *FDY = cast<FieldDecl>(Y);
7866 return hasSameType(FDX->getType(), FDY->getType());
7870 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7871 const auto *IFDY = cast<IndirectFieldDecl>(Y);
7872 return IFDX->getAnonField()->getCanonicalDecl() ==
7873 IFDY->getAnonField()->getCanonicalDecl();
7877 if (isa<EnumConstantDecl>(
X))
7882 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7883 const auto *USY = cast<UsingShadowDecl>(Y);
7889 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7890 const auto *UY = cast<UsingDecl>(Y);
7892 UX->hasTypename() == UY->hasTypename() &&
7893 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7895 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7896 const auto *UY = cast<UnresolvedUsingValueDecl>(Y);
7898 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7900 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7903 cast<UnresolvedUsingTypenameDecl>(Y)->getQualifier());
7908 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
7910 UX->getInstantiatedFromUsingDecl(),
7911 cast<UsingPackDecl>(Y)->getInstantiatedFromUsingDecl());
7915 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
7916 const auto *NAY = cast<NamespaceAliasDecl>(Y);
7917 return NAX->getNamespace()->Equals(NAY->getNamespace());
7965 bool AnyNonCanonArgs =
false;
7968 if (!AnyNonCanonArgs)
7978 llvm_unreachable(
"Unhandled template argument kind");
7988 llvm_unreachable(
"Comparing NULL template argument");
8013 llvm::FoldingSetNodeID ID1, ID2;
8023 return isSameTemplateArgument(Arg1, Arg2);
8027 llvm_unreachable(
"Unhandled template argument kind");
8032 if (!
T.hasLocalQualifiers()) {
8034 if (
const auto *AT = dyn_cast<ArrayType>(
T))
8039 if (!isa<ArrayType>(
T.getCanonicalType()))
8054 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
8055 if (!ATy || qs.
empty())
8062 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
8065 CAT->getSizeModifier(),
8066 CAT->getIndexTypeCVRQualifiers()));
8067 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
8069 IAT->getSizeModifier(),
8070 IAT->getIndexTypeCVRQualifiers()));
8072 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
8074 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
8075 DSAT->getIndexTypeCVRQualifiers()));
8077 const auto *VAT = cast<VariableArrayType>(ATy);
8078 return cast<ArrayType>(
8080 VAT->getIndexTypeCVRQualifiers()));
8094 return T.getUnqualifiedType();
8107 return T.getUnqualifiedType();
8122 assert(PrettyArrayType &&
"Not an array type!");
8159 uint64_t ElementCount = 1;
8162 CA = dyn_cast_or_null<ConstantArrayType>(
8165 return ElementCount;
8173 uint64_t ElementCount = 1;
8177 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8180 return ElementCount;
8190 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8192 case BuiltinType::Half:
return HalfRank;
8193 case BuiltinType::Float:
return FloatRank;
8226unsigned ASTContext::getIntegerRank(
const Type *
T)
const {
8231 if (
const auto *EIT = dyn_cast<BitIntType>(
T))
8232 return 0 + (EIT->getNumBits() << 3);
8234 switch (cast<BuiltinType>(
T)->getKind()) {
8235 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8236 case BuiltinType::Bool:
8238 case BuiltinType::Char_S:
8239 case BuiltinType::Char_U:
8240 case BuiltinType::SChar:
8241 case BuiltinType::UChar:
8243 case BuiltinType::Short:
8244 case BuiltinType::UShort:
8246 case BuiltinType::Int:
8247 case BuiltinType::UInt:
8249 case BuiltinType::Long:
8250 case BuiltinType::ULong:
8252 case BuiltinType::LongLong:
8253 case BuiltinType::ULongLong:
8255 case BuiltinType::Int128:
8256 case BuiltinType::UInt128:
8261 case BuiltinType::Char8:
8263 case BuiltinType::Char16:
8264 return getIntegerRank(
8266 case BuiltinType::Char32:
8267 return getIntegerRank(
8269 case BuiltinType::WChar_S:
8270 case BuiltinType::WChar_U:
8271 return getIntegerRank(
8301 uint64_t BitWidth = Field->getBitWidthValue();
8324 if (
QualType QT = Field->getType(); QT->isBitIntType())
8327 if (BitWidth < IntSize)
8330 if (BitWidth == IntSize)
8345 assert(!Promotable.
isNull());
8348 return ED->getPromotionType();
8357 if (BT->getKind() == BuiltinType::WChar_S ||
8358 BT->getKind() == BuiltinType::WChar_U ||
8359 BT->getKind() == BuiltinType::Char8 ||
8360 BT->getKind() == BuiltinType::Char16 ||
8361 BT->getKind() == BuiltinType::Char32) {
8362 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8366 for (
const auto &PT : PromoteTypes) {
8368 if (FromSize < ToSize ||
8369 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8372 llvm_unreachable(
"char type should fit into long long");
8379 uint64_t PromotableSize =
getIntWidth(Promotable);
8388 while (!
T.isNull()) {
8390 return T.getObjCLifetime();
8421 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8423 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8426 if (LHSC == RHSC)
return 0;
8431 unsigned LHSRank = getIntegerRank(LHSC);
8432 unsigned RHSRank = getIntegerRank(RHSC);
8434 if (LHSUnsigned == RHSUnsigned) {
8435 if (LHSRank == RHSRank)
return 0;
8436 return LHSRank > RHSRank ? 1 : -1;
8442 if (LHSRank >= RHSRank)
8452 if (RHSRank >= LHSRank)
8462 if (CFConstantStringTypeDecl)
8463 return CFConstantStringTypeDecl;
8465 assert(!CFConstantStringTagDecl &&
8466 "tag and typedef should be initialized together");
8506 if (
static_cast<unsigned>(CFRuntime) <
8509 Fields[Count++] = {
IntTy,
"flags" };
8511 Fields[Count++] = {
LongTy,
"length" };
8515 Fields[Count++] = { getFromTargetType(
Target->getUInt64Type()),
"_swift_rc" };
8519 Fields[Count++] = {
IntTy,
"_ptr" };
8525 for (
unsigned i = 0; i < Count; ++i) {
8529 Fields[i].Type,
nullptr,
8532 CFConstantStringTagDecl->
addDecl(Field);
8539 CFConstantStringTypeDecl =
8542 return CFConstantStringTypeDecl;
8546 if (!CFConstantStringTagDecl)
8548 return CFConstantStringTagDecl;
8558 if (ObjCSuperType.
isNull()) {
8563 return ObjCSuperType;
8568 CFConstantStringTypeDecl = cast<TypedefDecl>(TT->getDecl());
8569 CFConstantStringTagDecl = TT->castAsRecordDecl();
8573 if (BlockDescriptorType)
8586 static const char *
const FieldNames[] = {
8591 for (
size_t i = 0; i < 2; ++i) {
8594 &
Idents.
get(FieldNames[i]), FieldTypes[i],
nullptr,
8602 BlockDescriptorType = RD;
8608 if (BlockDescriptorExtendedType)
8623 static const char *
const FieldNames[] = {
8630 for (
size_t i = 0; i < 4; ++i) {
8633 &
Idents.
get(FieldNames[i]), FieldTypes[i],
nullptr,
8642 BlockDescriptorExtendedType = RD;
8647 const auto *BT = dyn_cast<BuiltinType>(
T);
8650 if (isa<PipeType>(
T))
8656 switch (BT->getKind()) {
8657#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8658 case BuiltinType::Id: \
8660#include "clang/Basic/OpenCLImageTypes.def"
8662 case BuiltinType::OCLClkEvent:
8665 case BuiltinType::OCLEvent:
8668 case BuiltinType::OCLQueue:
8671 case BuiltinType::OCLReserveID:
8674 case BuiltinType::OCLSampler:
8693 if (!copyExpr && record->hasTrivialDestructor())
return false;
8724 llvm_unreachable(
"impossible");
8726 llvm_unreachable(
"fell out of lifetime switch!");
8734 bool &HasByrefExtendedLayout)
const {
8739 HasByrefExtendedLayout =
false;
8741 HasByrefExtendedLayout =
true;
8755 assert(
Target &&
"Expected target to be initialized");
8756 const llvm::Triple &
T =
Target->getTriple();
8758 if (
T.isOSWindows() &&
T.isArch64Bit())
8764 assert(
Target &&
"Expected target to be initialized");
8765 const llvm::Triple &
T =
Target->getTriple();
8767 if (
T.isOSWindows() &&
T.isArch64Bit())
8773 if (!ObjCInstanceTypeDecl)
8774 ObjCInstanceTypeDecl =
8776 return ObjCInstanceTypeDecl;
8782 if (
const auto *TT = dyn_cast<TypedefType>(
T))
8784 return II->isStr(
"BOOL");
8792 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8801 else if (
type->isArrayType())
8820 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8827 !
D->isInlineSpecified() && (
D->isConstexpr() ||
First->isConstexpr()))
8858 for (
auto *PI :
Decl->parameters()) {
8863 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8872 ParmOffset = PtrSize;
8873 for (
auto *PVDecl :
Decl->parameters()) {
8874 QualType PType = PVDecl->getOriginalType();
8875 if (
const auto *AT =
8879 if (!isa<ConstantArrayType>(AT))
8880 PType = PVDecl->getType();
8882 PType = PVDecl->getType();
8902 for (
auto *PI :
Decl->parameters()) {
8909 "getObjCEncodingForFunctionDecl - Incomplete param type");
8916 for (
auto *PVDecl :
Decl->parameters()) {
8917 QualType PType = PVDecl->getOriginalType();
8918 if (
const auto *AT =
8922 if (!isa<ConstantArrayType>(AT))
8923 PType = PVDecl->getType();
8925 PType = PVDecl->getType();
8939 bool Extended)
const {
8943 ObjCEncOptions Options = ObjCEncOptions()
8944 .setExpandPointedToStructures()
8945 .setExpandStructures()
8946 .setIsOutermostType();
8948 Options.setEncodeBlockParameters().setEncodeClassNames();
8949 getObjCEncodingForTypeImpl(
T, S, Options,
nullptr);
8955 bool Extended)
const {
8960 Decl->getReturnType(), S, Extended);
8969 E =
Decl->sel_param_end(); PI !=
E; ++PI) {
8976 "getObjCEncodingForMethodDecl - Incomplete param type");
8984 ParmOffset = 2 * PtrSize;
8986 E =
Decl->sel_param_end(); PI !=
E; ++PI) {
8989 if (
const auto *AT =
8993 if (!isa<ConstantArrayType>(AT))
8998 PType, S, Extended);
9009 const Decl *Container)
const {
9012 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
9013 for (
auto *PID : CID->property_impls())
9014 if (PID->getPropertyDecl() == PD)
9017 const auto *OID = cast<ObjCImplementationDecl>(Container);
9018 for (
auto *PID : OID->property_impls())
9019 if (PID->getPropertyDecl() == PD)
9053 const Decl *Container)
const {
9055 bool Dynamic =
false;
9063 SynthesizePID = PropertyImpDecl;
9067 std::string S =
"T";
9112 if (SynthesizePID) {
9129 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9132 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9145 getObjCEncodingForTypeImpl(
T, S,
9147 .setExpandPointedToStructures()
9148 .setExpandStructures()
9149 .setIsOutermostType(),
9150 Field, NotEncodedT);
9154 std::string& S)
const {
9158 getObjCEncodingForTypeImpl(
T, S,
9160 .setExpandPointedToStructures()
9161 .setExpandStructures()
9162 .setIsOutermostType()
9163 .setEncodingProperty(),
9171 case BuiltinType::Void:
return 'v';
9172 case BuiltinType::Bool:
return 'B';
9173 case BuiltinType::Char8:
9174 case BuiltinType::Char_U:
9175 case BuiltinType::UChar:
return 'C';
9176 case BuiltinType::Char16:
9177 case BuiltinType::UShort:
return 'S';
9178 case BuiltinType::Char32:
9179 case BuiltinType::UInt:
return 'I';
9180 case BuiltinType::ULong:
9181 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9182 case BuiltinType::UInt128:
return 'T';
9183 case BuiltinType::ULongLong:
return 'Q';
9184 case BuiltinType::Char_S:
9185 case BuiltinType::SChar:
return 'c';
9186 case BuiltinType::Short:
return 's';
9187 case BuiltinType::WChar_S:
9188 case BuiltinType::WChar_U:
9189 case BuiltinType::Int:
return 'i';
9190 case BuiltinType::Long:
9191 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9192 case BuiltinType::LongLong:
return 'q';
9193 case BuiltinType::Int128:
return 't';
9194 case BuiltinType::Float:
return 'f';
9195 case BuiltinType::Double:
return 'd';
9196 case BuiltinType::LongDouble:
return 'D';
9197 case BuiltinType::NullPtr:
return '*';
9199 case BuiltinType::BFloat16:
9200 case BuiltinType::Float16:
9201 case BuiltinType::Float128:
9202 case BuiltinType::Ibm128:
9203 case BuiltinType::Half:
9204 case BuiltinType::ShortAccum:
9205 case BuiltinType::Accum:
9206 case BuiltinType::LongAccum:
9207 case BuiltinType::UShortAccum:
9208 case BuiltinType::UAccum:
9209 case BuiltinType::ULongAccum:
9210 case BuiltinType::ShortFract:
9211 case BuiltinType::Fract:
9212 case BuiltinType::LongFract:
9213 case BuiltinType::UShortFract:
9214 case BuiltinType::UFract:
9215 case BuiltinType::ULongFract:
9216 case BuiltinType::SatShortAccum:
9217 case BuiltinType::SatAccum:
9218 case BuiltinType::SatLongAccum:
9219 case BuiltinType::SatUShortAccum:
9220 case BuiltinType::SatUAccum:
9221 case BuiltinType::SatULongAccum:
9222 case BuiltinType::SatShortFract:
9223 case BuiltinType::SatFract:
9224 case BuiltinType::SatLongFract:
9225 case BuiltinType::SatUShortFract:
9226 case BuiltinType::SatUFract:
9227 case BuiltinType::SatULongFract:
9231#define SVE_TYPE(Name, Id, SingletonId) \
9232 case BuiltinType::Id:
9233#include "clang/Basic/AArch64ACLETypes.def"
9234#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9235#include "clang/Basic/RISCVVTypes.def"
9236#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9237#include "clang/Basic/WebAssemblyReferenceTypes.def"
9238#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9239#include "clang/Basic/AMDGPUTypes.def"
9243 "cannot yet @encode type %0");
9248 case BuiltinType::ObjCId:
9249 case BuiltinType::ObjCClass:
9250 case BuiltinType::ObjCSel:
9251 llvm_unreachable(
"@encoding ObjC primitive type");
9254#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9255 case BuiltinType::Id:
9256#include "clang/Basic/OpenCLImageTypes.def"
9257#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9258 case BuiltinType::Id:
9259#include "clang/Basic/OpenCLExtensionTypes.def"
9260 case BuiltinType::OCLEvent:
9261 case BuiltinType::OCLClkEvent:
9262 case BuiltinType::OCLQueue:
9263 case BuiltinType::OCLReserveID:
9264 case BuiltinType::OCLSampler:
9265 case BuiltinType::Dependent:
9266#define PPC_VECTOR_TYPE(Name, Id, Size) \
9267 case BuiltinType::Id:
9268#include "clang/Basic/PPCTypes.def"
9269#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9270#include "clang/Basic/HLSLIntangibleTypes.def"
9271#define BUILTIN_TYPE(KIND, ID)
9272#define PLACEHOLDER_TYPE(KIND, ID) \
9273 case BuiltinType::KIND:
9274#include "clang/AST/BuiltinTypes.def"
9275 llvm_unreachable(
"invalid builtin type for @encode");
9277 llvm_unreachable(
"invalid BuiltinType::Kind value");
9284 if (!
Enum->isFixed())
9294 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9314 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9322 S += llvm::utostr(Offset);
9337 bool VisitBasesAndFields) {
9342 PT->getPointeeType().getTypePtr(),
false);
9349 if (isa<ClassTemplateSpecializationDecl>(CXXRD))
9352 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9355 for (
const auto &B : CXXRD->bases())
9360 for (
auto *FD : CXXRD->fields())
9369void ASTContext::getObjCEncodingForTypeImpl(
QualType T, std::string &S,
9370 const ObjCEncOptions Options,
9374 switch (CT->getTypeClass()) {
9379 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9401 case Type::LValueReference:
9402 case Type::RValueReference: {
9404 if (isa<PointerType>(CT)) {
9406 if (PT->isObjCSelType()) {
9415 bool isReadOnly =
false;
9421 if (Options.IsOutermostType() &&
T.isConstQualified()) {
9425 }
else if (Options.IsOutermostType()) {
9428 P = PT->getPointeeType();
9429 if (
P.isConstQualified()) {
9438 if (StringRef(S).ends_with(
"nr"))
9439 S.replace(S.end()-2, S.end(),
"rn");
9450 const IdentifierInfo *II = RTy->getOriginalDecl()->getIdentifier();
9466 RTy, Options.ExpandPointedToStructures()))) {
9475 ObjCEncOptions NewOptions;
9476 if (Options.ExpandPointedToStructures())
9477 NewOptions.setExpandStructures();
9478 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9479 nullptr, NotEncodedT);
9483 case Type::ConstantArray:
9484 case Type::IncompleteArray:
9485 case Type::VariableArray: {
9486 const auto *AT = cast<ArrayType>(CT);
9488 if (isa<IncompleteArrayType>(AT) && !Options.IsStructField()) {
9492 getObjCEncodingForTypeImpl(
9493 AT->getElementType(), S,
9494 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9498 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9499 S += llvm::utostr(CAT->getZExtSize());
9502 assert((isa<VariableArrayType>(AT) || isa<IncompleteArrayType>(AT)) &&
9503 "Unknown array type!");
9507 getObjCEncodingForTypeImpl(
9508 AT->getElementType(), S,
9509 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9516 case Type::FunctionNoProto:
9517 case Type::FunctionProto:
9521 case Type::Record: {
9522 RecordDecl *RDecl = cast<RecordType>(CT)->getOriginalDecl();
9523 S += RDecl->
isUnion() ?
'(' :
'{';
9527 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9529 llvm::raw_string_ostream OS(S);
9536 if (Options.ExpandStructures()) {
9539 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9541 for (
const auto *Field : RDecl->
fields()) {
9544 S +=
Field->getNameAsString();
9549 if (
Field->isBitField()) {
9550 getObjCEncodingForTypeImpl(
Field->getType(), S,
9551 ObjCEncOptions().setExpandStructures(),
9556 getObjCEncodingForTypeImpl(
9558 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9564 S += RDecl->
isUnion() ?
')' :
'}';
9568 case Type::BlockPointer: {
9571 if (Options.EncodeBlockParameters()) {
9572 const auto *FT = BT->getPointeeType()->castAs<
FunctionType>();
9576 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9577 Options.forComponentType(), FD, NotEncodedT);
9581 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9582 for (
const auto &I : FPT->param_types())
9583 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9591 case Type::ObjCObject: {
9595 S +=
"{objc_object=}";
9599 S +=
"{objc_class=}";
9606 case Type::ObjCInterface: {
9612 if (Options.ExpandStructures()) {
9616 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9618 if (
Field->isBitField())
9619 getObjCEncodingForTypeImpl(
Field->getType(), S,
9620 ObjCEncOptions().setExpandStructures(),
9623 getObjCEncodingForTypeImpl(
Field->getType(), S,
9624 ObjCEncOptions().setExpandStructures(), FD,
9632 case Type::ObjCObjectPointer: {
9634 if (OPT->isObjCIdType()) {
9639 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9647 if (OPT->isObjCQualifiedIdType()) {
9648 getObjCEncodingForTypeImpl(
9650 Options.keepingOnly(ObjCEncOptions()
9651 .setExpandPointedToStructures()
9652 .setExpandStructures()),
9654 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9658 for (
const auto *I : OPT->quals()) {
9660 S += I->getObjCRuntimeNameAsString();
9669 if (OPT->getInterfaceDecl() &&
9670 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9672 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9673 for (
const auto *I : OPT->quals()) {
9675 S += I->getObjCRuntimeNameAsString();
9685 case Type::MemberPointer:
9689 case Type::ExtVector:
9695 case Type::ConstantMatrix:
9708 case Type::DeducedTemplateSpecialization:
9711 case Type::HLSLAttributedResource:
9712 case Type::HLSLInlineSpirv:
9713 llvm_unreachable(
"unexpected type");
9715 case Type::ArrayParameter:
9717#define ABSTRACT_TYPE(KIND, BASE)
9718#define TYPE(KIND, BASE)
9719#define DEPENDENT_TYPE(KIND, BASE) \
9721#define NON_CANONICAL_TYPE(KIND, BASE) \
9723#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9725#include "clang/AST/TypeNodes.inc"
9726 llvm_unreachable(
"@encode for dependent type!");
9728 llvm_unreachable(
"bad type kind!");
9731void ASTContext::getObjCEncodingForStructureImpl(
RecordDecl *RDecl,
9736 assert(RDecl &&
"Expected non-null RecordDecl");
9737 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9741 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9742 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9746 for (
const auto &BI : CXXRec->bases()) {
9747 if (!BI.isVirtual()) {
9752 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9753 std::make_pair(offs, base));
9759 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9762 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9763 std::make_pair(offs, Field));
9766 if (CXXRec && includeVBases) {
9767 for (
const auto &BI : CXXRec->vbases()) {
9773 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9774 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9775 std::make_pair(offs, base));
9789 std::multimap<uint64_t, NamedDecl *>::iterator
9790 CurLayObj = FieldOrBaseOffsets.begin();
9792 if (CXXRec && CXXRec->isDynamicClass() &&
9793 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9796 std::string recname = CXXRec->getNameAsString();
9797 if (recname.empty()) recname =
"?";
9810 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9811 std::make_pair(offs,
nullptr));
9814 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9816 assert(CurOffs <= CurLayObj->first);
9817 if (CurOffs < CurLayObj->first) {
9818 uint64_t padding = CurLayObj->first - CurOffs;
9834 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9839 getObjCEncodingForStructureImpl(base, S, FD,
false,
9846 const auto *field = cast<FieldDecl>(dcl);
9849 S += field->getNameAsString();
9853 if (field->isBitField()) {
9856 CurOffs += field->getBitWidthValue();
9861 getObjCEncodingForTypeImpl(
9862 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9873 std::string& S)
const {
9906 if (!ObjCClassDecl) {
9911 return ObjCClassDecl;
9915 if (!ObjCProtocolClassDecl) {
9916 ObjCProtocolClassDecl
9925 return ObjCProtocolClassDecl;
9981 const size_t NumFields = 5;
9983 const char *FieldNames[NumFields];
9987 FieldNames[0] =
"__stack";
9991 FieldNames[1] =
"__gr_top";
9995 FieldNames[2] =
"__vr_top";
9998 FieldTypes[3] = Context->
IntTy;
9999 FieldNames[3] =
"__gr_offs";
10002 FieldTypes[4] = Context->
IntTy;
10003 FieldNames[4] =
"__vr_offs";
10006 for (
unsigned i = 0; i < NumFields; ++i) {
10012 FieldTypes[i],
nullptr,
10017 VaListTagDecl->
addDecl(Field);
10034 const size_t NumFields = 5;
10036 const char *FieldNames[NumFields];
10040 FieldNames[0] =
"gpr";
10044 FieldNames[1] =
"fpr";
10048 FieldNames[2] =
"reserved";
10052 FieldNames[3] =
"overflow_arg_area";
10056 FieldNames[4] =
"reg_save_area";
10059 for (
unsigned i = 0; i < NumFields; ++i) {
10064 FieldTypes[i],
nullptr,
10069 VaListTagDecl->
addDecl(Field);
10081 std::nullopt, VaListTagTypedefDecl);
10097 const size_t NumFields = 4;
10099 const char *FieldNames[NumFields];
10103 FieldNames[0] =
"gp_offset";
10107 FieldNames[1] =
"fp_offset";
10111 FieldNames[2] =
"overflow_arg_area";
10115 FieldNames[3] =
"reg_save_area";
10118 for (
unsigned i = 0; i < NumFields; ++i) {
10124 FieldTypes[i],
nullptr,
10129 VaListTagDecl->
addDecl(Field);
10192 const size_t NumFields = 4;
10194 const char *FieldNames[NumFields];
10197 FieldTypes[0] = Context->
LongTy;
10198 FieldNames[0] =
"__gpr";
10201 FieldTypes[1] = Context->
LongTy;
10202 FieldNames[1] =
"__fpr";
10206 FieldNames[2] =
"__overflow_arg_area";
10210 FieldNames[3] =
"__reg_save_area";
10213 for (
unsigned i = 0; i < NumFields; ++i) {
10219 FieldTypes[i],
nullptr,
10224 VaListTagDecl->
addDecl(Field);
10246 const size_t NumFields = 3;
10248 const char *FieldNames[NumFields];
10252 FieldNames[0] =
"__current_saved_reg_area_pointer";
10256 FieldNames[1] =
"__saved_reg_area_end_pointer";
10260 FieldNames[2] =
"__overflow_area_pointer";
10263 for (
unsigned i = 0; i < NumFields; ++i) {
10271 VaListTagDecl->
addDecl(Field);
10283 std::nullopt, VaListTagTypedefDecl);
10303 constexpr size_t NumFields = 3;
10307 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10310 for (
unsigned i = 0; i < NumFields; ++i) {
10313 &Context->
Idents.
get(FieldNames[i]), FieldTypes[i],
nullptr,
10317 VaListTagDecl->
addDecl(Field);
10327 return VaListTagTypedefDecl;
10353 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10357 if (!BuiltinVaListDecl) {
10362 return BuiltinVaListDecl;
10375 if (!BuiltinMSVaListDecl)
10378 return BuiltinMSVaListDecl;
10395 assert(ObjCConstantStringType.
isNull() &&
10396 "'NSConstantString' type already set!");
10406 unsigned size = End -
Begin;
10407 assert(size > 1 &&
"set is not overloaded!");
10413 NamedDecl **Storage = OT->getStorage();
10416 assert(isa<FunctionTemplateDecl>(
D) ||
10417 isa<UnresolvedUsingValueDecl>(
D) ||
10418 (isa<UsingShadowDecl>(
D) &&
10419 isa<FunctionTemplateDecl>(
D->getUnderlyingDecl())));
10436 bool TemplateKeyword,
10441 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10442 assert(!Qualifier &&
"unexpected qualified template template parameter");
10443 assert(TemplateKeyword ==
false);
10448 llvm::FoldingSetNodeID ID;
10451 void *InsertPos =
nullptr;
10453 QualifiedTemplateNames.FindNodeOrInsertPos(ID, InsertPos);
10457 QualifiedTemplateNames.InsertNode(QTN, InsertPos);
10467 llvm::FoldingSetNodeID ID;
10470 void *InsertPos =
nullptr;
10472 DependentTemplateNames.FindNodeOrInsertPos(ID, InsertPos))
10477 DependentTemplateNames.InsertNode(QTN, InsertPos);
10482 Decl *AssociatedDecl,
10485 bool Final)
const {
10486 llvm::FoldingSetNodeID ID;
10488 Index, PackIndex, Final);
10490 void *insertPos =
nullptr;
10492 = SubstTemplateTemplateParms.FindNodeOrInsertPos(ID, insertPos);
10496 Replacement, AssociatedDecl, Index, PackIndex, Final);
10497 SubstTemplateTemplateParms.InsertNode(subst, insertPos);
10505 Decl *AssociatedDecl,
10506 unsigned Index,
bool Final)
const {
10508 llvm::FoldingSetNodeID ID;
10510 AssociatedDecl, Index, Final);
10512 void *InsertPos =
nullptr;
10514 = SubstTemplateTemplateParmPacks.FindNodeOrInsertPos(ID, InsertPos);
10519 SubstTemplateTemplateParmPacks.InsertNode(Subst, InsertPos);
10533 llvm::FoldingSetNodeID ID;
10536 void *InsertPos =
nullptr;
10538 DeducedTemplates.FindNodeOrInsertPos(ID, InsertPos);
10544 DeducedTemplates.InsertNode(DTS, InsertPos);
10567 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10597 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10598 CT = AT->getElementType();
10630 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10631 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10679 uint64_t MinElts = Info.
EC.getKnownMinValue();
10680 return VScale->first * MinElts * EltSize;
10688 "Expected RVV builtin type and vector type!");
10728 return IsValidCast(FirstType, SecondType) ||
10729 IsValidCast(SecondType, FirstType);
10737 "Expected RVV builtin type and vector type!");
10744 if (!BT->isRVVVLSBuiltinType())
10764 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10771 return IsLaxCompatible(FirstType, SecondType) ||
10772 IsLaxCompatible(SecondType, FirstType);
10779 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10782 Ty =
Attr->getModifiedType();
10786 Ty =
Paren->getInnerType();
10818 for (
auto *lhsProto : lhs->
quals()) {
10819 bool match =
false;
10820 for (
auto *rhsProto : rhs->
quals()) {
10851 for (
auto *I : lhs->
quals()) {
10855 if (!rhsID->ClassImplementsProtocol(I,
true))
10863 for (
auto *lhsProto : lhs->
quals()) {
10864 bool match =
false;
10869 for (
auto *rhsProto : rhs->
quals()) {
10879 for (
auto *I : lhs->
quals()) {
10883 if (rhsID->ClassImplementsProtocol(I,
true)) {
10900 for (
auto *lhsProto : lhs->
quals()) {
10901 bool match =
false;
10908 for (
auto *rhsProto : rhs->
quals()) {
10927 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
10929 for (
auto *lhsProto : LHSInheritedProtocols) {
10930 bool match =
false;
10931 for (
auto *rhsProto : rhs->
quals()) {
10961 auto finish = [&](
bool succeeded) ->
bool {
11006 bool BlockReturnType) {
11010 auto finish = [&](
bool succeeded) ->
bool {
11035 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
11039 (!BlockReturnType &&
11043 (BlockReturnType ? LHSOPT : RHSOPT),
11044 (BlockReturnType ? RHSOPT : LHSOPT),
false));
11052 return finish(BlockReturnType);
11054 return finish(!BlockReturnType);
11066 return (*lhs)->getName().compare((*rhs)->getName());
11083 assert(LHS->
getInterface() &&
"LHS must have an interface base");
11084 assert(RHS->
getInterface() &&
"RHS must have an interface base");
11090 for (
auto *proto : LHS->
quals()) {
11101 for (
auto *proto : RHS->
quals()) {
11109 for (
auto *proto : LHSProtocolSet) {
11110 if (RHSProtocolSet.count(proto))
11111 IntersectionSet.push_back(proto);
11120 if (!ImpliedProtocols.empty()) {
11122 return ImpliedProtocols.contains(proto);
11127 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11137 if (lhsOPT && rhsOPT)
11143 if (lhsBlock && rhsBlock)
11148 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11160 bool stripKindOf) {
11161 if (lhsArgs.size() != rhsArgs.size())
11168 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11174 if (!stripKindOf ||
11175 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11176 rhsArgs[i].stripObjCKindOfType(ctx))) {
11204 if (!LDecl || !RDecl)
11214 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11224 bool anyChanges =
false;
11242 if (!Protocols.empty())
11260 if (LHSSuperType.
isNull())
11270 if (KnownLHS != LHSAncestors.end()) {
11271 LHS = KnownLHS->second;
11275 bool anyChanges =
false;
11293 if (!Protocols.empty())
11310 if (RHSSuperType.
isNull())
11321 assert(LHS->
getInterface() &&
"LHS is not an interface type");
11322 assert(RHS->
getInterface() &&
"RHS is not an interface type");
11343 for (
auto *RHSPI : RHS->
quals())
11346 if (SuperClassInheritedProtocols.empty())
11349 for (
const auto *LHSProto : LHS->
quals()) {
11350 bool SuperImplementsProtocol =
false;
11351 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11352 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11353 SuperImplementsProtocol =
true;
11356 if (!SuperImplementsProtocol)
11386 if (!LHSOPT || !RHSOPT)
11404 bool CompareUnqualified) {
11423 bool OfBlockPointer,
11427 if (UD->
hasAttr<TransparentUnionAttr>()) {
11428 for (
const auto *I : UD->
fields()) {
11429 QualType ET = I->getType().getUnqualifiedType();
11443 bool OfBlockPointer,
11464 bool IsConditionalOperator) {
11467 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11468 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11469 bool allLTypes =
true;
11470 bool allRTypes =
true;
11474 if (OfBlockPointer) {
11476 QualType LHS = lbase->getReturnType();
11478 if (!UnqualifiedResult)
11480 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11545 bool NoReturn = IsConditionalOperator
11555 std::optional<FunctionEffectSet> MergedFX;
11557 if (lproto && rproto) {
11558 assert((AllowCXX ||
11559 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11560 "C++ shouldn't be here");
11562 if (lproto->getNumParams() != rproto->getNumParams())
11566 if (lproto->isVariadic() != rproto->isVariadic())
11569 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11573 if (lproto->getExtraAttributeInfo().CFISalt !=
11574 rproto->getExtraAttributeInfo().CFISalt)
11580 if (LHSFX != RHSFX) {
11581 if (IsConditionalOperator)
11590 if (*MergedFX != LHSFX)
11592 if (*MergedFX != RHSFX)
11597 bool canUseLeft, canUseRight;
11609 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11610 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11611 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11613 lParamType, rParamType, OfBlockPointer,
Unqualified);
11620 types.push_back(paramType);
11632 if (allLTypes)
return lhs;
11633 if (allRTypes)
return rhs;
11638 newParamInfos.empty() ? nullptr : newParamInfos.data();
11644 if (lproto) allRTypes =
false;
11645 if (rproto) allLTypes =
false;
11649 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11657 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11663 paramTy = ED->getIntegerType();
11673 if (allLTypes)
return lhs;
11674 if (allRTypes)
return rhs;
11683 if (allLTypes)
return lhs;
11684 if (allRTypes)
return rhs;
11690 QualType other,
bool isBlockReturnType) {
11697 if (underlyingType.
isNull())
11714 if (LangOpts.CPlusPlus || !LangOpts.C23)
11724 return Ctx.IsEquivalent(LHS, RHS) ? LHS :
QualType{};
11729 bool IsConditionalOperator) {
11740 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11744 if (LHSRefTy || RHSRefTy)
11756 if (LHSCan == RHSCan)
11761 Qualifiers RQuals = RHSCan.getLocalQualifiers();
11762 if (LQuals != RQuals) {
11779 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
11800 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
11801 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
11804 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
11805 LHSClass = Type::ConstantArray;
11806 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
11807 RHSClass = Type::ConstantArray;
11810 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
11811 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
11814 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
11815 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
11818 if (LHSClass != RHSClass) {
11828 if (OfBlockPointer && !BlockReturnType) {
11837 if (!AT->isDeduced() && AT->isGNUAutoType())
11841 if (!AT->isDeduced() && AT->isGNUAutoType())
11848 switch (LHSClass) {
11849#define TYPE(Class, Base)
11850#define ABSTRACT_TYPE(Class, Base)
11851#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
11852#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
11853#define DEPENDENT_TYPE(Class, Base) case Type::Class:
11854#include "clang/AST/TypeNodes.inc"
11855 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
11858 case Type::DeducedTemplateSpecialization:
11859 case Type::LValueReference:
11860 case Type::RValueReference:
11861 case Type::MemberPointer:
11862 llvm_unreachable(
"C++ should never be in mergeTypes");
11864 case Type::ObjCInterface:
11865 case Type::IncompleteArray:
11866 case Type::VariableArray:
11867 case Type::FunctionProto:
11868 case Type::ExtVector:
11869 llvm_unreachable(
"Types are eliminated above");
11871 case Type::Pointer:
11882 if (ResultType.
isNull())
11890 case Type::BlockPointer:
11915 if (ResultType.
isNull())
11934 if (ResultType.
isNull())
11942 case Type::ConstantArray:
11957 if (ResultType.
isNull())
11965 if (LVAT || RVAT) {
11968 -> std::pair<bool,llvm::APInt> {
11970 std::optional<llvm::APSInt> TheInt;
11973 return std::make_pair(
true, *TheInt);
11974 return std::make_pair(
false, llvm::APSInt());
11977 return std::make_pair(
true, CAT->getSize());
11978 return std::make_pair(
false, llvm::APInt());
11981 bool HaveLSize, HaveRSize;
11982 llvm::APInt LSize, RSize;
11983 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
11984 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
11985 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
12019 case Type::FunctionNoProto:
12021 false, IsConditionalOperator);
12025 case Type::Builtin:
12028 case Type::Complex:
12037 case Type::ConstantMatrix:
12042 case Type::ObjCObject: {
12051 case Type::ObjCObjectPointer:
12052 if (OfBlockPointer) {
12064 assert(LHS != RHS &&
12065 "Equivalent pipe types should have already been handled!");
12067 case Type::ArrayParameter:
12068 assert(LHS != RHS &&
12069 "Equivalent ArrayParameter types should have already been handled!");
12071 case Type::BitInt: {
12079 if (LHSUnsigned != RHSUnsigned)
12082 if (LHSBits != RHSBits)
12086 case Type::HLSLAttributedResource: {
12093 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
12095 if (LHSTy->
getAttrs() == RHSTy->getAttrs() &&
12100 case Type::HLSLInlineSpirv:
12104 if (LHSTy->
getOpcode() == RHSTy->getOpcode() &&
12105 LHSTy->
getSize() == RHSTy->getSize() &&
12107 for (
size_t I = 0; I < LHSTy->
getOperands().size(); I++)
12108 if (LHSTy->
getOperands()[I] != RHSTy->getOperands()[I])
12116 llvm_unreachable(
"Invalid Type::Class!");
12121 bool &CanUseFirst,
bool &CanUseSecond,
12123 assert(NewParamInfos.empty() &&
"param info list not empty");
12124 CanUseFirst = CanUseSecond =
true;
12130 if (!FirstHasInfo && !SecondHasInfo)
12133 bool NeedParamInfo =
false;
12137 for (
size_t I = 0; I <
E; ++I) {
12148 bool FirstNoEscape = FirstParam.
isNoEscape();
12149 bool SecondNoEscape = SecondParam.
isNoEscape();
12150 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12152 if (NewParamInfos.back().getOpaqueValue())
12153 NeedParamInfo =
true;
12154 if (FirstNoEscape != IsNoEscape)
12155 CanUseFirst =
false;
12156 if (SecondNoEscape != IsNoEscape)
12157 CanUseSecond =
false;
12160 if (!NeedParamInfo)
12161 NewParamInfos.clear();
12167 if (
auto It = ObjCLayouts.find(
D); It != ObjCLayouts.end()) {
12168 It->second =
nullptr;
12169 for (
auto *SubClass : ObjCSubClasses[
D])
12181 if (LHSCan == RHSCan)
12183 if (RHSCan->isFunctionType()) {
12187 cast<FunctionType>(RHSCan.getTypePtr())->getReturnType();
12189 cast<FunctionType>(LHSCan.
getTypePtr())->getReturnType();
12192 if (ResReturnType.
isNull())
12194 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12198 if (
const auto *FPT = cast<FunctionProtoType>(F)) {
12211 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12212 if (LQuals != RQuals) {
12225 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12241 if (ResQT == LHSBaseQT)
12243 if (ResQT == RHSBaseQT)
12255 T = ED->getIntegerType();
12259 return EIT->getNumBits();
12267 "Unexpected type");
12272 VTy->getNumElements(), VTy->getVectorKind());
12281 T = ED->getIntegerType();
12284 case BuiltinType::Char_U:
12286 case BuiltinType::Char_S:
12287 case BuiltinType::SChar:
12288 case BuiltinType::Char8:
12290 case BuiltinType::Short:
12292 case BuiltinType::Int:
12294 case BuiltinType::Long:
12296 case BuiltinType::LongLong:
12298 case BuiltinType::Int128:
12303 case BuiltinType::WChar_S:
12306 case BuiltinType::ShortAccum:
12308 case BuiltinType::Accum:
12310 case BuiltinType::LongAccum:
12312 case BuiltinType::SatShortAccum:
12314 case BuiltinType::SatAccum:
12316 case BuiltinType::SatLongAccum:
12318 case BuiltinType::ShortFract:
12320 case BuiltinType::Fract:
12322 case BuiltinType::LongFract:
12324 case BuiltinType::SatShortFract:
12326 case BuiltinType::SatFract:
12328 case BuiltinType::SatLongFract:
12333 "Unexpected signed integer or fixed point type");
12341 "Unexpected type");
12346 VTy->getNumElements(), VTy->getVectorKind());
12355 T = ED->getIntegerType();
12358 case BuiltinType::Char_S:
12360 case BuiltinType::Char_U:
12361 case BuiltinType::UChar:
12362 case BuiltinType::Char8:
12364 case BuiltinType::UShort:
12366 case BuiltinType::UInt:
12368 case BuiltinType::ULong:
12370 case BuiltinType::ULongLong:
12372 case BuiltinType::UInt128:
12377 case BuiltinType::WChar_U:
12380 case BuiltinType::UShortAccum:
12382 case BuiltinType::UAccum:
12384 case BuiltinType::ULongAccum:
12386 case BuiltinType::SatUShortAccum:
12388 case BuiltinType::SatUAccum:
12390 case BuiltinType::SatULongAccum:
12392 case BuiltinType::UShortFract:
12394 case BuiltinType::UFract:
12396 case BuiltinType::ULongFract:
12398 case BuiltinType::SatUShortFract:
12400 case BuiltinType::SatUFract:
12402 case BuiltinType::SatULongFract:
12407 "Unexpected signed integer or fixed point type");
12432 bool AllowTypeModifiers) {
12436 RequiresICE =
false;
12441 bool IsSpecial =
false;
12445 default: Done =
true; --Str;
break;
12447 RequiresICE =
true;
12450 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12451 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12455 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12456 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12460 assert(!IsSpecial &&
"Can't use 'L' with 'W', 'N', 'Z' or 'O' modifiers");
12461 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12466 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12467 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12476 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12477 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12483 llvm_unreachable(
"Unexpected integer type");
12494 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12495 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12501 llvm_unreachable(
"Unexpected integer type");
12514 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12515 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12531 default: llvm_unreachable(
"Unknown builtin type letter!");
12534 "Bad modifiers used with 'x'!");
12539 "Bad modifiers used with 'y'!");
12544 "Bad modifiers used with 'v'!");
12549 "Bad modifiers used with 'h'!");
12554 "Bad modifiers used with 'f'!");
12559 "Bad modifiers used with 'd'!");
12562 else if (HowLong == 2)
12568 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12577 else if (HowLong == 2)
12579 else if (HowLong == 1)
12585 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12594 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12598 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12602 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12619 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12631 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12639 unsigned NumElements = strtoul(Str, &End, 10);
12640 assert(End != Str &&
"Missing vector size");
12644 RequiresICE,
false);
12645 assert(!RequiresICE &&
"Can't require vector ICE");
12653 Type = Context.SveCountTy;
12657 Type = Context.AMDGPUBufferRsrcTy;
12661 llvm_unreachable(
"Unexpected target builtin type");
12667 unsigned NumElements = strtoul(Str, &End, 10);
12668 assert(End != Str &&
"Missing vector size");
12672 RequiresICE,
false);
12673 assert(!RequiresICE &&
"Can't require vector ICE");
12682 unsigned NumElements = strtoul(Str, &End, 10);
12683 assert(End != Str &&
"Missing vector size");
12695 assert(!RequiresICE &&
"Can't require complex ICE");
12704 if (
Type.isNull()) {
12715 if (
Type.isNull()) {
12721 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
12724 if (
Type.isNull()) {
12733 Type = Context.MFloat8Ty;
12738 Done = !AllowTypeModifiers;
12740 switch (
char c = *Str++) {
12741 default: Done =
true; --Str;
break;
12747 unsigned AddrSpace = strtoul(Str, &End, 10);
12775 "Integer constant 'I' type must be an integer");
12788 bool AllowTypeModifiers)
const {
12795 unsigned *IntegerConstantArgs)
const {
12797 if (TypeStr[0] ==
'\0') {
12804 bool RequiresICE =
false;
12807 RequiresICE,
true);
12811 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
12813 while (TypeStr[0] && TypeStr[0] !=
'.') {
12820 if (RequiresICE && IntegerConstantArgs)
12821 *IntegerConstantArgs |= 1 << ArgTypes.size();
12827 ArgTypes.push_back(Ty);
12830 if (
Id == Builtin::BI__GetExceptionInfo)
12833 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
12834 "'.' should only occur at end of builtin type list!");
12836 bool Variadic = (TypeStr[0] ==
'.');
12843 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
12895 !FD->
hasAttr<DLLExportAttr>()) ||
12896 FD->
hasAttr<GNUInlineAttr>()) {
12915 isa<CXXConstructorDecl>(FD) &&
12916 cast<CXXConstructorDecl>(FD)->isInheritingConstructor())
12929 if (
D->
hasAttr<DLLImportAttr>()) {
12932 }
else if (
D->
hasAttr<DLLExportAttr>()) {
12938 if (
D->
hasAttr<CUDAGlobalAttr>() &&
13001 while (LexicalContext && !isa<FunctionDecl>(LexicalContext))
13006 if (!LexicalContext)
13011 auto StaticLocalLinkage =
13023 return StaticLocalLinkage;
13050 return StrongLinkage;
13068 llvm_unreachable(
"Invalid Linkage!");
13078 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
13079 if (!VD->isFileVarDecl())
13084 if (VD->getDescribedVarTemplate() ||
13085 isa<VarTemplatePartialSpecializationDecl>(VD))
13087 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
13091 }
else if (isa<PragmaCommentDecl>(
D))
13093 else if (isa<PragmaDetectMismatchDecl>(
D))
13095 else if (isa<OMPRequiresDecl>(
D))
13097 else if (isa<OMPThreadPrivateDecl>(
D))
13099 else if (isa<OMPAllocateDecl>(
D))
13101 else if (isa<OMPDeclareReductionDecl>(
D) || isa<OMPDeclareMapperDecl>(
D))
13103 else if (isa<ImportDecl>(
D))
13120 if (LangOpts.SYCLIsDevice)
13121 return isa<FunctionDecl>(
D) && (
D->
hasAttr<SYCLKernelEntryPointAttr>() ||
13128 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
13130 if (!FD->doesThisDeclarationHaveABody())
13131 return FD->doesDeclarationForceExternallyVisibleDefinition();
13134 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13140 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13158 const auto *VD = cast<VarDecl>(
D);
13159 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13163 if (LangOpts.OpenMP &&
13164 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13171 if (VD->shouldEmitInExternalSource())
13184 if (VD->needsDestruction(*
this))
13188 if (VD->hasInitWithSideEffects())
13193 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13194 for (
const auto *BD : DD->flat_bindings())
13195 if (
const auto *BindingVD = BD->getHoldingVar())
13205 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13206 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13207 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13212 for (
auto *CurDecl :
13216 SeenDecls.insert(CurFD).second) {
13223 bool IsCXXMethod)
const {
13226 return ABI->getDefaultMethodCallConv(IsVariadic);
13228 switch (LangOpts.getDefaultCallingConv()) {
13256 return Target->getDefaultCallingConv();
13261 return ABI->isNearlyEmpty(RD);
13266 auto ABI =
Target->getCXXABI();
13267 if (ABI.isMicrosoft())
13270 auto ComponentLayout =
getLangOpts().RelativeCXXABIVTables
13276 return VTContext.get();
13282 switch (
T->getCXXABI().getKind()) {
13283 case TargetCXXABI::AppleARM64:
13284 case TargetCXXABI::Fuchsia:
13285 case TargetCXXABI::GenericAArch64:
13286 case TargetCXXABI::GenericItanium:
13287 case TargetCXXABI::GenericARM:
13288 case TargetCXXABI::GenericMIPS:
13289 case TargetCXXABI::iOS:
13290 case TargetCXXABI::WebAssembly:
13291 case TargetCXXABI::WatchOS:
13292 case TargetCXXABI::XL:
13294 case TargetCXXABI::Microsoft:
13297 llvm_unreachable(
"Unsupported ABI");
13301 assert(
T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13302 "Device mangle context does not support Microsoft mangling.");
13303 switch (
T.getCXXABI().getKind()) {
13304 case TargetCXXABI::AppleARM64:
13305 case TargetCXXABI::Fuchsia:
13306 case TargetCXXABI::GenericAArch64:
13307 case TargetCXXABI::GenericItanium:
13308 case TargetCXXABI::GenericARM:
13309 case TargetCXXABI::GenericMIPS:
13310 case TargetCXXABI::iOS:
13311 case TargetCXXABI::WebAssembly:
13312 case TargetCXXABI::WatchOS:
13313 case TargetCXXABI::XL:
13317 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13318 return RD->getDeviceLambdaManglingNumber();
13319 return std::nullopt;
13322 case TargetCXXABI::Microsoft:
13326 llvm_unreachable(
"Unsupported ABI");
13332 return ASTRecordLayouts.getMemorySize() +
13333 llvm::capacity_in_bytes(ObjCLayouts) +
13334 llvm::capacity_in_bytes(KeyFunctions) +
13335 llvm::capacity_in_bytes(ObjCImpls) +
13336 llvm::capacity_in_bytes(BlockVarCopyInits) +
13337 llvm::capacity_in_bytes(DeclAttrs) +
13338 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13339 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13340 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13341 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13342 llvm::capacity_in_bytes(OverriddenMethods) +
13343 llvm::capacity_in_bytes(Types) +
13344 llvm::capacity_in_bytes(VariableArrayTypes);
13352 unsigned Signed)
const {
13355 if (!QualTy && DestWidth == 128)
13384 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13391 MangleNumbers[ND] = Number;
13398 bool ForAuxTarget)
const {
13399 auto I = MangleNumbers.find(ND);
13400 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13403 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13404 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13406 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13407 "number for aux target");
13409 return Res > 1 ? Res : 1;
13416 StaticLocalNumbers[VD] = Number;
13423 auto I = StaticLocalNumbers.find(VD);
13424 return I != StaticLocalNumbers.end() ? I->second : 1;
13428 bool IsDestroying) {
13429 if (!IsDestroying) {
13441 bool IsTypeAware) {
13442 if (!IsTypeAware) {
13455 assert(LangOpts.CPlusPlus);
13456 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13464 assert(LangOpts.CPlusPlus);
13465 std::unique_ptr<MangleNumberingContext> &MCtx =
13466 ExtraMangleNumberingContexts[
D];
13472std::unique_ptr<MangleNumberingContext>
13474 return ABI->createMangleNumberingContext();
13479 return ABI->getCopyConstructorForExceptionObject(
13485 return ABI->addCopyConstructorForExceptionObject(
13492 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13497 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13502 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13506 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13510 ParamIndices[
D] = index;
13514 ParameterIndexTable::const_iterator I = ParamIndices.find(
D);
13515 assert(I != ParamIndices.end() &&
13516 "ParmIndices lacks entry set by ParmVarDecl");
13521 unsigned Length)
const {
13547 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13549 llvm::FoldingSetNodeID ID;
13553 if (
MSGuidDecl *Existing = MSGuidDecls.FindNodeOrInsertPos(ID, InsertPos))
13557 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
13558 MSGuidDecls.InsertNode(
New, InsertPos);
13564 const APValue &APVal)
const {
13565 llvm::FoldingSetNodeID ID;
13570 UnnamedGlobalConstantDecls.FindNodeOrInsertPos(ID, InsertPos))
13574 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
13575 UnnamedGlobalConstantDecls.InsertNode(
New, InsertPos);
13581 assert(
T->
isRecordType() &&
"template param object of unexpected type");
13587 llvm::FoldingSetNodeID ID;
13592 TemplateParamObjectDecls.FindNodeOrInsertPos(ID, InsertPos))
13596 TemplateParamObjectDecls.InsertNode(
New, InsertPos);
13602 if (!
T.isOSDarwin())
13605 if (!(
T.isiOS() &&
T.isOSVersionLT(7)) &&
13606 !(
T.isMacOSX() &&
T.isOSVersionLT(10, 9)))
13615 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
13622 if (MethodDecl->
hasAttr<UnavailableAttr>()
13623 || MethodDecl->
hasAttr<DeprecatedAttr>())
13637 IM != EM && IF != EF; ++IM, ++IF) {
13668 llvm::FoldingSetNodeID IDX, IDY;
13669 X->Profile(IDX, *
this,
true);
13670 Y->
Profile(IDY, *
this,
true);
13684 for (
const Decl *DX :
X->redecls()) {
13689 if (DX->isFirstDecl())
13692 llvm_unreachable(
"Corrupt redecls chain");
13695template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
13697 return cast_or_null<T>(
13699 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
13702template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
13705 const_cast<Decl *
>(cast<Decl>(Y))));
13710 bool IgnoreDeduced =
false) {
13725 bool IgnoreDeduced) {
13733 assert(Xs.size() == Ys.size());
13735 for (
size_t I = 0; I < Rs.size(); ++I)
13742 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
13752 switch (
X.getKind()) {
13782 auto NExpX =
X.getNumTemplateExpansions();
13796 if (Xs.size() != Ys.size())
13798 R.resize(Xs.size());
13799 for (
size_t I = 0; I < R.size(); ++I) {
13812 assert(!Different);
13840 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
13842 return std::nullopt;
13847 assert(Kind == NNS2.
getKind());
13852 auto Kind = Namespace1->getKind();
13853 if (Kind != Namespace2->getKind() ||
13854 (Kind == Decl::NamespaceAlias &&
13859 Namespace2->getNamespace()),
13893 llvm_unreachable(
"singletons did not compare equal");
13901 const T *Y,
bool IsSame) {
13902 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
13915 QualType EX =
X->getElementType(), EY = Y->getElementType();
13924 QY += EY.getQualifiers() - RQ;
13936 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
13937 return X->getSizeExpr();
13942 return X->getSizeModifier();
13948 return X->getIndexTypeCVRQualifiers();
13958 llvm::DenseMap<QualType, unsigned>
Found;
13959 for (
auto Ts : {
X, Y}) {
13966 Out.emplace_back(
T);
13976 bool AcceptDependent)
const {
14002 assert(AcceptDependent &&
14003 "computing composite pointer type of dependent types");
14018 llvm_unreachable(
"These ESTs should be handled above");
14023 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
14027 Result.Exceptions = ExceptionTypeStorage;
14034 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
14037 llvm_unreachable(
"invalid ExceptionSpecificationType");
14046#define UNEXPECTED_TYPE(Class, Kind) \
14047 case Type::Class: \
14048 llvm_unreachable("Unexpected " Kind ": " #Class);
14050#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
14051#define TYPE(Class, Base)
14052#include "clang/AST/TypeNodes.inc"
14054#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
14065#undef SUGAR_FREE_TYPE
14066#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
14069#undef NON_UNIQUE_TYPE
14073#undef UNEXPECTED_TYPE
14076 const auto *AX = cast<AutoType>(
X), *AY = cast<AutoType>(Y);
14077 assert(AX->getDeducedType().isNull());
14078 assert(AY->getDeducedType().isNull());
14079 assert(AX->getKeyword() == AY->getKeyword());
14080 assert(AX->isInstantiationDependentType() ==
14081 AY->isInstantiationDependentType());
14083 AY->getTypeConstraintArguments());
14086 AX->containsUnexpandedParameterPack(),
14088 AY->getTypeConstraintConcept()),
14091 case Type::IncompleteArray: {
14092 const auto *AX = cast<IncompleteArrayType>(
X),
14093 *AY = cast<IncompleteArrayType>(Y);
14098 case Type::DependentSizedArray: {
14099 const auto *AX = cast<DependentSizedArrayType>(
X),
14100 *AY = cast<DependentSizedArrayType>(Y);
14106 case Type::ConstantArray: {
14107 const auto *AX = cast<ConstantArrayType>(
X),
14108 *AY = cast<ConstantArrayType>(Y);
14109 assert(AX->getSize() == AY->getSize());
14110 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14111 ? AX->getSizeExpr()
14117 case Type::ArrayParameter: {
14118 const auto *AX = cast<ArrayParameterType>(
X),
14119 *AY = cast<ArrayParameterType>(Y);
14120 assert(AX->getSize() == AY->getSize());
14121 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14122 ? AX->getSizeExpr()
14129 case Type::Atomic: {
14130 const auto *AX = cast<AtomicType>(
X), *AY = cast<AtomicType>(Y);
14134 case Type::Complex: {
14135 const auto *CX = cast<ComplexType>(
X), *CY = cast<ComplexType>(Y);
14138 case Type::Pointer: {
14139 const auto *PX = cast<PointerType>(
X), *PY = cast<PointerType>(Y);
14142 case Type::BlockPointer: {
14143 const auto *PX = cast<BlockPointerType>(
X), *PY = cast<BlockPointerType>(Y);
14146 case Type::ObjCObjectPointer: {
14147 const auto *PX = cast<ObjCObjectPointerType>(
X),
14148 *PY = cast<ObjCObjectPointerType>(Y);
14151 case Type::MemberPointer: {
14152 const auto *PX = cast<MemberPointerType>(
X),
14153 *PY = cast<MemberPointerType>(Y);
14155 PY->getMostRecentCXXRecordDecl()));
14159 PX->getMostRecentCXXRecordDecl());
14161 case Type::LValueReference: {
14162 const auto *PX = cast<LValueReferenceType>(
X),
14163 *PY = cast<LValueReferenceType>(Y);
14166 PX->isSpelledAsLValue() ||
14167 PY->isSpelledAsLValue());
14169 case Type::RValueReference: {
14170 const auto *PX = cast<RValueReferenceType>(
X),
14171 *PY = cast<RValueReferenceType>(Y);
14175 case Type::DependentAddressSpace: {
14176 const auto *PX = cast<DependentAddressSpaceType>(
X),
14177 *PY = cast<DependentAddressSpaceType>(Y);
14178 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14180 PX->getAddrSpaceExpr(),
14183 case Type::FunctionNoProto: {
14184 const auto *FX = cast<FunctionNoProtoType>(
X),
14185 *FY = cast<FunctionNoProtoType>(Y);
14186 assert(FX->getExtInfo() == FY->getExtInfo());
14191 case Type::FunctionProto: {
14192 const auto *FX = cast<FunctionProtoType>(
X),
14193 *FY = cast<FunctionProtoType>(Y);
14195 EPIY = FY->getExtProtoInfo();
14196 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14199 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14200 assert(EPIX.
Variadic == EPIY.Variadic);
14217 case Type::ObjCObject: {
14218 const auto *OX = cast<ObjCObjectType>(
X), *OY = cast<ObjCObjectType>(Y);
14220 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14221 OY->getProtocols().begin(), OY->getProtocols().end(),
14223 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14225 "protocol lists must be the same");
14227 OY->getTypeArgsAsWritten());
14230 OX->getProtocols(),
14231 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14233 case Type::ConstantMatrix: {
14234 const auto *MX = cast<ConstantMatrixType>(
X),
14235 *MY = cast<ConstantMatrixType>(Y);
14236 assert(MX->getNumRows() == MY->getNumRows());
14237 assert(MX->getNumColumns() == MY->getNumColumns());
14239 MX->getNumRows(), MX->getNumColumns());
14241 case Type::DependentSizedMatrix: {
14242 const auto *MX = cast<DependentSizedMatrixType>(
X),
14243 *MY = cast<DependentSizedMatrixType>(Y);
14244 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14245 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14250 case Type::Vector: {
14251 const auto *VX = cast<VectorType>(
X), *VY = cast<VectorType>(Y);
14252 assert(VX->getNumElements() == VY->getNumElements());
14253 assert(VX->getVectorKind() == VY->getVectorKind());
14255 VX->getNumElements(), VX->getVectorKind());
14257 case Type::ExtVector: {
14258 const auto *VX = cast<ExtVectorType>(
X), *VY = cast<ExtVectorType>(Y);
14259 assert(VX->getNumElements() == VY->getNumElements());
14261 VX->getNumElements());
14263 case Type::DependentSizedExtVector: {
14264 const auto *VX = cast<DependentSizedExtVectorType>(
X),
14265 *VY = cast<DependentSizedExtVectorType>(Y);
14270 case Type::DependentVector: {
14271 const auto *VX = cast<DependentVectorType>(
X),
14272 *VY = cast<DependentVectorType>(Y);
14273 assert(VX->getVectorKind() == VY->getVectorKind());
14280 case Type::InjectedClassName: {
14281 const auto *TX = cast<TagType>(
X), *TY = cast<TagType>(Y);
14288 case Type::TemplateSpecialization: {
14289 const auto *TX = cast<TemplateSpecializationType>(
X),
14290 *TY = cast<TemplateSpecializationType>(Y);
14292 TY->template_arguments());
14296 TY->getTemplateName(),
14298 As, {},
X->getCanonicalTypeInternal());
14300 case Type::Decltype: {
14301 const auto *DX = cast<DecltypeType>(
X);
14302 [[maybe_unused]]
const auto *DY = cast<DecltypeType>(Y);
14303 assert(DX->isDependentType());
14304 assert(DY->isDependentType());
14305 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14309 case Type::PackIndexing: {
14310 const auto *DX = cast<PackIndexingType>(
X);
14311 [[maybe_unused]]
const auto *DY = cast<PackIndexingType>(Y);
14312 assert(DX->isDependentType());
14313 assert(DY->isDependentType());
14314 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14317 case Type::DependentName: {
14318 const auto *NX = cast<DependentNameType>(
X),
14319 *NY = cast<DependentNameType>(Y);
14320 assert(NX->getIdentifier() == NY->getIdentifier());
14325 case Type::DependentTemplateSpecialization: {
14326 const auto *TX = cast<DependentTemplateSpecializationType>(
X),
14327 *TY = cast<DependentTemplateSpecializationType>(Y);
14329 TY->template_arguments());
14331 &SY = TY->getDependentTemplateName();
14332 assert(SX.
getName() == SY.getName());
14340 case Type::UnaryTransform: {
14341 const auto *TX = cast<UnaryTransformType>(
X),
14342 *TY = cast<UnaryTransformType>(Y);
14343 assert(TX->getUTTKind() == TY->getUTTKind());
14347 TY->getUnderlyingType()),
14350 case Type::PackExpansion: {
14351 const auto *PX = cast<PackExpansionType>(
X),
14352 *PY = cast<PackExpansionType>(Y);
14353 assert(PX->getNumExpansions() == PY->getNumExpansions());
14356 PX->getNumExpansions(),
false);
14359 const auto *PX = cast<PipeType>(
X), *PY = cast<PipeType>(Y);
14360 assert(PX->isReadOnly() == PY->isReadOnly());
14365 case Type::TemplateTypeParm: {
14366 const auto *TX = cast<TemplateTypeParmType>(
X),
14367 *TY = cast<TemplateTypeParmType>(Y);
14368 assert(TX->getDepth() == TY->getDepth());
14369 assert(TX->getIndex() == TY->getIndex());
14370 assert(TX->isParameterPack() == TY->isParameterPack());
14372 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14376 llvm_unreachable(
"Unknown Type Class");
14386#define UNEXPECTED_TYPE(Class, Kind) \
14387 case Type::Class: \
14388 llvm_unreachable("Unexpected " Kind ": " #Class);
14389#define TYPE(Class, Base)
14390#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14391#include "clang/AST/TypeNodes.inc"
14393#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14419#undef CANONICAL_TYPE
14421#undef UNEXPECTED_TYPE
14423 case Type::Adjusted: {
14424 const auto *AX = cast<AdjustedType>(
X), *AY = cast<AdjustedType>(Y);
14425 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14432 case Type::Decayed: {
14433 const auto *DX = cast<DecayedType>(
X), *DY = cast<DecayedType>(Y);
14434 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14441 case Type::Attributed: {
14442 const auto *AX = cast<AttributedType>(
X), *AY = cast<AttributedType>(Y);
14444 if (Kind != AY->getAttrKind())
14446 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14454 case Type::BTFTagAttributed: {
14455 const auto *BX = cast<BTFTagAttributedType>(
X);
14456 const BTFTypeTagAttr *AX = BX->getAttr();
14458 if (AX->getBTFTypeTag() !=
14459 cast<BTFTagAttributedType>(Y)->getAttr()->getBTFTypeTag())
14464 const auto *AX = cast<AutoType>(
X), *AY = cast<AutoType>(Y);
14467 if (KW != AY->getKeyword())
14471 AY->getTypeConstraintConcept());
14475 AY->getTypeConstraintArguments())) {
14483 false,
false, CD, As);
14485 case Type::PackIndexing:
14486 case Type::Decltype:
14488 case Type::DeducedTemplateSpecialization:
14491 case Type::MacroQualified: {
14492 const auto *MX = cast<MacroQualifiedType>(
X),
14493 *MY = cast<MacroQualifiedType>(Y);
14495 if (IX != MY->getMacroIdentifier())
14499 case Type::SubstTemplateTypeParm: {
14500 const auto *SX = cast<SubstTemplateTypeParmType>(
X),
14501 *SY = cast<SubstTemplateTypeParmType>(Y);
14506 unsigned Index = SX->getIndex();
14507 if (Index != SY->getIndex())
14509 auto PackIndex = SX->getPackIndex();
14510 if (PackIndex != SY->getPackIndex())
14513 CD, Index, PackIndex,
14514 SX->getFinal() && SY->getFinal());
14516 case Type::ObjCTypeParam:
14522 case Type::TemplateSpecialization: {
14523 const auto *TX = cast<TemplateSpecializationType>(
X),
14524 *TY = cast<TemplateSpecializationType>(Y);
14527 TY->getTemplateName(),
true);
14532 TY->template_arguments()))
14538 case Type::Typedef: {
14539 const auto *TX = cast<TypedefType>(
X), *TY = cast<TypedefType>(Y);
14548 case Type::TypeOf: {
14554 if (cast<TypeOfType>(
X)->
getKind() == cast<TypeOfType>(Y)->
getKind() &&
14559 case Type::TypeOfExpr:
14562 case Type::UnaryTransform: {
14563 const auto *UX = cast<UnaryTransformType>(
X),
14564 *UY = cast<UnaryTransformType>(Y);
14566 if (KX != UY->getUTTKind())
14568 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
14575 case Type::Using: {
14576 const auto *UX = cast<UsingType>(
X), *UY = cast<UsingType>(Y);
14584 case Type::MemberPointer: {
14585 const auto *PX = cast<MemberPointerType>(
X),
14586 *PY = cast<MemberPointerType>(Y);
14588 assert(Cls == PY->getMostRecentCXXRecordDecl());
14593 case Type::CountAttributed: {
14594 const auto *DX = cast<CountAttributedType>(
X),
14595 *DY = cast<CountAttributedType>(Y);
14596 if (DX->isCountInBytes() != DY->isCountInBytes())
14598 if (DX->isOrNull() != DY->isOrNull())
14600 Expr *CEX = DX->getCountExpr();
14601 Expr *CEY = DY->getCountExpr();
14605 DX->isCountInBytes(), DX->isOrNull(),
14616 DX->isCountInBytes(), DX->isOrNull(),
14619 case Type::PredefinedSugar:
14620 assert(cast<PredefinedSugarType>(
X)->
getKind() !=
14621 cast<PredefinedSugarType>(Y)->
getKind());
14624 llvm_unreachable(
"Unhandled Type Class");
14646 if (
X.isCanonical())
14673 bool KeepCommonQualifiers =
Unqualified || isa<ArrayType>(SX.
Ty);
14675 if (SX.
Ty != SY.Ty) {
14683 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
14686 SX = Xs.pop_back_val();
14687 SY = Ys.pop_back_val();
14690 if (KeepCommonQualifiers)
14697 while (!Xs.empty() && !Ys.empty()) {
14700 SX = Xs.pop_back_val();
14701 SY = Ys.pop_back_val();
14706 SX.
Ty = Underlying.Ty;
14709 QX -= Underlying.Quals;
14727 llvm_unreachable(
"Not a saturated fixed point type!");
14728 case BuiltinType::SatShortAccum:
14730 case BuiltinType::SatAccum:
14732 case BuiltinType::SatLongAccum:
14734 case BuiltinType::SatUShortAccum:
14736 case BuiltinType::SatUAccum:
14738 case BuiltinType::SatULongAccum:
14740 case BuiltinType::SatShortFract:
14742 case BuiltinType::SatFract:
14744 case BuiltinType::SatLongFract:
14746 case BuiltinType::SatUShortFract:
14748 case BuiltinType::SatUFract:
14750 case BuiltinType::SatULongFract:
14762 llvm_unreachable(
"Not a fixed point type!");
14763 case BuiltinType::ShortAccum:
14765 case BuiltinType::Accum:
14767 case BuiltinType::LongAccum:
14769 case BuiltinType::UShortAccum:
14771 case BuiltinType::UAccum:
14773 case BuiltinType::ULongAccum:
14775 case BuiltinType::ShortFract:
14777 case BuiltinType::Fract:
14779 case BuiltinType::LongFract:
14781 case BuiltinType::UShortFract:
14783 case BuiltinType::UFract:
14785 case BuiltinType::ULongFract:
14791 if (LangOpts.OpenCL)
14815 llvm_unreachable(
"Not a fixed point type!");
14816 case BuiltinType::ShortAccum:
14817 case BuiltinType::SatShortAccum:
14818 return Target.getShortAccumScale();
14819 case BuiltinType::Accum:
14820 case BuiltinType::SatAccum:
14821 return Target.getAccumScale();
14822 case BuiltinType::LongAccum:
14823 case BuiltinType::SatLongAccum:
14824 return Target.getLongAccumScale();
14825 case BuiltinType::UShortAccum:
14826 case BuiltinType::SatUShortAccum:
14827 return Target.getUnsignedShortAccumScale();
14828 case BuiltinType::UAccum:
14829 case BuiltinType::SatUAccum:
14830 return Target.getUnsignedAccumScale();
14831 case BuiltinType::ULongAccum:
14832 case BuiltinType::SatULongAccum:
14833 return Target.getUnsignedLongAccumScale();
14834 case BuiltinType::ShortFract:
14835 case BuiltinType::SatShortFract:
14836 return Target.getShortFractScale();
14837 case BuiltinType::Fract:
14838 case BuiltinType::SatFract:
14839 return Target.getFractScale();
14840 case BuiltinType::LongFract:
14841 case BuiltinType::SatLongFract:
14842 return Target.getLongFractScale();
14843 case BuiltinType::UShortFract:
14844 case BuiltinType::SatUShortFract:
14845 return Target.getUnsignedShortFractScale();
14846 case BuiltinType::UFract:
14847 case BuiltinType::SatUFract:
14848 return Target.getUnsignedFractScale();
14849 case BuiltinType::ULongFract:
14850 case BuiltinType::SatULongFract:
14851 return Target.getUnsignedLongFractScale();
14861 llvm_unreachable(
"Not a fixed point type!");
14862 case BuiltinType::ShortAccum:
14863 case BuiltinType::SatShortAccum:
14864 return Target.getShortAccumIBits();
14865 case BuiltinType::Accum:
14866 case BuiltinType::SatAccum:
14867 return Target.getAccumIBits();
14868 case BuiltinType::LongAccum:
14869 case BuiltinType::SatLongAccum:
14870 return Target.getLongAccumIBits();
14871 case BuiltinType::UShortAccum:
14872 case BuiltinType::SatUShortAccum:
14873 return Target.getUnsignedShortAccumIBits();
14874 case BuiltinType::UAccum:
14875 case BuiltinType::SatUAccum:
14876 return Target.getUnsignedAccumIBits();
14877 case BuiltinType::ULongAccum:
14878 case BuiltinType::SatULongAccum:
14879 return Target.getUnsignedLongAccumIBits();
14880 case BuiltinType::ShortFract:
14881 case BuiltinType::SatShortFract:
14882 case BuiltinType::Fract:
14883 case BuiltinType::SatFract:
14884 case BuiltinType::LongFract:
14885 case BuiltinType::SatLongFract:
14886 case BuiltinType::UShortFract:
14887 case BuiltinType::SatUShortFract:
14888 case BuiltinType::UFract:
14889 case BuiltinType::SatUFract:
14890 case BuiltinType::ULongFract:
14891 case BuiltinType::SatULongFract:
14896llvm::FixedPointSemantics
14899 "Can only get the fixed point semantics for a "
14900 "fixed point or integer type.");
14902 return llvm::FixedPointSemantics::GetIntegerSemantics(
14906 return llvm::FixedPointSemantics(
14909 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
14924 "Expected unsigned fixed point type");
14927 case BuiltinType::UShortAccum:
14929 case BuiltinType::UAccum:
14931 case BuiltinType::ULongAccum:
14933 case BuiltinType::SatUShortAccum:
14935 case BuiltinType::SatUAccum:
14937 case BuiltinType::SatULongAccum:
14939 case BuiltinType::UShortFract:
14941 case BuiltinType::UFract:
14943 case BuiltinType::ULongFract:
14945 case BuiltinType::SatUShortFract:
14947 case BuiltinType::SatUFract:
14949 case BuiltinType::SatULongFract:
14952 llvm_unreachable(
"Unexpected unsigned fixed point type");
14960 std::vector<std::string> BackendFeats;
14961 llvm::AArch64::ExtensionSet FeatureBits;
14962 for (StringRef F : FMVFeatStrings)
14963 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
14965 FeatureBits.enable(*FMVExt->ID);
14966 FeatureBits.toLLVMFeatureList(BackendFeats);
14967 return BackendFeats;
14972 assert(TD !=
nullptr);
14975 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
14976 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
14987 Target->getTargetOpts().CPU,
14988 Target->getTargetOpts().Features);
14995 StringRef TargetCPU =
Target->getTargetOpts().CPU;
14997 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
15003 if (!
Target->getTriple().isAArch64())
15006 Target->getTargetOpts().FeaturesAsWritten.begin(),
15007 Target->getTargetOpts().FeaturesAsWritten.end());
15018 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
15020 Target->getCPUSpecificCPUDispatchFeatures(
15022 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
15023 Features.insert(Features.begin(),
15024 Target->getTargetOpts().FeaturesAsWritten.begin(),
15025 Target->getTargetOpts().FeaturesAsWritten.end());
15027 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
15028 if (
Target->getTriple().isAArch64()) {
15032 Features.insert(Features.begin(),
15033 Target->getTargetOpts().FeaturesAsWritten.begin(),
15034 Target->getTargetOpts().FeaturesAsWritten.end());
15036 }
else if (
Target->getTriple().isRISCV()) {
15038 std::vector<std::string> Features;
15039 if (VersionStr !=
"default") {
15041 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15044 Features.insert(Features.begin(),
15045 Target->getTargetOpts().FeaturesAsWritten.begin(),
15046 Target->getTargetOpts().FeaturesAsWritten.end());
15049 std::vector<std::string> Features;
15051 if (VersionStr.starts_with(
"arch="))
15052 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
15053 else if (VersionStr !=
"default")
15054 Features.push_back((StringRef{
"+"} + VersionStr).str());
15057 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
15058 std::vector<std::string> Features;
15059 if (
Target->getTriple().isRISCV()) {
15061 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15064 assert(
Target->getTriple().isAArch64());
15066 TV->getFeatures(Feats);
15069 Features.insert(Features.begin(),
15070 Target->getTargetOpts().FeaturesAsWritten.begin(),
15071 Target->getTargetOpts().FeaturesAsWritten.end());
15074 FeatureMap =
Target->getTargetOpts().FeatureMap;
15085 auto DeviceDiscriminatorOverrider =
15087 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15089 return RD->getDeviceLambdaManglingNumber();
15090 return std::nullopt;
15093 Context, Context.
getDiagnostics(), DeviceDiscriminatorOverrider)};
15101 std::string Buffer;
15102 Buffer.reserve(128);
15103 llvm::raw_string_ostream Out(Buffer);
15104 MC->mangleCanonicalTypeName(KernelNameType, Out);
15105 std::string KernelName = Out.str();
15107 return {KernelNameType, FD, KernelName};
15116 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15117 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15126 "SYCL kernel name conflict");
15141 return &IT->second;
15147 return *OMPTraitInfoVector.back();
15154 return DB << Section.
Decl;
15155 return DB <<
"a prior #pragma section";
15159 bool IsInternalVar =
15162 bool IsExplicitDeviceVar = (
D->
hasAttr<CUDADeviceAttr>() &&
15163 !
D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15164 (
D->
hasAttr<CUDAConstantAttr>() &&
15165 !
D->
getAttr<CUDAConstantAttr>()->isImplicit());
15169 return (IsInternalVar &&
15170 (
D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15183 if (!CUIDHash.empty())
15185 if (LangOpts.
CUID.empty())
15186 return StringRef();
15187 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.
CUID),
true);
15197 assert(PrimaryBase);
15200 auto Base = Layout.getPrimaryBase();
15201 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15203 PrimaryBase =
Base;
15205 return PrimaryBase;
15209 StringRef MangledName) {
15210 auto *
Method = cast<CXXMethodDecl>(VirtualMethodDecl.
getDecl());
15211 assert(
Method->isVirtual());
15212 bool DefaultIncludesPointerAuth =
15213 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15215 if (!DefaultIncludesPointerAuth)
15218 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15219 if (Existing != ThunksToBeAbbreviated.end())
15220 return Existing->second.contains(MangledName.str());
15223 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15225 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15227 for (
const auto &Thunk : *ThunkInfos) {
15229 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15235 Mangler->mangleThunk(
Method, Thunk,
true,
15238 llvm::raw_svector_ostream mangledNameStream(MangledName);
15242 mangledNameStream);
15244 Mangler->mangleThunk(
Method, Thunk,
false,
15245 mangledNameStream);
15247 Thunks[ElidedName].push_back(std::string(MangledName));
15250 llvm::StringSet<> SimplifiedThunkNames;
15251 for (
auto &ThunkList : Thunks) {
15252 llvm::sort(ThunkList.second);
15253 SimplifiedThunkNames.insert(ThunkList.second[0]);
15255 bool Result = SimplifiedThunkNames.contains(MangledName);
15256 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::Target Target
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.
static const TemplateArgument & getArgument(const TemplateArgument &A)
C Language Family Type Representation.
__device__ __2f16 float c
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.
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
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.
uint64_t getFieldOffset(const ValueDecl *FD) const
Get the offset of a FieldDecl or IndirectFieldDecl, in bits.
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 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 getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool AllowCXX=false, bool IsConditionalOperator=false)
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
CharUnits getObjCEncodingTypeSize(QualType T) const
Return the size of type T for Objective-C encoding purpose, in characters.
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
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 getucontext_tType() const
Retrieve the C ucontext_t 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 getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, const DependentTemplateStorage &Name, ArrayRef< TemplateArgumentLoc > Args) const
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
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.
QualType getCanonicalTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
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...
QualType getFILEType() const
Retrieve the C FILE type.
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...
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
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()
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
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
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
QualType getjmp_bufType() const
Retrieve the C jmp_buf type.
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
QualType getsigjmp_bufType() const
Retrieve the C sigjmp_buf type.
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.
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...
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
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.
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
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
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 getWideCharType() const
Return the type of wide characters.
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_stdio
Missing a type from <stdio.h>
@ GE_Missing_type
Missing a type.
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
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 void AddedStaticLocalNumbers(const Decl *D, unsigned Number)
An static local number was added to a Decl.
virtual ~ASTMutationListener()
virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M)
A definition has been made visible by being redefined locally.
virtual void AddedManglingNumber(const Decl *D, unsigned Number)
An mangling number was added to a Decl.
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,...
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
void Profile(llvm::FoldingSetNodeID &ID)
Attr - This represents one attribute.
An attributed type is a type to which a type attribute has been applied.
void Profile(llvm::FoldingSetNodeID &ID)
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
bool isConstrained() const
void Profile(llvm::FoldingSetNodeID &ID)
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...
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
bool canBeRedeclared(unsigned ID) const
Returns true if this is a builtin that can be redeclared.
const char * getTypeString(unsigned ID) const
Get the type descriptor string for the specified builtin.
bool isNoReturn(unsigned ID) const
Return true if we know this builtin never returns.
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
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)
Builds a canonical type from a QualType.
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.
QualType getElementType() const
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
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
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
Represents the type decltype(expr) (C++11).
Represents a C++17 deduced template specialization type.
void Profile(llvm::FoldingSetNodeID &ID) const
TemplateName getUnderlying() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
DefaultArguments getDefaultArguments() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
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)
Internal representation of canonical, dependent decltype(expr) types.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a qualified type name for which the type name is dependent.
void Profile(llvm::FoldingSetNodeID &ID)
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 template specialization type whose template cannot be resolved, e.g.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a dependent template name that cannot be resolved prior to template instantiation.
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.
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
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...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getOriginalDecl() const
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 ExtKind hasExternalDefinitions(const Decl *D)
virtual void ReadComments()
Loads comment ranges.
virtual void CompleteRedeclChain(const Decl *D)
Gives the external AST source an opportunity to complete the redeclaration chain for a declaration.
virtual void PrintStats()
Print any statistics that have been gathered regarding the external AST source.
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.
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...
static FunctionEffectSet getIntersection(FunctionEffectsRef LHS, FunctionEffectsRef RHS)
static FunctionEffectSet getUnion(FunctionEffectsRef LHS, FunctionEffectsRef RHS, Conflicts &Errs)
Represents an abstract function effect, using just an enumeration describing its kind.
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
QualType getWrappedType() const
const Attributes & getAttrs() const
QualType getContainedType() const
void Profile(llvm::FoldingSetNodeID &ID)
Represents an arbitrary, user-specified SPIR-V type instruction.
uint32_t getAlignment() const
uint32_t getOpcode() const
ArrayRef< SpirvOperand > getOperands() const
void Profile(llvm::FoldingSetNodeID &ID)
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.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
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)
The injected class name of a C++ class template or class template partial specialization.
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
CommentOptions CommentOpts
Options for parsing comments.
std::string CUID
The user provided compilation unit ID, if non-empty.
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 * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
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
Interfaces are the core concept in Objective-C for object oriented design.
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.
A class providing a concrete implementation of ObjCObjectType, so as to not increase the footprint of...
void Profile(llvm::FoldingSetNodeID &ID)
Represents a class type in Objective C.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
bool isObjCQualifiedClass() const
QualType getBaseType() const
Gets the base type of this object type.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
bool isObjCQualifiedId() const
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
bool isObjCUnqualifiedId() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
QualType getSuperClassType() const
Retrieve the type of the superclass of this object type.
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
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
qual_iterator qual_end() const
qual_iterator qual_begin() 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...
Represents a type parameter type in Objective C.
void Profile(llvm::FoldingSetNodeID &ID)
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
Represents a pack expansion of types.
void Profile(llvm::FoldingSetNodeID &ID)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
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()
void setAddressSpace(LangAS space)
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.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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.
FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
DiagnosticsEngine & getDiagnostics() const
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
unsigned getLineNumber(FileID FID, unsigned FilePos, bool *Invalid=nullptr) const
Given a SourceLocation, return the spelling line number for the position indicated.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
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...
Represents the result of substituting a builtin template as a pack.
void Profile(llvm::FoldingSetNodeID &ID)
Mark that we reuse the Profile. We do not introduce new fields.
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 result of substituting a set of types for a template type parameter pack.
void Profile(llvm::FoldingSetNodeID &ID)
Represents the result of substituting a type for a template type parameter.
void Profile(llvm::FoldingSetNodeID &ID)
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
TagDecl * getDefinitionOrSelf() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool canKeyFunctionBeInline() const
Can an out-of-line inline function serve as a key function?
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.
IntType getInt64Type() const
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...
unsigned getBFloat16Width() const
getBFloat16Width/Align/Format - Return the size/align/format of '__bf16'.
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 std::optional< std::pair< unsigned, unsigned > > getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode, llvm::StringMap< bool > *FeatureMap=nullptr) const
Returns target-specific min and max values VScale_Range.
virtual uint64_t getNullPointerValue(LangAS AddrSpace) const
Get integer value for null pointer.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
unsigned getHalfAlign() const
unsigned getBFloat16Align() const
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 getHalfWidth() const
getHalfWidth/Align/Format - Return the size/align/format of 'half'.
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
unsigned getFloat128Width() const
getFloat128Width/Align/Format - Return the size/align/format of '__float128'.
IntType getSignedSizeType() const
const llvm::fltSemantics & getLongDoubleFormat() const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool hasAArch64ACLETypes() const
Returns whether or not the AArch64 ACLE built-in types are available on this target.
bool useAddressSpaceMapMangling() const
Specify if mangling based on address space map should be used or not for language specific address sp...
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
unsigned getFloat128Align() const
virtual bool hasBFloat16Type() const
Determine whether the _BFloat16 type is supported on this target.
const llvm::fltSemantics & getFloat128Format() const
unsigned getLongDoubleWidth() const
getLongDoubleWidth/Align/Format - Return the size/align/format of 'long double'.
unsigned getLongDoubleAlign() const
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
A template argument list.
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.
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.
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()
Represents a type template specialization; the template must be a class template, a type alias templa...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
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)
void Profile(llvm::FoldingSetNodeID &ID)
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...
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
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 isBooleanType() const
bool isFunctionReferenceType() const
bool isObjCBuiltinType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isIncompleteArrayType() const
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
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 hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
bool isFunctionPointerType() const
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 isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder 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 isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
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.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
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 isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
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...
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
QualType getCanonicalTypeInternal() const
@ PtrdiffT
The "ptrdiff_t" type.
@ SizeT
The "size_t" type.
@ SignedSizeT
The signed integer type corresponding to "size_t".
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isMemberPointerType() const
bool isObjCIdType() const
EnumDecl * castAsEnumDecl() 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...
const T * castAsCanonical() const
Return this type's canonical type cast to the specified type.
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.
Represents a C++ using-enum-declaration.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-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.
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 internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
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
Matches all kinds of arrays.
const AstTypeMatcher< TagType > tagType
Matches tag types (record and enum types).
The JSON file list parser is used to communicate input to InstallAPI.
std::pair< FileID, unsigned > FileIDAndOffset
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.
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.
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.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
TagTypeKind
The kind of a tag type.
@ 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.
const FunctionProtoType * T
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
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
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)
Diagnostic wrappers for TextAPI types for error reporting.
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
A simple holder for a QualType representing a type in an exception specification.
A holder for Arm type attributes as described in the Arm C/C++ Language extensions which are not part...
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...
Parts of a decomposed MSGuidDecl.
Contains information gathered from parsing the contents of TargetAttr.
Describes how types, statements, expressions, and declarations should be printed.
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.
static constexpr size_t getOffset()
static TagTypeFoldingSetPlaceholder * fromTagType(TagType *T)
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *Tag, bool OwnsTag, bool IsInjected)
A this pointer adjustment.
IntType
===-— Target Data Type Query Methods ----------------------------—===//
AlignRequirementKind AlignRequirement
AlignRequirementKind AlignRequirement
static bool isEqual(const FoldingSetNodeID &LHS, const FoldingSetNodeID &RHS)
static FoldingSetNodeID getTombstoneKey()
static FoldingSetNodeID getEmptyKey()
static unsigned getHashValue(const FoldingSetNodeID &Val)