71#include "llvm/ADT/APFixedPoint.h"
72#include "llvm/ADT/APInt.h"
73#include "llvm/ADT/APSInt.h"
74#include "llvm/ADT/ArrayRef.h"
75#include "llvm/ADT/DenseMap.h"
76#include "llvm/ADT/DenseSet.h"
77#include "llvm/ADT/FoldingSet.h"
78#include "llvm/ADT/PointerUnion.h"
79#include "llvm/ADT/STLExtras.h"
80#include "llvm/ADT/SmallPtrSet.h"
81#include "llvm/ADT/SmallVector.h"
82#include "llvm/ADT/StringExtras.h"
83#include "llvm/ADT/StringRef.h"
84#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
85#include "llvm/Support/Capacity.h"
86#include "llvm/Support/Casting.h"
87#include "llvm/Support/Compiler.h"
88#include "llvm/Support/ErrorHandling.h"
89#include "llvm/Support/MD5.h"
90#include "llvm/Support/MathExtras.h"
91#include "llvm/Support/SipHash.h"
92#include "llvm/Support/raw_ostream.h"
93#include "llvm/TargetParser/AArch64TargetParser.h"
94#include "llvm/TargetParser/RISCVTargetParser.h"
95#include "llvm/TargetParser/Triple.h"
108using namespace clang;
126 if (
const auto *MI = dyn_cast<const MacroInfo *>(Key)) {
140 StringRef Buffer = SourceMgr.getBufferData(Decomposed.first, &
Invalid);
143 unsigned Offset = Decomposed.second;
144 if (
size_t Found = Buffer.find_last_of(
"#\n", Offset);
145 Found != StringRef::npos)
147 return {SourceMgr.getLocForStartOfFile(Decomposed.first)
148 .getLocWithOffset(Offset)};
159 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
164 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
165 if (VD->isStaticDataMember() &&
170 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(D)) {
175 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
182 if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
186 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
189 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
216 BaseLocation = D->getBeginLoc();
218 BaseLocation = D->getLocation();
220 if (!D->getLocation().isMacroID()) {
221 Locations.emplace_back(BaseLocation);
223 const auto *DeclCtx = D->getDeclContext();
234 Locations.emplace_back(SourceMgr.getExpansionLoc(BaseLocation));
241 Locations.emplace_back(SourceMgr.getSpellingLoc(D->getBeginLoc()));
249 const std::map<unsigned, RawComment *> &CommentsInTheFile)
const {
256 if (CommentsInTheFile.empty())
259 const auto *D = dyn_cast<const Decl *>(Key);
265 SourceMgr.getDecomposedLoc(RepresentativeLoc);
268 auto OffsetCommentBehindDecl =
269 CommentsInTheFile.lower_bound(LocDecomp.second);
272 if (OffsetCommentBehindDecl != CommentsInTheFile.end()) {
273 RawComment *CommentBehindDecl = OffsetCommentBehindDecl->second;
275 LangOpts.CommentOpts.ParseAllComments) &&
283 if (SourceMgr.getLineNumber(LocDecomp.first, LocDecomp.second) ==
284 Comments.getCommentBeginLine(CommentBehindDecl, LocDecomp.first,
285 OffsetCommentBehindDecl->first)) {
286 return CommentBehindDecl;
293 if (OffsetCommentBehindDecl == CommentsInTheFile.begin())
296 auto OffsetCommentBeforeDecl = --OffsetCommentBehindDecl;
297 RawComment *CommentBeforeDecl = OffsetCommentBeforeDecl->second;
301 LangOpts.CommentOpts.ParseAllComments) ||
306 const unsigned CommentEndOffset =
307 Comments.getCommentEndOffset(CommentBeforeDecl);
308 if (CommentEndOffset > LocDecomp.second)
314 SourceMgr.getBufferData(LocDecomp.first, &
Invalid).data();
319 StringRef
Text(Buffer + CommentEndOffset,
320 LocDecomp.second - CommentEndOffset);
324 if (
Text.find_last_of(
";{}#@") != StringRef::npos)
327 return CommentBeforeDecl;
333 for (
const auto Loc : Locs) {
336 if (Loc.isInvalid() || !Loc.isFileID())
347 const FileID File = SourceMgr.getDecomposedLoc(Loc).first;
351 const auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
352 if (!CommentsInThisFile || CommentsInThisFile->empty())
364 assert(LangOpts.CommentOpts.RetainCommentsFromSystemHeaders ||
366 Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
371 const Decl **OriginalDecl)
const {
374 *OriginalDecl =
nullptr;
380 if (
const auto *MI = dyn_cast<const MacroInfo *>(Key)) {
382 *OriginalDecl =
nullptr;
385 return Existing->second;
402 return DeclComment->second;
415 *OriginalDecl = RedeclComment->second;
416 auto CommentAtRedecl =
RawComments.find(RedeclComment->second);
418 "This decl is supposed to have comment attached.");
419 return CommentAtRedecl->second;
424 const Decl *LastCheckedRedecl = [&]() {
426 bool CanUseCommentlessCache =
false;
428 for (
auto *Redecl : CanonicalD->
redecls()) {
430 CanUseCommentlessCache =
true;
433 if (Redecl == LastChecked)
440 return CanUseCommentlessCache ? LastChecked :
nullptr;
446 if (LastCheckedRedecl) {
447 if (LastCheckedRedecl == Redecl) {
448 LastCheckedRedecl =
nullptr;
456 *OriginalDecl = Redecl;
457 return RedeclComment;
463 *OriginalDecl =
nullptr;
469 assert(Comment.
isDocumentation() || LangOpts.CommentOpts.ParseAllComments);
471 if (
const auto *D = dyn_cast<const Decl *>(Original)) {
481 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(DC)) {
486 for (
const auto *Ext : ID->known_extensions()) {
490 Redeclared.push_back(RedeclaredMethod);
497 if (
Comments.empty() || Decls.empty())
501 for (
const Decl *D : Decls) {
502 if (D->isInvalidDecl())
510 File = SourceMgr.getDecomposedLoc(Loc).first;
515 if (
File.isInvalid())
518 auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
519 if (!CommentsInThisFile || CommentsInThisFile->empty() ||
520 CommentsInThisFile->rbegin()->second->isAttached())
530 for (
const Decl *D : Decls) {
532 if (D->isInvalidDecl())
542 for (
const auto DeclLoc : DeclLocs) {
543 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
546 const FileID DeclFile = SourceMgr.getDecomposedLoc(DeclLoc).first;
550 const auto *CommentsInDeclFile =
551 DeclFile ==
File ? CommentsInThisFile
552 :
Comments.getCommentsInFile(DeclFile);
553 if (!CommentsInDeclFile || CommentsInDeclFile->empty())
568 const Decl *D)
const {
571 ThisDeclInfo->IsFilled =
false;
572 ThisDeclInfo->fill();
573 ThisDeclInfo->CommentDecl = FC->
getDecl();
574 if (!ThisDeclInfo->TemplateParameters)
584 return RC ? RC->
parse(*
this,
nullptr, D) :
nullptr;
595 llvm::DenseMap<const Decl *, comments::FullComment *>::iterator Pos =
599 if (Canonical != D) {
607 const Decl *OriginalDecl =
nullptr;
613 const auto *OMD = dyn_cast<ObjCMethodDecl>(D);
614 if (OMD && OMD->isPropertyAccessor())
621 for (
unsigned i = 0, e = Overridden.size(); i < e; i++)
625 else if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
628 QualType QT = TD->getUnderlyingType();
629 if (
const auto *TT = QT->
getAs<TagType>())
633 else if (
const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
634 while (IC->getSuperClass()) {
635 IC = IC->getSuperClass();
640 else if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(D)) {
645 else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
646 if (!(RD = RD->getDefinition()))
649 for (
const auto &I : RD->bases()) {
650 if (I.isVirtual() || (I.getAccessSpecifier() !=
AS_public))
664 for (
const auto &I : RD->vbases()) {
685 if (D != OriginalDecl && OriginalDecl)
693void ASTContext::CanonicalTemplateTemplateParm::Profile(
702 ID.AddInteger(Params->
size());
704 PEnd = Params->
end();
706 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
708 ID.AddBoolean(TTP->isParameterPack());
710 TTP->getNumExpansionParameters().toInternalRepresentation());
714 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
716 ID.AddBoolean(NTTP->isParameterPack());
717 ID.AddPointer(
C.getUnconstrainedType(
C.getCanonicalType(NTTP->getType()))
719 if (NTTP->isExpandedParameterPack()) {
721 ID.AddInteger(NTTP->getNumExpansionTypes());
722 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
724 ID.AddPointer(
T.getCanonicalType().getAsOpaquePtr());
727 ID.AddBoolean(
false);
737TemplateTemplateParmDecl *
741 llvm::FoldingSetNodeID ID;
742 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
743 llvm::FoldingSetInsertToken
Token;
744 CanonicalTemplateTemplateParm *Canonical =
745 CanonTemplateTemplateParms.lookup(ID,
Token);
747 return Canonical->getParam();
752 CanonParams.reserve(Params->
size());
754 PEnd = Params->
end();
758 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
763 TTP->getNumExpansionParameters());
764 CanonParams.push_back(NewTTP);
765 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
769 if (NTTP->isExpandedParameterPack()) {
772 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
774 ExpandedTInfos.push_back(
782 NTTP->getPosition(),
nullptr,
792 NTTP->getPosition(),
nullptr,
794 NTTP->isParameterPack(),
797 CanonParams.push_back(Param);
813 Canonical = CanonTemplateTemplateParms.lookup(ID,
Token);
814 assert(!Canonical &&
"Shouldn't be in the map!");
818 Canonical =
new (*this) CanonicalTemplateTemplateParm(CanonTTP);
819 CanonTemplateTemplateParms.insert(Canonical,
Token);
826 llvm::FoldingSetNodeID ID;
827 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
828 llvm::FoldingSetInsertToken
Token;
829 CanonicalTemplateTemplateParm *Canonical =
830 CanonTemplateTemplateParms.lookup(ID,
Token);
831 return Canonical ? Canonical->getParam() :
nullptr;
837 llvm::FoldingSetNodeID ID;
838 CanonicalTemplateTemplateParm::Profile(ID, *
this, CanonTTP);
839 llvm::FoldingSetInsertToken
Token;
840 if (
auto *Existing = CanonTemplateTemplateParms.lookup(ID,
Token))
841 return Existing->getParam();
842 CanonTemplateTemplateParms.insert(
843 new (*
this) CanonicalTemplateTemplateParm(CanonTTP),
Token);
864 [](
const DynTypedNode &P) { return P.get<WhileStmt>() != nullptr; });
888 return NoSanitizeL->containsType(Mask, TyName);
897 if (!LangOpts.CPlusPlus)
return nullptr;
900 case TargetCXXABI::AppleARM64:
901 case TargetCXXABI::Fuchsia:
902 case TargetCXXABI::GenericARM:
903 case TargetCXXABI::iOS:
904 case TargetCXXABI::WatchOS:
905 case TargetCXXABI::GenericAArch64:
906 case TargetCXXABI::GenericMIPS:
907 case TargetCXXABI::GenericItanium:
908 case TargetCXXABI::WebAssembly:
909 case TargetCXXABI::XL:
911 case TargetCXXABI::Microsoft:
914 llvm_unreachable(
"Invalid CXXABI type!");
918 if (!InterpContext) {
921 return *InterpContext;
926 switch (LangOpts.getAddressSpaceMapMangling()) {
934 llvm_unreachable(
"getAddressSpaceMapMangling() doesn't cover anything.");
940 : ConstantArrayTypes(this_(), ConstantArrayTypesLog2InitSize),
941 DependentSizedArrayTypes(this_()), DependentSizedExtVectorTypes(this_()),
942 DependentAddressSpaceTypes(this_()), DependentVectorTypes(this_()),
943 DependentSizedMatrixTypes(this_()),
944 FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
945 DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
946 DependentPackIndexingTypes(this_()), TemplateSpecializationTypes(this_()),
947 AttributedTypes(this_()), DependentBitIntTypes(this_()),
948 HLSLAttributedResourceTypes(this_()),
949 SubstTemplateTemplateParmPacks(this_()), DeducedTemplates(this_()),
950 PackIndexingTemplates(this_()), ArrayParameterTypes(this_()),
951 CanonTemplateTemplateParms(this_()), SourceMgr(SM), LangOpts(LOpts),
954 LangOpts.XRayNeverInstrumentFiles,
955 LangOpts.XRayAttrListFiles, SM)),
956 ProfList(new
ProfileList(LangOpts.ProfileListFiles, SM)),
960 CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
968 ReleaseDeclContextMaps();
971 for (
auto &Pair : Deallocations)
972 (Pair.first)(Pair.second);
973 Deallocations.clear();
979 I = ObjCLayouts.begin(),
980 E = ObjCLayouts.end();
987 for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
988 I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
993 ASTRecordLayouts.clear();
995 CtorClosureDefaultArgs.clear();
997 for (
const auto &
Value : ModuleInitializers)
998 Value.second->~PerModuleInitializers();
999 ModuleInitializers.
clear();
1003 NoSanitizeL.reset();
1009 TraversalScope = TopLevelDecls;
1023 llvm::errs() <<
"\n*** AST Context Stats:\n";
1024 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
1026 unsigned counts[] = {
1027#define TYPE(Name, Parent) 0,
1028#define ABSTRACT_TYPE(Name, Parent)
1029#include "clang/AST/TypeNodes.inc"
1033 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
1035 counts[(unsigned)
T->getTypeClass()]++;
1039 unsigned TotalBytes = 0;
1040#define TYPE(Name, Parent) \
1042 llvm::errs() << " " << counts[Idx] << " " << #Name \
1043 << " types, " << sizeof(Name##Type) << " each " \
1044 << "(" << counts[Idx] * sizeof(Name##Type) \
1046 TotalBytes += counts[Idx] * sizeof(Name##Type); \
1048#define ABSTRACT_TYPE(Name, Parent)
1049#include "clang/AST/TypeNodes.inc"
1051 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
1056 <<
" implicit default constructors created\n";
1059 <<
" implicit copy constructors created\n";
1063 <<
" implicit move constructors created\n";
1066 <<
" implicit copy assignment operators created\n";
1070 <<
" implicit move assignment operators created\n";
1073 <<
" implicit destructors created\n";
1076 llvm::errs() <<
"\n";
1080 BumpAlloc.PrintStats();
1084 bool NotifyListeners) {
1085 if (NotifyListeners)
1088 Listener->RedefinedHiddenDefinition(ND, M);
1095 if (It == MergedDefModules.end())
1098 auto &Merged = It->second;
1099 llvm::DenseSet<Module*>
Found;
1100 for (
Module *&M : Merged)
1101 if (!
Found.insert(M).second)
1103 llvm::erase(Merged,
nullptr);
1110 if (MergedIt == MergedDefModules.end())
1112 return MergedIt->second;
1115void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1116 if (LazyInitializers.empty())
1120 assert(Source &&
"lazy initializers but no external source");
1122 auto LazyInits = std::move(LazyInitializers);
1123 LazyInitializers.clear();
1125 for (
auto ID : LazyInits)
1126 Initializers.push_back(Source->GetExternalDecl(ID));
1128 assert(LazyInitializers.empty() &&
1129 "GetExternalDecl for lazy module initializer added more inits");
1135 if (
const auto *ID = dyn_cast<ImportDecl>(D)) {
1136 auto It = ModuleInitializers.find(ID->getImportedModule());
1139 if (It == ModuleInitializers.end())
1143 auto &Imported = *It->second;
1144 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1145 Imported.resolve(*
this);
1146 auto *OnlyDecl = Imported.Initializers.front();
1152 auto *&
Inits = ModuleInitializers[M];
1154 Inits =
new (*this) PerModuleInitializers;
1155 Inits->Initializers.push_back(D);
1160 auto *&
Inits = ModuleInitializers[M];
1162 Inits =
new (*this) PerModuleInitializers;
1163 Inits->LazyInitializers.insert(
Inits->LazyInitializers.end(),
1164 IDs.begin(), IDs.end());
1168 auto It = ModuleInitializers.find(M);
1169 if (It == ModuleInitializers.end())
1172 auto *
Inits = It->second;
1173 Inits->resolve(*
this);
1174 return Inits->Initializers;
1179 assert(!CurrentCXXNamedModule &&
1180 "We should set named module for ASTContext for only once");
1181 CurrentCXXNamedModule = M;
1193 auto GetRepresentativeModule = [
this](
const Module *M) {
1194 auto Iter = SameModuleLookupSet.find(M);
1195 if (Iter != SameModuleLookupSet.end())
1196 return Iter->second;
1198 const Module *RepresentativeModule =
1199 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1201 SameModuleLookupSet[M] = RepresentativeModule;
1202 return RepresentativeModule;
1205 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1206 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1210 if (!ExternCContext)
1213 return ExternCContext;
1227#define BuiltinTemplate(BTName) \
1228 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1229 if (!Decl##BTName) \
1231 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1232 return Decl##BTName; \
1234#include "clang/Basic/BuiltinTemplates.inc"
1247 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1248 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1253 StringRef Name)
const {
1277 Types.push_back(Ty);
1282 assert((!this->Target || this->Target == &Target) &&
1283 "Incorrect target reinitialization");
1284 assert(
VoidTy.isNull() &&
"Context reinitialized?");
1286 this->Target = &Target;
1287 this->AuxTarget = AuxTarget;
1289 ABI.reset(createCXXABI(Target));
1293 InitBuiltinType(
VoidTy, BuiltinType::Void);
1296 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1298 if (LangOpts.CharIsSigned)
1299 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1301 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1304 InitBuiltinType(
ShortTy, BuiltinType::Short);
1305 InitBuiltinType(
IntTy, BuiltinType::Int);
1306 InitBuiltinType(
LongTy, BuiltinType::Long);
1307 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1317 InitBuiltinType(
FloatTy, BuiltinType::Float);
1318 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1319 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1322 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1325 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1328 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1331 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1332 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1333 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1337 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1338 InitBuiltinType(
FractTy, BuiltinType::Fract);
1339 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1344 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1350 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1357 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1362 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1364 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1365 if (LangOpts.CPlusPlus && LangOpts.WChar)
1369 WideCharTy = getFromTargetType(Target.getWCharType());
1372 WIntTy = getFromTargetType(Target.getWIntType());
1375 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1377 if (LangOpts.CPlusPlus)
1378 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1380 Char16Ty = getFromTargetType(Target.getChar16Type());
1382 if (LangOpts.CPlusPlus)
1383 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1385 Char32Ty = getFromTargetType(Target.getChar32Type());
1392 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1395 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1407 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1413 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1416 if (LangOpts.OpenMP) {
1423 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1426 if (LangOpts.MatrixTypes)
1434 if (LangOpts.OpenCL) {
1435#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1436 InitBuiltinType(SingletonId, BuiltinType::Id);
1437#include "clang/Basic/OpenCLImageTypes.def"
1439 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1440 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1442 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1445#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1446 InitBuiltinType(Id##Ty, BuiltinType::Id);
1447#include "clang/Basic/OpenCLExtensionTypes.def"
1450 if (LangOpts.HLSL) {
1451#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1452 InitBuiltinType(SingletonId, BuiltinType::Id);
1453#include "clang/Basic/HLSLIntangibleTypes.def"
1455#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
1456 InitBuiltinType(SingletonId, BuiltinType::Id);
1457#include "clang/Basic/HLSLPackedTypes.def"
1460 if (Target.hasAArch64ACLETypes() ||
1461 (AuxTarget && AuxTarget->hasAArch64ACLETypes())) {
1462#define SVE_TYPE(Name, Id, SingletonId) \
1463 InitBuiltinType(SingletonId, BuiltinType::Id);
1464#include "clang/Basic/AArch64ACLETypes.def"
1467 if (Target.getTriple().isPPC64()) {
1468#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1469 InitBuiltinType(Id##Ty, BuiltinType::Id);
1470#include "clang/Basic/PPCTypes.def"
1471#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1472 InitBuiltinType(Id##Ty, BuiltinType::Id);
1473#include "clang/Basic/PPCTypes.def"
1476 if (Target.hasRISCVVTypes()) {
1477#define RVV_TYPE(Name, Id, SingletonId) \
1478 InitBuiltinType(SingletonId, BuiltinType::Id);
1479#include "clang/Basic/RISCVVTypes.def"
1482 if (Target.getTriple().isWasm() && Target.hasFeature(
"reference-types")) {
1483#define WASM_TYPE(Name, Id, SingletonId) \
1484 InitBuiltinType(SingletonId, BuiltinType::Id);
1485#include "clang/Basic/WebAssemblyReferenceTypes.def"
1488 if (Target.hasAMDGPUTypes() || (AuxTarget && (AuxTarget->hasAMDGPUTypes()))) {
1489#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1490 InitBuiltinType(SingletonId, BuiltinType::Id);
1491#include "clang/Basic/AMDGPUTypes.def"
1494 if (Target.getTriple().isSPIRV() ||
1495 (AuxTarget && AuxTarget->getTriple().isSPIRV())) {
1496#define SPIRV_TYPE(Name, Id, SingletonId) \
1497 InitBuiltinType(SingletonId, BuiltinType::Id);
1498#include "clang/Basic/SPIRVTypes.def"
1505 ObjCConstantStringType =
QualType();
1510 if (LangOpts.OpenCLGenericAddressSpace) {
1511 auto Q =
VoidTy.getQualifiers();
1520 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1523 InitBuiltinType(
MetaInfoTy, BuiltinType::MetaInfo);
1526 InitBuiltinType(
HalfTy, BuiltinType::Half);
1528 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1534 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1541 return SourceMgr.getDiagnostics();
1545 return new (DeclAttrAllocator.Allocate())
AttrVec;
1550 return CtorClosureDefaultArgs.lookup(CD);
1555 assert(!CtorClosureDefaultArgs.contains(CD));
1556 CtorClosureDefaultArgs[CD] = Args;
1563 if (It != ExplicitInstantiations.end())
1576 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1577 TemplateOrInstantiation.find(Var);
1578 if (Pos == TemplateOrInstantiation.end())
1591 Tmpl, TSK, PointOfInstantiation));
1597 assert(!TemplateOrInstantiation[Inst] &&
1598 "Already noted what the variable was instantiated from");
1599 TemplateOrInstantiation[Inst] = TSI;
1604 return InstantiatedFromUsingDecl.lookup(UUD);
1612 "pattern decl is not a using decl");
1616 "instantiation did not produce a using decl");
1617 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1618 InstantiatedFromUsingDecl[Inst] = Pattern;
1623 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1628 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1629 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1634 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1640 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1641 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1646 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1652 "Instantiated field decl is not unnamed");
1654 "Template field decl is not unnamed");
1655 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1656 "Already noted what unnamed field was instantiated from");
1658 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1674 return Range.end() - Range.begin();
1679 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1680 OverriddenMethods.find(
Method->getCanonicalDecl());
1681 if (Pos == OverriddenMethods.end())
1689 OverriddenMethods[
Method].push_back(Overridden);
1697 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1703 const auto *
Method = dyn_cast<ObjCMethodDecl>(D);
1708 Method->getOverriddenMethods(OverDecls);
1709 Overridden.append(OverDecls.begin(), OverDecls.end());
1712std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1716 auto it = RelocatableClasses.find(D);
1717 if (it != RelocatableClasses.end())
1718 return it->getSecond();
1719 return std::nullopt;
1726 assert(RelocatableClasses.find(D) == RelocatableClasses.end());
1727 RelocatableClasses.insert({D, Info});
1732 if (!Class->isPolymorphic())
1734 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
1735 using AuthAttr = VTablePointerAuthenticationAttr;
1736 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1738 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1739 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1740 ExplicitAuth->getAddressDiscrimination();
1741 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1742 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1743 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1746ASTContext::PointerAuthContent
1747ASTContext::findPointerAuthContent(QualType
T)
const {
1748 assert(isPointerAuthenticationAvailable());
1750 T =
T.getCanonicalType();
1752 return PointerAuthContent::None;
1754 if (
T.hasAddressDiscriminatedPointerAuth())
1755 return PointerAuthContent::AddressDiscriminatedData;
1758 return PointerAuthContent::None;
1761 return PointerAuthContent::None;
1763 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1764 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1765 return Existing->second;
1767 PointerAuthContent
Result = PointerAuthContent::None;
1769 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1770 auto [ResultIter, DidAdd] =
1771 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1777 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1778 static_assert(PointerAuthContent::None <
1779 PointerAuthContent::AddressDiscriminatedVTable);
1780 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1781 PointerAuthContent::AddressDiscriminatedData);
1784 return Result != PointerAuthContent::AddressDiscriminatedData;
1786 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1788 !ShouldContinueAfterUpdate(
1789 PointerAuthContent::AddressDiscriminatedVTable))
1790 return SaveResultAndReturn();
1791 for (
auto Base : CXXRD->bases()) {
1792 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1793 return SaveResultAndReturn();
1796 for (
auto *FieldDecl : RD->
fields()) {
1797 if (!ShouldContinueAfterUpdate(
1798 findPointerAuthContent(FieldDecl->getType())))
1799 return SaveResultAndReturn();
1801 return SaveResultAndReturn();
1805 assert(!Import->getNextLocalImport() &&
1806 "Import declaration already in the chain");
1807 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1808 if (!FirstLocalImport) {
1809 FirstLocalImport = Import;
1810 LastLocalImport = Import;
1814 LastLocalImport->setNextLocalImport(Import);
1815 LastLocalImport = Import;
1827 llvm_unreachable(
"Not a floating point type!");
1828 case BuiltinType::BFloat16:
1829 return Target->getBFloat16Format();
1830 case BuiltinType::Float16:
1831 return Target->getHalfFormat();
1832 case BuiltinType::Half:
1833 return Target->getHalfFormat();
1834 case BuiltinType::Float:
return Target->getFloatFormat();
1835 case BuiltinType::Double:
return Target->getDoubleFormat();
1836 case BuiltinType::Ibm128:
1837 return Target->getIbm128Format();
1838 case BuiltinType::LongDouble:
1840 return AuxTarget->getLongDoubleFormat();
1841 return Target->getLongDoubleFormat();
1842 case BuiltinType::Float128:
1844 return AuxTarget->getFloat128Format();
1845 return Target->getFloat128Format();
1850 unsigned Align = Target->getCharWidth();
1854 Align = AlignFromAttr;
1862 bool UseAlignAttrOnly;
1863 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1865 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1867 UseAlignAttrOnly = AlignFromAttr != 0;
1870 if (UseAlignAttrOnly) {
1872 }
else if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
1876 T = RT->getPointeeType();
1881 if (
T->isFunctionType())
1882 Align = getTypeInfoImpl(
T.getTypePtr()).Align;
1887 unsigned MinWidth = Target->getLargeArrayMinWidth();
1888 if (!ForAlignof && MinWidth) {
1890 Align = std::max(Align, Target->getLargeArrayAlign());
1893 Align = std::max(Align, Target->getLargeArrayAlign());
1898 Align = Target->getCharWidth();
1902 if (
const auto *VD = dyn_cast<VarDecl>(D))
1903 if (VD->hasGlobalStorage() && !ForAlignof) {
1914 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1928 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1929 if (LowBitOfOffset < FieldAlign)
1930 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1933 Align = std::min(Align, FieldAlign);
1941 const auto *VD = dyn_cast<VarDecl>(D);
1942 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1943 Align = std::min(Align, MaxAlignedAttr);
1963 if (
const auto *RD =
T->getAsCXXRecordDecl(); RD && !RD->
isInvalidDecl()) {
1981 "Overflow in array type char size evaluation");
1984 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
1986 Width = llvm::alignTo(Width, Align);
1993 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2011 switch (BT->getKind()) {
2012 case BuiltinType::Bool:
2013 case BuiltinType::Char_S:
2014 case BuiltinType::Char_U:
2015 case BuiltinType::SChar:
2016 case BuiltinType::UChar:
2017 case BuiltinType::Short:
2018 case BuiltinType::UShort:
2019 case BuiltinType::WChar_S:
2020 case BuiltinType::WChar_U:
2021 case BuiltinType::Char8:
2022 case BuiltinType::Char16:
2023 case BuiltinType::Char32:
2031 if (
const auto *ED =
T->getAsEnumDecl()) {
2032 if (
T->isDependentType() || ED->getPromotionType().isNull() ||
2040 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>()) {
2056 bool NeedsPreferredAlignment)
const {
2059 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2064 if (!
T->isIncompleteType())
2070 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2074 if (
const auto *TD =
T->getAsTagDecl())
2075 return TD->getMaxAlignment();
2081 TypeInfoMap::iterator I = MemoizedTypeInfo.find(
T);
2082 if (I != MemoizedTypeInfo.end())
2087 MemoizedTypeInfo[
T] = TI;
2102 switch (
T->getTypeClass()) {
2103#define TYPE(Class, Base)
2104#define ABSTRACT_TYPE(Class, Base)
2105#define NON_CANONICAL_TYPE(Class, Base)
2106#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2107#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
2109 assert(!T->isDependentType() && "should not see dependent types here"); \
2110 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
2111#include "clang/AST/TypeNodes.inc"
2112 llvm_unreachable(
"Should not see dependent types");
2114 case Type::FunctionNoProto:
2115 case Type::FunctionProto:
2121 case Type::IncompleteArray:
2122 case Type::VariableArray:
2123 case Type::ConstantArray:
2124 case Type::ArrayParameter: {
2127 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2128 Size = CAT->getZExtSize();
2131 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2132 "Overflow in array type bit size evaluation");
2133 Width = EltInfo.
Width * Size;
2134 Align = EltInfo.
Align;
2138 Width = llvm::alignTo(Width, Align);
2142 case Type::ExtVector:
2143 case Type::Vector: {
2146 Width = VT->isPackedVectorBoolType(*
this)
2147 ? VT->getNumElements()
2148 : EltInfo.
Width * VT->getNumElements();
2150 Width = std::max<unsigned>(8, Width);
2151 Align = std::max<unsigned>(
2152 8,
Target->vectorsAreElementAligned() ? EltInfo.
Width : Width);
2156 if (Align & (Align-1)) {
2157 Align = llvm::bit_ceil(Align);
2158 Width = llvm::alignTo(Width, Align);
2161 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
2162 if (TargetVectorAlign && TargetVectorAlign < Align)
2163 Align = TargetVectorAlign;
2173 Align = std::min<unsigned>(64, Width);
2180 case Type::ConstantMatrix: {
2182 TypeInfo ElementInfo =
getTypeInfo(MT->getElementType());
2186 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2187 Align = ElementInfo.
Align;
2193 default: llvm_unreachable(
"Unknown builtin type!");
2194 case BuiltinType::Void:
2199 case BuiltinType::Bool:
2200 Width = Target->getBoolWidth();
2201 Align = Target->getBoolAlign();
2203 case BuiltinType::Char_S:
2204 case BuiltinType::Char_U:
2205 case BuiltinType::UChar:
2206 case BuiltinType::SChar:
2207 case BuiltinType::Char8:
2208 Width = Target->getCharWidth();
2209 Align = Target->getCharAlign();
2211 case BuiltinType::WChar_S:
2212 case BuiltinType::WChar_U:
2213 Width = Target->getWCharWidth();
2214 Align = Target->getWCharAlign();
2216 case BuiltinType::Char16:
2217 Width = Target->getChar16Width();
2218 Align = Target->getChar16Align();
2220 case BuiltinType::Char32:
2221 Width = Target->getChar32Width();
2222 Align = Target->getChar32Align();
2224 case BuiltinType::UShort:
2225 case BuiltinType::Short:
2226 Width = Target->getShortWidth();
2227 Align = Target->getShortAlign();
2229 case BuiltinType::UInt:
2230 case BuiltinType::Int:
2231 Width = Target->getIntWidth();
2232 Align = Target->getIntAlign();
2234 case BuiltinType::ULong:
2235 case BuiltinType::Long:
2236 Width = Target->getLongWidth();
2237 Align = Target->getLongAlign();
2239 case BuiltinType::ULongLong:
2240 case BuiltinType::LongLong:
2241 Width = Target->getLongLongWidth();
2242 Align = Target->getLongLongAlign();
2244 case BuiltinType::Int128:
2245 case BuiltinType::UInt128:
2247 Align = Target->getInt128Align();
2249 case BuiltinType::ShortAccum:
2250 case BuiltinType::UShortAccum:
2251 case BuiltinType::SatShortAccum:
2252 case BuiltinType::SatUShortAccum:
2253 Width = Target->getShortAccumWidth();
2254 Align = Target->getShortAccumAlign();
2256 case BuiltinType::Accum:
2257 case BuiltinType::UAccum:
2258 case BuiltinType::SatAccum:
2259 case BuiltinType::SatUAccum:
2260 Width = Target->getAccumWidth();
2261 Align = Target->getAccumAlign();
2263 case BuiltinType::LongAccum:
2264 case BuiltinType::ULongAccum:
2265 case BuiltinType::SatLongAccum:
2266 case BuiltinType::SatULongAccum:
2267 Width = Target->getLongAccumWidth();
2268 Align = Target->getLongAccumAlign();
2270 case BuiltinType::ShortFract:
2271 case BuiltinType::UShortFract:
2272 case BuiltinType::SatShortFract:
2273 case BuiltinType::SatUShortFract:
2274 Width = Target->getShortFractWidth();
2275 Align = Target->getShortFractAlign();
2277 case BuiltinType::Fract:
2278 case BuiltinType::UFract:
2279 case BuiltinType::SatFract:
2280 case BuiltinType::SatUFract:
2281 Width = Target->getFractWidth();
2282 Align = Target->getFractAlign();
2284 case BuiltinType::LongFract:
2285 case BuiltinType::ULongFract:
2286 case BuiltinType::SatLongFract:
2287 case BuiltinType::SatULongFract:
2288 Width = Target->getLongFractWidth();
2289 Align = Target->getLongFractAlign();
2291 case BuiltinType::BFloat16:
2292 if (Target->hasBFloat16Type()) {
2293 Width = Target->getBFloat16Width();
2294 Align = Target->getBFloat16Align();
2298 AuxTarget->hasBFloat16Type()) {
2299 Width = AuxTarget->getBFloat16Width();
2300 Align = AuxTarget->getBFloat16Align();
2303 case BuiltinType::Float16:
2304 case BuiltinType::Half:
2305 if (Target->hasFloat16Type() || !
getLangOpts().OpenMP ||
2307 Width = Target->getHalfWidth();
2308 Align = Target->getHalfAlign();
2311 "Expected OpenMP device compilation.");
2312 Width = AuxTarget->getHalfWidth();
2313 Align = AuxTarget->getHalfAlign();
2316 case BuiltinType::Float:
2317 Width = Target->getFloatWidth();
2318 Align = Target->getFloatAlign();
2320 case BuiltinType::Double:
2321 Width = Target->getDoubleWidth();
2322 Align = Target->getDoubleAlign();
2324 case BuiltinType::Ibm128:
2325 Width = Target->getIbm128Width();
2326 Align = Target->getIbm128Align();
2328 case BuiltinType::LongDouble:
2330 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2331 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2332 Width = AuxTarget->getLongDoubleWidth();
2333 Align = AuxTarget->getLongDoubleAlign();
2335 Width = Target->getLongDoubleWidth();
2336 Align = Target->getLongDoubleAlign();
2340 if (&Target->getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended())
2343 case BuiltinType::Float128:
2344 if (Target->hasFloat128Type() || !
getLangOpts().OpenMP ||
2346 Width = Target->getFloat128Width();
2347 Align = Target->getFloat128Align();
2350 "Expected OpenMP device compilation.");
2351 Width = AuxTarget->getFloat128Width();
2352 Align = AuxTarget->getFloat128Align();
2355 case BuiltinType::NullPtr:
2360 case BuiltinType::MetaInfo:
2366 case BuiltinType::ObjCId:
2367 case BuiltinType::ObjCClass:
2368 case BuiltinType::ObjCSel:
2372 case BuiltinType::OCLSampler:
2373 case BuiltinType::OCLEvent:
2374 case BuiltinType::OCLClkEvent:
2375 case BuiltinType::OCLQueue:
2376 case BuiltinType::OCLReserveID:
2377#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2378 case BuiltinType::Id:
2379#include "clang/Basic/OpenCLImageTypes.def"
2380#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2381 case BuiltinType::Id:
2382#include "clang/Basic/OpenCLExtensionTypes.def"
2384 Width = Target->getPointerWidth(AS);
2385 Align = Target->getPointerAlign(AS);
2395#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2396 case BuiltinType::Id: \
2400#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2401 case BuiltinType::Id: \
2405#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2406 case BuiltinType::Id: \
2410#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2411 case BuiltinType::Id: \
2415#include "clang/Basic/AArch64ACLETypes.def"
2416#define PPC_VECTOR_TYPE(Name, Id, Size) \
2417 case BuiltinType::Id: \
2421#include "clang/Basic/PPCTypes.def"
2422#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2424 case BuiltinType::Id: \
2428#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2429 case BuiltinType::Id: \
2433#include "clang/Basic/RISCVVTypes.def"
2434#define WASM_TYPE(Name, Id, SingletonId) \
2435 case BuiltinType::Id: \
2439#include "clang/Basic/WebAssemblyReferenceTypes.def"
2440#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2441 case BuiltinType::ID: \
2445#include "clang/Basic/AMDGPUTypes.def"
2446#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2447#include "clang/Basic/HLSLIntangibleTypes.def"
2451#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2452#include "clang/Basic/HLSLPackedTypes.def"
2456#define SPIRV_TYPE(Name, Id, SingletonId) \
2457 case BuiltinType::Id: \
2458 Width = Target->getPointerWidth(LangAS::Default); \
2459 Align = Target->getPointerAlign(LangAS::Default); \
2461#include "clang/Basic/SPIRVTypes.def"
2464 case Type::ObjCObjectPointer:
2468 case Type::BlockPointer:
2470 Width = Target->getPointerWidth(AS);
2471 Align = Target->getPointerAlign(AS);
2473 case Type::LValueReference:
2474 case Type::RValueReference:
2478 Width = Target->getPointerWidth(AS);
2479 Align = Target->getPointerAlign(AS);
2483 Width = Target->getPointerWidth(AS);
2484 Align = Target->getPointerAlign(AS);
2486 case Type::MemberPointer: {
2488 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2493 case Type::Complex: {
2497 Width = EltInfo.
Width * 2;
2498 Align = EltInfo.
Align;
2501 case Type::ObjCObject:
2503 case Type::Adjusted:
2506 case Type::ObjCInterface: {
2508 if (ObjCI->getDecl()->isInvalidDecl()) {
2518 case Type::BitInt: {
2520 Align = Target->getBitIntAlign(EIT->getNumBits());
2521 Width = Target->getBitIntWidth(EIT->getNumBits());
2527 const TagDecl *TD = TT->getDecl()->getDefinitionOrSelf();
2540 Info.
Align = AttrAlign;
2550 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2556 case Type::SubstTemplateTypeParm:
2558 getReplacementType().getTypePtr());
2561 case Type::DeducedTemplateSpecialization: {
2563 assert(!A->getDeducedType().isNull() &&
2564 "cannot request the size of an undeduced or dependent auto type");
2565 return getTypeInfo(A->getDeducedType().getTypePtr());
2571 case Type::MacroQualified:
2575 case Type::ObjCTypeParam:
2581 case Type::Typedef: {
2583 TypeInfo Info =
getTypeInfo(TT->desugar().getTypePtr());
2587 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2598 case Type::Attributed:
2602 case Type::CountAttributed:
2605 case Type::LateParsedAttr:
2608 case Type::BTFTagAttributed:
2612 case Type::OverflowBehavior:
2616 case Type::HLSLAttributedResource:
2620 case Type::HLSLInlineSpirv: {
2623 Width = ST->getSize() * 8;
2624 Align = ST->getAlignment();
2625 if (Width == 0 && Align == 0) {
2633 case Type::Atomic: {
2642 Width = Target->getCharWidth();
2644 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2650 Width = llvm::bit_ceil(Width);
2656 Align =
static_cast<unsigned>(Width);
2663 case Type::PredefinedSugar:
2672 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2673 return TypeInfo(Width, Align, AlignRequirement);
2677 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(
T);
2678 if (I != MemoizedUnadjustedAlign.end())
2681 unsigned UnadjustedAlign;
2682 if (
const auto *RT =
T->getAsCanonical<RecordType>()) {
2689 UnadjustedAlign =
getTypeAlign(
T->getUnqualifiedDesugaredType());
2692 MemoizedUnadjustedAlign[
T] = UnadjustedAlign;
2693 return UnadjustedAlign;
2697 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2747 unsigned ABIAlign = TI.
Align;
2749 T =
T->getBaseElementTypeUnsafe();
2752 if (
T->isMemberPointerType())
2755 if (!Target->allowsLargerPreferedTypeAlignment())
2758 if (
const auto *RD =
T->getAsRecordDecl()) {
2767 unsigned PreferredAlign =
static_cast<unsigned>(
2769 assert(PreferredAlign >= ABIAlign &&
2770 "PreferredAlign should be at least as large as ABIAlign.");
2771 return PreferredAlign;
2778 T = CT->getElementType().getTypePtr();
2779 if (
const auto *ED =
T->getAsEnumDecl())
2780 T = ED->getIntegerType().getTypePtr();
2781 if (
T->isSpecificBuiltinType(BuiltinType::Double) ||
2782 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2783 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2784 (
T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2785 Target->defaultsToAIXPowerAlignment()))
2840 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
2844 std::swap(
Base, Derived);
2864 llvm::append_range(Ivars, OI->
ivars());
2867 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2869 Ivars.push_back(Iv);
2877 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2880 for (
auto *Proto : OI->all_referenced_protocols()) {
2885 for (
const auto *Cat : OI->visible_categories())
2891 SD = SD->getSuperClass();
2893 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2894 for (
auto *Proto : OC->protocols()) {
2897 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2899 if (!Protocols.insert(
2903 for (
auto *Proto : OP->protocols())
2910 bool CheckIfTriviallyCopyable) {
2911 assert(RD->
isUnion() &&
"Must be union type");
2913 Context.getTypeSizeInChars(Context.getCanonicalTagType(RD));
2915 for (
const auto *Field : RD->
fields()) {
2916 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2917 CheckIfTriviallyCopyable))
2919 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2920 if (FieldSize != UnionSize)
2929 return Context.getFieldOffset(Field);
2938static std::optional<int64_t>
2940 const RecordDecl *RD,
2941 bool CheckIfTriviallyCopyable);
2943static std::optional<int64_t>
2945 bool CheckIfTriviallyCopyable) {
2946 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2949 CheckIfTriviallyCopyable);
2953 bool IsBitIntType = Field->getType()->isBitIntType();
2954 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2955 !Context.hasUniqueObjectRepresentations(Field->getType(),
2956 CheckIfTriviallyCopyable))
2957 return std::nullopt;
2960 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2961 if (Field->isBitField()) {
2964 if (Field->isUnnamedBitField())
2967 int64_t BitfieldSize = Field->getBitWidthValue();
2969 if ((
unsigned)BitfieldSize >
2971 return std::nullopt;
2972 }
else if (BitfieldSize > FieldSizeInBits) {
2973 return std::nullopt;
2975 FieldSizeInBits = BitfieldSize;
2976 }
else if (IsBitIntType && !Context.hasUniqueObjectRepresentations(
2977 Field->getType(), CheckIfTriviallyCopyable)) {
2978 return std::nullopt;
2980 return FieldSizeInBits;
2983static std::optional<int64_t>
2985 bool CheckIfTriviallyCopyable) {
2987 CheckIfTriviallyCopyable);
2990template <
typename RangeT>
2992 const RangeT &Subobjects,
int64_t CurOffsetInBits,
2994 bool CheckIfTriviallyCopyable) {
2995 for (
const auto *Subobject : Subobjects) {
2996 std::optional<int64_t> SizeInBits =
2999 return std::nullopt;
3000 if (*SizeInBits != 0) {
3002 if (Offset != CurOffsetInBits)
3003 return std::nullopt;
3004 CurOffsetInBits += *SizeInBits;
3007 return CurOffsetInBits;
3010static std::optional<int64_t>
3013 bool CheckIfTriviallyCopyable) {
3014 assert(!RD->
isUnion() &&
"Must be struct/class type");
3015 const auto &Layout = Context.getASTRecordLayout(RD);
3018 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3019 if (ClassDecl->isDynamicClass())
3020 return std::nullopt;
3023 for (
const auto &
Base : ClassDecl->bases()) {
3026 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
3030 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
3033 std::optional<int64_t> OffsetAfterBases =
3035 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
3036 if (!OffsetAfterBases)
3037 return std::nullopt;
3038 CurOffsetInBits = *OffsetAfterBases;
3041 std::optional<int64_t> OffsetAfterFields =
3043 RD->
fields(), CurOffsetInBits, Context, Layout,
3044 CheckIfTriviallyCopyable);
3045 if (!OffsetAfterFields)
3046 return std::nullopt;
3047 CurOffsetInBits = *OffsetAfterFields;
3049 return CurOffsetInBits;
3053 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
3070 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
3075 CheckIfTriviallyCopyable);
3078 "hasUniqueObjectRepresentations should not be called with an "
3087 CheckIfTriviallyCopyable);
3110 return !ABI->getMemberPointerInfo(MPT).HasPadding;
3113 if (
Record->isInvalidDecl())
3118 CheckIfTriviallyCopyable);
3121 *
this,
Record, CheckIfTriviallyCopyable);
3123 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
3143 count += Ext->ivar_size();
3148 count += ImplDecl->ivar_size();
3174 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3175 I = ObjCImpls.find(D);
3176 if (I != ObjCImpls.end())
3184 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3185 I = ObjCImpls.find(D);
3186 if (I != ObjCImpls.end())
3194 assert(IFaceD && ImplD &&
"Passed null params");
3195 ObjCImpls[IFaceD] = ImplD;
3201 assert(CatD && ImplD &&
"Passed null params");
3202 ObjCImpls[CatD] = ImplD;
3207 return ObjCMethodRedecls.
lookup(MD);
3213 ObjCMethodRedecls[MD] = Redecl;
3218 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3220 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3221 return CD->getClassInterface();
3222 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3223 return IMD->getClassInterface();
3231 assert(VD &&
"Passed null params");
3232 assert(VD->
hasAttr<BlocksAttr>() &&
3233 "getBlockVarCopyInits - not __block var");
3234 auto I = BlockVarCopyInits.find(VD);
3235 if (I != BlockVarCopyInits.end())
3237 return {
nullptr,
false};
3243 assert(VD && CopyExpr &&
"Passed null params");
3244 assert(VD->
hasAttr<BlocksAttr>() &&
3245 "setBlockVarCopyInits - not __block var");
3246 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3250 unsigned DataSize)
const {
3255 "incorrect data size provided to CreateTypeSourceInfo!");
3272 return getObjCLayout(D);
3277 bool &AnyNonCanonArgs) {
3279 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3285 bool AnyNonCanonArgs =
false;
3286 for (
auto &Arg : Args) {
3289 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3291 return AnyNonCanonArgs;
3299ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3304 llvm::FoldingSetNodeID ID;
3306 llvm::FoldingSetInsertToken
Token;
3308 assert(eq->getQualifiers() == quals);
3317 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3320 (void)ExtQualNodes.lookup(ID,
Token);
3323 auto *eq =
new (*
this,
alignof(ExtQuals)) ExtQuals(baseType, canon, quals);
3324 ExtQualNodes.insert(eq, Token);
3325 return QualType(eq, fastQuals);
3329 LangAS AddressSpace)
const {
3342 "Type cannot be in multiple addr spaces!");
3345 return getExtQualType(TypeNode, Quals);
3351 if (!
T.hasAddressSpace())
3355 const Type *TypeNode;
3358 if (
T.getTypePtr()->isArrayType()) {
3360 TypeNode =
T.getTypePtr();
3364 while (
T.hasAddressSpace()) {
3365 TypeNode = Quals.
strip(
T);
3369 if (!
QualType(TypeNode, 0).hasAddressSpace())
3373 T =
T.getSingleStepDesugaredType(*
this);
3383 return getExtQualType(TypeNode, Quals);
3392 "Attempted to get vtable pointer discriminator on a monomorphic type");
3396 llvm::raw_svector_ostream Out(Str);
3397 MC->mangleCXXVTable(RD, Out);
3400 return llvm::getPointerAuthStableSipHash(Str);
3426 switch (
T->getTypeClass()) {
3431 case Type::LValueReference:
3436 case Type::RValueReference:
3450 case Type::ObjCObjectPointer:
3451 case Type::BlockPointer:
3460 case Type::VariableArray:
3461 case Type::ConstantArray:
3462 case Type::IncompleteArray:
3463 case Type::ArrayParameter:
3476 case Type::ObjCInterface:
3477 case Type::ObjCObject:
3478 OS <<
"<objc_object>";
3487 QualType UnderlyingType =
T->castAsEnumDecl()->getIntegerType();
3489 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3492 case Type::FunctionNoProto:
3493 case Type::FunctionProto: {
3509 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3510 for (
QualType Param : FPT->param_types()) {
3514 if (FPT->isVariadic())
3521 case Type::MemberPointer: {
3525 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3529 case Type::ExtVector:
3537 case Type::ConstantMatrix:
3541 case Type::Builtin: {
3543 switch (BTy->getKind()) {
3544#define SIGNED_TYPE(Id, SingletonId) \
3545 case BuiltinType::Id: \
3548#define UNSIGNED_TYPE(Id, SingletonId) \
3549 case BuiltinType::Id: \
3552#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3553#define BUILTIN_TYPE(Id, SingletonId)
3554#include "clang/AST/BuiltinTypes.def"
3555 llvm_unreachable(
"placeholder types should not appear here.");
3557 case BuiltinType::Half:
3560 case BuiltinType::Float:
3563 case BuiltinType::Double:
3566 case BuiltinType::LongDouble:
3569 case BuiltinType::Float16:
3572 case BuiltinType::Float128:
3576 case BuiltinType::Void:
3580 case BuiltinType::ObjCId:
3581 case BuiltinType::ObjCClass:
3582 case BuiltinType::ObjCSel:
3583 case BuiltinType::NullPtr:
3588 case BuiltinType::OCLSampler:
3589 case BuiltinType::OCLEvent:
3590 case BuiltinType::OCLClkEvent:
3591 case BuiltinType::OCLQueue:
3592 case BuiltinType::OCLReserveID:
3593 case BuiltinType::BFloat16:
3594 case BuiltinType::VectorQuad:
3595 case BuiltinType::VectorPair:
3596 case BuiltinType::DMR1024:
3597 case BuiltinType::DMR2048:
3598 case BuiltinType::MetaInfo:
3603 case BuiltinType::Ibm128:
3605#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3606 case BuiltinType::Id: \
3608#include "clang/Basic/OpenCLImageTypes.def"
3609#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3610 case BuiltinType::Id: \
3612#include "clang/Basic/OpenCLExtensionTypes.def"
3613#define SVE_TYPE(Name, Id, SingletonId) \
3614 case BuiltinType::Id: \
3616#include "clang/Basic/AArch64ACLETypes.def"
3617#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3618 case BuiltinType::Id: \
3620#include "clang/Basic/HLSLIntangibleTypes.def"
3621#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
3622 case BuiltinType::Id: \
3624#include "clang/Basic/HLSLPackedTypes.def"
3625 case BuiltinType::Dependent:
3626 llvm_unreachable(
"should never get here");
3627#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3628#include "clang/Basic/AMDGPUTypes.def"
3629 case BuiltinType::WasmExternRef:
3630#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3631#include "clang/Basic/RISCVVTypes.def"
3632#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3633#include "clang/Basic/SPIRVTypes.def"
3634 llvm_unreachable(
"not yet implemented");
3636 llvm_unreachable(
"should never get here");
3638 case Type::Record: {
3639 const RecordDecl *RD =
T->castAsCanonical<RecordType>()->getDecl();
3659 II = Typedef->getDeclName().getAsIdentifierInfo();
3662 OS <<
"<anonymous_record>";
3668 case Type::HLSLAttributedResource:
3669 case Type::HLSLInlineSpirv:
3670 llvm_unreachable(
"should never get here");
3672 case Type::OverflowBehavior:
3673 llvm_unreachable(
"should never get here");
3675 case Type::DeducedTemplateSpecialization:
3677#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3678#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3679#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3680#define ABSTRACT_TYPE(Class, Base)
3681#define TYPE(Class, Base)
3682#include "clang/AST/TypeNodes.inc"
3683 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3689 assert(!
T->isDependentType() &&
3690 "cannot compute type discriminator of a dependent type");
3692 llvm::raw_svector_ostream Out(Str);
3694 if (
T->isFunctionPointerType() ||
T->isFunctionReferenceType())
3695 T =
T->getPointeeType();
3697 if (
T->isFunctionType()) {
3700 T =
T.getUnqualifiedType();
3721 if (MPT->isMemberFunctionPointer()) {
3727 MPT->getMostRecentCXXRecordDecl());
3731 MC->mangleCanonicalTypeName(
T, Out);
3734 return llvm::getPointerAuthStableSipHash(Str);
3759 "Type cannot have multiple ObjCGCs!");
3762 return getExtQualType(TypeNode, Quals);
3767 QualType Pointee = Ptr->getPointeeType();
3776 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3779 assert(CountExpr &&
"use getIncompleteCountAttributedType for a null count");
3786 llvm::FoldingSetNodeID ID;
3789 llvm::FoldingSetInsertToken
Token;
3795 CATy = CountAttributedType::Create(*
this, WrappedTy, CanonTy, CountExpr,
3796 CountInBytes, OrNull, DependentDecls);
3797 Types.push_back(CATy);
3798 CountAttributedTypes.insert(CATy,
Token);
3804 QualType WrappedTy,
bool CountInBytes,
bool OrNull)
const {
3819 return CountAttributedType::Create(
3821 nullptr, CountInBytes, OrNull,
3828 CATy->complete(*
this, CountExpr, DependentDecls);
3839 Types.push_back(CATy);
3849 Types.push_back(LPATy);
3857 case Type::Attributed: {
3865 case Type::BTFTagAttributed: {
3866 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3871 case Type::OverflowBehavior: {
3872 const auto *OB = dyn_cast<OverflowBehaviorType>(Orig);
3874 adjustType(OB->getUnderlyingType(), Adjust));
3881 case Type::Adjusted: {
3887 case Type::MacroQualified: {
3890 MQT->getMacroIdentifier());
3894 return Adjust(Orig);
3900 if (
T->getExtInfo() == Info)
3904 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(
T)) {
3924 FPT->getExtProtoInfo());
3939 L->DeducedReturnType(FD, ResultType);
3950 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3951 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3967 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
3990 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
4016 if (TSInfo->getType() != FD->
getType())
4024 "TypeLoc size mismatch from updating exception specification");
4025 TSInfo->overrideType(Updated);
4034 llvm::FoldingSetInsertToken
Token;
4041 if (!
T.isCanonical()) {
4044 assert(!ComplexTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4047 Types.push_back(
New);
4057 llvm::FoldingSetInsertToken
Token;
4064 if (!
T.isCanonical()) {
4067 assert(!PointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4070 Types.push_back(
New);
4076 llvm::FoldingSetInsertToken
Token;
4085 Types.push_back(AT);
4086 AdjustedTypes.insert(AT,
Token);
4091 llvm::FoldingSetInsertToken
Token;
4099 Types.push_back(AT);
4100 AdjustedTypes.insert(AT,
Token);
4105 assert((
T->isArrayType() ||
T->isFunctionType()) &&
"T does not decay");
4114 if (
T->isArrayType())
4121 if (
T->isFunctionType())
4133 llvm::FoldingSetNodeID ID;
4134 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
4135 ATy->getSizeExpr(), ATy->getSizeModifier(),
4136 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
4137 llvm::FoldingSetInsertToken
Token;
4147 AT = ArrayParameterTypes.lookup(ID,
Token);
4148 assert(!AT &&
"Shouldn't be in the map!");
4153 Types.push_back(AT);
4154 ArrayParameterTypes.insert(AT,
Token);
4161 assert(
T->isFunctionType() &&
"block of function types only");
4164 llvm::FoldingSetInsertToken
Token;
4171 if (!
T.isCanonical()) {
4174 assert(!BlockPointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4178 Types.push_back(
New);
4179 BlockPointerTypes.insert(
New,
Token);
4187 assert((!
T->isPlaceholderType() ||
4188 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4189 "Unresolved placeholder type");
4193 llvm::FoldingSetInsertToken
Token;
4195 LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token))
4203 if (!SpelledAsLValue || InnerRef || !
T.isCanonical()) {
4204 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4207 assert(!LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token) &&
4208 "Shouldn't be in the map!");
4213 Types.push_back(
New);
4214 LValueReferenceTypes.insert(
New,
Token);
4222 assert((!
T->isPlaceholderType() ||
4223 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4224 "Unresolved placeholder type");
4228 llvm::FoldingSetInsertToken
Token;
4237 if (InnerRef || !
T.isCanonical()) {
4238 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4241 assert(!RValueReferenceTypes.lookup({T, false},
Token) &&
4242 "Shouldn't be in the map!");
4247 Types.push_back(
New);
4248 RValueReferenceTypes.insert(
New,
Token);
4256 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4259 Cls = Qualifier.getAsRecordDecl();
4263 llvm::FoldingSetNodeID ID;
4266 llvm::FoldingSetInsertToken
Token;
4272 return Qualifier.getCanonical();
4274 assert(R.isCanonical());
4280 if (!
T.isCanonical() || Qualifier != CanonicalQualifier) {
4286 MemberPointerTypes.lookup(ID,
Token);
4287 assert(!NewIP &&
"Shouldn't be in the map!");
4291 Types.push_back(
New);
4292 MemberPointerTypes.insert(
New,
Token);
4299 const llvm::APInt &ArySizeIn,
4300 const Expr *SizeExpr,
4302 unsigned IndexTypeQuals)
const {
4305 "Constant array of VLAs is illegal!");
4313 llvm::APInt ArySize(ArySizeIn);
4314 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
4316 llvm::FoldingSetNodeID ID;
4318 ASM, IndexTypeQuals);
4320 llvm::FoldingSetInsertToken
Token;
4332 ASM, IndexTypeQuals);
4337 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4340 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4341 ASM, IndexTypeQuals);
4342 ConstantArrayTypes.insert(
New,
Token);
4343 Types.push_back(
New);
4352 if (!
type->isVariablyModifiedType())
return type;
4357 const Type *ty = split.
Ty;
4359#define TYPE(Class, Base)
4360#define ABSTRACT_TYPE(Class, Base)
4361#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4362#include "clang/AST/TypeNodes.inc"
4363 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4369 case Type::DependentVector:
4370 case Type::ExtVector:
4371 case Type::DependentSizedExtVector:
4372 case Type::ConstantMatrix:
4373 case Type::DependentSizedMatrix:
4374 case Type::DependentAddressSpace:
4375 case Type::ObjCObject:
4376 case Type::ObjCInterface:
4377 case Type::ObjCObjectPointer:
4380 case Type::UnresolvedUsing:
4381 case Type::TypeOfExpr:
4383 case Type::Decltype:
4384 case Type::UnaryTransform:
4385 case Type::DependentName:
4386 case Type::InjectedClassName:
4387 case Type::TemplateSpecialization:
4388 case Type::TemplateTypeParm:
4389 case Type::SubstTemplateTypeParmPack:
4390 case Type::SubstBuiltinTemplatePack:
4392 case Type::DeducedTemplateSpecialization:
4393 case Type::PackExpansion:
4394 case Type::PackIndexing:
4396 case Type::DependentBitInt:
4397 case Type::ArrayParameter:
4398 case Type::HLSLAttributedResource:
4399 case Type::HLSLInlineSpirv:
4400 case Type::OverflowBehavior:
4401 llvm_unreachable(
"type should never be variably-modified");
4405 case Type::FunctionNoProto:
4406 case Type::FunctionProto:
4407 case Type::BlockPointer:
4408 case Type::MemberPointer:
4421 case Type::LValueReference: {
4425 lv->isSpelledAsLValue());
4429 case Type::RValueReference: {
4436 case Type::Atomic: {
4442 case Type::ConstantArray: {
4448 cat->getSizeModifier(),
4449 cat->getIndexTypeCVRQualifiers());
4453 case Type::DependentSizedArray: {
4457 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4462 case Type::IncompleteArray: {
4467 iat->getIndexTypeCVRQualifiers());
4472 case Type::VariableArray: {
4477 vat->getIndexTypeCVRQualifiers());
4490 unsigned IndexTypeQuals)
const {
4507 VariableArrayTypes.push_back(
New);
4508 Types.push_back(
New);
4518 unsigned elementTypeQuals)
const {
4521 "Size must be type- or value-dependent!");
4525 llvm::FoldingSetInsertToken
Token;
4526 llvm::FoldingSetNodeID ID;
4528 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4529 ASM, elementTypeQuals, numElements);
4544 DependentSizedArrayTypes.insert(newType,
Token);
4545 Types.push_back(newType);
4553 numElements, ASM, elementTypeQuals);
4554 DependentSizedArrayTypes.insert(canonTy,
Token);
4555 Types.push_back(canonTy);
4560 canonElementType.
Quals);
4564 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4573 Types.push_back(sugaredType);
4579 unsigned elementTypeQuals)
const {
4580 llvm::FoldingSetNodeID ID;
4583 llvm::FoldingSetInsertToken
Token;
4596 ASM, elementTypeQuals);
4601 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4607 IncompleteArrayTypes.insert(newType,
Token);
4608 Types.push_back(newType);
4614#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4615 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4618#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4619 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4623 llvm_unreachable(
"Unsupported builtin vector type");
4625#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4626 ElBits, NF, IsSigned) \
4627 case BuiltinType::Id: \
4628 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4629 llvm::ElementCount::getScalable(NumEls), NF};
4630#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4632 case BuiltinType::Id: \
4633 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4634 llvm::ElementCount::getScalable(NumEls), NF};
4635#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4637 case BuiltinType::Id: \
4638 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4639#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4641 case BuiltinType::Id: \
4642 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4643#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4644 case BuiltinType::Id: \
4645 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4646#include "clang/Basic/AArch64ACLETypes.def"
4648#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4650 case BuiltinType::Id: \
4651 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4652 llvm::ElementCount::getScalable(NumEls), NF};
4653#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4654 case BuiltinType::Id: \
4655 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4656 llvm::ElementCount::getScalable(NumEls), NF};
4657#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4658 case BuiltinType::Id: \
4659 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4660#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4661 case BuiltinType::Id: \
4662 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4663#include "clang/Basic/RISCVVTypes.def"
4670 if (Target->getTriple().isWasm() && Target->hasFeature(
"reference-types")) {
4671#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4672 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4674#include "clang/Basic/WebAssemblyReferenceTypes.def"
4677 "shouldn't try to generate type externref outside WebAssembly target");
4684 unsigned NumFields)
const {
4686 if (
auto It = ScalableVecTyMap.find(K); It != ScalableVecTyMap.end())
4689 if (Target->hasAArch64ACLETypes()) {
4692#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4693 ElBits, NF, IsSigned) \
4694 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4695 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4696 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4697 return ScalableVecTyMap[K] = SingletonId; \
4699#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4701 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4702 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4703 return ScalableVecTyMap[K] = SingletonId; \
4705#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4707 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4708 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4709 return ScalableVecTyMap[K] = SingletonId; \
4711#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4713 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4714 NumElts == (NumEls * NF) && NumFields == 1) { \
4715 return ScalableVecTyMap[K] = SingletonId; \
4717#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4718 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4719 return ScalableVecTyMap[K] = SingletonId;
4720#include "clang/Basic/AArch64ACLETypes.def"
4721 }
else if (Target->hasRISCVVTypes()) {
4723#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4725 if (!EltTy->isBooleanType() && \
4726 ((EltTy->hasIntegerRepresentation() && \
4727 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4728 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4730 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4731 IsBF && !IsFP)) && \
4732 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4733 return ScalableVecTyMap[K] = SingletonId;
4734#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4735 if (EltTy->isBooleanType() && NumElts == NumEls) \
4736 return ScalableVecTyMap[K] = SingletonId;
4737#include "clang/Basic/RISCVVTypes.def"
4752 llvm::FoldingSetNodeID ID;
4755 llvm::FoldingSetInsertToken
Token;
4767 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4770 VectorType(vecType, NumElts, Canonical, VecKind);
4772 Types.push_back(
New);
4779 llvm::FoldingSetNodeID ID;
4782 llvm::FoldingSetInsertToken
Token;
4788 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4791 if (CanonVecTy == VecType) {
4796 assert(!CanonCheck &&
4797 "Dependent-sized vector_size canonical type broken");
4799 DependentVectorTypes.insert(
New,
Token);
4808 Types.push_back(
New);
4815 unsigned NumElts)
const {
4822 llvm::FoldingSetNodeID ID;
4825 llvm::FoldingSetInsertToken
Token;
4837 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4842 Types.push_back(
New);
4850 llvm::FoldingSetNodeID ID;
4854 llvm::FoldingSetInsertToken
Token;
4856 DependentSizedExtVectorTypes.lookup(ID,
Token);
4866 if (CanonVecTy == vecType) {
4871 DependentSizedExtVectorTypes.lookup(ID,
Token);
4872 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4874 DependentSizedExtVectorTypes.insert(
New,
Token);
4883 Types.push_back(
New);
4888 QualType ElementTy,
unsigned NumRows,
unsigned NumColumns,
4889 std::optional<MatrixType::LayoutKind> Layout)
const {
4890 llvm::FoldingSetNodeID ID;
4892 Type::ConstantMatrix);
4895 "need a valid element type");
4896 assert(NumRows > 0 && NumRows <= LangOpts.MaxMatrixDimension &&
4897 NumColumns > 0 && NumColumns <= LangOpts.MaxMatrixDimension &&
4898 "need valid matrix dimensions");
4899 llvm::FoldingSetInsertToken
Token;
4906 NumColumns, std::nullopt);
4909 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4916 Types.push_back(
New);
4925 llvm::FoldingSetNodeID ID;
4929 llvm::FoldingSetInsertToken
Token;
4935 ColumnExpr, AttrLoc);
4938 DependentSizedMatrixTypes.lookup(ID,
Token);
4939 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4941 DependentSizedMatrixTypes.insert(Canon,
Token);
4942 Types.push_back(Canon);
4955 ColumnExpr, AttrLoc);
4956 Types.push_back(
New);
4964 const Type *Ty =
T->getUnqualifiedDesugaredType();
4966 if (
const auto *MT = dyn_cast<ConstantMatrixType>(Ty))
4969 MT->getNumColumns(), Layout),
4972 const auto *CAT = dyn_cast<ConstantArrayType>(Ty);
4978 CAT->getSizeExpr(), CAT->getSizeModifier(),
4979 CAT->getIndexTypeCVRQualifiers());
4987 Expr *AddrSpaceExpr,
4993 llvm::FoldingSetInsertToken
Token;
4994 llvm::FoldingSetNodeID ID;
4999 DependentAddressSpaceTypes.lookup(ID,
Token);
5005 DependentAddressSpaceTypes.insert(canonTy,
Token);
5006 Types.push_back(canonTy);
5009 if (canonPointeeType == PointeeType &&
5015 AddrSpaceExpr, AttrLoc);
5016 Types.push_back(sugaredType);
5022 return T.isCanonical() &&
5040 llvm::FoldingSetNodeID ID;
5043 llvm::FoldingSetInsertToken
Token;
5054 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5059 Types.push_back(
New);
5060 FunctionNoProtoTypes.insert(
New,
Token);
5076 return CanResultType;
5083 if (!NoexceptInType)
5100 bool AnyPackExpansions =
false;
5104 if (ET->
getAs<PackExpansionType>())
5105 AnyPackExpansions =
true;
5107 return AnyPackExpansions;
5113QualType ASTContext::getFunctionTypeInternal(
5114 QualType ResultTy, ArrayRef<QualType> ArgArray,
5115 const FunctionProtoType::ExtProtoInfo &EPI,
bool OnlyWantCanonical)
const {
5116 size_t NumArgs = ArgArray.size();
5120 llvm::FoldingSetNodeID
ID;
5125 bool Unique =
false;
5127 llvm::FoldingSetInsertToken Token;
5128 if (FunctionProtoType *FPT = FunctionProtoTypes.lookup(ID, Token)) {
5129 QualType Existing = QualType(FPT, 0);
5148 bool IsCanonicalExceptionSpec =
5152 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
5154 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
5155 if (!ArgArray[i].isCanonicalAsParam())
5156 isCanonical =
false;
5158 if (OnlyWantCanonical)
5159 assert(isCanonical &&
5160 "given non-canonical parameters constructing canonical type");
5165 if (!isCanonical && Canonical.
isNull()) {
5166 SmallVector<QualType, 16> CanonicalArgs;
5167 CanonicalArgs.reserve(NumArgs);
5168 for (
unsigned i = 0; i != NumArgs; ++i)
5171 llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
5172 FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
5175 if (IsCanonicalExceptionSpec) {
5177 }
else if (NoexceptInType) {
5190 bool AnyPacks =
false;
5192 if (ET->
getAs<PackExpansionType>())
5213 llvm_unreachable(
"dependent noexcept is already canonical");
5216 CanonicalEPI.
ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
5222 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5225 FunctionProtoType *NewIP = FunctionProtoTypes.lookup(ID, Token);
5226 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5231 auto ESH = FunctionProtoType::getExceptionSpecSize(
5233 size_t Size = FunctionProtoType::totalSizeToAlloc<
5234 QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
5235 FunctionType::FunctionTypeExtraAttributeInfo,
5236 FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
5237 Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, Qualifiers,
5238 FunctionEffect, EffectConditionExpr>(
5242 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5247 auto *FTP = (FunctionProtoType *)
Allocate(Size,
alignof(FunctionProtoType));
5248 FunctionProtoType::ExtProtoInfo newEPI = EPI;
5249 new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
5250 Types.push_back(FTP);
5252 FunctionProtoTypes.insert(FTP, Token);
5254 AnyFunctionEffects =
true;
5255 return QualType(FTP, 0);
5258QualType ASTContext::getPipeType(QualType
T,
bool ReadOnly)
const {
5259 llvm::FoldingSetInsertToken Token;
5260 if (PipeType *PT = PipeTypes.lookup({T, ReadOnly}, Token))
5261 return QualType(PT, 0);
5266 if (!
T.isCanonical()) {
5269 assert(!PipeTypes.lookup({T, ReadOnly}, Token) &&
5270 "Shouldn't be in the map!");
5272 auto *
New =
new (*
this,
alignof(PipeType)) PipeType(
T, Canonical, ReadOnly);
5273 Types.push_back(
New);
5274 PipeTypes.insert(
New, Token);
5275 return QualType(
New, 0);
5285 return getPipeType(
T,
true);
5289 return getPipeType(
T,
false);
5293 auto Key = std::make_pair(
unsigned(IsUnsigned), NumBits);
5295 llvm::FoldingSetInsertToken
Token;
5301 Types.push_back(
New);
5306 Expr *NumBitsExpr)
const {
5308 llvm::FoldingSetNodeID ID;
5311 llvm::FoldingSetInsertToken
Token;
5317 DependentBitIntTypes.insert(
New,
Token);
5319 Types.push_back(
New);
5327 if (
auto *Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5339 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5340 case Kind::SignedSizeT:
5342 case Kind::PtrdiffT:
5345 llvm_unreachable(
"unexpected kind");
5350 Types.push_back(
New);
5351 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5358 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5361 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5363 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5372 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5374 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5376 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5378 assert(TD->TypeForDecl);
5383 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5385 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5386 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5389 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5392 assert(
Decl->TypeForDecl);
5402 std::optional<bool> TypeMatchesDeclOrNone)
const {
5403 if (!TypeMatchesDeclOrNone) {
5404 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5405 assert(!DeclUnderlyingType.
isNull());
5406 if (UnderlyingType.
isNull())
5407 UnderlyingType = DeclUnderlyingType;
5409 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5410 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5414 assert(!UnderlyingType.
isNull());
5418 *TypeMatchesDeclOrNone) {
5419 if (
Decl->TypeForDecl)
5424 !*TypeMatchesDeclOrNone);
5426 Types.push_back(NewType);
5427 Decl->TypeForDecl = NewType;
5431 llvm::FoldingSetNodeID ID;
5433 *TypeMatchesDeclOrNone ?
QualType() : UnderlyingType);
5435 llvm::FoldingSetInsertToken
Token;
5437 TypedefTypes.lookup(ID,
Token))
5438 return QualType(Placeholder->getType(), 0);
5443 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5447 UnderlyingType, !*TypeMatchesDeclOrNone);
5448 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5450 TypedefTypes.insert(Placeholder,
Token);
5451 Types.push_back(NewType);
5460 if (UnderlyingType.
isNull()) {
5468 llvm::FoldingSetNodeID ID;
5471 llvm::FoldingSetInsertToken
Token;
5482 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5486 UsingTypes.insert(
T,
Token);
5492 const TagDecl *TD,
bool OwnsTag,
5494 const Type *CanonicalType,
5495 bool WithFoldingSetNode)
const {
5496 auto [TC, Size] = [&] {
5499 static_assert(
alignof(EnumType) ==
alignof(TagType));
5500 return std::make_tuple(Type::Enum,
sizeof(EnumType));
5501 case Decl::ClassTemplatePartialSpecialization:
5502 case Decl::ClassTemplateSpecialization:
5503 case Decl::CXXRecord:
5504 static_assert(
alignof(RecordType) ==
alignof(TagType));
5505 static_assert(
alignof(InjectedClassNameType) ==
alignof(TagType));
5507 return std::make_tuple(Type::InjectedClassName,
5508 sizeof(InjectedClassNameType));
5511 return std::make_tuple(Type::Record,
sizeof(RecordType));
5513 llvm_unreachable(
"unexpected decl kind");
5523 if (WithFoldingSetNode) {
5531 sizeof(TagTypeFoldingSetPlaceholder) +
5532 TagTypeFoldingSetPlaceholder::getOffset() + Size,
5533 std::max(
alignof(TagTypeFoldingSetPlaceholder),
alignof(TagType)));
5534 auto *
T =
new (Mem) TagTypeFoldingSetPlaceholder();
5535 Mem =
T->getTagType();
5537 Mem =
Allocate(Size,
alignof(TagType));
5540 auto *
T = [&, TC = TC]() -> TagType * {
5544 auto *
T =
new (Mem) EnumType(TC,
Keyword, Qualifier, TD, OwnsTag,
5545 IsInjected, CanonicalType);
5546 assert(
reinterpret_cast<void *
>(
T) ==
5547 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5548 "TagType must be the first base of EnumType");
5551 case Type::Record: {
5553 auto *
T =
new (Mem) RecordType(TC,
Keyword, Qualifier, TD, OwnsTag,
5554 IsInjected, CanonicalType);
5555 assert(
reinterpret_cast<void *
>(
T) ==
5556 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5557 "TagType must be the first base of RecordType");
5560 case Type::InjectedClassName: {
5561 auto *
T =
new (Mem) InjectedClassNameType(
Keyword, Qualifier, TD,
5562 IsInjected, CanonicalType);
5563 assert(
reinterpret_cast<void *
>(
T) ==
5564 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5565 "TagType must be the first base of InjectedClassNameType");
5569 llvm_unreachable(
"unexpected type class");
5572 assert(
T->getKeyword() ==
Keyword);
5573 assert(
T->getQualifier() == Qualifier);
5574 assert(
T->getDecl() == TD);
5575 assert(
T->isInjected() == IsInjected);
5576 assert(
T->isTagOwned() == OwnsTag);
5585 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5586 RD && RD->isInjectedClassName())
5593 if (TD->TypeForDecl)
5594 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5596 const Type *CanonicalType = getTagTypeInternal(
5599 false,
false,
nullptr,
5601 TD->TypeForDecl = CanonicalType;
5607 const TagDecl *TD,
bool OwnsTag)
const {
5610 bool IsInjected = TD != NonInjectedTD;
5617 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5618 if (
const Type *
T = TD->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5624 std::nullopt, NonInjectedTD,
5625 false, IsInjected, CanonicalType,
5627 TD->TypeForDecl =
T;
5631 llvm::FoldingSetNodeID ID;
5632 TagTypeFoldingSetPlaceholder::Profile(ID,
Keyword, Qualifier, NonInjectedTD,
5633 OwnsTag, IsInjected);
5635 llvm::FoldingSetInsertToken
Token;
5636 if (TagTypeFoldingSetPlaceholder *
T = TagTypes.lookup(ID,
Token))
5641 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5642 CanonicalType,
true);
5643 TagTypes.insert(TagTypeFoldingSetPlaceholder::fromTagType(
T),
Token);
5648 unsigned NumPositiveBits,
5651 unsigned IntWidth = Target->getIntWidth();
5652 unsigned CharWidth = Target->getCharWidth();
5653 unsigned ShortWidth = Target->getShortWidth();
5654 bool EnumTooLarge =
false;
5656 if (NumNegativeBits) {
5660 if (IsPacked && NumNegativeBits <= CharWidth &&
5661 NumPositiveBits < CharWidth) {
5663 BestWidth = CharWidth;
5664 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5665 NumPositiveBits < ShortWidth) {
5667 BestWidth = ShortWidth;
5668 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5670 BestWidth = IntWidth;
5672 BestWidth = Target->getLongWidth();
5674 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5677 BestWidth = Target->getLongLongWidth();
5679 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5680 EnumTooLarge =
true;
5684 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5689 if (IsPacked && NumPositiveBits <= CharWidth) {
5691 BestPromotionType =
IntTy;
5692 BestWidth = CharWidth;
5693 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5695 BestPromotionType =
IntTy;
5696 BestWidth = ShortWidth;
5697 }
else if (NumPositiveBits <= IntWidth) {
5699 BestWidth = IntWidth;
5700 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5703 }
else if (NumPositiveBits <= (BestWidth = Target->getLongWidth())) {
5705 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5709 BestWidth = Target->getLongLongWidth();
5710 if (NumPositiveBits > BestWidth) {
5715 EnumTooLarge =
true;
5718 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5723 return EnumTooLarge;
5727 assert((
T->isIntegralType(*
this) ||
T->isEnumeralType()) &&
5728 "Integral type required!");
5731 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5732 if (
T->isSignedIntegerOrEnumerationType())
5734 return Value.getActiveBits() <= BitWidth;
5736 return Value.getSignificantBits() <= BitWidth;
5742 const Type *CanonicalType)
const {
5744 UnresolvedUsingType::totalSizeToAlloc<
5746 !!
Token, !!Qualifier),
5750 auto *Placeholder =
new (
T->getFoldingSetPlaceholder())
5752 UnresolvedUsingTypes.insert(Placeholder,
Token);
5762 return D->TypeForDecl->getCanonicalTypeUnqualified();
5764 const Type *CanonicalType =
5768 D->TypeForDecl = CanonicalType;
5777 if (
const Type *
T = D->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5789 llvm::FoldingSetNodeID ID;
5792 llvm::FoldingSetInsertToken
Token;
5794 UnresolvedUsingTypes.lookup(ID,
Token))
5795 return QualType(Placeholder->getType(), 0);
5808 llvm::FoldingSetNodeID id;
5809 AttributedType::Profile(
id, *
this, attrKind, modifiedType, equivalentType,
5812 llvm::FoldingSetInsertToken
Token;
5813 AttributedType *
type = AttributedTypes.lookup(
id,
Token);
5816 assert(!
attr ||
attr->getKind() == attrKind);
5819 type =
new (*
this,
alignof(AttributedType))
5820 AttributedType(canon, attrKind,
attr, modifiedType, equivalentType);
5822 Types.push_back(
type);
5836 switch (nullability) {
5852 llvm_unreachable(
"Unknown nullability kind");
5857 llvm::FoldingSetNodeID ID;
5858 BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
5860 llvm::FoldingSetInsertToken
Token;
5861 BTFTagAttributedType *Ty = BTFTagAttributedTypes.lookup(ID,
Token);
5866 Ty =
new (*
this,
alignof(BTFTagAttributedType))
5867 BTFTagAttributedType(Canon, Wrapped, BTFAttr);
5869 Types.push_back(Ty);
5870 BTFTagAttributedTypes.insert(Ty,
Token);
5878 StringRef IdentName = II->
getName();
5879 OverflowBehaviorType::OverflowBehaviorKind Kind;
5880 if (IdentName ==
"wrap") {
5881 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
5882 }
else if (IdentName ==
"trap") {
5883 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
5892 OverflowBehaviorType::OverflowBehaviorKind Kind,
5895 "Cannot have underlying types that are themselves OBTs");
5897 llvm::FoldingSetInsertToken
Token;
5898 if (OverflowBehaviorType *OBT =
5899 OverflowBehaviorTypes.lookup({Underlying, Kind},
Token)) {
5908 assert(!OverflowBehaviorTypes.lookup({Underlying, Kind},
Token) &&
5909 "Shouldn't be in the map");
5912 OverflowBehaviorType *Ty =
new (*
this,
alignof(OverflowBehaviorType))
5913 OverflowBehaviorType(*
this, Canonical, Underlying, Kind);
5915 Types.push_back(Ty);
5916 OverflowBehaviorTypes.insert(Ty,
Token);
5922 const HLSLAttributedResourceType::Attributes &Attrs) {
5924 llvm::FoldingSetNodeID ID;
5925 HLSLAttributedResourceType::Profile(ID, *
this, Wrapped, Contained, Attrs);
5927 llvm::FoldingSetInsertToken
Token;
5928 HLSLAttributedResourceType *Ty =
5929 HLSLAttributedResourceTypes.lookup(ID,
Token);
5933 Ty =
new (*
this,
alignof(HLSLAttributedResourceType))
5934 HLSLAttributedResourceType(Wrapped, Contained, Attrs);
5936 Types.push_back(Ty);
5937 HLSLAttributedResourceTypes.insert(Ty,
Token);
5945 llvm::FoldingSetNodeID ID;
5946 HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
5948 llvm::FoldingSetInsertToken
Token;
5949 HLSLInlineSpirvType *Ty = HLSLInlineSpirvTypes.lookup(ID,
Token);
5954 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5955 alignof(HLSLInlineSpirvType));
5957 Ty =
new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
5959 Types.push_back(Ty);
5960 HLSLInlineSpirvTypes.insert(Ty,
Token);
5967 Decl *AssociatedDecl,
5972 std::make_tuple(Replacement, AssociatedDecl, Index,
5973 PackIndex.toInternalRepresentation(),
unsigned(Final));
5974 llvm::FoldingSetInsertToken
Token;
5975 SubstTemplateTypeParmType *SubstParm =
5976 SubstTemplateTypeParmTypes.lookup(Key,
Token);
5979 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5980 !Replacement.isCanonical()),
5981 alignof(SubstTemplateTypeParmType));
5982 SubstParm =
new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
5984 Types.push_back(SubstParm);
5985 SubstTemplateTypeParmTypes.insert(SubstParm,
Token);
5993 unsigned Index,
bool Final,
6000 llvm::FoldingSetNodeID ID;
6001 SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
6003 llvm::FoldingSetInsertToken
Token;
6004 if (SubstTemplateTypeParmPackType *SubstParm =
6005 SubstTemplateTypeParmPackTypes.lookup(ID,
Token))
6015 [[maybe_unused]]
const auto *Nothing =
6016 SubstTemplateTypeParmPackTypes.lookup(ID,
Token);
6021 auto *SubstParm =
new (*
this,
alignof(SubstTemplateTypeParmPackType))
6022 SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
6024 Types.push_back(SubstParm);
6025 SubstTemplateTypeParmPackTypes.insert(SubstParm,
Token);
6033 return P.getKind() == TemplateArgument::Type;
6035 "Pack contains a non-type");
6037 llvm::FoldingSetNodeID ID;
6038 SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
6040 llvm::FoldingSetInsertToken
Token;
6041 if (
auto *
T = SubstBuiltinTemplatePackTypes.lookup(ID,
Token))
6050 [[maybe_unused]]
const auto *Nothing =
6051 SubstBuiltinTemplatePackTypes.lookup(ID,
Token);
6055 auto *PackType =
new (*
this,
alignof(SubstBuiltinTemplatePackType))
6056 SubstBuiltinTemplatePackType(Canon, ArgPack);
6057 Types.push_back(PackType);
6058 SubstBuiltinTemplatePackTypes.insert(PackType,
Token);
6068 assert(Depth >= 0 &&
"Depth must be non-negative");
6069 assert(Index >= 0 &&
"Index must be non-negative");
6071 auto Key = std::make_tuple(
unsigned(Depth),
unsigned(Index),
6072 unsigned(ParameterPack), TTPDecl);
6073 llvm::FoldingSetInsertToken
Token;
6074 TemplateTypeParmType *TypeParm = TemplateTypeParmTypes.lookup(Key,
Token);
6081 TypeParm =
new (*
this,
alignof(TemplateTypeParmType))
6082 TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
6084 TypeParm =
new (*
this,
alignof(TemplateTypeParmType)) TemplateTypeParmType(
6085 Depth, Index, ParameterPack,
nullptr,
QualType());
6087 Types.push_back(TypeParm);
6088 TemplateTypeParmTypes.insert(TypeParm,
Token);
6114 llvm_unreachable(
"unexpected keyword kind");
6128 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
6138 SpecifiedArgVec.reserve(SpecifiedArgs.size());
6140 SpecifiedArgVec.push_back(Arg.getArgument());
6143 CanonicalArgs, Underlying);
6146[[maybe_unused]]
static bool
6149 if (Arg.isPackExpansion())
6160 Template.getAsDependentTemplateName()));
6162 for (
const auto &Arg : Args)
6166 llvm::FoldingSetNodeID ID;
6169 llvm::FoldingSetInsertToken
Token;
6170 if (
auto *
T = TemplateSpecializationTypes.lookup(ID,
Token))
6173 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6175 alignof(TemplateSpecializationType));
6179 assert(Spec->isDependentType() &&
6180 "canonical template specialization must be dependent");
6181 Types.push_back(Spec);
6182 TemplateSpecializationTypes.insert(Spec,
Token);
6190 const auto *TD =
Template.getAsTemplateDecl(
true);
6191 bool IsTypeAlias = TD && TD->isTypeAlias();
6192 if (Underlying.
isNull()) {
6199 bool NonCanonical =
Template != CanonTemplate ||
Keyword != CanonKeyword;
6201 if (CanonicalArgs.empty()) {
6204 CanonicalArgs = CanonArgsVec;
6206 NonCanonical |= !llvm::equal(
6207 SpecifiedArgs, CanonicalArgs,
6216 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
6218 "Caller must compute aliased type");
6219 IsTypeAlias =
false;
6222 CanonKeyword, CanonTemplate, CanonicalArgs);
6226 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6228 (IsTypeAlias ?
sizeof(
QualType) : 0),
6229 alignof(TemplateSpecializationType));
6230 auto *Spec =
new (Mem) TemplateSpecializationType(
6232 Types.push_back(Spec);
6238 llvm::FoldingSetInsertToken
Token;
6246 assert(!ParenTypes.lookup(InnerType,
Token) &&
6247 "Paren canonical type broken");
6252 ParenTypes.insert(
T,
Token);
6265 Types.push_back(newType);
6272 llvm::FoldingSetNodeID ID;
6273 DependentNameType::Profile(ID,
Keyword, NNS, Name);
6275 llvm::FoldingSetInsertToken
Token;
6276 if (DependentNameType *
T = DependentNameTypes.lookup(ID,
Token))
6284 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6286 [[maybe_unused]] DependentNameType *
T =
6287 DependentNameTypes.lookup(ID,
Token);
6288 assert(!
T &&
"broken canonicalization");
6292 DependentNameType *
T =
new (*
this,
alignof(DependentNameType))
6293 DependentNameType(
Keyword, NNS, Name, Canon);
6295 DependentNameTypes.insert(
T,
Token);
6301 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6303 if (TTP->isParameterPack())
6307 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6309 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6315 if (NTTP->getType()->isReferenceType()) {
6319 }
else if (
T->isRecordType()) {
6326 Expr *E =
new (*this)
6328 T,
VK, NTTP->getLocation());
6330 if (NTTP->isParameterPack())
6336 std::nullopt,
false,
6338 if (TTP->isParameterPack())
6344 if (Param->isTemplateParameterPack())
6353 bool ExpectPackInType)
const {
6355 "Pack expansions must expand one or more parameter packs");
6359 llvm::FoldingSetInsertToken
Token;
6360 PackExpansionType *
T = PackExpansionTypes.lookup(Key,
Token);
6371 PackExpansionTypes.lookup(Key,
Token);
6374 T =
new (*
this,
alignof(PackExpansionType))
6375 PackExpansionType(Pattern, Canon, NumExpansions);
6377 PackExpansionTypes.insert(
T,
Token);
6389 if (Protocols.empty())
return true;
6394 for (
unsigned i = 1; i != Protocols.size(); ++i)
6404 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6408 P = P->getCanonicalDecl();
6411 auto ProtocolsEnd = llvm::unique(Protocols);
6412 Protocols.erase(ProtocolsEnd, Protocols.end());
6417 unsigned NumProtocols)
const {
6426 bool isKindOf)
const {
6429 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6434 llvm::FoldingSetNodeID ID;
6435 ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
6436 llvm::FoldingSetInsertToken
Token;
6444 if (effectiveTypeArgs.empty()) {
6446 effectiveTypeArgs = baseObject->getTypeArgs();
6453 bool typeArgsAreCanonical = llvm::all_of(
6456 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6460 if (!typeArgsAreCanonical) {
6461 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6462 for (
auto typeArg : effectiveTypeArgs)
6464 canonTypeArgs = canonTypeArgsVec;
6466 canonTypeArgs = effectiveTypeArgs;
6471 if (!protocolsSorted) {
6472 canonProtocolsVec.append(protocols.begin(), protocols.end());
6474 canonProtocols = canonProtocolsVec;
6476 canonProtocols = protocols;
6480 canonProtocols, isKindOf);
6483 ObjCObjectTypes.lookup(ID,
Token);
6486 unsigned size =
sizeof(ObjCObjectTypeImpl);
6487 size += typeArgs.size() *
sizeof(
QualType);
6489 void *mem =
Allocate(size,
alignof(ObjCObjectTypeImpl));
6491 new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
6495 ObjCObjectTypes.insert(
T,
Token);
6505 bool allowOnPointerType)
const {
6508 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6513 if (allowOnPointerType) {
6514 if (
const auto *objPtr =
6515 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6519 protocolsVec.append(objT->qual_begin(),
6521 protocolsVec.append(protocols.begin(), protocols.end());
6524 objT->getBaseType(),
6525 objT->getTypeArgsAsWritten(),
6527 objT->isKindOfTypeAsWritten());
6533 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6538 objT->getTypeArgsAsWritten(),
6540 objT->isKindOfTypeAsWritten());
6544 if (
type->isObjCObjectType()) {
6554 if (
type->isObjCIdType()) {
6557 objPtr->isKindOfType());
6562 if (
type->isObjCClassType()) {
6565 objPtr->isKindOfType());
6578 if (!protocols.empty()) {
6582 Canonical, protocols, hasError,
true ));
6583 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6588 auto Key = std::make_tuple(
Decl, Canonical, protocols);
6589 llvm::FoldingSetInsertToken
Token;
6590 if (ObjCTypeParamType *TypeParam = ObjCTypeParamTypes.lookup(Key,
Token))
6593 unsigned size =
sizeof(ObjCTypeParamType);
6595 void *mem =
Allocate(size,
alignof(ObjCTypeParamType));
6596 auto *newType =
new (mem) ObjCTypeParamType(
Decl, Canonical, protocols);
6598 Types.push_back(newType);
6599 ObjCTypeParamTypes.insert(newType,
Token);
6609 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6624 for (
auto *Proto : OPT->quals()) {
6647 if (InheritedProtocols.empty())
6651 bool Conforms =
false;
6652 for (
auto *Proto : OPT->quals()) {
6654 for (
auto *PI : InheritedProtocols) {
6666 for (
auto *PI : InheritedProtocols) {
6668 bool Adopts =
false;
6669 for (
auto *Proto : OPT->quals()) {
6683 llvm::FoldingSetInsertToken
Token;
6698 Types.push_back(QType);
6699 ObjCObjectPointerTypes.insert(QType,
Token);
6707 if (
Decl->TypeForDecl)
6711 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6712 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6713 return QualType(PrevDecl->TypeForDecl, 0);
6722 Decl->TypeForDecl =
T;
6735 llvm::FoldingSetNodeID ID;
6739 llvm::FoldingSetInsertToken
Token;
6750 DependentTypeOfExprTypes.insert(Canon,
Token);
6758 Types.push_back(toe);
6769 auto *tot =
new (*
this,
alignof(TypeOfType))
6770 TypeOfType(*
this, tofType, Canonical, Kind);
6771 Types.push_back(tot);
6795 llvm_unreachable(
"Unknown value kind");
6810 }
else if (!UnderlyingType.
isNull()) {
6813 llvm::FoldingSetNodeID ID;
6814 DependentDecltypeType::Profile(ID, *
this, E);
6816 llvm::FoldingSetInsertToken
Token;
6817 if (DependentDecltypeType *Canon = DependentDecltypeTypes.lookup(ID,
Token))
6822 new (*
this,
alignof(DependentDecltypeType)) DependentDecltypeType(E);
6823 DependentDecltypeTypes.insert(DT,
Token);
6824 Types.push_back(DT);
6827 auto *DT =
new (*
this,
alignof(DecltypeType))
6828 DecltypeType(E, UnderlyingType, CanonType);
6829 Types.push_back(DT);
6834 bool FullySubstituted,
6838 if (FullySubstituted && Index) {
6841 llvm::FoldingSetNodeID ID;
6842 PackIndexingType::Profile(ID, *
this, Pattern.
getCanonicalType(), IndexExpr,
6843 FullySubstituted, Expansions);
6844 llvm::FoldingSetInsertToken
Token;
6845 PackIndexingType *Canon = DependentPackIndexingTypes.lookup(ID,
Token);
6848 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6852 IndexExpr, FullySubstituted, Expansions);
6853 DependentPackIndexingTypes.insert(Canon,
Token);
6859 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6861 auto *
T =
new (Mem) PackIndexingType(Canonical, Pattern, IndexExpr,
6862 FullySubstituted, Expansions);
6871 UnaryTransformType::UTTKind Kind)
const {
6874 if (BaseType->isDependentType()) {
6875 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6879 auto Key = std::make_tuple(BaseType, UnderlyingType, Kind);
6881 llvm::FoldingSetInsertToken
Token;
6882 if (UnaryTransformType *UT = UnaryTransformTypes.lookup(Key,
Token))
6886 if (!BaseType->isDependentType()) {
6890 BaseType != CanonBase) {
6896 auto *UT =
new (*
this,
alignof(UnaryTransformType))
6897 UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
6898 UnaryTransformTypes.insert(UT,
Token);
6899 Types.push_back(UT);
6912 TypeConstraintConcept.
isNull()) {
6913 assert(DeducedAsType.
isNull() &&
"");
6914 assert(TypeConstraintArgs.empty() &&
"");
6919 llvm::FoldingSetNodeID ID;
6920 AutoType::Profile(ID, *
this, DK, DeducedAsType,
Keyword,
6921 TypeConstraintConcept, TypeConstraintArgs);
6922 if (
auto const AT_iter = AutoTypes.find_as(ID); AT_iter != AutoTypes.end())
6923 return QualType(AT_iter->getSecond(), 0);
6926 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6928 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6929 if (!TypeConstraintConcept.
isNull()) {
6930 bool AnyNonCanonArgs =
false;
6934 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6935 if (TypeConstraintConcept != CanonicalConcept || AnyNonCanonArgs)
6937 CanonicalConceptArgs);
6941 void *Mem =
Allocate(
sizeof(AutoType) +
6944 auto *AT =
new (Mem) AutoType(DK, DeducedAsType,
Keyword,
6945 TypeConstraintConcept, TypeConstraintArgs);
6947 llvm::FoldingSetNodeID InsertedID;
6948 AT->Profile(InsertedID, *
this);
6949 assert(InsertedID == ID &&
"ID does not match");
6951 Types.push_back(AT);
6952 AutoTypes.try_emplace(ID.Intern(BumpAlloc), AT);
6957 QualType CanonT =
T.getNonPackExpansionType().getCanonicalType();
6960 if (
auto *AT = CanonT->
getAs<AutoType>()) {
6961 if (!AT->isConstrained())
6983 llvm::FoldingSetInsertToken
Token;
6984 llvm::FoldingSetNodeID ID;
6985 DeducedTemplateSpecializationType::Profile(ID, DK, DeducedAsType,
Keyword,
6987 if (DeducedTemplateSpecializationType *DTST =
6988 DeducedTemplateSpecializationTypes.lookup(ID,
Token))
6992 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6994 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
7003 [[maybe_unused]] DeducedTemplateSpecializationType *DTST =
7004 DeducedTemplateSpecializationTypes.lookup(ID,
Token);
7005 assert(!DTST &&
"broken canonicalization");
7009 auto *DTST =
new (*
this,
alignof(DeducedTemplateSpecializationType))
7010 DeducedTemplateSpecializationType(DK, DeducedAsType,
Keyword,
Template);
7013 llvm::FoldingSetNodeID TempID;
7014 DTST->Profile(TempID);
7015 assert(ID == TempID &&
"ID does not match");
7017 Types.push_back(DTST);
7018 DeducedTemplateSpecializationTypes.insert(DTST,
Token);
7027 llvm::FoldingSetInsertToken
Token;
7034 if (!
T.isCanonical()) {
7037 assert(!AtomicTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
7040 Types.push_back(
New);
7049 new (*
this,
alignof(AutoType))
7073 return getFromTargetType(Target->getSizeType());
7092 return getFromTargetType(Target->getUnsignedPtrDiffType(
LangAS::Default));
7097 return getFromTargetType(Target->getIntMaxType());
7102 return getFromTargetType(Target->getUIntMaxType());
7120 return getFromTargetType(Target->getIntPtrType());
7130 return getFromTargetType(Target->getProcessIDType());
7142 const Type *Ty =
T.getTypePtr();
7170 quals = splitType.
Quals;
7175 QualType elementType = AT->getElementType();
7180 if (elementType == unqualElementType) {
7181 assert(quals.
empty());
7182 quals = splitType.
Quals;
7190 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7192 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7195 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7199 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7201 VAT->getSizeModifier(),
7202 VAT->getIndexTypeCVRQualifiers());
7207 DSAT->getSizeModifier(), 0);
7217 bool AllowPiMismatch)
const {
7232 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7233 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7234 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7247 T1 = AT1->getElementType();
7248 T2 = AT2->getElementType();
7268 bool AllowPiMismatch)
const {
7273 if (T1PtrType && T2PtrType) {
7281 T1MPType && T2MPType) {
7284 if (T1MPType->getQualifier() != T2MPType->getQualifier())
7296 if (T1OPType && T2OPType) {
7328 if (Quals1 != Quals2)
7402 llvm_unreachable(
"bad template name kind!");
7408 if (!TP->hasDefaultArgument())
7410 return &TP->getDefaultArgument().getArgument();
7413 case NamedDecl::TemplateTypeParm:
7415 case NamedDecl::NonTypeTemplateParm:
7417 case NamedDecl::TemplateTemplateParm:
7420 llvm_unreachable(
"Unexpected template parameter kind");
7425 bool IgnoreDeduced)
const {
7426 while (std::optional<TemplateName> UnderlyingOrNone =
7428 Name = *UnderlyingOrNone;
7433 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7445 llvm_unreachable(
"cannot canonicalize overloaded template");
7449 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7478 assert(IgnoreDeduced ==
false);
7485 bool NonCanonical = CanonUnderlying != Underlying;
7491 assert(CanonArgs.size() <= Params.size());
7497 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7506 if (I ==
int(CanonArgs.size() - 1))
7507 CanonArgs.pop_back();
7508 NonCanonical =
true;
7518 llvm_unreachable(
"always sugar node");
7521 llvm_unreachable(
"bad template name!");
7526 bool IgnoreDeduced)
const {
7547 llvm::FoldingSetNodeID XCEID, YCEID;
7548 XCE->
Profile(XCEID, *
this,
true,
true);
7549 YCE->
Profile(YCEID, *
this,
true,
true);
7550 return XCEID == YCEID;
7599 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7601 if (TX->isParameterPack() != TY->isParameterPack())
7603 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7606 TY->getTypeConstraint());
7609 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7611 return TX->isParameterPack() == TY->isParameterPack() &&
7612 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7614 TY->getPlaceholderTypeConstraint());
7619 return TX->isParameterPack() == TY->isParameterPack() &&
7621 TY->getTemplateParameters());
7626 if (
X->size() != Y->
size())
7629 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7643 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7645 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7648 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7649 TTPY->getDefaultArgument().getArgument().getAsType());
7652 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7654 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7657 Expr *DefaultArgumentX =
7658 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7659 Expr *DefaultArgumentY =
7660 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7661 llvm::FoldingSetNodeID XID, YID;
7662 DefaultArgumentX->
Profile(XID, *
this,
true);
7663 DefaultArgumentY->
Profile(YID, *
this,
true);
7670 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7685 auto Kind =
X.getKind();
7693 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7696 NamespaceY->getNamespace()))
7701 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7702 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7711 llvm_unreachable(
"unhandled qualifier kind");
7717 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7719 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7731 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7735 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7736 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7737 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7740 if (!Cand1A || !Cand2A)
7746 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7747 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7751 if (Cand1ID != Cand2ID)
7785 auto *RD = dyn_cast<CXXRecordDecl>(
X->getDeclContext());
7793 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7794 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7796 TypedefY->getUnderlyingType());
7813 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7815 return (TagX->getTagKind() == TagY->getTagKind()) ||
7827 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7829 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7831 if (CtorX->getInheritedConstructor() &&
7832 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7833 CtorY->getInheritedConstructor().getConstructor()))
7837 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7842 if (FuncX->isMultiVersion()) {
7843 const auto *TAX = FuncX->getAttr<TargetAttr>();
7844 const auto *TAY = FuncY->getAttr<TargetAttr>();
7845 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7847 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7853 if ((FuncX->isMemberLikeConstrainedFriend() ||
7854 FuncY->isMemberLikeConstrainedFriend()) &&
7855 !FuncX->getLexicalDeclContext()->Equals(
7856 FuncY->getLexicalDeclContext())) {
7861 FuncY->getTrailingRequiresClause()))
7869 FD = FD->getCanonicalDecl();
7870 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7873 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7888 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7893 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7895 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7898 if (VarX->getType().isNull() || VarY->getType().isNull())
7901 if (
hasSameType(VarX->getType(), VarY->getType()))
7911 if (!VarXTy || !VarYTy)
7920 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7922 return NamespaceX->isInline() == NamespaceY->isInline();
7927 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7931 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7934 ConceptY->getConstraintExpr()))
7939 TemplateY->getTemplatedDecl()) &&
7941 TemplateY->getTemplateParameters());
7945 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7948 return hasSameType(FDX->getType(), FDY->getType());
7952 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7954 return IFDX->getAnonField()->getCanonicalDecl() ==
7955 IFDY->getAnonField()->getCanonicalDecl();
7964 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7971 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7974 UX->hasTypename() == UY->hasTypename() &&
7975 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7977 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7980 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7982 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7990 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
7992 UX->getInstantiatedFromUsingDecl(),
7997 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
7999 return NAX->getNamespace()->Equals(NAY->getNamespace());
8002 if (
const auto *UX = dyn_cast<UsingEnumDecl>(
X)) {
8053 bool AnyNonCanonArgs =
false;
8056 if (!AnyNonCanonArgs)
8066 llvm_unreachable(
"Unhandled template argument kind");
8076 llvm_unreachable(
"Comparing NULL template argument");
8101 llvm::FoldingSetNodeID ID1, ID2;
8111 return isSameTemplateArgument(Arg1, Arg2);
8115 llvm_unreachable(
"Unhandled template argument kind");
8120 if (!
T.hasLocalQualifiers()) {
8122 if (
const auto *AT = dyn_cast<ArrayType>(
T))
8142 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
8143 if (!ATy || qs.
empty())
8150 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
8153 CAT->getSizeModifier(),
8154 CAT->getIndexTypeCVRQualifiers()));
8155 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
8157 IAT->getSizeModifier(),
8158 IAT->getIndexTypeCVRQualifiers()));
8160 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
8162 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
8163 DSAT->getIndexTypeCVRQualifiers()));
8168 VAT->getIndexTypeCVRQualifiers()));
8176 if (
T->isArrayType() ||
T->isFunctionType())
8184 return T.getUnqualifiedType();
8195 if (
T->isArrayType() ||
T->isFunctionType())
8197 return T.getUnqualifiedType();
8212 assert(PrettyArrayType &&
"Not an array type!");
8246 uint64_t ElementCount = 1;
8249 CA = dyn_cast_if_present<ConstantArrayType>(
8252 return ElementCount;
8260 uint64_t ElementCount = 1;
8264 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8267 return ElementCount;
8277 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8279 case BuiltinType::Half:
return HalfRank;
8280 case BuiltinType::Float:
return FloatRank;
8313unsigned ASTContext::getIntegerRank(
const Type *
T)
const {
8314 assert(
T->isCanonicalUnqualified() &&
"T should be canonicalized");
8318 if (
const auto *EIT = dyn_cast<BitIntType>(
T))
8319 return 0 + (EIT->getNumBits() << 3);
8321 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(
T))
8322 return getIntegerRank(OBT->getUnderlyingType().getTypePtr());
8325 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8326 case BuiltinType::Bool:
8328 case BuiltinType::Char_S:
8329 case BuiltinType::Char_U:
8330 case BuiltinType::SChar:
8331 case BuiltinType::UChar:
8333 case BuiltinType::Short:
8334 case BuiltinType::UShort:
8336 case BuiltinType::Int:
8337 case BuiltinType::UInt:
8339 case BuiltinType::Long:
8340 case BuiltinType::ULong:
8342 case BuiltinType::LongLong:
8343 case BuiltinType::ULongLong:
8345 case BuiltinType::Int128:
8346 case BuiltinType::UInt128:
8351 case BuiltinType::Char8:
8353 case BuiltinType::Char16:
8354 return getIntegerRank(
8356 case BuiltinType::Char32:
8357 return getIntegerRank(
8359 case BuiltinType::WChar_S:
8360 case BuiltinType::WChar_U:
8361 return getIntegerRank(
8391 uint64_t BitWidth = Field->getBitWidthValue();
8417 if (BitWidth < IntSize)
8420 if (BitWidth == IntSize)
8435 assert(!Promotable.
isNull());
8438 return ED->getPromotionType();
8442 if (
const auto *OBT = Promotable->
getAs<OverflowBehaviorType>()) {
8455 if (BT->getKind() == BuiltinType::WChar_S ||
8456 BT->getKind() == BuiltinType::WChar_U ||
8457 BT->getKind() == BuiltinType::Char8 ||
8458 BT->getKind() == BuiltinType::Char16 ||
8459 BT->getKind() == BuiltinType::Char32) {
8460 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8464 for (
const auto &PT : PromoteTypes) {
8466 if (FromSize < ToSize ||
8467 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8470 llvm_unreachable(
"char type should fit into long long");
8477 uint64_t PromotableSize =
getIntWidth(Promotable);
8486 while (!
T.isNull()) {
8488 return T.getObjCLifetime();
8489 if (
T->isArrayType())
8492 T = PT->getPointeeType();
8494 T = RT->getPointeeType();
8519 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8521 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8524 if (LHSC == RHSC)
return 0;
8529 unsigned LHSRank = getIntegerRank(LHSC);
8530 unsigned RHSRank = getIntegerRank(RHSC);
8532 if (LHSUnsigned == RHSUnsigned) {
8533 if (LHSRank == RHSRank)
return 0;
8534 return LHSRank > RHSRank ? 1 : -1;
8540 if (LHSRank >= RHSRank)
8550 if (RHSRank >= LHSRank)
8560 if (CFConstantStringTypeDecl)
8561 return CFConstantStringTypeDecl;
8563 assert(!CFConstantStringTagDecl &&
8564 "tag and typedef should be initialized together");
8566 CFConstantStringTagDecl->startDefinition();
8604 if (
static_cast<unsigned>(CFRuntime) <
8607 Fields[Count++] = {
IntTy,
"flags" };
8609 Fields[Count++] = {
LongTy,
"length" };
8613 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()),
"_swift_rc" };
8617 Fields[Count++] = {
IntTy,
"_ptr" };
8623 for (
unsigned i = 0; i < Count; ++i) {
8627 Fields[i].Type,
nullptr,
8630 CFConstantStringTagDecl->addDecl(Field);
8633 CFConstantStringTagDecl->completeDefinition();
8637 CFConstantStringTypeDecl =
8640 return CFConstantStringTypeDecl;
8644 if (!CFConstantStringTagDecl)
8646 return CFConstantStringTagDecl;
8656 if (ObjCSuperType.isNull()) {
8661 return ObjCSuperType;
8667 CFConstantStringTagDecl = TT->castAsRecordDecl();
8671 if (BlockDescriptorType)
8684 static const char *
const FieldNames[] = {
8689 for (
size_t i = 0; i < 2; ++i) {
8692 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8700 BlockDescriptorType = RD;
8706 if (BlockDescriptorExtendedType)
8721 static const char *
const FieldNames[] = {
8728 for (
size_t i = 0; i < 4; ++i) {
8731 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8740 BlockDescriptorExtendedType = RD;
8745 const auto *BT = dyn_cast<BuiltinType>(
T);
8754 switch (BT->getKind()) {
8755#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8756 case BuiltinType::Id: \
8758#include "clang/Basic/OpenCLImageTypes.def"
8760 case BuiltinType::OCLClkEvent:
8763 case BuiltinType::OCLEvent:
8766 case BuiltinType::OCLQueue:
8769 case BuiltinType::OCLReserveID:
8772 case BuiltinType::OCLSampler:
8791 if (!copyExpr && record->hasTrivialDestructor())
return false;
8822 llvm_unreachable(
"impossible");
8824 llvm_unreachable(
"fell out of lifetime switch!");
8832 bool &HasByrefExtendedLayout)
const {
8837 HasByrefExtendedLayout =
false;
8839 HasByrefExtendedLayout =
true;
8853 assert(Target &&
"Expected target to be initialized");
8854 const llvm::Triple &
T = Target->getTriple();
8856 if (
T.isOSWindows() &&
T.isArch64Bit())
8862 assert(Target &&
"Expected target to be initialized");
8863 const llvm::Triple &
T = Target->getTriple();
8865 if (
T.isOSWindows() &&
T.isArch64Bit())
8871 if (!ObjCInstanceTypeDecl)
8872 ObjCInstanceTypeDecl =
8874 return ObjCInstanceTypeDecl;
8880 if (
const auto *TT = dyn_cast<TypedefType>(
T))
8882 return II->isStr(
"BOOL");
8890 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8899 else if (
type->isArrayType())
8918 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8925 !D->isInlineSpecified() && (D->isConstexpr() ||
First->isConstexpr()))
8956 for (
auto *PI :
Decl->parameters()) {
8961 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8970 ParmOffset = PtrSize;
8971 for (
auto *PVDecl :
Decl->parameters()) {
8972 QualType PType = PVDecl->getOriginalType();
8973 if (
const auto *AT =
8978 PType = PVDecl->getType();
8980 PType = PVDecl->getType();
9000 for (
auto *PI :
Decl->parameters()) {
9007 "getObjCEncodingForFunctionDecl - Incomplete param type");
9014 for (
auto *PVDecl :
Decl->parameters()) {
9015 QualType PType = PVDecl->getOriginalType();
9016 if (
const auto *AT =
9021 PType = PVDecl->getType();
9023 PType = PVDecl->getType();
9037 bool Extended)
const {
9041 ObjCEncOptions Options = ObjCEncOptions()
9042 .setExpandPointedToStructures()
9043 .setExpandStructures()
9044 .setIsOutermostType();
9046 Options.setEncodeBlockParameters().setEncodeClassNames();
9047 getObjCEncodingForTypeImpl(
T, S, Options,
nullptr);
9053 bool Extended)
const {
9058 Decl->getReturnType(), S, Extended);
9067 E =
Decl->sel_param_end(); PI != E; ++PI) {
9074 "getObjCEncodingForMethodDecl - Incomplete param type");
9082 ParmOffset = 2 * PtrSize;
9084 E =
Decl->sel_param_end(); PI != E; ++PI) {
9087 if (
const auto *AT =
9096 PType, S, Extended);
9107 const Decl *Container)
const {
9110 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
9111 for (
auto *PID : CID->property_impls())
9112 if (PID->getPropertyDecl() == PD)
9116 for (
auto *PID : OID->property_impls())
9117 if (PID->getPropertyDecl() == PD)
9151 const Decl *Container)
const {
9153 bool Dynamic =
false;
9161 SynthesizePID = PropertyImpDecl;
9165 std::string S =
"T";
9210 if (SynthesizePID) {
9227 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9230 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9243 getObjCEncodingForTypeImpl(
T, S,
9245 .setExpandPointedToStructures()
9246 .setExpandStructures()
9247 .setIsOutermostType(),
9248 Field, NotEncodedT);
9252 std::string& S)
const {
9256 getObjCEncodingForTypeImpl(
T, S,
9258 .setExpandPointedToStructures()
9259 .setExpandStructures()
9260 .setIsOutermostType()
9261 .setEncodingProperty(),
9269 case BuiltinType::Void:
return 'v';
9270 case BuiltinType::Bool:
return 'B';
9271 case BuiltinType::Char8:
9272 case BuiltinType::Char_U:
9273 case BuiltinType::UChar:
return 'C';
9274 case BuiltinType::Char16:
9275 case BuiltinType::UShort:
return 'S';
9276 case BuiltinType::Char32:
9277 case BuiltinType::UInt:
return 'I';
9278 case BuiltinType::ULong:
9279 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9280 case BuiltinType::UInt128:
return 'T';
9281 case BuiltinType::ULongLong:
return 'Q';
9282 case BuiltinType::Char_S:
9283 case BuiltinType::SChar:
return 'c';
9284 case BuiltinType::Short:
return 's';
9285 case BuiltinType::WChar_S:
9286 case BuiltinType::WChar_U:
9287 case BuiltinType::Int:
return 'i';
9288 case BuiltinType::Long:
9289 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9290 case BuiltinType::LongLong:
return 'q';
9291 case BuiltinType::Int128:
return 't';
9292 case BuiltinType::Float:
return 'f';
9293 case BuiltinType::Double:
return 'd';
9294 case BuiltinType::LongDouble:
return 'D';
9295 case BuiltinType::NullPtr:
return '*';
9297 case BuiltinType::BFloat16:
9298 case BuiltinType::Float16:
9299 case BuiltinType::Float128:
9300 case BuiltinType::Ibm128:
9301 case BuiltinType::Half:
9302 case BuiltinType::ShortAccum:
9303 case BuiltinType::Accum:
9304 case BuiltinType::LongAccum:
9305 case BuiltinType::UShortAccum:
9306 case BuiltinType::UAccum:
9307 case BuiltinType::ULongAccum:
9308 case BuiltinType::ShortFract:
9309 case BuiltinType::Fract:
9310 case BuiltinType::LongFract:
9311 case BuiltinType::UShortFract:
9312 case BuiltinType::UFract:
9313 case BuiltinType::ULongFract:
9314 case BuiltinType::SatShortAccum:
9315 case BuiltinType::SatAccum:
9316 case BuiltinType::SatLongAccum:
9317 case BuiltinType::SatUShortAccum:
9318 case BuiltinType::SatUAccum:
9319 case BuiltinType::SatULongAccum:
9320 case BuiltinType::SatShortFract:
9321 case BuiltinType::SatFract:
9322 case BuiltinType::SatLongFract:
9323 case BuiltinType::SatUShortFract:
9324 case BuiltinType::SatUFract:
9325 case BuiltinType::SatULongFract:
9329#define SVE_TYPE(Name, Id, SingletonId) \
9330 case BuiltinType::Id:
9331#include "clang/Basic/AArch64ACLETypes.def"
9332#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9333#include "clang/Basic/RISCVVTypes.def"
9334#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9335#include "clang/Basic/WebAssemblyReferenceTypes.def"
9336#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9337#include "clang/Basic/AMDGPUTypes.def"
9338#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9339#include "clang/Basic/SPIRVTypes.def"
9342 Diags.
Report(diag::err_unsupported_objc_primitive_encoding)
9347 case BuiltinType::ObjCId:
9348 case BuiltinType::ObjCClass:
9349 case BuiltinType::ObjCSel:
9350 llvm_unreachable(
"@encoding ObjC primitive type");
9353#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9354 case BuiltinType::Id:
9355#include "clang/Basic/OpenCLImageTypes.def"
9356#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9357 case BuiltinType::Id:
9358#include "clang/Basic/OpenCLExtensionTypes.def"
9359 case BuiltinType::OCLEvent:
9360 case BuiltinType::OCLClkEvent:
9361 case BuiltinType::OCLQueue:
9362 case BuiltinType::OCLReserveID:
9363 case BuiltinType::OCLSampler:
9364 case BuiltinType::Dependent:
9365 case BuiltinType::MetaInfo:
9366#define PPC_VECTOR_TYPE(Name, Id, Size) \
9367 case BuiltinType::Id:
9368#include "clang/Basic/PPCTypes.def"
9369#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9370#include "clang/Basic/HLSLIntangibleTypes.def"
9371#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9372#include "clang/Basic/HLSLPackedTypes.def"
9373#define BUILTIN_TYPE(KIND, ID)
9374#define PLACEHOLDER_TYPE(KIND, ID) \
9375 case BuiltinType::KIND:
9376#include "clang/AST/BuiltinTypes.def"
9377 llvm_unreachable(
"invalid builtin type for @encode");
9379 llvm_unreachable(
"invalid BuiltinType::Kind value");
9386 if (!
Enum->isFixed())
9396 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9416 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9424 S += llvm::utostr(Offset);
9426 if (
const auto *ET =
T->getAsCanonical<EnumType>())
9439 bool VisitBasesAndFields) {
9440 T =
T->getBaseElementTypeUnsafe();
9444 PT->getPointeeType().getTypePtr(),
false);
9446 auto *CXXRD =
T->getAsCXXRecordDecl();
9454 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9457 for (
const auto &B : CXXRD->bases())
9462 for (
auto *FD : CXXRD->fields())
9471void ASTContext::getObjCEncodingForTypeImpl(QualType
T, std::string &S,
9472 const ObjCEncOptions Options,
9473 const FieldDecl *FD,
9474 QualType *NotEncodedT)
const {
9476 switch (CT->getTypeClass()) {
9481 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9489 getObjCEncodingForTypeImpl(
T->
castAs<ComplexType>()->getElementType(), S,
9496 getObjCEncodingForTypeImpl(
T->
castAs<AtomicType>()->getValueType(), S,
9503 case Type::LValueReference:
9504 case Type::RValueReference: {
9507 const auto *PT =
T->
castAs<PointerType>();
9508 if (PT->isObjCSelType()) {
9517 bool isReadOnly =
false;
9522 if (
T->
getAs<TypedefType>()) {
9523 if (Options.IsOutermostType() &&
T.isConstQualified()) {
9527 }
else if (Options.IsOutermostType()) {
9528 QualType P = PointeeTy;
9529 while (
auto PT = P->
getAs<PointerType>())
9540 if (StringRef(S).ends_with(
"nr"))
9541 S.replace(S.end()-2, S.end(),
"rn");
9551 }
else if (
const auto *RTy = PointeeTy->
getAsCanonical<RecordType>()) {
9552 const IdentifierInfo *II = RTy->getDecl()->getIdentifier();
9554 if (II == &
Idents.get(
"objc_class")) {
9559 if (II == &
Idents.get(
"objc_object")) {
9568 RTy, Options.ExpandPointedToStructures()))) {
9577 ObjCEncOptions NewOptions;
9578 if (Options.ExpandPointedToStructures())
9579 NewOptions.setExpandStructures();
9580 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9581 nullptr, NotEncodedT);
9585 case Type::ConstantArray:
9586 case Type::IncompleteArray:
9587 case Type::VariableArray: {
9594 getObjCEncodingForTypeImpl(
9595 AT->getElementType(), S,
9596 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9600 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9601 S += llvm::utostr(CAT->getZExtSize());
9605 "Unknown array type!");
9609 getObjCEncodingForTypeImpl(
9610 AT->getElementType(), S,
9611 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9618 case Type::FunctionNoProto:
9619 case Type::FunctionProto:
9623 case Type::Record: {
9625 S += RDecl->
isUnion() ?
'(' :
'{';
9629 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9630 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
9631 llvm::raw_string_ostream
OS(S);
9632 printTemplateArgumentList(OS, TemplateArgs.
asArray(),
9638 if (Options.ExpandStructures()) {
9641 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9643 for (
const auto *Field : RDecl->
fields()) {
9646 S +=
Field->getNameAsString();
9651 if (
Field->isBitField()) {
9652 getObjCEncodingForTypeImpl(
Field->getType(), S,
9653 ObjCEncOptions().setExpandStructures(),
9656 QualType qt =
Field->getType();
9658 getObjCEncodingForTypeImpl(
9660 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9666 S += RDecl->
isUnion() ?
')' :
'}';
9670 case Type::BlockPointer: {
9671 const auto *BT =
T->
castAs<BlockPointerType>();
9673 if (Options.EncodeBlockParameters()) {
9674 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
9678 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9679 Options.forComponentType(), FD, NotEncodedT);
9683 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9684 for (
const auto &I : FPT->param_types())
9685 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9693 case Type::ObjCObject: {
9697 S +=
"{objc_object=}";
9701 S +=
"{objc_class=}";
9708 case Type::ObjCInterface: {
9711 ObjCInterfaceDecl *OI =
T->
castAs<ObjCObjectType>()->getInterface();
9714 if (Options.ExpandStructures()) {
9716 SmallVector<const ObjCIvarDecl*, 32> Ivars;
9718 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9719 const FieldDecl *
Field = Ivars[i];
9720 if (
Field->isBitField())
9721 getObjCEncodingForTypeImpl(
Field->getType(), S,
9722 ObjCEncOptions().setExpandStructures(),
9725 getObjCEncodingForTypeImpl(
Field->getType(), S,
9726 ObjCEncOptions().setExpandStructures(), FD,
9734 case Type::ObjCObjectPointer: {
9735 const auto *OPT =
T->
castAs<ObjCObjectPointerType>();
9736 if (OPT->isObjCIdType()) {
9741 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9749 if (OPT->isObjCQualifiedIdType()) {
9750 getObjCEncodingForTypeImpl(
9752 Options.keepingOnly(ObjCEncOptions()
9753 .setExpandPointedToStructures()
9754 .setExpandStructures()),
9756 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9760 for (
const auto *I : OPT->quals()) {
9762 S += I->getObjCRuntimeNameAsString();
9771 if (OPT->getInterfaceDecl() &&
9772 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9774 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9775 for (
const auto *I : OPT->quals()) {
9777 S += I->getObjCRuntimeNameAsString();
9787 case Type::MemberPointer:
9791 case Type::ExtVector:
9797 case Type::ConstantMatrix:
9810 case Type::DeducedTemplateSpecialization:
9814 case Type::OverflowBehavior:
9815 getObjCEncodingForTypeImpl(
9820 case Type::HLSLAttributedResource:
9821 case Type::HLSLInlineSpirv:
9822 llvm_unreachable(
"unexpected type");
9824 case Type::ArrayParameter:
9826#define ABSTRACT_TYPE(KIND, BASE)
9827#define TYPE(KIND, BASE)
9828#define DEPENDENT_TYPE(KIND, BASE) \
9830#define NON_CANONICAL_TYPE(KIND, BASE) \
9832#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9834#include "clang/AST/TypeNodes.inc"
9835 llvm_unreachable(
"@encode for dependent type!");
9837 llvm_unreachable(
"bad type kind!");
9840void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
9842 const FieldDecl *FD,
9844 QualType *NotEncodedT)
const {
9845 assert(RDecl &&
"Expected non-null RecordDecl");
9846 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9850 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9851 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9855 for (
const auto &BI : CXXRec->bases()) {
9856 if (!BI.isVirtual()) {
9861 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9862 std::make_pair(offs, base));
9867 for (FieldDecl *Field : RDecl->
fields()) {
9868 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9871 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9872 std::make_pair(offs, Field));
9875 if (CXXRec && includeVBases) {
9876 for (
const auto &BI : CXXRec->vbases()) {
9882 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9883 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9884 std::make_pair(offs, base));
9898 std::multimap<uint64_t, NamedDecl *>::iterator
9899 CurLayObj = FieldOrBaseOffsets.begin();
9901 if (CXXRec && CXXRec->isDynamicClass() &&
9902 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9905 std::string recname = CXXRec->getNameAsString();
9906 if (recname.empty()) recname =
"?";
9919 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9920 std::make_pair(offs,
nullptr));
9923 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9925 assert(CurOffs <= CurLayObj->first);
9926 if (CurOffs < CurLayObj->first) {
9927 uint64_t padding = CurLayObj->first - CurOffs;
9939 NamedDecl *dcl = CurLayObj->second;
9943 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9948 getObjCEncodingForStructureImpl(base, S, FD,
false,
9958 S += field->getNameAsString();
9962 if (field->isBitField()) {
9965 CurOffs += field->getBitWidthValue();
9968 QualType qt = field->getType();
9970 getObjCEncodingForTypeImpl(
9971 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9982 std::string& S)
const {
10007 if (!ObjCSelDecl) {
10011 return ObjCSelDecl;
10015 if (!ObjCClassDecl) {
10020 return ObjCClassDecl;
10024 if (!ObjCProtocolClassDecl) {
10025 ObjCProtocolClassDecl
10028 &
Idents.get(
"Protocol"),
10034 return ObjCProtocolClassDecl;
10055 QualType T = Context->getPointerType(Context->CharTy);
10056 return Context->buildImplicitTypedef(
T, Name);
10065 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 2);
10066 QualType T = Context->getPointerType(Context->CharTy);
10069 return Context->buildImplicitTypedef(
ArrayType,
"__builtin_zos_va_list");
10078 QualType T = Context->getPointerType(Context->VoidTy);
10079 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10082static TypedefDecl *
10086 if (Context->getLangOpts().CPlusPlus) {
10091 &Context->Idents.get(
"std"),
10099 const size_t NumFields = 5;
10101 const char *FieldNames[NumFields];
10104 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10105 FieldNames[0] =
"__stack";
10108 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10109 FieldNames[1] =
"__gr_top";
10112 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10113 FieldNames[2] =
"__vr_top";
10116 FieldTypes[3] = Context->IntTy;
10117 FieldNames[3] =
"__gr_offs";
10120 FieldTypes[4] = Context->IntTy;
10121 FieldNames[4] =
"__vr_offs";
10124 for (
unsigned i = 0; i < NumFields; ++i) {
10129 &Context->Idents.get(FieldNames[i]),
10130 FieldTypes[i],
nullptr,
10142 return Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10149 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10152 const size_t NumFields = 5;
10154 const char *FieldNames[NumFields];
10157 FieldTypes[0] = Context->UnsignedCharTy;
10158 FieldNames[0] =
"gpr";
10161 FieldTypes[1] = Context->UnsignedCharTy;
10162 FieldNames[1] =
"fpr";
10165 FieldTypes[2] = Context->UnsignedShortTy;
10166 FieldNames[2] =
"reserved";
10169 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10170 FieldNames[3] =
"overflow_arg_area";
10173 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
10174 FieldNames[4] =
"reg_save_area";
10177 for (
unsigned i = 0; i < NumFields; ++i) {
10181 &Context->Idents.get(FieldNames[i]),
10182 FieldTypes[i],
nullptr,
10195 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10199 std::nullopt, VaListTagTypedefDecl);
10202 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10203 QualType VaListTagArrayType = Context->getConstantArrayType(
10205 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10208static TypedefDecl *
10212 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10215 const size_t NumFields = 4;
10217 const char *FieldNames[NumFields];
10220 FieldTypes[0] = Context->UnsignedIntTy;
10221 FieldNames[0] =
"gp_offset";
10224 FieldTypes[1] = Context->UnsignedIntTy;
10225 FieldNames[1] =
"fp_offset";
10228 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10229 FieldNames[2] =
"overflow_arg_area";
10232 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10233 FieldNames[3] =
"reg_save_area";
10236 for (
unsigned i = 0; i < NumFields; ++i) {
10241 &Context->Idents.get(FieldNames[i]),
10242 FieldTypes[i],
nullptr,
10256 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10257 QualType VaListTagArrayType = Context->getConstantArrayType(
10259 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10262static TypedefDecl *
10265 RecordDecl *VaListDecl = Context->buildImplicitRecord(
"__va_list");
10266 if (Context->getLangOpts().CPlusPlus) {
10285 &Context->Idents.get(
"__ap"),
10286 Context->getPointerType(Context->VoidTy),
10296 Context->VaListTagDecl = VaListDecl;
10299 CanQualType T = Context->getCanonicalTagType(VaListDecl);
10300 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10303static TypedefDecl *
10307 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10310 const size_t NumFields = 4;
10312 const char *FieldNames[NumFields];
10315 FieldTypes[0] = Context->LongTy;
10316 FieldNames[0] =
"__gpr";
10319 FieldTypes[1] = Context->LongTy;
10320 FieldNames[1] =
"__fpr";
10323 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10324 FieldNames[2] =
"__overflow_arg_area";
10327 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10328 FieldNames[3] =
"__reg_save_area";
10331 for (
unsigned i = 0; i < NumFields; ++i) {
10336 &Context->Idents.get(FieldNames[i]),
10337 FieldTypes[i],
nullptr,
10351 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10352 QualType VaListTagArrayType = Context->getConstantArrayType(
10355 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10361 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10364 const size_t NumFields = 3;
10366 const char *FieldNames[NumFields];
10369 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10370 FieldNames[0] =
"__current_saved_reg_area_pointer";
10373 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10374 FieldNames[1] =
"__saved_reg_area_end_pointer";
10377 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10378 FieldNames[2] =
"__overflow_area_pointer";
10381 for (
unsigned i = 0; i < NumFields; ++i) {
10384 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
10397 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10401 std::nullopt, VaListTagTypedefDecl);
10404 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10405 QualType VaListTagArrayType = Context->getConstantArrayType(
10408 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10411static TypedefDecl *
10421 constexpr size_t NumFields = 3;
10422 QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
10423 Context->getPointerType(Context->IntTy),
10425 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10428 for (
unsigned i = 0; i < NumFields; ++i) {
10431 &Context->Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
10443 Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10445 return VaListTagTypedefDecl;
10471 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10475 if (!BuiltinVaListDecl) {
10476 BuiltinVaListDecl =
CreateVaListDecl(
this, Target->getBuiltinVaListKind());
10477 assert(BuiltinVaListDecl->isImplicit());
10480 return BuiltinVaListDecl;
10493 if (!BuiltinMSVaListDecl)
10496 return BuiltinMSVaListDecl;
10500 if (!BuiltinZOSVaListDecl)
10503 return BuiltinZOSVaListDecl;
10520 assert(ObjCConstantStringType.isNull() &&
10521 "'NSConstantString' type already set!");
10531 unsigned size = End - Begin;
10532 assert(size > 1 &&
"set is not overloaded!");
10538 NamedDecl **Storage = OT->getStorage();
10561 bool TemplateKeyword,
10566 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10567 assert(!Qualifier &&
"unexpected qualified template template parameter");
10568 assert(TemplateKeyword ==
false);
10573 llvm::FoldingSetNodeID ID;
10576 llvm::FoldingSetInsertToken
Token;
10581 QualifiedTemplateNames.insert(QTN,
Token);
10591 llvm::FoldingSetNodeID ID;
10594 llvm::FoldingSetInsertToken
Token;
10600 DependentTemplateNames.insert(QTN,
Token);
10605 Decl *AssociatedDecl,
10608 bool Final)
const {
10609 llvm::FoldingSetNodeID ID;
10613 llvm::FoldingSetInsertToken
Token;
10615 SubstTemplateTemplateParms.lookup(ID,
Token);
10619 Replacement, AssociatedDecl, Index,
PackIndex, Final);
10620 SubstTemplateTemplateParms.insert(subst,
Token);
10628 Decl *AssociatedDecl,
10629 unsigned Index,
bool Final)
const {
10631 llvm::FoldingSetNodeID ID;
10633 AssociatedDecl, Index, Final);
10635 llvm::FoldingSetInsertToken
Token;
10637 SubstTemplateTemplateParmPacks.lookup(ID,
Token);
10642 SubstTemplateTemplateParmPacks.insert(Subst,
Token);
10656 llvm::FoldingSetNodeID ID;
10659 llvm::FoldingSetInsertToken
Token;
10666 DeducedTemplates.insert(DTS,
Token);
10675 llvm::FoldingSetNodeID ID;
10677 FullySubstituted, Expansions);
10679 llvm::FoldingSetInsertToken
Token;
10683 Allocate(PackIndexingTemplateStorage::totalSizeToAlloc<TemplateName>(
10684 Expansions.size()),
10687 FullySubstituted, Expansions);
10688 PackIndexingTemplates.insert(PI,
Token);
10711 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10741 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10742 CT = AT->getElementType();
10774 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10775 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10824 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
10825 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
10827 if (!LHSOBT && !RHSOBT)
10830 if (LHSOBT && RHSOBT) {
10831 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
10836 QualType LHSUnderlying = LHSOBT ? LHSOBT->desugar() : LHS;
10837 QualType RHSUnderlying = RHSOBT ? RHSOBT->desugar() : RHS;
10839 if (RHSOBT && !LHSOBT) {
10850 auto VScale = Context.getTargetInfo().getVScaleRange(
10861 uint64_t MinElts = Info.
EC.getKnownMinValue();
10862 return VScale->first * MinElts * EltSize;
10870 "Expected RVV builtin type and vector type!");
10882 (llvm::RISCV::RVVBitsPerBlock >>
10884 Info.
EC.getKnownMinValue() &&
10898 return IsValidCast(FirstType, SecondType) ||
10899 IsValidCast(SecondType, FirstType);
10907 "Expected RVV builtin type and vector type!");
10914 if (!BT->isRVVVLSBuiltinType())
10934 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10941 return IsLaxCompatible(FirstType, SecondType) ||
10942 IsLaxCompatible(SecondType, FirstType);
10948 if (
const AttributedType *
Attr = dyn_cast<AttributedType>(Ty)) {
10949 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10952 Ty =
Attr->getModifiedType();
10956 Ty =
Paren->getInnerType();
10988 for (
auto *lhsProto : lhs->
quals()) {
10989 bool match =
false;
10990 for (
auto *rhsProto : rhs->
quals()) {
11021 for (
auto *I : lhs->
quals()) {
11025 if (!rhsID->ClassImplementsProtocol(I,
true))
11033 for (
auto *lhsProto : lhs->
quals()) {
11034 bool match =
false;
11039 for (
auto *rhsProto : rhs->
quals()) {
11049 for (
auto *I : lhs->
quals()) {
11053 if (rhsID->ClassImplementsProtocol(I,
true)) {
11070 for (
auto *lhsProto : lhs->
quals()) {
11071 bool match =
false;
11078 for (
auto *rhsProto : rhs->
quals()) {
11097 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
11099 for (
auto *lhsProto : LHSInheritedProtocols) {
11100 bool match =
false;
11101 for (
auto *rhsProto : rhs->
quals()) {
11126 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
11131 auto finish = [&](
bool succeeded) ->
bool {
11135 if (!RHS->isKindOfType())
11146 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
11151 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
11156 if (LHS->isObjCClass() && RHS->isObjCClass()) {
11161 if (LHS->getInterface() && RHS->getInterface()) {
11176 bool BlockReturnType) {
11180 auto finish = [&](
bool succeeded) ->
bool {
11205 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
11209 (!BlockReturnType &&
11213 (BlockReturnType ? LHSOPT : RHSOPT),
11214 (BlockReturnType ? RHSOPT : LHSOPT),
false));
11222 return finish(BlockReturnType);
11224 return finish(!BlockReturnType);
11236 return (*lhs)->getName().compare((*rhs)->getName());
11253 assert(LHS->getInterface() &&
"LHS must have an interface base");
11254 assert(RHS->getInterface() &&
"RHS must have an interface base");
11260 for (
auto *proto : LHS->quals()) {
11261 Context.CollectInheritedProtocols(proto, LHSProtocolSet);
11265 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
11271 for (
auto *proto : RHS->quals()) {
11272 Context.CollectInheritedProtocols(proto, RHSProtocolSet);
11276 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
11279 for (
auto *proto : LHSProtocolSet) {
11280 if (RHSProtocolSet.count(proto))
11281 IntersectionSet.push_back(proto);
11287 Context.CollectInheritedProtocols(CommonBase, ImpliedProtocols);
11290 if (!ImpliedProtocols.empty()) {
11292 return ImpliedProtocols.contains(proto);
11297 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11307 if (lhsOPT && rhsOPT)
11313 if (lhsBlock && rhsBlock)
11318 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11330 bool stripKindOf) {
11331 if (lhsArgs.size() != rhsArgs.size())
11338 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11344 if (!stripKindOf ||
11345 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11346 rhsArgs[i].stripObjCKindOfType(ctx))) {
11374 if (!LDecl || !RDecl)
11380 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
11384 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11389 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
11394 bool anyChanges =
false;
11395 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11398 LHS->getTypeArgs(), RHS->getTypeArgs(),
11401 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11412 if (!Protocols.empty())
11418 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
11421 anyKindOf || LHS->isKindOfType());
11429 QualType LHSSuperType = LHS->getSuperClassType();
11430 if (LHSSuperType.
isNull())
11439 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
11440 if (KnownLHS != LHSAncestors.end()) {
11441 LHS = KnownLHS->second;
11445 bool anyChanges =
false;
11446 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11449 LHS->getTypeArgs(), RHS->getTypeArgs(),
11452 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11463 if (!Protocols.empty())
11468 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
11471 anyKindOf || RHS->isKindOfType());
11479 QualType RHSSuperType = RHS->getSuperClassType();
11480 if (RHSSuperType.
isNull())
11491 assert(LHS->getInterface() &&
"LHS is not an interface type");
11492 assert(RHS->getInterface() &&
"RHS is not an interface type");
11497 bool IsSuperClass = LHSInterface->
isSuperClassOf(RHS->getInterface());
11504 if (LHS->getNumProtocols() > 0) {
11513 for (
auto *RHSPI : RHS->quals())
11516 if (SuperClassInheritedProtocols.empty())
11519 for (
const auto *LHSProto : LHS->quals()) {
11520 bool SuperImplementsProtocol =
false;
11521 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11522 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11523 SuperImplementsProtocol =
true;
11526 if (!SuperImplementsProtocol)
11532 if (LHS->isSpecialized()) {
11537 RHSSuper = RHSSuper->getSuperClassType()->castAs<
ObjCObjectType>();
11540 if (RHSSuper->isSpecialized() &&
11542 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
11556 if (!LHSOPT || !RHSOPT)
11574 bool CompareUnqualified) {
11593 bool OfBlockPointer,
11595 if (
const RecordType *UT =
T->getAsUnionType()) {
11597 if (UD->
hasAttr<TransparentUnionAttr>()) {
11598 for (
const auto *I : UD->
fields()) {
11599 QualType ET = I->getType().getUnqualifiedType();
11613 bool OfBlockPointer,
11634 bool IsConditionalOperator) {
11637 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11638 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11639 bool allLTypes =
true;
11640 bool allRTypes =
true;
11644 if (OfBlockPointer) {
11646 QualType LHS = lbase->getReturnType();
11648 if (!UnqualifiedResult)
11650 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11715 bool NoReturn = IsConditionalOperator
11725 std::optional<FunctionEffectSet> MergedFX;
11727 if (lproto && rproto) {
11728 assert((AllowCXX ||
11729 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11730 "C++ shouldn't be here");
11732 if (lproto->getNumParams() != rproto->getNumParams())
11736 if (lproto->isVariadic() != rproto->isVariadic())
11739 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11743 if (lproto->getExtraAttributeInfo().CFISalt !=
11744 rproto->getExtraAttributeInfo().CFISalt)
11750 if (LHSFX != RHSFX) {
11751 if (IsConditionalOperator)
11760 if (*MergedFX != LHSFX)
11762 if (*MergedFX != RHSFX)
11767 bool canUseLeft, canUseRight;
11779 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11780 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11781 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11783 lParamType, rParamType, OfBlockPointer,
Unqualified);
11790 types.push_back(paramType);
11802 if (allLTypes)
return lhs;
11803 if (allRTypes)
return rhs;
11808 newParamInfos.empty() ?
nullptr : newParamInfos.data();
11814 if (lproto) allRTypes =
false;
11815 if (rproto) allLTypes =
false;
11819 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11827 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11833 paramTy = ED->getIntegerType();
11843 if (allLTypes)
return lhs;
11844 if (allRTypes)
return rhs;
11853 if (allLTypes)
return lhs;
11854 if (allRTypes)
return rhs;
11860 QualType other,
bool isBlockReturnType) {
11866 ET->getDecl()->getDefinitionOrSelf()->getIntegerType();
11867 if (underlyingType.
isNull())
11869 if (Context.hasSameType(underlyingType, other))
11875 Context.getTypeSize(underlyingType) == Context.getTypeSize(other))
11884 if (LangOpts.CPlusPlus || !LangOpts.C23)
11905 bool BlockReturnType,
bool IsConditionalOperator) {
11906 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
11907 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
11909 if (!LHSOBT && !RHSOBT)
11910 return std::nullopt;
11914 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
11918 LHSOBT->getUnderlyingType(), RHSOBT->getUnderlyingType(),
11919 OfBlockPointer,
Unqualified, BlockReturnType, IsConditionalOperator);
11921 if (MergedUnderlying.
isNull())
11925 if (LHSOBT->getUnderlyingType() == RHSOBT->getUnderlyingType())
11928 LHSOBT->getBehaviorKind(),
11937 return mergeTypes(LHSOBT->getUnderlyingType(), RHS, OfBlockPointer,
11938 Unqualified, BlockReturnType, IsConditionalOperator);
11941 return mergeTypes(LHS, RHSOBT->getUnderlyingType(), OfBlockPointer,
11942 Unqualified, BlockReturnType, IsConditionalOperator);
11947 bool IsConditionalOperator) {
11958 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11962 if (LHSRefTy || RHSRefTy)
11965 if (std::optional<QualType> MergedOBT =
11967 BlockReturnType, IsConditionalOperator))
11979 if (LHSCan == RHSCan)
11984 Qualifiers RQuals = RHSCan.getLocalQualifiers();
11985 if (LQuals != RQuals) {
12002 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12023 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
12024 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
12027 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
12028 LHSClass = Type::ConstantArray;
12029 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
12030 RHSClass = Type::ConstantArray;
12033 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
12034 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
12037 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
12038 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
12041 if (LHSClass != RHSClass) {
12051 if (OfBlockPointer && !BlockReturnType) {
12059 if (
const auto *AT = LHS->
getAs<AutoType>()) {
12060 if (!AT->isDeduced() && AT->isGNUAutoType())
12063 if (
const auto *AT = RHS->
getAs<AutoType>()) {
12064 if (!AT->isDeduced() && AT->isGNUAutoType())
12071 switch (LHSClass) {
12072#define TYPE(Class, Base)
12073#define ABSTRACT_TYPE(Class, Base)
12074#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
12075#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
12076#define DEPENDENT_TYPE(Class, Base) case Type::Class:
12077#include "clang/AST/TypeNodes.inc"
12078 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
12081 case Type::DeducedTemplateSpecialization:
12082 case Type::LValueReference:
12083 case Type::RValueReference:
12084 case Type::MemberPointer:
12085 llvm_unreachable(
"C++ should never be in mergeTypes");
12087 case Type::ObjCInterface:
12088 case Type::IncompleteArray:
12089 case Type::VariableArray:
12090 case Type::FunctionProto:
12091 case Type::ExtVector:
12092 case Type::OverflowBehavior:
12093 llvm_unreachable(
"Types are eliminated above");
12095 case Type::Pointer:
12106 if (ResultType.
isNull())
12114 case Type::BlockPointer:
12139 if (ResultType.
isNull())
12158 if (ResultType.
isNull())
12166 case Type::ConstantArray:
12181 if (ResultType.
isNull())
12189 if (LVAT || RVAT) {
12192 -> std::pair<bool,llvm::APInt> {
12194 std::optional<llvm::APSInt> TheInt;
12197 return std::make_pair(
true, *TheInt);
12198 return std::make_pair(
false, llvm::APSInt());
12201 return std::make_pair(
true, CAT->getSize());
12202 return std::make_pair(
false, llvm::APInt());
12205 bool HaveLSize, HaveRSize;
12206 llvm::APInt LSize, RSize;
12207 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
12208 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
12209 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
12243 case Type::FunctionNoProto:
12245 false, IsConditionalOperator);
12249 case Type::Builtin:
12252 case Type::Complex:
12261 case Type::ConstantMatrix:
12266 case Type::ObjCObject: {
12275 case Type::ObjCObjectPointer:
12276 if (OfBlockPointer) {
12288 assert(LHS != RHS &&
12289 "Equivalent pipe types should have already been handled!");
12291 case Type::ArrayParameter:
12292 assert(LHS != RHS &&
12293 "Equivalent ArrayParameter types should have already been handled!");
12295 case Type::BitInt: {
12303 if (LHSUnsigned != RHSUnsigned)
12306 if (LHSBits != RHSBits)
12310 case Type::HLSLAttributedResource: {
12311 const HLSLAttributedResourceType *LHSTy =
12312 LHS->
castAs<HLSLAttributedResourceType>();
12313 const HLSLAttributedResourceType *RHSTy =
12314 RHS->
castAs<HLSLAttributedResourceType>();
12315 assert(LHSTy->getWrappedType() == RHSTy->getWrappedType() &&
12316 LHSTy->getWrappedType()->isHLSLResourceType() &&
12317 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
12319 if (LHSTy->getAttrs() == RHSTy->getAttrs() &&
12320 LHSTy->getContainedType() == RHSTy->getContainedType())
12324 case Type::HLSLInlineSpirv:
12325 const HLSLInlineSpirvType *LHSTy = LHS->
castAs<HLSLInlineSpirvType>();
12326 const HLSLInlineSpirvType *RHSTy = RHS->
castAs<HLSLInlineSpirvType>();
12328 if (LHSTy->getOpcode() == RHSTy->getOpcode() &&
12329 LHSTy->getSize() == RHSTy->getSize() &&
12330 LHSTy->getAlignment() == RHSTy->getAlignment()) {
12331 for (
size_t I = 0; I < LHSTy->getOperands().size(); I++)
12332 if (LHSTy->getOperands()[I] != RHSTy->getOperands()[I])
12340 llvm_unreachable(
"Invalid Type::Class!");
12345 bool &CanUseFirst,
bool &CanUseSecond,
12347 assert(NewParamInfos.empty() &&
"param info list not empty");
12348 CanUseFirst = CanUseSecond =
true;
12354 if (!FirstHasInfo && !SecondHasInfo)
12357 bool NeedParamInfo =
false;
12361 for (
size_t I = 0; I < E; ++I) {
12372 bool FirstNoEscape = FirstParam.
isNoEscape();
12373 bool SecondNoEscape = SecondParam.
isNoEscape();
12374 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12376 if (NewParamInfos.back().getOpaqueValue())
12377 NeedParamInfo =
true;
12378 if (FirstNoEscape != IsNoEscape)
12379 CanUseFirst =
false;
12380 if (SecondNoEscape != IsNoEscape)
12381 CanUseSecond =
false;
12384 if (!NeedParamInfo)
12385 NewParamInfos.clear();
12391 if (
auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
12392 It->second =
nullptr;
12393 for (
auto *SubClass : ObjCSubClasses.lookup(D))
12405 if (LHSCan == RHSCan)
12407 if (RHSCan->isFunctionType()) {
12416 if (ResReturnType.
isNull())
12418 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12435 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12442 if (LQuals != RQuals) {
12450 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12466 if (ResQT == LHSBaseQT)
12468 if (ResQT == RHSBaseQT)
12479 if (
const auto *ED =
T->getAsEnumDecl())
12480 T = ED->getIntegerType();
12481 if (
T->isBooleanType())
12484 return EIT->getNumBits();
12490 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12491 T->isFixedPointType()) &&
12492 "Unexpected type");
12497 VTy->getNumElements(), VTy->getVectorKind());
12504 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>())
12506 OBT->getBehaviorKind(),
12511 if (
const auto *ED =
T->getAsEnumDecl())
12512 T = ED->getIntegerType();
12515 case BuiltinType::Char_U:
12517 case BuiltinType::Char_S:
12518 case BuiltinType::SChar:
12519 case BuiltinType::Char8:
12521 case BuiltinType::Short:
12523 case BuiltinType::Int:
12525 case BuiltinType::Long:
12527 case BuiltinType::LongLong:
12529 case BuiltinType::Int128:
12534 case BuiltinType::WChar_S:
12537 case BuiltinType::ShortAccum:
12539 case BuiltinType::Accum:
12541 case BuiltinType::LongAccum:
12543 case BuiltinType::SatShortAccum:
12545 case BuiltinType::SatAccum:
12547 case BuiltinType::SatLongAccum:
12549 case BuiltinType::ShortFract:
12551 case BuiltinType::Fract:
12553 case BuiltinType::LongFract:
12555 case BuiltinType::SatShortFract:
12557 case BuiltinType::SatFract:
12559 case BuiltinType::SatLongFract:
12562 assert((
T->hasUnsignedIntegerRepresentation() ||
12563 T->isUnsignedFixedPointType()) &&
12564 "Unexpected signed integer or fixed point type");
12570 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12571 T->isFixedPointType()) &&
12572 "Unexpected type");
12577 VTy->getNumElements(), VTy->getVectorKind());
12585 if (
const auto *ED =
T->getAsEnumDecl())
12586 T = ED->getIntegerType();
12589 case BuiltinType::Char_S:
12591 case BuiltinType::Char_U:
12592 case BuiltinType::UChar:
12593 case BuiltinType::Char8:
12595 case BuiltinType::UShort:
12597 case BuiltinType::UInt:
12599 case BuiltinType::ULong:
12601 case BuiltinType::ULongLong:
12603 case BuiltinType::UInt128:
12608 case BuiltinType::WChar_U:
12611 case BuiltinType::UShortAccum:
12613 case BuiltinType::UAccum:
12615 case BuiltinType::ULongAccum:
12617 case BuiltinType::SatUShortAccum:
12619 case BuiltinType::SatUAccum:
12621 case BuiltinType::SatULongAccum:
12623 case BuiltinType::UShortFract:
12625 case BuiltinType::UFract:
12627 case BuiltinType::ULongFract:
12629 case BuiltinType::SatUShortFract:
12631 case BuiltinType::SatUFract:
12633 case BuiltinType::SatULongFract:
12637 (
T->hasSignedIntegerRepresentation() ||
T->isSignedFixedPointType()) &&
12638 "Unexpected signed integer or fixed point type");
12663 bool AllowTypeModifiers) {
12667 bool IsChar =
false, IsShort =
false;
12668 bool IsLeast =
false;
12669 RequiresICE =
false;
12674 bool IsSpecial =
false;
12678 default: Done =
true; --Str;
break;
12680 RequiresICE =
true;
12683 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12684 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12688 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12689 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12694 assert(!IsLeast &&
"Can't use 'l' modifier multiple times!");
12699 assert(!IsSpecial &&
12700 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12701 assert(HowLong == 0 &&
"Can't use both 'L' and 'B' modifiers!");
12709 assert(!IsSpecial &&
12710 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12711 assert(HowLong == 0 &&
"Can't use both 'L' and 'T' modifiers!");
12718 assert(!IsSpecial &&
12719 "Can't use 'L' with 'W', 'N', 'Z', 'O', 'B', or 'T' modifiers");
12720 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12725 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12726 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12730 if (Context.getTargetInfo().getLongWidth() == 32)
12735 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12736 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12740 switch (Context.getTargetInfo().getInt64Type()) {
12742 llvm_unreachable(
"Unexpected integer type");
12753 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12754 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12758 switch (Context.getTargetInfo().getIntTypeByWidth(32,
true)) {
12760 llvm_unreachable(
"Unexpected integer type");
12773 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12774 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12778 if (Context.getLangOpts().OpenCL)
12791 llvm_unreachable(
"Unknown builtin type letter!");
12794 "Bad modifiers used with 'x'!");
12795 Type = Context.Float16Ty;
12799 "Bad modifiers used with 'y'!");
12800 Type = Context.BFloat16Ty;
12804 "Bad modifiers used with 'v'!");
12805 Type = Context.VoidTy;
12809 "Bad modifiers used with 'h'!");
12810 Type = Context.HalfTy;
12814 "Bad modifiers used with 'f'!");
12815 Type = Context.FloatTy;
12819 "Bad modifiers used with 'd'!");
12821 Type = Context.LongDoubleTy;
12822 else if (HowLong == 2)
12823 Type = Context.Float128Ty;
12825 Type = Context.DoubleTy;
12828 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12830 Type = Context.UnsignedShortTy;
12832 Type = Context.ShortTy;
12836 Type =
Unsigned ? Context.UnsignedCharTy : Context.SignedCharTy;
12838 Type =
Unsigned ? Context.UnsignedShortTy : Context.ShortTy;
12839 else if (HowLong == 3)
12840 Type =
Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
12841 else if (HowLong == 2)
12842 Type =
Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
12843 else if (HowLong == 1)
12844 Type =
Unsigned ? Context.UnsignedLongTy : Context.LongTy;
12846 Type =
Unsigned ? Context.UnsignedIntTy : Context.IntTy;
12848 Type = Context.getLeastIntTypeForBitwidth(Context.getIntWidth(
Type),
12852 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12854 Type = Context.SignedCharTy;
12856 Type = Context.UnsignedCharTy;
12858 Type = Context.CharTy;
12861 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12862 Type = Context.BoolTy;
12865 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12866 Type = Context.getSizeType();
12869 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12870 Type = Context.getWideCharType();
12873 Type = Context.getCFConstantStringType();
12876 Type = Context.getObjCIdType();
12879 Type = Context.getObjCSelType();
12882 Type = Context.getObjCSuperType();
12885 Type = Context.MetaInfoTy;
12888 Type = Context.getBuiltinVaListType();
12889 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12900 Type = Context.getBuiltinVaListType();
12901 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12903 Type = Context.getArrayDecayedType(
Type);
12905 Type = Context.getLValueReferenceType(
Type);
12909 unsigned NumElements = strtoul(Str, &End, 10);
12910 assert(End != Str &&
"Missing vector size");
12914 RequiresICE,
false);
12915 assert(!RequiresICE &&
"Can't require vector ICE");
12917 Type = Context.getScalableVectorType(ElementType, NumElements);
12923 Type = Context.SveCountTy;
12927 Type = Context.AMDGPUBufferRsrcTy;
12931 Type = Context.AMDGPUFeaturePredicateTy;
12935 Type = Context.AMDGPUTextureTy;
12939 Type = Context.HLSLResourceTy;
12943 llvm_unreachable(
"Unexpected target builtin type");
12949 unsigned NumElements = strtoul(Str, &End, 10);
12950 assert(End != Str &&
"Missing vector size");
12954 RequiresICE,
false);
12955 assert(!RequiresICE &&
"Can't require vector ICE");
12964 unsigned NumElements = strtoul(Str, &End, 10);
12965 assert(End != Str &&
"Missing vector size");
12971 Type = Context.getExtVectorType(ElementType, NumElements);
12977 assert(!RequiresICE &&
"Can't require complex ICE");
12978 Type = Context.getComplexType(ElementType);
12982 Type = Context.getPointerDiffType();
12985 Type = Context.getFILEType();
12986 if (
Type.isNull()) {
12993 Type = Context.getsigjmp_bufType();
12995 Type = Context.getjmp_bufType();
12997 if (
Type.isNull()) {
13003 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
13004 Type = Context.getucontext_tType();
13006 if (
Type.isNull()) {
13012 Type = Context.getProcessIDType();
13015 Type = Context.MFloat8Ty;
13020 Done = !AllowTypeModifiers;
13022 switch (
char c = *Str++) {
13023 default: Done =
true; --Str;
break;
13029 unsigned AddrSpace = strtoul(Str, &End, 10);
13032 Type = Context.getAddrSpaceQualType(
13034 Context.getLangASForBuiltinAddressSpace(AddrSpace));
13038 Type = Context.getPointerType(
Type);
13040 Type = Context.getLValueReferenceType(
Type);
13048 Type = Context.getVolatileType(
Type);
13057 "Integer constant 'I' type must be an integer");
13070 bool AllowTypeModifiers)
const {
13077 unsigned *IntegerConstantArgs)
const {
13078 const char *TypeStr =
BuiltinInfo.getTypeString(Id);
13079 if (TypeStr[0] ==
'\0') {
13086 bool RequiresICE =
false;
13089 RequiresICE,
true);
13093 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
13095 while (TypeStr[0] && TypeStr[0] !=
'.') {
13102 if (RequiresICE && IntegerConstantArgs)
13103 *IntegerConstantArgs |= 1 << ArgTypes.size();
13109 ArgTypes.push_back(Ty);
13112 if (Id == Builtin::BI__GetExceptionInfo)
13115 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
13116 "'.' should only occur at end of builtin type list!");
13118 bool Variadic = (TypeStr[0] ==
'.');
13125 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
13175 if ((!Context.getLangOpts().CPlusPlus &&
13176 !Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13177 !FD->
hasAttr<DLLExportAttr>()) ||
13178 FD->
hasAttr<GNUInlineAttr>()) {
13197 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13200 !FD->
hasAttr<DLLExportAttr>()) {
13221 if (D->
hasAttr<DLLImportAttr>()) {
13224 }
else if (D->
hasAttr<DLLExportAttr>()) {
13227 }
else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice) {
13230 if (D->
hasAttr<CUDAGlobalAttr>() &&
13239 if (Context.shouldExternalize(D))
13254 switch (Source->hasExternalDefinitions(D)) {
13281 if (Context.getLangOpts().CPlusPlus &&
13282 Context.getLangOpts().IncrementalExtensions &&
13298 if (!LexicalContext)
13303 auto StaticLocalLinkage =
13315 return StaticLocalLinkage;
13321 if (Context.isMSStaticDataMemberInlineDefinition(VD))
13327 switch (Context.getInlineVariableDefinitionKind(VD)) {
13342 return StrongLinkage;
13345 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13360 llvm_unreachable(
"Invalid Linkage!");
13370 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13371 if (!VD->isFileVarDecl())
13376 if (VD->getDescribedVarTemplate() ||
13379 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13405 if (D->
hasAttr<WeakRefAttr>())
13412 if (LangOpts.SYCLIsDevice)
13414 D->
hasAttr<SYCLExternalAttr>());
13420 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13422 if (!FD->doesThisDeclarationHaveABody())
13423 return FD->doesDeclarationForceExternallyVisibleDefinition();
13426 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13431 if (
getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
13432 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13451 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13455 if (LangOpts.OpenMP &&
13456 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13463 if (VD->shouldEmitInExternalSource())
13476 if (VD->needsDestruction(*
this))
13480 if (VD->hasInitWithSideEffects())
13485 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13486 for (
const auto *BD : DD->flat_bindings())
13487 if (
const auto *BindingVD = BD->getHoldingVar())
13496 if (
auto *A = D->
getAttr<AttrT>())
13497 return A->isImplicit();
13502 assert(LangOpts.CUDA &&
"Should not be called by non-CUDA languages");
13504 "Expected Variable or Function");
13506 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13510 return !LangOpts.CUDAIsDevice || VD->hasAttr<CUDADeviceAttr>() ||
13511 VD->hasAttr<CUDAConstantAttr>() || VD->hasAttr<CUDASharedAttr>() ||
13512 VD->getType()->isCUDADeviceBuiltinSurfaceType() ||
13513 VD->getType()->isCUDADeviceBuiltinTextureType();
13518 if (!LangOpts.CUDAIsDevice)
13519 return FD->
hasAttr<CUDAHostAttr>() || !FD->
hasAttr<CUDADeviceAttr>();
13523 return (FD->
hasAttr<CUDADeviceAttr>() &&
13524 !(LangOpts.OffloadImplicitHostDeviceTemplates &&
13529 FD->
hasAttr<CUDAGlobalAttr>() ||
13530 (LangOpts.HIPStdPar && !FD->
hasAttr<CUDAHostAttr>());
13535 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13536 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13537 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13542 for (
auto *CurDecl :
13546 SeenDecls.insert(CurFD).second) {
13553 bool IsCXXMethod)
const {
13556 return ABI->getDefaultMethodCallConv(IsVariadic);
13558 switch (LangOpts.getDefaultCallingConv()) {
13586 return Target->getDefaultCallingConv();
13591 return ABI->isNearlyEmpty(RD);
13596 auto ABI = Target->getCXXABI();
13597 if (ABI.isMicrosoft())
13603 return VTContext.get();
13609 switch (
T->getCXXABI().getKind()) {
13610 case TargetCXXABI::AppleARM64:
13611 case TargetCXXABI::Fuchsia:
13612 case TargetCXXABI::GenericAArch64:
13613 case TargetCXXABI::GenericItanium:
13614 case TargetCXXABI::GenericARM:
13615 case TargetCXXABI::GenericMIPS:
13616 case TargetCXXABI::iOS:
13617 case TargetCXXABI::WebAssembly:
13618 case TargetCXXABI::WatchOS:
13619 case TargetCXXABI::XL:
13621 case TargetCXXABI::Microsoft:
13624 llvm_unreachable(
"Unsupported ABI");
13628 assert(
T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13629 "Device mangle context does not support Microsoft mangling.");
13630 switch (
T.getCXXABI().getKind()) {
13631 case TargetCXXABI::AppleARM64:
13632 case TargetCXXABI::Fuchsia:
13633 case TargetCXXABI::GenericAArch64:
13634 case TargetCXXABI::GenericItanium:
13635 case TargetCXXABI::GenericARM:
13636 case TargetCXXABI::GenericMIPS:
13637 case TargetCXXABI::iOS:
13638 case TargetCXXABI::WebAssembly:
13639 case TargetCXXABI::WatchOS:
13640 case TargetCXXABI::XL:
13644 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13645 return RD->getDeviceLambdaManglingNumber();
13646 return std::nullopt;
13649 case TargetCXXABI::Microsoft:
13653 llvm_unreachable(
"Unsupported ABI");
13671 return ASTRecordLayouts.getMemorySize() +
13672 llvm::capacity_in_bytes(ObjCLayouts) +
13673 llvm::capacity_in_bytes(KeyFunctions) +
13674 llvm::capacity_in_bytes(ObjCImpls) +
13675 llvm::capacity_in_bytes(BlockVarCopyInits) +
13676 DeclAttrAllocator.getTotalMemory() +
13677 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13678 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13679 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13680 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13681 llvm::capacity_in_bytes(OverriddenMethods) +
13682 llvm::capacity_in_bytes(Types) +
13683 llvm::capacity_in_bytes(VariableArrayTypes);
13691 unsigned Signed)
const {
13694 if (!QualTy && DestWidth == 128)
13700 unsigned Signed)
const {
13701 return getFromTargetType(
13729 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13736 MangleNumbers[ND] = Number;
13739 Listener->AddedManglingNumber(ND, Number);
13743 bool ForAuxTarget)
const {
13744 auto I = MangleNumbers.find(ND);
13745 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13748 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13749 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13751 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13752 "number for aux target");
13754 return Res > 1 ? Res : 1;
13761 StaticLocalNumbers[VD] = Number;
13764 Listener->AddedStaticLocalNumbers(VD, Number);
13768 auto I = StaticLocalNumbers.find(VD);
13769 return I != StaticLocalNumbers.end() ? I->second : 1;
13773 bool IsDestroying) {
13774 if (!IsDestroying) {
13786 bool IsTypeAware) {
13787 if (!IsTypeAware) {
13803 OperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] = OperatorDelete;
13806 GlobalOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13810 ArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13814 GlobalArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13824 return OperatorDeletesForVirtualDtor.contains(Dtor->getCanonicalDecl());
13826 return GlobalOperatorDeletesForVirtualDtor.contains(
13827 Dtor->getCanonicalDecl());
13829 return ArrayOperatorDeletesForVirtualDtor.contains(
13830 Dtor->getCanonicalDecl());
13832 return GlobalArrayOperatorDeletesForVirtualDtor.contains(
13833 Dtor->getCanonicalDecl());
13844 if (OperatorDeletesForVirtualDtor.contains(Canon))
13845 return OperatorDeletesForVirtualDtor[Canon];
13848 if (GlobalOperatorDeletesForVirtualDtor.contains(Canon))
13849 return GlobalOperatorDeletesForVirtualDtor[Canon];
13852 if (ArrayOperatorDeletesForVirtualDtor.contains(Canon))
13853 return ArrayOperatorDeletesForVirtualDtor[Canon];
13856 if (GlobalArrayOperatorDeletesForVirtualDtor.contains(Canon))
13857 return GlobalArrayOperatorDeletesForVirtualDtor[Canon];
13868 return MaybeRequireVectorDeletingDtor.count(RD);
13876 MaybeRequireVectorDeletingDtor.insert(RD);
13881 assert(LangOpts.CPlusPlus);
13885 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13893 assert(LangOpts.CPlusPlus);
13894 std::unique_ptr<MangleNumberingContext> &MCtx =
13895 ExtraMangleNumberingContexts[D];
13901std::unique_ptr<MangleNumberingContext>
13903 return ABI->createMangleNumberingContext();
13908 return ABI->getCopyConstructorForExceptionObject(
13914 return ABI->addCopyConstructorForExceptionObject(
13921 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13926 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13931 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13935 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13939 ParamIndices[D] =
index;
13943 ParameterIndexTable::const_iterator I = ParamIndices.find(D);
13944 assert(I != ParamIndices.end() &&
13945 "ParmIndices lacks entry set by ParmVarDecl");
13950 unsigned Length)
const {
13976 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13978 llvm::FoldingSetNodeID ID;
13981 llvm::FoldingSetInsertToken
Token;
13986 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
13993 const APValue &APVal)
const {
13994 llvm::FoldingSetNodeID ID;
13997 llvm::FoldingSetInsertToken
Token;
13999 UnnamedGlobalConstantDecls.lookup(ID,
Token))
14003 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
14004 UnnamedGlobalConstantDecls.insert(
New,
Token);
14010 assert(
T->isRecordType() &&
"template param object of unexpected type");
14016 llvm::FoldingSetNodeID ID;
14019 llvm::FoldingSetInsertToken
Token;
14021 TemplateParamObjectDecls.lookup(ID,
Token))
14025 TemplateParamObjectDecls.insert(
New,
Token);
14031 if (!
T.isOSDarwin())
14034 if (!(
T.isiOS() &&
T.isOSVersionLT(7)) &&
14035 !(
T.isMacOSX() &&
T.isOSVersionLT(10, 9)))
14044 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
14051 if (MethodDecl->
hasAttr<UnavailableAttr>()
14052 || MethodDecl->
hasAttr<DeprecatedAttr>())
14066 IM != EM && IF != EF; ++IM, ++IF) {
14097 llvm::FoldingSetNodeID IDX, IDY;
14098 X->Profile(IDX, *
this,
true);
14099 Y->
Profile(IDY, *
this,
true);
14113 for (
const Decl *DX :
X->redecls()) {
14118 if (DX->isFirstDecl())
14121 llvm_unreachable(
"Corrupt redecls chain");
14124template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14126 return cast_or_null<T>(
14128 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
14131template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14139 bool IgnoreDeduced =
false) {
14154 bool IgnoreDeduced) {
14156 assert(R.getAsVoidPointer() !=
nullptr);
14162 assert(Xs.size() == Ys.size());
14164 for (
size_t I = 0; I < Rs.size(); ++I)
14171 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
14181 switch (
X.getKind()) {
14211 auto NExpX =
X.getNumTemplateExpansions();
14225 if (Xs.size() != Ys.size())
14227 R.resize(Xs.size());
14228 for (
size_t I = 0; I < R.size(); ++I) {
14241 assert(!Different);
14269 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
14271 return std::nullopt;
14276 assert(Kind == NNS2.
getKind());
14281 auto Kind = Namespace1->getKind();
14282 if (Kind != Namespace2->getKind() ||
14283 (Kind == Decl::NamespaceAlias &&
14288 Namespace2->getNamespace()),
14322 llvm_unreachable(
"singletons did not compare equal");
14324 assert(R.getCanonical() == Canon);
14330 const T *Y,
bool IsSame) {
14331 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
14351 QX +=
X.getQualifiers() - RQ;
14361 Y->getElementType(), QX, QY);
14372 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
14373 return X->getSizeExpr();
14378 return X->getSizeModifier();
14384 return X->getIndexTypeCVRQualifiers();
14394 llvm::DenseMap<QualType, unsigned>
Found;
14395 for (
auto Ts : {
X, Y}) {
14402 Out.emplace_back(
T);
14408FunctionProtoType::ExceptionSpecInfo
14412 bool AcceptDependent)
const {
14438 assert(AcceptDependent &&
14439 "computing composite pointer type of dependent types");
14454 llvm_unreachable(
"These ESTs should be handled above");
14459 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
14463 Result.Exceptions = ExceptionTypeStorage;
14470 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
14473 llvm_unreachable(
"invalid ExceptionSpecificationType");
14482#define UNEXPECTED_TYPE(Class, Kind) \
14483 case Type::Class: \
14484 llvm_unreachable("Unexpected " Kind ": " #Class);
14486#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
14487#define TYPE(Class, Base)
14488#include "clang/AST/TypeNodes.inc"
14490#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
14501#undef SUGAR_FREE_TYPE
14502#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
14505#undef NON_UNIQUE_TYPE
14509#undef UNEXPECTED_TYPE
14513 assert(AX->getDeducedKind() == AY->getDeducedKind());
14515 assert(AX->getKeyword() == AY->getKeyword());
14518 AY->getTypeConstraintConcept().getAsTemplateDecl());
14522 AY->getTypeConstraintArguments())) {
14529 case Type::IncompleteArray: {
14536 case Type::DependentSizedArray: {
14544 case Type::ConstantArray: {
14547 assert(AX->getSize() == AY->getSize());
14548 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14549 ? AX->getSizeExpr()
14555 case Type::ArrayParameter: {
14558 assert(AX->getSize() == AY->getSize());
14559 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14560 ? AX->getSizeExpr()
14567 case Type::Atomic: {
14572 case Type::Complex: {
14576 case Type::Pointer: {
14580 case Type::BlockPointer: {
14584 case Type::ObjCObjectPointer: {
14589 case Type::MemberPointer: {
14593 PY->getMostRecentCXXRecordDecl()));
14597 PX->getMostRecentCXXRecordDecl());
14599 case Type::LValueReference: {
14604 PX->isSpelledAsLValue() ||
14605 PY->isSpelledAsLValue());
14607 case Type::RValueReference: {
14613 case Type::DependentAddressSpace: {
14616 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14618 PX->getAddrSpaceExpr(),
14621 case Type::FunctionNoProto: {
14624 assert(FX->getExtInfo() == FY->getExtInfo());
14629 case Type::FunctionProto: {
14633 EPIY = FY->getExtProtoInfo();
14634 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14641 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14642 assert(EPIX.
Variadic == EPIY.Variadic);
14651 auto P =
getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
14659 case Type::ObjCObject: {
14662 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14663 OY->getProtocols().begin(), OY->getProtocols().end(),
14665 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14667 "protocol lists must be the same");
14669 OY->getTypeArgsAsWritten());
14672 OX->getProtocols(),
14673 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14675 case Type::ConstantMatrix: {
14678 assert(MX->getNumRows() == MY->getNumRows());
14679 assert(MX->getNumColumns() == MY->getNumColumns());
14681 MX->getNumRows(), MX->getNumColumns());
14683 case Type::DependentSizedMatrix: {
14686 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14687 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14692 case Type::Vector: {
14694 assert(VX->getNumElements() == VY->getNumElements());
14695 assert(VX->getVectorKind() == VY->getVectorKind());
14697 VX->getNumElements(), VX->getVectorKind());
14699 case Type::ExtVector: {
14701 assert(VX->getNumElements() == VY->getNumElements());
14703 VX->getNumElements());
14705 case Type::DependentSizedExtVector: {
14712 case Type::DependentVector: {
14715 assert(VX->getVectorKind() == VY->getVectorKind());
14722 case Type::InjectedClassName: {
14729 case Type::TemplateSpecialization: {
14733 TY->template_arguments());
14737 TY->getTemplateName(),
14739 As, {},
X->getCanonicalTypeInternal());
14741 case Type::Decltype: {
14744 assert(DX->isDependentType());
14745 assert(DY->isDependentType());
14746 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14750 case Type::PackIndexing: {
14753 assert(DX->isDependentType());
14754 assert(DY->isDependentType());
14755 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14758 case Type::DependentName: {
14761 assert(NX->getIdentifier() == NY->getIdentifier());
14766 case Type::OverflowBehavior: {
14769 assert(NX->getBehaviorKind() == NY->getBehaviorKind());
14771 NX->getBehaviorKind(),
14773 NY->getUnderlyingType(), QX, QY));
14775 case Type::UnaryTransform: {
14778 assert(TX->getUTTKind() == TY->getUTTKind());
14782 TY->getUnderlyingType()),
14785 case Type::PackExpansion: {
14788 assert(PX->getNumExpansions() == PY->getNumExpansions());
14791 PX->getNumExpansions(),
false);
14795 assert(PX->isReadOnly() == PY->isReadOnly());
14800 case Type::TemplateTypeParm: {
14803 assert(TX->getDepth() == TY->getDepth());
14804 assert(TX->getIndex() == TY->getIndex());
14805 assert(TX->isParameterPack() == TY->isParameterPack());
14807 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14811 llvm_unreachable(
"Unknown Type Class");
14821#define UNEXPECTED_TYPE(Class, Kind) \
14822 case Type::Class: \
14823 llvm_unreachable("Unexpected " Kind ": " #Class);
14824#define TYPE(Class, Base)
14825#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14826#include "clang/AST/TypeNodes.inc"
14828#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14855#undef CANONICAL_TYPE
14857#undef UNEXPECTED_TYPE
14859 case Type::Adjusted: {
14861 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14868 case Type::Decayed: {
14870 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14877 case Type::Attributed: {
14879 AttributedType::Kind Kind = AX->getAttrKind();
14880 if (Kind != AY->getAttrKind())
14882 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14890 case Type::BTFTagAttributed: {
14892 const BTFTypeTagAttr *AX = BX->getAttr();
14894 if (AX->getBTFTypeTag() !=
14905 if (KW != AY->getKeyword())
14910 AY->getTypeConstraintConcept().getAsTemplateDecl());
14914 AY->getTypeConstraintArguments())) {
14925 case Type::PackIndexing:
14926 case Type::Decltype:
14928 case Type::DeducedTemplateSpecialization:
14931 case Type::MacroQualified: {
14935 if (IX != MY->getMacroIdentifier())
14939 case Type::SubstTemplateTypeParm: {
14946 unsigned Index = SX->getIndex();
14947 if (Index != SY->getIndex())
14954 SX->getFinal() && SY->getFinal());
14956 case Type::ObjCTypeParam:
14962 case Type::TemplateSpecialization: {
14967 TY->getTemplateName(),
true);
14972 TY->template_arguments()))
14978 case Type::Typedef: {
14988 case Type::TypeOf: {
14999 case Type::TypeOfExpr:
15002 case Type::UnaryTransform: {
15005 UnaryTransformType::UTTKind KX = UX->getUTTKind();
15006 if (KX != UY->getUTTKind())
15008 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
15015 case Type::Using: {
15024 case Type::MemberPointer: {
15028 assert(Cls == PY->getMostRecentCXXRecordDecl());
15033 case Type::CountAttributed: {
15036 if (DX->isCountInBytes() != DY->isCountInBytes())
15038 if (DX->isOrNull() != DY->isOrNull())
15040 Expr *CEX = DX->getCountExpr();
15041 Expr *CEY = DY->getCountExpr();
15045 DX->isCountInBytes(), DX->isOrNull(),
15056 DX->isCountInBytes(), DX->isOrNull(),
15060 case Type::LateParsedAttr:
15063 case Type::PredefinedSugar:
15068 llvm_unreachable(
"Unhandled Type Class");
15075 QualType NT =
T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
15090 if (
X.isCanonical())
15117 bool KeepCommonQualifiers =
15120 if (SX.
Ty != SY.Ty) {
15128 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
15131 SX = Xs.pop_back_val();
15132 SY = Ys.pop_back_val();
15135 if (KeepCommonQualifiers)
15142 while (!Xs.empty() && !Ys.empty()) {
15145 SX = Xs.pop_back_val();
15146 SY = Ys.pop_back_val();
15151 SX.
Ty = Underlying.Ty;
15154 QX -= Underlying.Quals;
15172 llvm_unreachable(
"Not a saturated fixed point type!");
15173 case BuiltinType::SatShortAccum:
15175 case BuiltinType::SatAccum:
15177 case BuiltinType::SatLongAccum:
15179 case BuiltinType::SatUShortAccum:
15181 case BuiltinType::SatUAccum:
15183 case BuiltinType::SatULongAccum:
15185 case BuiltinType::SatShortFract:
15187 case BuiltinType::SatFract:
15189 case BuiltinType::SatLongFract:
15191 case BuiltinType::SatUShortFract:
15193 case BuiltinType::SatUFract:
15195 case BuiltinType::SatULongFract:
15207 llvm_unreachable(
"Not a fixed point type!");
15208 case BuiltinType::ShortAccum:
15210 case BuiltinType::Accum:
15212 case BuiltinType::LongAccum:
15214 case BuiltinType::UShortAccum:
15216 case BuiltinType::UAccum:
15218 case BuiltinType::ULongAccum:
15220 case BuiltinType::ShortFract:
15222 case BuiltinType::Fract:
15224 case BuiltinType::LongFract:
15226 case BuiltinType::UShortFract:
15228 case BuiltinType::UFract:
15230 case BuiltinType::ULongFract:
15236 if (LangOpts.OpenCL)
15251 llvm_unreachable(
"Not a fixed point type!");
15252 case BuiltinType::ShortAccum:
15253 case BuiltinType::SatShortAccum:
15254 return Target.getShortAccumScale();
15255 case BuiltinType::Accum:
15256 case BuiltinType::SatAccum:
15257 return Target.getAccumScale();
15258 case BuiltinType::LongAccum:
15259 case BuiltinType::SatLongAccum:
15260 return Target.getLongAccumScale();
15261 case BuiltinType::UShortAccum:
15262 case BuiltinType::SatUShortAccum:
15263 return Target.getUnsignedShortAccumScale();
15264 case BuiltinType::UAccum:
15265 case BuiltinType::SatUAccum:
15266 return Target.getUnsignedAccumScale();
15267 case BuiltinType::ULongAccum:
15268 case BuiltinType::SatULongAccum:
15269 return Target.getUnsignedLongAccumScale();
15270 case BuiltinType::ShortFract:
15271 case BuiltinType::SatShortFract:
15272 return Target.getShortFractScale();
15273 case BuiltinType::Fract:
15274 case BuiltinType::SatFract:
15275 return Target.getFractScale();
15276 case BuiltinType::LongFract:
15277 case BuiltinType::SatLongFract:
15278 return Target.getLongFractScale();
15279 case BuiltinType::UShortFract:
15280 case BuiltinType::SatUShortFract:
15281 return Target.getUnsignedShortFractScale();
15282 case BuiltinType::UFract:
15283 case BuiltinType::SatUFract:
15284 return Target.getUnsignedFractScale();
15285 case BuiltinType::ULongFract:
15286 case BuiltinType::SatULongFract:
15287 return Target.getUnsignedLongFractScale();
15297 llvm_unreachable(
"Not a fixed point type!");
15298 case BuiltinType::ShortAccum:
15299 case BuiltinType::SatShortAccum:
15300 return Target.getShortAccumIBits();
15301 case BuiltinType::Accum:
15302 case BuiltinType::SatAccum:
15303 return Target.getAccumIBits();
15304 case BuiltinType::LongAccum:
15305 case BuiltinType::SatLongAccum:
15306 return Target.getLongAccumIBits();
15307 case BuiltinType::UShortAccum:
15308 case BuiltinType::SatUShortAccum:
15309 return Target.getUnsignedShortAccumIBits();
15310 case BuiltinType::UAccum:
15311 case BuiltinType::SatUAccum:
15312 return Target.getUnsignedAccumIBits();
15313 case BuiltinType::ULongAccum:
15314 case BuiltinType::SatULongAccum:
15315 return Target.getUnsignedLongAccumIBits();
15316 case BuiltinType::ShortFract:
15317 case BuiltinType::SatShortFract:
15318 case BuiltinType::Fract:
15319 case BuiltinType::SatFract:
15320 case BuiltinType::LongFract:
15321 case BuiltinType::SatLongFract:
15322 case BuiltinType::UShortFract:
15323 case BuiltinType::SatUShortFract:
15324 case BuiltinType::UFract:
15325 case BuiltinType::SatUFract:
15326 case BuiltinType::ULongFract:
15327 case BuiltinType::SatULongFract:
15332llvm::FixedPointSemantics
15335 "Can only get the fixed point semantics for a "
15336 "fixed point or integer type.");
15338 return llvm::FixedPointSemantics::GetIntegerSemantics(
15342 return llvm::FixedPointSemantics(
15345 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
15360 "Expected unsigned fixed point type");
15363 case BuiltinType::UShortAccum:
15365 case BuiltinType::UAccum:
15367 case BuiltinType::ULongAccum:
15369 case BuiltinType::SatUShortAccum:
15371 case BuiltinType::SatUAccum:
15373 case BuiltinType::SatULongAccum:
15375 case BuiltinType::UShortFract:
15377 case BuiltinType::UFract:
15379 case BuiltinType::ULongFract:
15381 case BuiltinType::SatUShortFract:
15383 case BuiltinType::SatUFract:
15385 case BuiltinType::SatULongFract:
15388 llvm_unreachable(
"Unexpected unsigned fixed point type");
15396 std::vector<std::string> BackendFeats;
15397 llvm::AArch64::ExtensionSet FeatureBits;
15398 for (StringRef F : FMVFeatStrings)
15399 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
15401 FeatureBits.enable(*FMVExt->ID);
15402 FeatureBits.toLLVMFeatureList(BackendFeats);
15403 return BackendFeats;
15408 assert(TD !=
nullptr);
15411 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
15412 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
15417const llvm::StringMap<bool> &
15422const llvm::StringMap<bool> &
15426 return Target->getTargetOpts().FeatureMap;
15428 const Attr *FeatureAttr;
15429 StringRef FeatureText;
15430 if (
const auto *TargetAttribute = FD->
getAttr<TargetAttr>()) {
15431 FeatureAttr = TargetAttribute;
15432 FeatureText = TargetAttribute->getFeaturesStr();
15433 }
else if (
const auto *Specific = FD->
getAttr<CPUSpecificAttr>()) {
15434 FeatureAttr = Specific;
15436 }
else if (
const auto *Clones = FD->
getAttr<TargetClonesAttr>()) {
15437 FeatureAttr = Clones;
15439 }
else if (
const auto *Version = FD->
getAttr<TargetVersionAttr>()) {
15440 FeatureAttr = Version;
15441 FeatureText = Version->getName();
15443 return Target->getTargetOpts().FeatureMap;
15446 auto Key = std::make_pair(FeatureText,
unsigned(FeatureAttr->
getKind()));
15447 auto It = FunctionFeatureMaps.find(Key);
15448 if (It != FunctionFeatureMaps.end())
15449 return *It->second;
15451 auto FeatureMap = std::make_unique<llvm::StringMap<bool>>();
15453 return *FunctionFeatureMaps.try_emplace(Key, std::move(FeatureMap))
15463 Target->getTargetOpts().CPU,
15464 Target->getTargetOpts().Features);
15471 StringRef TargetCPU = Target->getTargetOpts().CPU;
15473 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
15479 if (!Target->getTriple().isAArch64())
15482 Target->getTargetOpts().FeaturesAsWritten.begin(),
15483 Target->getTargetOpts().FeaturesAsWritten.end());
15494 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
15496 Target->getCPUSpecificCPUDispatchFeatures(
15498 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
15499 Features.insert(Features.begin(),
15500 Target->getTargetOpts().FeaturesAsWritten.begin(),
15501 Target->getTargetOpts().FeaturesAsWritten.end());
15502 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15503 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
15504 if (Target->getTriple().isAArch64()) {
15508 Features.insert(Features.begin(),
15509 Target->getTargetOpts().FeaturesAsWritten.begin(),
15510 Target->getTargetOpts().FeaturesAsWritten.end());
15511 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15512 }
else if (Target->getTriple().isRISCV()) {
15514 std::vector<std::string> Features;
15515 if (VersionStr !=
"default") {
15517 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15520 Features.insert(Features.begin(),
15521 Target->getTargetOpts().FeaturesAsWritten.begin(),
15522 Target->getTargetOpts().FeaturesAsWritten.end());
15523 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15524 }
else if (Target->getTriple().isOSAIX()) {
15525 std::vector<std::string> Features;
15527 if (VersionStr.starts_with(
"cpu="))
15528 TargetCPU = VersionStr.drop_front(
sizeof(
"cpu=") - 1);
15529 else if (VersionStr !=
"default")
15530 Features = Target->parseTargetAttr(VersionStr).Features;
15531 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15533 std::vector<std::string> Features;
15535 if (VersionStr.starts_with(
"arch="))
15536 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
15537 else if (VersionStr !=
"default")
15538 Features.push_back((StringRef{
"+"} + VersionStr).str());
15539 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15541 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
15542 std::vector<std::string> Features;
15543 if (Target->getTriple().isRISCV()) {
15545 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15548 assert(Target->getTriple().isAArch64());
15550 TV->getFeatures(Feats);
15553 Features.insert(Features.begin(),
15554 Target->getTargetOpts().FeaturesAsWritten.begin(),
15555 Target->getTargetOpts().FeaturesAsWritten.end());
15556 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15558 FeatureMap = Target->getTargetOpts().FeatureMap;
15569 auto DeviceDiscriminatorOverrider =
15571 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15573 return RD->getDeviceLambdaManglingNumber();
15574 return std::nullopt;
15577 Context, Context.getDiagnostics(), DeviceDiscriminatorOverrider)};
15585 std::string Buffer;
15586 Buffer.reserve(128);
15587 llvm::raw_string_ostream Out(Buffer);
15588 MC->mangleCanonicalTypeName(KernelNameType, Out);
15589 std::string KernelName = Out.str();
15591 return {KernelNameType, FD, KernelName};
15600 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15601 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15610 "SYCL kernel name conflict");
15625 return &IT->second;
15631 return *OMPTraitInfoVector.back();
15638 return DB << Section.
Decl;
15639 return DB <<
"a prior #pragma section";
15643 bool IsInternalVar =
15646 bool IsExplicitDeviceVar = (D->
hasAttr<CUDADeviceAttr>() &&
15647 !D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15648 (D->
hasAttr<CUDAConstantAttr>() &&
15649 !D->
getAttr<CUDAConstantAttr>()->isImplicit());
15653 return (IsInternalVar &&
15654 (D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15655 (D->
hasAttr<CUDAGlobalAttr>() &&
15662 (D->
hasAttr<HIPManagedAttr>() || D->
hasAttr<CUDAGlobalAttr>() ||
15667 if (!CUIDHash.empty())
15669 if (LangOpts.CUID.empty())
15670 return StringRef();
15671 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.CUID),
true);
15681 assert(PrimaryBase);
15684 auto Base = Layout.getPrimaryBase();
15685 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15687 PrimaryBase =
Base;
15689 return PrimaryBase;
15693 StringRef MangledName) {
15695 assert(
Method->isVirtual());
15696 bool DefaultIncludesPointerAuth =
15697 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15699 if (!DefaultIncludesPointerAuth)
15702 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15703 if (Existing != ThunksToBeAbbreviated.end())
15704 return Existing->second.contains(MangledName.str());
15707 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15709 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15711 for (
const auto &Thunk : *ThunkInfos) {
15713 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15719 Mangler->mangleThunk(
Method, Thunk,
true,
15722 llvm::raw_svector_ostream mangledNameStream(MangledName);
15726 mangledNameStream);
15728 Mangler->mangleThunk(
Method, Thunk,
false,
15729 mangledNameStream);
15731 Thunks[ElidedName].push_back(std::string(MangledName));
15734 llvm::StringSet<> SimplifiedThunkNames;
15735 for (
auto &ThunkList : Thunks) {
15736 llvm::sort(ThunkList.second);
15737 SimplifiedThunkNames.insert(ThunkList.second[0]);
15739 bool Result = SimplifiedThunkNames.contains(MangledName);
15740 ThunksToBeAbbreviated[VirtualMethodDecl] = std::move(SimplifiedThunkNames);
15758 std::vector<PFPField> &Fields,
bool IncludeVBases) {
15760 if (
auto *ElemDecl = AT->getElementType()->getAsCXXRecordDecl()) {
15762 for (
unsigned i = 0; i != AT->getSize(); ++i)
15779 Fields.push_back({FieldOffset, Field});
15786 if (
Base.isVirtual())
15793 if (IncludeVBases) {
15804 std::vector<PFPField> PFPFields;
15814 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->
getParent()))
15816 !FD->
hasAttr<NoFieldProtectionAttr>();
15821 auto *FD = dyn_cast<FieldDecl>(VD);
15844struct PaddingCalculator {
15845 PaddingCalculator(
const ASTContext &Ctx) : Ctx(Ctx) {}
15848 OccuppiedIntervals.clear();
15854 while (!Stack.empty()) {
15855 Data Current = Stack.back();
15859 MergeOccuppiedIntervals();
15862 llvm::SmallVector<ASTContext::BitInterval> GetPaddingIntervals() {
15863 llvm::SmallVector<ASTContext::BitInterval> Results;
15864 if (OccuppiedIntervals.size() == 1 &&
15865 OccuppiedIntervals.front().First == 0 &&
15866 OccuppiedIntervals.front().Last == TySizeInBits) {
15869 Results.reserve(OccuppiedIntervals.size() + 1);
15871 for (
const ASTContext::BitInterval &OccupiedInterval : OccuppiedIntervals) {
15872 if (OccupiedInterval.First > CurrentPos) {
15874 ASTContext::BitInterval{CurrentPos, OccupiedInterval.First});
15876 CurrentPos = OccupiedInterval.Last;
15878 if (TySizeInBits > CurrentPos) {
15879 Results.push_back(ASTContext::BitInterval{CurrentPos, TySizeInBits});
15888 bool VisitVirtualBase;
15914 uint64_t getScalarOccupiedSizeInBits(QualType Ty)
const {
15915 if (
const auto *BIT = Ty->
getAs<BitIntType>())
15916 return BIT->getNumBits();
15918 if (
const auto *BT = Ty->
getAs<BuiltinType>()) {
15919 if (BT->getKind() == BuiltinType::LongDouble &&
15921 &llvm::APFloat::x87DoubleExtended())
15922 return llvm::APFloat::getSizeInBits(
15929 void Visit(
const Data &D) {
15930 if (
auto *AT = dyn_cast<ConstantArrayType>(D.Ty)) {
15931 VisitArray(AT, D.StartBitOffset);
15935 if (
auto *
Record = D.Ty->getAsRecordDecl()) {
15936 VisitStruct(
Record, D.StartBitOffset, D.VisitVirtualBase);
15940 if (D.Ty->isAtomicType()) {
15941 auto Unwrapped = D;
15942 Unwrapped.Ty = D.Ty.getAtomicUnqualifiedType().getCanonicalType();
15943 Stack.push_back(Unwrapped);
15947 if (
const auto *
Complex = D.Ty->getAs<ComplexType>()) {
15948 VisitComplex(
Complex, D.StartBitOffset);
15952 if (
const auto *VT = D.Ty->getAs<clang::VectorType>()) {
15953 VisitVector(VT, D.StartBitOffset);
15957 if (
const auto *BITy = D.Ty->getAs<BitIntType>()) {
15958 VisitBitInt(BITy, D.StartBitOffset);
15962 uint64_t SizeBit = getScalarOccupiedSizeInBits(D.Ty);
15963 OccuppiedIntervals.push_back(
15964 ASTContext::BitInterval{D.StartBitOffset, D.StartBitOffset + SizeBit});
15967 void VisitArray(
const ConstantArrayType *AT,
uint64_t StartBitOffset) {
15968 for (
uint64_t ArrIndex = 0; ArrIndex < AT->
getSize().getLimitedValue();
15974 auto Offset = ElementSize.
alignTo(ElementAlign);
15976 Stack.push_back(
Data{
15977 StartBitOffset + ArrIndex * Offset.getQuantity() * Ctx.
getCharWidth(),
15982 void VisitStruct(
const RecordDecl *R,
uint64_t StartBitOffset,
15983 bool VisitVirtualBase) {
15985 auto *
CXXRecord = dyn_cast<CXXRecordDecl>(R);
15991 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15992 StartBitOffset, StartBitOffset + PointerSizeInBits});
15997 auto StartVBPtr = StartBitOffset + Offset * Ctx.
getCharWidth();
15998 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15999 StartVBPtr, StartVBPtr + PointerSizeInBits});
16002 const auto VisitBase = [&ASTLayout, StartBitOffset,
this](
16003 const CXXBaseSpecifier &
Base,
auto GetOffset) {
16004 auto *BaseRecord =
Base.getType()->getAsCXXRecordDecl();
16009 std::invoke(GetOffset, ASTLayout, BaseRecord).getQuantity();
16013 Base.getType().getCanonicalType(),
16018 if (!
Base.isVirtual()) {
16023 if (VisitVirtualBase) {
16024 for (
auto VBase :
CXXRecord->vbases()) {
16030 for (
auto *Field :
R->fields()) {
16032 if (
Field->isUnnamedBitField())
16036 if (
Field->isBitField()) {
16037 VisitBitfield(Field, StartBitOffset + FieldOffset);
16039 Stack.push_back(
Data{StartBitOffset + FieldOffset,
16040 Field->getType().getCanonicalType(),
16046 void VisitBitfield(
const FieldDecl *Field,
uint64_t StartBitOffset) {
16047 assert(
Field->isBitField() && !
Field->isUnnamedBitField());
16048 if (
Field->isZeroLengthBitField())
16051 const uint64_t DeclaredSizeInBits =
Field->getBitWidthValue();
16060 const uint64_t OccupiedSizeInBits =
16064 OccuppiedIntervals.push_back(
16065 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16080 const uint64_t Start = StartBitOffset;
16081 const uint64_t End = Start + OccupiedSizeInBits;
16085 const uint64_t ByteStart = llvm::alignDown(Start, CharWidth);
16086 const uint64_t ByteEnd = llvm::alignTo(End, CharWidth);
16087 if (ByteStart == ByteEnd - CharWidth) {
16088 const uint64_t Length = End - Start;
16089 const uint64_t Offset = Start - ByteStart;
16090 OccuppiedIntervals.push_back(
16091 {ByteEnd - Offset - Length, ByteEnd - Offset});
16097 const uint64_t MiddleIntervalStart = llvm::alignTo(Start, CharWidth);
16098 const uint64_t MiddleIntervalEnd = llvm::alignDown(End, CharWidth);
16099 if (MiddleIntervalStart != MiddleIntervalEnd)
16100 OccuppiedIntervals.push_back({MiddleIntervalStart, MiddleIntervalEnd});
16104 if (Start != MiddleIntervalStart) {
16105 const uint64_t Length = MiddleIntervalStart - Start;
16106 OccuppiedIntervals.push_back({ByteStart, ByteStart + Length});
16111 if (End != MiddleIntervalEnd) {
16112 const uint64_t Length = End - MiddleIntervalEnd;
16113 OccuppiedIntervals.push_back({ByteEnd - Length, ByteEnd});
16117 void VisitComplex(
const ComplexType *CT,
uint64_t StartBitOffset) {
16121 auto ImgOffset = ElementSize.
alignTo(ElementAlign);
16124 Data{StartBitOffset, ElementQualType,
true});
16127 ElementQualType,
true});
16130 void VisitVector(
const clang::VectorType *VT,
uint64_t StartBitOffset) {
16132 VisitPackedBooleanVector(VT, StartBitOffset);
16138 OccuppiedIntervals.push_back(
16139 ASTContext::BitInterval{StartBitOffset, StartBitOffset + SizeBit});
16147 void VisitBitInt(
const BitIntType *Ty,
uint64_t StartBitOffset) {
16151 OccuppiedIntervals.push_back(
16152 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16164 const uint64_t NumFullyPaddingBytes =
16165 (StorageSizeInBits - OccupiedSizeInBits) / CharWidth;
16166 const uint64_t NumFullyOccupiedBytes = OccupiedSizeInBits / CharWidth;
16167 const uint64_t NumRemainingOccupiedBits = OccupiedSizeInBits % CharWidth;
16170 if (NumRemainingOccupiedBits > 0)
16171 OccuppiedIntervals.push_back(
16172 {StartBitOffset + NumFullyPaddingBytes * CharWidth,
16173 StartBitOffset + NumFullyPaddingBytes * CharWidth +
16174 NumRemainingOccupiedBits});
16177 if (NumFullyOccupiedBytes > 0)
16178 OccuppiedIntervals.push_back({StartBitOffset + StorageSizeInBits -
16179 NumFullyOccupiedBytes * CharWidth,
16180 StartBitOffset + StorageSizeInBits});
16183 void VisitPackedBooleanVector(
const VectorType *VTy,
16186 assert(StartBitOffset % CharWidth == 0 &&
16187 "Expected aligned packed boolean vector");
16192 OccuppiedIntervals.push_back(
16193 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16201 const uint64_t NumFullyOccupiedBytes = OccupiedSizeInBits / CharWidth;
16202 const uint64_t NumRemainingOccupiedBits = OccupiedSizeInBits % CharWidth;
16206 if (NumRemainingOccupiedBits > 0) {
16207 const uint64_t ByteEnd = Start + CharWidth;
16208 OccuppiedIntervals.push_back({Start, Start + NumRemainingOccupiedBits});
16213 if (NumFullyOccupiedBytes > 0) {
16214 OccuppiedIntervals.push_back(
16215 {Start, Start + NumFullyOccupiedBytes * CharWidth});
16219 void MergeOccuppiedIntervals() {
16220 std::sort(OccuppiedIntervals.begin(), OccuppiedIntervals.end(),
16221 [](
const ASTContext::BitInterval &lhs,
16222 const ASTContext::BitInterval &rhs) {
16223 return std::tie(lhs.First, lhs.Last) <
16224 std::tie(rhs.First, rhs.Last);
16227 llvm::SmallVector<ASTContext::BitInterval> Merged;
16228 Merged.reserve(OccuppiedIntervals.size());
16230 for (
const ASTContext::BitInterval &NextInterval : OccuppiedIntervals) {
16231 if (Merged.empty()) {
16232 Merged.push_back(NextInterval);
16235 auto &LastInterval = Merged.back();
16237 if (NextInterval.First > LastInterval.Last) {
16238 Merged.push_back(NextInterval);
16240 LastInterval.Last = std::max(LastInterval.Last, NextInterval.Last);
16244 OccuppiedIntervals = Merged;
16247 const ASTContext &Ctx;
16250 llvm::SmallVector<Data> Stack;
16251 llvm::SmallVector<ASTContext::BitInterval> OccuppiedIntervals;
16255llvm::ArrayRef<ASTContext::BitInterval>
16258 auto cached = PaddingIntervalCache.find(Ty);
16259 if (cached != PaddingIntervalCache.end())
16260 return cached->second;
16262 PaddingCalculator pc{*
this};
16266 PaddingIntervalCache.insert_or_assign(Ty, pc.GetPaddingIntervals());
16267 assert(res &&
"Failed to insert?");
16269 return itr->second;
This file provides AST data structures related to concepts.
static void SortAndUniqueProtocols(SmallVectorImpl< ObjCProtocolDecl * > &Protocols)
static bool isCanonicalExceptionSpecification(const FunctionProtoType::ExceptionSpecInfo &ESI, bool NoexceptInType)
static SourceLocation getCommonAttrLoc(const T *X, const T *Y)
static auto getCanonicalTemplateArguments(const ASTContext &C, ArrayRef< TemplateArgument > Args, bool &AnyNonCanonArgs)
static char getObjCEncodingForPrimitiveType(const ASTContext *C, const BuiltinType *BT)
static bool isSameQualifier(const NestedNameSpecifier X, const NestedNameSpecifier Y)
static bool unionHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static TypedefDecl * CreateHexagonBuiltinVaListDecl(const ASTContext *Context)
#define CANONICAL_TYPE(Class)
static ElaboratedTypeKeyword getCommonTypeKeyword(const T *X, const T *Y, bool IsSame)
static Decl * getCommonDecl(Decl *X, Decl *Y)
static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context, const Decl *D, GVALinkage L)
static bool isTypeTypedefedAsBOOL(QualType T)
static void EncodeBitField(const ASTContext *Ctx, std::string &S, QualType T, const FieldDecl *FD)
static GVALinkage basicGVALinkageForVariable(const ASTContext &Context, const VarDecl *VD)
static QualType getCommonArrayElementType(const ASTContext &Ctx, const T *X, Qualifiers &QX, const T *Y, Qualifiers &QY)
static bool hasImplicitAttr(const ValueDecl *D)
#define SUGAR_FREE_TYPE(Class)
static SYCLKernelInfo BuildSYCLKernelInfo(ASTContext &Context, CanQualType KernelNameType, const FunctionDecl *FD)
static bool hasTemplateSpecializationInEncodedString(const Type *T, bool VisitBasesAndFields)
static void getIntersectionOfProtocols(ASTContext &Context, const ObjCInterfaceDecl *CommonBase, const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, SmallVectorImpl< ObjCProtocolDecl * > &IntersectionSet)
getIntersectionOfProtocols - This routine finds the intersection of set of protocols inherited from t...
static bool areCompatMatrixTypes(const ConstantMatrixType *LHS, const ConstantMatrixType *RHS)
areCompatMatrixTypes - Return true if the two specified matrix types are compatible.
static TypedefDecl * CreateAAPCSABIBuiltinVaListDecl(const ASTContext *Context)
static bool sameObjCTypeArgs(ASTContext &ctx, const ObjCInterfaceDecl *iface, ArrayRef< QualType > lhsArgs, ArrayRef< QualType > rhsArgs, bool stripKindOf)
static bool canAssignObjCObjectTypes(ASTContext &ctx, QualType lhs, QualType rhs)
Determine whether the first type is a subtype of the second.
static const Type * getIntegerTypeForEnum(const EnumType *ET)
static SmallVector< SourceLocation, 2 > getLocsForCommentSearch(ASTContext::RawCommentLookupKey Key, SourceManager &SourceMgr)
static bool hasSameCudaAttrs(const FunctionDecl *A, const FunctionDecl *B)
static TemplateName getCommonTemplateName(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced=false)
static int CmpProtocolNames(ObjCProtocolDecl *const *LHS, ObjCProtocolDecl *const *RHS)
CmpProtocolNames - Comparison predicate for sorting protocols alphabetically.
static auto * getCommonSizeExpr(const ASTContext &Ctx, T *X, T *Y)
static TypedefDecl * CreatePowerABIBuiltinVaListDecl(const ASTContext *Context)
static auto getCommonSizeModifier(const ArrayType *X, const ArrayType *Y)
static TemplateArgument getCommonTemplateArgument(const ASTContext &Ctx, const TemplateArgument &X, const TemplateArgument &Y)
static std::optional< int64_t > structHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static bool hasSameOverloadableAttrs(const FunctionDecl *A, const FunctionDecl *B)
Determine whether the attributes we can overload on are identical for A and B.
static T * getCommonDeclChecked(T *X, T *Y)
static NestedNameSpecifier getCommonNNS(const ASTContext &Ctx, NestedNameSpecifier NNS1, NestedNameSpecifier NNS2, bool IsSame)
Returns a NestedNameSpecifier which has only the common sugar present in both NNS1 and NNS2.
static TypedefDecl * CreateVoidPtrBuiltinVaListDecl(const ASTContext *Context)
static int64_t getSubobjectOffset(const FieldDecl *Field, const ASTContext &Context, const clang::ASTRecordLayout &)
static QualType getCommonSugarTypeNode(const ASTContext &Ctx, const Type *X, const Type *Y, SplitQualType Underlying)
static TypedefDecl * CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X, Qualifiers &QX, const Type *Y, Qualifiers &QY)
static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET, QualType other, bool isBlockReturnType)
Given that we have an enum type and a non-enum type, try to merge them.
static GVALinkage adjustGVALinkageForExternalDefinitionKind(const ASTContext &Ctx, const Decl *D, GVALinkage L)
Adjust the GVALinkage for a declaration based on what an external AST source knows about whether ther...
static TypedefDecl * CreateSystemZBuiltinVaListDecl(const ASTContext *Context)
static std::optional< int64_t > getSubobjectSizeInBits(const FieldDecl *Field, const ASTContext &Context, bool CheckIfTriviallyCopyable)
static GVALinkage basicGVALinkageForFunction(const ASTContext &Context, const FunctionDecl *FD)
#define NON_UNIQUE_TYPE(Class)
static TypedefDecl * CreateX86_64ABIBuiltinVaListDecl(const ASTContext *Context)
static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI, const LangOptions &LangOpts)
static ElaboratedTypeKeyword getCanonicalElaboratedTypeKeyword(ElaboratedTypeKeyword Keyword)
static QualType getCommonPointeeType(const ASTContext &Ctx, const T *X, const T *Y)
static auto getCommonIndexTypeCVRQualifiers(const ArrayType *X, const ArrayType *Y)
static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequiresICE, bool AllowTypeModifiers)
DecodeTypeFromStr - This decodes one type descriptor from Str, advancing the pointer over the consume...
static TypedefDecl * CreateCharPtrBuiltinVaListDecl(const ASTContext *Context)
static bool areSortedAndUniqued(ArrayRef< ObjCProtocolDecl * > Protocols)
static TypeInfoChars getConstantArrayInfoInChars(const ASTContext &Context, const ConstantArrayType *CAT)
getConstantArrayInfoInChars - Performing the computation in CharUnits instead of in bits prevents ove...
static FloatingRank getFloatingRank(QualType T)
getFloatingRank - Return a relative rank for floating point types.
static bool getCommonTemplateArguments(const ASTContext &Ctx, SmallVectorImpl< TemplateArgument > &R, ArrayRef< TemplateArgument > Xs, ArrayRef< TemplateArgument > Ys)
static TypedefDecl * CreateXtensaABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonElementType(const ASTContext &Ctx, const T *X, const T *Y)
static void mergeTypeLists(const ASTContext &Ctx, SmallVectorImpl< QualType > &Out, ArrayRef< QualType > X, ArrayRef< QualType > Y)
static bool matchesPostDecrInWhile(const UnaryOperator *UO, ASTContext &Ctx)
For the purposes of overflow pattern exclusion, does this match the while(i–) pattern?
static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx, raw_ostream &OS, QualType QT)
Encode a function type for use in the discriminator of a function pointer type.
static std::optional< int64_t > structSubobjectsHaveUniqueObjectRepresentations(const RangeT &Subobjects, int64_t CurOffsetInBits, const ASTContext &Context, const clang::ASTRecordLayout &Layout, bool CheckIfTriviallyCopyable)
static uint64_t getRVVTypeSize(ASTContext &Context, const BuiltinType *Ty)
getRVVTypeSize - Return RVV vector register size.
static auto unwrapSugar(SplitQualType &T, Qualifiers &QTotal)
static TemplateName getCommonTemplateNameChecked(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced)
static int compareObjCProtocolsByName(ObjCProtocolDecl *const *lhs, ObjCProtocolDecl *const *rhs)
Comparison routine for Objective-C protocols to be used with llvm::array_pod_sort.
static const TagDecl * getNonInjectedClassName(const TagDecl *TD)
static TypedefDecl * CreateZOSVaListDecl(const ASTContext *Context)
static bool hasAnyPackExpansions(ArrayRef< TemplateArgument > Args)
static char ObjCEncodingForEnumDecl(const ASTContext *C, const EnumDecl *ED)
static std::string charUnitsToString(CharUnits CU)
static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod, SmallVectorImpl< const NamedDecl * > &Redeclared)
static QualType getCommonTypeWithQualifierLifting(const ASTContext &Ctx, QualType X, QualType Y, Qualifiers &QX, Qualifiers &QY)
static auto getCommonTypes(const ASTContext &Ctx, ArrayRef< QualType > Xs, ArrayRef< QualType > Ys, bool Unqualified=false)
static bool isCanonicalResultType(QualType T)
Determine whether T is canonical as the result type of a function.
static TypedefDecl * CreateMSVaListDecl(const ASTContext *Context)
static bool areCompatVectorTypes(const VectorType *LHS, const VectorType *RHS)
areCompatVectorTypes - Return true if the two specified vector types are compatible.
static TypedefDecl * CreateCharPtrNamedVaListDecl(const ASTContext *Context, StringRef Name)
static NestedNameSpecifier getCommonQualifier(const ASTContext &Ctx, const T *X, const T *Y, bool IsSame)
#define UNEXPECTED_TYPE(Class, Kind)
static TypedefDecl * CreateVaListDecl(const ASTContext *Context, TargetInfo::BuiltinVaListKind Kind)
static bool primaryBaseHaseAddressDiscriminatedVTableAuthentication(const ASTContext &Context, const CXXRecordDecl *Class)
static std::vector< std::string > getFMVBackendFeaturesFor(const llvm::SmallVectorImpl< StringRef > &FMVFeatStrings)
Defines the clang::ASTContext interface.
#define BuiltinTemplate(BTName)
This file provides some common utility functions for processing Lambda related AST Constructs.
Provides definitions for the various language-specific address spaces.
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
Defines enum values for all the target-independent builtin functions.
static bool CanThrow(Expr *E, ASTContext &Ctx)
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static const Decl * getCanonicalDecl(const Decl *D)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
Defines the clang::Module class, which describes a module in the source code.
static StringRef getTriple(const Command &Job)
Defines types useful for describing an Objective-C runtime.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
static QualType getUnderlyingType(const SubRegion *R)
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
RawComment * getRawCommentNoCacheImpl(RawCommentLookupKey Key, const SourceLocation RepresentativeLoc, const std::map< unsigned, RawComment * > &CommentsInFile) const
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
bool isMemberPointerToDerivedMember() const
const ValueDecl * getMemberPointerDecl() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const
Returns true, if given type has a known lifetime.
MSGuidDecl * getMSGuidDecl(MSGuidDeclParts Parts) const
Return a declaration for the global GUID object representing the given GUID value.
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl, const ObjCMethodDecl *MethodImp)
CanQualType ObjCBuiltinSelTy
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
const llvm::StringMap< bool > & getFunctionFeatureMap(const FunctionDecl *FD) const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
void InitBuiltinTypes(const TargetInfo &Target, const TargetInfo *AuxTarget=nullptr)
Initialize built-in types.
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
CanQualType ARCUnbridgedCastTy
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, QualType Wrapped) const
llvm::DenseMap< const Decl *, comments::FullComment * > ParsedComments
Mapping from declarations to parsed comments attached to any redeclaration.
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
unsigned getIntWidth(QualType T) const
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
InlineVariableDefinitionKind
@ None
Not an inline variable.
@ Weak
Weak definition of inline variable.
@ Strong
Strong definition.
@ WeakUnknown
Weak for now, might become strong later in this TU.
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
TypedefDecl * getCFConstantStringDecl() const
CanQualType SatUnsignedFractTy
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns, std::optional< MatrixType::LayoutKind > Layout=std::nullopt) const
Return the unique reference to the matrix type of the specified element type and size.
ExternCContextDecl * getExternCContextDecl() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
CanQualType UnsignedShortAccumTy
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
QualType adjustFunctionResultType(QualType FunctionType, QualType NewResultType)
Change the result type of a function type, preserving sugar such as attributed types.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
QualType getCanonicalTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateName TypeConstraintConcept=TemplateName(), ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type.
bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool AllowCXX=false, bool IsConditionalOperator=false)
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
CharUnits getObjCEncodingTypeSize(QualType T) const
Return the size of type T for Objective-C encoding purpose, in characters.
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
const TemplateArgument * getDefaultTemplateArgumentOrNone(const NamedDecl *P) const
Return the default argument of a template parameter, if one exists.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
void setCurrentNamedModule(Module *M)
Set the (C++20) module we are building.
QualType getProcessIDType() const
Return the unique type for "pid_t" defined in <sys/types.h>.
CharUnits getMemberPointerPathAdjustment(const APValue &MP) const
Find the 'this' offset for the member path in a pointer-to-member APValue.
bool mayExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel may be externalized.
std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const
ArrayRef< CXXDefaultArgExpr * > getCtorClosureDefaultArgs(const CXXConstructorDecl *CD)
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
bool hasSameExpr(const Expr *X, const Expr *Y) const
Determine whether the given expressions X and Y are equivalent.
TemplateName getPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< TemplateName > Expansions={}) const
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
RawComment * getRawCommentNoCache(RawCommentLookupKey Key) const
Return the documentation comment attached to a given declaration or macro, without looking into cache...
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
unsigned getTypeUnadjustedAlign(QualType T) const
Return the ABI-specified natural alignment of a (complete) type T, before alignment adjustments,...
unsigned char getFixedPointIBits(QualType Ty) const
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes, bool OrNull, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
bool ObjCQualifiedClassTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS)
ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and Class<pr1, ...>.
bool shouldExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel should be externalized.
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type.
CanQualType SatLongAccumTy
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
OpenCLTypeKind getOpenCLTypeKind(const Type *T) const
Map an AST Type to an OpenCLTypeKind enum value.
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const
Put the string version of the type qualifiers QT into S.
unsigned getPreferredTypeAlign(QualType T) const
Return the "preferred" alignment of the specified type T for the current target, in bits.
std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, bool Extended=false) const
Emit the encoded type for the method declaration Decl into S.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
CanQualType OMPArrayShapingTy
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
std::string getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
getObjCEncodingForPropertyDecl - Return the encoded type for this method declaration.
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
unsigned getStaticLocalNumber(const VarDecl *VD) const
void addComment(const RawComment &RC)
void getLegacyIntegralTypeEncoding(QualType &t) const
getLegacyIntegralTypeEncoding - Another legacy compatibility encoding: 32-bit longs are encoded as 'l...
bool isSameTypeConstraint(const TypeConstraint *XTC, const TypeConstraint *YTC) const
Determine whether two type contraint are similar enough that they could used in declarations of the s...
void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo)
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=RecordDecl::TagKind::Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
void completeCountAttributedType(CountAttributedType *CATy, Expr *CountExpr, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
Supply the count expression and coupled declarations for a type created by getIncompleteCountAttribut...
CanQualType UnsignedLongFractTy
QualType mergeTagDefinitions(QualType, QualType)
void setClassMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
void setIsTypeAwareOperatorNewOrDelete(const FunctionDecl *FD, bool IsTypeAware)
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const
Return a dependent bit-precise integer type with the specified signedness and bit count.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
StringRef getCUIDHash() const
bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const
Returns true if this is an inline-initialized static data member which is treated as a definition for...
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const
Determine whether two function types are the same, ignoring exception specifications in cases where t...
QualType getBlockDescriptorExtendedType() const
Gets the struct used to keep track of the extended descriptor for pointer to blocks.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent) const
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
void addLazyModuleInitializers(Module *M, ArrayRef< GlobalDeclID > IDs)
bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
QualType getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
std::optional< QualType > tryMergeOverflowBehaviorTypes(QualType LHS, QualType RHS, bool OfBlockPointer, bool Unqualified, bool BlockReturnType, bool IsConditionalOperator)
Attempts to merge two types that may be OverflowBehaviorTypes.
CanQualType OMPIteratorTy
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
SelectorTable & Selectors
bool isTypeIgnoredBySanitizer(const SanitizerMask &Mask, const QualType &Ty) const
Check if a type can have its sanitizer instrumentation elided based on its presence within an ignorel...
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const
Return the minimum alignment as specified by the target.
RawCommentList Comments
All comments in this translation unit.
bool isSameDefaultTemplateArgument(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two default template arguments are similar enough that they may be used in declarat...
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType getLateParsedAttrType(QualType Wrapped, LateParsedTypeAttribute *LateParsedAttr) const
Return a placeholder type for a late-parsed type attribute.
QualType removePtrSizeAddrSpace(QualType T) const
Remove the existing address space on the type if it is a pointer size address space and return the ty...
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
llvm::ArrayRef< BitInterval > getPaddingIntervals(QualType Ty) const
CanQualType SatShortFractTy
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
bool canBindObjCObjectType(QualType To, QualType From)
TemplateTemplateParmDecl * insertCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *CanonTTP) const
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const
Compare the rank of two floating point types as above, but compare equal if both types have the same ...
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
void setParameterIndex(const ParmVarDecl *D, unsigned index)
Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
CanQualType getCanonicalSizeType() const
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl, StringRef MangledName)
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::SetVector< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
CanQualType ArraySectionTy
CanQualType ObjCBuiltinIdTy
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const
ObjCPropertyImplDecl * getObjCPropertyImplDeclForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
bool isNearlyEmpty(const CXXRecordDecl *RD) const
PointerAuthQualifier getObjCMemberSelTypePtrAuth()
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.
UsingEnumDecl * getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst)
If the given using-enum decl Inst is an instantiation of another using-enum decl, return it.
RecordDecl * getCFConstantStringTagDecl() const
std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const
Emit the encoded type for the function Decl into S.
TypeSourceInfo * getTemplateSpecializationTypeInfo(ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Canon=QualType()) const
CanQualType UnsignedFractTy
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
QualType mergeFunctionParameterTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeFunctionParameterTypes - merge two types which appear as function parameter types
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
TemplateTemplateParmDecl * findCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *TTP) const
const TargetInfo * getAuxTargetInfo() const
CanQualType ObjCBuiltinClassTy
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
CanQualType UnresolvedTemplateTy
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
friend class CXXRecordDecl
CanQualType UnsignedLongTy
llvm::DenseSet< const FunctionDecl * > CUDAImplicitHostDeviceFunUsedByDevice
Keep track of CUDA/HIP implicit host device functions used on device side in device compilation.
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized,...
bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits, unsigned NumPositiveBits, QualType &BestType, QualType &BestPromotionType)
Compute BestType and BestPromotionType for an enum based on the highest number of negative and positi...
llvm::APFixedPoint getFixedPointMin(QualType Ty) const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType adjustType(QualType OldType, llvm::function_ref< QualType(QualType)> Adjust) const
Rebuild a type, preserving any existing type sugar.
void addedLocalImportDecl(ImportDecl *Import)
Notify the AST context that a new import declaration has been parsed or implicitly created within thi...
const TranslationUnitKind TUKind
CanQualType UnsignedLongAccumTy
QualType AutoRRefDeductTy
RawComment * getRawCommentNoCacheImpl(RawCommentLookupKey Key, const SourceLocation RepresentativeLoc, const std::map< unsigned, RawComment * > &CommentsInFile) const
CountAttributedType * getIncompleteCountAttributedType(QualType WrappedTy, bool CountInBytes, bool OrNull) const
Return a CountAttributedType whose count expression has not been parsed yet, for use by a late-parsed...
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length.
QualType getCorrespondingSaturatedType(QualType Ty) const
bool arePFPFieldsTriviallyCopyable(const RecordDecl *RD) const
Returns whether this record's PFP fields (if any) are trivially copyable (i.e.
bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const
Determine whether the two declarations refer to the same entity.
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl, unsigned Index, bool Final, const TemplateArgument &ArgPack)
CanQualType BoundMemberTy
CanQualType SatUnsignedShortFractTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
bool hasSameFunctionTypeIgnoringParamABI(QualType T, QualType U) const
Determine if two function types are the same, ignoring parameter ABI annotations.
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
unsigned getOpenMPDefaultSimdAlign(QualType T) const
Get default simd alignment of the specified complete type in bits.
QualType getObjCSuperType() const
Returns the C struct type for objc_super.
QualType getBlockDescriptorType() const
Gets the struct used to keep track of the descriptor for pointer to blocks.
bool CommentsLoaded
True if comments are already loaded from ExternalASTSource.
BlockVarCopyInit getBlockVarCopyInit(const VarDecl *VD) const
Get the copy initialization expression of the VarDecl VD, or nullptr if none exists.
QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size, uint32_t Alignment, ArrayRef< SpirvOperand > Operands)
unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
bool isInSameModule(const Module *M1, const Module *M2) const
If the two module M1 and M2 are in the same module.
unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
QualType getLeastIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
CanQualType PseudoObjectTy
QualType getWebAssemblyExternrefType() const
Return a WebAssembly externref type.
void setTraversalScope(const std::vector< Decl * > &)
CharUnits getTypeUnadjustedAlignInChars(QualType T) const
getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, in characters,...
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
friend class NestedNameSpecifier
MangleContext * cudaNVInitDeviceMC()
unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const
Return the alignment in bits that should be given to a global variable with type T.
bool areCompatibleOverflowBehaviorTypes(QualType LHS, QualType RHS)
Return true if two OverflowBehaviorTypes are compatible for assignment.
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
MangleContext * createDeviceMangleContext(const TargetInfo &T)
Creates a device mangle context to correctly mangle lambdas in a mixed architecture compile by settin...
CharUnits getExnObjectAlignment() const
Return the alignment (in bytes) of the thrown exception object.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ASTMutationListener * Listener
CanQualType ObjCBuiltinBoolTy
TypeInfoChars getTypeInfoInChars(const Type *T) const
QualType getPredefinedSugarType(PredefinedSugarType::Kind KD) const
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
TemplateParamObjectDecl * getTemplateParamObjectDecl(QualType T, const APValue &V) const
Return the template parameter object of the given type with the given value.
interp::Context & getInterpContext() const
Returns the clang bytecode interpreter context.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
TemplateTemplateParmDecl * getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const
Canonicalize the given TemplateTemplateParmDecl.
CanQualType OCLClkEventTy
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
bool hasPFPFields(QualType Ty) const
const clang::PrintingPolicy & getPrintingPolicy() const
void ResetObjCLayout(const ObjCInterfaceDecl *D)
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
void setCtorClosureDefaultArgs(const CXXConstructorDecl *CD, ArrayRef< CXXDefaultArgExpr * > Args)
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
CharUnits getAlignOfGlobalVarInChars(QualType T, const VarDecl *VD) const
Return the alignment in characters that should be given to a global variable with type T.
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists.
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, UnsignedOrNone Index=std::nullopt) const
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getObjCIdType() const
Represents the Objective-CC id type.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
QualType getFunctionTypeWithoutParamABIs(QualType T) const
Get or construct a function type that is equivalent to the input type except that the parameter ABI a...
QualType getCorrespondingUnsaturatedType(QualType Ty) const
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl) const
unsigned getTargetDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
llvm::DenseMap< CanQualType, SYCLKernelInfo > SYCLKernels
Map of SYCL kernels indexed by the unique type used to name the kernel.
bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y) const
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
bool isDestroyingOperatorDelete(const FunctionDecl *FD) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
CanQualType UnsignedCharTy
CanQualType UnsignedShortFractTy
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
void * Allocate(size_t Size, unsigned Align=8) const
ArrayRef< ExplicitInstantiationDecl * > getExplicitInstantiationDecls(const NamedDecl *Spec) const
Get all ExplicitInstantiationDecls for a given specialization.
bool canBuiltinBeRedeclared(const FunctionDecl *) const
Return whether a declaration to a builtin is allowed to be overloaded/redeclared.
CanQualType UnsignedIntTy
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols) const
void getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT, QualType T, std::string &S, bool Extended) const
getObjCEncodingForMethodParameter - Return the encoded type for a single method parameter or return t...
static bool isPFPField(const FieldDecl *Field)
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const
Return the encoded type for this block declaration.
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
bool isSameAssociatedConstraint(const AssociatedConstraint &ACX, const AssociatedConstraint &ACY) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
QualType getExceptionObjectType(QualType T) const
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Note that the static data member Inst is an instantiation of the static data member template Tmpl of ...
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl)
ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's protocol list adopt all protocols in Q...
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType OCLReserveIDTy
bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two template parameters are similar enough that they may be used in declarations of...
void registerSYCLEntryPointFunction(FunctionDecl *FD)
Generates and stores SYCL kernel metadata for the provided SYCL kernel entry point function.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
CanQualType UnsignedShortTy
FunctionDecl * getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
AttrVec * allocateAttrVec()
Allocate an empty attribute vector with the lifetime of this context.
unsigned getTypeAlignIfKnown(QualType T, bool NeedsPreferredAlignment=false) const
Return the alignment of a type, in bits, or 0 if the type is incomplete and we cannot determine the a...
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may both be array types with the same bound (or both be array types ...
bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
llvm::DenseMap< RawCommentLookupKey, const RawComment * > RawComments
Mapping from declaration or macro to directly attached comment.
const SYCLKernelInfo & getSYCLKernelInfo(QualType T) const
Given a type used as a SYCL kernel name, returns a reference to the metadata generated from the corre...
bool canAssignObjCInterfacesInBlockPointer(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, bool BlockReturnType)
canAssignObjCInterfacesInBlockPointer - This routine is specifically written for providing type-safet...
CanQualType SatUnsignedLongFractTy
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
CanQualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
const ObjCInterfaceDecl * getObjContainingInterface(const NamedDecl *ND) const
Returns the Objective-C interface that ND belongs to if it is an Objective-C method/property/ivar etc...
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
CanQualType getCanonicalUnresolvedUsingType(const UnresolvedUsingTypenameDecl *D) const
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
llvm::APFixedPoint getFixedPointMax(QualType Ty) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool classMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
QualType getTemplateTypeParmType(int Depth, int Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
void deduplicateMergedDefinitionsFor(NamedDecl *ND)
Clean up the merged definition list.
static uint64_t getConstantArrayElementCount(const ConstantArrayType *CA)
Return number of (potentially nested) constant array elements.
DiagnosticsEngine & getDiagnostics() const
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void recordOffsetOfEvaluation(const OffsetOfExpr *E)
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
QualType getUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D) const
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
void getOverriddenMethods(const NamedDecl *Method, SmallVectorImpl< const NamedDecl * > &Overridden) const
Return C++ or ObjC overridden methods for the given Method.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y, bool IgnoreDeduced=false) const
Determine whether the given template names refer to the same template.
CanQualType SatLongFractTy
const TargetInfo & getTargetInfo() const
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
OBTAssignResult checkOBTAssignmentCompatibility(QualType LHS, QualType RHS)
Check overflow behavior type compatibility for assignments.
CanQualType SatShortAccumTy
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
static uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE)
Return number of elements initialized in a (potentially nested) ArrayInitLoopExpr.
void addExplicitInstantiationDecl(const NamedDecl *Spec, ExplicitInstantiationDecl *EID)
Add an ExplicitInstantiationDecl for a given specialization.
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
CanQualType IncompleteMatrixIdxTy
CanQualType getNSIntegerType() const
QualType getCorrespondingUnsignedType(QualType T) const
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
bool shouldEmitCUDADecl(const ValueDecl *D) const
Determines if the global variable or function D is emitted on the side of the CUDA/HIP compilation,...
TargetCXXABI::Kind getCXXABIKind() const
Return the C++ ABI kind that should be used.
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
CanQualType SatUnsignedLongAccumTy
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
CanQualType getCanonicalTagType(const TagDecl *TD) const
bool isSameTemplateArgument(const TemplateArgument &Arg1, const TemplateArgument &Arg2) const
Determine whether the given template arguments Arg1 and Arg2 are equivalent.
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getCorrespondingSignedType(QualType T) const
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
llvm::DenseMap< const Decl *, const Decl * > CommentlessRedeclChains
Keeps track of redeclaration chains that don't have any comment attached.
unsigned getTargetAddressSpace(LangAS AS) const
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
std::vector< PFPField > findPFPFields(QualType Ty) const
Returns a list of PFP fields for the given type, including subfields in bases or other fields,...
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
void addTranslationUnitDecl()
void getObjCEncodingForPropertyType(QualType T, std::string &S) const
Emit the Objective-C property type encoding for the given type T into S.
unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
CollectInheritedProtocols - Collect all protocols in current class and those inherited by it.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
llvm::DenseMap< const Decl *, const Decl * > RedeclChainComments
Mapping from canonical declaration to the first redeclaration in chain that has a comment attached.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
std::optional< CXXRecordDeclRelocationInfo > getRelocationInfoForCXXRecord(const CXXRecordDecl *) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
InlineVariableDefinitionKind getInlineVariableDefinitionKind(const VarDecl *VD) const
Determine whether a definition of this inline variable should be treated as a weak or strong definiti...
const RawComment * getRawCommentForAnyRedecl(RawCommentLookupKey Key, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration or macro.
TemplateName getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
CanQualType getUIntMaxType() const
Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in <stdint.h>.
CharUnits getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const
Loading virtual member pointers using the virtual inheritance model always results in an adjustment u...
LangAS getLangASForBuiltinAddressSpace(unsigned AS) const
bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U)
Determine whether two function types are the same, ignoring pointer sizes in the return type and para...
void addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, FunctionDecl *OperatorDelete, OperatorDeleteKind K) const
unsigned char getFixedPointScale(QualType Ty) const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
QualType DecodeTypeStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequireICE, bool AllowTypeModifiers) const
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
@ GE_Missing_type
Missing a type.
QualType adjustStringLiteralBaseType(QualType StrLTy) const
uint16_t getPointerAuthTypeDiscriminator(QualType T)
Return the "other" type-specific discriminator for the given type.
llvm::SetVector< const FieldDecl * > PFPFieldsWithEvaluatedOffset
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD, bool IsVTTEntry)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers using the ...
bool canonicalizeTemplateArguments(MutableArrayRef< TemplateArgument > Args) const
Canonicalize the given template argument list.
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
QualType getMatrixTypeWithLayout(QualType T, MatrixType::LayoutKind Layout) const
bool isUnaryOverflowPatternExcluded(const UnaryOperator *UO)
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
TemplateName getDeducedTemplateName(TemplateName Underlying, DefaultArguments DefaultArgs) const
Represents a TemplateName which had some of its default arguments deduced.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
CanQualType UnsignedAccumTy
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
void cacheRawComment(RawCommentLookupKey Original, const RawComment &Comment) const
Attaches Comment to Original (a declaration or macro), and to its redeclaration chain when Original i...
QualType getVariableArrayDecayedType(QualType Ty) const
Returns a vla type where known sizes are replaced with [*].
void setCFConstantStringType(QualType T)
const SYCLKernelInfo * findSYCLKernelInfo(QualType T) const
Returns a pointer to the metadata generated from the corresponding SYCLkernel entry point if the prov...
unsigned getParameterIndex(const ParmVarDecl *D) const
Used by ParmVarDecl to retrieve on the side the index of the parameter when it exceeds the size of th...
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false) const
void AddDeallocation(void(*Callback)(void *), void *Data) const
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
QualType getDeducedTemplateSpecializationType(DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword, TemplateName Template) const
C++17 deduced class template specialization type.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
QualType mergeTransparentUnionType(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeTransparentUnionType - if T is a transparent union type and a member of T is compatible with Sub...
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
bool isSentinelNullExpr(const Expr *E)
CanQualType getNSUIntegerType() const
void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying)
TypedefDecl * getBuiltinZOSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_zos_va_list type.
void recordMemberDataPointerEvaluation(const ValueDecl *VD)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
virtual ~ASTMutationListener()
virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType)
A function's return type has been deduced.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool hasOwnVFPtr() const
hasOwnVFPtr - Does this class provide its own virtual-function table pointer, rather than inheriting ...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
bool hasOwnVBPtr() const
hasOwnVBPtr - Does this class provide its own virtual-base table pointer, rather than inheriting one ...
CharUnits getSize() const
getSize - Get the record size in characters.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding,...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
CharUnits getUnadjustedAlignment() const
getUnadjustedAlignment - Get the record alignment in characters, before alignment adjustment.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Represents a loop initializing the elements of an array.
llvm::APInt getArraySize() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
A structure for storing the information associated with a name that has been assumed to be a template...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Attr - This represents one attribute.
attr::Kind getKind() const
A fixed int type of a specified bitwidth.
unsigned getNumBits() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
This class is used for builtin types like 'int'.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Implements C++ ABI-specific semantic analysis functions.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
CXXRecordDecl * getDefinition() const
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isDynamicClass() const
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
SplitQualType split() const
static CanQual< Type > CreateUnsafe(QualType Other)
QualType withConst() const
Retrieves a version of this type with const applied.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
This is an opaque type for sizes expressed in character units.
bool isPositive() const
Test whether the quantity is greater than zero.
bool isZero() const
Test whether the quantity equals zero.
CharUnits alignTo(CharUnits Align) const
Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is a multiple...
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static constexpr CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
static CharUnits Zero()
Construct a CharUnits quantity of zero.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Represents the canonical version of C arrays with a specified constant size.
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
void Profile(llvm::FoldingSetNodeID &ID)
unsigned getNumRows() const
Returns the number of rows in the matrix.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Decl::Kind getDeclKind() const
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isModuleLocal() const
Whether this declaration was a local declaration to a C++20 named module.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl,...
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
static Decl * castFromDeclContext(const DeclContext *)
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setImplicit(bool I=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
DeclarationNameLoc - Additional source/type location info for a declaration name.
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc, SourceLocation EndLoc)
Construct location information for a non-literal C++ operator.
The name of a declaration.
static int compare(DeclarationName LHS, DeclarationName RHS)
Represents a ValueDecl that came out of a declarator.
TypeSourceInfo * getTypeSourceInfo() const
TemplateName getUnderlying() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
DefaultArguments getDefaultArguments() const
Represents an extended address space qualifier where the input address space value is dependent.
Expr * getAddrSpaceExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents an array type in C++ whose size is a value-dependent expression.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Expr * getSizeExpr() const
Represents an extended vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Expr * getRowExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a dependent template name that cannot be resolved prior to template instantiation.
void Profile(llvm::FoldingSetNodeID &ID) const
IdentifierOrOverloadedOperator getName() const
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
bool hasTemplateKeyword() const
Was this template name was preceeded by the template keyword?
Internal representation of canonical, dependent typeof(expr) types.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
A dynamically typed AST node container.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
bool isComplete() const
Returns true if this can be considered a complete type.
EnumDecl * getDefinitionOrSelf() const
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Represents an explicit instantiation of a template entity in source code.
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
We can encode up to four bits in the low bits of a type pointer, but there are many more type qualifi...
void Profile(llvm::FoldingSetNodeID &ID) const
ExtVectorType - Extended vector type.
Declaration context for names declared as extern "C" in C++.
static ExternCContextDecl * Create(const ASTContext &C, TranslationUnitDecl *TU)
Abstract interface for external sources of AST nodes.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
unsigned getBitWidthValue() const
Computes the bit width of this field, if this is a bit field.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool isMSExternInline() const
The combination of the extern and inline keywords under MSVC forces the function to be required.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
FunctionDecl * getDefinition()
Get the definition for this declaration.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
bool isInlineDefinitionExternallyVisible() const
For an inline function definition in C, or for a gnu_inline function in C++, determine whether the de...
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
SmallVector< Conflict > Conflicts
static FunctionEffectSet getIntersection(FunctionEffectsRef LHS, FunctionEffectsRef RHS)
static FunctionEffectSet getUnion(FunctionEffectsRef LHS, FunctionEffectsRef RHS, Conflicts &Errs)
An immutable set of FunctionEffects and possibly conditions attached to them.
ArrayRef< EffectConditionExpr > conditions() const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
void Profile(llvm::FoldingSetNodeID &ID)
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
QualType getParamType(unsigned i) const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
CallingConv getCC() const
bool getNoCfCheck() const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
ExtInfo withNoReturn(bool noReturn) const
bool getHasRegParm() const
bool getProducesResult() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
ExtParameterInfo withIsNoEscape(bool NoEscape) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
QualType getReturnType() const
GlobalDecl - represents a global declaration.
unsigned getMultiVersionIndex() const
CXXDtorType getDtorType() const
const Decl * getDecl() const
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
StringRef getName() const
Return the actual identifier string.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Represents a C array with an unspecified size.
void Profile(llvm::FoldingSetNodeID &ID)
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
An lvalue reference type, per C++11 [dcl.ref].
@ Swift
Interoperability with the latest known version of the Swift runtime.
@ Swift4_2
Interoperability with the Swift 4.2 runtime.
@ Swift4_1
Interoperability with the Swift 4.1 runtime.
@ Integer
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
@ All
Permit vector bitcasts between all vectors with the same total bit-width.
@ PostDecrInWhile
while (count–)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::optional< TargetCXXABI::Kind > CXXABI
C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
clang::ObjCRuntime ObjCRuntime
CoreFoundationABI CFRuntime
bool isOverflowPatternExcluded(OverflowPatternExclusionKind Kind) const
Represents a placeholder type for late-parsed type attributes.
static void Profile(llvm::FoldingSetNodeID &ID, Parts P)
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
static bool isValidElementType(QualType T, const LangOptions &LangOpts)
Valid elements types are the following:
QualType getElementType() const
Returns type of the elements being stored in the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
void Profile(llvm::FoldingSetNodeID &ID)
Provides information a specialization of a member of a class template, which may be a member function...
static MicrosoftMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
Describes a module or submodule.
bool isNamedModule() const
Does this Module is a named module of a standard named module?
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isPlaceholderVar(const LangOptions &LangOpts) const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
bool isExternallyVisible() const
Represent a C++ namespace.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested)
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NestedNameSpecifier getCanonical() const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
CXXRecordDecl * getAsMicrosoftSuper() const
NamespaceAndPrefix getAsNamespaceAndPrefix() const
const Type * getAsType() const
Kind
The kind of specifier that completes this nested name specifier.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, int D, int P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
ObjCCategoryDecl - Represents a category declaration.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, const IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
bool hasDefinition() const
Determine whether this class has been defined.
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class,...
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
ObjCImplementationDecl * getImplementation() const
ObjCInterfaceDecl * getSuperClass() const
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
known_extensions_range known_extensions() const
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCIvarDecl * getNextIvar()
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCDeclQualifier getObjCDeclQualifier() const
unsigned param_size() const
param_const_iterator param_end() const
param_const_iterator param_begin() const
const ParmVarDecl *const * param_const_iterator
Selector getSelector() const
bool isInstanceMethod() const
QualType getReturnType() const
Represents a pointer to an Objective C object.
bool isObjCQualifiedClassType() const
True if this is equivalent to 'Class.
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
Represents one property declaration in an Objective-C interface.
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
SetterKind getSetterKind() const
getSetterKind - Return the method used for doing assignment in the property setter.
Selector getSetterName() const
Selector getGetterName() const
ObjCPropertyAttribute::Kind getPropertyAttributes() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
ObjCIvarDecl * getPropertyIvarDecl() const
Represents an Objective-C protocol declaration.
protocol_range protocols() const
bool isGNUFamily() const
Is this runtime basically of the GNU family of runtimes?
Represents the declaration of an Objective-C type parameter.
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
const OffsetOfNode & getComponent(unsigned Idx) const
unsigned getNumComponents() const
Helper class for OffsetOfExpr.
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
A structure for storing a pack-index-template-name ([temp.names]).
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
bool isFullySubstituted() const
TemplateName getPattern() const
Expr * getIndexExpr() const
ArrayRef< TemplateName > getExpansions() const
Sugar for parentheses used when specifying types.
void clear()
Clear parent maps.
DynTypedNodeList getParents(const NodeT &Node)
Returns the parents of the given node (within the traversal scope).
Represents a parameter to a function.
ObjCDeclQualifier getObjCDeclQualifier() const
QualType getOriginalType() const
ParsedAttr - Represents a syntactic attribute.
Pointer-authentication qualifiers.
static PointerAuthQualifier Create(unsigned Key, bool IsAddressDiscriminated, unsigned ExtraDiscriminator, PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer, bool AuthenticatesNullValues)
bool isEquivalent(PointerAuthQualifier Other) const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A (possibly-)qualified type.
bool hasAddressDiscriminatedPointerAuth() const
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
Qualifiers::GC getObjCGCAttr() const
Returns gc attribute of this type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
QualType withConst() const
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
bool isConstQualified() const
Determine whether this type is const-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
const Type * getTypePtrOrNull() const
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Represents a template name as written in source code.
void Profile(llvm::FoldingSetNodeID &ID)
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void removeCVRQualifiers(unsigned mask)
void addAddressSpace(LangAS space)
static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
Returns the common set of qualifiers while removing them from the given sets.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
void removeFastQualifiers(unsigned mask)
bool hasUnaligned() const
bool hasAddressSpace() const
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
unsigned getFastQualifiers() const
void removeAddressSpace()
PointerAuthQualifier getPointerAuth() const
bool hasObjCGCAttr() const
uint64_t getAsOpaqueValue() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCGCAttr() const
void addObjCGCAttr(GC type)
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
bool hasFlexibleArrayMember() const
field_range fields() const
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
RecordDecl * getMostRecentDecl()
virtual void completeDefinition()
Note that the definition of this type is now complete.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
This table allows us to fully hide how we implement multi-keyword caching.
std::string getAsString() const
Derive the full selector name (e.g.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
StringLiteral - This represents a string literal expression, e.g.
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
A structure for storing an already-substituted template template parameter pack.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context)
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
A structure for storing the information associated with a substituted template template parameter.
void Profile(llvm::FoldingSetNodeID &ID)
TemplateTemplateParmDecl * getParameter() const
Represents the declaration of a struct/union/class/enum.
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TagKind getTagKind() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Kind
The basic C++ ABI kind.
static Kind getKind(StringRef Name)
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
unsigned getMaxAtomicInlineWidth() const
Return the maximum width lock-free atomic operation which can be inlined given the supported features...
virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
unsigned getDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
@ AArch64ABIBuiltinVaList
__builtin_va_list as defined by the AArch64 ABI http://infocenter.arm.com/help/topic/com....
@ PowerABIBuiltinVaList
__builtin_va_list as defined by the Power ABI: https://www.power.org /resources/downloads/Power-Arch-...
@ AAPCSABIBuiltinVaList
__builtin_va_list as defined by ARM AAPCS ABI http://infocenter.arm.com
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
@ X86_64ABIBuiltinVaList
__builtin_va_list as defined by the x86-64 ABI: http://refspecs.linuxbase.org/elf/x86_64-abi-0....
virtual uint64_t getNullPointerValue(LangAS AddrSpace) const
Get integer value for null pointer.
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
IntType getPtrDiffType(LangAS AddrSpace) const
bool isLittleEndian() const
IntType getSizeType() const
FloatModeKind getRealTypeByWidth(unsigned BitWidth, FloatModeKind ExplicitType) const
Return floating point type with specified width.
virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return integer type with specified width.
unsigned getMaxAlignedAttribute() const
Get the maximum alignment in bits for a static variable with aligned attribute.
virtual unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
unsigned getTargetAddressSpace(LangAS AS) const
IntType getSignedSizeType() const
const llvm::fltSemantics & getLongDoubleFormat() const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool useAddressSpaceMapMangling() const
Specify if mangling based on address space map should be used or not for language specific address sp...
A convenient class for passing around template argument information.
ArrayRef< TemplateArgumentLoc > arguments() const
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
UnsignedOrNone getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DeducedTemplateStorage * getAsDeducedTemplateName() const
Retrieve the deduced template info, if any.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
std::optional< TemplateName > desugar(bool IgnoreDeduced) const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ PackIndexingTemplate
A pack-index-template-name.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
PackIndexingTemplateStorage * getAsPackIndexingTemplate() const
Retrieve the pack-index-template-name storage, if any.
A template parameter object.
static void Profile(llvm::FoldingSetNodeID &ID, QualType T, const APValue &V)
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
ArrayRef< NamedDecl * > asArray()
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TemplateNameKind templateParameterKind() const
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, int D, int P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
unsigned getDepth() const
Get the nesting depth of the template parameter.
Declaration of a template type parameter.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, int D, int P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
Token - This structure provides full information about a lexed token.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
TemplateName getNamedConcept() const
ConceptReference * getConceptReference() const
Represents a declaration of a type.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location.
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
The base class of the type hierarchy.
bool isBlockPointerType() const
bool isObjCBuiltinType() const
bool isPackedVectorBoolType(const ASTContext &ctx) const
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isFloat16Type() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
bool isPointerType() const
TagDecl * castAsTagDecl() const
bool isArrayParameterType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isSignedFixedPointType() const
Return true if this is a fixed point type that is signed according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isEnumeralType() const
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isSaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
QualType getCanonicalTypeInternal() const
@ PtrdiffT
The "ptrdiff_t" type.
@ SizeT
The "size_t" type.
@ SignedSizeT
The signed integer type corresponding to "size_t".
bool isObjCIdType() const
bool isOverflowBehaviorType() const
bool isUnsaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isUnsignedFixedPointType() const
Return true if this is a fixed point type that is unsigned according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isVectorType() const
bool isObjCClassType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isRecordType() const
bool isObjCRetainableType() const
NullabilityKindOrNone getNullability() const
Determine the nullability of the given type.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType Underlying)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
static void Profile(llvm::FoldingSetNodeID &ID, QualType Ty, const APValue &APVal)
The iterator over UnresolvedSets.
Represents the dependent type named by a dependently-scoped typename using declaration,...
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D)
Represents a dependent using declaration which was marked with typename.
UnresolvedUsingTypenameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Represents a C++ using-enum-declaration.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
bool isStaticDataMember() const
Determines whether this is a static data member.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
bool isInline() const
Whether this variable is (C++1z) inline.
@ DeclarationOnly
This declaration is only a declaration.
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
void Profile(llvm::FoldingSetNodeID &ID)
VectorKind getVectorKind() const
QualType getElementType() const
Holds all information required to evaluate constexpr code in a module.
Defines the Linkage enumeration and various utility functions.
Defines the clang::TargetInfo interface.
mlir::Type getBaseType(mlir::Value varPtr)
const AstTypeMatcher< TagType > tagType
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
GVALinkage
A more specific kind of linkage than enum Linkage.
@ GVA_AvailableExternally
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
OpenCLTypeKind
OpenCL type kinds.
bool isRVVFixedLengthDataVectorKind(VectorKind VK)
True if VK is one of the RVV fixed-length data vector kinds, i.e.
constexpr llvm::StringLiteral VTTVTablePointerDiscriminatorSuffix
FunctionType::ExtInfo getFunctionExtInfo(const Type &t)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
@ ICIS_NoInit
No in-class initializer.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
std::pair< FileID, unsigned > FileIDAndOffset
CXXABI * CreateMicrosoftCXXABI(ASTContext &Ctx)
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
TypeOfKind
The kind of 'typeof' expression we're after.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
unsigned getRVVFixedLengthMaskRatioLog2(VectorKind VK)
Return log2 of the R of the vbool<R>_t type recorded in an RVV fixed-length mask vector kind: Ratio1 ...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool isRVVFixedLengthVectorKind(VectorKind VK)
True if VK is one of the RVV fixed-length data or mask vector kinds.
CXXABI * CreateItaniumCXXABI(ASTContext &Ctx)
Creates an instance of a C++ ABI class.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
constexpr uint16_t SelPointerConstantDiscriminator
Constant discriminator to be used with objective-c sel pointers.
bool isDiscardableGVALinkage(GVALinkage L)
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
@ Keyword
The name has been typo-corrected to a keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
TranslationUnitKind
Describes the kind of translation unit being processed.
@ Deduced
The normal deduced case.
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
const Decl & adjustDeclToTemplate(const Decl &D)
If we have a 'templated' declaration for a template, adjust 'D' to refer to the actual template.
bool isPtrSizeAddressSpace(LangAS AS)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ Invariant
The parameter is invariant: must match exactly.
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
@ AltiVecBool
is AltiVec 'vector bool ...'
@ SveFixedLengthData
is AArch64 SVE fixed-length data vector
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ Generic
not a target-specific vector type
@ SveFixedLengthPredicate
is AArch64 SVE fixed-length predicate vector
U cast(CodeGen::Address addr)
LangAS getLangASFromTargetAS(unsigned TargetAS)
@ ResistPragmaPack
The type's natural alignment is preserved under pragma pack in MSVC record layout (e....
@ None
The alignment was not explicit in code.
@ RequiredByEnum
The alignment comes from an alignment attribute on a enum type.
@ RequiredByTypedef
The alignment comes from an alignment attribute on a typedef.
@ RequiredByRecord
The alignment comes from an alignment attribute on a record type.
@ PackIndex
Index of a pack indexing expression or specifier.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
bool isRVVFixedLengthMaskVectorKind(VectorKind VK)
True if VK is one of the RVV fixed-length mask vector kinds, i.e.
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t int64_t
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
const Expr * ConstraintExpr
UnsignedOrNone ArgPackSubstIndex
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Expr * getCopyExpr() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
ArrayRef< TemplateArgument > Args
Holds information about the various types of exception specification.
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
bool requiresFunctionProtoTypeArmAttributes() const
FunctionEffectsRef FunctionEffects
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
bool requiresFunctionProtoTypeExtraAttributeInfo() const
unsigned HasTrailingReturn
bool requiresFunctionProtoTypeExtraBitfields() const
FunctionType::ExtInfo ExtInfo
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
A late-parsed attribute that will be applied as a type attribute.
constexpr underlying_type toInternalRepresentation() const
Contains information gathered from parsing the contents of TargetAttr.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
Store declaration pairs already found to be non-equivalent.
bool IsEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
A this pointer adjustment.
IntType
===-— Target Data Type Query Methods ----------------------------—===//
AlignRequirementKind AlignRequirement
AlignRequirementKind AlignRequirement