69#include "llvm/ADT/APFixedPoint.h"
70#include "llvm/ADT/APInt.h"
71#include "llvm/ADT/APSInt.h"
72#include "llvm/ADT/ArrayRef.h"
73#include "llvm/ADT/DenseMap.h"
74#include "llvm/ADT/DenseSet.h"
75#include "llvm/ADT/FoldingSet.h"
76#include "llvm/ADT/PointerUnion.h"
77#include "llvm/ADT/STLExtras.h"
78#include "llvm/ADT/SmallPtrSet.h"
79#include "llvm/ADT/SmallVector.h"
80#include "llvm/ADT/StringExtras.h"
81#include "llvm/ADT/StringRef.h"
82#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
83#include "llvm/Support/Capacity.h"
84#include "llvm/Support/Casting.h"
85#include "llvm/Support/Compiler.h"
86#include "llvm/Support/ErrorHandling.h"
87#include "llvm/Support/MD5.h"
88#include "llvm/Support/MathExtras.h"
89#include "llvm/Support/SipHash.h"
90#include "llvm/Support/raw_ostream.h"
91#include "llvm/TargetParser/AArch64TargetParser.h"
92#include "llvm/TargetParser/Triple.h"
105using namespace clang;
129 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
134 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
135 if (VD->isStaticDataMember() &&
140 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(D)) {
145 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
152 if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
156 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
159 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
191 Locations.emplace_back(BaseLocation);
204 Locations.emplace_back(SourceMgr.getExpansionLoc(BaseLocation));
211 Locations.emplace_back(SourceMgr.getSpellingLoc(D->
getBeginLoc()));
219 const std::map<unsigned, RawComment *> &CommentsInTheFile)
const {
222 if (RepresentativeLocForDecl.
isInvalid() ||
223 !RepresentativeLocForDecl.
isFileID())
227 if (CommentsInTheFile.empty())
233 SourceMgr.getDecomposedLoc(RepresentativeLocForDecl);
236 auto OffsetCommentBehindDecl =
237 CommentsInTheFile.lower_bound(DeclLocDecomp.second);
240 if (OffsetCommentBehindDecl != CommentsInTheFile.end()) {
241 RawComment *CommentBehindDecl = OffsetCommentBehindDecl->second;
243 LangOpts.CommentOpts.ParseAllComments) &&
250 if (SourceMgr.getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second) ==
251 Comments.getCommentBeginLine(CommentBehindDecl, DeclLocDecomp.first,
252 OffsetCommentBehindDecl->first)) {
253 return CommentBehindDecl;
260 if (OffsetCommentBehindDecl == CommentsInTheFile.begin())
263 auto OffsetCommentBeforeDecl = --OffsetCommentBehindDecl;
264 RawComment *CommentBeforeDecl = OffsetCommentBeforeDecl->second;
268 LangOpts.CommentOpts.ParseAllComments) ||
273 const unsigned CommentEndOffset =
274 Comments.getCommentEndOffset(CommentBeforeDecl);
278 const char *Buffer = SourceMgr.getBufferData(DeclLocDecomp.first,
284 StringRef
Text(Buffer + CommentEndOffset,
285 DeclLocDecomp.second - CommentEndOffset);
289 if (
Text.find_last_of(
";{}#@") != StringRef::npos)
292 return CommentBeforeDecl;
298 for (
const auto DeclLoc : DeclLocs) {
301 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
312 const FileID File = SourceMgr.getDecomposedLoc(DeclLoc).first;
316 const auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
317 if (!CommentsInThisFile || CommentsInThisFile->empty())
329 assert(LangOpts.RetainCommentsFromSystemHeaders ||
331 Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
336 const Decl **OriginalDecl)
const {
339 OriginalDecl =
nullptr;
351 return DeclComment->second;
364 *OriginalDecl = RedeclComment->second;
367 "This decl is supposed to have comment attached.");
368 return CommentAtRedecl->second;
373 const Decl *LastCheckedRedecl = [&]() {
375 bool CanUseCommentlessCache =
false;
377 for (
auto *Redecl : CanonicalD->
redecls()) {
379 CanUseCommentlessCache =
true;
382 if (Redecl == LastChecked)
389 return CanUseCommentlessCache ? LastChecked :
nullptr;
395 if (LastCheckedRedecl) {
396 if (LastCheckedRedecl == Redecl) {
397 LastCheckedRedecl =
nullptr;
405 *OriginalDecl = Redecl;
406 return RedeclComment;
412 *OriginalDecl =
nullptr;
418 assert(Comment.
isDocumentation() || LangOpts.CommentOpts.ParseAllComments);
428 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(DC)) {
433 for (
const auto *Ext : ID->known_extensions()) {
437 Redeclared.push_back(RedeclaredMethod);
444 if (
Comments.empty() || Decls.empty())
448 for (
const Decl *D : Decls) {
449 if (D->isInvalidDecl())
457 File = SourceMgr.getDecomposedLoc(Loc).first;
462 if (
File.isInvalid())
465 auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
466 if (!CommentsInThisFile || CommentsInThisFile->empty() ||
467 CommentsInThisFile->rbegin()->second->isAttached())
477 for (
const Decl *D : Decls) {
479 if (D->isInvalidDecl())
489 for (
const auto DeclLoc : DeclLocs) {
490 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
494 D, DeclLoc, *CommentsInThisFile)) {
505 const Decl *D)
const {
508 ThisDeclInfo->IsFilled =
false;
509 ThisDeclInfo->fill();
510 ThisDeclInfo->CommentDecl = FC->
getDecl();
511 if (!ThisDeclInfo->TemplateParameters)
521 return RC ? RC->
parse(*
this,
nullptr, D) :
nullptr;
532 llvm::DenseMap<const Decl *, comments::FullComment *>::iterator Pos =
536 if (Canonical != D) {
544 const Decl *OriginalDecl =
nullptr;
550 const auto *OMD = dyn_cast<ObjCMethodDecl>(D);
551 if (OMD && OMD->isPropertyAccessor())
558 for (
unsigned i = 0, e = Overridden.size(); i < e; i++)
562 else if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
565 QualType QT = TD->getUnderlyingType();
566 if (
const auto *TT = QT->
getAs<TagType>())
570 else if (
const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
571 while (IC->getSuperClass()) {
572 IC = IC->getSuperClass();
577 else if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(D)) {
582 else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
583 if (!(RD = RD->getDefinition()))
586 for (
const auto &I : RD->bases()) {
587 if (I.isVirtual() || (I.getAccessSpecifier() !=
AS_public))
601 for (
const auto &I : RD->vbases()) {
622 if (D != OriginalDecl && OriginalDecl)
630void ASTContext::CanonicalTemplateTemplateParm::Profile(
639 ID.AddInteger(Params->
size());
641 PEnd = Params->
end();
643 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
645 ID.AddBoolean(TTP->isParameterPack());
647 TTP->getNumExpansionParameters().toInternalRepresentation());
651 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
653 ID.AddBoolean(NTTP->isParameterPack());
654 ID.AddPointer(
C.getUnconstrainedType(
C.getCanonicalType(NTTP->getType()))
656 if (NTTP->isExpandedParameterPack()) {
658 ID.AddInteger(NTTP->getNumExpansionTypes());
659 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
660 QualType T = NTTP->getExpansionType(I);
661 ID.AddPointer(T.getCanonicalType().getAsOpaquePtr());
664 ID.AddBoolean(
false);
674TemplateTemplateParmDecl *
678 llvm::FoldingSetNodeID ID;
679 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
680 void *InsertPos =
nullptr;
681 CanonicalTemplateTemplateParm *Canonical
682 = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
684 return Canonical->getParam();
689 CanonParams.reserve(Params->
size());
691 PEnd = Params->
end();
695 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
700 TTP->getNumExpansionParameters());
701 CanonParams.push_back(NewTTP);
702 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
706 if (NTTP->isExpandedParameterPack()) {
709 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
711 ExpandedTInfos.push_back(
719 NTTP->getPosition(),
nullptr,
729 NTTP->getPosition(),
nullptr,
731 NTTP->isParameterPack(),
734 CanonParams.push_back(Param);
750 Canonical = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
751 assert(!Canonical &&
"Shouldn't be in the map!");
755 Canonical =
new (*this) CanonicalTemplateTemplateParm(CanonTTP);
756 CanonTemplateTemplateParms.InsertNode(Canonical, InsertPos);
763 llvm::FoldingSetNodeID ID;
764 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
765 void *InsertPos =
nullptr;
766 CanonicalTemplateTemplateParm *Canonical =
767 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
768 return Canonical ? Canonical->getParam() :
nullptr;
774 llvm::FoldingSetNodeID ID;
775 CanonicalTemplateTemplateParm::Profile(ID, *
this, CanonTTP);
776 void *InsertPos =
nullptr;
778 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos))
779 return Existing->getParam();
780 CanonTemplateTemplateParms.InsertNode(
781 new (*
this) CanonicalTemplateTemplateParm(CanonTTP), InsertPos);
802 [](
const DynTypedNode &P) { return P.get<WhileStmt>() != nullptr; });
826 return NoSanitizeL->containsType(Mask, TyName);
835 if (!LangOpts.CPlusPlus)
return nullptr;
838 case TargetCXXABI::AppleARM64:
839 case TargetCXXABI::Fuchsia:
840 case TargetCXXABI::GenericARM:
841 case TargetCXXABI::iOS:
842 case TargetCXXABI::WatchOS:
843 case TargetCXXABI::GenericAArch64:
844 case TargetCXXABI::GenericMIPS:
845 case TargetCXXABI::GenericItanium:
846 case TargetCXXABI::WebAssembly:
847 case TargetCXXABI::XL:
849 case TargetCXXABI::Microsoft:
852 llvm_unreachable(
"Invalid CXXABI type!");
856 if (!InterpContext) {
859 return *InterpContext;
865 return *ParentMapCtx;
870 switch (LangOpts.getAddressSpaceMapMangling()) {
878 llvm_unreachable(
"getAddressSpaceMapMangling() doesn't cover anything.");
884 : ConstantArrayTypes(this_(), ConstantArrayTypesLog2InitSize),
885 DependentSizedArrayTypes(this_()), DependentSizedExtVectorTypes(this_()),
886 DependentAddressSpaceTypes(this_()), DependentVectorTypes(this_()),
887 DependentSizedMatrixTypes(this_()),
888 FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
889 DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
890 DependentPackIndexingTypes(this_()), TemplateSpecializationTypes(this_()),
891 DependentBitIntTypes(this_()), SubstTemplateTemplateParmPacks(this_()),
892 DeducedTemplates(this_()), ArrayParameterTypes(this_()),
893 CanonTemplateTemplateParms(this_()), SourceMgr(
SM), LangOpts(LOpts),
896 LangOpts.XRayNeverInstrumentFiles,
897 LangOpts.XRayAttrListFiles,
SM)),
901 Comments(
SM), CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
909 ReleaseDeclContextMaps();
912 for (
auto &Pair : Deallocations)
913 (Pair.first)(Pair.second);
914 Deallocations.clear();
920 I = ObjCLayouts.begin(),
921 E = ObjCLayouts.end();
928 for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
929 I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
934 ASTRecordLayouts.clear();
936 for (llvm::DenseMap<const Decl*, AttrVec*>::iterator A = DeclAttrs.begin(),
937 AEnd = DeclAttrs.end();
939 A->second->~AttrVec();
942 for (
const auto &
Value : ModuleInitializers)
943 Value.second->~PerModuleInitializers();
944 ModuleInitializers.
clear();
954 TraversalScope = TopLevelDecls;
959 Deallocations.push_back({Callback,
Data});
968 llvm::errs() <<
"\n*** AST Context Stats:\n";
969 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
971 unsigned counts[] = {
972#define TYPE(Name, Parent) 0,
973#define ABSTRACT_TYPE(Name, Parent)
974#include "clang/AST/TypeNodes.inc"
978 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
980 counts[(
unsigned)T->getTypeClass()]++;
984 unsigned TotalBytes = 0;
985#define TYPE(Name, Parent) \
987 llvm::errs() << " " << counts[Idx] << " " << #Name \
988 << " types, " << sizeof(Name##Type) << " each " \
989 << "(" << counts[Idx] * sizeof(Name##Type) \
991 TotalBytes += counts[Idx] * sizeof(Name##Type); \
993#define ABSTRACT_TYPE(Name, Parent)
994#include "clang/AST/TypeNodes.inc"
996 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
1001 <<
" implicit default constructors created\n";
1004 <<
" implicit copy constructors created\n";
1008 <<
" implicit move constructors created\n";
1011 <<
" implicit copy assignment operators created\n";
1015 <<
" implicit move assignment operators created\n";
1018 <<
" implicit destructors created\n";
1021 llvm::errs() <<
"\n";
1025 BumpAlloc.PrintStats();
1029 bool NotifyListeners) {
1030 if (NotifyListeners)
1033 Listener->RedefinedHiddenDefinition(ND, M);
1040 if (It == MergedDefModules.end())
1043 auto &Merged = It->second;
1044 llvm::DenseSet<Module*>
Found;
1045 for (
Module *&M : Merged)
1046 if (!
Found.insert(M).second)
1048 llvm::erase(Merged,
nullptr);
1055 if (MergedIt == MergedDefModules.end())
1057 return MergedIt->second;
1060void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1061 if (LazyInitializers.empty())
1065 assert(Source &&
"lazy initializers but no external source");
1067 auto LazyInits = std::move(LazyInitializers);
1068 LazyInitializers.clear();
1070 for (
auto ID : LazyInits)
1071 Initializers.push_back(Source->GetExternalDecl(ID));
1073 assert(LazyInitializers.empty() &&
1074 "GetExternalDecl for lazy module initializer added more inits");
1080 if (
const auto *ID = dyn_cast<ImportDecl>(D)) {
1081 auto It = ModuleInitializers.find(ID->getImportedModule());
1084 if (It == ModuleInitializers.end())
1088 auto &Imported = *It->second;
1089 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1090 Imported.resolve(*
this);
1091 auto *OnlyDecl = Imported.Initializers.front();
1097 auto *&
Inits = ModuleInitializers[M];
1099 Inits =
new (*this) PerModuleInitializers;
1100 Inits->Initializers.push_back(D);
1105 auto *&
Inits = ModuleInitializers[M];
1107 Inits =
new (*this) PerModuleInitializers;
1108 Inits->LazyInitializers.insert(
Inits->LazyInitializers.end(),
1109 IDs.begin(), IDs.end());
1113 auto It = ModuleInitializers.find(M);
1114 if (It == ModuleInitializers.end())
1117 auto *
Inits = It->second;
1118 Inits->resolve(*
this);
1119 return Inits->Initializers;
1124 assert(!CurrentCXXNamedModule &&
1125 "We should set named module for ASTContext for only once");
1126 CurrentCXXNamedModule = M;
1138 auto GetRepresentativeModule = [
this](
const Module *M) {
1139 auto Iter = SameModuleLookupSet.find(M);
1140 if (Iter != SameModuleLookupSet.end())
1141 return Iter->second;
1143 const Module *RepresentativeModule =
1144 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1146 SameModuleLookupSet[M] = RepresentativeModule;
1147 return RepresentativeModule;
1150 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1151 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1155 if (!ExternCContext)
1158 return ExternCContext;
1172#define BuiltinTemplate(BTName) \
1173 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1174 if (!Decl##BTName) \
1176 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1177 return Decl##BTName; \
1179#include "clang/Basic/BuiltinTemplates.inc"
1192 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1193 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1198 StringRef Name)
const {
1222 Types.push_back(Ty);
1227 assert((!this->Target || this->Target == &Target) &&
1228 "Incorrect target reinitialization");
1229 assert(
VoidTy.isNull() &&
"Context reinitialized?");
1231 this->Target = &Target;
1232 this->AuxTarget = AuxTarget;
1234 ABI.reset(createCXXABI(Target));
1238 InitBuiltinType(
VoidTy, BuiltinType::Void);
1241 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1243 if (LangOpts.CharIsSigned)
1244 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1246 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1249 InitBuiltinType(
ShortTy, BuiltinType::Short);
1250 InitBuiltinType(
IntTy, BuiltinType::Int);
1251 InitBuiltinType(
LongTy, BuiltinType::Long);
1252 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1262 InitBuiltinType(
FloatTy, BuiltinType::Float);
1263 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1264 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1267 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1270 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1273 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1276 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1277 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1278 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1282 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1283 InitBuiltinType(
FractTy, BuiltinType::Fract);
1284 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1289 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1295 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1302 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1307 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1309 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1310 if (LangOpts.CPlusPlus && LangOpts.WChar)
1314 WideCharTy = getFromTargetType(Target.getWCharType());
1317 WIntTy = getFromTargetType(Target.getWIntType());
1320 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1322 if (LangOpts.CPlusPlus)
1323 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1325 Char16Ty = getFromTargetType(Target.getChar16Type());
1327 if (LangOpts.CPlusPlus)
1328 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1330 Char32Ty = getFromTargetType(Target.getChar32Type());
1337 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1340 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1352 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1358 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1361 if (LangOpts.OpenMP) {
1368 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1371 if (LangOpts.MatrixTypes)
1379 if (LangOpts.OpenCL) {
1380#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1381 InitBuiltinType(SingletonId, BuiltinType::Id);
1382#include "clang/Basic/OpenCLImageTypes.def"
1384 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1385 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1387 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1390#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1391 InitBuiltinType(Id##Ty, BuiltinType::Id);
1392#include "clang/Basic/OpenCLExtensionTypes.def"
1395 if (LangOpts.HLSL) {
1396#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1397 InitBuiltinType(SingletonId, BuiltinType::Id);
1398#include "clang/Basic/HLSLIntangibleTypes.def"
1401 if (Target.hasAArch64ACLETypes() ||
1402 (AuxTarget && AuxTarget->hasAArch64ACLETypes())) {
1403#define SVE_TYPE(Name, Id, SingletonId) \
1404 InitBuiltinType(SingletonId, BuiltinType::Id);
1405#include "clang/Basic/AArch64ACLETypes.def"
1408 if (Target.getTriple().isPPC64()) {
1409#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1410 InitBuiltinType(Id##Ty, BuiltinType::Id);
1411#include "clang/Basic/PPCTypes.def"
1412#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1413 InitBuiltinType(Id##Ty, BuiltinType::Id);
1414#include "clang/Basic/PPCTypes.def"
1417 if (Target.hasRISCVVTypes()) {
1418#define RVV_TYPE(Name, Id, SingletonId) \
1419 InitBuiltinType(SingletonId, BuiltinType::Id);
1420#include "clang/Basic/RISCVVTypes.def"
1423 if (Target.getTriple().isWasm() && Target.hasFeature(
"reference-types")) {
1424#define WASM_TYPE(Name, Id, SingletonId) \
1425 InitBuiltinType(SingletonId, BuiltinType::Id);
1426#include "clang/Basic/WebAssemblyReferenceTypes.def"
1429 if (Target.getTriple().isAMDGPU() ||
1430 (Target.getTriple().isSPIRV() &&
1431 Target.getTriple().getVendor() == llvm::Triple::AMD) ||
1433 (AuxTarget->getTriple().isAMDGPU() ||
1434 ((AuxTarget->getTriple().isSPIRV() &&
1435 AuxTarget->getTriple().getVendor() == llvm::Triple::AMD))))) {
1436#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1437 InitBuiltinType(SingletonId, BuiltinType::Id);
1438#include "clang/Basic/AMDGPUTypes.def"
1445 ObjCConstantStringType =
QualType();
1450 if (LangOpts.OpenCLGenericAddressSpace) {
1451 auto Q =
VoidTy.getQualifiers();
1460 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1463 InitBuiltinType(
HalfTy, BuiltinType::Half);
1465 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1471 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1478 return SourceMgr.getDiagnostics();
1493 llvm::DenseMap<const Decl*, AttrVec*>::iterator Pos = DeclAttrs.find(D);
1494 if (Pos != DeclAttrs.end()) {
1495 Pos->second->~AttrVec();
1496 DeclAttrs.erase(Pos);
1504 if (It != ExplicitInstantiations.end())
1525 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1526 TemplateOrInstantiation.find(Var);
1527 if (Pos == TemplateOrInstantiation.end())
1540 Tmpl, TSK, PointOfInstantiation));
1546 assert(!TemplateOrInstantiation[Inst] &&
1547 "Already noted what the variable was instantiated from");
1548 TemplateOrInstantiation[Inst] = TSI;
1553 return InstantiatedFromUsingDecl.lookup(UUD);
1561 "pattern decl is not a using decl");
1565 "instantiation did not produce a using decl");
1566 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1567 InstantiatedFromUsingDecl[Inst] = Pattern;
1572 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1577 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1578 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1583 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1589 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1590 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1595 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1601 "Instantiated field decl is not unnamed");
1603 "Template field decl is not unnamed");
1604 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1605 "Already noted what unnamed field was instantiated from");
1607 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1623 return Range.end() - Range.begin();
1628 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1629 OverriddenMethods.find(
Method->getCanonicalDecl());
1630 if (Pos == OverriddenMethods.end())
1638 OverriddenMethods[
Method].push_back(Overridden);
1646 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1652 const auto *
Method = dyn_cast<ObjCMethodDecl>(D);
1657 Method->getOverriddenMethods(OverDecls);
1658 Overridden.append(OverDecls.begin(), OverDecls.end());
1661std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1665 auto it = RelocatableClasses.find(D);
1666 if (it != RelocatableClasses.end())
1667 return it->getSecond();
1668 return std::nullopt;
1675 assert(RelocatableClasses.find(D) == RelocatableClasses.end());
1676 RelocatableClasses.insert({D, Info});
1681 if (!Class->isPolymorphic())
1683 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
1684 using AuthAttr = VTablePointerAuthenticationAttr;
1685 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1687 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1688 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1689 ExplicitAuth->getAddressDiscrimination();
1690 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1691 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1692 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1695ASTContext::PointerAuthContent
1696ASTContext::findPointerAuthContent(QualType T)
const {
1697 assert(isPointerAuthenticationAvailable());
1701 return PointerAuthContent::None;
1704 return PointerAuthContent::AddressDiscriminatedData;
1707 return PointerAuthContent::None;
1710 return PointerAuthContent::None;
1712 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1713 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1714 return Existing->second;
1716 PointerAuthContent
Result = PointerAuthContent::None;
1718 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1719 auto [ResultIter, DidAdd] =
1720 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1726 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1727 static_assert(PointerAuthContent::None <
1728 PointerAuthContent::AddressDiscriminatedVTable);
1729 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1730 PointerAuthContent::AddressDiscriminatedData);
1733 return Result != PointerAuthContent::AddressDiscriminatedData;
1735 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1737 !ShouldContinueAfterUpdate(
1738 PointerAuthContent::AddressDiscriminatedVTable))
1739 return SaveResultAndReturn();
1740 for (
auto Base : CXXRD->bases()) {
1741 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1742 return SaveResultAndReturn();
1745 for (
auto *FieldDecl : RD->
fields()) {
1746 if (!ShouldContinueAfterUpdate(
1747 findPointerAuthContent(FieldDecl->getType())))
1748 return SaveResultAndReturn();
1750 return SaveResultAndReturn();
1754 assert(!Import->getNextLocalImport() &&
1755 "Import declaration already in the chain");
1756 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1757 if (!FirstLocalImport) {
1758 FirstLocalImport = Import;
1759 LastLocalImport = Import;
1763 LastLocalImport->setNextLocalImport(Import);
1764 LastLocalImport = Import;
1776 llvm_unreachable(
"Not a floating point type!");
1777 case BuiltinType::BFloat16:
1778 return Target->getBFloat16Format();
1779 case BuiltinType::Float16:
1780 return Target->getHalfFormat();
1781 case BuiltinType::Half:
1782 return Target->getHalfFormat();
1783 case BuiltinType::Float:
return Target->getFloatFormat();
1784 case BuiltinType::Double:
return Target->getDoubleFormat();
1785 case BuiltinType::Ibm128:
1786 return Target->getIbm128Format();
1787 case BuiltinType::LongDouble:
1789 return AuxTarget->getLongDoubleFormat();
1790 return Target->getLongDoubleFormat();
1791 case BuiltinType::Float128:
1793 return AuxTarget->getFloat128Format();
1794 return Target->getFloat128Format();
1799 unsigned Align = Target->getCharWidth();
1803 Align = AlignFromAttr;
1811 bool UseAlignAttrOnly;
1812 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1814 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1816 UseAlignAttrOnly = AlignFromAttr != 0;
1819 if (UseAlignAttrOnly) {
1821 }
else if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
1825 T = RT->getPointeeType();
1830 if (T->isFunctionType())
1831 Align = getTypeInfoImpl(T.getTypePtr()).Align;
1836 unsigned MinWidth = Target->getLargeArrayMinWidth();
1837 if (!ForAlignof && MinWidth) {
1839 Align = std::max(Align, Target->getLargeArrayAlign());
1842 Align = std::max(Align, Target->getLargeArrayAlign());
1847 Align = Target->getCharWidth();
1851 if (
const auto *VD = dyn_cast<VarDecl>(D))
1852 if (VD->hasGlobalStorage() && !ForAlignof) {
1863 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1877 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1878 if (LowBitOfOffset < FieldAlign)
1879 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1882 Align = std::min(Align, FieldAlign);
1890 const auto *VD = dyn_cast<VarDecl>(D);
1891 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1892 Align = std::min(Align, MaxAlignedAttr);
1912 if (
const auto *RD = T->getAsCXXRecordDecl(); RD && !RD->
isInvalidDecl()) {
1929 (uint64_t)(-1)/Size) &&
1930 "Overflow in array type char size evaluation");
1933 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
1935 Width = llvm::alignTo(Width, Align);
1942 if (
const auto *CAT = dyn_cast<ConstantArrayType>(T))
1960 switch (BT->getKind()) {
1961 case BuiltinType::Bool:
1962 case BuiltinType::Char_S:
1963 case BuiltinType::Char_U:
1964 case BuiltinType::SChar:
1965 case BuiltinType::UChar:
1966 case BuiltinType::Short:
1967 case BuiltinType::UShort:
1968 case BuiltinType::WChar_S:
1969 case BuiltinType::WChar_U:
1970 case BuiltinType::Char8:
1971 case BuiltinType::Char16:
1972 case BuiltinType::Char32:
1980 if (
const auto *ED = T->getAsEnumDecl()) {
1981 if (T->isDependentType() || ED->getPromotionType().isNull() ||
1989 if (
const auto *OBT = T->getAs<OverflowBehaviorType>()) {
2005 bool NeedsPreferredAlignment)
const {
2008 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2013 if (!T->isIncompleteType())
2019 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2023 if (
const auto *TD = T->getAsTagDecl())
2024 return TD->getMaxAlignment();
2030 TypeInfoMap::iterator I = MemoizedTypeInfo.find(T);
2031 if (I != MemoizedTypeInfo.end())
2036 MemoizedTypeInfo[T] = TI;
2046TypeInfo ASTContext::getTypeInfoImpl(
const Type *T)
const {
2051 switch (T->getTypeClass()) {
2052#define TYPE(Class, Base)
2053#define ABSTRACT_TYPE(Class, Base)
2054#define NON_CANONICAL_TYPE(Class, Base)
2055#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2056#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
2058 assert(!T->isDependentType() && "should not see dependent types here"); \
2059 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
2060#include "clang/AST/TypeNodes.inc"
2061 llvm_unreachable(
"Should not see dependent types");
2063 case Type::FunctionNoProto:
2064 case Type::FunctionProto:
2070 case Type::IncompleteArray:
2071 case Type::VariableArray:
2072 case Type::ConstantArray:
2073 case Type::ArrayParameter: {
2076 if (
const auto *CAT = dyn_cast<ConstantArrayType>(T))
2077 Size = CAT->getZExtSize();
2080 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2081 "Overflow in array type bit size evaluation");
2082 Width = EltInfo.
Width * Size;
2083 Align = EltInfo.
Align;
2087 Width = llvm::alignTo(Width, Align);
2091 case Type::ExtVector:
2092 case Type::Vector: {
2095 Width = VT->isPackedVectorBoolType(*
this)
2096 ? VT->getNumElements()
2097 : EltInfo.
Width * VT->getNumElements();
2099 Width = std::max<unsigned>(8, Width);
2100 Align = std::max<unsigned>(
2101 8,
Target->vectorsAreElementAligned() ? EltInfo.
Width : Width);
2105 if (Align & (Align-1)) {
2106 Align = llvm::bit_ceil(Align);
2107 Width = llvm::alignTo(Width, Align);
2110 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
2111 if (TargetVectorAlign && TargetVectorAlign < Align)
2112 Align = TargetVectorAlign;
2126 Align = std::min<unsigned>(64, Width);
2130 case Type::ConstantMatrix: {
2132 TypeInfo ElementInfo =
getTypeInfo(MT->getElementType());
2136 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2137 Align = ElementInfo.
Align;
2143 default: llvm_unreachable(
"Unknown builtin type!");
2144 case BuiltinType::Void:
2149 case BuiltinType::Bool:
2150 Width = Target->getBoolWidth();
2151 Align = Target->getBoolAlign();
2153 case BuiltinType::Char_S:
2154 case BuiltinType::Char_U:
2155 case BuiltinType::UChar:
2156 case BuiltinType::SChar:
2157 case BuiltinType::Char8:
2158 Width = Target->getCharWidth();
2159 Align = Target->getCharAlign();
2161 case BuiltinType::WChar_S:
2162 case BuiltinType::WChar_U:
2163 Width = Target->getWCharWidth();
2164 Align = Target->getWCharAlign();
2166 case BuiltinType::Char16:
2167 Width = Target->getChar16Width();
2168 Align = Target->getChar16Align();
2170 case BuiltinType::Char32:
2171 Width = Target->getChar32Width();
2172 Align = Target->getChar32Align();
2174 case BuiltinType::UShort:
2175 case BuiltinType::Short:
2176 Width = Target->getShortWidth();
2177 Align = Target->getShortAlign();
2179 case BuiltinType::UInt:
2180 case BuiltinType::Int:
2181 Width = Target->getIntWidth();
2182 Align = Target->getIntAlign();
2184 case BuiltinType::ULong:
2185 case BuiltinType::Long:
2186 Width = Target->getLongWidth();
2187 Align = Target->getLongAlign();
2189 case BuiltinType::ULongLong:
2190 case BuiltinType::LongLong:
2191 Width = Target->getLongLongWidth();
2192 Align = Target->getLongLongAlign();
2194 case BuiltinType::Int128:
2195 case BuiltinType::UInt128:
2197 Align = Target->getInt128Align();
2199 case BuiltinType::ShortAccum:
2200 case BuiltinType::UShortAccum:
2201 case BuiltinType::SatShortAccum:
2202 case BuiltinType::SatUShortAccum:
2203 Width = Target->getShortAccumWidth();
2204 Align = Target->getShortAccumAlign();
2206 case BuiltinType::Accum:
2207 case BuiltinType::UAccum:
2208 case BuiltinType::SatAccum:
2209 case BuiltinType::SatUAccum:
2210 Width = Target->getAccumWidth();
2211 Align = Target->getAccumAlign();
2213 case BuiltinType::LongAccum:
2214 case BuiltinType::ULongAccum:
2215 case BuiltinType::SatLongAccum:
2216 case BuiltinType::SatULongAccum:
2217 Width = Target->getLongAccumWidth();
2218 Align = Target->getLongAccumAlign();
2220 case BuiltinType::ShortFract:
2221 case BuiltinType::UShortFract:
2222 case BuiltinType::SatShortFract:
2223 case BuiltinType::SatUShortFract:
2224 Width = Target->getShortFractWidth();
2225 Align = Target->getShortFractAlign();
2227 case BuiltinType::Fract:
2228 case BuiltinType::UFract:
2229 case BuiltinType::SatFract:
2230 case BuiltinType::SatUFract:
2231 Width = Target->getFractWidth();
2232 Align = Target->getFractAlign();
2234 case BuiltinType::LongFract:
2235 case BuiltinType::ULongFract:
2236 case BuiltinType::SatLongFract:
2237 case BuiltinType::SatULongFract:
2238 Width = Target->getLongFractWidth();
2239 Align = Target->getLongFractAlign();
2241 case BuiltinType::BFloat16:
2242 if (Target->hasBFloat16Type()) {
2243 Width = Target->getBFloat16Width();
2244 Align = Target->getBFloat16Align();
2248 AuxTarget->hasBFloat16Type()) {
2249 Width = AuxTarget->getBFloat16Width();
2250 Align = AuxTarget->getBFloat16Align();
2253 case BuiltinType::Float16:
2254 case BuiltinType::Half:
2255 if (Target->hasFloat16Type() || !
getLangOpts().OpenMP ||
2257 Width = Target->getHalfWidth();
2258 Align = Target->getHalfAlign();
2261 "Expected OpenMP device compilation.");
2262 Width = AuxTarget->getHalfWidth();
2263 Align = AuxTarget->getHalfAlign();
2266 case BuiltinType::Float:
2267 Width = Target->getFloatWidth();
2268 Align = Target->getFloatAlign();
2270 case BuiltinType::Double:
2271 Width = Target->getDoubleWidth();
2272 Align = Target->getDoubleAlign();
2274 case BuiltinType::Ibm128:
2275 Width = Target->getIbm128Width();
2276 Align = Target->getIbm128Align();
2278 case BuiltinType::LongDouble:
2280 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2281 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2282 Width = AuxTarget->getLongDoubleWidth();
2283 Align = AuxTarget->getLongDoubleAlign();
2285 Width = Target->getLongDoubleWidth();
2286 Align = Target->getLongDoubleAlign();
2289 case BuiltinType::Float128:
2290 if (Target->hasFloat128Type() || !
getLangOpts().OpenMP ||
2292 Width = Target->getFloat128Width();
2293 Align = Target->getFloat128Align();
2296 "Expected OpenMP device compilation.");
2297 Width = AuxTarget->getFloat128Width();
2298 Align = AuxTarget->getFloat128Align();
2301 case BuiltinType::NullPtr:
2306 case BuiltinType::ObjCId:
2307 case BuiltinType::ObjCClass:
2308 case BuiltinType::ObjCSel:
2312 case BuiltinType::OCLSampler:
2313 case BuiltinType::OCLEvent:
2314 case BuiltinType::OCLClkEvent:
2315 case BuiltinType::OCLQueue:
2316 case BuiltinType::OCLReserveID:
2317#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2318 case BuiltinType::Id:
2319#include "clang/Basic/OpenCLImageTypes.def"
2320#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2321 case BuiltinType::Id:
2322#include "clang/Basic/OpenCLExtensionTypes.def"
2324 Width = Target->getPointerWidth(AS);
2325 Align = Target->getPointerAlign(AS);
2335#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2336 case BuiltinType::Id: \
2340#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2341 case BuiltinType::Id: \
2345#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2346 case BuiltinType::Id: \
2350#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2351 case BuiltinType::Id: \
2355#include "clang/Basic/AArch64ACLETypes.def"
2356#define PPC_VECTOR_TYPE(Name, Id, Size) \
2357 case BuiltinType::Id: \
2361#include "clang/Basic/PPCTypes.def"
2362#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2364 case BuiltinType::Id: \
2368#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2369 case BuiltinType::Id: \
2373#include "clang/Basic/RISCVVTypes.def"
2374#define WASM_TYPE(Name, Id, SingletonId) \
2375 case BuiltinType::Id: \
2379#include "clang/Basic/WebAssemblyReferenceTypes.def"
2380#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2381 case BuiltinType::ID: \
2385#include "clang/Basic/AMDGPUTypes.def"
2386#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2387#include "clang/Basic/HLSLIntangibleTypes.def"
2393 case Type::ObjCObjectPointer:
2397 case Type::BlockPointer:
2399 Width = Target->getPointerWidth(AS);
2400 Align = Target->getPointerAlign(AS);
2402 case Type::LValueReference:
2403 case Type::RValueReference:
2407 Width = Target->getPointerWidth(AS);
2408 Align = Target->getPointerAlign(AS);
2412 Width = Target->getPointerWidth(AS);
2413 Align = Target->getPointerAlign(AS);
2415 case Type::MemberPointer: {
2417 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2422 case Type::Complex: {
2426 Width = EltInfo.
Width * 2;
2427 Align = EltInfo.
Align;
2430 case Type::ObjCObject:
2432 case Type::Adjusted:
2435 case Type::ObjCInterface: {
2437 if (ObjCI->getDecl()->isInvalidDecl()) {
2447 case Type::BitInt: {
2449 Align = Target->getBitIntAlign(EIT->getNumBits());
2450 Width = Target->getBitIntWidth(EIT->getNumBits());
2456 const TagDecl *TD = TT->getDecl()->getDefinitionOrSelf();
2469 Info.
Align = AttrAlign;
2479 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2485 case Type::SubstTemplateTypeParm:
2487 getReplacementType().getTypePtr());
2490 case Type::DeducedTemplateSpecialization: {
2492 assert(!A->getDeducedType().isNull() &&
2493 "cannot request the size of an undeduced or dependent auto type");
2494 return getTypeInfo(A->getDeducedType().getTypePtr());
2500 case Type::MacroQualified:
2504 case Type::ObjCTypeParam:
2510 case Type::Typedef: {
2512 TypeInfo Info =
getTypeInfo(TT->desugar().getTypePtr());
2516 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2527 case Type::Attributed:
2531 case Type::CountAttributed:
2534 case Type::BTFTagAttributed:
2538 case Type::OverflowBehavior:
2542 case Type::HLSLAttributedResource:
2546 case Type::HLSLInlineSpirv: {
2549 Width = ST->getSize() * 8;
2550 Align = ST->getAlignment();
2551 if (Width == 0 && Align == 0) {
2559 case Type::Atomic: {
2568 Width = Target->getCharWidth();
2570 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2576 Width = llvm::bit_ceil(Width);
2579 Align =
static_cast<unsigned>(Width);
2584 case Type::PredefinedSugar:
2593 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2594 return TypeInfo(Width, Align, AlignRequirement);
2598 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(T);
2599 if (I != MemoizedUnadjustedAlign.end())
2602 unsigned UnadjustedAlign;
2603 if (
const auto *RT = T->getAsCanonical<RecordType>()) {
2610 UnadjustedAlign =
getTypeAlign(T->getUnqualifiedDesugaredType());
2613 MemoizedUnadjustedAlign[T] = UnadjustedAlign;
2614 return UnadjustedAlign;
2618 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2668 unsigned ABIAlign = TI.
Align;
2670 T = T->getBaseElementTypeUnsafe();
2673 if (T->isMemberPointerType())
2676 if (!Target->allowsLargerPreferedTypeAlignment())
2679 if (
const auto *RD = T->getAsRecordDecl()) {
2688 unsigned PreferredAlign =
static_cast<unsigned>(
2690 assert(PreferredAlign >= ABIAlign &&
2691 "PreferredAlign should be at least as large as ABIAlign.");
2692 return PreferredAlign;
2699 T = CT->getElementType().getTypePtr();
2700 if (
const auto *ED = T->getAsEnumDecl())
2701 T = ED->getIntegerType().getTypePtr();
2702 if (T->isSpecificBuiltinType(BuiltinType::Double) ||
2703 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2704 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2705 (T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2706 Target->defaultsToAIXPowerAlignment()))
2710 return std::max(ABIAlign, (
unsigned)
getTypeSize(T));
2761 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
2765 std::swap(
Base, Derived);
2785 llvm::append_range(Ivars, OI->
ivars());
2788 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2790 Ivars.push_back(Iv);
2798 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2801 for (
auto *Proto : OI->all_referenced_protocols()) {
2806 for (
const auto *Cat : OI->visible_categories())
2812 SD = SD->getSuperClass();
2814 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2815 for (
auto *Proto : OC->protocols()) {
2818 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2820 if (!Protocols.insert(
2824 for (
auto *Proto : OP->protocols())
2831 bool CheckIfTriviallyCopyable) {
2832 assert(RD->
isUnion() &&
"Must be union type");
2834 Context.getTypeSizeInChars(Context.getCanonicalTagType(RD));
2836 for (
const auto *Field : RD->
fields()) {
2837 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2838 CheckIfTriviallyCopyable))
2840 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2841 if (FieldSize != UnionSize)
2850 return Context.getFieldOffset(Field);
2859static std::optional<int64_t>
2861 const RecordDecl *RD,
2862 bool CheckIfTriviallyCopyable);
2864static std::optional<int64_t>
2866 bool CheckIfTriviallyCopyable) {
2867 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2870 CheckIfTriviallyCopyable);
2874 bool IsBitIntType = Field->getType()->isBitIntType();
2875 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2876 !Context.hasUniqueObjectRepresentations(Field->getType(),
2877 CheckIfTriviallyCopyable))
2878 return std::nullopt;
2880 int64_t FieldSizeInBits =
2881 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2882 if (Field->isBitField()) {
2885 if (Field->isUnnamedBitField())
2888 int64_t BitfieldSize = Field->getBitWidthValue();
2890 if ((
unsigned)BitfieldSize >
2892 return std::nullopt;
2893 }
else if (BitfieldSize > FieldSizeInBits) {
2894 return std::nullopt;
2896 FieldSizeInBits = BitfieldSize;
2897 }
else if (IsBitIntType && !Context.hasUniqueObjectRepresentations(
2898 Field->getType(), CheckIfTriviallyCopyable)) {
2899 return std::nullopt;
2901 return FieldSizeInBits;
2904static std::optional<int64_t>
2906 bool CheckIfTriviallyCopyable) {
2908 CheckIfTriviallyCopyable);
2911template <
typename RangeT>
2913 const RangeT &Subobjects, int64_t CurOffsetInBits,
2915 bool CheckIfTriviallyCopyable) {
2916 for (
const auto *Subobject : Subobjects) {
2917 std::optional<int64_t> SizeInBits =
2920 return std::nullopt;
2921 if (*SizeInBits != 0) {
2923 if (Offset != CurOffsetInBits)
2924 return std::nullopt;
2925 CurOffsetInBits += *SizeInBits;
2928 return CurOffsetInBits;
2931static std::optional<int64_t>
2934 bool CheckIfTriviallyCopyable) {
2935 assert(!RD->
isUnion() &&
"Must be struct/class type");
2936 const auto &Layout = Context.getASTRecordLayout(RD);
2938 int64_t CurOffsetInBits = 0;
2939 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
2940 if (ClassDecl->isDynamicClass())
2941 return std::nullopt;
2944 for (
const auto &
Base : ClassDecl->bases()) {
2947 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
2951 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
2954 std::optional<int64_t> OffsetAfterBases =
2956 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
2957 if (!OffsetAfterBases)
2958 return std::nullopt;
2959 CurOffsetInBits = *OffsetAfterBases;
2962 std::optional<int64_t> OffsetAfterFields =
2964 RD->
fields(), CurOffsetInBits, Context, Layout,
2965 CheckIfTriviallyCopyable);
2966 if (!OffsetAfterFields)
2967 return std::nullopt;
2968 CurOffsetInBits = *OffsetAfterFields;
2970 return CurOffsetInBits;
2974 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
2991 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
2996 CheckIfTriviallyCopyable);
2999 "hasUniqueObjectRepresentations should not be called with an "
3023 return !ABI->getMemberPointerInfo(MPT).HasPadding;
3026 if (
Record->isInvalidDecl())
3031 CheckIfTriviallyCopyable);
3034 *
this,
Record, CheckIfTriviallyCopyable);
3036 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
3057 count += Ext->ivar_size();
3062 count += ImplDecl->ivar_size();
3088 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3089 I = ObjCImpls.find(D);
3090 if (I != ObjCImpls.end())
3098 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3099 I = ObjCImpls.find(D);
3100 if (I != ObjCImpls.end())
3108 assert(IFaceD && ImplD &&
"Passed null params");
3109 ObjCImpls[IFaceD] = ImplD;
3115 assert(CatD && ImplD &&
"Passed null params");
3116 ObjCImpls[CatD] = ImplD;
3121 return ObjCMethodRedecls.
lookup(MD);
3127 ObjCMethodRedecls[MD] = Redecl;
3132 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3134 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3135 return CD->getClassInterface();
3136 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3137 return IMD->getClassInterface();
3145 assert(VD &&
"Passed null params");
3146 assert(VD->
hasAttr<BlocksAttr>() &&
3147 "getBlockVarCopyInits - not __block var");
3148 auto I = BlockVarCopyInits.find(VD);
3149 if (I != BlockVarCopyInits.end())
3151 return {
nullptr,
false};
3157 assert(VD && CopyExpr &&
"Passed null params");
3158 assert(VD->
hasAttr<BlocksAttr>() &&
3159 "setBlockVarCopyInits - not __block var");
3160 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3164 unsigned DataSize)
const {
3169 "incorrect data size provided to CreateTypeSourceInfo!");
3186 return getObjCLayout(D);
3191 bool &AnyNonCanonArgs) {
3193 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3199 bool AnyNonCanonArgs =
false;
3200 for (
auto &Arg : Args) {
3203 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3205 return AnyNonCanonArgs;
3213ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3218 llvm::FoldingSetNodeID ID;
3220 void *insertPos =
nullptr;
3221 if (
ExtQuals *eq = ExtQualNodes.FindNodeOrInsertPos(ID, insertPos)) {
3222 assert(eq->getQualifiers() == quals);
3231 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3234 (void) ExtQualNodes.FindNodeOrInsertPos(ID, insertPos);
3237 auto *eq =
new (*
this,
alignof(ExtQuals)) ExtQuals(baseType, canon, quals);
3238 ExtQualNodes.InsertNode(eq, insertPos);
3239 return QualType(eq, fastQuals);
3243 LangAS AddressSpace)
const {
3256 "Type cannot be in multiple addr spaces!");
3259 return getExtQualType(TypeNode, Quals);
3265 if (!T.hasAddressSpace())
3269 const Type *TypeNode;
3272 if (T.getTypePtr()->isArrayType()) {
3274 TypeNode = T.getTypePtr();
3278 while (T.hasAddressSpace()) {
3279 TypeNode = Quals.
strip(T);
3283 if (!
QualType(TypeNode, 0).hasAddressSpace())
3287 T = T.getSingleStepDesugaredType(*
this);
3297 return getExtQualType(TypeNode, Quals);
3305 "Attempted to get vtable pointer discriminator on a monomorphic type");
3308 llvm::raw_svector_ostream Out(Str);
3309 MC->mangleCXXVTable(RD, Out);
3310 return llvm::getPointerAuthStableSipHash(Str);
3336 switch (T->getTypeClass()) {
3341 case Type::LValueReference:
3346 case Type::RValueReference:
3360 case Type::ObjCObjectPointer:
3361 case Type::BlockPointer:
3370 case Type::VariableArray:
3371 case Type::ConstantArray:
3372 case Type::IncompleteArray:
3373 case Type::ArrayParameter:
3386 case Type::ObjCInterface:
3387 case Type::ObjCObject:
3388 OS <<
"<objc_object>";
3399 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3402 case Type::FunctionNoProto:
3403 case Type::FunctionProto: {
3419 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3420 for (
QualType Param : FPT->param_types()) {
3424 if (FPT->isVariadic())
3431 case Type::MemberPointer: {
3435 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3439 case Type::ExtVector:
3447 case Type::ConstantMatrix:
3451 case Type::Builtin: {
3453 switch (BTy->getKind()) {
3454#define SIGNED_TYPE(Id, SingletonId) \
3455 case BuiltinType::Id: \
3458#define UNSIGNED_TYPE(Id, SingletonId) \
3459 case BuiltinType::Id: \
3462#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3463#define BUILTIN_TYPE(Id, SingletonId)
3464#include "clang/AST/BuiltinTypes.def"
3465 llvm_unreachable(
"placeholder types should not appear here.");
3467 case BuiltinType::Half:
3470 case BuiltinType::Float:
3473 case BuiltinType::Double:
3476 case BuiltinType::LongDouble:
3479 case BuiltinType::Float16:
3482 case BuiltinType::Float128:
3486 case BuiltinType::Void:
3490 case BuiltinType::ObjCId:
3491 case BuiltinType::ObjCClass:
3492 case BuiltinType::ObjCSel:
3493 case BuiltinType::NullPtr:
3498 case BuiltinType::OCLSampler:
3499 case BuiltinType::OCLEvent:
3500 case BuiltinType::OCLClkEvent:
3501 case BuiltinType::OCLQueue:
3502 case BuiltinType::OCLReserveID:
3503 case BuiltinType::BFloat16:
3504 case BuiltinType::VectorQuad:
3505 case BuiltinType::VectorPair:
3506 case BuiltinType::DMR1024:
3507 case BuiltinType::DMR2048:
3512 case BuiltinType::Ibm128:
3514#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3515 case BuiltinType::Id: \
3517#include "clang/Basic/OpenCLImageTypes.def"
3518#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3519 case BuiltinType::Id: \
3521#include "clang/Basic/OpenCLExtensionTypes.def"
3522#define SVE_TYPE(Name, Id, SingletonId) \
3523 case BuiltinType::Id: \
3525#include "clang/Basic/AArch64ACLETypes.def"
3526#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3527 case BuiltinType::Id: \
3529#include "clang/Basic/HLSLIntangibleTypes.def"
3530 case BuiltinType::Dependent:
3531 llvm_unreachable(
"should never get here");
3532#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3533#include "clang/Basic/AMDGPUTypes.def"
3534 case BuiltinType::WasmExternRef:
3535#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3536#include "clang/Basic/RISCVVTypes.def"
3537 llvm_unreachable(
"not yet implemented");
3539 llvm_unreachable(
"should never get here");
3541 case Type::Record: {
3542 const RecordDecl *RD = T->castAsCanonical<RecordType>()->getDecl();
3562 II = Typedef->getDeclName().getAsIdentifierInfo();
3565 OS <<
"<anonymous_record>";
3571 case Type::HLSLAttributedResource:
3572 case Type::HLSLInlineSpirv:
3573 llvm_unreachable(
"should never get here");
3575 case Type::OverflowBehavior:
3576 llvm_unreachable(
"should never get here");
3578 case Type::DeducedTemplateSpecialization:
3580#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3581#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3582#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3583#define ABSTRACT_TYPE(Class, Base)
3584#define TYPE(Class, Base)
3585#include "clang/AST/TypeNodes.inc"
3586 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3592 assert(!T->isDependentType() &&
3593 "cannot compute type discriminator of a dependent type");
3595 llvm::raw_svector_ostream Out(Str);
3597 if (T->isFunctionPointerType() || T->isFunctionReferenceType())
3598 T = T->getPointeeType();
3600 if (T->isFunctionType()) {
3603 T = T.getUnqualifiedType();
3624 if (MPT->isMemberFunctionPointer()) {
3630 MPT->getMostRecentCXXRecordDecl());
3634 MC->mangleCanonicalTypeName(T, Out);
3637 return llvm::getPointerAuthStableSipHash(Str);
3662 "Type cannot have multiple ObjCGCs!");
3665 return getExtQualType(TypeNode, Quals);
3679 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3683 llvm::FoldingSetNodeID ID;
3686 void *InsertPos =
nullptr;
3688 CountAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
3693 size_t Size = CountAttributedType::totalSizeToAlloc<TypeCoupledDeclRefInfo>(
3694 DependentDecls.size());
3697 OrNull, DependentDecls);
3698 Types.push_back(CATy);
3699 CountAttributedTypes.InsertNode(CATy, InsertPos);
3708 case Type::Attributed: {
3716 case Type::BTFTagAttributed: {
3717 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3722 case Type::OverflowBehavior: {
3723 const auto *OB = dyn_cast<OverflowBehaviorType>(Orig);
3725 adjustType(OB->getUnderlyingType(), Adjust));
3732 case Type::Adjusted: {
3738 case Type::MacroQualified: {
3741 MQT->getMacroIdentifier());
3745 return Adjust(Orig);
3751 if (T->getExtInfo() == Info)
3755 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(T)) {
3775 FPT->getExtProtoInfo());
3790 L->DeducedReturnType(FD, ResultType);
3801 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3802 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3818 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
3841 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
3867 if (TSInfo->getType() != FD->
getType())
3875 "TypeLoc size mismatch from updating exception specification");
3876 TSInfo->overrideType(Updated);
3885 llvm::FoldingSetNodeID ID;
3888 void *InsertPos =
nullptr;
3889 if (
ComplexType *CT = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos))
3895 if (!T.isCanonical()) {
3899 ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos);
3900 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3903 Types.push_back(
New);
3904 ComplexTypes.InsertNode(
New, InsertPos);
3913 llvm::FoldingSetNodeID ID;
3916 void *InsertPos =
nullptr;
3917 if (
PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos))
3923 if (!T.isCanonical()) {
3927 PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos);
3928 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3931 Types.push_back(
New);
3932 PointerTypes.InsertNode(
New, InsertPos);
3937 llvm::FoldingSetNodeID ID;
3939 void *InsertPos =
nullptr;
3940 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3947 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3948 assert(!AT &&
"Shouldn't be in the map!");
3952 Types.push_back(AT);
3953 AdjustedTypes.InsertNode(AT, InsertPos);
3958 llvm::FoldingSetNodeID ID;
3960 void *InsertPos =
nullptr;
3961 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3968 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3969 assert(!AT &&
"Shouldn't be in the map!");
3972 Types.push_back(AT);
3973 AdjustedTypes.InsertNode(AT, InsertPos);
3978 assert((T->isArrayType() || T->isFunctionType()) &&
"T does not decay");
3987 if (T->isArrayType())
3994 if (T->isFunctionType())
4006 llvm::FoldingSetNodeID ID;
4007 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
4008 ATy->getSizeExpr(), ATy->getSizeModifier(),
4009 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
4010 void *InsertPos =
nullptr;
4012 ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
4021 AT = ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
4022 assert(!AT &&
"Shouldn't be in the map!");
4027 Types.push_back(AT);
4028 ArrayParameterTypes.InsertNode(AT, InsertPos);
4035 assert(T->isFunctionType() &&
"block of function types only");
4038 llvm::FoldingSetNodeID ID;
4041 void *InsertPos =
nullptr;
4043 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4049 if (!T.isCanonical()) {
4054 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4055 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4059 Types.push_back(
New);
4060 BlockPointerTypes.InsertNode(
New, InsertPos);
4068 assert((!T->isPlaceholderType() ||
4069 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4070 "Unresolved placeholder type");
4074 llvm::FoldingSetNodeID ID;
4077 void *InsertPos =
nullptr;
4079 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4087 if (!SpelledAsLValue || InnerRef || !T.isCanonical()) {
4088 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() : T);
4093 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4094 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4099 Types.push_back(
New);
4100 LValueReferenceTypes.InsertNode(
New, InsertPos);
4108 assert((!T->isPlaceholderType() ||
4109 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4110 "Unresolved placeholder type");
4114 llvm::FoldingSetNodeID ID;
4117 void *InsertPos =
nullptr;
4119 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4127 if (InnerRef || !T.isCanonical()) {
4128 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() : T);
4133 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4134 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4139 Types.push_back(
New);
4140 RValueReferenceTypes.InsertNode(
New, InsertPos);
4148 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4151 Cls = Qualifier.getAsRecordDecl();
4155 llvm::FoldingSetNodeID ID;
4158 void *InsertPos =
nullptr;
4160 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4165 return Qualifier.getCanonical();
4167 assert(R.isCanonical());
4173 if (!T.isCanonical() || Qualifier != CanonicalQualifier) {
4179 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4180 assert(!NewIP &&
"Shouldn't be in the map!");
4184 Types.push_back(
New);
4185 MemberPointerTypes.InsertNode(
New, InsertPos);
4192 const llvm::APInt &ArySizeIn,
4193 const Expr *SizeExpr,
4195 unsigned IndexTypeQuals)
const {
4198 "Constant array of VLAs is illegal!");
4206 llvm::APInt ArySize(ArySizeIn);
4207 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
4209 llvm::FoldingSetNodeID ID;
4211 ASM, IndexTypeQuals);
4213 void *InsertPos =
nullptr;
4215 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
4226 ASM, IndexTypeQuals);
4231 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
4232 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4235 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4236 ASM, IndexTypeQuals);
4237 ConstantArrayTypes.InsertNode(
New, InsertPos);
4238 Types.push_back(
New);
4247 if (!
type->isVariablyModifiedType())
return type;
4252 const Type *ty = split.
Ty;
4254#define TYPE(Class, Base)
4255#define ABSTRACT_TYPE(Class, Base)
4256#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4257#include "clang/AST/TypeNodes.inc"
4258 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4264 case Type::DependentVector:
4265 case Type::ExtVector:
4266 case Type::DependentSizedExtVector:
4267 case Type::ConstantMatrix:
4268 case Type::DependentSizedMatrix:
4269 case Type::DependentAddressSpace:
4270 case Type::ObjCObject:
4271 case Type::ObjCInterface:
4272 case Type::ObjCObjectPointer:
4275 case Type::UnresolvedUsing:
4276 case Type::TypeOfExpr:
4278 case Type::Decltype:
4279 case Type::UnaryTransform:
4280 case Type::DependentName:
4281 case Type::InjectedClassName:
4282 case Type::TemplateSpecialization:
4283 case Type::TemplateTypeParm:
4284 case Type::SubstTemplateTypeParmPack:
4285 case Type::SubstBuiltinTemplatePack:
4287 case Type::DeducedTemplateSpecialization:
4288 case Type::PackExpansion:
4289 case Type::PackIndexing:
4291 case Type::DependentBitInt:
4292 case Type::ArrayParameter:
4293 case Type::HLSLAttributedResource:
4294 case Type::HLSLInlineSpirv:
4295 case Type::OverflowBehavior:
4296 llvm_unreachable(
"type should never be variably-modified");
4300 case Type::FunctionNoProto:
4301 case Type::FunctionProto:
4302 case Type::BlockPointer:
4303 case Type::MemberPointer:
4316 case Type::LValueReference: {
4320 lv->isSpelledAsLValue());
4324 case Type::RValueReference: {
4331 case Type::Atomic: {
4337 case Type::ConstantArray: {
4343 cat->getSizeModifier(),
4344 cat->getIndexTypeCVRQualifiers());
4348 case Type::DependentSizedArray: {
4352 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4357 case Type::IncompleteArray: {
4362 iat->getIndexTypeCVRQualifiers());
4367 case Type::VariableArray: {
4372 vat->getIndexTypeCVRQualifiers());
4385 unsigned IndexTypeQuals)
const {
4402 VariableArrayTypes.push_back(
New);
4403 Types.push_back(
New);
4413 unsigned elementTypeQuals)
const {
4416 "Size must be type- or value-dependent!");
4420 void *insertPos =
nullptr;
4421 llvm::FoldingSetNodeID ID;
4423 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4424 ASM, elementTypeQuals, numElements);
4428 DependentSizedArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4440 DependentSizedArrayTypes.InsertNode(newType, insertPos);
4441 Types.push_back(newType);
4449 numElements, ASM, elementTypeQuals);
4450 DependentSizedArrayTypes.InsertNode(canonTy, insertPos);
4451 Types.push_back(canonTy);
4456 canonElementType.
Quals);
4460 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4469 Types.push_back(sugaredType);
4475 unsigned elementTypeQuals)
const {
4476 llvm::FoldingSetNodeID ID;
4479 void *insertPos =
nullptr;
4481 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos))
4493 ASM, elementTypeQuals);
4498 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4499 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4505 IncompleteArrayTypes.InsertNode(newType, insertPos);
4506 Types.push_back(newType);
4512#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4513 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4516#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4517 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4521 llvm_unreachable(
"Unsupported builtin vector type");
4523#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4524 ElBits, NF, IsSigned) \
4525 case BuiltinType::Id: \
4526 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4527 llvm::ElementCount::getScalable(NumEls), NF};
4528#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4530 case BuiltinType::Id: \
4531 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4532 llvm::ElementCount::getScalable(NumEls), NF};
4533#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4535 case BuiltinType::Id: \
4536 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4537#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4539 case BuiltinType::Id: \
4540 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4541#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4542 case BuiltinType::Id: \
4543 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4544#include "clang/Basic/AArch64ACLETypes.def"
4546#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4548 case BuiltinType::Id: \
4549 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4550 llvm::ElementCount::getScalable(NumEls), NF};
4551#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4552 case BuiltinType::Id: \
4553 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4554 llvm::ElementCount::getScalable(NumEls), NF};
4555#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4556 case BuiltinType::Id: \
4557 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4558#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4559 case BuiltinType::Id: \
4560 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4561#include "clang/Basic/RISCVVTypes.def"
4568 if (Target->getTriple().isWasm() && Target->hasFeature(
"reference-types")) {
4569#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4570 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4572#include "clang/Basic/WebAssemblyReferenceTypes.def"
4575 "shouldn't try to generate type externref outside WebAssembly target");
4582 unsigned NumFields)
const {
4584 if (
auto It = ScalableVecTyMap.find(K); It != ScalableVecTyMap.end())
4587 if (Target->hasAArch64ACLETypes()) {
4590#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4591 ElBits, NF, IsSigned) \
4592 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4593 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4594 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4595 return ScalableVecTyMap[K] = SingletonId; \
4597#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4599 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4600 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4601 return ScalableVecTyMap[K] = SingletonId; \
4603#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4605 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4606 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4607 return ScalableVecTyMap[K] = SingletonId; \
4609#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4611 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4612 NumElts == (NumEls * NF) && NumFields == 1) { \
4613 return ScalableVecTyMap[K] = SingletonId; \
4615#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4616 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4617 return ScalableVecTyMap[K] = SingletonId;
4618#include "clang/Basic/AArch64ACLETypes.def"
4619 }
else if (Target->hasRISCVVTypes()) {
4621#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4623 if (!EltTy->isBooleanType() && \
4624 ((EltTy->hasIntegerRepresentation() && \
4625 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4626 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4628 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4629 IsBF && !IsFP)) && \
4630 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4631 return ScalableVecTyMap[K] = SingletonId;
4632#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4633 if (EltTy->isBooleanType() && NumElts == NumEls) \
4634 return ScalableVecTyMap[K] = SingletonId;
4635#include "clang/Basic/RISCVVTypes.def"
4650 llvm::FoldingSetNodeID ID;
4653 void *InsertPos =
nullptr;
4654 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4664 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4665 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4668 VectorType(vecType, NumElts, Canonical, VecKind);
4669 VectorTypes.InsertNode(
New, InsertPos);
4670 Types.push_back(
New);
4677 llvm::FoldingSetNodeID ID;
4680 void *InsertPos =
nullptr;
4682 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4687 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4690 if (CanonVecTy == VecType) {
4695 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4696 assert(!CanonCheck &&
4697 "Dependent-sized vector_size canonical type broken");
4699 DependentVectorTypes.InsertNode(
New, InsertPos);
4708 Types.push_back(
New);
4715 unsigned NumElts)
const {
4722 llvm::FoldingSetNodeID ID;
4725 void *InsertPos =
nullptr;
4726 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4736 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4737 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4741 VectorTypes.InsertNode(
New, InsertPos);
4742 Types.push_back(
New);
4750 llvm::FoldingSetNodeID ID;
4754 void *InsertPos =
nullptr;
4756 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4766 if (CanonVecTy == vecType) {
4771 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4772 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4774 DependentSizedExtVectorTypes.InsertNode(
New, InsertPos);
4783 Types.push_back(
New);
4788 unsigned NumColumns)
const {
4789 llvm::FoldingSetNodeID ID;
4791 Type::ConstantMatrix);
4794 "need a valid element type");
4795 assert(NumRows > 0 && NumRows <= LangOpts.MaxMatrixDimension &&
4796 NumColumns > 0 && NumColumns <= LangOpts.MaxMatrixDimension &&
4797 "need valid matrix dimensions");
4798 void *InsertPos =
nullptr;
4808 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4814 MatrixTypes.InsertNode(
New, InsertPos);
4815 Types.push_back(
New);
4824 llvm::FoldingSetNodeID ID;
4828 void *InsertPos =
nullptr;
4830 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4835 ColumnExpr, AttrLoc);
4838 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4839 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4841 DependentSizedMatrixTypes.InsertNode(Canon, InsertPos);
4842 Types.push_back(Canon);
4855 ColumnExpr, AttrLoc);
4856 Types.push_back(
New);
4861 Expr *AddrSpaceExpr,
4867 void *insertPos =
nullptr;
4868 llvm::FoldingSetNodeID ID;
4873 DependentAddressSpaceTypes.FindNodeOrInsertPos(ID, insertPos);
4879 DependentAddressSpaceTypes.InsertNode(canonTy, insertPos);
4880 Types.push_back(canonTy);
4883 if (canonPointeeType == PointeeType &&
4889 AddrSpaceExpr, AttrLoc);
4890 Types.push_back(sugaredType);
4896 return T.isCanonical() &&
4914 llvm::FoldingSetNodeID ID;
4917 void *InsertPos =
nullptr;
4919 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
4929 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
4930 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4935 Types.push_back(
New);
4936 FunctionNoProtoTypes.InsertNode(
New, InsertPos);
4952 return CanResultType;
4959 if (!NoexceptInType)
4976 bool AnyPackExpansions =
false;
4980 if (ET->
getAs<PackExpansionType>())
4981 AnyPackExpansions =
true;
4983 return AnyPackExpansions;
4989QualType ASTContext::getFunctionTypeInternal(
4990 QualType ResultTy, ArrayRef<QualType> ArgArray,
4991 const FunctionProtoType::ExtProtoInfo &EPI,
bool OnlyWantCanonical)
const {
4992 size_t NumArgs = ArgArray.size();
4996 llvm::FoldingSetNodeID
ID;
5001 bool Unique =
false;
5003 void *InsertPos =
nullptr;
5004 if (FunctionProtoType *FPT =
5005 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos)) {
5006 QualType Existing = QualType(FPT, 0);
5025 bool IsCanonicalExceptionSpec =
5029 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
5031 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
5032 if (!ArgArray[i].isCanonicalAsParam())
5033 isCanonical =
false;
5035 if (OnlyWantCanonical)
5036 assert(isCanonical &&
5037 "given non-canonical parameters constructing canonical type");
5042 if (!isCanonical && Canonical.
isNull()) {
5043 SmallVector<QualType, 16> CanonicalArgs;
5044 CanonicalArgs.reserve(NumArgs);
5045 for (
unsigned i = 0; i != NumArgs; ++i)
5048 llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
5049 FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
5052 if (IsCanonicalExceptionSpec) {
5054 }
else if (NoexceptInType) {
5067 bool AnyPacks =
false;
5069 if (ET->
getAs<PackExpansionType>())
5090 llvm_unreachable(
"dependent noexcept is already canonical");
5093 CanonicalEPI.
ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
5099 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5102 FunctionProtoType *NewIP =
5103 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
5104 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5109 auto ESH = FunctionProtoType::getExceptionSpecSize(
5111 size_t Size = FunctionProtoType::totalSizeToAlloc<
5112 QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
5113 FunctionType::FunctionTypeExtraAttributeInfo,
5114 FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
5115 Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, Qualifiers,
5116 FunctionEffect, EffectConditionExpr>(
5120 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5125 auto *FTP = (FunctionProtoType *)
Allocate(Size,
alignof(FunctionProtoType));
5126 FunctionProtoType::ExtProtoInfo newEPI = EPI;
5127 new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
5128 Types.push_back(FTP);
5130 FunctionProtoTypes.InsertNode(FTP, InsertPos);
5132 AnyFunctionEffects =
true;
5133 return QualType(FTP, 0);
5136QualType ASTContext::getPipeType(QualType T,
bool ReadOnly)
const {
5137 llvm::FoldingSetNodeID
ID;
5140 void *InsertPos =
nullptr;
5141 if (PipeType *PT = PipeTypes.FindNodeOrInsertPos(ID, InsertPos))
5142 return QualType(PT, 0);
5151 PipeType *NewIP = PipeTypes.FindNodeOrInsertPos(ID, InsertPos);
5152 assert(!NewIP &&
"Shouldn't be in the map!");
5155 auto *
New =
new (*
this,
alignof(PipeType)) PipeType(T, Canonical, ReadOnly);
5156 Types.push_back(
New);
5157 PipeTypes.InsertNode(
New, InsertPos);
5158 return QualType(
New, 0);
5168 return getPipeType(T,
true);
5172 return getPipeType(T,
false);
5176 llvm::FoldingSetNodeID ID;
5179 void *InsertPos =
nullptr;
5180 if (
BitIntType *EIT = BitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5184 BitIntTypes.InsertNode(
New, InsertPos);
5185 Types.push_back(
New);
5190 Expr *NumBitsExpr)
const {
5192 llvm::FoldingSetNodeID ID;
5195 void *InsertPos =
nullptr;
5197 DependentBitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5202 DependentBitIntTypes.InsertNode(
New, InsertPos);
5204 Types.push_back(
New);
5212 if (
auto *Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5224 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5225 case Kind::SignedSizeT:
5227 case Kind::PtrdiffT:
5230 llvm_unreachable(
"unexpected kind");
5235 Types.push_back(
New);
5236 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5243 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5246 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5248 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5257 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5259 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5261 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5263 assert(TD->TypeForDecl);
5268 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5270 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5271 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5274 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5277 assert(
Decl->TypeForDecl);
5287 std::optional<bool> TypeMatchesDeclOrNone)
const {
5288 if (!TypeMatchesDeclOrNone) {
5289 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5290 assert(!DeclUnderlyingType.
isNull());
5291 if (UnderlyingType.
isNull())
5292 UnderlyingType = DeclUnderlyingType;
5294 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5295 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5299 assert(!UnderlyingType.
isNull());
5303 *TypeMatchesDeclOrNone) {
5304 if (
Decl->TypeForDecl)
5309 !*TypeMatchesDeclOrNone);
5311 Types.push_back(NewType);
5312 Decl->TypeForDecl = NewType;
5316 llvm::FoldingSetNodeID ID;
5318 *TypeMatchesDeclOrNone ?
QualType() : UnderlyingType);
5320 void *InsertPos =
nullptr;
5322 TypedefTypes.FindNodeOrInsertPos(ID, InsertPos))
5323 return QualType(Placeholder->getType(), 0);
5328 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5332 UnderlyingType, !*TypeMatchesDeclOrNone);
5333 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5335 TypedefTypes.InsertNode(Placeholder, InsertPos);
5336 Types.push_back(NewType);
5345 if (UnderlyingType.
isNull()) {
5353 llvm::FoldingSetNodeID ID;
5356 void *InsertPos =
nullptr;
5357 if (
const UsingType *T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5367 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5371 UsingTypes.InsertNode(T, InsertPos);
5377 const TagDecl *TD,
bool OwnsTag,
5379 const Type *CanonicalType,
5380 bool WithFoldingSetNode)
const {
5381 auto [TC, Size] = [&] {
5384 static_assert(
alignof(EnumType) ==
alignof(TagType));
5385 return std::make_tuple(Type::Enum,
sizeof(EnumType));
5386 case Decl::ClassTemplatePartialSpecialization:
5387 case Decl::ClassTemplateSpecialization:
5388 case Decl::CXXRecord:
5389 static_assert(
alignof(RecordType) ==
alignof(TagType));
5390 static_assert(
alignof(InjectedClassNameType) ==
alignof(TagType));
5392 return std::make_tuple(Type::InjectedClassName,
5393 sizeof(InjectedClassNameType));
5396 return std::make_tuple(Type::Record,
sizeof(RecordType));
5398 llvm_unreachable(
"unexpected decl kind");
5408 if (WithFoldingSetNode) {
5416 sizeof(TagTypeFoldingSetPlaceholder) +
5417 TagTypeFoldingSetPlaceholder::getOffset() + Size,
5418 std::max(
alignof(TagTypeFoldingSetPlaceholder),
alignof(TagType)));
5419 auto *T =
new (Mem) TagTypeFoldingSetPlaceholder();
5420 Mem = T->getTagType();
5422 Mem =
Allocate(Size,
alignof(TagType));
5425 auto *T = [&, TC = TC]() -> TagType * {
5429 auto *T =
new (Mem) EnumType(TC,
Keyword, Qualifier, TD, OwnsTag,
5430 IsInjected, CanonicalType);
5431 assert(
reinterpret_cast<void *
>(T) ==
5432 reinterpret_cast<void *
>(
static_cast<TagType *
>(T)) &&
5433 "TagType must be the first base of EnumType");
5436 case Type::Record: {
5438 auto *T =
new (Mem) RecordType(TC,
Keyword, Qualifier, TD, OwnsTag,
5439 IsInjected, CanonicalType);
5440 assert(
reinterpret_cast<void *
>(T) ==
5441 reinterpret_cast<void *
>(
static_cast<TagType *
>(T)) &&
5442 "TagType must be the first base of RecordType");
5445 case Type::InjectedClassName: {
5446 auto *T =
new (Mem) InjectedClassNameType(
Keyword, Qualifier, TD,
5447 IsInjected, CanonicalType);
5448 assert(
reinterpret_cast<void *
>(T) ==
5449 reinterpret_cast<void *
>(
static_cast<TagType *
>(T)) &&
5450 "TagType must be the first base of InjectedClassNameType");
5454 llvm_unreachable(
"unexpected type class");
5457 assert(T->getKeyword() ==
Keyword);
5458 assert(T->getQualifier() == Qualifier);
5459 assert(T->getDecl() == TD);
5460 assert(T->isInjected() == IsInjected);
5461 assert(T->isTagOwned() == OwnsTag);
5470 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5471 RD && RD->isInjectedClassName())
5478 if (TD->TypeForDecl)
5479 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5481 const Type *CanonicalType = getTagTypeInternal(
5484 false,
false,
nullptr,
5486 TD->TypeForDecl = CanonicalType;
5492 const TagDecl *TD,
bool OwnsTag)
const {
5495 bool IsInjected = TD != NonInjectedTD;
5502 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5503 if (
const Type *T = TD->TypeForDecl; T && !T->isCanonicalUnqualified())
5509 std::nullopt, NonInjectedTD,
5510 false, IsInjected, CanonicalType,
5512 TD->TypeForDecl = T;
5516 llvm::FoldingSetNodeID ID;
5517 TagTypeFoldingSetPlaceholder::Profile(ID,
Keyword, Qualifier, NonInjectedTD,
5518 OwnsTag, IsInjected);
5520 void *InsertPos =
nullptr;
5521 if (TagTypeFoldingSetPlaceholder *T =
5522 TagTypes.FindNodeOrInsertPos(ID, InsertPos))
5523 return QualType(T->getTagType(), 0);
5527 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5528 CanonicalType,
true);
5529 TagTypes.InsertNode(TagTypeFoldingSetPlaceholder::fromTagType(T), InsertPos);
5534 unsigned NumPositiveBits,
5537 unsigned IntWidth = Target->getIntWidth();
5538 unsigned CharWidth = Target->getCharWidth();
5539 unsigned ShortWidth = Target->getShortWidth();
5540 bool EnumTooLarge =
false;
5542 if (NumNegativeBits) {
5546 if (IsPacked && NumNegativeBits <= CharWidth &&
5547 NumPositiveBits < CharWidth) {
5549 BestWidth = CharWidth;
5550 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5551 NumPositiveBits < ShortWidth) {
5553 BestWidth = ShortWidth;
5554 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5556 BestWidth = IntWidth;
5558 BestWidth = Target->getLongWidth();
5560 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5563 BestWidth = Target->getLongLongWidth();
5565 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5566 EnumTooLarge =
true;
5570 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5575 if (IsPacked && NumPositiveBits <= CharWidth) {
5577 BestPromotionType =
IntTy;
5578 BestWidth = CharWidth;
5579 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5581 BestPromotionType =
IntTy;
5582 BestWidth = ShortWidth;
5583 }
else if (NumPositiveBits <= IntWidth) {
5585 BestWidth = IntWidth;
5586 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5589 }
else if (NumPositiveBits <= (BestWidth = Target->getLongWidth())) {
5591 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5595 BestWidth = Target->getLongLongWidth();
5596 if (NumPositiveBits > BestWidth) {
5601 EnumTooLarge =
true;
5604 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5609 return EnumTooLarge;
5613 assert((T->isIntegralType(*
this) || T->isEnumeralType()) &&
5614 "Integral type required!");
5617 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5618 if (T->isSignedIntegerOrEnumerationType())
5620 return Value.getActiveBits() <= BitWidth;
5622 return Value.getSignificantBits() <= BitWidth;
5628 const Type *CanonicalType)
const {
5630 UnresolvedUsingType::totalSizeToAlloc<
5632 !!InsertPos, !!Qualifier),
5636 auto *Placeholder =
new (T->getFoldingSetPlaceholder())
5638 TypedefTypes.InsertNode(Placeholder, InsertPos);
5648 return D->TypeForDecl->getCanonicalTypeUnqualified();
5650 const Type *CanonicalType = getUnresolvedUsingTypeInternal(
5654 D->TypeForDecl = CanonicalType;
5663 if (
const Type *T = D->TypeForDecl; T && !T->isCanonicalUnqualified())
5670 nullptr, CanonicalType);
5675 llvm::FoldingSetNodeID ID;
5678 void *InsertPos =
nullptr;
5680 UnresolvedUsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5681 return QualType(Placeholder->getType(), 0);
5685 const Type *T = getUnresolvedUsingTypeInternal(
Keyword, Qualifier, D,
5686 InsertPos, CanonicalType);
5694 llvm::FoldingSetNodeID id;
5695 AttributedType::Profile(
id, attrKind, modifiedType, equivalentType,
attr);
5697 void *insertPos =
nullptr;
5698 AttributedType *
type = AttributedTypes.FindNodeOrInsertPos(
id, insertPos);
5701 assert(!
attr ||
attr->getKind() == attrKind);
5704 type =
new (*
this,
alignof(AttributedType))
5705 AttributedType(canon, attrKind,
attr, modifiedType, equivalentType);
5707 Types.push_back(
type);
5708 AttributedTypes.InsertNode(
type, insertPos);
5721 switch (nullability) {
5737 llvm_unreachable(
"Unknown nullability kind");
5742 llvm::FoldingSetNodeID ID;
5743 BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
5745 void *InsertPos =
nullptr;
5746 BTFTagAttributedType *Ty =
5747 BTFTagAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
5752 Ty =
new (*
this,
alignof(BTFTagAttributedType))
5753 BTFTagAttributedType(Canon, Wrapped, BTFAttr);
5755 Types.push_back(Ty);
5756 BTFTagAttributedTypes.InsertNode(Ty, InsertPos);
5764 StringRef IdentName = II->
getName();
5765 OverflowBehaviorType::OverflowBehaviorKind Kind;
5766 if (IdentName ==
"wrap") {
5767 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
5768 }
else if (IdentName ==
"trap") {
5769 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
5778 OverflowBehaviorType::OverflowBehaviorKind Kind,
5781 "Cannot have underlying types that are themselves OBTs");
5782 llvm::FoldingSetNodeID ID;
5783 OverflowBehaviorType::Profile(ID, Underlying, Kind);
5784 void *InsertPos =
nullptr;
5786 if (OverflowBehaviorType *OBT =
5787 OverflowBehaviorTypes.FindNodeOrInsertPos(ID, InsertPos)) {
5796 assert(!OverflowBehaviorTypes.FindNodeOrInsertPos(ID, InsertPos) &&
5797 "Shouldn't be in the map");
5800 OverflowBehaviorType *Ty =
new (*
this,
alignof(OverflowBehaviorType))
5801 OverflowBehaviorType(Canonical, Underlying, Kind);
5803 Types.push_back(Ty);
5804 OverflowBehaviorTypes.InsertNode(Ty, InsertPos);
5810 const HLSLAttributedResourceType::Attributes &Attrs) {
5812 llvm::FoldingSetNodeID ID;
5813 HLSLAttributedResourceType::Profile(ID, Wrapped, Contained, Attrs);
5815 void *InsertPos =
nullptr;
5816 HLSLAttributedResourceType *Ty =
5817 HLSLAttributedResourceTypes.FindNodeOrInsertPos(ID, InsertPos);
5821 Ty =
new (*
this,
alignof(HLSLAttributedResourceType))
5822 HLSLAttributedResourceType(Wrapped, Contained, Attrs);
5824 Types.push_back(Ty);
5825 HLSLAttributedResourceTypes.InsertNode(Ty, InsertPos);
5833 llvm::FoldingSetNodeID ID;
5834 HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
5836 void *InsertPos =
nullptr;
5837 HLSLInlineSpirvType *Ty =
5838 HLSLInlineSpirvTypes.FindNodeOrInsertPos(ID, InsertPos);
5843 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5844 alignof(HLSLInlineSpirvType));
5846 Ty =
new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
5848 Types.push_back(Ty);
5849 HLSLInlineSpirvTypes.InsertNode(Ty, InsertPos);
5856 Decl *AssociatedDecl,
5860 llvm::FoldingSetNodeID ID;
5861 SubstTemplateTypeParmType::Profile(ID, Replacement, AssociatedDecl, Index,
5863 void *InsertPos =
nullptr;
5864 SubstTemplateTypeParmType *SubstParm =
5865 SubstTemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5868 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5869 !Replacement.isCanonical()),
5870 alignof(SubstTemplateTypeParmType));
5871 SubstParm =
new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
5872 Index, PackIndex, Final);
5873 Types.push_back(SubstParm);
5874 SubstTemplateTypeParmTypes.InsertNode(SubstParm, InsertPos);
5882 unsigned Index,
bool Final,
5889 llvm::FoldingSetNodeID ID;
5890 SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
5892 void *InsertPos =
nullptr;
5893 if (SubstTemplateTypeParmPackType *SubstParm =
5894 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos))
5904 [[maybe_unused]]
const auto *Nothing =
5905 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos);
5910 auto *SubstParm =
new (*
this,
alignof(SubstTemplateTypeParmPackType))
5911 SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
5913 Types.push_back(SubstParm);
5914 SubstTemplateTypeParmPackTypes.InsertNode(SubstParm, InsertPos);
5922 return P.getKind() == TemplateArgument::Type;
5924 "Pack contains a non-type");
5926 llvm::FoldingSetNodeID ID;
5927 SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
5929 void *InsertPos =
nullptr;
5931 SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos))
5940 [[maybe_unused]]
const auto *Nothing =
5941 SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos);
5945 auto *PackType =
new (*
this,
alignof(SubstBuiltinTemplatePackType))
5946 SubstBuiltinTemplatePackType(Canon, ArgPack);
5947 Types.push_back(PackType);
5948 SubstBuiltinTemplatePackTypes.InsertNode(PackType, InsertPos);
5958 llvm::FoldingSetNodeID ID;
5959 TemplateTypeParmType::Profile(ID, Depth, Index, ParameterPack, TTPDecl);
5960 void *InsertPos =
nullptr;
5961 TemplateTypeParmType *TypeParm
5962 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5969 TypeParm =
new (*
this,
alignof(TemplateTypeParmType))
5970 TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
5972 TemplateTypeParmType *TypeCheck
5973 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5974 assert(!TypeCheck &&
"Template type parameter canonical type broken");
5977 TypeParm =
new (*
this,
alignof(TemplateTypeParmType)) TemplateTypeParmType(
5978 Depth, Index, ParameterPack,
nullptr,
QualType());
5980 Types.push_back(TypeParm);
5981 TemplateTypeParmTypes.InsertNode(TypeParm, InsertPos);
6007 llvm_unreachable(
"unexpected keyword kind");
6021 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
6031 SpecifiedArgVec.reserve(SpecifiedArgs.size());
6033 SpecifiedArgVec.push_back(Arg.getArgument());
6036 CanonicalArgs, Underlying);
6039[[maybe_unused]]
static bool
6042 if (Arg.isPackExpansion())
6053 Template.getAsDependentTemplateName()));
6055 for (
const auto &Arg : Args)
6059 llvm::FoldingSetNodeID ID;
6062 void *InsertPos =
nullptr;
6063 if (
auto *T = TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
6066 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6068 alignof(TemplateSpecializationType));
6072 assert(Spec->isDependentType() &&
6073 "canonical template specialization must be dependent");
6074 Types.push_back(Spec);
6075 TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
6083 const auto *TD =
Template.getAsTemplateDecl(
true);
6084 bool IsTypeAlias = TD && TD->isTypeAlias();
6085 if (Underlying.
isNull()) {
6092 bool NonCanonical =
Template != CanonTemplate ||
Keyword != CanonKeyword;
6094 if (CanonicalArgs.empty()) {
6097 CanonicalArgs = CanonArgsVec;
6099 NonCanonical |= !llvm::equal(
6100 SpecifiedArgs, CanonicalArgs,
6109 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
6111 "Caller must compute aliased type");
6112 IsTypeAlias =
false;
6115 CanonKeyword, CanonTemplate, CanonicalArgs);
6119 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6121 (IsTypeAlias ?
sizeof(
QualType) : 0),
6122 alignof(TemplateSpecializationType));
6123 auto *Spec =
new (Mem) TemplateSpecializationType(
6125 Types.push_back(Spec);
6131 llvm::FoldingSetNodeID ID;
6134 void *InsertPos =
nullptr;
6135 ParenType *T = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6142 ParenType *CheckT = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6143 assert(!CheckT &&
"Paren canonical type broken");
6149 ParenTypes.InsertNode(T, InsertPos);
6162 Types.push_back(newType);
6169 llvm::FoldingSetNodeID ID;
6170 DependentNameType::Profile(ID,
Keyword, NNS, Name);
6172 void *InsertPos =
nullptr;
6173 if (DependentNameType *T =
6174 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos))
6182 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6184 [[maybe_unused]] DependentNameType *T =
6185 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos);
6186 assert(!T &&
"broken canonicalization");
6190 DependentNameType *T =
new (*
this,
alignof(DependentNameType))
6191 DependentNameType(
Keyword, NNS, Name, Canon);
6193 DependentNameTypes.InsertNode(T, InsertPos);
6199 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6201 if (TTP->isParameterPack())
6205 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6207 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6213 if (T->isRecordType()) {
6222 Expr *E =
new (*this)
6224 T,
VK, NTTP->getLocation());
6226 if (NTTP->isParameterPack())
6232 std::nullopt,
false,
6234 if (TTP->isParameterPack())
6240 if (Param->isTemplateParameterPack())
6249 bool ExpectPackInType)
const {
6251 "Pack expansions must expand one or more parameter packs");
6253 llvm::FoldingSetNodeID ID;
6254 PackExpansionType::Profile(ID, Pattern, NumExpansions);
6256 void *InsertPos =
nullptr;
6257 PackExpansionType *T = PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
6268 PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
6271 T =
new (*
this,
alignof(PackExpansionType))
6272 PackExpansionType(Pattern, Canon, NumExpansions);
6274 PackExpansionTypes.InsertNode(T, InsertPos);
6286 if (Protocols.empty())
return true;
6291 for (
unsigned i = 1; i != Protocols.size(); ++i)
6301 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6305 P = P->getCanonicalDecl();
6308 auto ProtocolsEnd = llvm::unique(Protocols);
6309 Protocols.erase(ProtocolsEnd, Protocols.end());
6314 unsigned NumProtocols)
const {
6323 bool isKindOf)
const {
6326 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6331 llvm::FoldingSetNodeID ID;
6332 ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
6333 void *InsertPos =
nullptr;
6334 if (
ObjCObjectType *QT = ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos))
6341 if (effectiveTypeArgs.empty()) {
6343 effectiveTypeArgs = baseObject->getTypeArgs();
6350 bool typeArgsAreCanonical = llvm::all_of(
6353 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6357 if (!typeArgsAreCanonical) {
6358 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6359 for (
auto typeArg : effectiveTypeArgs)
6361 canonTypeArgs = canonTypeArgsVec;
6363 canonTypeArgs = effectiveTypeArgs;
6368 if (!protocolsSorted) {
6369 canonProtocolsVec.append(protocols.begin(), protocols.end());
6371 canonProtocols = canonProtocolsVec;
6373 canonProtocols = protocols;
6377 canonProtocols, isKindOf);
6380 ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos);
6383 unsigned size =
sizeof(ObjCObjectTypeImpl);
6384 size += typeArgs.size() *
sizeof(
QualType);
6386 void *mem =
Allocate(size,
alignof(ObjCObjectTypeImpl));
6388 new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
6392 ObjCObjectTypes.InsertNode(T, InsertPos);
6402 bool allowOnPointerType)
const {
6405 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6410 if (allowOnPointerType) {
6411 if (
const auto *objPtr =
6412 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6416 protocolsVec.append(objT->qual_begin(),
6418 protocolsVec.append(protocols.begin(), protocols.end());
6421 objT->getBaseType(),
6422 objT->getTypeArgsAsWritten(),
6424 objT->isKindOfTypeAsWritten());
6430 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6435 objT->getTypeArgsAsWritten(),
6437 objT->isKindOfTypeAsWritten());
6441 if (
type->isObjCObjectType()) {
6451 if (
type->isObjCIdType()) {
6454 objPtr->isKindOfType());
6459 if (
type->isObjCClassType()) {
6462 objPtr->isKindOfType());
6474 llvm::FoldingSetNodeID ID;
6475 ObjCTypeParamType::Profile(ID,
Decl,
Decl->getUnderlyingType(), protocols);
6476 void *InsertPos =
nullptr;
6477 if (ObjCTypeParamType *TypeParam =
6478 ObjCTypeParamTypes.FindNodeOrInsertPos(ID, InsertPos))
6483 if (!protocols.empty()) {
6487 Canonical, protocols, hasError,
true ));
6488 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6491 unsigned size =
sizeof(ObjCTypeParamType);
6493 void *mem =
Allocate(size,
alignof(ObjCTypeParamType));
6494 auto *newType =
new (mem) ObjCTypeParamType(
Decl, Canonical, protocols);
6496 Types.push_back(newType);
6497 ObjCTypeParamTypes.InsertNode(newType, InsertPos);
6507 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6522 for (
auto *Proto : OPT->quals()) {
6545 if (InheritedProtocols.empty())
6549 bool Conforms =
false;
6550 for (
auto *Proto : OPT->quals()) {
6552 for (
auto *PI : InheritedProtocols) {
6564 for (
auto *PI : InheritedProtocols) {
6566 bool Adopts =
false;
6567 for (
auto *Proto : OPT->quals()) {
6581 llvm::FoldingSetNodeID ID;
6584 void *InsertPos =
nullptr;
6586 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
6595 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
6604 Types.push_back(QType);
6605 ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
6613 if (
Decl->TypeForDecl)
6617 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6618 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6619 return QualType(PrevDecl->TypeForDecl, 0);
6628 Decl->TypeForDecl = T;
6641 llvm::FoldingSetNodeID ID;
6645 void *InsertPos =
nullptr;
6647 DependentTypeOfExprTypes.FindNodeOrInsertPos(ID, InsertPos);
6657 DependentTypeOfExprTypes.InsertNode(Canon, InsertPos);
6665 Types.push_back(toe);
6676 auto *tot =
new (*
this,
alignof(TypeOfType))
6677 TypeOfType(*
this, tofType, Canonical, Kind);
6678 Types.push_back(tot);
6702 llvm_unreachable(
"Unknown value kind");
6717 }
else if (!UnderlyingType.
isNull()) {
6720 llvm::FoldingSetNodeID ID;
6721 DependentDecltypeType::Profile(ID, *
this, E);
6723 void *InsertPos =
nullptr;
6724 if (DependentDecltypeType *Canon =
6725 DependentDecltypeTypes.FindNodeOrInsertPos(ID, InsertPos))
6730 new (*
this,
alignof(DependentDecltypeType)) DependentDecltypeType(E);
6731 DependentDecltypeTypes.InsertNode(DT, InsertPos);
6732 Types.push_back(DT);
6735 auto *DT =
new (*
this,
alignof(DecltypeType))
6736 DecltypeType(E, UnderlyingType, CanonType);
6737 Types.push_back(DT);
6742 bool FullySubstituted,
6746 if (FullySubstituted && Index) {
6749 llvm::FoldingSetNodeID ID;
6750 PackIndexingType::Profile(ID, *
this, Pattern.
getCanonicalType(), IndexExpr,
6751 FullySubstituted, Expansions);
6752 void *InsertPos =
nullptr;
6753 PackIndexingType *Canon =
6754 DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos);
6757 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6761 IndexExpr, FullySubstituted, Expansions);
6762 DependentPackIndexingTypes.InsertNode(Canon, InsertPos);
6768 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6770 auto *T =
new (Mem) PackIndexingType(Canonical, Pattern, IndexExpr,
6771 FullySubstituted, Expansions);
6780 UnaryTransformType::UTTKind Kind)
const {
6782 llvm::FoldingSetNodeID ID;
6783 UnaryTransformType::Profile(ID, BaseType, UnderlyingType, Kind);
6785 void *InsertPos =
nullptr;
6786 if (UnaryTransformType *UT =
6787 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos))
6791 if (!BaseType->isDependentType()) {
6794 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6797 BaseType != CanonBase) {
6802 [[maybe_unused]] UnaryTransformType *UT =
6803 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos);
6804 assert(!UT &&
"broken canonicalization");
6808 auto *UT =
new (*
this,
alignof(UnaryTransformType))
6809 UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
6810 UnaryTransformTypes.InsertNode(UT, InsertPos);
6811 Types.push_back(UT);
6824 !TypeConstraintConcept) {
6825 assert(DeducedAsType.
isNull() &&
"");
6826 assert(TypeConstraintArgs.empty() &&
"");
6831 llvm::FoldingSetNodeID ID;
6832 AutoType::Profile(ID, *
this, DK, DeducedAsType,
Keyword,
6833 TypeConstraintConcept, TypeConstraintArgs);
6834 if (
auto const AT_iter = AutoTypes.find(ID); AT_iter != AutoTypes.end())
6835 return QualType(AT_iter->getSecond(), 0);
6838 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6840 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6841 if (TypeConstraintConcept) {
6842 bool AnyNonCanonArgs =
false;
6843 auto *CanonicalConcept =
6846 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6847 if (TypeConstraintConcept != CanonicalConcept || AnyNonCanonArgs)
6849 CanonicalConceptArgs);
6853 void *Mem =
Allocate(
sizeof(AutoType) +
6856 auto *AT =
new (Mem) AutoType(DK, DeducedAsType,
Keyword,
6857 TypeConstraintConcept, TypeConstraintArgs);
6859 llvm::FoldingSetNodeID InsertedID;
6860 AT->Profile(InsertedID, *
this);
6861 assert(InsertedID == ID &&
"ID does not match");
6863 Types.push_back(AT);
6864 AutoTypes.try_emplace(ID, AT);
6872 if (
auto *AT = CanonT->
getAs<AutoType>()) {
6873 if (!AT->isConstrained())
6897 "unexpected DeducedAsPack for DeducedTemplateSpecializationType");
6900 void *InsertPos =
nullptr;
6901 llvm::FoldingSetNodeID ID;
6902 DeducedTemplateSpecializationType::Profile(ID, DK, DeducedAsType,
Keyword,
6904 if (DeducedTemplateSpecializationType *DTST =
6905 DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
6909 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6911 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6920 [[maybe_unused]] DeducedTemplateSpecializationType *DTST =
6921 DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos);
6922 assert(!DTST &&
"broken canonicalization");
6926 auto *DTST =
new (*
this,
alignof(DeducedTemplateSpecializationType))
6927 DeducedTemplateSpecializationType(DK, DeducedAsType,
Keyword,
Template);
6930 llvm::FoldingSetNodeID TempID;
6931 DTST->Profile(TempID);
6932 assert(ID == TempID &&
"ID does not match");
6934 Types.push_back(DTST);
6935 DeducedTemplateSpecializationTypes.InsertNode(DTST, InsertPos);
6944 llvm::FoldingSetNodeID ID;
6947 void *InsertPos =
nullptr;
6948 if (
AtomicType *AT = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos))
6954 if (!T.isCanonical()) {
6958 AtomicType *NewIP = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos);
6959 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
6962 Types.push_back(
New);
6963 AtomicTypes.InsertNode(
New, InsertPos);
6995 return getFromTargetType(Target->getSizeType());
7014 return getFromTargetType(Target->getUnsignedPtrDiffType(
LangAS::Default));
7019 return getFromTargetType(Target->getIntMaxType());
7024 return getFromTargetType(Target->getUIntMaxType());
7042 return getFromTargetType(Target->getIntPtrType());
7052 return getFromTargetType(Target->getProcessIDType());
7064 const Type *Ty = T.getTypePtr();
7092 quals = splitType.
Quals;
7097 QualType elementType = AT->getElementType();
7102 if (elementType == unqualElementType) {
7103 assert(quals.
empty());
7104 quals = splitType.
Quals;
7112 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7114 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7117 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7121 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7123 VAT->getSizeModifier(),
7124 VAT->getIndexTypeCVRQualifiers());
7129 DSAT->getSizeModifier(), 0);
7139 bool AllowPiMismatch)
const {
7154 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7155 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7156 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7169 T1 = AT1->getElementType();
7170 T2 = AT2->getElementType();
7190 bool AllowPiMismatch)
const {
7195 if (T1PtrType && T2PtrType) {
7203 T1MPType && T2MPType) {
7206 if (T1MPType->getQualifier() != T2MPType->getQualifier())
7218 if (T1OPType && T2OPType) {
7250 if (Quals1 != Quals2)
7320 llvm_unreachable(
"bad template name kind!");
7326 if (!TP->hasDefaultArgument())
7328 return &TP->getDefaultArgument().getArgument();
7331 case NamedDecl::TemplateTypeParm:
7333 case NamedDecl::NonTypeTemplateParm:
7335 case NamedDecl::TemplateTemplateParm:
7338 llvm_unreachable(
"Unexpected template parameter kind");
7343 bool IgnoreDeduced)
const {
7344 while (std::optional<TemplateName> UnderlyingOrNone =
7346 Name = *UnderlyingOrNone;
7351 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7363 llvm_unreachable(
"cannot canonicalize overloaded template");
7367 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7386 assert(IgnoreDeduced ==
false);
7393 bool NonCanonical = CanonUnderlying != Underlying;
7399 assert(CanonArgs.size() <= Params.size());
7405 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7414 if (I ==
int(CanonArgs.size() - 1))
7415 CanonArgs.pop_back();
7416 NonCanonical =
true;
7426 llvm_unreachable(
"always sugar node");
7429 llvm_unreachable(
"bad template name!");
7434 bool IgnoreDeduced)
const {
7455 llvm::FoldingSetNodeID XCEID, YCEID;
7456 XCE->
Profile(XCEID, *
this,
true,
true);
7457 YCE->
Profile(YCEID, *
this,
true,
true);
7458 return XCEID == YCEID;
7507 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7509 if (TX->isParameterPack() != TY->isParameterPack())
7511 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7514 TY->getTypeConstraint());
7517 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7519 return TX->isParameterPack() == TY->isParameterPack() &&
7520 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7522 TY->getPlaceholderTypeConstraint());
7527 return TX->isParameterPack() == TY->isParameterPack() &&
7529 TY->getTemplateParameters());
7534 if (
X->size() != Y->
size())
7537 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7551 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7553 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7556 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7557 TTPY->getDefaultArgument().getArgument().getAsType());
7560 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7562 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7565 Expr *DefaultArgumentX =
7566 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7567 Expr *DefaultArgumentY =
7568 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7569 llvm::FoldingSetNodeID XID, YID;
7570 DefaultArgumentX->
Profile(XID, *
this,
true);
7571 DefaultArgumentY->
Profile(YID, *
this,
true);
7578 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7593 auto Kind =
X.getKind();
7601 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7604 NamespaceY->getNamespace()))
7609 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7610 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7619 llvm_unreachable(
"unhandled qualifier kind");
7625 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7627 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7639 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7643 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7644 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7645 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7648 if (!Cand1A || !Cand2A)
7654 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7655 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7659 if (Cand1ID != Cand2ID)
7693 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7694 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7696 TypedefY->getUnderlyingType());
7713 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7715 return (TagX->getTagKind() == TagY->getTagKind()) ||
7727 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7729 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7731 if (CtorX->getInheritedConstructor() &&
7732 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7733 CtorY->getInheritedConstructor().getConstructor()))
7737 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7742 if (FuncX->isMultiVersion()) {
7743 const auto *TAX = FuncX->getAttr<TargetAttr>();
7744 const auto *TAY = FuncY->getAttr<TargetAttr>();
7745 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7747 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7753 if ((FuncX->isMemberLikeConstrainedFriend() ||
7754 FuncY->isMemberLikeConstrainedFriend()) &&
7755 !FuncX->getLexicalDeclContext()->Equals(
7756 FuncY->getLexicalDeclContext())) {
7761 FuncY->getTrailingRequiresClause()))
7769 FD = FD->getCanonicalDecl();
7770 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7773 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7788 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7793 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7795 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7798 if (VarX->getType().isNull() || VarY->getType().isNull())
7801 if (
hasSameType(VarX->getType(), VarY->getType()))
7811 if (!VarXTy || !VarYTy)
7820 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7822 return NamespaceX->isInline() == NamespaceY->isInline();
7827 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7831 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7834 ConceptY->getConstraintExpr()))
7839 TemplateY->getTemplatedDecl()) &&
7841 TemplateY->getTemplateParameters());
7845 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7848 return hasSameType(FDX->getType(), FDY->getType());
7852 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7854 return IFDX->getAnonField()->getCanonicalDecl() ==
7855 IFDY->getAnonField()->getCanonicalDecl();
7864 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7871 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7874 UX->hasTypename() == UY->hasTypename() &&
7875 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7877 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7880 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7882 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7890 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
7892 UX->getInstantiatedFromUsingDecl(),
7897 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
7899 return NAX->getNamespace()->Equals(NAY->getNamespace());
7947 bool AnyNonCanonArgs =
false;
7950 if (!AnyNonCanonArgs)
7960 llvm_unreachable(
"Unhandled template argument kind");
7970 llvm_unreachable(
"Comparing NULL template argument");
7995 llvm::FoldingSetNodeID ID1, ID2;
8005 return isSameTemplateArgument(Arg1, Arg2);
8009 llvm_unreachable(
"Unhandled template argument kind");
8014 if (!T.hasLocalQualifiers()) {
8016 if (
const auto *AT = dyn_cast<ArrayType>(T))
8036 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
8037 if (!ATy || qs.
empty())
8044 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
8047 CAT->getSizeModifier(),
8048 CAT->getIndexTypeCVRQualifiers()));
8049 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
8051 IAT->getSizeModifier(),
8052 IAT->getIndexTypeCVRQualifiers()));
8054 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
8056 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
8057 DSAT->getIndexTypeCVRQualifiers()));
8062 VAT->getIndexTypeCVRQualifiers()));
8070 if (T->isArrayType() || T->isFunctionType())
8078 return T.getUnqualifiedType();
8089 if (T->isArrayType() || T->isFunctionType())
8091 return T.getUnqualifiedType();
8106 assert(PrettyArrayType &&
"Not an array type!");
8143 uint64_t ElementCount = 1;
8146 CA = dyn_cast_or_null<ConstantArrayType>(
8149 return ElementCount;
8157 uint64_t ElementCount = 1;
8161 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8164 return ElementCount;
8174 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8176 case BuiltinType::Half:
return HalfRank;
8177 case BuiltinType::Float:
return FloatRank;
8210unsigned ASTContext::getIntegerRank(
const Type *T)
const {
8211 assert(T->isCanonicalUnqualified() &&
"T should be canonicalized");
8215 if (
const auto *EIT = dyn_cast<BitIntType>(T))
8216 return 0 + (EIT->getNumBits() << 3);
8218 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(T))
8219 return getIntegerRank(OBT->getUnderlyingType().getTypePtr());
8222 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8223 case BuiltinType::Bool:
8225 case BuiltinType::Char_S:
8226 case BuiltinType::Char_U:
8227 case BuiltinType::SChar:
8228 case BuiltinType::UChar:
8230 case BuiltinType::Short:
8231 case BuiltinType::UShort:
8233 case BuiltinType::Int:
8234 case BuiltinType::UInt:
8236 case BuiltinType::Long:
8237 case BuiltinType::ULong:
8239 case BuiltinType::LongLong:
8240 case BuiltinType::ULongLong:
8242 case BuiltinType::Int128:
8243 case BuiltinType::UInt128:
8248 case BuiltinType::Char8:
8250 case BuiltinType::Char16:
8251 return getIntegerRank(
8253 case BuiltinType::Char32:
8254 return getIntegerRank(
8256 case BuiltinType::WChar_S:
8257 case BuiltinType::WChar_U:
8258 return getIntegerRank(
8288 uint64_t BitWidth = Field->getBitWidthValue();
8314 if (BitWidth < IntSize)
8317 if (BitWidth == IntSize)
8332 assert(!Promotable.
isNull());
8335 return ED->getPromotionType();
8339 if (
const auto *OBT = Promotable->
getAs<OverflowBehaviorType>()) {
8352 if (BT->getKind() == BuiltinType::WChar_S ||
8353 BT->getKind() == BuiltinType::WChar_U ||
8354 BT->getKind() == BuiltinType::Char8 ||
8355 BT->getKind() == BuiltinType::Char16 ||
8356 BT->getKind() == BuiltinType::Char32) {
8357 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8361 for (
const auto &PT : PromoteTypes) {
8363 if (FromSize < ToSize ||
8364 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8367 llvm_unreachable(
"char type should fit into long long");
8374 uint64_t PromotableSize =
getIntWidth(Promotable);
8383 while (!T.isNull()) {
8385 return T.getObjCLifetime();
8386 if (T->isArrayType())
8388 else if (
const auto *PT = T->getAs<
PointerType>())
8389 T = PT->getPointeeType();
8391 T = RT->getPointeeType();
8416 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8418 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8421 if (LHSC == RHSC)
return 0;
8426 unsigned LHSRank = getIntegerRank(LHSC);
8427 unsigned RHSRank = getIntegerRank(RHSC);
8429 if (LHSUnsigned == RHSUnsigned) {
8430 if (LHSRank == RHSRank)
return 0;
8431 return LHSRank > RHSRank ? 1 : -1;
8437 if (LHSRank >= RHSRank)
8447 if (RHSRank >= LHSRank)
8457 if (CFConstantStringTypeDecl)
8458 return CFConstantStringTypeDecl;
8460 assert(!CFConstantStringTagDecl &&
8461 "tag and typedef should be initialized together");
8463 CFConstantStringTagDecl->startDefinition();
8501 if (
static_cast<unsigned>(CFRuntime) <
8504 Fields[Count++] = {
IntTy,
"flags" };
8506 Fields[Count++] = {
LongTy,
"length" };
8510 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()),
"_swift_rc" };
8514 Fields[Count++] = {
IntTy,
"_ptr" };
8520 for (
unsigned i = 0; i < Count; ++i) {
8524 Fields[i].Type,
nullptr,
8527 CFConstantStringTagDecl->addDecl(Field);
8530 CFConstantStringTagDecl->completeDefinition();
8534 CFConstantStringTypeDecl =
8537 return CFConstantStringTypeDecl;
8541 if (!CFConstantStringTagDecl)
8543 return CFConstantStringTagDecl;
8553 if (ObjCSuperType.isNull()) {
8558 return ObjCSuperType;
8564 CFConstantStringTagDecl = TT->castAsRecordDecl();
8568 if (BlockDescriptorType)
8581 static const char *
const FieldNames[] = {
8586 for (
size_t i = 0; i < 2; ++i) {
8589 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8597 BlockDescriptorType = RD;
8603 if (BlockDescriptorExtendedType)
8618 static const char *
const FieldNames[] = {
8625 for (
size_t i = 0; i < 4; ++i) {
8628 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8637 BlockDescriptorExtendedType = RD;
8642 const auto *BT = dyn_cast<BuiltinType>(T);
8651 switch (BT->getKind()) {
8652#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8653 case BuiltinType::Id: \
8655#include "clang/Basic/OpenCLImageTypes.def"
8657 case BuiltinType::OCLClkEvent:
8660 case BuiltinType::OCLEvent:
8663 case BuiltinType::OCLQueue:
8666 case BuiltinType::OCLReserveID:
8669 case BuiltinType::OCLSampler:
8688 if (!copyExpr && record->hasTrivialDestructor())
return false;
8719 llvm_unreachable(
"impossible");
8721 llvm_unreachable(
"fell out of lifetime switch!");
8729 bool &HasByrefExtendedLayout)
const {
8734 HasByrefExtendedLayout =
false;
8736 HasByrefExtendedLayout =
true;
8750 assert(Target &&
"Expected target to be initialized");
8751 const llvm::Triple &T = Target->getTriple();
8753 if (T.isOSWindows() && T.isArch64Bit())
8759 assert(Target &&
"Expected target to be initialized");
8760 const llvm::Triple &T = Target->getTriple();
8762 if (T.isOSWindows() && T.isArch64Bit())
8768 if (!ObjCInstanceTypeDecl)
8769 ObjCInstanceTypeDecl =
8771 return ObjCInstanceTypeDecl;
8777 if (
const auto *TT = dyn_cast<TypedefType>(T))
8779 return II->isStr(
"BOOL");
8787 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8796 else if (
type->isArrayType())
8815 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8822 !D->isInlineSpecified() && (D->isConstexpr() ||
First->isConstexpr()))
8853 for (
auto *PI :
Decl->parameters()) {
8858 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8867 ParmOffset = PtrSize;
8868 for (
auto *PVDecl :
Decl->parameters()) {
8869 QualType PType = PVDecl->getOriginalType();
8870 if (
const auto *AT =
8875 PType = PVDecl->getType();
8877 PType = PVDecl->getType();
8897 for (
auto *PI :
Decl->parameters()) {
8904 "getObjCEncodingForFunctionDecl - Incomplete param type");
8911 for (
auto *PVDecl :
Decl->parameters()) {
8912 QualType PType = PVDecl->getOriginalType();
8913 if (
const auto *AT =
8918 PType = PVDecl->getType();
8920 PType = PVDecl->getType();
8934 bool Extended)
const {
8938 ObjCEncOptions Options = ObjCEncOptions()
8939 .setExpandPointedToStructures()
8940 .setExpandStructures()
8941 .setIsOutermostType();
8943 Options.setEncodeBlockParameters().setEncodeClassNames();
8944 getObjCEncodingForTypeImpl(T, S, Options,
nullptr);
8950 bool Extended)
const {
8955 Decl->getReturnType(), S, Extended);
8964 E =
Decl->sel_param_end(); PI != E; ++PI) {
8971 "getObjCEncodingForMethodDecl - Incomplete param type");
8979 ParmOffset = 2 * PtrSize;
8981 E =
Decl->sel_param_end(); PI != E; ++PI) {
8984 if (
const auto *AT =
8993 PType, S, Extended);
9004 const Decl *Container)
const {
9007 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
9008 for (
auto *PID : CID->property_impls())
9009 if (PID->getPropertyDecl() == PD)
9013 for (
auto *PID : OID->property_impls())
9014 if (PID->getPropertyDecl() == PD)
9048 const Decl *Container)
const {
9050 bool Dynamic =
false;
9058 SynthesizePID = PropertyImpDecl;
9062 std::string S =
"T";
9107 if (SynthesizePID) {
9124 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9127 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9140 getObjCEncodingForTypeImpl(T, S,
9142 .setExpandPointedToStructures()
9143 .setExpandStructures()
9144 .setIsOutermostType(),
9145 Field, NotEncodedT);
9149 std::string& S)
const {
9153 getObjCEncodingForTypeImpl(T, S,
9155 .setExpandPointedToStructures()
9156 .setExpandStructures()
9157 .setIsOutermostType()
9158 .setEncodingProperty(),
9166 case BuiltinType::Void:
return 'v';
9167 case BuiltinType::Bool:
return 'B';
9168 case BuiltinType::Char8:
9169 case BuiltinType::Char_U:
9170 case BuiltinType::UChar:
return 'C';
9171 case BuiltinType::Char16:
9172 case BuiltinType::UShort:
return 'S';
9173 case BuiltinType::Char32:
9174 case BuiltinType::UInt:
return 'I';
9175 case BuiltinType::ULong:
9176 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9177 case BuiltinType::UInt128:
return 'T';
9178 case BuiltinType::ULongLong:
return 'Q';
9179 case BuiltinType::Char_S:
9180 case BuiltinType::SChar:
return 'c';
9181 case BuiltinType::Short:
return 's';
9182 case BuiltinType::WChar_S:
9183 case BuiltinType::WChar_U:
9184 case BuiltinType::Int:
return 'i';
9185 case BuiltinType::Long:
9186 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9187 case BuiltinType::LongLong:
return 'q';
9188 case BuiltinType::Int128:
return 't';
9189 case BuiltinType::Float:
return 'f';
9190 case BuiltinType::Double:
return 'd';
9191 case BuiltinType::LongDouble:
return 'D';
9192 case BuiltinType::NullPtr:
return '*';
9194 case BuiltinType::BFloat16:
9195 case BuiltinType::Float16:
9196 case BuiltinType::Float128:
9197 case BuiltinType::Ibm128:
9198 case BuiltinType::Half:
9199 case BuiltinType::ShortAccum:
9200 case BuiltinType::Accum:
9201 case BuiltinType::LongAccum:
9202 case BuiltinType::UShortAccum:
9203 case BuiltinType::UAccum:
9204 case BuiltinType::ULongAccum:
9205 case BuiltinType::ShortFract:
9206 case BuiltinType::Fract:
9207 case BuiltinType::LongFract:
9208 case BuiltinType::UShortFract:
9209 case BuiltinType::UFract:
9210 case BuiltinType::ULongFract:
9211 case BuiltinType::SatShortAccum:
9212 case BuiltinType::SatAccum:
9213 case BuiltinType::SatLongAccum:
9214 case BuiltinType::SatUShortAccum:
9215 case BuiltinType::SatUAccum:
9216 case BuiltinType::SatULongAccum:
9217 case BuiltinType::SatShortFract:
9218 case BuiltinType::SatFract:
9219 case BuiltinType::SatLongFract:
9220 case BuiltinType::SatUShortFract:
9221 case BuiltinType::SatUFract:
9222 case BuiltinType::SatULongFract:
9226#define SVE_TYPE(Name, Id, SingletonId) \
9227 case BuiltinType::Id:
9228#include "clang/Basic/AArch64ACLETypes.def"
9229#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9230#include "clang/Basic/RISCVVTypes.def"
9231#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9232#include "clang/Basic/WebAssemblyReferenceTypes.def"
9233#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9234#include "clang/Basic/AMDGPUTypes.def"
9237 Diags.
Report(diag::err_unsupported_objc_primitive_encoding)
9242 case BuiltinType::ObjCId:
9243 case BuiltinType::ObjCClass:
9244 case BuiltinType::ObjCSel:
9245 llvm_unreachable(
"@encoding ObjC primitive type");
9248#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9249 case BuiltinType::Id:
9250#include "clang/Basic/OpenCLImageTypes.def"
9251#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9252 case BuiltinType::Id:
9253#include "clang/Basic/OpenCLExtensionTypes.def"
9254 case BuiltinType::OCLEvent:
9255 case BuiltinType::OCLClkEvent:
9256 case BuiltinType::OCLQueue:
9257 case BuiltinType::OCLReserveID:
9258 case BuiltinType::OCLSampler:
9259 case BuiltinType::Dependent:
9260#define PPC_VECTOR_TYPE(Name, Id, Size) \
9261 case BuiltinType::Id:
9262#include "clang/Basic/PPCTypes.def"
9263#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9264#include "clang/Basic/HLSLIntangibleTypes.def"
9265#define BUILTIN_TYPE(KIND, ID)
9266#define PLACEHOLDER_TYPE(KIND, ID) \
9267 case BuiltinType::KIND:
9268#include "clang/AST/BuiltinTypes.def"
9269 llvm_unreachable(
"invalid builtin type for @encode");
9271 llvm_unreachable(
"invalid BuiltinType::Kind value");
9278 if (!
Enum->isFixed())
9288 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9308 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9316 S += llvm::utostr(Offset);
9331 bool VisitBasesAndFields) {
9332 T = T->getBaseElementTypeUnsafe();
9336 PT->getPointeeType().getTypePtr(),
false);
9338 auto *CXXRD = T->getAsCXXRecordDecl();
9346 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9349 for (
const auto &B : CXXRD->bases())
9354 for (
auto *FD : CXXRD->fields())
9363void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S,
9364 const ObjCEncOptions Options,
9365 const FieldDecl *FD,
9366 QualType *NotEncodedT)
const {
9368 switch (CT->getTypeClass()) {
9373 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9381 getObjCEncodingForTypeImpl(T->
castAs<ComplexType>()->getElementType(), S,
9388 getObjCEncodingForTypeImpl(T->
castAs<AtomicType>()->getValueType(), S,
9395 case Type::LValueReference:
9396 case Type::RValueReference: {
9399 const auto *PT = T->
castAs<PointerType>();
9400 if (PT->isObjCSelType()) {
9409 bool isReadOnly =
false;
9414 if (T->
getAs<TypedefType>()) {
9419 }
else if (Options.IsOutermostType()) {
9420 QualType P = PointeeTy;
9421 while (
auto PT = P->
getAs<PointerType>())
9432 if (StringRef(S).ends_with(
"nr"))
9433 S.replace(S.end()-2, S.end(),
"rn");
9443 }
else if (
const auto *RTy = PointeeTy->
getAsCanonical<RecordType>()) {
9444 const IdentifierInfo *II = RTy->getDecl()->getIdentifier();
9446 if (II == &
Idents.get(
"objc_class")) {
9451 if (II == &
Idents.get(
"objc_object")) {
9460 RTy, Options.ExpandPointedToStructures()))) {
9469 ObjCEncOptions NewOptions;
9470 if (Options.ExpandPointedToStructures())
9471 NewOptions.setExpandStructures();
9472 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9473 nullptr, NotEncodedT);
9477 case Type::ConstantArray:
9478 case Type::IncompleteArray:
9479 case Type::VariableArray: {
9486 getObjCEncodingForTypeImpl(
9487 AT->getElementType(), S,
9488 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9492 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9493 S += llvm::utostr(CAT->getZExtSize());
9497 "Unknown array type!");
9501 getObjCEncodingForTypeImpl(
9502 AT->getElementType(), S,
9503 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9510 case Type::FunctionNoProto:
9511 case Type::FunctionProto:
9515 case Type::Record: {
9517 S += RDecl->
isUnion() ?
'(' :
'{';
9521 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9522 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
9523 llvm::raw_string_ostream
OS(S);
9524 printTemplateArgumentList(OS, TemplateArgs.
asArray(),
9530 if (Options.ExpandStructures()) {
9533 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9535 for (
const auto *Field : RDecl->
fields()) {
9538 S +=
Field->getNameAsString();
9543 if (
Field->isBitField()) {
9544 getObjCEncodingForTypeImpl(
Field->getType(), S,
9545 ObjCEncOptions().setExpandStructures(),
9548 QualType qt =
Field->getType();
9550 getObjCEncodingForTypeImpl(
9552 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9558 S += RDecl->
isUnion() ?
')' :
'}';
9562 case Type::BlockPointer: {
9563 const auto *BT = T->
castAs<BlockPointerType>();
9565 if (Options.EncodeBlockParameters()) {
9566 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
9570 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9571 Options.forComponentType(), FD, NotEncodedT);
9575 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9576 for (
const auto &I : FPT->param_types())
9577 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9585 case Type::ObjCObject: {
9589 S +=
"{objc_object=}";
9593 S +=
"{objc_class=}";
9600 case Type::ObjCInterface: {
9603 ObjCInterfaceDecl *OI = T->
castAs<ObjCObjectType>()->getInterface();
9606 if (Options.ExpandStructures()) {
9608 SmallVector<const ObjCIvarDecl*, 32> Ivars;
9610 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9611 const FieldDecl *
Field = Ivars[i];
9612 if (
Field->isBitField())
9613 getObjCEncodingForTypeImpl(
Field->getType(), S,
9614 ObjCEncOptions().setExpandStructures(),
9617 getObjCEncodingForTypeImpl(
Field->getType(), S,
9618 ObjCEncOptions().setExpandStructures(), FD,
9626 case Type::ObjCObjectPointer: {
9627 const auto *OPT = T->
castAs<ObjCObjectPointerType>();
9628 if (OPT->isObjCIdType()) {
9633 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9641 if (OPT->isObjCQualifiedIdType()) {
9642 getObjCEncodingForTypeImpl(
9644 Options.keepingOnly(ObjCEncOptions()
9645 .setExpandPointedToStructures()
9646 .setExpandStructures()),
9648 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9652 for (
const auto *I : OPT->quals()) {
9654 S += I->getObjCRuntimeNameAsString();
9663 if (OPT->getInterfaceDecl() &&
9664 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9666 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9667 for (
const auto *I : OPT->quals()) {
9669 S += I->getObjCRuntimeNameAsString();
9679 case Type::MemberPointer:
9683 case Type::ExtVector:
9689 case Type::ConstantMatrix:
9702 case Type::DeducedTemplateSpecialization:
9705 case Type::HLSLAttributedResource:
9706 case Type::HLSLInlineSpirv:
9707 case Type::OverflowBehavior:
9708 llvm_unreachable(
"unexpected type");
9710 case Type::ArrayParameter:
9712#define ABSTRACT_TYPE(KIND, BASE)
9713#define TYPE(KIND, BASE)
9714#define DEPENDENT_TYPE(KIND, BASE) \
9716#define NON_CANONICAL_TYPE(KIND, BASE) \
9718#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9720#include "clang/AST/TypeNodes.inc"
9721 llvm_unreachable(
"@encode for dependent type!");
9723 llvm_unreachable(
"bad type kind!");
9726void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
9728 const FieldDecl *FD,
9730 QualType *NotEncodedT)
const {
9731 assert(RDecl &&
"Expected non-null RecordDecl");
9732 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9736 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9737 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9741 for (
const auto &BI : CXXRec->bases()) {
9742 if (!BI.isVirtual()) {
9747 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9748 std::make_pair(offs, base));
9753 for (FieldDecl *Field : RDecl->
fields()) {
9754 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9757 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9758 std::make_pair(offs, Field));
9761 if (CXXRec && includeVBases) {
9762 for (
const auto &BI : CXXRec->vbases()) {
9768 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9769 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9770 std::make_pair(offs, base));
9784 std::multimap<uint64_t, NamedDecl *>::iterator
9785 CurLayObj = FieldOrBaseOffsets.begin();
9787 if (CXXRec && CXXRec->isDynamicClass() &&
9788 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9791 std::string recname = CXXRec->getNameAsString();
9792 if (recname.empty()) recname =
"?";
9805 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9806 std::make_pair(offs,
nullptr));
9809 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9811 assert(CurOffs <= CurLayObj->first);
9812 if (CurOffs < CurLayObj->first) {
9813 uint64_t padding = CurLayObj->first - CurOffs;
9825 NamedDecl *dcl = CurLayObj->second;
9829 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9834 getObjCEncodingForStructureImpl(base, S, FD,
false,
9844 S += field->getNameAsString();
9848 if (field->isBitField()) {
9851 CurOffs += field->getBitWidthValue();
9854 QualType qt = field->getType();
9856 getObjCEncodingForTypeImpl(
9857 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9868 std::string& S)
const {
9901 if (!ObjCClassDecl) {
9906 return ObjCClassDecl;
9910 if (!ObjCProtocolClassDecl) {
9911 ObjCProtocolClassDecl
9920 return ObjCProtocolClassDecl;
9941 QualType T = Context->getPointerType(Context->CharTy);
9942 return Context->buildImplicitTypedef(T, Name);
9955 QualType T = Context->getPointerType(Context->VoidTy);
9956 return Context->buildImplicitTypedef(T,
"__builtin_va_list");
9963 if (Context->getLangOpts().CPlusPlus) {
9968 &Context->Idents.get(
"std"),
9976 const size_t NumFields = 5;
9978 const char *FieldNames[NumFields];
9981 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
9982 FieldNames[0] =
"__stack";
9985 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
9986 FieldNames[1] =
"__gr_top";
9989 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
9990 FieldNames[2] =
"__vr_top";
9993 FieldTypes[3] = Context->IntTy;
9994 FieldNames[3] =
"__gr_offs";
9997 FieldTypes[4] = Context->IntTy;
9998 FieldNames[4] =
"__vr_offs";
10001 for (
unsigned i = 0; i < NumFields; ++i) {
10006 &Context->Idents.get(FieldNames[i]),
10007 FieldTypes[i],
nullptr,
10019 return Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10026 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10029 const size_t NumFields = 5;
10031 const char *FieldNames[NumFields];
10034 FieldTypes[0] = Context->UnsignedCharTy;
10035 FieldNames[0] =
"gpr";
10038 FieldTypes[1] = Context->UnsignedCharTy;
10039 FieldNames[1] =
"fpr";
10042 FieldTypes[2] = Context->UnsignedShortTy;
10043 FieldNames[2] =
"reserved";
10046 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10047 FieldNames[3] =
"overflow_arg_area";
10050 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
10051 FieldNames[4] =
"reg_save_area";
10054 for (
unsigned i = 0; i < NumFields; ++i) {
10058 &Context->Idents.get(FieldNames[i]),
10059 FieldTypes[i],
nullptr,
10072 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10076 std::nullopt, VaListTagTypedefDecl);
10079 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10080 QualType VaListTagArrayType = Context->getConstantArrayType(
10082 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10085static TypedefDecl *
10089 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10092 const size_t NumFields = 4;
10094 const char *FieldNames[NumFields];
10097 FieldTypes[0] = Context->UnsignedIntTy;
10098 FieldNames[0] =
"gp_offset";
10101 FieldTypes[1] = Context->UnsignedIntTy;
10102 FieldNames[1] =
"fp_offset";
10105 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10106 FieldNames[2] =
"overflow_arg_area";
10109 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10110 FieldNames[3] =
"reg_save_area";
10113 for (
unsigned i = 0; i < NumFields; ++i) {
10118 &Context->Idents.get(FieldNames[i]),
10119 FieldTypes[i],
nullptr,
10133 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10134 QualType VaListTagArrayType = Context->getConstantArrayType(
10136 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10139static TypedefDecl *
10142 RecordDecl *VaListDecl = Context->buildImplicitRecord(
"__va_list");
10143 if (Context->getLangOpts().CPlusPlus) {
10162 &Context->Idents.get(
"__ap"),
10163 Context->getPointerType(Context->VoidTy),
10173 Context->VaListTagDecl = VaListDecl;
10176 CanQualType T = Context->getCanonicalTagType(VaListDecl);
10177 return Context->buildImplicitTypedef(T,
"__builtin_va_list");
10180static TypedefDecl *
10184 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10187 const size_t NumFields = 4;
10189 const char *FieldNames[NumFields];
10192 FieldTypes[0] = Context->LongTy;
10193 FieldNames[0] =
"__gpr";
10196 FieldTypes[1] = Context->LongTy;
10197 FieldNames[1] =
"__fpr";
10200 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10201 FieldNames[2] =
"__overflow_arg_area";
10204 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10205 FieldNames[3] =
"__reg_save_area";
10208 for (
unsigned i = 0; i < NumFields; ++i) {
10213 &Context->Idents.get(FieldNames[i]),
10214 FieldTypes[i],
nullptr,
10228 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10229 QualType VaListTagArrayType = Context->getConstantArrayType(
10232 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10238 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10241 const size_t NumFields = 3;
10243 const char *FieldNames[NumFields];
10246 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10247 FieldNames[0] =
"__current_saved_reg_area_pointer";
10250 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10251 FieldNames[1] =
"__saved_reg_area_end_pointer";
10254 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10255 FieldNames[2] =
"__overflow_area_pointer";
10258 for (
unsigned i = 0; i < NumFields; ++i) {
10261 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
10274 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10278 std::nullopt, VaListTagTypedefDecl);
10281 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10282 QualType VaListTagArrayType = Context->getConstantArrayType(
10285 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10288static TypedefDecl *
10298 constexpr size_t NumFields = 3;
10299 QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
10300 Context->getPointerType(Context->IntTy),
10302 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10305 for (
unsigned i = 0; i < NumFields; ++i) {
10308 &Context->Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
10320 Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10322 return VaListTagTypedefDecl;
10348 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10352 if (!BuiltinVaListDecl) {
10353 BuiltinVaListDecl =
CreateVaListDecl(
this, Target->getBuiltinVaListKind());
10354 assert(BuiltinVaListDecl->isImplicit());
10357 return BuiltinVaListDecl;
10370 if (!BuiltinMSVaListDecl)
10373 return BuiltinMSVaListDecl;
10390 assert(ObjCConstantStringType.isNull() &&
10391 "'NSConstantString' type already set!");
10401 unsigned size = End - Begin;
10402 assert(size > 1 &&
"set is not overloaded!");
10408 NamedDecl **Storage = OT->getStorage();
10431 bool TemplateKeyword,
10436 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10437 assert(!Qualifier &&
"unexpected qualified template template parameter");
10438 assert(TemplateKeyword ==
false);
10443 llvm::FoldingSetNodeID ID;
10446 void *InsertPos =
nullptr;
10448 QualifiedTemplateNames.FindNodeOrInsertPos(ID, InsertPos);
10452 QualifiedTemplateNames.InsertNode(QTN, InsertPos);
10462 llvm::FoldingSetNodeID ID;
10465 void *InsertPos =
nullptr;
10467 DependentTemplateNames.FindNodeOrInsertPos(ID, InsertPos))
10472 DependentTemplateNames.InsertNode(QTN, InsertPos);
10477 Decl *AssociatedDecl,
10480 bool Final)
const {
10481 llvm::FoldingSetNodeID ID;
10483 Index, PackIndex, Final);
10485 void *insertPos =
nullptr;
10487 = SubstTemplateTemplateParms.FindNodeOrInsertPos(ID, insertPos);
10491 Replacement, AssociatedDecl, Index, PackIndex, Final);
10492 SubstTemplateTemplateParms.InsertNode(subst, insertPos);
10500 Decl *AssociatedDecl,
10501 unsigned Index,
bool Final)
const {
10503 llvm::FoldingSetNodeID ID;
10505 AssociatedDecl, Index, Final);
10507 void *InsertPos =
nullptr;
10509 = SubstTemplateTemplateParmPacks.FindNodeOrInsertPos(ID, InsertPos);
10514 SubstTemplateTemplateParmPacks.InsertNode(Subst, InsertPos);
10528 llvm::FoldingSetNodeID ID;
10531 void *InsertPos =
nullptr;
10533 DeducedTemplates.FindNodeOrInsertPos(ID, InsertPos);
10539 DeducedTemplates.InsertNode(DTS, InsertPos);
10562 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10592 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10593 CT = AT->getElementType();
10625 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10626 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10683 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
10684 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
10686 if (!LHSOBT && !RHSOBT)
10689 if (LHSOBT && RHSOBT) {
10690 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
10695 QualType LHSUnderlying = LHSOBT ? LHSOBT->desugar() : LHS;
10696 QualType RHSUnderlying = RHSOBT ? RHSOBT->desugar() : RHS;
10698 if (RHSOBT && !LHSOBT) {
10709 auto VScale = Context.getTargetInfo().getVScaleRange(
10716 uint64_t EltSize = Context.getTypeSize(Info.
ElementType);
10720 uint64_t MinElts = Info.
EC.getKnownMinValue();
10721 return VScale->first * MinElts * EltSize;
10729 "Expected RVV builtin type and vector type!");
10769 return IsValidCast(FirstType, SecondType) ||
10770 IsValidCast(SecondType, FirstType);
10778 "Expected RVV builtin type and vector type!");
10785 if (!BT->isRVVVLSBuiltinType())
10805 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10812 return IsLaxCompatible(FirstType, SecondType) ||
10813 IsLaxCompatible(SecondType, FirstType);
10819 if (
const AttributedType *
Attr = dyn_cast<AttributedType>(Ty)) {
10820 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10823 Ty =
Attr->getModifiedType();
10827 Ty =
Paren->getInnerType();
10859 for (
auto *lhsProto : lhs->
quals()) {
10860 bool match =
false;
10861 for (
auto *rhsProto : rhs->
quals()) {
10892 for (
auto *I : lhs->
quals()) {
10896 if (!rhsID->ClassImplementsProtocol(I,
true))
10904 for (
auto *lhsProto : lhs->
quals()) {
10905 bool match =
false;
10910 for (
auto *rhsProto : rhs->
quals()) {
10920 for (
auto *I : lhs->
quals()) {
10924 if (rhsID->ClassImplementsProtocol(I,
true)) {
10941 for (
auto *lhsProto : lhs->
quals()) {
10942 bool match =
false;
10949 for (
auto *rhsProto : rhs->
quals()) {
10968 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
10970 for (
auto *lhsProto : LHSInheritedProtocols) {
10971 bool match =
false;
10972 for (
auto *rhsProto : rhs->
quals()) {
10997 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
11002 auto finish = [&](
bool succeeded) ->
bool {
11006 if (!RHS->isKindOfType())
11017 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
11022 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
11027 if (LHS->isObjCClass() && RHS->isObjCClass()) {
11032 if (LHS->getInterface() && RHS->getInterface()) {
11047 bool BlockReturnType) {
11051 auto finish = [&](
bool succeeded) ->
bool {
11076 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
11080 (!BlockReturnType &&
11084 (BlockReturnType ? LHSOPT : RHSOPT),
11085 (BlockReturnType ? RHSOPT : LHSOPT),
false));
11093 return finish(BlockReturnType);
11095 return finish(!BlockReturnType);
11107 return (*lhs)->getName().compare((*rhs)->getName());
11124 assert(LHS->getInterface() &&
"LHS must have an interface base");
11125 assert(RHS->getInterface() &&
"RHS must have an interface base");
11131 for (
auto *proto : LHS->quals()) {
11132 Context.CollectInheritedProtocols(proto, LHSProtocolSet);
11136 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
11142 for (
auto *proto : RHS->quals()) {
11143 Context.CollectInheritedProtocols(proto, RHSProtocolSet);
11147 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
11150 for (
auto *proto : LHSProtocolSet) {
11151 if (RHSProtocolSet.count(proto))
11152 IntersectionSet.push_back(proto);
11158 Context.CollectInheritedProtocols(CommonBase, ImpliedProtocols);
11161 if (!ImpliedProtocols.empty()) {
11163 return ImpliedProtocols.contains(proto);
11168 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11178 if (lhsOPT && rhsOPT)
11184 if (lhsBlock && rhsBlock)
11189 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11201 bool stripKindOf) {
11202 if (lhsArgs.size() != rhsArgs.size())
11209 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11215 if (!stripKindOf ||
11216 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11217 rhsArgs[i].stripObjCKindOfType(ctx))) {
11245 if (!LDecl || !RDecl)
11251 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
11255 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11260 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
11265 bool anyChanges =
false;
11266 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11269 LHS->getTypeArgs(), RHS->getTypeArgs(),
11272 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11283 if (!Protocols.empty())
11289 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
11292 anyKindOf || LHS->isKindOfType());
11300 QualType LHSSuperType = LHS->getSuperClassType();
11301 if (LHSSuperType.
isNull())
11310 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
11311 if (KnownLHS != LHSAncestors.end()) {
11312 LHS = KnownLHS->second;
11316 bool anyChanges =
false;
11317 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11320 LHS->getTypeArgs(), RHS->getTypeArgs(),
11323 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11334 if (!Protocols.empty())
11339 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
11342 anyKindOf || RHS->isKindOfType());
11350 QualType RHSSuperType = RHS->getSuperClassType();
11351 if (RHSSuperType.
isNull())
11362 assert(LHS->getInterface() &&
"LHS is not an interface type");
11363 assert(RHS->getInterface() &&
"RHS is not an interface type");
11368 bool IsSuperClass = LHSInterface->
isSuperClassOf(RHS->getInterface());
11375 if (LHS->getNumProtocols() > 0) {
11384 for (
auto *RHSPI : RHS->quals())
11387 if (SuperClassInheritedProtocols.empty())
11390 for (
const auto *LHSProto : LHS->quals()) {
11391 bool SuperImplementsProtocol =
false;
11392 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11393 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11394 SuperImplementsProtocol =
true;
11397 if (!SuperImplementsProtocol)
11403 if (LHS->isSpecialized()) {
11408 RHSSuper = RHSSuper->getSuperClassType()->castAs<
ObjCObjectType>();
11411 if (RHSSuper->isSpecialized() &&
11413 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
11427 if (!LHSOPT || !RHSOPT)
11445 bool CompareUnqualified) {
11464 bool OfBlockPointer,
11466 if (
const RecordType *UT = T->getAsUnionType()) {
11468 if (UD->
hasAttr<TransparentUnionAttr>()) {
11469 for (
const auto *I : UD->
fields()) {
11470 QualType ET = I->getType().getUnqualifiedType();
11484 bool OfBlockPointer,
11505 bool IsConditionalOperator) {
11508 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11509 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11510 bool allLTypes =
true;
11511 bool allRTypes =
true;
11515 if (OfBlockPointer) {
11517 QualType LHS = lbase->getReturnType();
11519 if (!UnqualifiedResult)
11521 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11586 bool NoReturn = IsConditionalOperator
11596 std::optional<FunctionEffectSet> MergedFX;
11598 if (lproto && rproto) {
11599 assert((AllowCXX ||
11600 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11601 "C++ shouldn't be here");
11603 if (lproto->getNumParams() != rproto->getNumParams())
11607 if (lproto->isVariadic() != rproto->isVariadic())
11610 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11614 if (lproto->getExtraAttributeInfo().CFISalt !=
11615 rproto->getExtraAttributeInfo().CFISalt)
11621 if (LHSFX != RHSFX) {
11622 if (IsConditionalOperator)
11631 if (*MergedFX != LHSFX)
11633 if (*MergedFX != RHSFX)
11638 bool canUseLeft, canUseRight;
11650 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11651 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11652 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11654 lParamType, rParamType, OfBlockPointer,
Unqualified);
11661 types.push_back(paramType);
11673 if (allLTypes)
return lhs;
11674 if (allRTypes)
return rhs;
11679 newParamInfos.empty() ?
nullptr : newParamInfos.data();
11685 if (lproto) allRTypes =
false;
11686 if (rproto) allLTypes =
false;
11690 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11698 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11704 paramTy = ED->getIntegerType();
11714 if (allLTypes)
return lhs;
11715 if (allRTypes)
return rhs;
11724 if (allLTypes)
return lhs;
11725 if (allRTypes)
return rhs;
11731 QualType other,
bool isBlockReturnType) {
11737 ET->getDecl()->getDefinitionOrSelf()->getIntegerType();
11738 if (underlyingType.
isNull())
11740 if (Context.hasSameType(underlyingType, other))
11746 Context.getTypeSize(underlyingType) == Context.getTypeSize(other))
11755 if (LangOpts.CPlusPlus || !LangOpts.C23)
11776 bool BlockReturnType,
bool IsConditionalOperator) {
11777 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
11778 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
11780 if (!LHSOBT && !RHSOBT)
11781 return std::nullopt;
11785 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
11789 LHSOBT->getUnderlyingType(), RHSOBT->getUnderlyingType(),
11790 OfBlockPointer,
Unqualified, BlockReturnType, IsConditionalOperator);
11792 if (MergedUnderlying.
isNull())
11796 if (LHSOBT->getUnderlyingType() == RHSOBT->getUnderlyingType())
11799 LHSOBT->getBehaviorKind(),
11808 return mergeTypes(LHSOBT->getUnderlyingType(), RHS, OfBlockPointer,
11809 Unqualified, BlockReturnType, IsConditionalOperator);
11812 return mergeTypes(LHS, RHSOBT->getUnderlyingType(), OfBlockPointer,
11813 Unqualified, BlockReturnType, IsConditionalOperator);
11818 bool IsConditionalOperator) {
11829 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11833 if (LHSRefTy || RHSRefTy)
11836 if (std::optional<QualType> MergedOBT =
11838 BlockReturnType, IsConditionalOperator))
11850 if (LHSCan == RHSCan)
11855 Qualifiers RQuals = RHSCan.getLocalQualifiers();
11856 if (LQuals != RQuals) {
11873 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
11894 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
11895 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
11898 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
11899 LHSClass = Type::ConstantArray;
11900 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
11901 RHSClass = Type::ConstantArray;
11904 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
11905 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
11908 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
11909 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
11912 if (LHSClass != RHSClass) {
11922 if (OfBlockPointer && !BlockReturnType) {
11930 if (
const auto *AT = LHS->
getAs<AutoType>()) {
11931 if (!AT->isDeduced() && AT->isGNUAutoType())
11934 if (
const auto *AT = RHS->
getAs<AutoType>()) {
11935 if (!AT->isDeduced() && AT->isGNUAutoType())
11942 switch (LHSClass) {
11943#define TYPE(Class, Base)
11944#define ABSTRACT_TYPE(Class, Base)
11945#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
11946#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
11947#define DEPENDENT_TYPE(Class, Base) case Type::Class:
11948#include "clang/AST/TypeNodes.inc"
11949 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
11952 case Type::DeducedTemplateSpecialization:
11953 case Type::LValueReference:
11954 case Type::RValueReference:
11955 case Type::MemberPointer:
11956 llvm_unreachable(
"C++ should never be in mergeTypes");
11958 case Type::ObjCInterface:
11959 case Type::IncompleteArray:
11960 case Type::VariableArray:
11961 case Type::FunctionProto:
11962 case Type::ExtVector:
11963 case Type::OverflowBehavior:
11964 llvm_unreachable(
"Types are eliminated above");
11966 case Type::Pointer:
11977 if (ResultType.
isNull())
11985 case Type::BlockPointer:
12010 if (ResultType.
isNull())
12029 if (ResultType.
isNull())
12037 case Type::ConstantArray:
12052 if (ResultType.
isNull())
12060 if (LVAT || RVAT) {
12063 -> std::pair<bool,llvm::APInt> {
12065 std::optional<llvm::APSInt> TheInt;
12068 return std::make_pair(
true, *TheInt);
12069 return std::make_pair(
false, llvm::APSInt());
12072 return std::make_pair(
true, CAT->getSize());
12073 return std::make_pair(
false, llvm::APInt());
12076 bool HaveLSize, HaveRSize;
12077 llvm::APInt LSize, RSize;
12078 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
12079 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
12080 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
12114 case Type::FunctionNoProto:
12116 false, IsConditionalOperator);
12120 case Type::Builtin:
12123 case Type::Complex:
12132 case Type::ConstantMatrix:
12137 case Type::ObjCObject: {
12146 case Type::ObjCObjectPointer:
12147 if (OfBlockPointer) {
12159 assert(LHS != RHS &&
12160 "Equivalent pipe types should have already been handled!");
12162 case Type::ArrayParameter:
12163 assert(LHS != RHS &&
12164 "Equivalent ArrayParameter types should have already been handled!");
12166 case Type::BitInt: {
12174 if (LHSUnsigned != RHSUnsigned)
12177 if (LHSBits != RHSBits)
12181 case Type::HLSLAttributedResource: {
12182 const HLSLAttributedResourceType *LHSTy =
12183 LHS->
castAs<HLSLAttributedResourceType>();
12184 const HLSLAttributedResourceType *RHSTy =
12185 RHS->
castAs<HLSLAttributedResourceType>();
12186 assert(LHSTy->getWrappedType() == RHSTy->getWrappedType() &&
12187 LHSTy->getWrappedType()->isHLSLResourceType() &&
12188 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
12190 if (LHSTy->getAttrs() == RHSTy->getAttrs() &&
12191 LHSTy->getContainedType() == RHSTy->getContainedType())
12195 case Type::HLSLInlineSpirv:
12196 const HLSLInlineSpirvType *LHSTy = LHS->
castAs<HLSLInlineSpirvType>();
12197 const HLSLInlineSpirvType *RHSTy = RHS->
castAs<HLSLInlineSpirvType>();
12199 if (LHSTy->getOpcode() == RHSTy->getOpcode() &&
12200 LHSTy->getSize() == RHSTy->getSize() &&
12201 LHSTy->getAlignment() == RHSTy->getAlignment()) {
12202 for (
size_t I = 0; I < LHSTy->getOperands().size(); I++)
12203 if (LHSTy->getOperands()[I] != RHSTy->getOperands()[I])
12211 llvm_unreachable(
"Invalid Type::Class!");
12216 bool &CanUseFirst,
bool &CanUseSecond,
12218 assert(NewParamInfos.empty() &&
"param info list not empty");
12219 CanUseFirst = CanUseSecond =
true;
12225 if (!FirstHasInfo && !SecondHasInfo)
12228 bool NeedParamInfo =
false;
12232 for (
size_t I = 0; I < E; ++I) {
12243 bool FirstNoEscape = FirstParam.
isNoEscape();
12244 bool SecondNoEscape = SecondParam.
isNoEscape();
12245 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12247 if (NewParamInfos.back().getOpaqueValue())
12248 NeedParamInfo =
true;
12249 if (FirstNoEscape != IsNoEscape)
12250 CanUseFirst =
false;
12251 if (SecondNoEscape != IsNoEscape)
12252 CanUseSecond =
false;
12255 if (!NeedParamInfo)
12256 NewParamInfos.clear();
12262 if (
auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
12263 It->second =
nullptr;
12264 for (
auto *SubClass : ObjCSubClasses.lookup(D))
12276 if (LHSCan == RHSCan)
12278 if (RHSCan->isFunctionType()) {
12287 if (ResReturnType.
isNull())
12289 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12306 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12307 if (LQuals != RQuals) {
12320 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12336 if (ResQT == LHSBaseQT)
12338 if (ResQT == RHSBaseQT)
12349 if (
const auto *ED = T->getAsEnumDecl())
12350 T = ED->getIntegerType();
12351 if (T->isBooleanType())
12353 if (
const auto *EIT = T->getAs<
BitIntType>())
12354 return EIT->getNumBits();
12360 assert((T->hasIntegerRepresentation() || T->isEnumeralType() ||
12361 T->isFixedPointType()) &&
12362 "Unexpected type");
12365 if (
const auto *VTy = T->getAs<
VectorType>())
12367 VTy->getNumElements(), VTy->getVectorKind());
12370 if (
const auto *EITy = T->getAs<
BitIntType>())
12374 if (
const auto *OBT = T->getAs<OverflowBehaviorType>())
12376 OBT->getBehaviorKind(),
12381 if (
const auto *ED = T->getAsEnumDecl())
12382 T = ED->getIntegerType();
12385 case BuiltinType::Char_U:
12387 case BuiltinType::Char_S:
12388 case BuiltinType::SChar:
12389 case BuiltinType::Char8:
12391 case BuiltinType::Short:
12393 case BuiltinType::Int:
12395 case BuiltinType::Long:
12397 case BuiltinType::LongLong:
12399 case BuiltinType::Int128:
12404 case BuiltinType::WChar_S:
12407 case BuiltinType::ShortAccum:
12409 case BuiltinType::Accum:
12411 case BuiltinType::LongAccum:
12413 case BuiltinType::SatShortAccum:
12415 case BuiltinType::SatAccum:
12417 case BuiltinType::SatLongAccum:
12419 case BuiltinType::ShortFract:
12421 case BuiltinType::Fract:
12423 case BuiltinType::LongFract:
12425 case BuiltinType::SatShortFract:
12427 case BuiltinType::SatFract:
12429 case BuiltinType::SatLongFract:
12432 assert((T->hasUnsignedIntegerRepresentation() ||
12433 T->isUnsignedFixedPointType()) &&
12434 "Unexpected signed integer or fixed point type");
12440 assert((T->hasIntegerRepresentation() || T->isEnumeralType() ||
12441 T->isFixedPointType()) &&
12442 "Unexpected type");
12445 if (
const auto *VTy = T->getAs<
VectorType>())
12447 VTy->getNumElements(), VTy->getVectorKind());
12450 if (
const auto *EITy = T->getAs<
BitIntType>())
12455 if (
const auto *ED = T->getAsEnumDecl())
12456 T = ED->getIntegerType();
12459 case BuiltinType::Char_S:
12461 case BuiltinType::Char_U:
12462 case BuiltinType::UChar:
12463 case BuiltinType::Char8:
12465 case BuiltinType::UShort:
12467 case BuiltinType::UInt:
12469 case BuiltinType::ULong:
12471 case BuiltinType::ULongLong:
12473 case BuiltinType::UInt128:
12478 case BuiltinType::WChar_U:
12481 case BuiltinType::UShortAccum:
12483 case BuiltinType::UAccum:
12485 case BuiltinType::ULongAccum:
12487 case BuiltinType::SatUShortAccum:
12489 case BuiltinType::SatUAccum:
12491 case BuiltinType::SatULongAccum:
12493 case BuiltinType::UShortFract:
12495 case BuiltinType::UFract:
12497 case BuiltinType::ULongFract:
12499 case BuiltinType::SatUShortFract:
12501 case BuiltinType::SatUFract:
12503 case BuiltinType::SatULongFract:
12507 (T->hasSignedIntegerRepresentation() || T->isSignedFixedPointType()) &&
12508 "Unexpected signed integer or fixed point type");
12533 bool AllowTypeModifiers) {
12537 RequiresICE =
false;
12542 bool IsSpecial =
false;
12546 default: Done =
true; --Str;
break;
12548 RequiresICE =
true;
12551 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12552 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12556 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12557 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12561 assert(!IsSpecial &&
"Can't use 'L' with 'W', 'N', 'Z' or 'O' modifiers");
12562 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12567 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12568 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12572 if (Context.getTargetInfo().getLongWidth() == 32)
12577 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12578 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12582 switch (Context.getTargetInfo().getInt64Type()) {
12584 llvm_unreachable(
"Unexpected integer type");
12595 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12596 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12600 switch (Context.getTargetInfo().getIntTypeByWidth(32,
true)) {
12602 llvm_unreachable(
"Unexpected integer type");
12615 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12616 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12620 if (Context.getLangOpts().OpenCL)
12633 llvm_unreachable(
"Unknown builtin type letter!");
12636 "Bad modifiers used with 'x'!");
12637 Type = Context.Float16Ty;
12641 "Bad modifiers used with 'y'!");
12642 Type = Context.BFloat16Ty;
12646 "Bad modifiers used with 'v'!");
12647 Type = Context.VoidTy;
12651 "Bad modifiers used with 'h'!");
12652 Type = Context.HalfTy;
12656 "Bad modifiers used with 'f'!");
12657 Type = Context.FloatTy;
12661 "Bad modifiers used with 'd'!");
12663 Type = Context.LongDoubleTy;
12664 else if (HowLong == 2)
12665 Type = Context.Float128Ty;
12667 Type = Context.DoubleTy;
12670 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12672 Type = Context.UnsignedShortTy;
12674 Type = Context.ShortTy;
12678 Type =
Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
12679 else if (HowLong == 2)
12680 Type =
Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
12681 else if (HowLong == 1)
12682 Type =
Unsigned ? Context.UnsignedLongTy : Context.LongTy;
12684 Type =
Unsigned ? Context.UnsignedIntTy : Context.IntTy;
12687 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12689 Type = Context.SignedCharTy;
12691 Type = Context.UnsignedCharTy;
12693 Type = Context.CharTy;
12696 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12697 Type = Context.BoolTy;
12700 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12701 Type = Context.getSizeType();
12704 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12705 Type = Context.getWideCharType();
12708 Type = Context.getCFConstantStringType();
12711 Type = Context.getObjCIdType();
12714 Type = Context.getObjCSelType();
12717 Type = Context.getObjCSuperType();
12720 Type = Context.getBuiltinVaListType();
12721 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12732 Type = Context.getBuiltinVaListType();
12733 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12735 Type = Context.getArrayDecayedType(
Type);
12737 Type = Context.getLValueReferenceType(
Type);
12741 unsigned NumElements = strtoul(Str, &End, 10);
12742 assert(End != Str &&
"Missing vector size");
12746 RequiresICE,
false);
12747 assert(!RequiresICE &&
"Can't require vector ICE");
12749 Type = Context.getScalableVectorType(ElementType, NumElements);
12755 Type = Context.SveCountTy;
12759 Type = Context.AMDGPUBufferRsrcTy;
12763 Type = Context.AMDGPUFeaturePredicateTy;
12767 Type = Context.AMDGPUTextureTy;
12771 Type = Context.HLSLResourceTy;
12775 llvm_unreachable(
"Unexpected target builtin type");
12781 unsigned NumElements = strtoul(Str, &End, 10);
12782 assert(End != Str &&
"Missing vector size");
12786 RequiresICE,
false);
12787 assert(!RequiresICE &&
"Can't require vector ICE");
12796 unsigned NumElements = strtoul(Str, &End, 10);
12797 assert(End != Str &&
"Missing vector size");
12803 Type = Context.getExtVectorType(ElementType, NumElements);
12809 assert(!RequiresICE &&
"Can't require complex ICE");
12810 Type = Context.getComplexType(ElementType);
12814 Type = Context.getPointerDiffType();
12817 Type = Context.getFILEType();
12818 if (
Type.isNull()) {
12825 Type = Context.getsigjmp_bufType();
12827 Type = Context.getjmp_bufType();
12829 if (
Type.isNull()) {
12835 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
12836 Type = Context.getucontext_tType();
12838 if (
Type.isNull()) {
12844 Type = Context.getProcessIDType();
12847 Type = Context.MFloat8Ty;
12852 Done = !AllowTypeModifiers;
12854 switch (
char c = *Str++) {
12855 default: Done =
true; --Str;
break;
12861 unsigned AddrSpace = strtoul(Str, &End, 10);
12864 Type = Context.getAddrSpaceQualType(
12866 Context.getLangASForBuiltinAddressSpace(AddrSpace));
12870 Type = Context.getPointerType(
Type);
12872 Type = Context.getLValueReferenceType(
Type);
12880 Type = Context.getVolatileType(
Type);
12889 "Integer constant 'I' type must be an integer");
12902 bool AllowTypeModifiers)
const {
12909 unsigned *IntegerConstantArgs)
const {
12910 const char *TypeStr =
BuiltinInfo.getTypeString(Id);
12911 if (TypeStr[0] ==
'\0') {
12918 bool RequiresICE =
false;
12921 RequiresICE,
true);
12925 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
12927 while (TypeStr[0] && TypeStr[0] !=
'.') {
12934 if (RequiresICE && IntegerConstantArgs)
12935 *IntegerConstantArgs |= 1 << ArgTypes.size();
12941 ArgTypes.push_back(Ty);
12944 if (Id == Builtin::BI__GetExceptionInfo)
12947 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
12948 "'.' should only occur at end of builtin type list!");
12950 bool Variadic = (TypeStr[0] ==
'.');
12957 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
13007 if ((!Context.getLangOpts().CPlusPlus &&
13008 !Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13009 !FD->
hasAttr<DLLExportAttr>()) ||
13010 FD->
hasAttr<GNUInlineAttr>()) {
13028 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13031 !FD->
hasAttr<DLLExportAttr>()) {
13052 if (D->
hasAttr<DLLImportAttr>()) {
13055 }
else if (D->
hasAttr<DLLExportAttr>()) {
13058 }
else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice) {
13061 if (D->
hasAttr<CUDAGlobalAttr>() &&
13070 if (Context.shouldExternalize(D))
13085 switch (Source->hasExternalDefinitions(D)) {
13112 if (Context.getLangOpts().CPlusPlus &&
13113 Context.getLangOpts().IncrementalExtensions &&
13129 if (!LexicalContext)
13134 auto StaticLocalLinkage =
13146 return StaticLocalLinkage;
13152 if (Context.isMSStaticDataMemberInlineDefinition(VD))
13158 switch (Context.getInlineVariableDefinitionKind(VD)) {
13173 return StrongLinkage;
13176 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13191 llvm_unreachable(
"Invalid Linkage!");
13201 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13202 if (!VD->isFileVarDecl())
13207 if (VD->getDescribedVarTemplate() ||
13210 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13236 if (D->
hasAttr<WeakRefAttr>())
13243 if (LangOpts.SYCLIsDevice)
13245 D->
hasAttr<SYCLExternalAttr>());
13251 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13253 if (!FD->doesThisDeclarationHaveABody())
13254 return FD->doesDeclarationForceExternallyVisibleDefinition();
13257 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13262 if (
getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
13263 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13282 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13286 if (LangOpts.OpenMP &&
13287 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13294 if (VD->shouldEmitInExternalSource())
13307 if (VD->needsDestruction(*
this))
13311 if (VD->hasInitWithSideEffects())
13316 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13317 for (
const auto *BD : DD->flat_bindings())
13318 if (
const auto *BindingVD = BD->getHoldingVar())
13328 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13329 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13330 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13335 for (
auto *CurDecl :
13339 SeenDecls.insert(CurFD).second) {
13346 bool IsCXXMethod)
const {
13349 return ABI->getDefaultMethodCallConv(IsVariadic);
13351 switch (LangOpts.getDefaultCallingConv()) {
13379 return Target->getDefaultCallingConv();
13384 return ABI->isNearlyEmpty(RD);
13389 auto ABI = Target->getCXXABI();
13390 if (ABI.isMicrosoft())
13396 return VTContext.get();
13402 switch (T->getCXXABI().getKind()) {
13403 case TargetCXXABI::AppleARM64:
13404 case TargetCXXABI::Fuchsia:
13405 case TargetCXXABI::GenericAArch64:
13406 case TargetCXXABI::GenericItanium:
13407 case TargetCXXABI::GenericARM:
13408 case TargetCXXABI::GenericMIPS:
13409 case TargetCXXABI::iOS:
13410 case TargetCXXABI::WebAssembly:
13411 case TargetCXXABI::WatchOS:
13412 case TargetCXXABI::XL:
13414 case TargetCXXABI::Microsoft:
13417 llvm_unreachable(
"Unsupported ABI");
13421 assert(T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13422 "Device mangle context does not support Microsoft mangling.");
13423 switch (T.getCXXABI().getKind()) {
13424 case TargetCXXABI::AppleARM64:
13425 case TargetCXXABI::Fuchsia:
13426 case TargetCXXABI::GenericAArch64:
13427 case TargetCXXABI::GenericItanium:
13428 case TargetCXXABI::GenericARM:
13429 case TargetCXXABI::GenericMIPS:
13430 case TargetCXXABI::iOS:
13431 case TargetCXXABI::WebAssembly:
13432 case TargetCXXABI::WatchOS:
13433 case TargetCXXABI::XL:
13437 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13438 return RD->getDeviceLambdaManglingNumber();
13439 return std::nullopt;
13442 case TargetCXXABI::Microsoft:
13446 llvm_unreachable(
"Unsupported ABI");
13464 return ASTRecordLayouts.getMemorySize() +
13465 llvm::capacity_in_bytes(ObjCLayouts) +
13466 llvm::capacity_in_bytes(KeyFunctions) +
13467 llvm::capacity_in_bytes(ObjCImpls) +
13468 llvm::capacity_in_bytes(BlockVarCopyInits) +
13469 llvm::capacity_in_bytes(DeclAttrs) +
13470 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13471 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13472 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13473 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13474 llvm::capacity_in_bytes(OverriddenMethods) +
13475 llvm::capacity_in_bytes(Types) +
13476 llvm::capacity_in_bytes(VariableArrayTypes);
13484 unsigned Signed)
const {
13487 if (!QualTy && DestWidth == 128)
13516 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13523 MangleNumbers[ND] = Number;
13526 Listener->AddedManglingNumber(ND, Number);
13530 bool ForAuxTarget)
const {
13531 auto I = MangleNumbers.find(ND);
13532 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13535 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13536 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13538 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13539 "number for aux target");
13541 return Res > 1 ? Res : 1;
13548 StaticLocalNumbers[VD] = Number;
13551 Listener->AddedStaticLocalNumbers(VD, Number);
13555 auto I = StaticLocalNumbers.find(VD);
13556 return I != StaticLocalNumbers.end() ? I->second : 1;
13560 bool IsDestroying) {
13561 if (!IsDestroying) {
13573 bool IsTypeAware) {
13574 if (!IsTypeAware) {
13613 return GlobalOperatorDeletesForVirtualDtor.contains(
13616 return ArrayOperatorDeletesForVirtualDtor.contains(
13619 return GlobalArrayOperatorDeletesForVirtualDtor.contains(
13631 if (OperatorDeletesForVirtualDtor.contains(Canon))
13632 return OperatorDeletesForVirtualDtor[Canon];
13635 if (GlobalOperatorDeletesForVirtualDtor.contains(Canon))
13636 return GlobalOperatorDeletesForVirtualDtor[Canon];
13639 if (ArrayOperatorDeletesForVirtualDtor.contains(Canon))
13640 return ArrayOperatorDeletesForVirtualDtor[Canon];
13643 if (GlobalArrayOperatorDeletesForVirtualDtor.contains(Canon))
13644 return GlobalArrayOperatorDeletesForVirtualDtor[Canon];
13655 return MaybeRequireVectorDeletingDtor.count(RD);
13663 MaybeRequireVectorDeletingDtor.insert(RD);
13668 assert(LangOpts.CPlusPlus);
13669 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13677 assert(LangOpts.CPlusPlus);
13678 std::unique_ptr<MangleNumberingContext> &MCtx =
13679 ExtraMangleNumberingContexts[D];
13685std::unique_ptr<MangleNumberingContext>
13687 return ABI->createMangleNumberingContext();
13692 return ABI->getCopyConstructorForExceptionObject(
13698 return ABI->addCopyConstructorForExceptionObject(
13705 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13710 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13715 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13719 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13723 ParamIndices[D] =
index;
13727 ParameterIndexTable::const_iterator I = ParamIndices.find(D);
13728 assert(I != ParamIndices.end() &&
13729 "ParmIndices lacks entry set by ParmVarDecl");
13734 unsigned Length)
const {
13760 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13762 llvm::FoldingSetNodeID ID;
13766 if (
MSGuidDecl *Existing = MSGuidDecls.FindNodeOrInsertPos(ID, InsertPos))
13770 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
13771 MSGuidDecls.InsertNode(
New, InsertPos);
13777 const APValue &APVal)
const {
13778 llvm::FoldingSetNodeID ID;
13783 UnnamedGlobalConstantDecls.FindNodeOrInsertPos(ID, InsertPos))
13787 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
13788 UnnamedGlobalConstantDecls.InsertNode(
New, InsertPos);
13794 assert(T->isRecordType() &&
"template param object of unexpected type");
13800 llvm::FoldingSetNodeID ID;
13805 TemplateParamObjectDecls.FindNodeOrInsertPos(ID, InsertPos))
13809 TemplateParamObjectDecls.InsertNode(
New, InsertPos);
13815 if (!T.isOSDarwin())
13818 if (!(T.isiOS() && T.isOSVersionLT(7)) &&
13819 !(T.isMacOSX() && T.isOSVersionLT(10, 9)))
13828 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
13835 if (MethodDecl->
hasAttr<UnavailableAttr>()
13836 || MethodDecl->
hasAttr<DeprecatedAttr>())
13850 IM != EM && IF != EF; ++IM, ++IF) {
13881 llvm::FoldingSetNodeID IDX, IDY;
13882 X->Profile(IDX, *
this,
true);
13883 Y->
Profile(IDY, *
this,
true);
13897 for (
const Decl *DX :
X->redecls()) {
13902 if (DX->isFirstDecl())
13905 llvm_unreachable(
"Corrupt redecls chain");
13908template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
13910 return cast_or_null<T>(
13912 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
13915template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
13923 bool IgnoreDeduced =
false) {
13938 bool IgnoreDeduced) {
13940 assert(R.getAsVoidPointer() !=
nullptr);
13946 assert(Xs.size() == Ys.size());
13948 for (
size_t I = 0; I < Rs.size(); ++I)
13955 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
13965 switch (
X.getKind()) {
13995 auto NExpX =
X.getNumTemplateExpansions();
14009 if (Xs.size() != Ys.size())
14011 R.resize(Xs.size());
14012 for (
size_t I = 0; I < R.size(); ++I) {
14025 assert(!Different);
14053 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
14055 return std::nullopt;
14060 assert(Kind == NNS2.
getKind());
14065 auto Kind = Namespace1->getKind();
14066 if (Kind != Namespace2->getKind() ||
14067 (Kind == Decl::NamespaceAlias &&
14072 Namespace2->getNamespace()),
14106 llvm_unreachable(
"singletons did not compare equal");
14108 assert(R.getCanonical() == Canon);
14114 const T *Y,
bool IsSame) {
14115 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
14135 QX +=
X.getQualifiers() - RQ;
14145 Y->getElementType(), QX, QY);
14156 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
14157 return X->getSizeExpr();
14162 return X->getSizeModifier();
14168 return X->getIndexTypeCVRQualifiers();
14178 llvm::DenseMap<QualType, unsigned>
Found;
14179 for (
auto Ts : {
X, Y}) {
14186 Out.emplace_back(T);
14192FunctionProtoType::ExceptionSpecInfo
14196 bool AcceptDependent)
const {
14222 assert(AcceptDependent &&
14223 "computing composite pointer type of dependent types");
14238 llvm_unreachable(
"These ESTs should be handled above");
14243 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
14247 Result.Exceptions = ExceptionTypeStorage;
14254 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
14257 llvm_unreachable(
"invalid ExceptionSpecificationType");
14266#define UNEXPECTED_TYPE(Class, Kind) \
14267 case Type::Class: \
14268 llvm_unreachable("Unexpected " Kind ": " #Class);
14270#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
14271#define TYPE(Class, Base)
14272#include "clang/AST/TypeNodes.inc"
14274#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
14285#undef SUGAR_FREE_TYPE
14286#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
14289#undef NON_UNIQUE_TYPE
14293#undef UNEXPECTED_TYPE
14297 assert(AX->getDeducedKind() == AY->getDeducedKind());
14299 assert(AX->getKeyword() == AY->getKeyword());
14301 AY->getTypeConstraintConcept());
14305 AY->getTypeConstraintArguments())) {
14312 case Type::IncompleteArray: {
14319 case Type::DependentSizedArray: {
14327 case Type::ConstantArray: {
14330 assert(AX->getSize() == AY->getSize());
14331 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14332 ? AX->getSizeExpr()
14338 case Type::ArrayParameter: {
14341 assert(AX->getSize() == AY->getSize());
14342 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14343 ? AX->getSizeExpr()
14350 case Type::Atomic: {
14355 case Type::Complex: {
14359 case Type::Pointer: {
14363 case Type::BlockPointer: {
14367 case Type::ObjCObjectPointer: {
14372 case Type::MemberPointer: {
14376 PY->getMostRecentCXXRecordDecl()));
14380 PX->getMostRecentCXXRecordDecl());
14382 case Type::LValueReference: {
14387 PX->isSpelledAsLValue() ||
14388 PY->isSpelledAsLValue());
14390 case Type::RValueReference: {
14396 case Type::DependentAddressSpace: {
14399 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14401 PX->getAddrSpaceExpr(),
14404 case Type::FunctionNoProto: {
14407 assert(FX->getExtInfo() == FY->getExtInfo());
14412 case Type::FunctionProto: {
14416 EPIY = FY->getExtProtoInfo();
14417 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14424 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14425 assert(EPIX.
Variadic == EPIY.Variadic);
14434 auto P =
getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
14442 case Type::ObjCObject: {
14445 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14446 OY->getProtocols().begin(), OY->getProtocols().end(),
14448 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14450 "protocol lists must be the same");
14452 OY->getTypeArgsAsWritten());
14455 OX->getProtocols(),
14456 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14458 case Type::ConstantMatrix: {
14461 assert(MX->getNumRows() == MY->getNumRows());
14462 assert(MX->getNumColumns() == MY->getNumColumns());
14464 MX->getNumRows(), MX->getNumColumns());
14466 case Type::DependentSizedMatrix: {
14469 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14470 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14475 case Type::Vector: {
14477 assert(VX->getNumElements() == VY->getNumElements());
14478 assert(VX->getVectorKind() == VY->getVectorKind());
14480 VX->getNumElements(), VX->getVectorKind());
14482 case Type::ExtVector: {
14484 assert(VX->getNumElements() == VY->getNumElements());
14486 VX->getNumElements());
14488 case Type::DependentSizedExtVector: {
14495 case Type::DependentVector: {
14498 assert(VX->getVectorKind() == VY->getVectorKind());
14505 case Type::InjectedClassName: {
14512 case Type::TemplateSpecialization: {
14516 TY->template_arguments());
14520 TY->getTemplateName(),
14522 As, {},
X->getCanonicalTypeInternal());
14524 case Type::Decltype: {
14527 assert(DX->isDependentType());
14528 assert(DY->isDependentType());
14529 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14533 case Type::PackIndexing: {
14536 assert(DX->isDependentType());
14537 assert(DY->isDependentType());
14538 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14541 case Type::DependentName: {
14544 assert(NX->getIdentifier() == NY->getIdentifier());
14549 case Type::OverflowBehavior: {
14552 assert(NX->getBehaviorKind() == NY->getBehaviorKind());
14554 NX->getBehaviorKind(),
14556 NY->getUnderlyingType(), QX, QY));
14558 case Type::UnaryTransform: {
14561 assert(TX->getUTTKind() == TY->getUTTKind());
14565 TY->getUnderlyingType()),
14568 case Type::PackExpansion: {
14571 assert(PX->getNumExpansions() == PY->getNumExpansions());
14574 PX->getNumExpansions(),
false);
14578 assert(PX->isReadOnly() == PY->isReadOnly());
14583 case Type::TemplateTypeParm: {
14586 assert(TX->getDepth() == TY->getDepth());
14587 assert(TX->getIndex() == TY->getIndex());
14588 assert(TX->isParameterPack() == TY->isParameterPack());
14590 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14594 llvm_unreachable(
"Unknown Type Class");
14604#define UNEXPECTED_TYPE(Class, Kind) \
14605 case Type::Class: \
14606 llvm_unreachable("Unexpected " Kind ": " #Class);
14607#define TYPE(Class, Base)
14608#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14609#include "clang/AST/TypeNodes.inc"
14611#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14638#undef CANONICAL_TYPE
14640#undef UNEXPECTED_TYPE
14642 case Type::Adjusted: {
14644 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14651 case Type::Decayed: {
14653 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14660 case Type::Attributed: {
14662 AttributedType::Kind Kind = AX->getAttrKind();
14663 if (Kind != AY->getAttrKind())
14665 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14673 case Type::BTFTagAttributed: {
14675 const BTFTypeTagAttr *AX = BX->getAttr();
14677 if (AX->getBTFTypeTag() !=
14688 if (KW != AY->getKeyword())
14692 AY->getTypeConstraintConcept());
14696 AY->getTypeConstraintArguments())) {
14707 case Type::PackIndexing:
14708 case Type::Decltype:
14710 case Type::DeducedTemplateSpecialization:
14713 case Type::MacroQualified: {
14717 if (IX != MY->getMacroIdentifier())
14721 case Type::SubstTemplateTypeParm: {
14728 unsigned Index = SX->getIndex();
14729 if (Index != SY->getIndex())
14731 auto PackIndex = SX->getPackIndex();
14732 if (PackIndex != SY->getPackIndex())
14735 CD, Index, PackIndex,
14736 SX->getFinal() && SY->getFinal());
14738 case Type::ObjCTypeParam:
14744 case Type::TemplateSpecialization: {
14749 TY->getTemplateName(),
true);
14754 TY->template_arguments()))
14760 case Type::Typedef: {
14770 case Type::TypeOf: {
14781 case Type::TypeOfExpr:
14784 case Type::UnaryTransform: {
14787 UnaryTransformType::UTTKind KX = UX->getUTTKind();
14788 if (KX != UY->getUTTKind())
14790 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
14797 case Type::Using: {
14806 case Type::MemberPointer: {
14810 assert(Cls == PY->getMostRecentCXXRecordDecl());
14815 case Type::CountAttributed: {
14818 if (DX->isCountInBytes() != DY->isCountInBytes())
14820 if (DX->isOrNull() != DY->isOrNull())
14822 Expr *CEX = DX->getCountExpr();
14823 Expr *CEY = DY->getCountExpr();
14827 DX->isCountInBytes(), DX->isOrNull(),
14838 DX->isCountInBytes(), DX->isOrNull(),
14841 case Type::PredefinedSugar:
14846 llvm_unreachable(
"Unhandled Type Class");
14868 if (
X.isCanonical())
14895 bool KeepCommonQualifiers =
14898 if (SX.
Ty != SY.Ty) {
14906 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
14909 SX = Xs.pop_back_val();
14910 SY = Ys.pop_back_val();
14913 if (KeepCommonQualifiers)
14920 while (!Xs.empty() && !Ys.empty()) {
14923 SX = Xs.pop_back_val();
14924 SY = Ys.pop_back_val();
14929 SX.
Ty = Underlying.Ty;
14932 QX -= Underlying.Quals;
14950 llvm_unreachable(
"Not a saturated fixed point type!");
14951 case BuiltinType::SatShortAccum:
14953 case BuiltinType::SatAccum:
14955 case BuiltinType::SatLongAccum:
14957 case BuiltinType::SatUShortAccum:
14959 case BuiltinType::SatUAccum:
14961 case BuiltinType::SatULongAccum:
14963 case BuiltinType::SatShortFract:
14965 case BuiltinType::SatFract:
14967 case BuiltinType::SatLongFract:
14969 case BuiltinType::SatUShortFract:
14971 case BuiltinType::SatUFract:
14973 case BuiltinType::SatULongFract:
14985 llvm_unreachable(
"Not a fixed point type!");
14986 case BuiltinType::ShortAccum:
14988 case BuiltinType::Accum:
14990 case BuiltinType::LongAccum:
14992 case BuiltinType::UShortAccum:
14994 case BuiltinType::UAccum:
14996 case BuiltinType::ULongAccum:
14998 case BuiltinType::ShortFract:
15000 case BuiltinType::Fract:
15002 case BuiltinType::LongFract:
15004 case BuiltinType::UShortFract:
15006 case BuiltinType::UFract:
15008 case BuiltinType::ULongFract:
15014 if (LangOpts.OpenCL)
15038 llvm_unreachable(
"Not a fixed point type!");
15039 case BuiltinType::ShortAccum:
15040 case BuiltinType::SatShortAccum:
15041 return Target.getShortAccumScale();
15042 case BuiltinType::Accum:
15043 case BuiltinType::SatAccum:
15044 return Target.getAccumScale();
15045 case BuiltinType::LongAccum:
15046 case BuiltinType::SatLongAccum:
15047 return Target.getLongAccumScale();
15048 case BuiltinType::UShortAccum:
15049 case BuiltinType::SatUShortAccum:
15050 return Target.getUnsignedShortAccumScale();
15051 case BuiltinType::UAccum:
15052 case BuiltinType::SatUAccum:
15053 return Target.getUnsignedAccumScale();
15054 case BuiltinType::ULongAccum:
15055 case BuiltinType::SatULongAccum:
15056 return Target.getUnsignedLongAccumScale();
15057 case BuiltinType::ShortFract:
15058 case BuiltinType::SatShortFract:
15059 return Target.getShortFractScale();
15060 case BuiltinType::Fract:
15061 case BuiltinType::SatFract:
15062 return Target.getFractScale();
15063 case BuiltinType::LongFract:
15064 case BuiltinType::SatLongFract:
15065 return Target.getLongFractScale();
15066 case BuiltinType::UShortFract:
15067 case BuiltinType::SatUShortFract:
15068 return Target.getUnsignedShortFractScale();
15069 case BuiltinType::UFract:
15070 case BuiltinType::SatUFract:
15071 return Target.getUnsignedFractScale();
15072 case BuiltinType::ULongFract:
15073 case BuiltinType::SatULongFract:
15074 return Target.getUnsignedLongFractScale();
15084 llvm_unreachable(
"Not a fixed point type!");
15085 case BuiltinType::ShortAccum:
15086 case BuiltinType::SatShortAccum:
15087 return Target.getShortAccumIBits();
15088 case BuiltinType::Accum:
15089 case BuiltinType::SatAccum:
15090 return Target.getAccumIBits();
15091 case BuiltinType::LongAccum:
15092 case BuiltinType::SatLongAccum:
15093 return Target.getLongAccumIBits();
15094 case BuiltinType::UShortAccum:
15095 case BuiltinType::SatUShortAccum:
15096 return Target.getUnsignedShortAccumIBits();
15097 case BuiltinType::UAccum:
15098 case BuiltinType::SatUAccum:
15099 return Target.getUnsignedAccumIBits();
15100 case BuiltinType::ULongAccum:
15101 case BuiltinType::SatULongAccum:
15102 return Target.getUnsignedLongAccumIBits();
15103 case BuiltinType::ShortFract:
15104 case BuiltinType::SatShortFract:
15105 case BuiltinType::Fract:
15106 case BuiltinType::SatFract:
15107 case BuiltinType::LongFract:
15108 case BuiltinType::SatLongFract:
15109 case BuiltinType::UShortFract:
15110 case BuiltinType::SatUShortFract:
15111 case BuiltinType::UFract:
15112 case BuiltinType::SatUFract:
15113 case BuiltinType::ULongFract:
15114 case BuiltinType::SatULongFract:
15119llvm::FixedPointSemantics
15122 "Can only get the fixed point semantics for a "
15123 "fixed point or integer type.");
15125 return llvm::FixedPointSemantics::GetIntegerSemantics(
15129 return llvm::FixedPointSemantics(
15132 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
15147 "Expected unsigned fixed point type");
15150 case BuiltinType::UShortAccum:
15152 case BuiltinType::UAccum:
15154 case BuiltinType::ULongAccum:
15156 case BuiltinType::SatUShortAccum:
15158 case BuiltinType::SatUAccum:
15160 case BuiltinType::SatULongAccum:
15162 case BuiltinType::UShortFract:
15164 case BuiltinType::UFract:
15166 case BuiltinType::ULongFract:
15168 case BuiltinType::SatUShortFract:
15170 case BuiltinType::SatUFract:
15172 case BuiltinType::SatULongFract:
15175 llvm_unreachable(
"Unexpected unsigned fixed point type");
15183 std::vector<std::string> BackendFeats;
15184 llvm::AArch64::ExtensionSet FeatureBits;
15185 for (StringRef F : FMVFeatStrings)
15186 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
15188 FeatureBits.enable(*FMVExt->ID);
15189 FeatureBits.toLLVMFeatureList(BackendFeats);
15190 return BackendFeats;
15195 assert(TD !=
nullptr);
15198 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
15199 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
15210 Target->getTargetOpts().CPU,
15211 Target->getTargetOpts().Features);
15218 StringRef TargetCPU = Target->getTargetOpts().CPU;
15220 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
15226 if (!Target->getTriple().isAArch64())
15229 Target->getTargetOpts().FeaturesAsWritten.begin(),
15230 Target->getTargetOpts().FeaturesAsWritten.end());
15241 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
15243 Target->getCPUSpecificCPUDispatchFeatures(
15245 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
15246 Features.insert(Features.begin(),
15247 Target->getTargetOpts().FeaturesAsWritten.begin(),
15248 Target->getTargetOpts().FeaturesAsWritten.end());
15249 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15250 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
15251 if (Target->getTriple().isAArch64()) {
15255 Features.insert(Features.begin(),
15256 Target->getTargetOpts().FeaturesAsWritten.begin(),
15257 Target->getTargetOpts().FeaturesAsWritten.end());
15258 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15259 }
else if (Target->getTriple().isRISCV()) {
15261 std::vector<std::string> Features;
15262 if (VersionStr !=
"default") {
15264 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15267 Features.insert(Features.begin(),
15268 Target->getTargetOpts().FeaturesAsWritten.begin(),
15269 Target->getTargetOpts().FeaturesAsWritten.end());
15270 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15271 }
else if (Target->getTriple().isOSAIX()) {
15272 std::vector<std::string> Features;
15274 if (VersionStr.starts_with(
"cpu="))
15275 TargetCPU = VersionStr.drop_front(
sizeof(
"cpu=") - 1);
15277 assert(VersionStr ==
"default");
15278 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15280 std::vector<std::string> Features;
15282 if (VersionStr.starts_with(
"arch="))
15283 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
15284 else if (VersionStr !=
"default")
15285 Features.push_back((StringRef{
"+"} + VersionStr).str());
15286 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15288 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
15289 std::vector<std::string> Features;
15290 if (Target->getTriple().isRISCV()) {
15292 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15295 assert(Target->getTriple().isAArch64());
15297 TV->getFeatures(Feats);
15300 Features.insert(Features.begin(),
15301 Target->getTargetOpts().FeaturesAsWritten.begin(),
15302 Target->getTargetOpts().FeaturesAsWritten.end());
15303 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15305 FeatureMap = Target->getTargetOpts().FeatureMap;
15316 auto DeviceDiscriminatorOverrider =
15318 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15320 return RD->getDeviceLambdaManglingNumber();
15321 return std::nullopt;
15324 Context, Context.getDiagnostics(), DeviceDiscriminatorOverrider)};
15332 std::string Buffer;
15333 Buffer.reserve(128);
15334 llvm::raw_string_ostream Out(Buffer);
15335 MC->mangleCanonicalTypeName(KernelNameType, Out);
15336 std::string KernelName = Out.str();
15338 return {KernelNameType, FD, KernelName};
15347 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15348 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15357 "SYCL kernel name conflict");
15372 return &IT->second;
15378 return *OMPTraitInfoVector.back();
15385 return DB << Section.
Decl;
15386 return DB <<
"a prior #pragma section";
15390 bool IsInternalVar =
15393 bool IsExplicitDeviceVar = (D->
hasAttr<CUDADeviceAttr>() &&
15394 !D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15395 (D->
hasAttr<CUDAConstantAttr>() &&
15396 !D->
getAttr<CUDAConstantAttr>()->isImplicit());
15400 return (IsInternalVar &&
15401 (D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15402 (D->
hasAttr<CUDAGlobalAttr>() &&
15409 (D->
hasAttr<HIPManagedAttr>() || D->
hasAttr<CUDAGlobalAttr>() ||
15414 if (!CUIDHash.empty())
15416 if (LangOpts.CUID.empty())
15417 return StringRef();
15418 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.CUID),
true);
15428 assert(PrimaryBase);
15431 auto Base = Layout.getPrimaryBase();
15432 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15434 PrimaryBase =
Base;
15436 return PrimaryBase;
15440 StringRef MangledName) {
15442 assert(
Method->isVirtual());
15443 bool DefaultIncludesPointerAuth =
15444 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15446 if (!DefaultIncludesPointerAuth)
15449 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15450 if (Existing != ThunksToBeAbbreviated.end())
15451 return Existing->second.contains(MangledName.str());
15454 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15456 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15458 for (
const auto &Thunk : *ThunkInfos) {
15460 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15466 Mangler->mangleThunk(
Method, Thunk,
true,
15469 llvm::raw_svector_ostream mangledNameStream(MangledName);
15473 mangledNameStream);
15475 Mangler->mangleThunk(
Method, Thunk,
false,
15476 mangledNameStream);
15478 Thunks[ElidedName].push_back(std::string(MangledName));
15481 llvm::StringSet<> SimplifiedThunkNames;
15482 for (
auto &ThunkList : Thunks) {
15483 llvm::sort(ThunkList.second);
15484 SimplifiedThunkNames.insert(ThunkList.second[0]);
15486 bool Result = SimplifiedThunkNames.contains(MangledName);
15487 ThunksToBeAbbreviated[VirtualMethodDecl] = std::move(SimplifiedThunkNames);
15505 std::vector<PFPField> &Fields,
bool IncludeVBases) {
15507 if (
auto *ElemDecl = AT->getElementType()->getAsCXXRecordDecl()) {
15509 for (
unsigned i = 0; i != AT->getSize(); ++i)
15526 Fields.push_back({FieldOffset, Field});
15533 if (
Base.isVirtual())
15540 if (IncludeVBases) {
15551 std::vector<PFPField> PFPFields;
15561 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->
getParent()))
15563 !FD->
hasAttr<NoFieldProtectionAttr>();
15568 auto *FD = dyn_cast<FieldDecl>(VD);
This file provides AST data structures related to concepts.
static void SortAndUniqueProtocols(SmallVectorImpl< ObjCProtocolDecl * > &Protocols)
static bool isCanonicalExceptionSpecification(const FunctionProtoType::ExceptionSpecInfo &ESI, bool NoexceptInType)
static SourceLocation getCommonAttrLoc(const T *X, const T *Y)
static auto getCanonicalTemplateArguments(const ASTContext &C, ArrayRef< TemplateArgument > Args, bool &AnyNonCanonArgs)
static char getObjCEncodingForPrimitiveType(const ASTContext *C, const BuiltinType *BT)
static bool isSameQualifier(const NestedNameSpecifier X, const NestedNameSpecifier Y)
static bool unionHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static TypedefDecl * CreateHexagonBuiltinVaListDecl(const ASTContext *Context)
#define CANONICAL_TYPE(Class)
static ElaboratedTypeKeyword getCommonTypeKeyword(const T *X, const T *Y, bool IsSame)
static Decl * getCommonDecl(Decl *X, Decl *Y)
static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context, const Decl *D, GVALinkage L)
static bool isTypeTypedefedAsBOOL(QualType T)
static void EncodeBitField(const ASTContext *Ctx, std::string &S, QualType T, const FieldDecl *FD)
static GVALinkage basicGVALinkageForVariable(const ASTContext &Context, const VarDecl *VD)
static QualType getCommonArrayElementType(const ASTContext &Ctx, const T *X, Qualifiers &QX, const T *Y, Qualifiers &QY)
#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 TemplateName getCommonTemplateName(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced=false)
static int CmpProtocolNames(ObjCProtocolDecl *const *LHS, ObjCProtocolDecl *const *RHS)
CmpProtocolNames - Comparison predicate for sorting protocols alphabetically.
static auto * getCommonSizeExpr(const ASTContext &Ctx, T *X, T *Y)
static TypedefDecl * CreatePowerABIBuiltinVaListDecl(const ASTContext *Context)
static auto getCommonSizeModifier(const ArrayType *X, const ArrayType *Y)
static TemplateArgument getCommonTemplateArgument(const ASTContext &Ctx, const TemplateArgument &X, const TemplateArgument &Y)
static std::optional< int64_t > structHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static bool hasSameOverloadableAttrs(const FunctionDecl *A, const FunctionDecl *B)
Determine whether the attributes we can overload on are identical for A and B.
static T * getCommonDeclChecked(T *X, T *Y)
static NestedNameSpecifier getCommonNNS(const ASTContext &Ctx, NestedNameSpecifier NNS1, NestedNameSpecifier NNS2, bool IsSame)
Returns a NestedNameSpecifier which has only the common sugar present in both NNS1 and NNS2.
static TypedefDecl * CreateVoidPtrBuiltinVaListDecl(const ASTContext *Context)
static int64_t getSubobjectOffset(const FieldDecl *Field, const ASTContext &Context, const clang::ASTRecordLayout &)
static QualType getCommonSugarTypeNode(const ASTContext &Ctx, const Type *X, const Type *Y, SplitQualType Underlying)
static TypedefDecl * CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X, Qualifiers &QX, const Type *Y, Qualifiers &QY)
static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET, QualType other, bool isBlockReturnType)
Given that we have an enum type and a non-enum type, try to merge them.
static GVALinkage adjustGVALinkageForExternalDefinitionKind(const ASTContext &Ctx, const Decl *D, GVALinkage L)
Adjust the GVALinkage for a declaration based on what an external AST source knows about whether ther...
static TypedefDecl * CreateSystemZBuiltinVaListDecl(const ASTContext *Context)
static std::optional< int64_t > getSubobjectSizeInBits(const FieldDecl *Field, const ASTContext &Context, bool CheckIfTriviallyCopyable)
static GVALinkage basicGVALinkageForFunction(const ASTContext &Context, const FunctionDecl *FD)
#define NON_UNIQUE_TYPE(Class)
static TypedefDecl * CreateX86_64ABIBuiltinVaListDecl(const ASTContext *Context)
static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI, const LangOptions &LangOpts)
static ElaboratedTypeKeyword getCanonicalElaboratedTypeKeyword(ElaboratedTypeKeyword Keyword)
static QualType getCommonPointeeType(const ASTContext &Ctx, const T *X, const T *Y)
static auto getCommonIndexTypeCVRQualifiers(const ArrayType *X, const ArrayType *Y)
static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequiresICE, bool AllowTypeModifiers)
DecodeTypeFromStr - This decodes one type descriptor from Str, advancing the pointer over the consume...
static TypedefDecl * CreateCharPtrBuiltinVaListDecl(const ASTContext *Context)
static bool areSortedAndUniqued(ArrayRef< ObjCProtocolDecl * > Protocols)
static TypeInfoChars getConstantArrayInfoInChars(const ASTContext &Context, const ConstantArrayType *CAT)
getConstantArrayInfoInChars - Performing the computation in CharUnits instead of in bits prevents ove...
static FloatingRank getFloatingRank(QualType T)
getFloatingRank - Return a relative rank for floating point types.
static bool getCommonTemplateArguments(const ASTContext &Ctx, SmallVectorImpl< TemplateArgument > &R, ArrayRef< TemplateArgument > Xs, ArrayRef< TemplateArgument > Ys)
static TypedefDecl * CreateXtensaABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonElementType(const ASTContext &Ctx, const T *X, const T *Y)
static void mergeTypeLists(const ASTContext &Ctx, SmallVectorImpl< QualType > &Out, ArrayRef< QualType > X, ArrayRef< QualType > Y)
static bool matchesPostDecrInWhile(const UnaryOperator *UO, ASTContext &Ctx)
For the purposes of overflow pattern exclusion, does this match the while(i–) pattern?
static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx, raw_ostream &OS, QualType QT)
Encode a function type for use in the discriminator of a function pointer type.
static std::optional< int64_t > structSubobjectsHaveUniqueObjectRepresentations(const RangeT &Subobjects, int64_t CurOffsetInBits, const ASTContext &Context, const clang::ASTRecordLayout &Layout, bool CheckIfTriviallyCopyable)
static uint64_t getRVVTypeSize(ASTContext &Context, const BuiltinType *Ty)
getRVVTypeSize - Return RVV vector register size.
static auto unwrapSugar(SplitQualType &T, Qualifiers &QTotal)
static TemplateName getCommonTemplateNameChecked(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced)
static int compareObjCProtocolsByName(ObjCProtocolDecl *const *lhs, ObjCProtocolDecl *const *rhs)
Comparison routine for Objective-C protocols to be used with llvm::array_pod_sort.
static 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 QualType getCommonTypeWithQualifierLifting(const ASTContext &Ctx, QualType X, QualType Y, Qualifiers &QX, Qualifiers &QY)
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.
static StringRef getTriple(const Command &Job)
Defines types useful for describing an Objective-C runtime.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
static QualType getUnderlyingType(const SubRegion *R)
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
__device__ __2f16 float c
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
RawComment * getRawCommentForDeclNoCacheImpl(const Decl *D, const SourceLocation RepresentativeLocForDecl, const std::map< unsigned, RawComment * > &CommentsInFile) const
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
bool isMemberPointerToDerivedMember() const
const ValueDecl * getMemberPointerDecl() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const
Returns true, if given type has a known lifetime.
MSGuidDecl * getMSGuidDecl(MSGuidDeclParts Parts) const
Return a declaration for the global GUID object representing the given GUID value.
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl, const ObjCMethodDecl *MethodImp)
CanQualType ObjCBuiltinSelTy
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
void InitBuiltinTypes(const TargetInfo &Target, const TargetInfo *AuxTarget=nullptr)
Initialize built-in types.
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
MemberSpecializationInfo * getInstantiatedFromStaticDataMember(const VarDecl *Var)
If this variable is an instantiated static data member of a class template specialization,...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
CanQualType ARCUnbridgedCastTy
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, QualType Wrapped) const
llvm::DenseMap< const Decl *, comments::FullComment * > ParsedComments
Mapping from declarations to parsed comments attached to any redeclaration.
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
unsigned getIntWidth(QualType T) const
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
InlineVariableDefinitionKind
@ None
Not an inline variable.
@ Weak
Weak definition of inline variable.
@ Strong
Strong definition.
@ WeakUnknown
Weak for now, might become strong later in this TU.
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
TypedefDecl * getCFConstantStringDecl() const
CanQualType SatUnsignedFractTy
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
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.
bool isPFPField(const FieldDecl *Field) const
QualType adjustFunctionResultType(QualType FunctionType, QualType NewResultType)
Change the result type of a function type, preserving sugar such as attributed types.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
QualType getCanonicalTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type.
bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool AllowCXX=false, bool IsConditionalOperator=false)
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
CharUnits getObjCEncodingTypeSize(QualType T) const
Return the size of type T for Objective-C encoding purpose, in characters.
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
const TemplateArgument * getDefaultTemplateArgumentOrNone(const NamedDecl *P) const
Return the default argument of a template parameter, if one exists.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
void setCurrentNamedModule(Module *M)
Set the (C++20) module we are building.
QualType getProcessIDType() const
Return the unique type for "pid_t" defined in <sys/types.h>.
CharUnits getMemberPointerPathAdjustment(const APValue &MP) const
Find the 'this' offset for the member path in a pointer-to-member APValue.
bool mayExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel may be externalized.
std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
bool hasSameExpr(const Expr *X, const Expr *Y) const
Determine whether the given expressions X and Y are equivalent.
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
unsigned getTypeUnadjustedAlign(QualType T) const
Return the ABI-specified natural alignment of a (complete) type T, before alignment adjustments,...
unsigned char getFixedPointIBits(QualType Ty) const
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes, bool OrNull, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
bool ObjCQualifiedClassTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS)
ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and Class<pr1, ...>.
bool shouldExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel should be externalized.
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type.
CanQualType SatLongAccumTy
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
OpenCLTypeKind getOpenCLTypeKind(const Type *T) const
Map an AST Type to an OpenCLTypeKind enum value.
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const
Put the string version of the type qualifiers QT into S.
unsigned getPreferredTypeAlign(QualType T) const
Return the "preferred" alignment of the specified type T for the current target, in bits.
std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, bool Extended=false) const
Emit the encoded type for the method declaration Decl into S.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
CanQualType OMPArrayShapingTy
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
std::string getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
getObjCEncodingForPropertyDecl - Return the encoded type for this method declaration.
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
unsigned getStaticLocalNumber(const VarDecl *VD) const
void addComment(const RawComment &RC)
void getLegacyIntegralTypeEncoding(QualType &t) const
getLegacyIntegralTypeEncoding - Another legacy compatibility encoding: 32-bit longs are encoded as 'l...
bool isSameTypeConstraint(const TypeConstraint *XTC, const TypeConstraint *YTC) const
Determine whether two type contraint are similar enough that they could used in declarations of the s...
void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo)
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=RecordDecl::TagKind::Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
CanQualType UnsignedLongFractTy
QualType mergeTagDefinitions(QualType, QualType)
void setClassMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
void setIsTypeAwareOperatorNewOrDelete(const FunctionDecl *FD, bool IsTypeAware)
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const
Return a dependent bit-precise integer type with the specified signedness and bit count.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
StringRef getCUIDHash() const
bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const
Returns true if this is an inline-initialized static data member which is treated as a definition for...
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const
Determine whether two function types are the same, ignoring exception specifications in cases where t...
QualType getBlockDescriptorExtendedType() const
Gets the struct used to keep track of the extended descriptor for pointer to blocks.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent) const
void addLazyModuleInitializers(Module *M, ArrayRef< GlobalDeclID > IDs)
bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
QualType getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
std::optional< QualType > tryMergeOverflowBehaviorTypes(QualType LHS, QualType RHS, bool OfBlockPointer, bool Unqualified, bool BlockReturnType, bool IsConditionalOperator)
Attempts to merge two types that may be OverflowBehaviorTypes.
CanQualType OMPIteratorTy
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
SelectorTable & Selectors
bool isTypeIgnoredBySanitizer(const SanitizerMask &Mask, const QualType &Ty) const
Check if a type can have its sanitizer instrumentation elided based on its presence within an ignorel...
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const
Return the minimum alignment as specified by the target.
RawCommentList Comments
All comments in this translation unit.
bool isSameDefaultTemplateArgument(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two default template arguments are similar enough that they may be used in declarat...
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType 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 getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::SetVector< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
CanQualType ArraySectionTy
CanQualType ObjCBuiltinIdTy
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const
ObjCPropertyImplDecl * getObjCPropertyImplDeclForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
bool isNearlyEmpty(const CXXRecordDecl *RD) const
PointerAuthQualifier getObjCMemberSelTypePtrAuth()
void cacheRawCommentForDecl(const Decl &OriginalD, const RawComment &Comment) const
Attaches Comment to OriginalD and to its redeclaration chain and removes the redeclaration chain from...
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.
void eraseDeclAttrs(const Decl *D)
Erase the attributes corresponding to the given declaration.
UsingEnumDecl * getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst)
If the given using-enum decl Inst is an instantiation of another using-enum decl, return it.
RecordDecl * getCFConstantStringTagDecl() const
std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const
Emit the encoded type for the function Decl into S.
TypeSourceInfo * getTemplateSpecializationTypeInfo(ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Canon=QualType()) const
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
CanQualType UnsignedFractTy
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
QualType mergeFunctionParameterTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeFunctionParameterTypes - merge two types which appear as function parameter types
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
TemplateTemplateParmDecl * findCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *TTP) const
const TargetInfo * getAuxTargetInfo() const
CanQualType ObjCBuiltinClassTy
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
CanQualType UnresolvedTemplateTy
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
friend class CXXRecordDecl
CanQualType UnsignedLongTy
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized,...
bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits, unsigned NumPositiveBits, QualType &BestType, QualType &BestPromotionType)
Compute BestType and BestPromotionType for an enum based on the highest number of negative and positi...
llvm::APFixedPoint getFixedPointMin(QualType Ty) const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType adjustType(QualType OldType, llvm::function_ref< QualType(QualType)> Adjust) const
Rebuild a type, preserving any existing type sugar.
void addedLocalImportDecl(ImportDecl *Import)
Notify the AST context that a new import declaration has been parsed or implicitly created within thi...
const TranslationUnitKind TUKind
CanQualType UnsignedLongAccumTy
QualType AutoRRefDeductTy
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length.
QualType getCorrespondingSaturatedType(QualType Ty) const
bool arePFPFieldsTriviallyCopyable(const RecordDecl *RD) const
Returns whether this record's PFP fields (if any) are trivially copyable (i.e.
bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const
Determine whether the two declarations refer to the same entity.
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl, unsigned Index, bool Final, const TemplateArgument &ArgPack)
CanQualType BoundMemberTy
CanQualType SatUnsignedShortFractTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
bool hasSameFunctionTypeIgnoringParamABI(QualType T, QualType U) const
Determine if two function types are the same, ignoring parameter ABI annotations.
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
unsigned getOpenMPDefaultSimdAlign(QualType T) const
Get default simd alignment of the specified complete type in bits.
QualType getObjCSuperType() const
Returns the C struct type for objc_super.
QualType getBlockDescriptorType() const
Gets the struct used to keep track of the descriptor for pointer to blocks.
bool CommentsLoaded
True if comments are already loaded from ExternalASTSource.
BlockVarCopyInit getBlockVarCopyInit(const VarDecl *VD) const
Get the copy initialization expression of the VarDecl VD, or nullptr if none exists.
QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size, uint32_t Alignment, ArrayRef< SpirvOperand > Operands)
unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
bool isInSameModule(const Module *M1, const Module *M2) const
If the two module M1 and M2 are in the same module.
unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
CanQualType PseudoObjectTy
QualType getWebAssemblyExternrefType() const
Return a WebAssembly externref type.
void setTraversalScope(const std::vector< Decl * > &)
CharUnits getTypeUnadjustedAlignInChars(QualType T) const
getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, in characters,...
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
friend class NestedNameSpecifier
MangleContext * cudaNVInitDeviceMC()
unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const
Return the alignment in bits that should be given to a global variable with type T.
bool areCompatibleOverflowBehaviorTypes(QualType LHS, QualType RHS)
Return true if two OverflowBehaviorTypes are compatible for assignment.
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
MangleContext * createDeviceMangleContext(const TargetInfo &T)
Creates a device mangle context to correctly mangle lambdas in a mixed architecture compile by settin...
CharUnits getExnObjectAlignment() const
Return the alignment (in bytes) of the thrown exception object.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ASTMutationListener * Listener
CanQualType ObjCBuiltinBoolTy
TypeInfoChars getTypeInfoInChars(const Type *T) const
QualType getPredefinedSugarType(PredefinedSugarType::Kind KD) const
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
TemplateParamObjectDecl * getTemplateParamObjectDecl(QualType T, const APValue &V) const
Return the template parameter object of the given type with the given value.
interp::Context & getInterpContext() const
Returns the clang bytecode interpreter context.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
TemplateTemplateParmDecl * getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const
Canonicalize the given TemplateTemplateParmDecl.
CanQualType OCLClkEventTy
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
bool hasPFPFields(QualType Ty) const
const clang::PrintingPolicy & getPrintingPolicy() const
void ResetObjCLayout(const ObjCInterfaceDecl *D)
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
CharUnits getAlignOfGlobalVarInChars(QualType T, const VarDecl *VD) const
Return the alignment in characters that should be given to a global variable with type T.
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists.
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, UnsignedOrNone Index=std::nullopt) const
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getObjCIdType() const
Represents the Objective-CC id type.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
QualType getFunctionTypeWithoutParamABIs(QualType T) const
Get or construct a function type that is equivalent to the input type except that the parameter ABI a...
QualType getCorrespondingUnsaturatedType(QualType Ty) const
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl) const
unsigned getTargetDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
llvm::DenseMap< CanQualType, SYCLKernelInfo > SYCLKernels
Map of SYCL kernels indexed by the unique type used to name the kernel.
bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y) const
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
bool isDestroyingOperatorDelete(const FunctionDecl *FD) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
llvm::DenseMap< const Decl *, const RawComment * > DeclRawComments
Mapping from declaration to directly attached comment.
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
CanQualType UnsignedCharTy
CanQualType UnsignedShortFractTy
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
void * Allocate(size_t Size, unsigned Align=8) const
ArrayRef< ExplicitInstantiationDecl * > getExplicitInstantiationDecls(const NamedDecl *Spec) const
Get all ExplicitInstantiationDecls for a given specialization.
bool canBuiltinBeRedeclared(const FunctionDecl *) const
Return whether a declaration to a builtin is allowed to be overloaded/redeclared.
CanQualType UnsignedIntTy
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols) const
void getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT, QualType T, std::string &S, bool Extended) const
getObjCEncodingForMethodParameter - Return the encoded type for a single method parameter or return t...
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const
Return the encoded type for this block declaration.
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
bool isSameAssociatedConstraint(const AssociatedConstraint &ACX, const AssociatedConstraint &ACY) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
QualType getExceptionObjectType(QualType T) const
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Note that the static data member Inst is an instantiation of the static data member template Tmpl of ...
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl)
ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's protocol list adopt all protocols in Q...
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType OCLReserveIDTy
bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two template parameters are similar enough that they may be used in declarations of...
void registerSYCLEntryPointFunction(FunctionDecl *FD)
Generates and stores SYCL kernel metadata for the provided SYCL kernel entry point function.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
CanQualType UnsignedShortTy
FunctionDecl * getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
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 ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
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 classMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
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.
void recordOffsetOfEvaluation(const OffsetOfExpr *E)
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
QualType getUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D) const
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
void getOverriddenMethods(const NamedDecl *Method, SmallVectorImpl< const NamedDecl * > &Overridden) const
Return C++ or ObjC overridden methods for the given Method.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y, bool IgnoreDeduced=false) const
Determine whether the given template names refer to the same template.
CanQualType SatLongFractTy
const TargetInfo & getTargetInfo() const
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
OBTAssignResult checkOBTAssignmentCompatibility(QualType LHS, QualType RHS)
Check overflow behavior type compatibility for assignments.
CanQualType SatShortAccumTy
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
void addExplicitInstantiationDecl(const NamedDecl *Spec, ExplicitInstantiationDecl *EID)
Add an ExplicitInstantiationDecl for a given specialization.
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
CanQualType IncompleteMatrixIdxTy
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
CanQualType getNSIntegerType() const
QualType getCorrespondingUnsignedType(QualType T) const
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
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
std::vector< PFPField > findPFPFields(QualType Ty) const
Returns a list of PFP fields for the given type, including subfields in bases or other fields,...
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
void addTranslationUnitDecl()
void getObjCEncodingForPropertyType(QualType T, std::string &S) const
Emit the Objective-C property type encoding for the given type T into S.
unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
CollectInheritedProtocols - Collect all protocols in current class and those inherited by it.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
llvm::DenseMap< const Decl *, const Decl * > RedeclChainComments
Mapping from canonical declaration to the first redeclaration in chain that has a comment attached.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
std::optional< CXXRecordDeclRelocationInfo > getRelocationInfoForCXXRecord(const CXXRecordDecl *) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
InlineVariableDefinitionKind getInlineVariableDefinitionKind(const VarDecl *VD) const
Determine whether a definition of this inline variable should be treated as a weak or strong definiti...
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...
void addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, FunctionDecl *OperatorDelete, OperatorDeleteKind K) const
unsigned char getFixedPointScale(QualType Ty) const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
QualType DecodeTypeStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequireICE, bool AllowTypeModifiers) const
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
@ GE_Missing_type
Missing a type.
QualType adjustStringLiteralBaseType(QualType StrLTy) const
uint16_t getPointerAuthTypeDiscriminator(QualType T)
Return the "other" type-specific discriminator for the given type.
llvm::SetVector< const FieldDecl * > PFPFieldsWithEvaluatedOffset
bool canonicalizeTemplateArguments(MutableArrayRef< TemplateArgument > Args) const
Canonicalize the given template argument list.
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
bool isUnaryOverflowPatternExcluded(const UnaryOperator *UO)
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
TemplateName getDeducedTemplateName(TemplateName Underlying, DefaultArguments DefaultArgs) const
Represents a TemplateName which had some of its default arguments deduced.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
CanQualType UnsignedAccumTy
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
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.
QualType getDeducedTemplateSpecializationType(DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword, TemplateName Template) const
C++17 deduced class template specialization type.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
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)
void recordMemberDataPointerEvaluation(const ValueDecl *VD)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
virtual ~ASTMutationListener()
virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType)
A function's return type has been deduced.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
CharUnits getSize() const
getSize - Get the record size in characters.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding,...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
CharUnits getUnadjustedAlignment() const
getUnadjustedAlignment - Get the record alignment in characters, before alignment adjustment.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
void Profile(llvm::FoldingSetNodeID &ID)
Represents a loop initializing the elements of an array.
llvm::APInt getArraySize() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
A structure for storing the information associated with a name that has been assumed to be a template...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
void Profile(llvm::FoldingSetNodeID &ID)
Attr - This represents one attribute.
A fixed int type of a specified bitwidth.
void Profile(llvm::FoldingSetNodeID &ID) const
unsigned getNumBits() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
void Profile(llvm::FoldingSetNodeID &ID)
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
This class is used for builtin types like 'int'.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Implements C++ ABI-specific semantic analysis functions.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
CXXDestructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a static or instance method of a struct/union/class.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
CXXRecordDecl * getDefinition() const
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isDynamicClass() const
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
SplitQualType split() const
static CanQual< Type > CreateUnsafe(QualType Other)
QualType withConst() const
Retrieves a version of this type with const applied.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isPositive() const
isPositive - Test whether the quantity is greater than zero.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Complex values, per C99 6.2.5p11.
void Profile(llvm::FoldingSetNodeID &ID)
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Represents the canonical version of C arrays with a specified constant size.
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
void Profile(llvm::FoldingSetNodeID &ID)
unsigned getNumRows() const
Returns the number of rows in the matrix.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
Decl::Kind getDeclKind() const
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isModuleLocal() const
Whether this declaration was a local declaration to a C++20 named module.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl,...
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
static Decl * castFromDeclContext(const DeclContext *)
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
void setImplicit(bool I=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
DeclarationNameLoc - Additional source/type location info for a declaration name.
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc, SourceLocation EndLoc)
Construct location information for a non-literal C++ operator.
The name of a declaration.
static int compare(DeclarationName LHS, DeclarationName RHS)
Represents a ValueDecl that came out of a declarator.
TypeSourceInfo * getTypeSourceInfo() const
TemplateName getUnderlying() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
DefaultArguments getDefaultArguments() const
Represents an extended address space qualifier where the input address space value is dependent.
Expr * getAddrSpaceExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents an array type in C++ whose size is a value-dependent expression.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Expr * getSizeExpr() const
Represents an extended vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Expr * getRowExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a dependent template name that cannot be resolved prior to template instantiation.
void Profile(llvm::FoldingSetNodeID &ID) const
IdentifierOrOverloadedOperator getName() const
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
bool hasTemplateKeyword() const
Was this template name was preceeded by the template keyword?
Internal representation of canonical, dependent typeof(expr) types.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
A dynamically typed AST node container.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
bool isComplete() const
Returns true if this can be considered a complete type.
EnumDecl * getDefinitionOrSelf() const
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Represents an explicit instantiation of a template entity in source code.
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
We can encode up to four bits in the low bits of a type pointer, but there are many more type qualifi...
void Profile(llvm::FoldingSetNodeID &ID) const
ExtVectorType - Extended vector type.
Declaration context for names declared as extern "C" in C++.
static ExternCContextDecl * Create(const ASTContext &C, TranslationUnitDecl *TU)
Abstract interface for external sources of AST nodes.
virtual void CompleteRedeclChain(const Decl *D)
Gives the external AST source an opportunity to complete the redeclaration chain for a declaration.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
unsigned getBitWidthValue() const
Computes the bit width of this field, if this is a bit field.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool isMSExternInline() const
The combination of the extern and inline keywords under MSVC forces the function to be required.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
bool isInlineDefinitionExternallyVisible() const
For an inline function definition in C, or for a gnu_inline function in C++, determine whether the de...
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
SmallVector< Conflict > Conflicts
static FunctionEffectSet getIntersection(FunctionEffectsRef LHS, FunctionEffectsRef RHS)
static FunctionEffectSet getUnion(FunctionEffectsRef LHS, FunctionEffectsRef RHS, Conflicts &Errs)
An immutable set of FunctionEffects and possibly conditions attached to them.
ArrayRef< EffectConditionExpr > conditions() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
void Profile(llvm::FoldingSetNodeID &ID)
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
QualType getParamType(unsigned i) const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
CallingConv getCC() const
bool getNoCfCheck() const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
ExtInfo withNoReturn(bool noReturn) const
bool getHasRegParm() const
bool getProducesResult() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
ExtParameterInfo withIsNoEscape(bool NoEscape) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
QualType getReturnType() const
GlobalDecl - represents a global declaration.
unsigned getMultiVersionIndex() const
CXXDtorType getDtorType() const
const Decl * getDecl() const
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
StringRef getName() const
Return the actual identifier string.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Represents a C array with an unspecified size.
void Profile(llvm::FoldingSetNodeID &ID)
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
An lvalue reference type, per C++11 [dcl.ref].
@ Swift
Interoperability with the latest known version of the Swift runtime.
@ Swift4_2
Interoperability with the Swift 4.2 runtime.
@ Swift4_1
Interoperability with the Swift 4.1 runtime.
@ Integer
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
@ All
Permit vector bitcasts between all vectors with the same total bit-width.
@ PostDecrInWhile
while (count–)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::optional< TargetCXXABI::Kind > CXXABI
C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
clang::ObjCRuntime ObjCRuntime
CoreFoundationABI CFRuntime
bool isOverflowPatternExcluded(OverflowPatternExclusionKind Kind) const
static void Profile(llvm::FoldingSetNodeID &ID, Parts P)
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
static bool isValidElementType(QualType T, const LangOptions &LangOpts)
Valid elements types are the following:
QualType getElementType() const
Returns type of the elements being stored in the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
void Profile(llvm::FoldingSetNodeID &ID)
Provides information a specialization of a member of a class template, which may be a member function...
static MicrosoftMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
Describes a module or submodule.
bool isNamedModule() const
Does this Module is a named module of a standard named module?
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isPlaceholderVar(const LangOptions &LangOpts) const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
bool isExternallyVisible() const
Represent a C++ namespace.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested)
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NestedNameSpecifier getCanonical() const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
CXXRecordDecl * getAsMicrosoftSuper() const
NamespaceAndPrefix getAsNamespaceAndPrefix() const
const Type * getAsType() const
Kind
The kind of specifier that completes this nested name specifier.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
ObjCCategoryDecl - Represents a category declaration.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, const IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
bool hasDefinition() const
Determine whether this class has been defined.
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class,...
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
ObjCImplementationDecl * getImplementation() const
ObjCInterfaceDecl * getSuperClass() const
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
known_extensions_range known_extensions() const
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCIvarDecl * getNextIvar()
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCDeclQualifier getObjCDeclQualifier() const
unsigned param_size() const
param_const_iterator param_end() const
param_const_iterator param_begin() const
const ParmVarDecl *const * param_const_iterator
Selector getSelector() const
bool isInstanceMethod() const
QualType getReturnType() const
Represents a pointer to an Objective C object.
bool isObjCQualifiedClassType() const
True if this is equivalent to 'Class.
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
void Profile(llvm::FoldingSetNodeID &ID)
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
Represents one property declaration in an Objective-C interface.
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
SetterKind getSetterKind() const
getSetterKind - Return the method used for doing assignment in the property setter.
Selector getSetterName() const
Selector getGetterName() const
ObjCPropertyAttribute::Kind getPropertyAttributes() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
ObjCIvarDecl * getPropertyIvarDecl() const
Represents an Objective-C protocol declaration.
protocol_range protocols() const
bool isGNUFamily() const
Is this runtime basically of the GNU family of runtimes?
Represents the declaration of an Objective-C type parameter.
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
const OffsetOfNode & getComponent(unsigned Idx) const
unsigned getNumComponents() const
Helper class for OffsetOfExpr.
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
Sugar for parentheses used when specifying types.
void Profile(llvm::FoldingSetNodeID &ID)
void clear()
Clear parent maps.
DynTypedNodeList getParents(const NodeT &Node)
Returns the parents of the given node (within the traversal scope).
Represents a parameter to a function.
ObjCDeclQualifier getObjCDeclQualifier() const
QualType getOriginalType() const
ParsedAttr - Represents a syntactic attribute.
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.
QualType getNonPackExpansionType() const
Remove an outer pack expansion type (if any) from this type.
bool isConstQualified() const
Determine whether this type is const-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
const Type * getTypePtrOrNull() const
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Represents a template name as written in source code.
void Profile(llvm::FoldingSetNodeID &ID)
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void removeCVRQualifiers(unsigned mask)
void addAddressSpace(LangAS space)
static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
Returns the common set of qualifiers while removing them from the given sets.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
void removeFastQualifiers(unsigned mask)
bool hasUnaligned() const
bool hasAddressSpace() const
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
unsigned getFastQualifiers() const
void removeAddressSpace()
PointerAuthQualifier getPointerAuth() const
bool hasObjCGCAttr() const
uint64_t getAsOpaqueValue() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
void addObjCGCAttr(GC type)
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
bool hasFlexibleArrayMember() const
field_range fields() const
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
RecordDecl * getMostRecentDecl()
virtual void completeDefinition()
Note that the definition of this type is now complete.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
void Profile(llvm::FoldingSetNodeID &ID)
This table allows us to fully hide how we implement multi-keyword caching.
std::string getAsString() const
Derive the full selector name (e.g.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
StringLiteral - This represents a string literal expression, e.g.
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
A structure for storing an already-substituted template template parameter pack.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context)
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
A structure for storing the information associated with a substituted template template parameter.
void Profile(llvm::FoldingSetNodeID &ID)
TemplateTemplateParmDecl * getParameter() const
Represents the declaration of a struct/union/class/enum.
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TagKind getTagKind() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Kind
The basic C++ ABI kind.
static Kind getKind(StringRef Name)
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
unsigned getMaxAtomicInlineWidth() const
Return the maximum width lock-free atomic operation which can be inlined given the supported features...
virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
unsigned getDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
@ AArch64ABIBuiltinVaList
__builtin_va_list as defined by the AArch64 ABI http://infocenter.arm.com/help/topic/com....
@ PowerABIBuiltinVaList
__builtin_va_list as defined by the Power ABI: https://www.power.org /resources/downloads/Power-Arch-...
@ AAPCSABIBuiltinVaList
__builtin_va_list as defined by ARM AAPCS ABI http://infocenter.arm.com
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
@ X86_64ABIBuiltinVaList
__builtin_va_list as defined by the x86-64 ABI: http://refspecs.linuxbase.org/elf/x86_64-abi-0....
virtual uint64_t getNullPointerValue(LangAS AddrSpace) const
Get integer value for null pointer.
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
IntType getPtrDiffType(LangAS AddrSpace) const
IntType getSizeType() const
FloatModeKind getRealTypeByWidth(unsigned BitWidth, FloatModeKind ExplicitType) const
Return floating point type with specified width.
virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return integer type with specified width.
unsigned getMaxAlignedAttribute() const
Get the maximum alignment in bits for a static variable with aligned attribute.
virtual unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
unsigned getTargetAddressSpace(LangAS AS) const
IntType getSignedSizeType() const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool useAddressSpaceMapMangling() const
Specify if mangling based on address space map should be used or not for language specific address sp...
A convenient class for passing around template argument information.
ArrayRef< TemplateArgumentLoc > arguments() const
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
UnsignedOrNone getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DeducedTemplateStorage * getAsDeducedTemplateName() const
Retrieve the deduced template info, if any.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
std::optional< TemplateName > desugar(bool IgnoreDeduced) const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
A template parameter object.
static void Profile(llvm::FoldingSetNodeID &ID, QualType T, const APValue &V)
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
ArrayRef< NamedDecl * > asArray()
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TemplateNameKind templateParameterKind() const
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Declaration of a template type parameter.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
TemplateDecl * getNamedConcept() const
ConceptReference * getConceptReference() const
Represents a declaration of a type.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location.
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
The base class of the type hierarchy.
bool isBlockPointerType() const
bool isObjCBuiltinType() const
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isFloat16Type() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
bool isPointerType() const
TagDecl * castAsTagDecl() const
bool isArrayParameterType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isSignedFixedPointType() const
Return true if this is a fixed point type that is signed according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isEnumeralType() const
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isSaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
QualType getCanonicalTypeInternal() const
@ PtrdiffT
The "ptrdiff_t" type.
@ SizeT
The "size_t" type.
@ SignedSizeT
The signed integer type corresponding to "size_t".
bool isObjCIdType() const
bool isOverflowBehaviorType() const
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...
bool isAnyPointerType() const
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isRecordType() const
bool isObjCRetainableType() const
NullabilityKindOrNone getNullability() const
Determine the nullability of the given type.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType Underlying)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
static void Profile(llvm::FoldingSetNodeID &ID, QualType Ty, const APValue &APVal)
The iterator over UnresolvedSets.
Represents the dependent type named by a dependently-scoped typename using declaration,...
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D)
Represents a dependent using declaration which was marked with typename.
UnresolvedUsingTypenameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Represents a C++ using-enum-declaration.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
bool isStaticDataMember() const
Determines whether this is a static data member.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
bool isInline() const
Whether this variable is (C++1z) inline.
@ DeclarationOnly
This declaration is only a declaration.
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
void Profile(llvm::FoldingSetNodeID &ID)
VectorKind getVectorKind() const
QualType getElementType() const
Holds all information required to evaluate constexpr code in a module.
Defines the Linkage enumeration and various utility functions.
Defines the clang::TargetInfo interface.
mlir::Type getBaseType(mlir::Value varPtr)
const AstTypeMatcher< TagType > tagType
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
GVALinkage
A more specific kind of linkage than enum Linkage.
@ GVA_AvailableExternally
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
OpenCLTypeKind
OpenCL type kinds.
FunctionType::ExtInfo getFunctionExtInfo(const Type &t)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
@ ICIS_NoInit
No in-class initializer.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
std::pair< FileID, unsigned > FileIDAndOffset
CXXABI * CreateMicrosoftCXXABI(ASTContext &Ctx)
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
TypeOfKind
The kind of 'typeof' expression we're after.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
CXXABI * CreateItaniumCXXABI(ASTContext &Ctx)
Creates an instance of a C++ ABI class.
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.
OptionalUnsigned< unsigned > UnsignedOrNone
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
constexpr uint16_t SelPointerConstantDiscriminator
Constant discriminator to be used with objective-c sel pointers.
bool isDiscardableGVALinkage(GVALinkage L)
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
@ Keyword
The name has been typo-corrected to a keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
TranslationUnitKind
Describes the kind of translation unit being processed.
@ Deduced
The normal deduced case.
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
@ DeducedAsPack
Same as above, but additionally this represents a case where the deduced entity itself is a pack.
const Decl & adjustDeclToTemplate(const Decl &D)
If we have a 'templated' declaration for a template, adjust 'D' to refer to the actual template.
bool isPtrSizeAddressSpace(LangAS AS)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ Invariant
The parameter is invariant: must match exactly.
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
@ AltiVecBool
is AltiVec 'vector bool ...'
@ SveFixedLengthData
is AArch64 SVE fixed-length data vector
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ Generic
not a target-specific vector type
@ RVVFixedLengthData
is RISC-V RVV fixed-length data vector
@ RVVFixedLengthMask
is RISC-V RVV fixed-length mask vector
@ SveFixedLengthPredicate
is AArch64 SVE fixed-length predicate vector
U cast(CodeGen::Address addr)
LangAS getLangASFromTargetAS(unsigned TargetAS)
@ None
The alignment was not explicit in code.
@ RequiredByEnum
The alignment comes from an alignment attribute on a enum type.
@ RequiredByTypedef
The alignment comes from an alignment attribute on a typedef.
@ RequiredByRecord
The alignment comes from an alignment attribute on a record type.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
const Expr * ConstraintExpr
UnsignedOrNone ArgPackSubstIndex
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Expr * getCopyExpr() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
ArrayRef< TemplateArgument > Args
Holds information about the various types of exception specification.
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
bool requiresFunctionProtoTypeArmAttributes() const
FunctionEffectsRef FunctionEffects
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
bool requiresFunctionProtoTypeExtraAttributeInfo() const
unsigned HasTrailingReturn
bool requiresFunctionProtoTypeExtraBitfields() const
FunctionType::ExtInfo ExtInfo
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
A lazy value (of type T) that is within an AST node of type Owner, where the value might change in la...
Contains information gathered from parsing the contents of TargetAttr.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
Store declaration pairs already found to be non-equivalent.
bool IsEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
A this pointer adjustment.
IntType
===-— Target Data Type Query Methods ----------------------------—===//
AlignRequirementKind AlignRequirement
AlignRequirementKind AlignRequirement