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/Triple.h"
107using namespace clang;
125 if (
const auto *MI = dyn_cast<const MacroInfo *>(Key)) {
139 StringRef Buffer = SourceMgr.getBufferData(Decomposed.first, &
Invalid);
142 unsigned Offset = Decomposed.second;
143 if (
size_t Found = Buffer.find_last_of(
"#\n", Offset);
144 Found != StringRef::npos)
146 return {SourceMgr.getLocForStartOfFile(Decomposed.first)
147 .getLocWithOffset(Offset)};
158 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
163 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
164 if (VD->isStaticDataMember() &&
169 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(D)) {
174 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
181 if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
185 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
188 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
215 BaseLocation = D->getBeginLoc();
217 BaseLocation = D->getLocation();
219 if (!D->getLocation().isMacroID()) {
220 Locations.emplace_back(BaseLocation);
222 const auto *DeclCtx = D->getDeclContext();
233 Locations.emplace_back(SourceMgr.getExpansionLoc(BaseLocation));
240 Locations.emplace_back(SourceMgr.getSpellingLoc(D->getBeginLoc()));
248 const std::map<unsigned, RawComment *> &CommentsInTheFile)
const {
255 if (CommentsInTheFile.empty())
258 const auto *D = dyn_cast<const Decl *>(Key);
264 SourceMgr.getDecomposedLoc(RepresentativeLoc);
267 auto OffsetCommentBehindDecl =
268 CommentsInTheFile.lower_bound(LocDecomp.second);
271 if (OffsetCommentBehindDecl != CommentsInTheFile.end()) {
272 RawComment *CommentBehindDecl = OffsetCommentBehindDecl->second;
274 LangOpts.CommentOpts.ParseAllComments) &&
282 if (SourceMgr.getLineNumber(LocDecomp.first, LocDecomp.second) ==
283 Comments.getCommentBeginLine(CommentBehindDecl, LocDecomp.first,
284 OffsetCommentBehindDecl->first)) {
285 return CommentBehindDecl;
292 if (OffsetCommentBehindDecl == CommentsInTheFile.begin())
295 auto OffsetCommentBeforeDecl = --OffsetCommentBehindDecl;
296 RawComment *CommentBeforeDecl = OffsetCommentBeforeDecl->second;
300 LangOpts.CommentOpts.ParseAllComments) ||
305 const unsigned CommentEndOffset =
306 Comments.getCommentEndOffset(CommentBeforeDecl);
311 SourceMgr.getBufferData(LocDecomp.first, &
Invalid).data();
316 StringRef
Text(Buffer + CommentEndOffset,
317 LocDecomp.second - CommentEndOffset);
321 if (
Text.find_last_of(
";{}#@") != StringRef::npos)
324 return CommentBeforeDecl;
330 for (
const auto Loc : Locs) {
333 if (Loc.isInvalid() || !Loc.isFileID())
344 const FileID File = SourceMgr.getDecomposedLoc(Loc).first;
348 const auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
349 if (!CommentsInThisFile || CommentsInThisFile->empty())
361 assert(LangOpts.CommentOpts.RetainCommentsFromSystemHeaders ||
363 Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
368 const Decl **OriginalDecl)
const {
371 *OriginalDecl =
nullptr;
377 if (
const auto *MI = dyn_cast<const MacroInfo *>(Key)) {
379 *OriginalDecl =
nullptr;
382 return Existing->second;
399 return DeclComment->second;
412 *OriginalDecl = RedeclComment->second;
413 auto CommentAtRedecl =
RawComments.find(RedeclComment->second);
415 "This decl is supposed to have comment attached.");
416 return CommentAtRedecl->second;
421 const Decl *LastCheckedRedecl = [&]() {
423 bool CanUseCommentlessCache =
false;
425 for (
auto *Redecl : CanonicalD->
redecls()) {
427 CanUseCommentlessCache =
true;
430 if (Redecl == LastChecked)
437 return CanUseCommentlessCache ? LastChecked :
nullptr;
443 if (LastCheckedRedecl) {
444 if (LastCheckedRedecl == Redecl) {
445 LastCheckedRedecl =
nullptr;
453 *OriginalDecl = Redecl;
454 return RedeclComment;
460 *OriginalDecl =
nullptr;
466 assert(Comment.
isDocumentation() || LangOpts.CommentOpts.ParseAllComments);
468 if (
const auto *D = dyn_cast<const Decl *>(Original)) {
478 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(DC)) {
483 for (
const auto *Ext : ID->known_extensions()) {
487 Redeclared.push_back(RedeclaredMethod);
494 if (
Comments.empty() || Decls.empty())
498 for (
const Decl *D : Decls) {
499 if (D->isInvalidDecl())
507 File = SourceMgr.getDecomposedLoc(Loc).first;
512 if (
File.isInvalid())
515 auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
516 if (!CommentsInThisFile || CommentsInThisFile->empty() ||
517 CommentsInThisFile->rbegin()->second->isAttached())
527 for (
const Decl *D : Decls) {
529 if (D->isInvalidDecl())
539 for (
const auto DeclLoc : DeclLocs) {
540 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
555 const Decl *D)
const {
558 ThisDeclInfo->IsFilled =
false;
559 ThisDeclInfo->fill();
560 ThisDeclInfo->CommentDecl = FC->
getDecl();
561 if (!ThisDeclInfo->TemplateParameters)
571 return RC ? RC->
parse(*
this,
nullptr, D) :
nullptr;
582 llvm::DenseMap<const Decl *, comments::FullComment *>::iterator Pos =
586 if (Canonical != D) {
594 const Decl *OriginalDecl =
nullptr;
600 const auto *OMD = dyn_cast<ObjCMethodDecl>(D);
601 if (OMD && OMD->isPropertyAccessor())
608 for (
unsigned i = 0, e = Overridden.size(); i < e; i++)
612 else if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
615 QualType QT = TD->getUnderlyingType();
616 if (
const auto *TT = QT->
getAs<TagType>())
620 else if (
const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
621 while (IC->getSuperClass()) {
622 IC = IC->getSuperClass();
627 else if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(D)) {
632 else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
633 if (!(RD = RD->getDefinition()))
636 for (
const auto &I : RD->bases()) {
637 if (I.isVirtual() || (I.getAccessSpecifier() !=
AS_public))
651 for (
const auto &I : RD->vbases()) {
672 if (D != OriginalDecl && OriginalDecl)
680void ASTContext::CanonicalTemplateTemplateParm::Profile(
689 ID.AddInteger(Params->
size());
691 PEnd = Params->
end();
693 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
695 ID.AddBoolean(TTP->isParameterPack());
697 TTP->getNumExpansionParameters().toInternalRepresentation());
701 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
703 ID.AddBoolean(NTTP->isParameterPack());
704 ID.AddPointer(
C.getUnconstrainedType(
C.getCanonicalType(NTTP->getType()))
706 if (NTTP->isExpandedParameterPack()) {
708 ID.AddInteger(NTTP->getNumExpansionTypes());
709 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
711 ID.AddPointer(
T.getCanonicalType().getAsOpaquePtr());
714 ID.AddBoolean(
false);
724TemplateTemplateParmDecl *
728 llvm::FoldingSetNodeID ID;
729 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
730 llvm::FoldingSetInsertToken
Token;
731 CanonicalTemplateTemplateParm *Canonical =
732 CanonTemplateTemplateParms.lookup(ID,
Token);
734 return Canonical->getParam();
739 CanonParams.reserve(Params->
size());
741 PEnd = Params->
end();
745 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
750 TTP->getNumExpansionParameters());
751 CanonParams.push_back(NewTTP);
752 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
756 if (NTTP->isExpandedParameterPack()) {
759 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
761 ExpandedTInfos.push_back(
769 NTTP->getPosition(),
nullptr,
779 NTTP->getPosition(),
nullptr,
781 NTTP->isParameterPack(),
784 CanonParams.push_back(Param);
800 Canonical = CanonTemplateTemplateParms.lookup(ID,
Token);
801 assert(!Canonical &&
"Shouldn't be in the map!");
805 Canonical =
new (*this) CanonicalTemplateTemplateParm(CanonTTP);
806 CanonTemplateTemplateParms.insert(Canonical,
Token);
813 llvm::FoldingSetNodeID ID;
814 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
815 llvm::FoldingSetInsertToken
Token;
816 CanonicalTemplateTemplateParm *Canonical =
817 CanonTemplateTemplateParms.lookup(ID,
Token);
818 return Canonical ? Canonical->getParam() :
nullptr;
824 llvm::FoldingSetNodeID ID;
825 CanonicalTemplateTemplateParm::Profile(ID, *
this, CanonTTP);
826 llvm::FoldingSetInsertToken
Token;
827 if (
auto *Existing = CanonTemplateTemplateParms.lookup(ID,
Token))
828 return Existing->getParam();
829 CanonTemplateTemplateParms.insert(
830 new (*
this) CanonicalTemplateTemplateParm(CanonTTP),
Token);
851 [](
const DynTypedNode &P) { return P.get<WhileStmt>() != nullptr; });
875 return NoSanitizeL->containsType(Mask, TyName);
884 if (!LangOpts.CPlusPlus)
return nullptr;
887 case TargetCXXABI::AppleARM64:
888 case TargetCXXABI::Fuchsia:
889 case TargetCXXABI::GenericARM:
890 case TargetCXXABI::iOS:
891 case TargetCXXABI::WatchOS:
892 case TargetCXXABI::GenericAArch64:
893 case TargetCXXABI::GenericMIPS:
894 case TargetCXXABI::GenericItanium:
895 case TargetCXXABI::WebAssembly:
896 case TargetCXXABI::XL:
898 case TargetCXXABI::Microsoft:
901 llvm_unreachable(
"Invalid CXXABI type!");
905 if (!InterpContext) {
908 return *InterpContext;
913 switch (LangOpts.getAddressSpaceMapMangling()) {
921 llvm_unreachable(
"getAddressSpaceMapMangling() doesn't cover anything.");
927 : ConstantArrayTypes(this_(), ConstantArrayTypesLog2InitSize),
928 DependentSizedArrayTypes(this_()), DependentSizedExtVectorTypes(this_()),
929 DependentAddressSpaceTypes(this_()), DependentVectorTypes(this_()),
930 DependentSizedMatrixTypes(this_()),
931 FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
932 DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
933 DependentPackIndexingTypes(this_()), TemplateSpecializationTypes(this_()),
934 AttributedTypes(this_()), DependentBitIntTypes(this_()),
935 HLSLAttributedResourceTypes(this_()),
936 SubstTemplateTemplateParmPacks(this_()), DeducedTemplates(this_()),
937 PackIndexingTemplates(this_()), ArrayParameterTypes(this_()),
938 CanonTemplateTemplateParms(this_()), SourceMgr(SM), LangOpts(LOpts),
941 LangOpts.XRayNeverInstrumentFiles,
942 LangOpts.XRayAttrListFiles, SM)),
943 ProfList(new
ProfileList(LangOpts.ProfileListFiles, SM)),
947 CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
955 ReleaseDeclContextMaps();
958 for (
auto &Pair : Deallocations)
959 (Pair.first)(Pair.second);
960 Deallocations.clear();
966 I = ObjCLayouts.begin(),
967 E = ObjCLayouts.end();
974 for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
975 I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
980 ASTRecordLayouts.clear();
982 for (llvm::DenseMap<const Decl*, AttrVec*>::iterator A = DeclAttrs.begin(),
983 AEnd = DeclAttrs.end();
985 A->second->~AttrVec();
987 LastDeclAttrsDecl =
nullptr;
989 CtorClosureDefaultArgs.clear();
991 for (
const auto &
Value : ModuleInitializers)
992 Value.second->~PerModuleInitializers();
993 ModuleInitializers.
clear();
1003 TraversalScope = TopLevelDecls;
1017 llvm::errs() <<
"\n*** AST Context Stats:\n";
1018 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
1020 unsigned counts[] = {
1021#define TYPE(Name, Parent) 0,
1022#define ABSTRACT_TYPE(Name, Parent)
1023#include "clang/AST/TypeNodes.inc"
1027 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
1033 unsigned TotalBytes = 0;
1034#define TYPE(Name, Parent) \
1036 llvm::errs() << " " << counts[Idx] << " " << #Name \
1037 << " types, " << sizeof(Name##Type) << " each " \
1038 << "(" << counts[Idx] * sizeof(Name##Type) \
1040 TotalBytes += counts[Idx] * sizeof(Name##Type); \
1042#define ABSTRACT_TYPE(Name, Parent)
1043#include "clang/AST/TypeNodes.inc"
1045 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
1050 <<
" implicit default constructors created\n";
1053 <<
" implicit copy constructors created\n";
1057 <<
" implicit move constructors created\n";
1060 <<
" implicit copy assignment operators created\n";
1064 <<
" implicit move assignment operators created\n";
1067 <<
" implicit destructors created\n";
1070 llvm::errs() <<
"\n";
1074 BumpAlloc.PrintStats();
1078 bool NotifyListeners) {
1079 if (NotifyListeners)
1082 Listener->RedefinedHiddenDefinition(ND, M);
1089 if (It == MergedDefModules.end())
1092 auto &Merged = It->second;
1093 llvm::DenseSet<Module*>
Found;
1094 for (
Module *&M : Merged)
1095 if (!
Found.insert(M).second)
1097 llvm::erase(Merged,
nullptr);
1104 if (MergedIt == MergedDefModules.end())
1106 return MergedIt->second;
1109void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1110 if (LazyInitializers.empty())
1114 assert(Source &&
"lazy initializers but no external source");
1116 auto LazyInits = std::move(LazyInitializers);
1117 LazyInitializers.clear();
1119 for (
auto ID : LazyInits)
1120 Initializers.push_back(Source->GetExternalDecl(ID));
1122 assert(LazyInitializers.empty() &&
1123 "GetExternalDecl for lazy module initializer added more inits");
1129 if (
const auto *ID = dyn_cast<ImportDecl>(D)) {
1130 auto It = ModuleInitializers.find(ID->getImportedModule());
1133 if (It == ModuleInitializers.end())
1137 auto &Imported = *It->second;
1138 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1139 Imported.resolve(*
this);
1140 auto *OnlyDecl = Imported.Initializers.front();
1146 auto *&
Inits = ModuleInitializers[M];
1148 Inits =
new (*this) PerModuleInitializers;
1149 Inits->Initializers.push_back(D);
1154 auto *&
Inits = ModuleInitializers[M];
1156 Inits =
new (*this) PerModuleInitializers;
1157 Inits->LazyInitializers.insert(
Inits->LazyInitializers.end(),
1158 IDs.begin(), IDs.end());
1162 auto It = ModuleInitializers.find(M);
1163 if (It == ModuleInitializers.end())
1166 auto *
Inits = It->second;
1167 Inits->resolve(*
this);
1168 return Inits->Initializers;
1173 assert(!CurrentCXXNamedModule &&
1174 "We should set named module for ASTContext for only once");
1175 CurrentCXXNamedModule = M;
1187 auto GetRepresentativeModule = [
this](
const Module *M) {
1188 auto Iter = SameModuleLookupSet.find(M);
1189 if (Iter != SameModuleLookupSet.end())
1190 return Iter->second;
1192 const Module *RepresentativeModule =
1193 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1195 SameModuleLookupSet[M] = RepresentativeModule;
1196 return RepresentativeModule;
1199 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1200 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1204 if (!ExternCContext)
1207 return ExternCContext;
1221#define BuiltinTemplate(BTName) \
1222 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1223 if (!Decl##BTName) \
1225 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1226 return Decl##BTName; \
1228#include "clang/Basic/BuiltinTemplates.inc"
1241 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1242 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1247 StringRef Name)
const {
1271 Types.push_back(Ty);
1276 assert((!this->Target || this->Target == &Target) &&
1277 "Incorrect target reinitialization");
1278 assert(
VoidTy.isNull() &&
"Context reinitialized?");
1280 this->Target = &Target;
1281 this->AuxTarget = AuxTarget;
1283 ABI.reset(createCXXABI(Target));
1287 InitBuiltinType(
VoidTy, BuiltinType::Void);
1290 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1292 if (LangOpts.CharIsSigned)
1293 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1295 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1298 InitBuiltinType(
ShortTy, BuiltinType::Short);
1299 InitBuiltinType(
IntTy, BuiltinType::Int);
1300 InitBuiltinType(
LongTy, BuiltinType::Long);
1301 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1311 InitBuiltinType(
FloatTy, BuiltinType::Float);
1312 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1313 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1316 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1319 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1322 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1325 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1326 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1327 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1331 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1332 InitBuiltinType(
FractTy, BuiltinType::Fract);
1333 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1338 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1344 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1351 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1356 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1358 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1359 if (LangOpts.CPlusPlus && LangOpts.WChar)
1363 WideCharTy = getFromTargetType(Target.getWCharType());
1366 WIntTy = getFromTargetType(Target.getWIntType());
1369 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1371 if (LangOpts.CPlusPlus)
1372 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1374 Char16Ty = getFromTargetType(Target.getChar16Type());
1376 if (LangOpts.CPlusPlus)
1377 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1379 Char32Ty = getFromTargetType(Target.getChar32Type());
1386 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1389 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1401 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1407 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1410 if (LangOpts.OpenMP) {
1417 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1420 if (LangOpts.MatrixTypes)
1428 if (LangOpts.OpenCL) {
1429#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1430 InitBuiltinType(SingletonId, BuiltinType::Id);
1431#include "clang/Basic/OpenCLImageTypes.def"
1433 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1434 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1436 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1439#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1440 InitBuiltinType(Id##Ty, BuiltinType::Id);
1441#include "clang/Basic/OpenCLExtensionTypes.def"
1444 if (LangOpts.HLSL) {
1445#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1446 InitBuiltinType(SingletonId, BuiltinType::Id);
1447#include "clang/Basic/HLSLIntangibleTypes.def"
1449#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
1450 InitBuiltinType(SingletonId, BuiltinType::Id);
1451#include "clang/Basic/HLSLPackedTypes.def"
1454 if (Target.hasAArch64ACLETypes() ||
1455 (AuxTarget && AuxTarget->hasAArch64ACLETypes())) {
1456#define SVE_TYPE(Name, Id, SingletonId) \
1457 InitBuiltinType(SingletonId, BuiltinType::Id);
1458#include "clang/Basic/AArch64ACLETypes.def"
1461 if (Target.getTriple().isPPC64()) {
1462#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1463 InitBuiltinType(Id##Ty, BuiltinType::Id);
1464#include "clang/Basic/PPCTypes.def"
1465#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1466 InitBuiltinType(Id##Ty, BuiltinType::Id);
1467#include "clang/Basic/PPCTypes.def"
1470 if (Target.hasRISCVVTypes()) {
1471#define RVV_TYPE(Name, Id, SingletonId) \
1472 InitBuiltinType(SingletonId, BuiltinType::Id);
1473#include "clang/Basic/RISCVVTypes.def"
1476 if (Target.getTriple().isWasm() && Target.hasFeature(
"reference-types")) {
1477#define WASM_TYPE(Name, Id, SingletonId) \
1478 InitBuiltinType(SingletonId, BuiltinType::Id);
1479#include "clang/Basic/WebAssemblyReferenceTypes.def"
1482 if (Target.hasAMDGPUTypes() || (AuxTarget && (AuxTarget->hasAMDGPUTypes()))) {
1483#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1484 InitBuiltinType(SingletonId, BuiltinType::Id);
1485#include "clang/Basic/AMDGPUTypes.def"
1488 if (Target.getTriple().isSPIRV() ||
1489 (AuxTarget && AuxTarget->getTriple().isSPIRV())) {
1490#define SPIRV_TYPE(Name, Id, SingletonId) \
1491 InitBuiltinType(SingletonId, BuiltinType::Id);
1492#include "clang/Basic/SPIRVTypes.def"
1499 ObjCConstantStringType =
QualType();
1504 if (LangOpts.OpenCLGenericAddressSpace) {
1505 auto Q =
VoidTy.getQualifiers();
1514 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1517 InitBuiltinType(
MetaInfoTy, BuiltinType::MetaInfo);
1520 InitBuiltinType(
HalfTy, BuiltinType::Half);
1522 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1528 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1535 return SourceMgr.getDiagnostics();
1540 if (LastDeclAttrsDecl == D) {
1541 assert(LastDeclAttrs !=
nullptr && LastDeclAttrs == DeclAttrs[D]);
1542 return *LastDeclAttrs;
1551 LastDeclAttrsDecl = D;
1558 llvm::DenseMap<const Decl*, AttrVec*>::iterator Pos = DeclAttrs.find(D);
1559 if (Pos != DeclAttrs.end()) {
1560 Pos->second->~AttrVec();
1561 DeclAttrs.erase(Pos);
1563 if (LastDeclAttrsDecl == D)
1564 LastDeclAttrsDecl =
nullptr;
1569 return CtorClosureDefaultArgs.lookup(CD);
1574 assert(!CtorClosureDefaultArgs.contains(CD));
1575 CtorClosureDefaultArgs[CD] = Args;
1582 if (It != ExplicitInstantiations.end())
1595 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1596 TemplateOrInstantiation.find(Var);
1597 if (Pos == TemplateOrInstantiation.end())
1610 Tmpl, TSK, PointOfInstantiation));
1616 assert(!TemplateOrInstantiation[Inst] &&
1617 "Already noted what the variable was instantiated from");
1618 TemplateOrInstantiation[Inst] = TSI;
1623 return InstantiatedFromUsingDecl.lookup(UUD);
1631 "pattern decl is not a using decl");
1635 "instantiation did not produce a using decl");
1636 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1637 InstantiatedFromUsingDecl[Inst] = Pattern;
1642 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1647 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1648 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1653 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1659 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1660 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1665 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1671 "Instantiated field decl is not unnamed");
1673 "Template field decl is not unnamed");
1674 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1675 "Already noted what unnamed field was instantiated from");
1677 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1693 return Range.end() - Range.begin();
1698 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1699 OverriddenMethods.find(
Method->getCanonicalDecl());
1700 if (Pos == OverriddenMethods.end())
1708 OverriddenMethods[
Method].push_back(Overridden);
1716 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1722 const auto *
Method = dyn_cast<ObjCMethodDecl>(D);
1727 Method->getOverriddenMethods(OverDecls);
1728 Overridden.append(OverDecls.begin(), OverDecls.end());
1731std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1735 auto it = RelocatableClasses.find(D);
1736 if (it != RelocatableClasses.end())
1737 return it->getSecond();
1738 return std::nullopt;
1745 assert(RelocatableClasses.find(D) == RelocatableClasses.end());
1746 RelocatableClasses.insert({D, Info});
1751 if (!Class->isPolymorphic())
1753 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
1754 using AuthAttr = VTablePointerAuthenticationAttr;
1755 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1757 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1758 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1759 ExplicitAuth->getAddressDiscrimination();
1760 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1761 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1762 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1765ASTContext::PointerAuthContent
1766ASTContext::findPointerAuthContent(QualType
T)
const {
1767 assert(isPointerAuthenticationAvailable());
1769 T =
T.getCanonicalType();
1771 return PointerAuthContent::None;
1773 if (
T.hasAddressDiscriminatedPointerAuth())
1774 return PointerAuthContent::AddressDiscriminatedData;
1777 return PointerAuthContent::None;
1780 return PointerAuthContent::None;
1782 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1783 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1784 return Existing->second;
1786 PointerAuthContent
Result = PointerAuthContent::None;
1788 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1789 auto [ResultIter, DidAdd] =
1790 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1796 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1797 static_assert(PointerAuthContent::None <
1798 PointerAuthContent::AddressDiscriminatedVTable);
1799 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1800 PointerAuthContent::AddressDiscriminatedData);
1803 return Result != PointerAuthContent::AddressDiscriminatedData;
1805 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1807 !ShouldContinueAfterUpdate(
1808 PointerAuthContent::AddressDiscriminatedVTable))
1809 return SaveResultAndReturn();
1810 for (
auto Base : CXXRD->bases()) {
1811 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1812 return SaveResultAndReturn();
1815 for (
auto *FieldDecl : RD->
fields()) {
1816 if (!ShouldContinueAfterUpdate(
1817 findPointerAuthContent(FieldDecl->getType())))
1818 return SaveResultAndReturn();
1820 return SaveResultAndReturn();
1824 assert(!Import->getNextLocalImport() &&
1825 "Import declaration already in the chain");
1826 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1827 if (!FirstLocalImport) {
1828 FirstLocalImport = Import;
1829 LastLocalImport = Import;
1833 LastLocalImport->setNextLocalImport(Import);
1834 LastLocalImport = Import;
1846 llvm_unreachable(
"Not a floating point type!");
1847 case BuiltinType::BFloat16:
1848 return Target->getBFloat16Format();
1849 case BuiltinType::Float16:
1850 return Target->getHalfFormat();
1851 case BuiltinType::Half:
1852 return Target->getHalfFormat();
1853 case BuiltinType::Float:
return Target->getFloatFormat();
1854 case BuiltinType::Double:
return Target->getDoubleFormat();
1855 case BuiltinType::Ibm128:
1856 return Target->getIbm128Format();
1857 case BuiltinType::LongDouble:
1859 return AuxTarget->getLongDoubleFormat();
1860 return Target->getLongDoubleFormat();
1861 case BuiltinType::Float128:
1863 return AuxTarget->getFloat128Format();
1864 return Target->getFloat128Format();
1869 unsigned Align = Target->getCharWidth();
1873 Align = AlignFromAttr;
1881 bool UseAlignAttrOnly;
1882 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1884 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1886 UseAlignAttrOnly = AlignFromAttr != 0;
1889 if (UseAlignAttrOnly) {
1891 }
else if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
1895 T = RT->getPointeeType();
1900 if (
T->isFunctionType())
1901 Align = getTypeInfoImpl(
T.getTypePtr()).Align;
1906 unsigned MinWidth = Target->getLargeArrayMinWidth();
1907 if (!ForAlignof && MinWidth) {
1909 Align = std::max(Align, Target->getLargeArrayAlign());
1912 Align = std::max(Align, Target->getLargeArrayAlign());
1917 Align = Target->getCharWidth();
1921 if (
const auto *VD = dyn_cast<VarDecl>(D))
1922 if (VD->hasGlobalStorage() && !ForAlignof) {
1933 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1947 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1948 if (LowBitOfOffset < FieldAlign)
1949 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1952 Align = std::min(Align, FieldAlign);
1960 const auto *VD = dyn_cast<VarDecl>(D);
1961 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1962 Align = std::min(Align, MaxAlignedAttr);
1982 if (
const auto *RD =
T->getAsCXXRecordDecl(); RD && !RD->
isInvalidDecl()) {
1999 (uint64_t)(-1)/Size) &&
2000 "Overflow in array type char size evaluation");
2003 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
2005 Width = llvm::alignTo(Width, Align);
2012 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2030 switch (BT->getKind()) {
2031 case BuiltinType::Bool:
2032 case BuiltinType::Char_S:
2033 case BuiltinType::Char_U:
2034 case BuiltinType::SChar:
2035 case BuiltinType::UChar:
2036 case BuiltinType::Short:
2037 case BuiltinType::UShort:
2038 case BuiltinType::WChar_S:
2039 case BuiltinType::WChar_U:
2040 case BuiltinType::Char8:
2041 case BuiltinType::Char16:
2042 case BuiltinType::Char32:
2050 if (
const auto *ED =
T->getAsEnumDecl()) {
2051 if (
T->isDependentType() || ED->getPromotionType().isNull() ||
2059 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>()) {
2075 bool NeedsPreferredAlignment)
const {
2078 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2083 if (!
T->isIncompleteType())
2089 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2093 if (
const auto *TD =
T->getAsTagDecl())
2094 return TD->getMaxAlignment();
2100 TypeInfoMap::iterator I = MemoizedTypeInfo.find(
T);
2101 if (I != MemoizedTypeInfo.end())
2106 MemoizedTypeInfo[
T] = TI;
2121 switch (
T->getTypeClass()) {
2122#define TYPE(Class, Base)
2123#define ABSTRACT_TYPE(Class, Base)
2124#define NON_CANONICAL_TYPE(Class, Base)
2125#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2126#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
2128 assert(!T->isDependentType() && "should not see dependent types here"); \
2129 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
2130#include "clang/AST/TypeNodes.inc"
2131 llvm_unreachable(
"Should not see dependent types");
2133 case Type::FunctionNoProto:
2134 case Type::FunctionProto:
2140 case Type::IncompleteArray:
2141 case Type::VariableArray:
2142 case Type::ConstantArray:
2143 case Type::ArrayParameter: {
2146 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2147 Size = CAT->getZExtSize();
2150 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2151 "Overflow in array type bit size evaluation");
2152 Width = EltInfo.
Width * Size;
2153 Align = EltInfo.
Align;
2157 Width = llvm::alignTo(Width, Align);
2161 case Type::ExtVector:
2162 case Type::Vector: {
2165 Width = VT->isPackedVectorBoolType(*
this)
2166 ? VT->getNumElements()
2167 : EltInfo.
Width * VT->getNumElements();
2169 Width = std::max<unsigned>(8, Width);
2170 Align = std::max<unsigned>(
2171 8,
Target->vectorsAreElementAligned() ? EltInfo.
Width : Width);
2175 if (Align & (Align-1)) {
2176 Align = llvm::bit_ceil(Align);
2177 Width = llvm::alignTo(Width, Align);
2180 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
2181 if (TargetVectorAlign && TargetVectorAlign < Align)
2182 Align = TargetVectorAlign;
2196 Align = std::min<unsigned>(64, Width);
2203 case Type::ConstantMatrix: {
2205 TypeInfo ElementInfo =
getTypeInfo(MT->getElementType());
2209 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2210 Align = ElementInfo.
Align;
2216 default: llvm_unreachable(
"Unknown builtin type!");
2217 case BuiltinType::Void:
2222 case BuiltinType::Bool:
2223 Width = Target->getBoolWidth();
2224 Align = Target->getBoolAlign();
2226 case BuiltinType::Char_S:
2227 case BuiltinType::Char_U:
2228 case BuiltinType::UChar:
2229 case BuiltinType::SChar:
2230 case BuiltinType::Char8:
2231 Width = Target->getCharWidth();
2232 Align = Target->getCharAlign();
2234 case BuiltinType::WChar_S:
2235 case BuiltinType::WChar_U:
2236 Width = Target->getWCharWidth();
2237 Align = Target->getWCharAlign();
2239 case BuiltinType::Char16:
2240 Width = Target->getChar16Width();
2241 Align = Target->getChar16Align();
2243 case BuiltinType::Char32:
2244 Width = Target->getChar32Width();
2245 Align = Target->getChar32Align();
2247 case BuiltinType::UShort:
2248 case BuiltinType::Short:
2249 Width = Target->getShortWidth();
2250 Align = Target->getShortAlign();
2252 case BuiltinType::UInt:
2253 case BuiltinType::Int:
2254 Width = Target->getIntWidth();
2255 Align = Target->getIntAlign();
2257 case BuiltinType::ULong:
2258 case BuiltinType::Long:
2259 Width = Target->getLongWidth();
2260 Align = Target->getLongAlign();
2262 case BuiltinType::ULongLong:
2263 case BuiltinType::LongLong:
2264 Width = Target->getLongLongWidth();
2265 Align = Target->getLongLongAlign();
2267 case BuiltinType::Int128:
2268 case BuiltinType::UInt128:
2270 Align = Target->getInt128Align();
2272 case BuiltinType::ShortAccum:
2273 case BuiltinType::UShortAccum:
2274 case BuiltinType::SatShortAccum:
2275 case BuiltinType::SatUShortAccum:
2276 Width = Target->getShortAccumWidth();
2277 Align = Target->getShortAccumAlign();
2279 case BuiltinType::Accum:
2280 case BuiltinType::UAccum:
2281 case BuiltinType::SatAccum:
2282 case BuiltinType::SatUAccum:
2283 Width = Target->getAccumWidth();
2284 Align = Target->getAccumAlign();
2286 case BuiltinType::LongAccum:
2287 case BuiltinType::ULongAccum:
2288 case BuiltinType::SatLongAccum:
2289 case BuiltinType::SatULongAccum:
2290 Width = Target->getLongAccumWidth();
2291 Align = Target->getLongAccumAlign();
2293 case BuiltinType::ShortFract:
2294 case BuiltinType::UShortFract:
2295 case BuiltinType::SatShortFract:
2296 case BuiltinType::SatUShortFract:
2297 Width = Target->getShortFractWidth();
2298 Align = Target->getShortFractAlign();
2300 case BuiltinType::Fract:
2301 case BuiltinType::UFract:
2302 case BuiltinType::SatFract:
2303 case BuiltinType::SatUFract:
2304 Width = Target->getFractWidth();
2305 Align = Target->getFractAlign();
2307 case BuiltinType::LongFract:
2308 case BuiltinType::ULongFract:
2309 case BuiltinType::SatLongFract:
2310 case BuiltinType::SatULongFract:
2311 Width = Target->getLongFractWidth();
2312 Align = Target->getLongFractAlign();
2314 case BuiltinType::BFloat16:
2315 if (Target->hasBFloat16Type()) {
2316 Width = Target->getBFloat16Width();
2317 Align = Target->getBFloat16Align();
2321 AuxTarget->hasBFloat16Type()) {
2322 Width = AuxTarget->getBFloat16Width();
2323 Align = AuxTarget->getBFloat16Align();
2326 case BuiltinType::Float16:
2327 case BuiltinType::Half:
2328 if (Target->hasFloat16Type() || !
getLangOpts().OpenMP ||
2330 Width = Target->getHalfWidth();
2331 Align = Target->getHalfAlign();
2334 "Expected OpenMP device compilation.");
2335 Width = AuxTarget->getHalfWidth();
2336 Align = AuxTarget->getHalfAlign();
2339 case BuiltinType::Float:
2340 Width = Target->getFloatWidth();
2341 Align = Target->getFloatAlign();
2343 case BuiltinType::Double:
2344 Width = Target->getDoubleWidth();
2345 Align = Target->getDoubleAlign();
2347 case BuiltinType::Ibm128:
2348 Width = Target->getIbm128Width();
2349 Align = Target->getIbm128Align();
2351 case BuiltinType::LongDouble:
2353 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2354 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2355 Width = AuxTarget->getLongDoubleWidth();
2356 Align = AuxTarget->getLongDoubleAlign();
2358 Width = Target->getLongDoubleWidth();
2359 Align = Target->getLongDoubleAlign();
2363 if (&Target->getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended())
2366 case BuiltinType::Float128:
2367 if (Target->hasFloat128Type() || !
getLangOpts().OpenMP ||
2369 Width = Target->getFloat128Width();
2370 Align = Target->getFloat128Align();
2373 "Expected OpenMP device compilation.");
2374 Width = AuxTarget->getFloat128Width();
2375 Align = AuxTarget->getFloat128Align();
2378 case BuiltinType::NullPtr:
2383 case BuiltinType::MetaInfo:
2389 case BuiltinType::ObjCId:
2390 case BuiltinType::ObjCClass:
2391 case BuiltinType::ObjCSel:
2395 case BuiltinType::OCLSampler:
2396 case BuiltinType::OCLEvent:
2397 case BuiltinType::OCLClkEvent:
2398 case BuiltinType::OCLQueue:
2399 case BuiltinType::OCLReserveID:
2400#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2401 case BuiltinType::Id:
2402#include "clang/Basic/OpenCLImageTypes.def"
2403#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2404 case BuiltinType::Id:
2405#include "clang/Basic/OpenCLExtensionTypes.def"
2407 Width = Target->getPointerWidth(AS);
2408 Align = Target->getPointerAlign(AS);
2418#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2419 case BuiltinType::Id: \
2423#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2424 case BuiltinType::Id: \
2428#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2429 case BuiltinType::Id: \
2433#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2434 case BuiltinType::Id: \
2438#include "clang/Basic/AArch64ACLETypes.def"
2439#define PPC_VECTOR_TYPE(Name, Id, Size) \
2440 case BuiltinType::Id: \
2444#include "clang/Basic/PPCTypes.def"
2445#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2447 case BuiltinType::Id: \
2451#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2452 case BuiltinType::Id: \
2456#include "clang/Basic/RISCVVTypes.def"
2457#define WASM_TYPE(Name, Id, SingletonId) \
2458 case BuiltinType::Id: \
2462#include "clang/Basic/WebAssemblyReferenceTypes.def"
2463#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2464 case BuiltinType::ID: \
2468#include "clang/Basic/AMDGPUTypes.def"
2469#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2470#include "clang/Basic/HLSLIntangibleTypes.def"
2474#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2475#include "clang/Basic/HLSLPackedTypes.def"
2479#define SPIRV_TYPE(Name, Id, SingletonId) \
2480 case BuiltinType::Id: \
2481 Width = Target->getPointerWidth(LangAS::Default); \
2482 Align = Target->getPointerAlign(LangAS::Default); \
2484#include "clang/Basic/SPIRVTypes.def"
2487 case Type::ObjCObjectPointer:
2491 case Type::BlockPointer:
2493 Width = Target->getPointerWidth(AS);
2494 Align = Target->getPointerAlign(AS);
2496 case Type::LValueReference:
2497 case Type::RValueReference:
2501 Width = Target->getPointerWidth(AS);
2502 Align = Target->getPointerAlign(AS);
2506 Width = Target->getPointerWidth(AS);
2507 Align = Target->getPointerAlign(AS);
2509 case Type::MemberPointer: {
2511 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2516 case Type::Complex: {
2520 Width = EltInfo.
Width * 2;
2521 Align = EltInfo.
Align;
2524 case Type::ObjCObject:
2526 case Type::Adjusted:
2529 case Type::ObjCInterface: {
2531 if (ObjCI->getDecl()->isInvalidDecl()) {
2541 case Type::BitInt: {
2543 Align = Target->getBitIntAlign(EIT->getNumBits());
2544 Width = Target->getBitIntWidth(EIT->getNumBits());
2550 const TagDecl *TD = TT->getDecl()->getDefinitionOrSelf();
2563 Info.
Align = AttrAlign;
2573 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2579 case Type::SubstTemplateTypeParm:
2581 getReplacementType().getTypePtr());
2584 case Type::DeducedTemplateSpecialization: {
2586 assert(!A->getDeducedType().isNull() &&
2587 "cannot request the size of an undeduced or dependent auto type");
2588 return getTypeInfo(A->getDeducedType().getTypePtr());
2594 case Type::MacroQualified:
2598 case Type::ObjCTypeParam:
2604 case Type::Typedef: {
2606 TypeInfo Info =
getTypeInfo(TT->desugar().getTypePtr());
2610 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2621 case Type::Attributed:
2625 case Type::CountAttributed:
2628 case Type::LateParsedAttr:
2631 case Type::BTFTagAttributed:
2635 case Type::OverflowBehavior:
2639 case Type::HLSLAttributedResource:
2643 case Type::HLSLInlineSpirv: {
2646 Width = ST->getSize() * 8;
2647 Align = ST->getAlignment();
2648 if (Width == 0 && Align == 0) {
2656 case Type::Atomic: {
2665 Width = Target->getCharWidth();
2667 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2673 Width = llvm::bit_ceil(Width);
2676 Align =
static_cast<unsigned>(Width);
2681 case Type::PredefinedSugar:
2690 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2691 return TypeInfo(Width, Align, AlignRequirement);
2695 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(
T);
2696 if (I != MemoizedUnadjustedAlign.end())
2699 unsigned UnadjustedAlign;
2700 if (
const auto *RT =
T->getAsCanonical<RecordType>()) {
2707 UnadjustedAlign =
getTypeAlign(
T->getUnqualifiedDesugaredType());
2710 MemoizedUnadjustedAlign[
T] = UnadjustedAlign;
2711 return UnadjustedAlign;
2715 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2765 unsigned ABIAlign = TI.
Align;
2767 T =
T->getBaseElementTypeUnsafe();
2770 if (
T->isMemberPointerType())
2773 if (!Target->allowsLargerPreferedTypeAlignment())
2776 if (
const auto *RD =
T->getAsRecordDecl()) {
2785 unsigned PreferredAlign =
static_cast<unsigned>(
2787 assert(PreferredAlign >= ABIAlign &&
2788 "PreferredAlign should be at least as large as ABIAlign.");
2789 return PreferredAlign;
2796 T = CT->getElementType().getTypePtr();
2797 if (
const auto *ED =
T->getAsEnumDecl())
2798 T = ED->getIntegerType().getTypePtr();
2799 if (
T->isSpecificBuiltinType(BuiltinType::Double) ||
2800 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2801 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2802 (
T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2803 Target->defaultsToAIXPowerAlignment()))
2858 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
2862 std::swap(
Base, Derived);
2882 llvm::append_range(Ivars, OI->
ivars());
2885 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2887 Ivars.push_back(Iv);
2895 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2898 for (
auto *Proto : OI->all_referenced_protocols()) {
2903 for (
const auto *Cat : OI->visible_categories())
2909 SD = SD->getSuperClass();
2911 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2912 for (
auto *Proto : OC->protocols()) {
2915 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2917 if (!Protocols.insert(
2921 for (
auto *Proto : OP->protocols())
2928 bool CheckIfTriviallyCopyable) {
2929 assert(RD->
isUnion() &&
"Must be union type");
2931 Context.getTypeSizeInChars(Context.getCanonicalTagType(RD));
2933 for (
const auto *Field : RD->
fields()) {
2934 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2935 CheckIfTriviallyCopyable))
2937 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2938 if (FieldSize != UnionSize)
2947 return Context.getFieldOffset(Field);
2956static std::optional<int64_t>
2958 const RecordDecl *RD,
2959 bool CheckIfTriviallyCopyable);
2961static std::optional<int64_t>
2963 bool CheckIfTriviallyCopyable) {
2964 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2967 CheckIfTriviallyCopyable);
2971 bool IsBitIntType = Field->getType()->isBitIntType();
2972 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2973 !Context.hasUniqueObjectRepresentations(Field->getType(),
2974 CheckIfTriviallyCopyable))
2975 return std::nullopt;
2977 int64_t FieldSizeInBits =
2978 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2979 if (Field->isBitField()) {
2982 if (Field->isUnnamedBitField())
2985 int64_t BitfieldSize = Field->getBitWidthValue();
2987 if ((
unsigned)BitfieldSize >
2989 return std::nullopt;
2990 }
else if (BitfieldSize > FieldSizeInBits) {
2991 return std::nullopt;
2993 FieldSizeInBits = BitfieldSize;
2994 }
else if (IsBitIntType && !Context.hasUniqueObjectRepresentations(
2995 Field->getType(), CheckIfTriviallyCopyable)) {
2996 return std::nullopt;
2998 return FieldSizeInBits;
3001static std::optional<int64_t>
3003 bool CheckIfTriviallyCopyable) {
3005 CheckIfTriviallyCopyable);
3008template <
typename RangeT>
3010 const RangeT &Subobjects, int64_t CurOffsetInBits,
3012 bool CheckIfTriviallyCopyable) {
3013 for (
const auto *Subobject : Subobjects) {
3014 std::optional<int64_t> SizeInBits =
3017 return std::nullopt;
3018 if (*SizeInBits != 0) {
3020 if (Offset != CurOffsetInBits)
3021 return std::nullopt;
3022 CurOffsetInBits += *SizeInBits;
3025 return CurOffsetInBits;
3028static std::optional<int64_t>
3031 bool CheckIfTriviallyCopyable) {
3032 assert(!RD->
isUnion() &&
"Must be struct/class type");
3033 const auto &Layout = Context.getASTRecordLayout(RD);
3035 int64_t CurOffsetInBits = 0;
3036 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3037 if (ClassDecl->isDynamicClass())
3038 return std::nullopt;
3041 for (
const auto &
Base : ClassDecl->bases()) {
3044 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
3048 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
3051 std::optional<int64_t> OffsetAfterBases =
3053 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
3054 if (!OffsetAfterBases)
3055 return std::nullopt;
3056 CurOffsetInBits = *OffsetAfterBases;
3059 std::optional<int64_t> OffsetAfterFields =
3061 RD->
fields(), CurOffsetInBits, Context, Layout,
3062 CheckIfTriviallyCopyable);
3063 if (!OffsetAfterFields)
3064 return std::nullopt;
3065 CurOffsetInBits = *OffsetAfterFields;
3067 return CurOffsetInBits;
3071 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
3088 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
3093 CheckIfTriviallyCopyable);
3096 "hasUniqueObjectRepresentations should not be called with an "
3105 CheckIfTriviallyCopyable);
3128 return !ABI->getMemberPointerInfo(MPT).HasPadding;
3131 if (
Record->isInvalidDecl())
3136 CheckIfTriviallyCopyable);
3139 *
this,
Record, CheckIfTriviallyCopyable);
3141 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
3161 count += Ext->ivar_size();
3166 count += ImplDecl->ivar_size();
3192 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3193 I = ObjCImpls.find(D);
3194 if (I != ObjCImpls.end())
3202 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3203 I = ObjCImpls.find(D);
3204 if (I != ObjCImpls.end())
3212 assert(IFaceD && ImplD &&
"Passed null params");
3213 ObjCImpls[IFaceD] = ImplD;
3219 assert(CatD && ImplD &&
"Passed null params");
3220 ObjCImpls[CatD] = ImplD;
3225 return ObjCMethodRedecls.
lookup(MD);
3231 ObjCMethodRedecls[MD] = Redecl;
3236 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3238 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3239 return CD->getClassInterface();
3240 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3241 return IMD->getClassInterface();
3249 assert(VD &&
"Passed null params");
3250 assert(VD->
hasAttr<BlocksAttr>() &&
3251 "getBlockVarCopyInits - not __block var");
3252 auto I = BlockVarCopyInits.find(VD);
3253 if (I != BlockVarCopyInits.end())
3255 return {
nullptr,
false};
3261 assert(VD && CopyExpr &&
"Passed null params");
3262 assert(VD->
hasAttr<BlocksAttr>() &&
3263 "setBlockVarCopyInits - not __block var");
3264 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3268 unsigned DataSize)
const {
3273 "incorrect data size provided to CreateTypeSourceInfo!");
3290 return getObjCLayout(D);
3295 bool &AnyNonCanonArgs) {
3297 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3303 bool AnyNonCanonArgs =
false;
3304 for (
auto &Arg : Args) {
3307 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3309 return AnyNonCanonArgs;
3317ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3322 llvm::FoldingSetNodeID ID;
3324 llvm::FoldingSetInsertToken
Token;
3326 assert(eq->getQualifiers() == quals);
3335 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3338 (void)ExtQualNodes.lookup(ID,
Token);
3341 auto *eq =
new (*
this,
alignof(ExtQuals)) ExtQuals(baseType, canon, quals);
3342 ExtQualNodes.insert(eq, Token);
3343 return QualType(eq, fastQuals);
3347 LangAS AddressSpace)
const {
3360 "Type cannot be in multiple addr spaces!");
3363 return getExtQualType(TypeNode, Quals);
3369 if (!
T.hasAddressSpace())
3373 const Type *TypeNode;
3376 if (
T.getTypePtr()->isArrayType()) {
3378 TypeNode =
T.getTypePtr();
3382 while (
T.hasAddressSpace()) {
3383 TypeNode = Quals.
strip(
T);
3387 if (!
QualType(TypeNode, 0).hasAddressSpace())
3391 T =
T.getSingleStepDesugaredType(*
this);
3401 return getExtQualType(TypeNode, Quals);
3410 "Attempted to get vtable pointer discriminator on a monomorphic type");
3414 llvm::raw_svector_ostream Out(Str);
3415 MC->mangleCXXVTable(RD, Out);
3418 return llvm::getPointerAuthStableSipHash(Str);
3444 switch (
T->getTypeClass()) {
3449 case Type::LValueReference:
3454 case Type::RValueReference:
3468 case Type::ObjCObjectPointer:
3469 case Type::BlockPointer:
3478 case Type::VariableArray:
3479 case Type::ConstantArray:
3480 case Type::IncompleteArray:
3481 case Type::ArrayParameter:
3494 case Type::ObjCInterface:
3495 case Type::ObjCObject:
3496 OS <<
"<objc_object>";
3505 QualType UnderlyingType =
T->castAsEnumDecl()->getIntegerType();
3507 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3510 case Type::FunctionNoProto:
3511 case Type::FunctionProto: {
3527 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3528 for (
QualType Param : FPT->param_types()) {
3532 if (FPT->isVariadic())
3539 case Type::MemberPointer: {
3543 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3547 case Type::ExtVector:
3555 case Type::ConstantMatrix:
3559 case Type::Builtin: {
3561 switch (BTy->getKind()) {
3562#define SIGNED_TYPE(Id, SingletonId) \
3563 case BuiltinType::Id: \
3566#define UNSIGNED_TYPE(Id, SingletonId) \
3567 case BuiltinType::Id: \
3570#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3571#define BUILTIN_TYPE(Id, SingletonId)
3572#include "clang/AST/BuiltinTypes.def"
3573 llvm_unreachable(
"placeholder types should not appear here.");
3575 case BuiltinType::Half:
3578 case BuiltinType::Float:
3581 case BuiltinType::Double:
3584 case BuiltinType::LongDouble:
3587 case BuiltinType::Float16:
3590 case BuiltinType::Float128:
3594 case BuiltinType::Void:
3598 case BuiltinType::ObjCId:
3599 case BuiltinType::ObjCClass:
3600 case BuiltinType::ObjCSel:
3601 case BuiltinType::NullPtr:
3606 case BuiltinType::OCLSampler:
3607 case BuiltinType::OCLEvent:
3608 case BuiltinType::OCLClkEvent:
3609 case BuiltinType::OCLQueue:
3610 case BuiltinType::OCLReserveID:
3611 case BuiltinType::BFloat16:
3612 case BuiltinType::VectorQuad:
3613 case BuiltinType::VectorPair:
3614 case BuiltinType::DMR1024:
3615 case BuiltinType::DMR2048:
3616 case BuiltinType::MetaInfo:
3621 case BuiltinType::Ibm128:
3623#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3624 case BuiltinType::Id: \
3626#include "clang/Basic/OpenCLImageTypes.def"
3627#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3628 case BuiltinType::Id: \
3630#include "clang/Basic/OpenCLExtensionTypes.def"
3631#define SVE_TYPE(Name, Id, SingletonId) \
3632 case BuiltinType::Id: \
3634#include "clang/Basic/AArch64ACLETypes.def"
3635#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3636 case BuiltinType::Id: \
3638#include "clang/Basic/HLSLIntangibleTypes.def"
3639#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
3640 case BuiltinType::Id: \
3642#include "clang/Basic/HLSLPackedTypes.def"
3643 case BuiltinType::Dependent:
3644 llvm_unreachable(
"should never get here");
3645#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3646#include "clang/Basic/AMDGPUTypes.def"
3647 case BuiltinType::WasmExternRef:
3648#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3649#include "clang/Basic/RISCVVTypes.def"
3650#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3651#include "clang/Basic/SPIRVTypes.def"
3652 llvm_unreachable(
"not yet implemented");
3654 llvm_unreachable(
"should never get here");
3656 case Type::Record: {
3657 const RecordDecl *RD =
T->castAsCanonical<RecordType>()->getDecl();
3677 II = Typedef->getDeclName().getAsIdentifierInfo();
3680 OS <<
"<anonymous_record>";
3686 case Type::HLSLAttributedResource:
3687 case Type::HLSLInlineSpirv:
3688 llvm_unreachable(
"should never get here");
3690 case Type::OverflowBehavior:
3691 llvm_unreachable(
"should never get here");
3693 case Type::DeducedTemplateSpecialization:
3695#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3696#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3697#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3698#define ABSTRACT_TYPE(Class, Base)
3699#define TYPE(Class, Base)
3700#include "clang/AST/TypeNodes.inc"
3701 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3707 assert(!
T->isDependentType() &&
3708 "cannot compute type discriminator of a dependent type");
3710 llvm::raw_svector_ostream Out(Str);
3712 if (
T->isFunctionPointerType() ||
T->isFunctionReferenceType())
3713 T =
T->getPointeeType();
3715 if (
T->isFunctionType()) {
3718 T =
T.getUnqualifiedType();
3739 if (MPT->isMemberFunctionPointer()) {
3745 MPT->getMostRecentCXXRecordDecl());
3749 MC->mangleCanonicalTypeName(
T, Out);
3752 return llvm::getPointerAuthStableSipHash(Str);
3777 "Type cannot have multiple ObjCGCs!");
3780 return getExtQualType(TypeNode, Quals);
3785 QualType Pointee = Ptr->getPointeeType();
3794 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3797 assert(CountExpr &&
"use getIncompleteCountAttributedType for a null count");
3804 llvm::FoldingSetNodeID ID;
3807 llvm::FoldingSetInsertToken
Token;
3813 CATy = CountAttributedType::Create(*
this, WrappedTy, CanonTy, CountExpr,
3814 CountInBytes, OrNull, DependentDecls);
3815 Types.push_back(CATy);
3816 CountAttributedTypes.insert(CATy,
Token);
3822 QualType WrappedTy,
bool CountInBytes,
bool OrNull)
const {
3837 return CountAttributedType::Create(
3839 nullptr, CountInBytes, OrNull,
3846 CATy->complete(*
this, CountExpr, DependentDecls);
3857 Types.push_back(CATy);
3867 Types.push_back(LPATy);
3875 case Type::Attributed: {
3883 case Type::BTFTagAttributed: {
3884 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3889 case Type::OverflowBehavior: {
3890 const auto *OB = dyn_cast<OverflowBehaviorType>(Orig);
3892 adjustType(OB->getUnderlyingType(), Adjust));
3899 case Type::Adjusted: {
3905 case Type::MacroQualified: {
3908 MQT->getMacroIdentifier());
3912 return Adjust(Orig);
3918 if (
T->getExtInfo() == Info)
3922 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(
T)) {
3942 FPT->getExtProtoInfo());
3957 L->DeducedReturnType(FD, ResultType);
3968 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3969 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3985 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
4008 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
4034 if (TSInfo->getType() != FD->
getType())
4042 "TypeLoc size mismatch from updating exception specification");
4043 TSInfo->overrideType(Updated);
4052 llvm::FoldingSetInsertToken
Token;
4059 if (!
T.isCanonical()) {
4062 assert(!ComplexTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4065 Types.push_back(
New);
4075 llvm::FoldingSetInsertToken
Token;
4082 if (!
T.isCanonical()) {
4085 assert(!PointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4088 Types.push_back(
New);
4094 llvm::FoldingSetInsertToken
Token;
4103 Types.push_back(AT);
4104 AdjustedTypes.insert(AT,
Token);
4109 llvm::FoldingSetInsertToken
Token;
4117 Types.push_back(AT);
4118 AdjustedTypes.insert(AT,
Token);
4123 assert((
T->isArrayType() ||
T->isFunctionType()) &&
"T does not decay");
4132 if (
T->isArrayType())
4139 if (
T->isFunctionType())
4151 llvm::FoldingSetNodeID ID;
4152 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
4153 ATy->getSizeExpr(), ATy->getSizeModifier(),
4154 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
4155 llvm::FoldingSetInsertToken
Token;
4165 AT = ArrayParameterTypes.lookup(ID,
Token);
4166 assert(!AT &&
"Shouldn't be in the map!");
4171 Types.push_back(AT);
4172 ArrayParameterTypes.insert(AT,
Token);
4179 assert(
T->isFunctionType() &&
"block of function types only");
4182 llvm::FoldingSetInsertToken
Token;
4189 if (!
T.isCanonical()) {
4192 assert(!BlockPointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4196 Types.push_back(
New);
4197 BlockPointerTypes.insert(
New,
Token);
4205 assert((!
T->isPlaceholderType() ||
4206 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4207 "Unresolved placeholder type");
4211 llvm::FoldingSetInsertToken
Token;
4213 LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token))
4221 if (!SpelledAsLValue || InnerRef || !
T.isCanonical()) {
4222 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4225 assert(!LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token) &&
4226 "Shouldn't be in the map!");
4231 Types.push_back(
New);
4232 LValueReferenceTypes.insert(
New,
Token);
4240 assert((!
T->isPlaceholderType() ||
4241 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4242 "Unresolved placeholder type");
4246 llvm::FoldingSetInsertToken
Token;
4255 if (InnerRef || !
T.isCanonical()) {
4256 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4259 assert(!RValueReferenceTypes.lookup({T, false},
Token) &&
4260 "Shouldn't be in the map!");
4265 Types.push_back(
New);
4266 RValueReferenceTypes.insert(
New,
Token);
4274 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4277 Cls = Qualifier.getAsRecordDecl();
4281 llvm::FoldingSetNodeID ID;
4284 llvm::FoldingSetInsertToken
Token;
4290 return Qualifier.getCanonical();
4292 assert(R.isCanonical());
4298 if (!
T.isCanonical() || Qualifier != CanonicalQualifier) {
4304 MemberPointerTypes.lookup(ID,
Token);
4305 assert(!NewIP &&
"Shouldn't be in the map!");
4309 Types.push_back(
New);
4310 MemberPointerTypes.insert(
New,
Token);
4317 const llvm::APInt &ArySizeIn,
4318 const Expr *SizeExpr,
4320 unsigned IndexTypeQuals)
const {
4323 "Constant array of VLAs is illegal!");
4331 llvm::APInt ArySize(ArySizeIn);
4332 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
4334 llvm::FoldingSetNodeID ID;
4336 ASM, IndexTypeQuals);
4338 llvm::FoldingSetInsertToken
Token;
4350 ASM, IndexTypeQuals);
4355 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4358 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4359 ASM, IndexTypeQuals);
4360 ConstantArrayTypes.insert(
New,
Token);
4361 Types.push_back(
New);
4370 if (!
type->isVariablyModifiedType())
return type;
4375 const Type *ty = split.
Ty;
4377#define TYPE(Class, Base)
4378#define ABSTRACT_TYPE(Class, Base)
4379#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4380#include "clang/AST/TypeNodes.inc"
4381 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4387 case Type::DependentVector:
4388 case Type::ExtVector:
4389 case Type::DependentSizedExtVector:
4390 case Type::ConstantMatrix:
4391 case Type::DependentSizedMatrix:
4392 case Type::DependentAddressSpace:
4393 case Type::ObjCObject:
4394 case Type::ObjCInterface:
4395 case Type::ObjCObjectPointer:
4398 case Type::UnresolvedUsing:
4399 case Type::TypeOfExpr:
4401 case Type::Decltype:
4402 case Type::UnaryTransform:
4403 case Type::DependentName:
4404 case Type::InjectedClassName:
4405 case Type::TemplateSpecialization:
4406 case Type::TemplateTypeParm:
4407 case Type::SubstTemplateTypeParmPack:
4408 case Type::SubstBuiltinTemplatePack:
4410 case Type::DeducedTemplateSpecialization:
4411 case Type::PackExpansion:
4412 case Type::PackIndexing:
4414 case Type::DependentBitInt:
4415 case Type::ArrayParameter:
4416 case Type::HLSLAttributedResource:
4417 case Type::HLSLInlineSpirv:
4418 case Type::OverflowBehavior:
4419 llvm_unreachable(
"type should never be variably-modified");
4423 case Type::FunctionNoProto:
4424 case Type::FunctionProto:
4425 case Type::BlockPointer:
4426 case Type::MemberPointer:
4439 case Type::LValueReference: {
4443 lv->isSpelledAsLValue());
4447 case Type::RValueReference: {
4454 case Type::Atomic: {
4460 case Type::ConstantArray: {
4466 cat->getSizeModifier(),
4467 cat->getIndexTypeCVRQualifiers());
4471 case Type::DependentSizedArray: {
4475 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4480 case Type::IncompleteArray: {
4485 iat->getIndexTypeCVRQualifiers());
4490 case Type::VariableArray: {
4495 vat->getIndexTypeCVRQualifiers());
4508 unsigned IndexTypeQuals)
const {
4525 VariableArrayTypes.push_back(
New);
4526 Types.push_back(
New);
4536 unsigned elementTypeQuals)
const {
4539 "Size must be type- or value-dependent!");
4543 llvm::FoldingSetInsertToken
Token;
4544 llvm::FoldingSetNodeID ID;
4546 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4547 ASM, elementTypeQuals, numElements);
4562 DependentSizedArrayTypes.insert(newType,
Token);
4563 Types.push_back(newType);
4571 numElements, ASM, elementTypeQuals);
4572 DependentSizedArrayTypes.insert(canonTy,
Token);
4573 Types.push_back(canonTy);
4578 canonElementType.
Quals);
4582 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4591 Types.push_back(sugaredType);
4597 unsigned elementTypeQuals)
const {
4598 llvm::FoldingSetNodeID ID;
4601 llvm::FoldingSetInsertToken
Token;
4614 ASM, elementTypeQuals);
4619 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4625 IncompleteArrayTypes.insert(newType,
Token);
4626 Types.push_back(newType);
4632#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4633 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4636#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4637 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4641 llvm_unreachable(
"Unsupported builtin vector type");
4643#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4644 ElBits, NF, IsSigned) \
4645 case BuiltinType::Id: \
4646 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4647 llvm::ElementCount::getScalable(NumEls), NF};
4648#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4650 case BuiltinType::Id: \
4651 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4652 llvm::ElementCount::getScalable(NumEls), NF};
4653#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4655 case BuiltinType::Id: \
4656 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4657#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4659 case BuiltinType::Id: \
4660 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4661#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4662 case BuiltinType::Id: \
4663 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4664#include "clang/Basic/AArch64ACLETypes.def"
4666#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4668 case BuiltinType::Id: \
4669 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4670 llvm::ElementCount::getScalable(NumEls), NF};
4671#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4672 case BuiltinType::Id: \
4673 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4674 llvm::ElementCount::getScalable(NumEls), NF};
4675#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4676 case BuiltinType::Id: \
4677 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4678#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4679 case BuiltinType::Id: \
4680 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4681#include "clang/Basic/RISCVVTypes.def"
4688 if (Target->getTriple().isWasm() && Target->hasFeature(
"reference-types")) {
4689#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4690 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4692#include "clang/Basic/WebAssemblyReferenceTypes.def"
4695 "shouldn't try to generate type externref outside WebAssembly target");
4702 unsigned NumFields)
const {
4704 if (
auto It = ScalableVecTyMap.find(K); It != ScalableVecTyMap.end())
4707 if (Target->hasAArch64ACLETypes()) {
4710#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4711 ElBits, NF, IsSigned) \
4712 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4713 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4714 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4715 return ScalableVecTyMap[K] = SingletonId; \
4717#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4719 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4720 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4721 return ScalableVecTyMap[K] = SingletonId; \
4723#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4725 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4726 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4727 return ScalableVecTyMap[K] = SingletonId; \
4729#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4731 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4732 NumElts == (NumEls * NF) && NumFields == 1) { \
4733 return ScalableVecTyMap[K] = SingletonId; \
4735#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4736 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4737 return ScalableVecTyMap[K] = SingletonId;
4738#include "clang/Basic/AArch64ACLETypes.def"
4739 }
else if (Target->hasRISCVVTypes()) {
4741#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4743 if (!EltTy->isBooleanType() && \
4744 ((EltTy->hasIntegerRepresentation() && \
4745 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4746 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4748 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4749 IsBF && !IsFP)) && \
4750 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4751 return ScalableVecTyMap[K] = SingletonId;
4752#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4753 if (EltTy->isBooleanType() && NumElts == NumEls) \
4754 return ScalableVecTyMap[K] = SingletonId;
4755#include "clang/Basic/RISCVVTypes.def"
4770 llvm::FoldingSetNodeID ID;
4773 llvm::FoldingSetInsertToken
Token;
4785 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4788 VectorType(vecType, NumElts, Canonical, VecKind);
4790 Types.push_back(
New);
4797 llvm::FoldingSetNodeID ID;
4800 llvm::FoldingSetInsertToken
Token;
4806 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4809 if (CanonVecTy == VecType) {
4814 assert(!CanonCheck &&
4815 "Dependent-sized vector_size canonical type broken");
4817 DependentVectorTypes.insert(
New,
Token);
4826 Types.push_back(
New);
4833 unsigned NumElts)
const {
4840 llvm::FoldingSetNodeID ID;
4843 llvm::FoldingSetInsertToken
Token;
4855 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4860 Types.push_back(
New);
4868 llvm::FoldingSetNodeID ID;
4872 llvm::FoldingSetInsertToken
Token;
4874 DependentSizedExtVectorTypes.lookup(ID,
Token);
4884 if (CanonVecTy == vecType) {
4889 DependentSizedExtVectorTypes.lookup(ID,
Token);
4890 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4892 DependentSizedExtVectorTypes.insert(
New,
Token);
4901 Types.push_back(
New);
4906 QualType ElementTy,
unsigned NumRows,
unsigned NumColumns,
4907 std::optional<MatrixType::LayoutKind> Layout)
const {
4908 llvm::FoldingSetNodeID ID;
4910 Type::ConstantMatrix);
4913 "need a valid element type");
4914 assert(NumRows > 0 && NumRows <= LangOpts.MaxMatrixDimension &&
4915 NumColumns > 0 && NumColumns <= LangOpts.MaxMatrixDimension &&
4916 "need valid matrix dimensions");
4917 llvm::FoldingSetInsertToken
Token;
4924 NumColumns, std::nullopt);
4927 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4934 Types.push_back(
New);
4943 llvm::FoldingSetNodeID ID;
4947 llvm::FoldingSetInsertToken
Token;
4953 ColumnExpr, AttrLoc);
4956 DependentSizedMatrixTypes.lookup(ID,
Token);
4957 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4959 DependentSizedMatrixTypes.insert(Canon,
Token);
4960 Types.push_back(Canon);
4973 ColumnExpr, AttrLoc);
4974 Types.push_back(
New);
4982 const Type *Ty =
T->getUnqualifiedDesugaredType();
4984 if (
const auto *MT = dyn_cast<ConstantMatrixType>(Ty))
4987 MT->getNumColumns(), Layout),
4990 const auto *CAT = dyn_cast<ConstantArrayType>(Ty);
4996 CAT->getSizeExpr(), CAT->getSizeModifier(),
4997 CAT->getIndexTypeCVRQualifiers());
5005 Expr *AddrSpaceExpr,
5011 llvm::FoldingSetInsertToken
Token;
5012 llvm::FoldingSetNodeID ID;
5017 DependentAddressSpaceTypes.lookup(ID,
Token);
5023 DependentAddressSpaceTypes.insert(canonTy,
Token);
5024 Types.push_back(canonTy);
5027 if (canonPointeeType == PointeeType &&
5033 AddrSpaceExpr, AttrLoc);
5034 Types.push_back(sugaredType);
5040 return T.isCanonical() &&
5058 llvm::FoldingSetNodeID ID;
5061 llvm::FoldingSetInsertToken
Token;
5072 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5077 Types.push_back(
New);
5078 FunctionNoProtoTypes.insert(
New,
Token);
5094 return CanResultType;
5101 if (!NoexceptInType)
5118 bool AnyPackExpansions =
false;
5122 if (ET->
getAs<PackExpansionType>())
5123 AnyPackExpansions =
true;
5125 return AnyPackExpansions;
5131QualType ASTContext::getFunctionTypeInternal(
5132 QualType ResultTy, ArrayRef<QualType> ArgArray,
5133 const FunctionProtoType::ExtProtoInfo &EPI,
bool OnlyWantCanonical)
const {
5134 size_t NumArgs = ArgArray.size();
5138 llvm::FoldingSetNodeID
ID;
5143 bool Unique =
false;
5145 llvm::FoldingSetInsertToken Token;
5146 if (FunctionProtoType *FPT = FunctionProtoTypes.lookup(ID, Token)) {
5147 QualType Existing = QualType(FPT, 0);
5166 bool IsCanonicalExceptionSpec =
5170 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
5172 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
5173 if (!ArgArray[i].isCanonicalAsParam())
5174 isCanonical =
false;
5176 if (OnlyWantCanonical)
5177 assert(isCanonical &&
5178 "given non-canonical parameters constructing canonical type");
5183 if (!isCanonical && Canonical.
isNull()) {
5184 SmallVector<QualType, 16> CanonicalArgs;
5185 CanonicalArgs.reserve(NumArgs);
5186 for (
unsigned i = 0; i != NumArgs; ++i)
5189 llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
5190 FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
5193 if (IsCanonicalExceptionSpec) {
5195 }
else if (NoexceptInType) {
5208 bool AnyPacks =
false;
5210 if (ET->
getAs<PackExpansionType>())
5231 llvm_unreachable(
"dependent noexcept is already canonical");
5234 CanonicalEPI.
ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
5240 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5243 FunctionProtoType *NewIP = FunctionProtoTypes.lookup(ID, Token);
5244 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5249 auto ESH = FunctionProtoType::getExceptionSpecSize(
5251 size_t Size = FunctionProtoType::totalSizeToAlloc<
5252 QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
5253 FunctionType::FunctionTypeExtraAttributeInfo,
5254 FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
5255 Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, Qualifiers,
5256 FunctionEffect, EffectConditionExpr>(
5260 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5265 auto *FTP = (FunctionProtoType *)
Allocate(Size,
alignof(FunctionProtoType));
5266 FunctionProtoType::ExtProtoInfo newEPI = EPI;
5267 new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
5268 Types.push_back(FTP);
5270 FunctionProtoTypes.insert(FTP, Token);
5272 AnyFunctionEffects =
true;
5273 return QualType(FTP, 0);
5276QualType ASTContext::getPipeType(QualType
T,
bool ReadOnly)
const {
5277 llvm::FoldingSetInsertToken Token;
5278 if (PipeType *PT = PipeTypes.lookup({T, ReadOnly}, Token))
5279 return QualType(PT, 0);
5284 if (!
T.isCanonical()) {
5287 assert(!PipeTypes.lookup({T, ReadOnly}, Token) &&
5288 "Shouldn't be in the map!");
5290 auto *
New =
new (*
this,
alignof(PipeType)) PipeType(
T, Canonical, ReadOnly);
5291 Types.push_back(
New);
5292 PipeTypes.insert(
New, Token);
5293 return QualType(
New, 0);
5303 return getPipeType(
T,
true);
5307 return getPipeType(
T,
false);
5311 auto Key = std::make_pair(
unsigned(IsUnsigned), NumBits);
5313 llvm::FoldingSetInsertToken
Token;
5319 Types.push_back(
New);
5324 Expr *NumBitsExpr)
const {
5326 llvm::FoldingSetNodeID ID;
5329 llvm::FoldingSetInsertToken
Token;
5335 DependentBitIntTypes.insert(
New,
Token);
5337 Types.push_back(
New);
5345 if (
auto *Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5357 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5358 case Kind::SignedSizeT:
5360 case Kind::PtrdiffT:
5363 llvm_unreachable(
"unexpected kind");
5368 Types.push_back(
New);
5369 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5376 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5379 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5381 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5390 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5392 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5394 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5396 assert(TD->TypeForDecl);
5401 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5403 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5404 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5407 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5410 assert(
Decl->TypeForDecl);
5420 std::optional<bool> TypeMatchesDeclOrNone)
const {
5421 if (!TypeMatchesDeclOrNone) {
5422 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5423 assert(!DeclUnderlyingType.
isNull());
5424 if (UnderlyingType.
isNull())
5425 UnderlyingType = DeclUnderlyingType;
5427 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5428 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5432 assert(!UnderlyingType.
isNull());
5436 *TypeMatchesDeclOrNone) {
5437 if (
Decl->TypeForDecl)
5442 !*TypeMatchesDeclOrNone);
5444 Types.push_back(NewType);
5445 Decl->TypeForDecl = NewType;
5449 llvm::FoldingSetNodeID ID;
5451 *TypeMatchesDeclOrNone ?
QualType() : UnderlyingType);
5453 llvm::FoldingSetInsertToken
Token;
5455 TypedefTypes.lookup(ID,
Token))
5456 return QualType(Placeholder->getType(), 0);
5461 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5465 UnderlyingType, !*TypeMatchesDeclOrNone);
5466 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5468 TypedefTypes.insert(Placeholder,
Token);
5469 Types.push_back(NewType);
5478 if (UnderlyingType.
isNull()) {
5486 llvm::FoldingSetNodeID ID;
5489 llvm::FoldingSetInsertToken
Token;
5500 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5504 UsingTypes.insert(
T,
Token);
5510 const TagDecl *TD,
bool OwnsTag,
5512 const Type *CanonicalType,
5513 bool WithFoldingSetNode)
const {
5514 auto [TC, Size] = [&] {
5517 static_assert(
alignof(EnumType) ==
alignof(TagType));
5518 return std::make_tuple(Type::Enum,
sizeof(EnumType));
5519 case Decl::ClassTemplatePartialSpecialization:
5520 case Decl::ClassTemplateSpecialization:
5521 case Decl::CXXRecord:
5522 static_assert(
alignof(RecordType) ==
alignof(TagType));
5523 static_assert(
alignof(InjectedClassNameType) ==
alignof(TagType));
5525 return std::make_tuple(Type::InjectedClassName,
5526 sizeof(InjectedClassNameType));
5529 return std::make_tuple(Type::Record,
sizeof(RecordType));
5531 llvm_unreachable(
"unexpected decl kind");
5541 if (WithFoldingSetNode) {
5549 sizeof(TagTypeFoldingSetPlaceholder) +
5550 TagTypeFoldingSetPlaceholder::getOffset() + Size,
5551 std::max(
alignof(TagTypeFoldingSetPlaceholder),
alignof(TagType)));
5552 auto *
T =
new (Mem) TagTypeFoldingSetPlaceholder();
5553 Mem =
T->getTagType();
5555 Mem =
Allocate(Size,
alignof(TagType));
5558 auto *
T = [&, TC = TC]() -> TagType * {
5562 auto *
T =
new (Mem) EnumType(TC,
Keyword, Qualifier, TD, OwnsTag,
5563 IsInjected, CanonicalType);
5564 assert(
reinterpret_cast<void *
>(
T) ==
5565 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5566 "TagType must be the first base of EnumType");
5569 case Type::Record: {
5571 auto *
T =
new (Mem) RecordType(TC,
Keyword, Qualifier, TD, OwnsTag,
5572 IsInjected, CanonicalType);
5573 assert(
reinterpret_cast<void *
>(
T) ==
5574 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5575 "TagType must be the first base of RecordType");
5578 case Type::InjectedClassName: {
5579 auto *
T =
new (Mem) InjectedClassNameType(
Keyword, Qualifier, TD,
5580 IsInjected, CanonicalType);
5581 assert(
reinterpret_cast<void *
>(
T) ==
5582 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5583 "TagType must be the first base of InjectedClassNameType");
5587 llvm_unreachable(
"unexpected type class");
5590 assert(
T->getKeyword() ==
Keyword);
5591 assert(
T->getQualifier() == Qualifier);
5592 assert(
T->getDecl() == TD);
5593 assert(
T->isInjected() == IsInjected);
5594 assert(
T->isTagOwned() == OwnsTag);
5603 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5604 RD && RD->isInjectedClassName())
5611 if (TD->TypeForDecl)
5612 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5614 const Type *CanonicalType = getTagTypeInternal(
5617 false,
false,
nullptr,
5619 TD->TypeForDecl = CanonicalType;
5625 const TagDecl *TD,
bool OwnsTag)
const {
5628 bool IsInjected = TD != NonInjectedTD;
5635 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5636 if (
const Type *
T = TD->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5642 std::nullopt, NonInjectedTD,
5643 false, IsInjected, CanonicalType,
5645 TD->TypeForDecl =
T;
5649 llvm::FoldingSetNodeID ID;
5650 TagTypeFoldingSetPlaceholder::Profile(ID,
Keyword, Qualifier, NonInjectedTD,
5651 OwnsTag, IsInjected);
5653 llvm::FoldingSetInsertToken
Token;
5654 if (TagTypeFoldingSetPlaceholder *
T = TagTypes.lookup(ID,
Token))
5659 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5660 CanonicalType,
true);
5661 TagTypes.insert(TagTypeFoldingSetPlaceholder::fromTagType(
T),
Token);
5666 unsigned NumPositiveBits,
5669 unsigned IntWidth = Target->getIntWidth();
5670 unsigned CharWidth = Target->getCharWidth();
5671 unsigned ShortWidth = Target->getShortWidth();
5672 bool EnumTooLarge =
false;
5674 if (NumNegativeBits) {
5678 if (IsPacked && NumNegativeBits <= CharWidth &&
5679 NumPositiveBits < CharWidth) {
5681 BestWidth = CharWidth;
5682 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5683 NumPositiveBits < ShortWidth) {
5685 BestWidth = ShortWidth;
5686 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5688 BestWidth = IntWidth;
5690 BestWidth = Target->getLongWidth();
5692 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5695 BestWidth = Target->getLongLongWidth();
5697 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5698 EnumTooLarge =
true;
5702 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5707 if (IsPacked && NumPositiveBits <= CharWidth) {
5709 BestPromotionType =
IntTy;
5710 BestWidth = CharWidth;
5711 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5713 BestPromotionType =
IntTy;
5714 BestWidth = ShortWidth;
5715 }
else if (NumPositiveBits <= IntWidth) {
5717 BestWidth = IntWidth;
5718 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5721 }
else if (NumPositiveBits <= (BestWidth = Target->getLongWidth())) {
5723 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5727 BestWidth = Target->getLongLongWidth();
5728 if (NumPositiveBits > BestWidth) {
5733 EnumTooLarge =
true;
5736 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5741 return EnumTooLarge;
5745 assert((
T->isIntegralType(*
this) ||
T->isEnumeralType()) &&
5746 "Integral type required!");
5749 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5750 if (
T->isSignedIntegerOrEnumerationType())
5752 return Value.getActiveBits() <= BitWidth;
5754 return Value.getSignificantBits() <= BitWidth;
5760 const Type *CanonicalType)
const {
5762 UnresolvedUsingType::totalSizeToAlloc<
5764 !!
Token, !!Qualifier),
5768 auto *Placeholder =
new (
T->getFoldingSetPlaceholder())
5770 UnresolvedUsingTypes.insert(Placeholder,
Token);
5780 return D->TypeForDecl->getCanonicalTypeUnqualified();
5782 const Type *CanonicalType =
5786 D->TypeForDecl = CanonicalType;
5795 if (
const Type *
T = D->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5807 llvm::FoldingSetNodeID ID;
5810 llvm::FoldingSetInsertToken
Token;
5812 UnresolvedUsingTypes.lookup(ID,
Token))
5813 return QualType(Placeholder->getType(), 0);
5826 llvm::FoldingSetNodeID id;
5827 AttributedType::Profile(
id, *
this, attrKind, modifiedType, equivalentType,
5830 llvm::FoldingSetInsertToken
Token;
5831 AttributedType *
type = AttributedTypes.lookup(
id,
Token);
5834 assert(!
attr ||
attr->getKind() == attrKind);
5837 type =
new (*
this,
alignof(AttributedType))
5838 AttributedType(canon, attrKind,
attr, modifiedType, equivalentType);
5840 Types.push_back(
type);
5854 switch (nullability) {
5870 llvm_unreachable(
"Unknown nullability kind");
5875 llvm::FoldingSetNodeID ID;
5876 BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
5878 llvm::FoldingSetInsertToken
Token;
5879 BTFTagAttributedType *Ty = BTFTagAttributedTypes.lookup(ID,
Token);
5884 Ty =
new (*
this,
alignof(BTFTagAttributedType))
5885 BTFTagAttributedType(Canon, Wrapped, BTFAttr);
5887 Types.push_back(Ty);
5888 BTFTagAttributedTypes.insert(Ty,
Token);
5896 StringRef IdentName = II->
getName();
5897 OverflowBehaviorType::OverflowBehaviorKind Kind;
5898 if (IdentName ==
"wrap") {
5899 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
5900 }
else if (IdentName ==
"trap") {
5901 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
5910 OverflowBehaviorType::OverflowBehaviorKind Kind,
5913 "Cannot have underlying types that are themselves OBTs");
5915 llvm::FoldingSetInsertToken
Token;
5916 if (OverflowBehaviorType *OBT =
5917 OverflowBehaviorTypes.lookup({Underlying, Kind},
Token)) {
5926 assert(!OverflowBehaviorTypes.lookup({Underlying, Kind},
Token) &&
5927 "Shouldn't be in the map");
5930 OverflowBehaviorType *Ty =
new (*
this,
alignof(OverflowBehaviorType))
5931 OverflowBehaviorType(*
this, Canonical, Underlying, Kind);
5933 Types.push_back(Ty);
5934 OverflowBehaviorTypes.insert(Ty,
Token);
5940 const HLSLAttributedResourceType::Attributes &Attrs) {
5942 llvm::FoldingSetNodeID ID;
5943 HLSLAttributedResourceType::Profile(ID, *
this, Wrapped, Contained, Attrs);
5945 llvm::FoldingSetInsertToken
Token;
5946 HLSLAttributedResourceType *Ty =
5947 HLSLAttributedResourceTypes.lookup(ID,
Token);
5951 Ty =
new (*
this,
alignof(HLSLAttributedResourceType))
5952 HLSLAttributedResourceType(Wrapped, Contained, Attrs);
5954 Types.push_back(Ty);
5955 HLSLAttributedResourceTypes.insert(Ty,
Token);
5963 llvm::FoldingSetNodeID ID;
5964 HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
5966 llvm::FoldingSetInsertToken
Token;
5967 HLSLInlineSpirvType *Ty = HLSLInlineSpirvTypes.lookup(ID,
Token);
5972 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5973 alignof(HLSLInlineSpirvType));
5975 Ty =
new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
5977 Types.push_back(Ty);
5978 HLSLInlineSpirvTypes.insert(Ty,
Token);
5985 Decl *AssociatedDecl,
5990 std::make_tuple(Replacement, AssociatedDecl, Index,
5991 PackIndex.toInternalRepresentation(),
unsigned(Final));
5992 llvm::FoldingSetInsertToken
Token;
5993 SubstTemplateTypeParmType *SubstParm =
5994 SubstTemplateTypeParmTypes.lookup(Key,
Token);
5997 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5998 !Replacement.isCanonical()),
5999 alignof(SubstTemplateTypeParmType));
6000 SubstParm =
new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
6002 Types.push_back(SubstParm);
6003 SubstTemplateTypeParmTypes.insert(SubstParm,
Token);
6011 unsigned Index,
bool Final,
6018 llvm::FoldingSetNodeID ID;
6019 SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
6021 llvm::FoldingSetInsertToken
Token;
6022 if (SubstTemplateTypeParmPackType *SubstParm =
6023 SubstTemplateTypeParmPackTypes.lookup(ID,
Token))
6033 [[maybe_unused]]
const auto *Nothing =
6034 SubstTemplateTypeParmPackTypes.lookup(ID,
Token);
6039 auto *SubstParm =
new (*
this,
alignof(SubstTemplateTypeParmPackType))
6040 SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
6042 Types.push_back(SubstParm);
6043 SubstTemplateTypeParmPackTypes.insert(SubstParm,
Token);
6051 return P.getKind() == TemplateArgument::Type;
6053 "Pack contains a non-type");
6055 llvm::FoldingSetNodeID ID;
6056 SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
6058 llvm::FoldingSetInsertToken
Token;
6059 if (
auto *
T = SubstBuiltinTemplatePackTypes.lookup(ID,
Token))
6068 [[maybe_unused]]
const auto *Nothing =
6069 SubstBuiltinTemplatePackTypes.lookup(ID,
Token);
6073 auto *PackType =
new (*
this,
alignof(SubstBuiltinTemplatePackType))
6074 SubstBuiltinTemplatePackType(Canon, ArgPack);
6075 Types.push_back(PackType);
6076 SubstBuiltinTemplatePackTypes.insert(PackType,
Token);
6086 assert(Depth >= 0 &&
"Depth must be non-negative");
6087 assert(Index >= 0 &&
"Index must be non-negative");
6089 auto Key = std::make_tuple(
unsigned(Depth),
unsigned(Index),
6090 unsigned(ParameterPack), TTPDecl);
6091 llvm::FoldingSetInsertToken
Token;
6092 TemplateTypeParmType *TypeParm = TemplateTypeParmTypes.lookup(Key,
Token);
6099 TypeParm =
new (*
this,
alignof(TemplateTypeParmType))
6100 TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
6102 TypeParm =
new (*
this,
alignof(TemplateTypeParmType)) TemplateTypeParmType(
6103 Depth, Index, ParameterPack,
nullptr,
QualType());
6105 Types.push_back(TypeParm);
6106 TemplateTypeParmTypes.insert(TypeParm,
Token);
6132 llvm_unreachable(
"unexpected keyword kind");
6146 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
6156 SpecifiedArgVec.reserve(SpecifiedArgs.size());
6158 SpecifiedArgVec.push_back(Arg.getArgument());
6161 CanonicalArgs, Underlying);
6164[[maybe_unused]]
static bool
6167 if (Arg.isPackExpansion())
6178 Template.getAsDependentTemplateName()));
6180 for (
const auto &Arg : Args)
6184 llvm::FoldingSetNodeID ID;
6187 llvm::FoldingSetInsertToken
Token;
6188 if (
auto *
T = TemplateSpecializationTypes.lookup(ID,
Token))
6191 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6193 alignof(TemplateSpecializationType));
6197 assert(Spec->isDependentType() &&
6198 "canonical template specialization must be dependent");
6199 Types.push_back(Spec);
6200 TemplateSpecializationTypes.insert(Spec,
Token);
6208 const auto *TD =
Template.getAsTemplateDecl(
true);
6209 bool IsTypeAlias = TD && TD->isTypeAlias();
6210 if (Underlying.
isNull()) {
6217 bool NonCanonical =
Template != CanonTemplate ||
Keyword != CanonKeyword;
6219 if (CanonicalArgs.empty()) {
6222 CanonicalArgs = CanonArgsVec;
6224 NonCanonical |= !llvm::equal(
6225 SpecifiedArgs, CanonicalArgs,
6234 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
6236 "Caller must compute aliased type");
6237 IsTypeAlias =
false;
6240 CanonKeyword, CanonTemplate, CanonicalArgs);
6244 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6246 (IsTypeAlias ?
sizeof(
QualType) : 0),
6247 alignof(TemplateSpecializationType));
6248 auto *Spec =
new (Mem) TemplateSpecializationType(
6250 Types.push_back(Spec);
6256 llvm::FoldingSetInsertToken
Token;
6264 assert(!ParenTypes.lookup(InnerType,
Token) &&
6265 "Paren canonical type broken");
6270 ParenTypes.insert(
T,
Token);
6283 Types.push_back(newType);
6290 llvm::FoldingSetNodeID ID;
6291 DependentNameType::Profile(ID,
Keyword, NNS, Name);
6293 llvm::FoldingSetInsertToken
Token;
6294 if (DependentNameType *
T = DependentNameTypes.lookup(ID,
Token))
6302 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6304 [[maybe_unused]] DependentNameType *
T =
6305 DependentNameTypes.lookup(ID,
Token);
6306 assert(!
T &&
"broken canonicalization");
6310 DependentNameType *
T =
new (*
this,
alignof(DependentNameType))
6311 DependentNameType(
Keyword, NNS, Name, Canon);
6313 DependentNameTypes.insert(
T,
Token);
6319 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6321 if (TTP->isParameterPack())
6325 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6327 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6333 if (
T->isRecordType()) {
6342 Expr *E =
new (*this)
6344 T,
VK, NTTP->getLocation());
6346 if (NTTP->isParameterPack())
6352 std::nullopt,
false,
6354 if (TTP->isParameterPack())
6360 if (Param->isTemplateParameterPack())
6369 bool ExpectPackInType)
const {
6371 "Pack expansions must expand one or more parameter packs");
6375 llvm::FoldingSetInsertToken
Token;
6376 PackExpansionType *
T = PackExpansionTypes.lookup(Key,
Token);
6387 PackExpansionTypes.lookup(Key,
Token);
6390 T =
new (*
this,
alignof(PackExpansionType))
6391 PackExpansionType(Pattern, Canon, NumExpansions);
6393 PackExpansionTypes.insert(
T,
Token);
6405 if (Protocols.empty())
return true;
6410 for (
unsigned i = 1; i != Protocols.size(); ++i)
6420 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6424 P = P->getCanonicalDecl();
6427 auto ProtocolsEnd = llvm::unique(Protocols);
6428 Protocols.erase(ProtocolsEnd, Protocols.end());
6433 unsigned NumProtocols)
const {
6442 bool isKindOf)
const {
6445 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6450 llvm::FoldingSetNodeID ID;
6451 ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
6452 llvm::FoldingSetInsertToken
Token;
6460 if (effectiveTypeArgs.empty()) {
6462 effectiveTypeArgs = baseObject->getTypeArgs();
6469 bool typeArgsAreCanonical = llvm::all_of(
6472 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6476 if (!typeArgsAreCanonical) {
6477 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6478 for (
auto typeArg : effectiveTypeArgs)
6480 canonTypeArgs = canonTypeArgsVec;
6482 canonTypeArgs = effectiveTypeArgs;
6487 if (!protocolsSorted) {
6488 canonProtocolsVec.append(protocols.begin(), protocols.end());
6490 canonProtocols = canonProtocolsVec;
6492 canonProtocols = protocols;
6496 canonProtocols, isKindOf);
6499 ObjCObjectTypes.lookup(ID,
Token);
6502 unsigned size =
sizeof(ObjCObjectTypeImpl);
6503 size += typeArgs.size() *
sizeof(
QualType);
6505 void *mem =
Allocate(size,
alignof(ObjCObjectTypeImpl));
6507 new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
6511 ObjCObjectTypes.insert(
T,
Token);
6521 bool allowOnPointerType)
const {
6524 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6529 if (allowOnPointerType) {
6530 if (
const auto *objPtr =
6531 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6535 protocolsVec.append(objT->qual_begin(),
6537 protocolsVec.append(protocols.begin(), protocols.end());
6540 objT->getBaseType(),
6541 objT->getTypeArgsAsWritten(),
6543 objT->isKindOfTypeAsWritten());
6549 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6554 objT->getTypeArgsAsWritten(),
6556 objT->isKindOfTypeAsWritten());
6560 if (
type->isObjCObjectType()) {
6570 if (
type->isObjCIdType()) {
6573 objPtr->isKindOfType());
6578 if (
type->isObjCClassType()) {
6581 objPtr->isKindOfType());
6594 if (!protocols.empty()) {
6598 Canonical, protocols, hasError,
true ));
6599 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6604 auto Key = std::make_tuple(
Decl, Canonical, protocols);
6605 llvm::FoldingSetInsertToken
Token;
6606 if (ObjCTypeParamType *TypeParam = ObjCTypeParamTypes.lookup(Key,
Token))
6609 unsigned size =
sizeof(ObjCTypeParamType);
6611 void *mem =
Allocate(size,
alignof(ObjCTypeParamType));
6612 auto *newType =
new (mem) ObjCTypeParamType(
Decl, Canonical, protocols);
6614 Types.push_back(newType);
6615 ObjCTypeParamTypes.insert(newType,
Token);
6625 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6640 for (
auto *Proto : OPT->quals()) {
6663 if (InheritedProtocols.empty())
6667 bool Conforms =
false;
6668 for (
auto *Proto : OPT->quals()) {
6670 for (
auto *PI : InheritedProtocols) {
6682 for (
auto *PI : InheritedProtocols) {
6684 bool Adopts =
false;
6685 for (
auto *Proto : OPT->quals()) {
6699 llvm::FoldingSetInsertToken
Token;
6714 Types.push_back(QType);
6715 ObjCObjectPointerTypes.insert(QType,
Token);
6723 if (
Decl->TypeForDecl)
6727 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6728 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6729 return QualType(PrevDecl->TypeForDecl, 0);
6738 Decl->TypeForDecl =
T;
6751 llvm::FoldingSetNodeID ID;
6755 llvm::FoldingSetInsertToken
Token;
6766 DependentTypeOfExprTypes.insert(Canon,
Token);
6774 Types.push_back(toe);
6785 auto *tot =
new (*
this,
alignof(TypeOfType))
6786 TypeOfType(*
this, tofType, Canonical, Kind);
6787 Types.push_back(tot);
6811 llvm_unreachable(
"Unknown value kind");
6826 }
else if (!UnderlyingType.
isNull()) {
6829 llvm::FoldingSetNodeID ID;
6830 DependentDecltypeType::Profile(ID, *
this, E);
6832 llvm::FoldingSetInsertToken
Token;
6833 if (DependentDecltypeType *Canon = DependentDecltypeTypes.lookup(ID,
Token))
6838 new (*
this,
alignof(DependentDecltypeType)) DependentDecltypeType(E);
6839 DependentDecltypeTypes.insert(DT,
Token);
6840 Types.push_back(DT);
6843 auto *DT =
new (*
this,
alignof(DecltypeType))
6844 DecltypeType(E, UnderlyingType, CanonType);
6845 Types.push_back(DT);
6850 bool FullySubstituted,
6854 if (FullySubstituted && Index) {
6857 llvm::FoldingSetNodeID ID;
6858 PackIndexingType::Profile(ID, *
this, Pattern.
getCanonicalType(), IndexExpr,
6859 FullySubstituted, Expansions);
6860 llvm::FoldingSetInsertToken
Token;
6861 PackIndexingType *Canon = DependentPackIndexingTypes.lookup(ID,
Token);
6864 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6868 IndexExpr, FullySubstituted, Expansions);
6869 DependentPackIndexingTypes.insert(Canon,
Token);
6875 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6877 auto *
T =
new (Mem) PackIndexingType(Canonical, Pattern, IndexExpr,
6878 FullySubstituted, Expansions);
6887 UnaryTransformType::UTTKind Kind)
const {
6890 if (BaseType->isDependentType()) {
6891 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6895 auto Key = std::make_tuple(BaseType, UnderlyingType, Kind);
6897 llvm::FoldingSetInsertToken
Token;
6898 if (UnaryTransformType *UT = UnaryTransformTypes.lookup(Key,
Token))
6902 if (!BaseType->isDependentType()) {
6906 BaseType != CanonBase) {
6912 auto *UT =
new (*
this,
alignof(UnaryTransformType))
6913 UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
6914 UnaryTransformTypes.insert(UT,
Token);
6915 Types.push_back(UT);
6928 TypeConstraintConcept.
isNull()) {
6929 assert(DeducedAsType.
isNull() &&
"");
6930 assert(TypeConstraintArgs.empty() &&
"");
6935 llvm::FoldingSetNodeID ID;
6936 AutoType::Profile(ID, *
this, DK, DeducedAsType,
Keyword,
6937 TypeConstraintConcept, TypeConstraintArgs);
6938 if (
auto const AT_iter = AutoTypes.find_as(ID); AT_iter != AutoTypes.end())
6939 return QualType(AT_iter->getSecond(), 0);
6942 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6944 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6945 if (!TypeConstraintConcept.
isNull()) {
6946 bool AnyNonCanonArgs =
false;
6950 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6951 if (TypeConstraintConcept != CanonicalConcept || AnyNonCanonArgs)
6953 CanonicalConceptArgs);
6957 void *Mem =
Allocate(
sizeof(AutoType) +
6960 auto *AT =
new (Mem) AutoType(DK, DeducedAsType,
Keyword,
6961 TypeConstraintConcept, TypeConstraintArgs);
6963 llvm::FoldingSetNodeID InsertedID;
6964 AT->Profile(InsertedID, *
this);
6965 assert(InsertedID == ID &&
"ID does not match");
6967 Types.push_back(AT);
6968 AutoTypes.try_emplace(ID.Intern(BumpAlloc), AT);
6973 QualType CanonT =
T.getNonPackExpansionType().getCanonicalType();
6976 if (
auto *AT = CanonT->
getAs<AutoType>()) {
6977 if (!AT->isConstrained())
6999 llvm::FoldingSetInsertToken
Token;
7000 llvm::FoldingSetNodeID ID;
7001 DeducedTemplateSpecializationType::Profile(ID, DK, DeducedAsType,
Keyword,
7003 if (DeducedTemplateSpecializationType *DTST =
7004 DeducedTemplateSpecializationTypes.lookup(ID,
Token))
7008 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
7010 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
7019 [[maybe_unused]] DeducedTemplateSpecializationType *DTST =
7020 DeducedTemplateSpecializationTypes.lookup(ID,
Token);
7021 assert(!DTST &&
"broken canonicalization");
7025 auto *DTST =
new (*
this,
alignof(DeducedTemplateSpecializationType))
7026 DeducedTemplateSpecializationType(DK, DeducedAsType,
Keyword,
Template);
7029 llvm::FoldingSetNodeID TempID;
7030 DTST->Profile(TempID);
7031 assert(ID == TempID &&
"ID does not match");
7033 Types.push_back(DTST);
7034 DeducedTemplateSpecializationTypes.insert(DTST,
Token);
7043 llvm::FoldingSetInsertToken
Token;
7050 if (!
T.isCanonical()) {
7053 assert(!AtomicTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
7056 Types.push_back(
New);
7065 new (*
this,
alignof(AutoType))
7089 return getFromTargetType(Target->getSizeType());
7108 return getFromTargetType(Target->getUnsignedPtrDiffType(
LangAS::Default));
7113 return getFromTargetType(Target->getIntMaxType());
7118 return getFromTargetType(Target->getUIntMaxType());
7136 return getFromTargetType(Target->getIntPtrType());
7146 return getFromTargetType(Target->getProcessIDType());
7158 const Type *Ty =
T.getTypePtr();
7186 quals = splitType.
Quals;
7191 QualType elementType = AT->getElementType();
7196 if (elementType == unqualElementType) {
7197 assert(quals.
empty());
7198 quals = splitType.
Quals;
7206 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7208 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7211 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7215 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7217 VAT->getSizeModifier(),
7218 VAT->getIndexTypeCVRQualifiers());
7223 DSAT->getSizeModifier(), 0);
7233 bool AllowPiMismatch)
const {
7248 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7249 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7250 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7263 T1 = AT1->getElementType();
7264 T2 = AT2->getElementType();
7284 bool AllowPiMismatch)
const {
7289 if (T1PtrType && T2PtrType) {
7297 T1MPType && T2MPType) {
7300 if (T1MPType->getQualifier() != T2MPType->getQualifier())
7312 if (T1OPType && T2OPType) {
7344 if (Quals1 != Quals2)
7418 llvm_unreachable(
"bad template name kind!");
7424 if (!TP->hasDefaultArgument())
7426 return &TP->getDefaultArgument().getArgument();
7429 case NamedDecl::TemplateTypeParm:
7431 case NamedDecl::NonTypeTemplateParm:
7433 case NamedDecl::TemplateTemplateParm:
7436 llvm_unreachable(
"Unexpected template parameter kind");
7441 bool IgnoreDeduced)
const {
7442 while (std::optional<TemplateName> UnderlyingOrNone =
7444 Name = *UnderlyingOrNone;
7449 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7461 llvm_unreachable(
"cannot canonicalize overloaded template");
7465 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7494 assert(IgnoreDeduced ==
false);
7501 bool NonCanonical = CanonUnderlying != Underlying;
7507 assert(CanonArgs.size() <= Params.size());
7513 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7522 if (I ==
int(CanonArgs.size() - 1))
7523 CanonArgs.pop_back();
7524 NonCanonical =
true;
7534 llvm_unreachable(
"always sugar node");
7537 llvm_unreachable(
"bad template name!");
7542 bool IgnoreDeduced)
const {
7563 llvm::FoldingSetNodeID XCEID, YCEID;
7564 XCE->
Profile(XCEID, *
this,
true,
true);
7565 YCE->
Profile(YCEID, *
this,
true,
true);
7566 return XCEID == YCEID;
7615 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7617 if (TX->isParameterPack() != TY->isParameterPack())
7619 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7622 TY->getTypeConstraint());
7625 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7627 return TX->isParameterPack() == TY->isParameterPack() &&
7628 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7630 TY->getPlaceholderTypeConstraint());
7635 return TX->isParameterPack() == TY->isParameterPack() &&
7637 TY->getTemplateParameters());
7642 if (
X->size() != Y->
size())
7645 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7659 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7661 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7664 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7665 TTPY->getDefaultArgument().getArgument().getAsType());
7668 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7670 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7673 Expr *DefaultArgumentX =
7674 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7675 Expr *DefaultArgumentY =
7676 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7677 llvm::FoldingSetNodeID XID, YID;
7678 DefaultArgumentX->
Profile(XID, *
this,
true);
7679 DefaultArgumentY->
Profile(YID, *
this,
true);
7686 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7701 auto Kind =
X.getKind();
7709 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7712 NamespaceY->getNamespace()))
7717 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7718 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7727 llvm_unreachable(
"unhandled qualifier kind");
7733 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7735 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7747 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7751 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7752 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7753 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7756 if (!Cand1A || !Cand2A)
7762 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7763 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7767 if (Cand1ID != Cand2ID)
7801 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7802 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7804 TypedefY->getUnderlyingType());
7821 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7823 return (TagX->getTagKind() == TagY->getTagKind()) ||
7835 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7837 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7839 if (CtorX->getInheritedConstructor() &&
7840 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7841 CtorY->getInheritedConstructor().getConstructor()))
7845 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7850 if (FuncX->isMultiVersion()) {
7851 const auto *TAX = FuncX->getAttr<TargetAttr>();
7852 const auto *TAY = FuncY->getAttr<TargetAttr>();
7853 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7855 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7861 if ((FuncX->isMemberLikeConstrainedFriend() ||
7862 FuncY->isMemberLikeConstrainedFriend()) &&
7863 !FuncX->getLexicalDeclContext()->Equals(
7864 FuncY->getLexicalDeclContext())) {
7869 FuncY->getTrailingRequiresClause()))
7877 FD = FD->getCanonicalDecl();
7878 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7881 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7896 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7901 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7903 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7906 if (VarX->getType().isNull() || VarY->getType().isNull())
7909 if (
hasSameType(VarX->getType(), VarY->getType()))
7919 if (!VarXTy || !VarYTy)
7928 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7930 return NamespaceX->isInline() == NamespaceY->isInline();
7935 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7939 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7942 ConceptY->getConstraintExpr()))
7947 TemplateY->getTemplatedDecl()) &&
7949 TemplateY->getTemplateParameters());
7953 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7956 return hasSameType(FDX->getType(), FDY->getType());
7960 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7962 return IFDX->getAnonField()->getCanonicalDecl() ==
7963 IFDY->getAnonField()->getCanonicalDecl();
7972 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7979 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7982 UX->hasTypename() == UY->hasTypename() &&
7983 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7985 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7988 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7990 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7998 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
8000 UX->getInstantiatedFromUsingDecl(),
8005 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
8007 return NAX->getNamespace()->Equals(NAY->getNamespace());
8010 if (
const auto *UX = dyn_cast<UsingEnumDecl>(
X)) {
8061 bool AnyNonCanonArgs =
false;
8064 if (!AnyNonCanonArgs)
8074 llvm_unreachable(
"Unhandled template argument kind");
8084 llvm_unreachable(
"Comparing NULL template argument");
8109 llvm::FoldingSetNodeID ID1, ID2;
8119 return isSameTemplateArgument(Arg1, Arg2);
8123 llvm_unreachable(
"Unhandled template argument kind");
8128 if (!
T.hasLocalQualifiers()) {
8130 if (
const auto *AT = dyn_cast<ArrayType>(
T))
8150 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
8151 if (!ATy || qs.
empty())
8158 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
8161 CAT->getSizeModifier(),
8162 CAT->getIndexTypeCVRQualifiers()));
8163 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
8165 IAT->getSizeModifier(),
8166 IAT->getIndexTypeCVRQualifiers()));
8168 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
8170 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
8171 DSAT->getIndexTypeCVRQualifiers()));
8176 VAT->getIndexTypeCVRQualifiers()));
8184 if (
T->isArrayType() ||
T->isFunctionType())
8192 return T.getUnqualifiedType();
8203 if (
T->isArrayType() ||
T->isFunctionType())
8205 return T.getUnqualifiedType();
8220 assert(PrettyArrayType &&
"Not an array type!");
8254 uint64_t ElementCount = 1;
8257 CA = dyn_cast_if_present<ConstantArrayType>(
8260 return ElementCount;
8268 uint64_t ElementCount = 1;
8272 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8275 return ElementCount;
8285 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8287 case BuiltinType::Half:
return HalfRank;
8288 case BuiltinType::Float:
return FloatRank;
8321unsigned ASTContext::getIntegerRank(
const Type *
T)
const {
8322 assert(
T->isCanonicalUnqualified() &&
"T should be canonicalized");
8326 if (
const auto *EIT = dyn_cast<BitIntType>(
T))
8327 return 0 + (EIT->getNumBits() << 3);
8329 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(
T))
8330 return getIntegerRank(OBT->getUnderlyingType().getTypePtr());
8333 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8334 case BuiltinType::Bool:
8336 case BuiltinType::Char_S:
8337 case BuiltinType::Char_U:
8338 case BuiltinType::SChar:
8339 case BuiltinType::UChar:
8341 case BuiltinType::Short:
8342 case BuiltinType::UShort:
8344 case BuiltinType::Int:
8345 case BuiltinType::UInt:
8347 case BuiltinType::Long:
8348 case BuiltinType::ULong:
8350 case BuiltinType::LongLong:
8351 case BuiltinType::ULongLong:
8353 case BuiltinType::Int128:
8354 case BuiltinType::UInt128:
8359 case BuiltinType::Char8:
8361 case BuiltinType::Char16:
8362 return getIntegerRank(
8364 case BuiltinType::Char32:
8365 return getIntegerRank(
8367 case BuiltinType::WChar_S:
8368 case BuiltinType::WChar_U:
8369 return getIntegerRank(
8399 uint64_t BitWidth = Field->getBitWidthValue();
8425 if (BitWidth < IntSize)
8428 if (BitWidth == IntSize)
8443 assert(!Promotable.
isNull());
8446 return ED->getPromotionType();
8450 if (
const auto *OBT = Promotable->
getAs<OverflowBehaviorType>()) {
8463 if (BT->getKind() == BuiltinType::WChar_S ||
8464 BT->getKind() == BuiltinType::WChar_U ||
8465 BT->getKind() == BuiltinType::Char8 ||
8466 BT->getKind() == BuiltinType::Char16 ||
8467 BT->getKind() == BuiltinType::Char32) {
8468 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8472 for (
const auto &PT : PromoteTypes) {
8474 if (FromSize < ToSize ||
8475 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8478 llvm_unreachable(
"char type should fit into long long");
8485 uint64_t PromotableSize =
getIntWidth(Promotable);
8494 while (!
T.isNull()) {
8496 return T.getObjCLifetime();
8497 if (
T->isArrayType())
8500 T = PT->getPointeeType();
8502 T = RT->getPointeeType();
8527 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8529 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8532 if (LHSC == RHSC)
return 0;
8537 unsigned LHSRank = getIntegerRank(LHSC);
8538 unsigned RHSRank = getIntegerRank(RHSC);
8540 if (LHSUnsigned == RHSUnsigned) {
8541 if (LHSRank == RHSRank)
return 0;
8542 return LHSRank > RHSRank ? 1 : -1;
8548 if (LHSRank >= RHSRank)
8558 if (RHSRank >= LHSRank)
8568 if (CFConstantStringTypeDecl)
8569 return CFConstantStringTypeDecl;
8571 assert(!CFConstantStringTagDecl &&
8572 "tag and typedef should be initialized together");
8574 CFConstantStringTagDecl->startDefinition();
8612 if (
static_cast<unsigned>(CFRuntime) <
8615 Fields[Count++] = {
IntTy,
"flags" };
8617 Fields[Count++] = {
LongTy,
"length" };
8621 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()),
"_swift_rc" };
8625 Fields[Count++] = {
IntTy,
"_ptr" };
8631 for (
unsigned i = 0; i < Count; ++i) {
8635 Fields[i].Type,
nullptr,
8638 CFConstantStringTagDecl->addDecl(Field);
8641 CFConstantStringTagDecl->completeDefinition();
8645 CFConstantStringTypeDecl =
8648 return CFConstantStringTypeDecl;
8652 if (!CFConstantStringTagDecl)
8654 return CFConstantStringTagDecl;
8664 if (ObjCSuperType.isNull()) {
8669 return ObjCSuperType;
8675 CFConstantStringTagDecl = TT->castAsRecordDecl();
8679 if (BlockDescriptorType)
8692 static const char *
const FieldNames[] = {
8697 for (
size_t i = 0; i < 2; ++i) {
8700 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8708 BlockDescriptorType = RD;
8714 if (BlockDescriptorExtendedType)
8729 static const char *
const FieldNames[] = {
8736 for (
size_t i = 0; i < 4; ++i) {
8739 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8748 BlockDescriptorExtendedType = RD;
8753 const auto *BT = dyn_cast<BuiltinType>(
T);
8762 switch (BT->getKind()) {
8763#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8764 case BuiltinType::Id: \
8766#include "clang/Basic/OpenCLImageTypes.def"
8768 case BuiltinType::OCLClkEvent:
8771 case BuiltinType::OCLEvent:
8774 case BuiltinType::OCLQueue:
8777 case BuiltinType::OCLReserveID:
8780 case BuiltinType::OCLSampler:
8799 if (!copyExpr && record->hasTrivialDestructor())
return false;
8830 llvm_unreachable(
"impossible");
8832 llvm_unreachable(
"fell out of lifetime switch!");
8840 bool &HasByrefExtendedLayout)
const {
8845 HasByrefExtendedLayout =
false;
8847 HasByrefExtendedLayout =
true;
8861 assert(Target &&
"Expected target to be initialized");
8862 const llvm::Triple &
T = Target->getTriple();
8864 if (
T.isOSWindows() &&
T.isArch64Bit())
8870 assert(Target &&
"Expected target to be initialized");
8871 const llvm::Triple &
T = Target->getTriple();
8873 if (
T.isOSWindows() &&
T.isArch64Bit())
8879 if (!ObjCInstanceTypeDecl)
8880 ObjCInstanceTypeDecl =
8882 return ObjCInstanceTypeDecl;
8888 if (
const auto *TT = dyn_cast<TypedefType>(
T))
8890 return II->isStr(
"BOOL");
8898 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8907 else if (
type->isArrayType())
8926 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8933 !D->isInlineSpecified() && (D->isConstexpr() ||
First->isConstexpr()))
8964 for (
auto *PI :
Decl->parameters()) {
8969 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8978 ParmOffset = PtrSize;
8979 for (
auto *PVDecl :
Decl->parameters()) {
8980 QualType PType = PVDecl->getOriginalType();
8981 if (
const auto *AT =
8986 PType = PVDecl->getType();
8988 PType = PVDecl->getType();
9008 for (
auto *PI :
Decl->parameters()) {
9015 "getObjCEncodingForFunctionDecl - Incomplete param type");
9022 for (
auto *PVDecl :
Decl->parameters()) {
9023 QualType PType = PVDecl->getOriginalType();
9024 if (
const auto *AT =
9029 PType = PVDecl->getType();
9031 PType = PVDecl->getType();
9045 bool Extended)
const {
9049 ObjCEncOptions Options = ObjCEncOptions()
9050 .setExpandPointedToStructures()
9051 .setExpandStructures()
9052 .setIsOutermostType();
9054 Options.setEncodeBlockParameters().setEncodeClassNames();
9055 getObjCEncodingForTypeImpl(
T, S, Options,
nullptr);
9061 bool Extended)
const {
9066 Decl->getReturnType(), S, Extended);
9075 E =
Decl->sel_param_end(); PI != E; ++PI) {
9082 "getObjCEncodingForMethodDecl - Incomplete param type");
9090 ParmOffset = 2 * PtrSize;
9092 E =
Decl->sel_param_end(); PI != E; ++PI) {
9095 if (
const auto *AT =
9104 PType, S, Extended);
9115 const Decl *Container)
const {
9118 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
9119 for (
auto *PID : CID->property_impls())
9120 if (PID->getPropertyDecl() == PD)
9124 for (
auto *PID : OID->property_impls())
9125 if (PID->getPropertyDecl() == PD)
9159 const Decl *Container)
const {
9161 bool Dynamic =
false;
9169 SynthesizePID = PropertyImpDecl;
9173 std::string S =
"T";
9218 if (SynthesizePID) {
9235 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9238 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9251 getObjCEncodingForTypeImpl(
T, S,
9253 .setExpandPointedToStructures()
9254 .setExpandStructures()
9255 .setIsOutermostType(),
9256 Field, NotEncodedT);
9260 std::string& S)
const {
9264 getObjCEncodingForTypeImpl(
T, S,
9266 .setExpandPointedToStructures()
9267 .setExpandStructures()
9268 .setIsOutermostType()
9269 .setEncodingProperty(),
9277 case BuiltinType::Void:
return 'v';
9278 case BuiltinType::Bool:
return 'B';
9279 case BuiltinType::Char8:
9280 case BuiltinType::Char_U:
9281 case BuiltinType::UChar:
return 'C';
9282 case BuiltinType::Char16:
9283 case BuiltinType::UShort:
return 'S';
9284 case BuiltinType::Char32:
9285 case BuiltinType::UInt:
return 'I';
9286 case BuiltinType::ULong:
9287 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9288 case BuiltinType::UInt128:
return 'T';
9289 case BuiltinType::ULongLong:
return 'Q';
9290 case BuiltinType::Char_S:
9291 case BuiltinType::SChar:
return 'c';
9292 case BuiltinType::Short:
return 's';
9293 case BuiltinType::WChar_S:
9294 case BuiltinType::WChar_U:
9295 case BuiltinType::Int:
return 'i';
9296 case BuiltinType::Long:
9297 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9298 case BuiltinType::LongLong:
return 'q';
9299 case BuiltinType::Int128:
return 't';
9300 case BuiltinType::Float:
return 'f';
9301 case BuiltinType::Double:
return 'd';
9302 case BuiltinType::LongDouble:
return 'D';
9303 case BuiltinType::NullPtr:
return '*';
9305 case BuiltinType::BFloat16:
9306 case BuiltinType::Float16:
9307 case BuiltinType::Float128:
9308 case BuiltinType::Ibm128:
9309 case BuiltinType::Half:
9310 case BuiltinType::ShortAccum:
9311 case BuiltinType::Accum:
9312 case BuiltinType::LongAccum:
9313 case BuiltinType::UShortAccum:
9314 case BuiltinType::UAccum:
9315 case BuiltinType::ULongAccum:
9316 case BuiltinType::ShortFract:
9317 case BuiltinType::Fract:
9318 case BuiltinType::LongFract:
9319 case BuiltinType::UShortFract:
9320 case BuiltinType::UFract:
9321 case BuiltinType::ULongFract:
9322 case BuiltinType::SatShortAccum:
9323 case BuiltinType::SatAccum:
9324 case BuiltinType::SatLongAccum:
9325 case BuiltinType::SatUShortAccum:
9326 case BuiltinType::SatUAccum:
9327 case BuiltinType::SatULongAccum:
9328 case BuiltinType::SatShortFract:
9329 case BuiltinType::SatFract:
9330 case BuiltinType::SatLongFract:
9331 case BuiltinType::SatUShortFract:
9332 case BuiltinType::SatUFract:
9333 case BuiltinType::SatULongFract:
9337#define SVE_TYPE(Name, Id, SingletonId) \
9338 case BuiltinType::Id:
9339#include "clang/Basic/AArch64ACLETypes.def"
9340#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9341#include "clang/Basic/RISCVVTypes.def"
9342#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9343#include "clang/Basic/WebAssemblyReferenceTypes.def"
9344#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9345#include "clang/Basic/AMDGPUTypes.def"
9346#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9347#include "clang/Basic/SPIRVTypes.def"
9350 Diags.
Report(diag::err_unsupported_objc_primitive_encoding)
9355 case BuiltinType::ObjCId:
9356 case BuiltinType::ObjCClass:
9357 case BuiltinType::ObjCSel:
9358 llvm_unreachable(
"@encoding ObjC primitive type");
9361#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9362 case BuiltinType::Id:
9363#include "clang/Basic/OpenCLImageTypes.def"
9364#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9365 case BuiltinType::Id:
9366#include "clang/Basic/OpenCLExtensionTypes.def"
9367 case BuiltinType::OCLEvent:
9368 case BuiltinType::OCLClkEvent:
9369 case BuiltinType::OCLQueue:
9370 case BuiltinType::OCLReserveID:
9371 case BuiltinType::OCLSampler:
9372 case BuiltinType::Dependent:
9373 case BuiltinType::MetaInfo:
9374#define PPC_VECTOR_TYPE(Name, Id, Size) \
9375 case BuiltinType::Id:
9376#include "clang/Basic/PPCTypes.def"
9377#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9378#include "clang/Basic/HLSLIntangibleTypes.def"
9379#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9380#include "clang/Basic/HLSLPackedTypes.def"
9381#define BUILTIN_TYPE(KIND, ID)
9382#define PLACEHOLDER_TYPE(KIND, ID) \
9383 case BuiltinType::KIND:
9384#include "clang/AST/BuiltinTypes.def"
9385 llvm_unreachable(
"invalid builtin type for @encode");
9387 llvm_unreachable(
"invalid BuiltinType::Kind value");
9394 if (!
Enum->isFixed())
9404 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9424 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9432 S += llvm::utostr(Offset);
9434 if (
const auto *ET =
T->getAsCanonical<EnumType>())
9447 bool VisitBasesAndFields) {
9448 T =
T->getBaseElementTypeUnsafe();
9452 PT->getPointeeType().getTypePtr(),
false);
9454 auto *CXXRD =
T->getAsCXXRecordDecl();
9462 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9465 for (
const auto &B : CXXRD->bases())
9470 for (
auto *FD : CXXRD->fields())
9479void ASTContext::getObjCEncodingForTypeImpl(QualType
T, std::string &S,
9480 const ObjCEncOptions Options,
9481 const FieldDecl *FD,
9482 QualType *NotEncodedT)
const {
9484 switch (CT->getTypeClass()) {
9489 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9497 getObjCEncodingForTypeImpl(
T->
castAs<ComplexType>()->getElementType(), S,
9504 getObjCEncodingForTypeImpl(
T->
castAs<AtomicType>()->getValueType(), S,
9511 case Type::LValueReference:
9512 case Type::RValueReference: {
9515 const auto *PT =
T->
castAs<PointerType>();
9516 if (PT->isObjCSelType()) {
9525 bool isReadOnly =
false;
9530 if (
T->
getAs<TypedefType>()) {
9531 if (Options.IsOutermostType() &&
T.isConstQualified()) {
9535 }
else if (Options.IsOutermostType()) {
9536 QualType P = PointeeTy;
9537 while (
auto PT = P->
getAs<PointerType>())
9548 if (StringRef(S).ends_with(
"nr"))
9549 S.replace(S.end()-2, S.end(),
"rn");
9559 }
else if (
const auto *RTy = PointeeTy->
getAsCanonical<RecordType>()) {
9560 const IdentifierInfo *II = RTy->getDecl()->getIdentifier();
9562 if (II == &
Idents.get(
"objc_class")) {
9567 if (II == &
Idents.get(
"objc_object")) {
9576 RTy, Options.ExpandPointedToStructures()))) {
9585 ObjCEncOptions NewOptions;
9586 if (Options.ExpandPointedToStructures())
9587 NewOptions.setExpandStructures();
9588 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9589 nullptr, NotEncodedT);
9593 case Type::ConstantArray:
9594 case Type::IncompleteArray:
9595 case Type::VariableArray: {
9602 getObjCEncodingForTypeImpl(
9603 AT->getElementType(), S,
9604 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9608 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9609 S += llvm::utostr(CAT->getZExtSize());
9613 "Unknown array type!");
9617 getObjCEncodingForTypeImpl(
9618 AT->getElementType(), S,
9619 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9626 case Type::FunctionNoProto:
9627 case Type::FunctionProto:
9631 case Type::Record: {
9633 S += RDecl->
isUnion() ?
'(' :
'{';
9637 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9638 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
9639 llvm::raw_string_ostream
OS(S);
9640 printTemplateArgumentList(OS, TemplateArgs.
asArray(),
9646 if (Options.ExpandStructures()) {
9649 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9651 for (
const auto *Field : RDecl->
fields()) {
9654 S +=
Field->getNameAsString();
9659 if (
Field->isBitField()) {
9660 getObjCEncodingForTypeImpl(
Field->getType(), S,
9661 ObjCEncOptions().setExpandStructures(),
9664 QualType qt =
Field->getType();
9666 getObjCEncodingForTypeImpl(
9668 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9674 S += RDecl->
isUnion() ?
')' :
'}';
9678 case Type::BlockPointer: {
9679 const auto *BT =
T->
castAs<BlockPointerType>();
9681 if (Options.EncodeBlockParameters()) {
9682 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
9686 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9687 Options.forComponentType(), FD, NotEncodedT);
9691 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9692 for (
const auto &I : FPT->param_types())
9693 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9701 case Type::ObjCObject: {
9705 S +=
"{objc_object=}";
9709 S +=
"{objc_class=}";
9716 case Type::ObjCInterface: {
9719 ObjCInterfaceDecl *OI =
T->
castAs<ObjCObjectType>()->getInterface();
9722 if (Options.ExpandStructures()) {
9724 SmallVector<const ObjCIvarDecl*, 32> Ivars;
9726 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9727 const FieldDecl *
Field = Ivars[i];
9728 if (
Field->isBitField())
9729 getObjCEncodingForTypeImpl(
Field->getType(), S,
9730 ObjCEncOptions().setExpandStructures(),
9733 getObjCEncodingForTypeImpl(
Field->getType(), S,
9734 ObjCEncOptions().setExpandStructures(), FD,
9742 case Type::ObjCObjectPointer: {
9743 const auto *OPT =
T->
castAs<ObjCObjectPointerType>();
9744 if (OPT->isObjCIdType()) {
9749 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9757 if (OPT->isObjCQualifiedIdType()) {
9758 getObjCEncodingForTypeImpl(
9760 Options.keepingOnly(ObjCEncOptions()
9761 .setExpandPointedToStructures()
9762 .setExpandStructures()),
9764 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9768 for (
const auto *I : OPT->quals()) {
9770 S += I->getObjCRuntimeNameAsString();
9779 if (OPT->getInterfaceDecl() &&
9780 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9782 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9783 for (
const auto *I : OPT->quals()) {
9785 S += I->getObjCRuntimeNameAsString();
9795 case Type::MemberPointer:
9799 case Type::ExtVector:
9805 case Type::ConstantMatrix:
9818 case Type::DeducedTemplateSpecialization:
9821 case Type::HLSLAttributedResource:
9822 case Type::HLSLInlineSpirv:
9823 case Type::OverflowBehavior:
9824 llvm_unreachable(
"unexpected type");
9826 case Type::ArrayParameter:
9828#define ABSTRACT_TYPE(KIND, BASE)
9829#define TYPE(KIND, BASE)
9830#define DEPENDENT_TYPE(KIND, BASE) \
9832#define NON_CANONICAL_TYPE(KIND, BASE) \
9834#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9836#include "clang/AST/TypeNodes.inc"
9837 llvm_unreachable(
"@encode for dependent type!");
9839 llvm_unreachable(
"bad type kind!");
9842void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
9844 const FieldDecl *FD,
9846 QualType *NotEncodedT)
const {
9847 assert(RDecl &&
"Expected non-null RecordDecl");
9848 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9852 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9853 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9857 for (
const auto &BI : CXXRec->bases()) {
9858 if (!BI.isVirtual()) {
9863 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9864 std::make_pair(offs, base));
9869 for (FieldDecl *Field : RDecl->
fields()) {
9870 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9873 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9874 std::make_pair(offs, Field));
9877 if (CXXRec && includeVBases) {
9878 for (
const auto &BI : CXXRec->vbases()) {
9884 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9885 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9886 std::make_pair(offs, base));
9900 std::multimap<uint64_t, NamedDecl *>::iterator
9901 CurLayObj = FieldOrBaseOffsets.begin();
9903 if (CXXRec && CXXRec->isDynamicClass() &&
9904 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9907 std::string recname = CXXRec->getNameAsString();
9908 if (recname.empty()) recname =
"?";
9921 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9922 std::make_pair(offs,
nullptr));
9925 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9927 assert(CurOffs <= CurLayObj->first);
9928 if (CurOffs < CurLayObj->first) {
9929 uint64_t padding = CurLayObj->first - CurOffs;
9941 NamedDecl *dcl = CurLayObj->second;
9945 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9950 getObjCEncodingForStructureImpl(base, S, FD,
false,
9960 S += field->getNameAsString();
9964 if (field->isBitField()) {
9967 CurOffs += field->getBitWidthValue();
9970 QualType qt = field->getType();
9972 getObjCEncodingForTypeImpl(
9973 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9984 std::string& S)
const {
10009 if (!ObjCSelDecl) {
10013 return ObjCSelDecl;
10017 if (!ObjCClassDecl) {
10022 return ObjCClassDecl;
10026 if (!ObjCProtocolClassDecl) {
10027 ObjCProtocolClassDecl
10030 &
Idents.get(
"Protocol"),
10036 return ObjCProtocolClassDecl;
10057 QualType T = Context->getPointerType(Context->CharTy);
10058 return Context->buildImplicitTypedef(
T, Name);
10067 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 2);
10068 QualType T = Context->getPointerType(Context->CharTy);
10071 return Context->buildImplicitTypedef(
ArrayType,
"__builtin_zos_va_list");
10080 QualType T = Context->getPointerType(Context->VoidTy);
10081 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10084static TypedefDecl *
10088 if (Context->getLangOpts().CPlusPlus) {
10093 &Context->Idents.get(
"std"),
10101 const size_t NumFields = 5;
10103 const char *FieldNames[NumFields];
10106 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10107 FieldNames[0] =
"__stack";
10110 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10111 FieldNames[1] =
"__gr_top";
10114 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10115 FieldNames[2] =
"__vr_top";
10118 FieldTypes[3] = Context->IntTy;
10119 FieldNames[3] =
"__gr_offs";
10122 FieldTypes[4] = Context->IntTy;
10123 FieldNames[4] =
"__vr_offs";
10126 for (
unsigned i = 0; i < NumFields; ++i) {
10131 &Context->Idents.get(FieldNames[i]),
10132 FieldTypes[i],
nullptr,
10144 return Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10151 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10154 const size_t NumFields = 5;
10156 const char *FieldNames[NumFields];
10159 FieldTypes[0] = Context->UnsignedCharTy;
10160 FieldNames[0] =
"gpr";
10163 FieldTypes[1] = Context->UnsignedCharTy;
10164 FieldNames[1] =
"fpr";
10167 FieldTypes[2] = Context->UnsignedShortTy;
10168 FieldNames[2] =
"reserved";
10171 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10172 FieldNames[3] =
"overflow_arg_area";
10175 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
10176 FieldNames[4] =
"reg_save_area";
10179 for (
unsigned i = 0; i < NumFields; ++i) {
10183 &Context->Idents.get(FieldNames[i]),
10184 FieldTypes[i],
nullptr,
10197 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10201 std::nullopt, VaListTagTypedefDecl);
10204 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10205 QualType VaListTagArrayType = Context->getConstantArrayType(
10207 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10210static TypedefDecl *
10214 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10217 const size_t NumFields = 4;
10219 const char *FieldNames[NumFields];
10222 FieldTypes[0] = Context->UnsignedIntTy;
10223 FieldNames[0] =
"gp_offset";
10226 FieldTypes[1] = Context->UnsignedIntTy;
10227 FieldNames[1] =
"fp_offset";
10230 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10231 FieldNames[2] =
"overflow_arg_area";
10234 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10235 FieldNames[3] =
"reg_save_area";
10238 for (
unsigned i = 0; i < NumFields; ++i) {
10243 &Context->Idents.get(FieldNames[i]),
10244 FieldTypes[i],
nullptr,
10258 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10259 QualType VaListTagArrayType = Context->getConstantArrayType(
10261 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10264static TypedefDecl *
10267 RecordDecl *VaListDecl = Context->buildImplicitRecord(
"__va_list");
10268 if (Context->getLangOpts().CPlusPlus) {
10287 &Context->Idents.get(
"__ap"),
10288 Context->getPointerType(Context->VoidTy),
10298 Context->VaListTagDecl = VaListDecl;
10301 CanQualType T = Context->getCanonicalTagType(VaListDecl);
10302 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10305static TypedefDecl *
10309 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10312 const size_t NumFields = 4;
10314 const char *FieldNames[NumFields];
10317 FieldTypes[0] = Context->LongTy;
10318 FieldNames[0] =
"__gpr";
10321 FieldTypes[1] = Context->LongTy;
10322 FieldNames[1] =
"__fpr";
10325 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10326 FieldNames[2] =
"__overflow_arg_area";
10329 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10330 FieldNames[3] =
"__reg_save_area";
10333 for (
unsigned i = 0; i < NumFields; ++i) {
10338 &Context->Idents.get(FieldNames[i]),
10339 FieldTypes[i],
nullptr,
10353 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10354 QualType VaListTagArrayType = Context->getConstantArrayType(
10357 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10363 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10366 const size_t NumFields = 3;
10368 const char *FieldNames[NumFields];
10371 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10372 FieldNames[0] =
"__current_saved_reg_area_pointer";
10375 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10376 FieldNames[1] =
"__saved_reg_area_end_pointer";
10379 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10380 FieldNames[2] =
"__overflow_area_pointer";
10383 for (
unsigned i = 0; i < NumFields; ++i) {
10386 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
10399 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10403 std::nullopt, VaListTagTypedefDecl);
10406 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10407 QualType VaListTagArrayType = Context->getConstantArrayType(
10410 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10413static TypedefDecl *
10423 constexpr size_t NumFields = 3;
10424 QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
10425 Context->getPointerType(Context->IntTy),
10427 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10430 for (
unsigned i = 0; i < NumFields; ++i) {
10433 &Context->Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
10445 Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10447 return VaListTagTypedefDecl;
10473 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10477 if (!BuiltinVaListDecl) {
10478 BuiltinVaListDecl =
CreateVaListDecl(
this, Target->getBuiltinVaListKind());
10479 assert(BuiltinVaListDecl->isImplicit());
10482 return BuiltinVaListDecl;
10495 if (!BuiltinMSVaListDecl)
10498 return BuiltinMSVaListDecl;
10502 if (!BuiltinZOSVaListDecl)
10505 return BuiltinZOSVaListDecl;
10522 assert(ObjCConstantStringType.isNull() &&
10523 "'NSConstantString' type already set!");
10533 unsigned size = End - Begin;
10534 assert(size > 1 &&
"set is not overloaded!");
10540 NamedDecl **Storage = OT->getStorage();
10563 bool TemplateKeyword,
10568 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10569 assert(!Qualifier &&
"unexpected qualified template template parameter");
10570 assert(TemplateKeyword ==
false);
10575 llvm::FoldingSetNodeID ID;
10578 llvm::FoldingSetInsertToken
Token;
10583 QualifiedTemplateNames.insert(QTN,
Token);
10593 llvm::FoldingSetNodeID ID;
10596 llvm::FoldingSetInsertToken
Token;
10602 DependentTemplateNames.insert(QTN,
Token);
10607 Decl *AssociatedDecl,
10610 bool Final)
const {
10611 llvm::FoldingSetNodeID ID;
10615 llvm::FoldingSetInsertToken
Token;
10617 SubstTemplateTemplateParms.lookup(ID,
Token);
10621 Replacement, AssociatedDecl, Index,
PackIndex, Final);
10622 SubstTemplateTemplateParms.insert(subst,
Token);
10630 Decl *AssociatedDecl,
10631 unsigned Index,
bool Final)
const {
10633 llvm::FoldingSetNodeID ID;
10635 AssociatedDecl, Index, Final);
10637 llvm::FoldingSetInsertToken
Token;
10639 SubstTemplateTemplateParmPacks.lookup(ID,
Token);
10644 SubstTemplateTemplateParmPacks.insert(Subst,
Token);
10658 llvm::FoldingSetNodeID ID;
10661 llvm::FoldingSetInsertToken
Token;
10668 DeducedTemplates.insert(DTS,
Token);
10677 llvm::FoldingSetNodeID ID;
10679 FullySubstituted, Expansions);
10681 llvm::FoldingSetInsertToken
Token;
10685 Allocate(PackIndexingTemplateStorage::totalSizeToAlloc<TemplateName>(
10686 Expansions.size()),
10689 FullySubstituted, Expansions);
10690 PackIndexingTemplates.insert(PI,
Token);
10713 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10743 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10744 CT = AT->getElementType();
10776 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10777 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10834 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
10835 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
10837 if (!LHSOBT && !RHSOBT)
10840 if (LHSOBT && RHSOBT) {
10841 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
10846 QualType LHSUnderlying = LHSOBT ? LHSOBT->desugar() : LHS;
10847 QualType RHSUnderlying = RHSOBT ? RHSOBT->desugar() : RHS;
10849 if (RHSOBT && !LHSOBT) {
10860 auto VScale = Context.getTargetInfo().getVScaleRange(
10867 uint64_t EltSize = Context.getTypeSize(Info.
ElementType);
10871 uint64_t MinElts = Info.
EC.getKnownMinValue();
10872 return VScale->first * MinElts * EltSize;
10880 "Expected RVV builtin type and vector type!");
10920 return IsValidCast(FirstType, SecondType) ||
10921 IsValidCast(SecondType, FirstType);
10929 "Expected RVV builtin type and vector type!");
10936 if (!BT->isRVVVLSBuiltinType())
10956 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10963 return IsLaxCompatible(FirstType, SecondType) ||
10964 IsLaxCompatible(SecondType, FirstType);
10970 if (
const AttributedType *
Attr = dyn_cast<AttributedType>(Ty)) {
10971 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10974 Ty =
Attr->getModifiedType();
10978 Ty =
Paren->getInnerType();
11010 for (
auto *lhsProto : lhs->
quals()) {
11011 bool match =
false;
11012 for (
auto *rhsProto : rhs->
quals()) {
11043 for (
auto *I : lhs->
quals()) {
11047 if (!rhsID->ClassImplementsProtocol(I,
true))
11055 for (
auto *lhsProto : lhs->
quals()) {
11056 bool match =
false;
11061 for (
auto *rhsProto : rhs->
quals()) {
11071 for (
auto *I : lhs->
quals()) {
11075 if (rhsID->ClassImplementsProtocol(I,
true)) {
11092 for (
auto *lhsProto : lhs->
quals()) {
11093 bool match =
false;
11100 for (
auto *rhsProto : rhs->
quals()) {
11119 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
11121 for (
auto *lhsProto : LHSInheritedProtocols) {
11122 bool match =
false;
11123 for (
auto *rhsProto : rhs->
quals()) {
11148 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
11153 auto finish = [&](
bool succeeded) ->
bool {
11157 if (!RHS->isKindOfType())
11168 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
11173 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
11178 if (LHS->isObjCClass() && RHS->isObjCClass()) {
11183 if (LHS->getInterface() && RHS->getInterface()) {
11198 bool BlockReturnType) {
11202 auto finish = [&](
bool succeeded) ->
bool {
11227 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
11231 (!BlockReturnType &&
11235 (BlockReturnType ? LHSOPT : RHSOPT),
11236 (BlockReturnType ? RHSOPT : LHSOPT),
false));
11244 return finish(BlockReturnType);
11246 return finish(!BlockReturnType);
11258 return (*lhs)->getName().compare((*rhs)->getName());
11275 assert(LHS->getInterface() &&
"LHS must have an interface base");
11276 assert(RHS->getInterface() &&
"RHS must have an interface base");
11282 for (
auto *proto : LHS->quals()) {
11283 Context.CollectInheritedProtocols(proto, LHSProtocolSet);
11287 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
11293 for (
auto *proto : RHS->quals()) {
11294 Context.CollectInheritedProtocols(proto, RHSProtocolSet);
11298 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
11301 for (
auto *proto : LHSProtocolSet) {
11302 if (RHSProtocolSet.count(proto))
11303 IntersectionSet.push_back(proto);
11309 Context.CollectInheritedProtocols(CommonBase, ImpliedProtocols);
11312 if (!ImpliedProtocols.empty()) {
11314 return ImpliedProtocols.contains(proto);
11319 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11329 if (lhsOPT && rhsOPT)
11335 if (lhsBlock && rhsBlock)
11340 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11352 bool stripKindOf) {
11353 if (lhsArgs.size() != rhsArgs.size())
11360 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11366 if (!stripKindOf ||
11367 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11368 rhsArgs[i].stripObjCKindOfType(ctx))) {
11396 if (!LDecl || !RDecl)
11402 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
11406 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11411 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
11416 bool anyChanges =
false;
11417 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11420 LHS->getTypeArgs(), RHS->getTypeArgs(),
11423 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11434 if (!Protocols.empty())
11440 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
11443 anyKindOf || LHS->isKindOfType());
11451 QualType LHSSuperType = LHS->getSuperClassType();
11452 if (LHSSuperType.
isNull())
11461 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
11462 if (KnownLHS != LHSAncestors.end()) {
11463 LHS = KnownLHS->second;
11467 bool anyChanges =
false;
11468 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11471 LHS->getTypeArgs(), RHS->getTypeArgs(),
11474 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11485 if (!Protocols.empty())
11490 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
11493 anyKindOf || RHS->isKindOfType());
11501 QualType RHSSuperType = RHS->getSuperClassType();
11502 if (RHSSuperType.
isNull())
11513 assert(LHS->getInterface() &&
"LHS is not an interface type");
11514 assert(RHS->getInterface() &&
"RHS is not an interface type");
11519 bool IsSuperClass = LHSInterface->
isSuperClassOf(RHS->getInterface());
11526 if (LHS->getNumProtocols() > 0) {
11535 for (
auto *RHSPI : RHS->quals())
11538 if (SuperClassInheritedProtocols.empty())
11541 for (
const auto *LHSProto : LHS->quals()) {
11542 bool SuperImplementsProtocol =
false;
11543 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11544 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11545 SuperImplementsProtocol =
true;
11548 if (!SuperImplementsProtocol)
11554 if (LHS->isSpecialized()) {
11559 RHSSuper = RHSSuper->getSuperClassType()->castAs<
ObjCObjectType>();
11562 if (RHSSuper->isSpecialized() &&
11564 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
11578 if (!LHSOPT || !RHSOPT)
11596 bool CompareUnqualified) {
11615 bool OfBlockPointer,
11617 if (
const RecordType *UT =
T->getAsUnionType()) {
11619 if (UD->
hasAttr<TransparentUnionAttr>()) {
11620 for (
const auto *I : UD->
fields()) {
11621 QualType ET = I->getType().getUnqualifiedType();
11635 bool OfBlockPointer,
11656 bool IsConditionalOperator) {
11659 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11660 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11661 bool allLTypes =
true;
11662 bool allRTypes =
true;
11666 if (OfBlockPointer) {
11668 QualType LHS = lbase->getReturnType();
11670 if (!UnqualifiedResult)
11672 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11737 bool NoReturn = IsConditionalOperator
11747 std::optional<FunctionEffectSet> MergedFX;
11749 if (lproto && rproto) {
11750 assert((AllowCXX ||
11751 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11752 "C++ shouldn't be here");
11754 if (lproto->getNumParams() != rproto->getNumParams())
11758 if (lproto->isVariadic() != rproto->isVariadic())
11761 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11765 if (lproto->getExtraAttributeInfo().CFISalt !=
11766 rproto->getExtraAttributeInfo().CFISalt)
11772 if (LHSFX != RHSFX) {
11773 if (IsConditionalOperator)
11782 if (*MergedFX != LHSFX)
11784 if (*MergedFX != RHSFX)
11789 bool canUseLeft, canUseRight;
11801 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11802 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11803 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11805 lParamType, rParamType, OfBlockPointer,
Unqualified);
11812 types.push_back(paramType);
11824 if (allLTypes)
return lhs;
11825 if (allRTypes)
return rhs;
11830 newParamInfos.empty() ?
nullptr : newParamInfos.data();
11836 if (lproto) allRTypes =
false;
11837 if (rproto) allLTypes =
false;
11841 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11849 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11855 paramTy = ED->getIntegerType();
11865 if (allLTypes)
return lhs;
11866 if (allRTypes)
return rhs;
11875 if (allLTypes)
return lhs;
11876 if (allRTypes)
return rhs;
11882 QualType other,
bool isBlockReturnType) {
11888 ET->getDecl()->getDefinitionOrSelf()->getIntegerType();
11889 if (underlyingType.
isNull())
11891 if (Context.hasSameType(underlyingType, other))
11897 Context.getTypeSize(underlyingType) == Context.getTypeSize(other))
11906 if (LangOpts.CPlusPlus || !LangOpts.C23)
11927 bool BlockReturnType,
bool IsConditionalOperator) {
11928 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
11929 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
11931 if (!LHSOBT && !RHSOBT)
11932 return std::nullopt;
11936 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
11940 LHSOBT->getUnderlyingType(), RHSOBT->getUnderlyingType(),
11941 OfBlockPointer,
Unqualified, BlockReturnType, IsConditionalOperator);
11943 if (MergedUnderlying.
isNull())
11947 if (LHSOBT->getUnderlyingType() == RHSOBT->getUnderlyingType())
11950 LHSOBT->getBehaviorKind(),
11959 return mergeTypes(LHSOBT->getUnderlyingType(), RHS, OfBlockPointer,
11960 Unqualified, BlockReturnType, IsConditionalOperator);
11963 return mergeTypes(LHS, RHSOBT->getUnderlyingType(), OfBlockPointer,
11964 Unqualified, BlockReturnType, IsConditionalOperator);
11969 bool IsConditionalOperator) {
11980 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11984 if (LHSRefTy || RHSRefTy)
11987 if (std::optional<QualType> MergedOBT =
11989 BlockReturnType, IsConditionalOperator))
12001 if (LHSCan == RHSCan)
12006 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12007 if (LQuals != RQuals) {
12024 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12045 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
12046 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
12049 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
12050 LHSClass = Type::ConstantArray;
12051 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
12052 RHSClass = Type::ConstantArray;
12055 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
12056 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
12059 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
12060 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
12063 if (LHSClass != RHSClass) {
12073 if (OfBlockPointer && !BlockReturnType) {
12081 if (
const auto *AT = LHS->
getAs<AutoType>()) {
12082 if (!AT->isDeduced() && AT->isGNUAutoType())
12085 if (
const auto *AT = RHS->
getAs<AutoType>()) {
12086 if (!AT->isDeduced() && AT->isGNUAutoType())
12093 switch (LHSClass) {
12094#define TYPE(Class, Base)
12095#define ABSTRACT_TYPE(Class, Base)
12096#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
12097#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
12098#define DEPENDENT_TYPE(Class, Base) case Type::Class:
12099#include "clang/AST/TypeNodes.inc"
12100 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
12103 case Type::DeducedTemplateSpecialization:
12104 case Type::LValueReference:
12105 case Type::RValueReference:
12106 case Type::MemberPointer:
12107 llvm_unreachable(
"C++ should never be in mergeTypes");
12109 case Type::ObjCInterface:
12110 case Type::IncompleteArray:
12111 case Type::VariableArray:
12112 case Type::FunctionProto:
12113 case Type::ExtVector:
12114 case Type::OverflowBehavior:
12115 llvm_unreachable(
"Types are eliminated above");
12117 case Type::Pointer:
12128 if (ResultType.
isNull())
12136 case Type::BlockPointer:
12161 if (ResultType.
isNull())
12180 if (ResultType.
isNull())
12188 case Type::ConstantArray:
12203 if (ResultType.
isNull())
12211 if (LVAT || RVAT) {
12214 -> std::pair<bool,llvm::APInt> {
12216 std::optional<llvm::APSInt> TheInt;
12219 return std::make_pair(
true, *TheInt);
12220 return std::make_pair(
false, llvm::APSInt());
12223 return std::make_pair(
true, CAT->getSize());
12224 return std::make_pair(
false, llvm::APInt());
12227 bool HaveLSize, HaveRSize;
12228 llvm::APInt LSize, RSize;
12229 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
12230 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
12231 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
12265 case Type::FunctionNoProto:
12267 false, IsConditionalOperator);
12271 case Type::Builtin:
12274 case Type::Complex:
12283 case Type::ConstantMatrix:
12288 case Type::ObjCObject: {
12297 case Type::ObjCObjectPointer:
12298 if (OfBlockPointer) {
12310 assert(LHS != RHS &&
12311 "Equivalent pipe types should have already been handled!");
12313 case Type::ArrayParameter:
12314 assert(LHS != RHS &&
12315 "Equivalent ArrayParameter types should have already been handled!");
12317 case Type::BitInt: {
12325 if (LHSUnsigned != RHSUnsigned)
12328 if (LHSBits != RHSBits)
12332 case Type::HLSLAttributedResource: {
12333 const HLSLAttributedResourceType *LHSTy =
12334 LHS->
castAs<HLSLAttributedResourceType>();
12335 const HLSLAttributedResourceType *RHSTy =
12336 RHS->
castAs<HLSLAttributedResourceType>();
12337 assert(LHSTy->getWrappedType() == RHSTy->getWrappedType() &&
12338 LHSTy->getWrappedType()->isHLSLResourceType() &&
12339 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
12341 if (LHSTy->getAttrs() == RHSTy->getAttrs() &&
12342 LHSTy->getContainedType() == RHSTy->getContainedType())
12346 case Type::HLSLInlineSpirv:
12347 const HLSLInlineSpirvType *LHSTy = LHS->
castAs<HLSLInlineSpirvType>();
12348 const HLSLInlineSpirvType *RHSTy = RHS->
castAs<HLSLInlineSpirvType>();
12350 if (LHSTy->getOpcode() == RHSTy->getOpcode() &&
12351 LHSTy->getSize() == RHSTy->getSize() &&
12352 LHSTy->getAlignment() == RHSTy->getAlignment()) {
12353 for (
size_t I = 0; I < LHSTy->getOperands().size(); I++)
12354 if (LHSTy->getOperands()[I] != RHSTy->getOperands()[I])
12362 llvm_unreachable(
"Invalid Type::Class!");
12367 bool &CanUseFirst,
bool &CanUseSecond,
12369 assert(NewParamInfos.empty() &&
"param info list not empty");
12370 CanUseFirst = CanUseSecond =
true;
12376 if (!FirstHasInfo && !SecondHasInfo)
12379 bool NeedParamInfo =
false;
12383 for (
size_t I = 0; I < E; ++I) {
12394 bool FirstNoEscape = FirstParam.
isNoEscape();
12395 bool SecondNoEscape = SecondParam.
isNoEscape();
12396 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12398 if (NewParamInfos.back().getOpaqueValue())
12399 NeedParamInfo =
true;
12400 if (FirstNoEscape != IsNoEscape)
12401 CanUseFirst =
false;
12402 if (SecondNoEscape != IsNoEscape)
12403 CanUseSecond =
false;
12406 if (!NeedParamInfo)
12407 NewParamInfos.clear();
12413 if (
auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
12414 It->second =
nullptr;
12415 for (
auto *SubClass : ObjCSubClasses.lookup(D))
12427 if (LHSCan == RHSCan)
12429 if (RHSCan->isFunctionType()) {
12438 if (ResReturnType.
isNull())
12440 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12457 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12464 if (LQuals != RQuals) {
12472 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12488 if (ResQT == LHSBaseQT)
12490 if (ResQT == RHSBaseQT)
12501 if (
const auto *ED =
T->getAsEnumDecl())
12502 T = ED->getIntegerType();
12503 if (
T->isBooleanType())
12506 return EIT->getNumBits();
12512 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12513 T->isFixedPointType()) &&
12514 "Unexpected type");
12519 VTy->getNumElements(), VTy->getVectorKind());
12526 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>())
12528 OBT->getBehaviorKind(),
12533 if (
const auto *ED =
T->getAsEnumDecl())
12534 T = ED->getIntegerType();
12537 case BuiltinType::Char_U:
12539 case BuiltinType::Char_S:
12540 case BuiltinType::SChar:
12541 case BuiltinType::Char8:
12543 case BuiltinType::Short:
12545 case BuiltinType::Int:
12547 case BuiltinType::Long:
12549 case BuiltinType::LongLong:
12551 case BuiltinType::Int128:
12556 case BuiltinType::WChar_S:
12559 case BuiltinType::ShortAccum:
12561 case BuiltinType::Accum:
12563 case BuiltinType::LongAccum:
12565 case BuiltinType::SatShortAccum:
12567 case BuiltinType::SatAccum:
12569 case BuiltinType::SatLongAccum:
12571 case BuiltinType::ShortFract:
12573 case BuiltinType::Fract:
12575 case BuiltinType::LongFract:
12577 case BuiltinType::SatShortFract:
12579 case BuiltinType::SatFract:
12581 case BuiltinType::SatLongFract:
12584 assert((
T->hasUnsignedIntegerRepresentation() ||
12585 T->isUnsignedFixedPointType()) &&
12586 "Unexpected signed integer or fixed point type");
12592 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12593 T->isFixedPointType()) &&
12594 "Unexpected type");
12599 VTy->getNumElements(), VTy->getVectorKind());
12607 if (
const auto *ED =
T->getAsEnumDecl())
12608 T = ED->getIntegerType();
12611 case BuiltinType::Char_S:
12613 case BuiltinType::Char_U:
12614 case BuiltinType::UChar:
12615 case BuiltinType::Char8:
12617 case BuiltinType::UShort:
12619 case BuiltinType::UInt:
12621 case BuiltinType::ULong:
12623 case BuiltinType::ULongLong:
12625 case BuiltinType::UInt128:
12630 case BuiltinType::WChar_U:
12633 case BuiltinType::UShortAccum:
12635 case BuiltinType::UAccum:
12637 case BuiltinType::ULongAccum:
12639 case BuiltinType::SatUShortAccum:
12641 case BuiltinType::SatUAccum:
12643 case BuiltinType::SatULongAccum:
12645 case BuiltinType::UShortFract:
12647 case BuiltinType::UFract:
12649 case BuiltinType::ULongFract:
12651 case BuiltinType::SatUShortFract:
12653 case BuiltinType::SatUFract:
12655 case BuiltinType::SatULongFract:
12659 (
T->hasSignedIntegerRepresentation() ||
T->isSignedFixedPointType()) &&
12660 "Unexpected signed integer or fixed point type");
12685 bool AllowTypeModifiers) {
12689 bool IsChar =
false, IsShort =
false;
12690 RequiresICE =
false;
12695 bool IsSpecial =
false;
12699 default: Done =
true; --Str;
break;
12701 RequiresICE =
true;
12704 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12705 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12709 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12710 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12715 assert(!IsSpecial &&
12716 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12717 assert(HowLong == 0 &&
"Can't use both 'L' and 'B' modifiers!");
12725 assert(!IsSpecial &&
12726 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12727 assert(HowLong == 0 &&
"Can't use both 'L' and 'T' modifiers!");
12734 assert(!IsSpecial &&
12735 "Can't use 'L' with 'W', 'N', 'Z', 'O', 'B', or 'T' modifiers");
12736 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12741 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12742 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12746 if (Context.getTargetInfo().getLongWidth() == 32)
12751 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12752 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12756 switch (Context.getTargetInfo().getInt64Type()) {
12758 llvm_unreachable(
"Unexpected integer type");
12769 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12770 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12774 switch (Context.getTargetInfo().getIntTypeByWidth(32,
true)) {
12776 llvm_unreachable(
"Unexpected integer type");
12789 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12790 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12794 if (Context.getLangOpts().OpenCL)
12807 llvm_unreachable(
"Unknown builtin type letter!");
12810 "Bad modifiers used with 'x'!");
12811 Type = Context.Float16Ty;
12815 "Bad modifiers used with 'y'!");
12816 Type = Context.BFloat16Ty;
12820 "Bad modifiers used with 'v'!");
12821 Type = Context.VoidTy;
12825 "Bad modifiers used with 'h'!");
12826 Type = Context.HalfTy;
12830 "Bad modifiers used with 'f'!");
12831 Type = Context.FloatTy;
12835 "Bad modifiers used with 'd'!");
12837 Type = Context.LongDoubleTy;
12838 else if (HowLong == 2)
12839 Type = Context.Float128Ty;
12841 Type = Context.DoubleTy;
12844 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12846 Type = Context.UnsignedShortTy;
12848 Type = Context.ShortTy;
12852 Type =
Unsigned ? Context.UnsignedCharTy : Context.SignedCharTy;
12854 Type =
Unsigned ? Context.UnsignedShortTy : Context.ShortTy;
12855 else if (HowLong == 3)
12856 Type =
Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
12857 else if (HowLong == 2)
12858 Type =
Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
12859 else if (HowLong == 1)
12860 Type =
Unsigned ? Context.UnsignedLongTy : Context.LongTy;
12862 Type =
Unsigned ? Context.UnsignedIntTy : Context.IntTy;
12865 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12867 Type = Context.SignedCharTy;
12869 Type = Context.UnsignedCharTy;
12871 Type = Context.CharTy;
12874 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12875 Type = Context.BoolTy;
12878 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12879 Type = Context.getSizeType();
12882 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12883 Type = Context.getWideCharType();
12886 Type = Context.getCFConstantStringType();
12889 Type = Context.getObjCIdType();
12892 Type = Context.getObjCSelType();
12895 Type = Context.getObjCSuperType();
12898 Type = Context.getBuiltinVaListType();
12899 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12910 Type = Context.getBuiltinVaListType();
12911 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12913 Type = Context.getArrayDecayedType(
Type);
12915 Type = Context.getLValueReferenceType(
Type);
12919 unsigned NumElements = strtoul(Str, &End, 10);
12920 assert(End != Str &&
"Missing vector size");
12924 RequiresICE,
false);
12925 assert(!RequiresICE &&
"Can't require vector ICE");
12927 Type = Context.getScalableVectorType(ElementType, NumElements);
12933 Type = Context.SveCountTy;
12937 Type = Context.AMDGPUBufferRsrcTy;
12941 Type = Context.AMDGPUFeaturePredicateTy;
12945 Type = Context.AMDGPUTextureTy;
12949 Type = Context.HLSLResourceTy;
12953 llvm_unreachable(
"Unexpected target builtin type");
12959 unsigned NumElements = strtoul(Str, &End, 10);
12960 assert(End != Str &&
"Missing vector size");
12964 RequiresICE,
false);
12965 assert(!RequiresICE &&
"Can't require vector ICE");
12974 unsigned NumElements = strtoul(Str, &End, 10);
12975 assert(End != Str &&
"Missing vector size");
12981 Type = Context.getExtVectorType(ElementType, NumElements);
12987 assert(!RequiresICE &&
"Can't require complex ICE");
12988 Type = Context.getComplexType(ElementType);
12992 Type = Context.getPointerDiffType();
12995 Type = Context.getFILEType();
12996 if (
Type.isNull()) {
13003 Type = Context.getsigjmp_bufType();
13005 Type = Context.getjmp_bufType();
13007 if (
Type.isNull()) {
13013 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
13014 Type = Context.getucontext_tType();
13016 if (
Type.isNull()) {
13022 Type = Context.getProcessIDType();
13025 Type = Context.MFloat8Ty;
13030 Done = !AllowTypeModifiers;
13032 switch (
char c = *Str++) {
13033 default: Done =
true; --Str;
break;
13039 unsigned AddrSpace = strtoul(Str, &End, 10);
13042 Type = Context.getAddrSpaceQualType(
13044 Context.getLangASForBuiltinAddressSpace(AddrSpace));
13048 Type = Context.getPointerType(
Type);
13050 Type = Context.getLValueReferenceType(
Type);
13058 Type = Context.getVolatileType(
Type);
13067 "Integer constant 'I' type must be an integer");
13080 bool AllowTypeModifiers)
const {
13087 unsigned *IntegerConstantArgs)
const {
13088 const char *TypeStr =
BuiltinInfo.getTypeString(Id);
13089 if (TypeStr[0] ==
'\0') {
13096 bool RequiresICE =
false;
13099 RequiresICE,
true);
13103 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
13105 while (TypeStr[0] && TypeStr[0] !=
'.') {
13112 if (RequiresICE && IntegerConstantArgs)
13113 *IntegerConstantArgs |= 1 << ArgTypes.size();
13119 ArgTypes.push_back(Ty);
13122 if (Id == Builtin::BI__GetExceptionInfo)
13125 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
13126 "'.' should only occur at end of builtin type list!");
13128 bool Variadic = (TypeStr[0] ==
'.');
13135 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
13185 if ((!Context.getLangOpts().CPlusPlus &&
13186 !Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13187 !FD->
hasAttr<DLLExportAttr>()) ||
13188 FD->
hasAttr<GNUInlineAttr>()) {
13207 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13210 !FD->
hasAttr<DLLExportAttr>()) {
13231 if (D->
hasAttr<DLLImportAttr>()) {
13234 }
else if (D->
hasAttr<DLLExportAttr>()) {
13237 }
else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice) {
13240 if (D->
hasAttr<CUDAGlobalAttr>() &&
13249 if (Context.shouldExternalize(D))
13264 switch (Source->hasExternalDefinitions(D)) {
13291 if (Context.getLangOpts().CPlusPlus &&
13292 Context.getLangOpts().IncrementalExtensions &&
13308 if (!LexicalContext)
13313 auto StaticLocalLinkage =
13325 return StaticLocalLinkage;
13331 if (Context.isMSStaticDataMemberInlineDefinition(VD))
13337 switch (Context.getInlineVariableDefinitionKind(VD)) {
13352 return StrongLinkage;
13355 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13370 llvm_unreachable(
"Invalid Linkage!");
13380 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13381 if (!VD->isFileVarDecl())
13386 if (VD->getDescribedVarTemplate() ||
13389 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13415 if (D->
hasAttr<WeakRefAttr>())
13422 if (LangOpts.SYCLIsDevice)
13424 D->
hasAttr<SYCLExternalAttr>());
13430 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13432 if (!FD->doesThisDeclarationHaveABody())
13433 return FD->doesDeclarationForceExternallyVisibleDefinition();
13436 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13441 if (
getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
13442 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13461 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13465 if (LangOpts.OpenMP &&
13466 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13473 if (VD->shouldEmitInExternalSource())
13486 if (VD->needsDestruction(*
this))
13490 if (VD->hasInitWithSideEffects())
13495 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13496 for (
const auto *BD : DD->flat_bindings())
13497 if (
const auto *BindingVD = BD->getHoldingVar())
13506 if (
auto *A = D->
getAttr<AttrT>())
13507 return A->isImplicit();
13512 assert(LangOpts.CUDA &&
"Should not be called by non-CUDA languages");
13514 "Expected Variable or Function");
13516 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13520 return !LangOpts.CUDAIsDevice || VD->hasAttr<CUDADeviceAttr>() ||
13521 VD->hasAttr<CUDAConstantAttr>() || VD->hasAttr<CUDASharedAttr>() ||
13522 VD->getType()->isCUDADeviceBuiltinSurfaceType() ||
13523 VD->getType()->isCUDADeviceBuiltinTextureType();
13528 if (!LangOpts.CUDAIsDevice)
13529 return FD->
hasAttr<CUDAHostAttr>() || !FD->
hasAttr<CUDADeviceAttr>();
13533 return (FD->
hasAttr<CUDADeviceAttr>() &&
13534 !(LangOpts.OffloadImplicitHostDeviceTemplates &&
13539 FD->
hasAttr<CUDAGlobalAttr>() ||
13540 (LangOpts.HIPStdPar && !FD->
hasAttr<CUDAHostAttr>());
13545 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13546 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13547 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13552 for (
auto *CurDecl :
13556 SeenDecls.insert(CurFD).second) {
13563 bool IsCXXMethod)
const {
13566 return ABI->getDefaultMethodCallConv(IsVariadic);
13568 switch (LangOpts.getDefaultCallingConv()) {
13596 return Target->getDefaultCallingConv();
13601 return ABI->isNearlyEmpty(RD);
13606 auto ABI = Target->getCXXABI();
13607 if (ABI.isMicrosoft())
13613 return VTContext.get();
13619 switch (
T->getCXXABI().getKind()) {
13620 case TargetCXXABI::AppleARM64:
13621 case TargetCXXABI::Fuchsia:
13622 case TargetCXXABI::GenericAArch64:
13623 case TargetCXXABI::GenericItanium:
13624 case TargetCXXABI::GenericARM:
13625 case TargetCXXABI::GenericMIPS:
13626 case TargetCXXABI::iOS:
13627 case TargetCXXABI::WebAssembly:
13628 case TargetCXXABI::WatchOS:
13629 case TargetCXXABI::XL:
13631 case TargetCXXABI::Microsoft:
13634 llvm_unreachable(
"Unsupported ABI");
13638 assert(
T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13639 "Device mangle context does not support Microsoft mangling.");
13640 switch (
T.getCXXABI().getKind()) {
13641 case TargetCXXABI::AppleARM64:
13642 case TargetCXXABI::Fuchsia:
13643 case TargetCXXABI::GenericAArch64:
13644 case TargetCXXABI::GenericItanium:
13645 case TargetCXXABI::GenericARM:
13646 case TargetCXXABI::GenericMIPS:
13647 case TargetCXXABI::iOS:
13648 case TargetCXXABI::WebAssembly:
13649 case TargetCXXABI::WatchOS:
13650 case TargetCXXABI::XL:
13654 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13655 return RD->getDeviceLambdaManglingNumber();
13656 return std::nullopt;
13659 case TargetCXXABI::Microsoft:
13663 llvm_unreachable(
"Unsupported ABI");
13681 return ASTRecordLayouts.getMemorySize() +
13682 llvm::capacity_in_bytes(ObjCLayouts) +
13683 llvm::capacity_in_bytes(KeyFunctions) +
13684 llvm::capacity_in_bytes(ObjCImpls) +
13685 llvm::capacity_in_bytes(BlockVarCopyInits) +
13686 llvm::capacity_in_bytes(DeclAttrs) +
13687 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13688 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13689 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13690 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13691 llvm::capacity_in_bytes(OverriddenMethods) +
13692 llvm::capacity_in_bytes(Types) +
13693 llvm::capacity_in_bytes(VariableArrayTypes);
13701 unsigned Signed)
const {
13704 if (!QualTy && DestWidth == 128)
13710 unsigned Signed)
const {
13711 return getFromTargetType(
13739 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13746 MangleNumbers[ND] = Number;
13749 Listener->AddedManglingNumber(ND, Number);
13753 bool ForAuxTarget)
const {
13754 auto I = MangleNumbers.find(ND);
13755 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13758 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13759 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13761 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13762 "number for aux target");
13764 return Res > 1 ? Res : 1;
13771 StaticLocalNumbers[VD] = Number;
13774 Listener->AddedStaticLocalNumbers(VD, Number);
13778 auto I = StaticLocalNumbers.find(VD);
13779 return I != StaticLocalNumbers.end() ? I->second : 1;
13783 bool IsDestroying) {
13784 if (!IsDestroying) {
13796 bool IsTypeAware) {
13797 if (!IsTypeAware) {
13813 OperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] = OperatorDelete;
13816 GlobalOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13820 ArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13824 GlobalArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13834 return OperatorDeletesForVirtualDtor.contains(Dtor->getCanonicalDecl());
13836 return GlobalOperatorDeletesForVirtualDtor.contains(
13837 Dtor->getCanonicalDecl());
13839 return ArrayOperatorDeletesForVirtualDtor.contains(
13840 Dtor->getCanonicalDecl());
13842 return GlobalArrayOperatorDeletesForVirtualDtor.contains(
13843 Dtor->getCanonicalDecl());
13854 if (OperatorDeletesForVirtualDtor.contains(Canon))
13855 return OperatorDeletesForVirtualDtor[Canon];
13858 if (GlobalOperatorDeletesForVirtualDtor.contains(Canon))
13859 return GlobalOperatorDeletesForVirtualDtor[Canon];
13862 if (ArrayOperatorDeletesForVirtualDtor.contains(Canon))
13863 return ArrayOperatorDeletesForVirtualDtor[Canon];
13866 if (GlobalArrayOperatorDeletesForVirtualDtor.contains(Canon))
13867 return GlobalArrayOperatorDeletesForVirtualDtor[Canon];
13878 return MaybeRequireVectorDeletingDtor.count(RD);
13886 MaybeRequireVectorDeletingDtor.insert(RD);
13891 assert(LangOpts.CPlusPlus);
13895 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13903 assert(LangOpts.CPlusPlus);
13904 std::unique_ptr<MangleNumberingContext> &MCtx =
13905 ExtraMangleNumberingContexts[D];
13911std::unique_ptr<MangleNumberingContext>
13913 return ABI->createMangleNumberingContext();
13918 return ABI->getCopyConstructorForExceptionObject(
13924 return ABI->addCopyConstructorForExceptionObject(
13931 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13936 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13941 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13945 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13949 ParamIndices[D] =
index;
13953 ParameterIndexTable::const_iterator I = ParamIndices.find(D);
13954 assert(I != ParamIndices.end() &&
13955 "ParmIndices lacks entry set by ParmVarDecl");
13960 unsigned Length)
const {
13986 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13988 llvm::FoldingSetNodeID ID;
13991 llvm::FoldingSetInsertToken
Token;
13996 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
14003 const APValue &APVal)
const {
14004 llvm::FoldingSetNodeID ID;
14007 llvm::FoldingSetInsertToken
Token;
14009 UnnamedGlobalConstantDecls.lookup(ID,
Token))
14013 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
14014 UnnamedGlobalConstantDecls.insert(
New,
Token);
14020 assert(
T->isRecordType() &&
"template param object of unexpected type");
14026 llvm::FoldingSetNodeID ID;
14029 llvm::FoldingSetInsertToken
Token;
14031 TemplateParamObjectDecls.lookup(ID,
Token))
14035 TemplateParamObjectDecls.insert(
New,
Token);
14041 if (!
T.isOSDarwin())
14044 if (!(
T.isiOS() &&
T.isOSVersionLT(7)) &&
14045 !(
T.isMacOSX() &&
T.isOSVersionLT(10, 9)))
14054 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
14061 if (MethodDecl->
hasAttr<UnavailableAttr>()
14062 || MethodDecl->
hasAttr<DeprecatedAttr>())
14076 IM != EM && IF != EF; ++IM, ++IF) {
14107 llvm::FoldingSetNodeID IDX, IDY;
14108 X->Profile(IDX, *
this,
true);
14109 Y->
Profile(IDY, *
this,
true);
14123 for (
const Decl *DX :
X->redecls()) {
14128 if (DX->isFirstDecl())
14131 llvm_unreachable(
"Corrupt redecls chain");
14134template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14136 return cast_or_null<T>(
14138 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
14141template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14149 bool IgnoreDeduced =
false) {
14164 bool IgnoreDeduced) {
14166 assert(R.getAsVoidPointer() !=
nullptr);
14172 assert(Xs.size() == Ys.size());
14174 for (
size_t I = 0; I < Rs.size(); ++I)
14181 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
14191 switch (
X.getKind()) {
14221 auto NExpX =
X.getNumTemplateExpansions();
14235 if (Xs.size() != Ys.size())
14237 R.resize(Xs.size());
14238 for (
size_t I = 0; I < R.size(); ++I) {
14251 assert(!Different);
14279 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
14281 return std::nullopt;
14286 assert(Kind == NNS2.
getKind());
14291 auto Kind = Namespace1->getKind();
14292 if (Kind != Namespace2->getKind() ||
14293 (Kind == Decl::NamespaceAlias &&
14298 Namespace2->getNamespace()),
14332 llvm_unreachable(
"singletons did not compare equal");
14334 assert(R.getCanonical() == Canon);
14340 const T *Y,
bool IsSame) {
14341 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
14361 QX +=
X.getQualifiers() - RQ;
14371 Y->getElementType(), QX, QY);
14382 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
14383 return X->getSizeExpr();
14388 return X->getSizeModifier();
14394 return X->getIndexTypeCVRQualifiers();
14404 llvm::DenseMap<QualType, unsigned>
Found;
14405 for (
auto Ts : {
X, Y}) {
14412 Out.emplace_back(
T);
14418FunctionProtoType::ExceptionSpecInfo
14422 bool AcceptDependent)
const {
14448 assert(AcceptDependent &&
14449 "computing composite pointer type of dependent types");
14464 llvm_unreachable(
"These ESTs should be handled above");
14469 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
14473 Result.Exceptions = ExceptionTypeStorage;
14480 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
14483 llvm_unreachable(
"invalid ExceptionSpecificationType");
14492#define UNEXPECTED_TYPE(Class, Kind) \
14493 case Type::Class: \
14494 llvm_unreachable("Unexpected " Kind ": " #Class);
14496#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
14497#define TYPE(Class, Base)
14498#include "clang/AST/TypeNodes.inc"
14500#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
14511#undef SUGAR_FREE_TYPE
14512#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
14515#undef NON_UNIQUE_TYPE
14519#undef UNEXPECTED_TYPE
14523 assert(AX->getDeducedKind() == AY->getDeducedKind());
14525 assert(AX->getKeyword() == AY->getKeyword());
14528 AY->getTypeConstraintConcept().getAsTemplateDecl());
14532 AY->getTypeConstraintArguments())) {
14539 case Type::IncompleteArray: {
14546 case Type::DependentSizedArray: {
14554 case Type::ConstantArray: {
14557 assert(AX->getSize() == AY->getSize());
14558 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14559 ? AX->getSizeExpr()
14565 case Type::ArrayParameter: {
14568 assert(AX->getSize() == AY->getSize());
14569 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14570 ? AX->getSizeExpr()
14577 case Type::Atomic: {
14582 case Type::Complex: {
14586 case Type::Pointer: {
14590 case Type::BlockPointer: {
14594 case Type::ObjCObjectPointer: {
14599 case Type::MemberPointer: {
14603 PY->getMostRecentCXXRecordDecl()));
14607 PX->getMostRecentCXXRecordDecl());
14609 case Type::LValueReference: {
14614 PX->isSpelledAsLValue() ||
14615 PY->isSpelledAsLValue());
14617 case Type::RValueReference: {
14623 case Type::DependentAddressSpace: {
14626 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14628 PX->getAddrSpaceExpr(),
14631 case Type::FunctionNoProto: {
14634 assert(FX->getExtInfo() == FY->getExtInfo());
14639 case Type::FunctionProto: {
14643 EPIY = FY->getExtProtoInfo();
14644 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14651 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14652 assert(EPIX.
Variadic == EPIY.Variadic);
14661 auto P =
getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
14669 case Type::ObjCObject: {
14672 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14673 OY->getProtocols().begin(), OY->getProtocols().end(),
14675 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14677 "protocol lists must be the same");
14679 OY->getTypeArgsAsWritten());
14682 OX->getProtocols(),
14683 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14685 case Type::ConstantMatrix: {
14688 assert(MX->getNumRows() == MY->getNumRows());
14689 assert(MX->getNumColumns() == MY->getNumColumns());
14691 MX->getNumRows(), MX->getNumColumns());
14693 case Type::DependentSizedMatrix: {
14696 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14697 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14702 case Type::Vector: {
14704 assert(VX->getNumElements() == VY->getNumElements());
14705 assert(VX->getVectorKind() == VY->getVectorKind());
14707 VX->getNumElements(), VX->getVectorKind());
14709 case Type::ExtVector: {
14711 assert(VX->getNumElements() == VY->getNumElements());
14713 VX->getNumElements());
14715 case Type::DependentSizedExtVector: {
14722 case Type::DependentVector: {
14725 assert(VX->getVectorKind() == VY->getVectorKind());
14732 case Type::InjectedClassName: {
14739 case Type::TemplateSpecialization: {
14743 TY->template_arguments());
14747 TY->getTemplateName(),
14749 As, {},
X->getCanonicalTypeInternal());
14751 case Type::Decltype: {
14754 assert(DX->isDependentType());
14755 assert(DY->isDependentType());
14756 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14760 case Type::PackIndexing: {
14763 assert(DX->isDependentType());
14764 assert(DY->isDependentType());
14765 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14768 case Type::DependentName: {
14771 assert(NX->getIdentifier() == NY->getIdentifier());
14776 case Type::OverflowBehavior: {
14779 assert(NX->getBehaviorKind() == NY->getBehaviorKind());
14781 NX->getBehaviorKind(),
14783 NY->getUnderlyingType(), QX, QY));
14785 case Type::UnaryTransform: {
14788 assert(TX->getUTTKind() == TY->getUTTKind());
14792 TY->getUnderlyingType()),
14795 case Type::PackExpansion: {
14798 assert(PX->getNumExpansions() == PY->getNumExpansions());
14801 PX->getNumExpansions(),
false);
14805 assert(PX->isReadOnly() == PY->isReadOnly());
14810 case Type::TemplateTypeParm: {
14813 assert(TX->getDepth() == TY->getDepth());
14814 assert(TX->getIndex() == TY->getIndex());
14815 assert(TX->isParameterPack() == TY->isParameterPack());
14817 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14821 llvm_unreachable(
"Unknown Type Class");
14831#define UNEXPECTED_TYPE(Class, Kind) \
14832 case Type::Class: \
14833 llvm_unreachable("Unexpected " Kind ": " #Class);
14834#define TYPE(Class, Base)
14835#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14836#include "clang/AST/TypeNodes.inc"
14838#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14865#undef CANONICAL_TYPE
14867#undef UNEXPECTED_TYPE
14869 case Type::Adjusted: {
14871 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14878 case Type::Decayed: {
14880 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14887 case Type::Attributed: {
14889 AttributedType::Kind Kind = AX->getAttrKind();
14890 if (Kind != AY->getAttrKind())
14892 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14900 case Type::BTFTagAttributed: {
14902 const BTFTypeTagAttr *AX = BX->getAttr();
14904 if (AX->getBTFTypeTag() !=
14915 if (KW != AY->getKeyword())
14920 AY->getTypeConstraintConcept().getAsTemplateDecl());
14924 AY->getTypeConstraintArguments())) {
14935 case Type::PackIndexing:
14936 case Type::Decltype:
14938 case Type::DeducedTemplateSpecialization:
14941 case Type::MacroQualified: {
14945 if (IX != MY->getMacroIdentifier())
14949 case Type::SubstTemplateTypeParm: {
14956 unsigned Index = SX->getIndex();
14957 if (Index != SY->getIndex())
14964 SX->getFinal() && SY->getFinal());
14966 case Type::ObjCTypeParam:
14972 case Type::TemplateSpecialization: {
14977 TY->getTemplateName(),
true);
14982 TY->template_arguments()))
14988 case Type::Typedef: {
14998 case Type::TypeOf: {
15009 case Type::TypeOfExpr:
15012 case Type::UnaryTransform: {
15015 UnaryTransformType::UTTKind KX = UX->getUTTKind();
15016 if (KX != UY->getUTTKind())
15018 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
15025 case Type::Using: {
15034 case Type::MemberPointer: {
15038 assert(Cls == PY->getMostRecentCXXRecordDecl());
15043 case Type::CountAttributed: {
15046 if (DX->isCountInBytes() != DY->isCountInBytes())
15048 if (DX->isOrNull() != DY->isOrNull())
15050 Expr *CEX = DX->getCountExpr();
15051 Expr *CEY = DY->getCountExpr();
15055 DX->isCountInBytes(), DX->isOrNull(),
15066 DX->isCountInBytes(), DX->isOrNull(),
15070 case Type::LateParsedAttr:
15073 case Type::PredefinedSugar:
15078 llvm_unreachable(
"Unhandled Type Class");
15085 QualType NT =
T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
15100 if (
X.isCanonical())
15127 bool KeepCommonQualifiers =
15130 if (SX.
Ty != SY.Ty) {
15138 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
15141 SX = Xs.pop_back_val();
15142 SY = Ys.pop_back_val();
15145 if (KeepCommonQualifiers)
15152 while (!Xs.empty() && !Ys.empty()) {
15155 SX = Xs.pop_back_val();
15156 SY = Ys.pop_back_val();
15161 SX.
Ty = Underlying.Ty;
15164 QX -= Underlying.Quals;
15182 llvm_unreachable(
"Not a saturated fixed point type!");
15183 case BuiltinType::SatShortAccum:
15185 case BuiltinType::SatAccum:
15187 case BuiltinType::SatLongAccum:
15189 case BuiltinType::SatUShortAccum:
15191 case BuiltinType::SatUAccum:
15193 case BuiltinType::SatULongAccum:
15195 case BuiltinType::SatShortFract:
15197 case BuiltinType::SatFract:
15199 case BuiltinType::SatLongFract:
15201 case BuiltinType::SatUShortFract:
15203 case BuiltinType::SatUFract:
15205 case BuiltinType::SatULongFract:
15217 llvm_unreachable(
"Not a fixed point type!");
15218 case BuiltinType::ShortAccum:
15220 case BuiltinType::Accum:
15222 case BuiltinType::LongAccum:
15224 case BuiltinType::UShortAccum:
15226 case BuiltinType::UAccum:
15228 case BuiltinType::ULongAccum:
15230 case BuiltinType::ShortFract:
15232 case BuiltinType::Fract:
15234 case BuiltinType::LongFract:
15236 case BuiltinType::UShortFract:
15238 case BuiltinType::UFract:
15240 case BuiltinType::ULongFract:
15246 if (LangOpts.OpenCL)
15261 llvm_unreachable(
"Not a fixed point type!");
15262 case BuiltinType::ShortAccum:
15263 case BuiltinType::SatShortAccum:
15264 return Target.getShortAccumScale();
15265 case BuiltinType::Accum:
15266 case BuiltinType::SatAccum:
15267 return Target.getAccumScale();
15268 case BuiltinType::LongAccum:
15269 case BuiltinType::SatLongAccum:
15270 return Target.getLongAccumScale();
15271 case BuiltinType::UShortAccum:
15272 case BuiltinType::SatUShortAccum:
15273 return Target.getUnsignedShortAccumScale();
15274 case BuiltinType::UAccum:
15275 case BuiltinType::SatUAccum:
15276 return Target.getUnsignedAccumScale();
15277 case BuiltinType::ULongAccum:
15278 case BuiltinType::SatULongAccum:
15279 return Target.getUnsignedLongAccumScale();
15280 case BuiltinType::ShortFract:
15281 case BuiltinType::SatShortFract:
15282 return Target.getShortFractScale();
15283 case BuiltinType::Fract:
15284 case BuiltinType::SatFract:
15285 return Target.getFractScale();
15286 case BuiltinType::LongFract:
15287 case BuiltinType::SatLongFract:
15288 return Target.getLongFractScale();
15289 case BuiltinType::UShortFract:
15290 case BuiltinType::SatUShortFract:
15291 return Target.getUnsignedShortFractScale();
15292 case BuiltinType::UFract:
15293 case BuiltinType::SatUFract:
15294 return Target.getUnsignedFractScale();
15295 case BuiltinType::ULongFract:
15296 case BuiltinType::SatULongFract:
15297 return Target.getUnsignedLongFractScale();
15307 llvm_unreachable(
"Not a fixed point type!");
15308 case BuiltinType::ShortAccum:
15309 case BuiltinType::SatShortAccum:
15310 return Target.getShortAccumIBits();
15311 case BuiltinType::Accum:
15312 case BuiltinType::SatAccum:
15313 return Target.getAccumIBits();
15314 case BuiltinType::LongAccum:
15315 case BuiltinType::SatLongAccum:
15316 return Target.getLongAccumIBits();
15317 case BuiltinType::UShortAccum:
15318 case BuiltinType::SatUShortAccum:
15319 return Target.getUnsignedShortAccumIBits();
15320 case BuiltinType::UAccum:
15321 case BuiltinType::SatUAccum:
15322 return Target.getUnsignedAccumIBits();
15323 case BuiltinType::ULongAccum:
15324 case BuiltinType::SatULongAccum:
15325 return Target.getUnsignedLongAccumIBits();
15326 case BuiltinType::ShortFract:
15327 case BuiltinType::SatShortFract:
15328 case BuiltinType::Fract:
15329 case BuiltinType::SatFract:
15330 case BuiltinType::LongFract:
15331 case BuiltinType::SatLongFract:
15332 case BuiltinType::UShortFract:
15333 case BuiltinType::SatUShortFract:
15334 case BuiltinType::UFract:
15335 case BuiltinType::SatUFract:
15336 case BuiltinType::ULongFract:
15337 case BuiltinType::SatULongFract:
15342llvm::FixedPointSemantics
15345 "Can only get the fixed point semantics for a "
15346 "fixed point or integer type.");
15348 return llvm::FixedPointSemantics::GetIntegerSemantics(
15352 return llvm::FixedPointSemantics(
15355 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
15370 "Expected unsigned fixed point type");
15373 case BuiltinType::UShortAccum:
15375 case BuiltinType::UAccum:
15377 case BuiltinType::ULongAccum:
15379 case BuiltinType::SatUShortAccum:
15381 case BuiltinType::SatUAccum:
15383 case BuiltinType::SatULongAccum:
15385 case BuiltinType::UShortFract:
15387 case BuiltinType::UFract:
15389 case BuiltinType::ULongFract:
15391 case BuiltinType::SatUShortFract:
15393 case BuiltinType::SatUFract:
15395 case BuiltinType::SatULongFract:
15398 llvm_unreachable(
"Unexpected unsigned fixed point type");
15406 std::vector<std::string> BackendFeats;
15407 llvm::AArch64::ExtensionSet FeatureBits;
15408 for (StringRef F : FMVFeatStrings)
15409 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
15411 FeatureBits.enable(*FMVExt->ID);
15412 FeatureBits.toLLVMFeatureList(BackendFeats);
15413 return BackendFeats;
15418 assert(TD !=
nullptr);
15421 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
15422 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
15433 Target->getTargetOpts().CPU,
15434 Target->getTargetOpts().Features);
15441 StringRef TargetCPU = Target->getTargetOpts().CPU;
15443 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
15449 if (!Target->getTriple().isAArch64())
15452 Target->getTargetOpts().FeaturesAsWritten.begin(),
15453 Target->getTargetOpts().FeaturesAsWritten.end());
15464 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
15466 Target->getCPUSpecificCPUDispatchFeatures(
15468 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
15469 Features.insert(Features.begin(),
15470 Target->getTargetOpts().FeaturesAsWritten.begin(),
15471 Target->getTargetOpts().FeaturesAsWritten.end());
15472 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15473 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
15474 if (Target->getTriple().isAArch64()) {
15478 Features.insert(Features.begin(),
15479 Target->getTargetOpts().FeaturesAsWritten.begin(),
15480 Target->getTargetOpts().FeaturesAsWritten.end());
15481 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15482 }
else if (Target->getTriple().isRISCV()) {
15484 std::vector<std::string> Features;
15485 if (VersionStr !=
"default") {
15487 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15490 Features.insert(Features.begin(),
15491 Target->getTargetOpts().FeaturesAsWritten.begin(),
15492 Target->getTargetOpts().FeaturesAsWritten.end());
15493 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15494 }
else if (Target->getTriple().isOSAIX()) {
15495 std::vector<std::string> Features;
15497 if (VersionStr.starts_with(
"cpu="))
15498 TargetCPU = VersionStr.drop_front(
sizeof(
"cpu=") - 1);
15499 else if (VersionStr !=
"default")
15500 Features = Target->parseTargetAttr(VersionStr).Features;
15501 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15503 std::vector<std::string> Features;
15505 if (VersionStr.starts_with(
"arch="))
15506 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
15507 else if (VersionStr !=
"default")
15508 Features.push_back((StringRef{
"+"} + VersionStr).str());
15509 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15511 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
15512 std::vector<std::string> Features;
15513 if (Target->getTriple().isRISCV()) {
15515 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15518 assert(Target->getTriple().isAArch64());
15520 TV->getFeatures(Feats);
15523 Features.insert(Features.begin(),
15524 Target->getTargetOpts().FeaturesAsWritten.begin(),
15525 Target->getTargetOpts().FeaturesAsWritten.end());
15526 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15528 FeatureMap = Target->getTargetOpts().FeatureMap;
15539 auto DeviceDiscriminatorOverrider =
15541 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15543 return RD->getDeviceLambdaManglingNumber();
15544 return std::nullopt;
15547 Context, Context.getDiagnostics(), DeviceDiscriminatorOverrider)};
15555 std::string Buffer;
15556 Buffer.reserve(128);
15557 llvm::raw_string_ostream Out(Buffer);
15558 MC->mangleCanonicalTypeName(KernelNameType, Out);
15559 std::string KernelName = Out.str();
15561 return {KernelNameType, FD, KernelName};
15570 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15571 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15580 "SYCL kernel name conflict");
15595 return &IT->second;
15601 return *OMPTraitInfoVector.back();
15608 return DB << Section.
Decl;
15609 return DB <<
"a prior #pragma section";
15613 bool IsInternalVar =
15616 bool IsExplicitDeviceVar = (D->
hasAttr<CUDADeviceAttr>() &&
15617 !D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15618 (D->
hasAttr<CUDAConstantAttr>() &&
15619 !D->
getAttr<CUDAConstantAttr>()->isImplicit());
15623 return (IsInternalVar &&
15624 (D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15625 (D->
hasAttr<CUDAGlobalAttr>() &&
15632 (D->
hasAttr<HIPManagedAttr>() || D->
hasAttr<CUDAGlobalAttr>() ||
15637 if (!CUIDHash.empty())
15639 if (LangOpts.CUID.empty())
15640 return StringRef();
15641 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.CUID),
true);
15651 assert(PrimaryBase);
15654 auto Base = Layout.getPrimaryBase();
15655 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15657 PrimaryBase =
Base;
15659 return PrimaryBase;
15663 StringRef MangledName) {
15665 assert(
Method->isVirtual());
15666 bool DefaultIncludesPointerAuth =
15667 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15669 if (!DefaultIncludesPointerAuth)
15672 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15673 if (Existing != ThunksToBeAbbreviated.end())
15674 return Existing->second.contains(MangledName.str());
15677 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15679 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15681 for (
const auto &Thunk : *ThunkInfos) {
15683 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15689 Mangler->mangleThunk(
Method, Thunk,
true,
15692 llvm::raw_svector_ostream mangledNameStream(MangledName);
15696 mangledNameStream);
15698 Mangler->mangleThunk(
Method, Thunk,
false,
15699 mangledNameStream);
15701 Thunks[ElidedName].push_back(std::string(MangledName));
15704 llvm::StringSet<> SimplifiedThunkNames;
15705 for (
auto &ThunkList : Thunks) {
15706 llvm::sort(ThunkList.second);
15707 SimplifiedThunkNames.insert(ThunkList.second[0]);
15709 bool Result = SimplifiedThunkNames.contains(MangledName);
15710 ThunksToBeAbbreviated[VirtualMethodDecl] = std::move(SimplifiedThunkNames);
15728 std::vector<PFPField> &Fields,
bool IncludeVBases) {
15730 if (
auto *ElemDecl = AT->getElementType()->getAsCXXRecordDecl()) {
15732 for (
unsigned i = 0; i != AT->getSize(); ++i)
15749 Fields.push_back({FieldOffset, Field});
15756 if (
Base.isVirtual())
15763 if (IncludeVBases) {
15774 std::vector<PFPField> PFPFields;
15784 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->
getParent()))
15786 !FD->
hasAttr<NoFieldProtectionAttr>();
15791 auto *FD = dyn_cast<FieldDecl>(VD);
15814struct PaddingCalculator {
15815 PaddingCalculator(
const ASTContext &Ctx) : Ctx(Ctx) {}
15818 OccuppiedIntervals.clear();
15824 while (!Stack.empty()) {
15825 Data Current = Stack.back();
15829 MergeOccuppiedIntervals();
15832 llvm::SmallVector<ASTContext::BitInterval> GetPaddingIntervals() {
15833 llvm::SmallVector<ASTContext::BitInterval> Results;
15834 if (OccuppiedIntervals.size() == 1 &&
15835 OccuppiedIntervals.front().First == 0 &&
15836 OccuppiedIntervals.front().Last == TySizeInBits) {
15839 Results.reserve(OccuppiedIntervals.size() + 1);
15841 for (
const ASTContext::BitInterval &OccupiedInterval : OccuppiedIntervals) {
15842 if (OccupiedInterval.First > CurrentPos) {
15844 ASTContext::BitInterval{CurrentPos, OccupiedInterval.First});
15846 CurrentPos = OccupiedInterval.Last;
15848 if (TySizeInBits > CurrentPos) {
15849 Results.push_back(ASTContext::BitInterval{CurrentPos, TySizeInBits});
15858 bool VisitVirtualBase;
15884 uint64_t getScalarOccupiedSizeInBits(QualType Ty)
const {
15885 if (
const auto *BIT = Ty->
getAs<BitIntType>())
15886 return BIT->getNumBits();
15888 if (
const auto *BT = Ty->
getAs<BuiltinType>()) {
15889 if (BT->getKind() == BuiltinType::LongDouble &&
15891 &llvm::APFloat::x87DoubleExtended())
15892 return llvm::APFloat::getSizeInBits(
15899 void Visit(
const Data &D) {
15900 if (
auto *AT = dyn_cast<ConstantArrayType>(D.Ty)) {
15901 VisitArray(AT, D.StartBitOffset);
15905 if (
auto *
Record = D.Ty->getAsRecordDecl()) {
15906 VisitStruct(
Record, D.StartBitOffset, D.VisitVirtualBase);
15910 if (D.Ty->isAtomicType()) {
15911 auto Unwrapped = D;
15912 Unwrapped.Ty = D.Ty.getAtomicUnqualifiedType().getCanonicalType();
15913 Stack.push_back(Unwrapped);
15917 if (
const auto *
Complex = D.Ty->getAs<ComplexType>()) {
15918 VisitComplex(
Complex, D.StartBitOffset);
15922 if (
const auto *VT = D.Ty->getAs<clang::VectorType>()) {
15923 VisitVector(VT, D.StartBitOffset);
15927 if (
const auto *BITy = D.Ty->getAs<BitIntType>()) {
15928 VisitBitInt(BITy, D.StartBitOffset);
15932 uint64_t SizeBit = getScalarOccupiedSizeInBits(D.Ty);
15933 OccuppiedIntervals.push_back(
15934 ASTContext::BitInterval{D.StartBitOffset, D.StartBitOffset + SizeBit});
15937 void VisitArray(
const ConstantArrayType *AT, uint64_t StartBitOffset) {
15938 for (uint64_t ArrIndex = 0; ArrIndex < AT->
getSize().getLimitedValue();
15944 auto Offset = ElementSize.
alignTo(ElementAlign);
15946 Stack.push_back(
Data{
15947 StartBitOffset + ArrIndex * Offset.getQuantity() * Ctx.
getCharWidth(),
15952 void VisitStruct(
const RecordDecl *R, uint64_t StartBitOffset,
15953 bool VisitVirtualBase) {
15955 auto *
CXXRecord = dyn_cast<CXXRecordDecl>(R);
15961 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15962 StartBitOffset, StartBitOffset + PointerSizeInBits});
15967 auto StartVBPtr = StartBitOffset + Offset * Ctx.
getCharWidth();
15968 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15969 StartVBPtr, StartVBPtr + PointerSizeInBits});
15972 const auto VisitBase = [&ASTLayout, StartBitOffset,
this](
15973 const CXXBaseSpecifier &
Base,
auto GetOffset) {
15974 auto *BaseRecord =
Base.getType()->getAsCXXRecordDecl();
15979 std::invoke(GetOffset, ASTLayout, BaseRecord).getQuantity();
15983 Base.getType().getCanonicalType(),
15988 if (!
Base.isVirtual()) {
15993 if (VisitVirtualBase) {
15994 for (
auto VBase :
CXXRecord->vbases()) {
16000 for (
auto *Field :
R->fields()) {
16002 if (
Field->isUnnamedBitField())
16006 if (
Field->isBitField()) {
16007 VisitBitfield(Field, StartBitOffset + FieldOffset);
16009 Stack.push_back(
Data{StartBitOffset + FieldOffset,
16010 Field->getType().getCanonicalType(),
16016 void VisitBitfield(
const FieldDecl *Field, uint64_t StartBitOffset) {
16017 assert(
Field->isBitField() && !
Field->isUnnamedBitField());
16018 if (
Field->isZeroLengthBitField())
16021 const uint64_t DeclaredSizeInBits =
Field->getBitWidthValue();
16030 const uint64_t OccupiedSizeInBits =
16034 OccuppiedIntervals.push_back(
16035 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16050 const uint64_t Start = StartBitOffset;
16051 const uint64_t End = Start + OccupiedSizeInBits;
16055 const uint64_t ByteStart = llvm::alignDown(Start, CharWidth);
16056 const uint64_t ByteEnd = llvm::alignTo(End, CharWidth);
16057 if (ByteStart == ByteEnd - CharWidth) {
16058 const uint64_t Length = End - Start;
16059 const uint64_t Offset = Start - ByteStart;
16060 OccuppiedIntervals.push_back(
16061 {ByteEnd - Offset - Length, ByteEnd - Offset});
16067 const uint64_t MiddleIntervalStart = llvm::alignTo(Start, CharWidth);
16068 const uint64_t MiddleIntervalEnd = llvm::alignDown(End, CharWidth);
16069 if (MiddleIntervalStart != MiddleIntervalEnd)
16070 OccuppiedIntervals.push_back({MiddleIntervalStart, MiddleIntervalEnd});
16074 if (Start != MiddleIntervalStart) {
16075 const uint64_t Length = MiddleIntervalStart - Start;
16076 OccuppiedIntervals.push_back({ByteStart, ByteStart + Length});
16081 if (End != MiddleIntervalEnd) {
16082 const uint64_t Length = End - MiddleIntervalEnd;
16083 OccuppiedIntervals.push_back({ByteEnd - Length, ByteEnd});
16087 void VisitComplex(
const ComplexType *CT, uint64_t StartBitOffset) {
16091 auto ImgOffset = ElementSize.
alignTo(ElementAlign);
16094 Data{StartBitOffset, ElementQualType,
true});
16097 ElementQualType,
true});
16100 void VisitVector(
const clang::VectorType *VT, uint64_t StartBitOffset) {
16102 VisitPackedBooleanVector(VT, StartBitOffset);
16108 OccuppiedIntervals.push_back(
16109 ASTContext::BitInterval{StartBitOffset, StartBitOffset + SizeBit});
16117 void VisitBitInt(
const BitIntType *Ty, uint64_t StartBitOffset) {
16121 OccuppiedIntervals.push_back(
16122 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16134 const uint64_t NumFullyPaddingBytes =
16135 (StorageSizeInBits - OccupiedSizeInBits) / CharWidth;
16136 const uint64_t NumFullyOccupiedBytes = OccupiedSizeInBits / CharWidth;
16137 const uint64_t NumRemainingOccupiedBits = OccupiedSizeInBits % CharWidth;
16140 if (NumRemainingOccupiedBits > 0)
16141 OccuppiedIntervals.push_back(
16142 {StartBitOffset + NumFullyPaddingBytes * CharWidth,
16143 StartBitOffset + NumFullyPaddingBytes * CharWidth +
16144 NumRemainingOccupiedBits});
16147 if (NumFullyOccupiedBytes > 0)
16148 OccuppiedIntervals.push_back({StartBitOffset + StorageSizeInBits -
16149 NumFullyOccupiedBytes * CharWidth,
16150 StartBitOffset + StorageSizeInBits});
16153 void VisitPackedBooleanVector(
const VectorType *VTy,
16154 uint64_t StartBitOffset) {
16156 assert(StartBitOffset % CharWidth == 0 &&
16157 "Expected aligned packed boolean vector");
16162 OccuppiedIntervals.push_back(
16163 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16171 const uint64_t NumFullyOccupiedBytes = OccupiedSizeInBits / CharWidth;
16172 const uint64_t NumRemainingOccupiedBits = OccupiedSizeInBits % CharWidth;
16176 if (NumRemainingOccupiedBits > 0) {
16177 const uint64_t ByteEnd = Start + CharWidth;
16178 OccuppiedIntervals.push_back({Start, Start + NumRemainingOccupiedBits});
16183 if (NumFullyOccupiedBytes > 0) {
16184 OccuppiedIntervals.push_back(
16185 {Start, Start + NumFullyOccupiedBytes * CharWidth});
16189 void MergeOccuppiedIntervals() {
16190 std::sort(OccuppiedIntervals.begin(), OccuppiedIntervals.end(),
16191 [](
const ASTContext::BitInterval &lhs,
16192 const ASTContext::BitInterval &rhs) {
16193 return std::tie(lhs.First, lhs.Last) <
16194 std::tie(rhs.First, rhs.Last);
16197 llvm::SmallVector<ASTContext::BitInterval> Merged;
16198 Merged.reserve(OccuppiedIntervals.size());
16200 for (
const ASTContext::BitInterval &NextInterval : OccuppiedIntervals) {
16201 if (Merged.empty()) {
16202 Merged.push_back(NextInterval);
16205 auto &LastInterval = Merged.back();
16207 if (NextInterval.First > LastInterval.Last) {
16208 Merged.push_back(NextInterval);
16210 LastInterval.Last = std::max(LastInterval.Last, NextInterval.Last);
16214 OccuppiedIntervals = Merged;
16217 const ASTContext &Ctx;
16220 llvm::SmallVector<Data> Stack;
16221 llvm::SmallVector<ASTContext::BitInterval> OccuppiedIntervals;
16225llvm::ArrayRef<ASTContext::BitInterval>
16228 auto cached = PaddingIntervalCache.find(Ty);
16229 if (cached != PaddingIntervalCache.end())
16230 return cached->second;
16232 PaddingCalculator pc{*
this};
16236 PaddingIntervalCache.insert_or_assign(Ty, pc.GetPaddingIntervals());
16237 assert(res &&
"Failed to insert?");
16239 return itr->second;
This file provides AST data structures related to concepts.
static void SortAndUniqueProtocols(SmallVectorImpl< ObjCProtocolDecl * > &Protocols)
static bool isCanonicalExceptionSpecification(const FunctionProtoType::ExceptionSpecInfo &ESI, bool NoexceptInType)
static SourceLocation getCommonAttrLoc(const T *X, const T *Y)
static auto getCanonicalTemplateArguments(const ASTContext &C, ArrayRef< TemplateArgument > Args, bool &AnyNonCanonArgs)
static char getObjCEncodingForPrimitiveType(const ASTContext *C, const BuiltinType *BT)
static bool isSameQualifier(const NestedNameSpecifier X, const NestedNameSpecifier Y)
static bool unionHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static TypedefDecl * CreateHexagonBuiltinVaListDecl(const ASTContext *Context)
#define CANONICAL_TYPE(Class)
static ElaboratedTypeKeyword getCommonTypeKeyword(const T *X, const T *Y, bool IsSame)
static Decl * getCommonDecl(Decl *X, Decl *Y)
static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context, const Decl *D, GVALinkage L)
static bool isTypeTypedefedAsBOOL(QualType T)
static void EncodeBitField(const ASTContext *Ctx, std::string &S, QualType T, const FieldDecl *FD)
static GVALinkage basicGVALinkageForVariable(const ASTContext &Context, const VarDecl *VD)
static QualType getCommonArrayElementType(const ASTContext &Ctx, const T *X, Qualifiers &QX, const T *Y, Qualifiers &QY)
static bool hasImplicitAttr(const ValueDecl *D)
#define SUGAR_FREE_TYPE(Class)
static SYCLKernelInfo BuildSYCLKernelInfo(ASTContext &Context, CanQualType KernelNameType, const FunctionDecl *FD)
static bool hasTemplateSpecializationInEncodedString(const Type *T, bool VisitBasesAndFields)
static void getIntersectionOfProtocols(ASTContext &Context, const ObjCInterfaceDecl *CommonBase, const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, SmallVectorImpl< ObjCProtocolDecl * > &IntersectionSet)
getIntersectionOfProtocols - This routine finds the intersection of set of protocols inherited from t...
static bool areCompatMatrixTypes(const ConstantMatrixType *LHS, const ConstantMatrixType *RHS)
areCompatMatrixTypes - Return true if the two specified matrix types are compatible.
static TypedefDecl * CreateAAPCSABIBuiltinVaListDecl(const ASTContext *Context)
static bool sameObjCTypeArgs(ASTContext &ctx, const ObjCInterfaceDecl *iface, ArrayRef< QualType > lhsArgs, ArrayRef< QualType > rhsArgs, bool stripKindOf)
static bool canAssignObjCObjectTypes(ASTContext &ctx, QualType lhs, QualType rhs)
Determine whether the first type is a subtype of the second.
static const Type * getIntegerTypeForEnum(const EnumType *ET)
static SmallVector< SourceLocation, 2 > getLocsForCommentSearch(ASTContext::RawCommentLookupKey Key, SourceManager &SourceMgr)
static bool hasSameCudaAttrs(const FunctionDecl *A, const FunctionDecl *B)
static TemplateName getCommonTemplateName(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced=false)
static int CmpProtocolNames(ObjCProtocolDecl *const *LHS, ObjCProtocolDecl *const *RHS)
CmpProtocolNames - Comparison predicate for sorting protocols alphabetically.
static auto * getCommonSizeExpr(const ASTContext &Ctx, T *X, T *Y)
static TypedefDecl * CreatePowerABIBuiltinVaListDecl(const ASTContext *Context)
static auto getCommonSizeModifier(const ArrayType *X, const ArrayType *Y)
static TemplateArgument getCommonTemplateArgument(const ASTContext &Ctx, const TemplateArgument &X, const TemplateArgument &Y)
static std::optional< int64_t > structHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static bool hasSameOverloadableAttrs(const FunctionDecl *A, const FunctionDecl *B)
Determine whether the attributes we can overload on are identical for A and B.
static T * getCommonDeclChecked(T *X, T *Y)
static NestedNameSpecifier getCommonNNS(const ASTContext &Ctx, NestedNameSpecifier NNS1, NestedNameSpecifier NNS2, bool IsSame)
Returns a NestedNameSpecifier which has only the common sugar present in both NNS1 and NNS2.
static TypedefDecl * CreateVoidPtrBuiltinVaListDecl(const ASTContext *Context)
static int64_t getSubobjectOffset(const FieldDecl *Field, const ASTContext &Context, const clang::ASTRecordLayout &)
static QualType getCommonSugarTypeNode(const ASTContext &Ctx, const Type *X, const Type *Y, SplitQualType Underlying)
static TypedefDecl * CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X, Qualifiers &QX, const Type *Y, Qualifiers &QY)
static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET, QualType other, bool isBlockReturnType)
Given that we have an enum type and a non-enum type, try to merge them.
static GVALinkage adjustGVALinkageForExternalDefinitionKind(const ASTContext &Ctx, const Decl *D, GVALinkage L)
Adjust the GVALinkage for a declaration based on what an external AST source knows about whether ther...
static TypedefDecl * CreateSystemZBuiltinVaListDecl(const ASTContext *Context)
static std::optional< int64_t > getSubobjectSizeInBits(const FieldDecl *Field, const ASTContext &Context, bool CheckIfTriviallyCopyable)
static GVALinkage basicGVALinkageForFunction(const ASTContext &Context, const FunctionDecl *FD)
#define NON_UNIQUE_TYPE(Class)
static TypedefDecl * CreateX86_64ABIBuiltinVaListDecl(const ASTContext *Context)
static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI, const LangOptions &LangOpts)
static ElaboratedTypeKeyword getCanonicalElaboratedTypeKeyword(ElaboratedTypeKeyword Keyword)
static QualType getCommonPointeeType(const ASTContext &Ctx, const T *X, const T *Y)
static auto getCommonIndexTypeCVRQualifiers(const ArrayType *X, const ArrayType *Y)
static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequiresICE, bool AllowTypeModifiers)
DecodeTypeFromStr - This decodes one type descriptor from Str, advancing the pointer over the consume...
static TypedefDecl * CreateCharPtrBuiltinVaListDecl(const ASTContext *Context)
static bool areSortedAndUniqued(ArrayRef< ObjCProtocolDecl * > Protocols)
static TypeInfoChars getConstantArrayInfoInChars(const ASTContext &Context, const ConstantArrayType *CAT)
getConstantArrayInfoInChars - Performing the computation in CharUnits instead of in bits prevents ove...
static FloatingRank getFloatingRank(QualType T)
getFloatingRank - Return a relative rank for floating point types.
static bool getCommonTemplateArguments(const ASTContext &Ctx, SmallVectorImpl< TemplateArgument > &R, ArrayRef< TemplateArgument > Xs, ArrayRef< TemplateArgument > Ys)
static TypedefDecl * CreateXtensaABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonElementType(const ASTContext &Ctx, const T *X, const T *Y)
static void mergeTypeLists(const ASTContext &Ctx, SmallVectorImpl< QualType > &Out, ArrayRef< QualType > X, ArrayRef< QualType > Y)
static bool matchesPostDecrInWhile(const UnaryOperator *UO, ASTContext &Ctx)
For the purposes of overflow pattern exclusion, does this match the while(i–) pattern?
static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx, raw_ostream &OS, QualType QT)
Encode a function type for use in the discriminator of a function pointer type.
static std::optional< int64_t > structSubobjectsHaveUniqueObjectRepresentations(const RangeT &Subobjects, int64_t CurOffsetInBits, const ASTContext &Context, const clang::ASTRecordLayout &Layout, bool CheckIfTriviallyCopyable)
static uint64_t getRVVTypeSize(ASTContext &Context, const BuiltinType *Ty)
getRVVTypeSize - Return RVV vector register size.
static auto unwrapSugar(SplitQualType &T, Qualifiers &QTotal)
static TemplateName getCommonTemplateNameChecked(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced)
static int compareObjCProtocolsByName(ObjCProtocolDecl *const *lhs, ObjCProtocolDecl *const *rhs)
Comparison routine for Objective-C protocols to be used with llvm::array_pod_sort.
static const TagDecl * getNonInjectedClassName(const TagDecl *TD)
static TypedefDecl * CreateZOSVaListDecl(const ASTContext *Context)
static bool hasAnyPackExpansions(ArrayRef< TemplateArgument > Args)
static char ObjCEncodingForEnumDecl(const ASTContext *C, const EnumDecl *ED)
static std::string charUnitsToString(CharUnits CU)
static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod, SmallVectorImpl< const NamedDecl * > &Redeclared)
static QualType getCommonTypeWithQualifierLifting(const ASTContext &Ctx, QualType X, QualType Y, Qualifiers &QX, Qualifiers &QY)
static auto getCommonTypes(const ASTContext &Ctx, ArrayRef< QualType > Xs, ArrayRef< QualType > Ys, bool Unqualified=false)
static bool isCanonicalResultType(QualType T)
Determine whether T is canonical as the result type of a function.
static TypedefDecl * CreateMSVaListDecl(const ASTContext *Context)
static bool areCompatVectorTypes(const VectorType *LHS, const VectorType *RHS)
areCompatVectorTypes - Return true if the two specified vector types are compatible.
static TypedefDecl * CreateCharPtrNamedVaListDecl(const ASTContext *Context, StringRef Name)
static NestedNameSpecifier getCommonQualifier(const ASTContext &Ctx, const T *X, const T *Y, bool IsSame)
#define UNEXPECTED_TYPE(Class, Kind)
static TypedefDecl * CreateVaListDecl(const ASTContext *Context, TargetInfo::BuiltinVaListKind Kind)
static bool primaryBaseHaseAddressDiscriminatedVTableAuthentication(const ASTContext &Context, const CXXRecordDecl *Class)
static std::vector< std::string > getFMVBackendFeaturesFor(const llvm::SmallVectorImpl< StringRef > &FMVFeatStrings)
Defines the clang::ASTContext interface.
#define BuiltinTemplate(BTName)
This file provides some common utility functions for processing Lambda related AST Constructs.
Provides definitions for the various language-specific address spaces.
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
Defines enum values for all the target-independent builtin functions.
static bool CanThrow(Expr *E, ASTContext &Ctx)
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static const Decl * getCanonicalDecl(const Decl *D)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
Defines the clang::Module class, which describes a module in the source code.
static StringRef getTriple(const Command &Job)
Defines types useful for describing an Objective-C runtime.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
static QualType getUnderlyingType(const SubRegion *R)
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
RawComment * getRawCommentNoCacheImpl(RawCommentLookupKey Key, const SourceLocation RepresentativeLoc, const std::map< unsigned, RawComment * > &CommentsInFile) const
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
bool isMemberPointerToDerivedMember() const
const ValueDecl * getMemberPointerDecl() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const
Returns true, if given type has a known lifetime.
MSGuidDecl * getMSGuidDecl(MSGuidDeclParts Parts) const
Return a declaration for the global GUID object representing the given GUID value.
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl, const ObjCMethodDecl *MethodImp)
CanQualType ObjCBuiltinSelTy
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
void InitBuiltinTypes(const TargetInfo &Target, const TargetInfo *AuxTarget=nullptr)
Initialize built-in types.
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
CanQualType ARCUnbridgedCastTy
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, QualType Wrapped) const
llvm::DenseMap< const Decl *, comments::FullComment * > ParsedComments
Mapping from declarations to parsed comments attached to any redeclaration.
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
unsigned getIntWidth(QualType T) const
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
InlineVariableDefinitionKind
@ None
Not an inline variable.
@ Weak
Weak definition of inline variable.
@ Strong
Strong definition.
@ WeakUnknown
Weak for now, might become strong later in this TU.
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
TypedefDecl * getCFConstantStringDecl() const
CanQualType SatUnsignedFractTy
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns, std::optional< MatrixType::LayoutKind > Layout=std::nullopt) const
Return the unique reference to the matrix type of the specified element type and size.
ExternCContextDecl * getExternCContextDecl() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
CanQualType UnsignedShortAccumTy
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
QualType adjustFunctionResultType(QualType FunctionType, QualType NewResultType)
Change the result type of a function type, preserving sugar such as attributed types.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
QualType getCanonicalTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateName TypeConstraintConcept=TemplateName(), ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type.
bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool AllowCXX=false, bool IsConditionalOperator=false)
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
CharUnits getObjCEncodingTypeSize(QualType T) const
Return the size of type T for Objective-C encoding purpose, in characters.
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
const TemplateArgument * getDefaultTemplateArgumentOrNone(const NamedDecl *P) const
Return the default argument of a template parameter, if one exists.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
void setCurrentNamedModule(Module *M)
Set the (C++20) module we are building.
QualType getProcessIDType() const
Return the unique type for "pid_t" defined in <sys/types.h>.
CharUnits getMemberPointerPathAdjustment(const APValue &MP) const
Find the 'this' offset for the member path in a pointer-to-member APValue.
bool mayExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel may be externalized.
std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const
ArrayRef< CXXDefaultArgExpr * > getCtorClosureDefaultArgs(const CXXConstructorDecl *CD)
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
bool hasSameExpr(const Expr *X, const Expr *Y) const
Determine whether the given expressions X and Y are equivalent.
TemplateName getPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< TemplateName > Expansions={}) const
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
RawComment * getRawCommentNoCache(RawCommentLookupKey Key) const
Return the documentation comment attached to a given declaration or macro, without looking into cache...
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
unsigned getTypeUnadjustedAlign(QualType T) const
Return the ABI-specified natural alignment of a (complete) type T, before alignment adjustments,...
unsigned char getFixedPointIBits(QualType Ty) const
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes, bool OrNull, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
bool ObjCQualifiedClassTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS)
ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and Class<pr1, ...>.
bool shouldExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel should be externalized.
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type.
CanQualType SatLongAccumTy
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
OpenCLTypeKind getOpenCLTypeKind(const Type *T) const
Map an AST Type to an OpenCLTypeKind enum value.
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const
Put the string version of the type qualifiers QT into S.
unsigned getPreferredTypeAlign(QualType T) const
Return the "preferred" alignment of the specified type T for the current target, in bits.
std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, bool Extended=false) const
Emit the encoded type for the method declaration Decl into S.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
CanQualType OMPArrayShapingTy
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
std::string getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
getObjCEncodingForPropertyDecl - Return the encoded type for this method declaration.
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
unsigned getStaticLocalNumber(const VarDecl *VD) const
void addComment(const RawComment &RC)
void getLegacyIntegralTypeEncoding(QualType &t) const
getLegacyIntegralTypeEncoding - Another legacy compatibility encoding: 32-bit longs are encoded as 'l...
bool isSameTypeConstraint(const TypeConstraint *XTC, const TypeConstraint *YTC) const
Determine whether two type contraint are similar enough that they could used in declarations of the s...
void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo)
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=RecordDecl::TagKind::Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
void completeCountAttributedType(CountAttributedType *CATy, Expr *CountExpr, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
Supply the count expression and coupled declarations for a type created by getIncompleteCountAttribut...
CanQualType UnsignedLongFractTy
QualType mergeTagDefinitions(QualType, QualType)
void setClassMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
void setIsTypeAwareOperatorNewOrDelete(const FunctionDecl *FD, bool IsTypeAware)
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const
Return a dependent bit-precise integer type with the specified signedness and bit count.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
StringRef getCUIDHash() const
bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const
Returns true if this is an inline-initialized static data member which is treated as a definition for...
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const
Determine whether two function types are the same, ignoring exception specifications in cases where t...
QualType getBlockDescriptorExtendedType() const
Gets the struct used to keep track of the extended descriptor for pointer to blocks.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent) const
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
void addLazyModuleInitializers(Module *M, ArrayRef< GlobalDeclID > IDs)
bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
QualType getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
std::optional< QualType > tryMergeOverflowBehaviorTypes(QualType LHS, QualType RHS, bool OfBlockPointer, bool Unqualified, bool BlockReturnType, bool IsConditionalOperator)
Attempts to merge two types that may be OverflowBehaviorTypes.
CanQualType OMPIteratorTy
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
SelectorTable & Selectors
bool isTypeIgnoredBySanitizer(const SanitizerMask &Mask, const QualType &Ty) const
Check if a type can have its sanitizer instrumentation elided based on its presence within an ignorel...
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const
Return the minimum alignment as specified by the target.
RawCommentList Comments
All comments in this translation unit.
bool isSameDefaultTemplateArgument(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two default template arguments are similar enough that they may be used in declarat...
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType getLateParsedAttrType(QualType Wrapped, LateParsedTypeAttribute *LateParsedAttr) const
Return a placeholder type for a late-parsed type attribute.
QualType removePtrSizeAddrSpace(QualType T) const
Remove the existing address space on the type if it is a pointer size address space and return the ty...
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
llvm::ArrayRef< BitInterval > getPaddingIntervals(QualType Ty) const
CanQualType SatShortFractTy
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
bool canBindObjCObjectType(QualType To, QualType From)
TemplateTemplateParmDecl * insertCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *CanonTTP) const
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const
Compare the rank of two floating point types as above, but compare equal if both types have the same ...
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
void setParameterIndex(const ParmVarDecl *D, unsigned index)
Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
CanQualType getCanonicalSizeType() const
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl, StringRef MangledName)
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::SetVector< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
CanQualType ArraySectionTy
CanQualType ObjCBuiltinIdTy
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const
ObjCPropertyImplDecl * getObjCPropertyImplDeclForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
bool isNearlyEmpty(const CXXRecordDecl *RD) const
PointerAuthQualifier getObjCMemberSelTypePtrAuth()
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.
void eraseDeclAttrs(const Decl *D)
Erase the attributes corresponding to the given declaration.
UsingEnumDecl * getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst)
If the given using-enum decl Inst is an instantiation of another using-enum decl, return it.
RecordDecl * getCFConstantStringTagDecl() const
std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const
Emit the encoded type for the function Decl into S.
TypeSourceInfo * getTemplateSpecializationTypeInfo(ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Canon=QualType()) const
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
unsigned getTypeAlignIfKnown(QualType T, bool NeedsPreferredAlignment=false) const
Return the alignment of a type, in bits, or 0 if the type is incomplete and we cannot determine the a...
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may both be array types with the same bound (or both be array types ...
bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
llvm::DenseMap< RawCommentLookupKey, const RawComment * > RawComments
Mapping from declaration or macro to directly attached comment.
const SYCLKernelInfo & getSYCLKernelInfo(QualType T) const
Given a type used as a SYCL kernel name, returns a reference to the metadata generated from the corre...
bool canAssignObjCInterfacesInBlockPointer(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, bool BlockReturnType)
canAssignObjCInterfacesInBlockPointer - This routine is specifically written for providing type-safet...
CanQualType SatUnsignedLongFractTy
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
CanQualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
const ObjCInterfaceDecl * getObjContainingInterface(const NamedDecl *ND) const
Returns the Objective-C interface that ND belongs to if it is an Objective-C method/property/ivar etc...
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
CanQualType getCanonicalUnresolvedUsingType(const UnresolvedUsingTypenameDecl *D) const
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
llvm::APFixedPoint getFixedPointMax(QualType Ty) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool classMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
QualType getTemplateTypeParmType(int Depth, int Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
void deduplicateMergedDefinitionsFor(NamedDecl *ND)
Clean up the merged definition list.
static uint64_t getConstantArrayElementCount(const ConstantArrayType *CA)
Return number of (potentially nested) constant array elements.
DiagnosticsEngine & getDiagnostics() const
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void recordOffsetOfEvaluation(const OffsetOfExpr *E)
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
QualType getUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D) const
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
void getOverriddenMethods(const NamedDecl *Method, SmallVectorImpl< const NamedDecl * > &Overridden) const
Return C++ or ObjC overridden methods for the given Method.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y, bool IgnoreDeduced=false) const
Determine whether the given template names refer to the same template.
CanQualType SatLongFractTy
const TargetInfo & getTargetInfo() const
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
OBTAssignResult checkOBTAssignmentCompatibility(QualType LHS, QualType RHS)
Check overflow behavior type compatibility for assignments.
CanQualType SatShortAccumTy
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
static uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE)
Return number of elements initialized in a (potentially nested) ArrayInitLoopExpr.
void addExplicitInstantiationDecl(const NamedDecl *Spec, ExplicitInstantiationDecl *EID)
Add an ExplicitInstantiationDecl for a given specialization.
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
CanQualType IncompleteMatrixIdxTy
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
CanQualType getNSIntegerType() const
QualType getCorrespondingUnsignedType(QualType T) const
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
bool shouldEmitCUDADecl(const ValueDecl *D) const
Determines if the global variable or function D is emitted on the side of the CUDA/HIP compilation,...
TargetCXXABI::Kind getCXXABIKind() const
Return the C++ ABI kind that should be used.
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
CanQualType SatUnsignedLongAccumTy
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
CanQualType getCanonicalTagType(const TagDecl *TD) const
bool isSameTemplateArgument(const TemplateArgument &Arg1, const TemplateArgument &Arg2) const
Determine whether the given template arguments Arg1 and Arg2 are equivalent.
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getCorrespondingSignedType(QualType T) const
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
llvm::DenseMap< const Decl *, const Decl * > CommentlessRedeclChains
Keeps track of redeclaration chains that don't have any comment attached.
unsigned getTargetAddressSpace(LangAS AS) const
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
std::vector< PFPField > findPFPFields(QualType Ty) const
Returns a list of PFP fields for the given type, including subfields in bases or other fields,...
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
void addTranslationUnitDecl()
void getObjCEncodingForPropertyType(QualType T, std::string &S) const
Emit the Objective-C property type encoding for the given type T into S.
unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
CollectInheritedProtocols - Collect all protocols in current class and those inherited by it.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
llvm::DenseMap< const Decl *, const Decl * > RedeclChainComments
Mapping from canonical declaration to the first redeclaration in chain that has a comment attached.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
std::optional< CXXRecordDeclRelocationInfo > getRelocationInfoForCXXRecord(const CXXRecordDecl *) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
InlineVariableDefinitionKind getInlineVariableDefinitionKind(const VarDecl *VD) const
Determine whether a definition of this inline variable should be treated as a weak or strong definiti...
const RawComment * getRawCommentForAnyRedecl(RawCommentLookupKey Key, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration or macro.
TemplateName getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
CanQualType getUIntMaxType() const
Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in <stdint.h>.
CharUnits getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const
Loading virtual member pointers using the virtual inheritance model always results in an adjustment u...
LangAS getLangASForBuiltinAddressSpace(unsigned AS) const
bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U)
Determine whether two function types are the same, ignoring pointer sizes in the return type and para...
void addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, FunctionDecl *OperatorDelete, OperatorDeleteKind K) const
unsigned char getFixedPointScale(QualType Ty) const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
QualType DecodeTypeStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequireICE, bool AllowTypeModifiers) const
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
@ GE_Missing_type
Missing a type.
QualType adjustStringLiteralBaseType(QualType StrLTy) const
uint16_t getPointerAuthTypeDiscriminator(QualType T)
Return the "other" type-specific discriminator for the given type.
llvm::SetVector< const FieldDecl * > PFPFieldsWithEvaluatedOffset
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD, bool IsVTTEntry)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers using the ...
bool canonicalizeTemplateArguments(MutableArrayRef< TemplateArgument > Args) const
Canonicalize the given template argument list.
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
QualType getMatrixTypeWithLayout(QualType T, MatrixType::LayoutKind Layout) const
bool isUnaryOverflowPatternExcluded(const UnaryOperator *UO)
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
TemplateName getDeducedTemplateName(TemplateName Underlying, DefaultArguments DefaultArgs) const
Represents a TemplateName which had some of its default arguments deduced.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
CanQualType UnsignedAccumTy
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
void cacheRawComment(RawCommentLookupKey Original, const RawComment &Comment) const
Attaches Comment to Original (a declaration or macro), and to its redeclaration chain when Original i...
QualType getVariableArrayDecayedType(QualType Ty) const
Returns a vla type where known sizes are replaced with [*].
void setCFConstantStringType(QualType T)
const SYCLKernelInfo * findSYCLKernelInfo(QualType T) const
Returns a pointer to the metadata generated from the corresponding SYCLkernel entry point if the prov...
unsigned getParameterIndex(const ParmVarDecl *D) const
Used by ParmVarDecl to retrieve on the side the index of the parameter when it exceeds the size of th...
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false) const
void AddDeallocation(void(*Callback)(void *), void *Data) const
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
AttrVec & getDeclAttrs(const Decl *D)
Retrieve the attributes for the given declaration.
QualType getDeducedTemplateSpecializationType(DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword, TemplateName Template) const
C++17 deduced class template specialization type.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
QualType mergeTransparentUnionType(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeTransparentUnionType - if T is a transparent union type and a member of T is compatible with Sub...
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
bool isSentinelNullExpr(const Expr *E)
CanQualType getNSUIntegerType() const
void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying)
TypedefDecl * getBuiltinZOSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_zos_va_list type.
void recordMemberDataPointerEvaluation(const ValueDecl *VD)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
virtual ~ASTMutationListener()
virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType)
A function's return type has been deduced.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool hasOwnVFPtr() const
hasOwnVFPtr - Does this class provide its own virtual-function table pointer, rather than inheriting ...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
bool hasOwnVBPtr() const
hasOwnVBPtr - Does this class provide its own virtual-base table pointer, rather than inheriting one ...
CharUnits getSize() const
getSize - Get the record size in characters.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding,...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
CharUnits getUnadjustedAlignment() const
getUnadjustedAlignment - Get the record alignment in characters, before alignment adjustment.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Represents a loop initializing the elements of an array.
llvm::APInt getArraySize() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
A structure for storing the information associated with a name that has been assumed to be a template...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Attr - This represents one attribute.
A fixed int type of a specified bitwidth.
unsigned getNumBits() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
This class is used for builtin types like 'int'.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Implements C++ ABI-specific semantic analysis functions.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
CXXRecordDecl * getDefinition() const
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isDynamicClass() const
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
SplitQualType split() const
static CanQual< Type > CreateUnsafe(QualType Other)
QualType withConst() const
Retrieves a version of this type with const applied.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
This is an opaque type for sizes expressed in character units.
bool isPositive() const
Test whether the quantity is greater than zero.
bool isZero() const
Test whether the quantity equals zero.
CharUnits alignTo(CharUnits Align) const
Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is a multiple...
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
static CharUnits Zero()
Construct a CharUnits quantity of zero.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Represents the canonical version of C arrays with a specified constant size.
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
void Profile(llvm::FoldingSetNodeID &ID)
unsigned getNumRows() const
Returns the number of rows in the matrix.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Decl::Kind getDeclKind() const
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isModuleLocal() const
Whether this declaration was a local declaration to a C++20 named module.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl,...
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
static Decl * castFromDeclContext(const DeclContext *)
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setImplicit(bool I=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
DeclarationNameLoc - Additional source/type location info for a declaration name.
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc, SourceLocation EndLoc)
Construct location information for a non-literal C++ operator.
The name of a declaration.
static int compare(DeclarationName LHS, DeclarationName RHS)
Represents a ValueDecl that came out of a declarator.
TypeSourceInfo * getTypeSourceInfo() const
TemplateName getUnderlying() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
DefaultArguments getDefaultArguments() const
Represents an extended address space qualifier where the input address space value is dependent.
Expr * getAddrSpaceExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents an array type in C++ whose size is a value-dependent expression.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Expr * getSizeExpr() const
Represents an extended vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Expr * getRowExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a dependent template name that cannot be resolved prior to template instantiation.
void Profile(llvm::FoldingSetNodeID &ID) const
IdentifierOrOverloadedOperator getName() const
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
bool hasTemplateKeyword() const
Was this template name was preceeded by the template keyword?
Internal representation of canonical, dependent typeof(expr) types.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
A dynamically typed AST node container.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
bool isComplete() const
Returns true if this can be considered a complete type.
EnumDecl * getDefinitionOrSelf() const
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Represents an explicit instantiation of a template entity in source code.
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
We can encode up to four bits in the low bits of a type pointer, but there are many more type qualifi...
void Profile(llvm::FoldingSetNodeID &ID) const
ExtVectorType - Extended vector type.
Declaration context for names declared as extern "C" in C++.
static ExternCContextDecl * Create(const ASTContext &C, TranslationUnitDecl *TU)
Abstract interface for external sources of AST nodes.
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.
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.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
CXXABI * CreateItaniumCXXABI(ASTContext &Ctx)
Creates an instance of a C++ ABI class.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
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
@ RVVFixedLengthData
is RISC-V RVV fixed-length data vector
@ RVVFixedLengthMask
is RISC-V RVV fixed-length mask vector
@ SveFixedLengthPredicate
is AArch64 SVE fixed-length predicate vector
U cast(CodeGen::Address addr)
LangAS getLangASFromTargetAS(unsigned TargetAS)
@ 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)
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