70#include "llvm/ADT/APFixedPoint.h"
71#include "llvm/ADT/APInt.h"
72#include "llvm/ADT/APSInt.h"
73#include "llvm/ADT/ArrayRef.h"
74#include "llvm/ADT/DenseMap.h"
75#include "llvm/ADT/DenseSet.h"
76#include "llvm/ADT/FoldingSet.h"
77#include "llvm/ADT/PointerUnion.h"
78#include "llvm/ADT/STLExtras.h"
79#include "llvm/ADT/SmallPtrSet.h"
80#include "llvm/ADT/SmallVector.h"
81#include "llvm/ADT/StringExtras.h"
82#include "llvm/ADT/StringRef.h"
83#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
84#include "llvm/Support/Capacity.h"
85#include "llvm/Support/Casting.h"
86#include "llvm/Support/Compiler.h"
87#include "llvm/Support/ErrorHandling.h"
88#include "llvm/Support/MD5.h"
89#include "llvm/Support/MathExtras.h"
90#include "llvm/Support/SipHash.h"
91#include "llvm/Support/raw_ostream.h"
92#include "llvm/TargetParser/AArch64TargetParser.h"
93#include "llvm/TargetParser/Triple.h"
106using namespace clang;
124 if (
const auto *MI = dyn_cast<const MacroInfo *>(Key)) {
138 StringRef Buffer = SourceMgr.getBufferData(Decomposed.first, &
Invalid);
141 unsigned Offset = Decomposed.second;
142 if (
size_t Found = Buffer.find_last_of(
"#\n", Offset);
143 Found != StringRef::npos)
145 return {SourceMgr.getLocForStartOfFile(Decomposed.first)
146 .getLocWithOffset(Offset)};
157 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
162 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
163 if (VD->isStaticDataMember() &&
168 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(D)) {
173 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
180 if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
184 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
187 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
214 BaseLocation = D->getBeginLoc();
216 BaseLocation = D->getLocation();
218 if (!D->getLocation().isMacroID()) {
219 Locations.emplace_back(BaseLocation);
221 const auto *DeclCtx = D->getDeclContext();
232 Locations.emplace_back(SourceMgr.getExpansionLoc(BaseLocation));
239 Locations.emplace_back(SourceMgr.getSpellingLoc(D->getBeginLoc()));
247 const std::map<unsigned, RawComment *> &CommentsInTheFile)
const {
254 if (CommentsInTheFile.empty())
257 const auto *D = dyn_cast<const Decl *>(Key);
263 SourceMgr.getDecomposedLoc(RepresentativeLoc);
266 auto OffsetCommentBehindDecl =
267 CommentsInTheFile.lower_bound(LocDecomp.second);
270 if (OffsetCommentBehindDecl != CommentsInTheFile.end()) {
271 RawComment *CommentBehindDecl = OffsetCommentBehindDecl->second;
273 LangOpts.CommentOpts.ParseAllComments) &&
281 if (SourceMgr.getLineNumber(LocDecomp.first, LocDecomp.second) ==
282 Comments.getCommentBeginLine(CommentBehindDecl, LocDecomp.first,
283 OffsetCommentBehindDecl->first)) {
284 return CommentBehindDecl;
291 if (OffsetCommentBehindDecl == CommentsInTheFile.begin())
294 auto OffsetCommentBeforeDecl = --OffsetCommentBehindDecl;
295 RawComment *CommentBeforeDecl = OffsetCommentBeforeDecl->second;
299 LangOpts.CommentOpts.ParseAllComments) ||
304 const unsigned CommentEndOffset =
305 Comments.getCommentEndOffset(CommentBeforeDecl);
310 SourceMgr.getBufferData(LocDecomp.first, &
Invalid).data();
315 StringRef
Text(Buffer + CommentEndOffset,
316 LocDecomp.second - CommentEndOffset);
320 if (
Text.find_last_of(
";{}#@") != StringRef::npos)
323 return CommentBeforeDecl;
329 for (
const auto Loc : Locs) {
332 if (Loc.isInvalid() || !Loc.isFileID())
343 const FileID File = SourceMgr.getDecomposedLoc(Loc).first;
347 const auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
348 if (!CommentsInThisFile || CommentsInThisFile->empty())
360 assert(LangOpts.RetainCommentsFromSystemHeaders ||
362 Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
367 const Decl **OriginalDecl)
const {
370 *OriginalDecl =
nullptr;
376 if (
const auto *MI = dyn_cast<const MacroInfo *>(Key)) {
378 *OriginalDecl =
nullptr;
381 return Existing->second;
398 return DeclComment->second;
411 *OriginalDecl = RedeclComment->second;
412 auto CommentAtRedecl =
RawComments.find(RedeclComment->second);
414 "This decl is supposed to have comment attached.");
415 return CommentAtRedecl->second;
420 const Decl *LastCheckedRedecl = [&]() {
422 bool CanUseCommentlessCache =
false;
424 for (
auto *Redecl : CanonicalD->
redecls()) {
426 CanUseCommentlessCache =
true;
429 if (Redecl == LastChecked)
436 return CanUseCommentlessCache ? LastChecked :
nullptr;
442 if (LastCheckedRedecl) {
443 if (LastCheckedRedecl == Redecl) {
444 LastCheckedRedecl =
nullptr;
452 *OriginalDecl = Redecl;
453 return RedeclComment;
459 *OriginalDecl =
nullptr;
465 assert(Comment.
isDocumentation() || LangOpts.CommentOpts.ParseAllComments);
467 if (
const auto *D = dyn_cast<const Decl *>(Original)) {
477 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(DC)) {
482 for (
const auto *Ext : ID->known_extensions()) {
486 Redeclared.push_back(RedeclaredMethod);
493 if (
Comments.empty() || Decls.empty())
497 for (
const Decl *D : Decls) {
498 if (D->isInvalidDecl())
506 File = SourceMgr.getDecomposedLoc(Loc).first;
511 if (
File.isInvalid())
514 auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
515 if (!CommentsInThisFile || CommentsInThisFile->empty() ||
516 CommentsInThisFile->rbegin()->second->isAttached())
526 for (
const Decl *D : Decls) {
528 if (D->isInvalidDecl())
538 for (
const auto DeclLoc : DeclLocs) {
539 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
554 const Decl *D)
const {
557 ThisDeclInfo->IsFilled =
false;
558 ThisDeclInfo->fill();
559 ThisDeclInfo->CommentDecl = FC->
getDecl();
560 if (!ThisDeclInfo->TemplateParameters)
570 return RC ? RC->
parse(*
this,
nullptr, D) :
nullptr;
581 llvm::DenseMap<const Decl *, comments::FullComment *>::iterator Pos =
585 if (Canonical != D) {
593 const Decl *OriginalDecl =
nullptr;
599 const auto *OMD = dyn_cast<ObjCMethodDecl>(D);
600 if (OMD && OMD->isPropertyAccessor())
607 for (
unsigned i = 0, e = Overridden.size(); i < e; i++)
611 else if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
614 QualType QT = TD->getUnderlyingType();
615 if (
const auto *TT = QT->
getAs<TagType>())
619 else if (
const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
620 while (IC->getSuperClass()) {
621 IC = IC->getSuperClass();
626 else if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(D)) {
631 else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
632 if (!(RD = RD->getDefinition()))
635 for (
const auto &I : RD->bases()) {
636 if (I.isVirtual() || (I.getAccessSpecifier() !=
AS_public))
650 for (
const auto &I : RD->vbases()) {
671 if (D != OriginalDecl && OriginalDecl)
679void ASTContext::CanonicalTemplateTemplateParm::Profile(
688 ID.AddInteger(Params->
size());
690 PEnd = Params->
end();
692 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
694 ID.AddBoolean(TTP->isParameterPack());
696 TTP->getNumExpansionParameters().toInternalRepresentation());
700 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
702 ID.AddBoolean(NTTP->isParameterPack());
703 ID.AddPointer(
C.getUnconstrainedType(
C.getCanonicalType(NTTP->getType()))
705 if (NTTP->isExpandedParameterPack()) {
707 ID.AddInteger(NTTP->getNumExpansionTypes());
708 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
710 ID.AddPointer(
T.getCanonicalType().getAsOpaquePtr());
713 ID.AddBoolean(
false);
723TemplateTemplateParmDecl *
727 llvm::FoldingSetNodeID ID;
728 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
729 llvm::FoldingSetInsertToken
Token;
730 CanonicalTemplateTemplateParm *Canonical =
731 CanonTemplateTemplateParms.lookup(ID,
Token);
733 return Canonical->getParam();
738 CanonParams.reserve(Params->
size());
740 PEnd = Params->
end();
744 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
749 TTP->getNumExpansionParameters());
750 CanonParams.push_back(NewTTP);
751 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
755 if (NTTP->isExpandedParameterPack()) {
758 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
760 ExpandedTInfos.push_back(
768 NTTP->getPosition(),
nullptr,
778 NTTP->getPosition(),
nullptr,
780 NTTP->isParameterPack(),
783 CanonParams.push_back(Param);
799 Canonical = CanonTemplateTemplateParms.lookup(ID,
Token);
800 assert(!Canonical &&
"Shouldn't be in the map!");
804 Canonical =
new (*this) CanonicalTemplateTemplateParm(CanonTTP);
805 CanonTemplateTemplateParms.insert(Canonical,
Token);
812 llvm::FoldingSetNodeID ID;
813 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
814 llvm::FoldingSetInsertToken
Token;
815 CanonicalTemplateTemplateParm *Canonical =
816 CanonTemplateTemplateParms.lookup(ID,
Token);
817 return Canonical ? Canonical->getParam() :
nullptr;
823 llvm::FoldingSetNodeID ID;
824 CanonicalTemplateTemplateParm::Profile(ID, *
this, CanonTTP);
825 llvm::FoldingSetInsertToken
Token;
826 if (
auto *Existing = CanonTemplateTemplateParms.lookup(ID,
Token))
827 return Existing->getParam();
828 CanonTemplateTemplateParms.insert(
829 new (*
this) CanonicalTemplateTemplateParm(CanonTTP),
Token);
850 [](
const DynTypedNode &P) { return P.get<WhileStmt>() != nullptr; });
874 return NoSanitizeL->containsType(Mask, TyName);
883 if (!LangOpts.CPlusPlus)
return nullptr;
886 case TargetCXXABI::AppleARM64:
887 case TargetCXXABI::Fuchsia:
888 case TargetCXXABI::GenericARM:
889 case TargetCXXABI::iOS:
890 case TargetCXXABI::WatchOS:
891 case TargetCXXABI::GenericAArch64:
892 case TargetCXXABI::GenericMIPS:
893 case TargetCXXABI::GenericItanium:
894 case TargetCXXABI::WebAssembly:
895 case TargetCXXABI::XL:
897 case TargetCXXABI::Microsoft:
900 llvm_unreachable(
"Invalid CXXABI type!");
904 if (!InterpContext) {
907 return *InterpContext;
913 return *ParentMapCtx;
918 switch (LangOpts.getAddressSpaceMapMangling()) {
926 llvm_unreachable(
"getAddressSpaceMapMangling() doesn't cover anything.");
932 : ConstantArrayTypes(this_(), ConstantArrayTypesLog2InitSize),
933 DependentSizedArrayTypes(this_()), DependentSizedExtVectorTypes(this_()),
934 DependentAddressSpaceTypes(this_()), DependentVectorTypes(this_()),
935 DependentSizedMatrixTypes(this_()),
936 FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
937 DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
938 DependentPackIndexingTypes(this_()), TemplateSpecializationTypes(this_()),
939 AttributedTypes(this_()), DependentBitIntTypes(this_()),
940 HLSLAttributedResourceTypes(this_()),
941 SubstTemplateTemplateParmPacks(this_()), DeducedTemplates(this_()),
942 PackIndexingTemplates(this_()), ArrayParameterTypes(this_()),
943 CanonTemplateTemplateParms(this_()), SourceMgr(SM), LangOpts(LOpts),
946 LangOpts.XRayNeverInstrumentFiles,
947 LangOpts.XRayAttrListFiles, SM)),
948 ProfList(new
ProfileList(LangOpts.ProfileListFiles, SM)),
951 Comments(SM), CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
959 ReleaseDeclContextMaps();
962 for (
auto &Pair : Deallocations)
963 (Pair.first)(Pair.second);
964 Deallocations.clear();
970 I = ObjCLayouts.begin(),
971 E = ObjCLayouts.end();
978 for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
979 I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
984 ASTRecordLayouts.clear();
986 for (llvm::DenseMap<const Decl*, AttrVec*>::iterator A = DeclAttrs.begin(),
987 AEnd = DeclAttrs.end();
989 A->second->~AttrVec();
992 CtorClosureDefaultArgs.clear();
994 for (
const auto &
Value : ModuleInitializers)
995 Value.second->~PerModuleInitializers();
996 ModuleInitializers.
clear();
1000 NoSanitizeL.reset();
1006 TraversalScope = TopLevelDecls;
1020 llvm::errs() <<
"\n*** AST Context Stats:\n";
1021 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
1023 unsigned counts[] = {
1024#define TYPE(Name, Parent) 0,
1025#define ABSTRACT_TYPE(Name, Parent)
1026#include "clang/AST/TypeNodes.inc"
1030 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
1036 unsigned TotalBytes = 0;
1037#define TYPE(Name, Parent) \
1039 llvm::errs() << " " << counts[Idx] << " " << #Name \
1040 << " types, " << sizeof(Name##Type) << " each " \
1041 << "(" << counts[Idx] * sizeof(Name##Type) \
1043 TotalBytes += counts[Idx] * sizeof(Name##Type); \
1045#define ABSTRACT_TYPE(Name, Parent)
1046#include "clang/AST/TypeNodes.inc"
1048 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
1053 <<
" implicit default constructors created\n";
1056 <<
" implicit copy constructors created\n";
1060 <<
" implicit move constructors created\n";
1063 <<
" implicit copy assignment operators created\n";
1067 <<
" implicit move assignment operators created\n";
1070 <<
" implicit destructors created\n";
1073 llvm::errs() <<
"\n";
1077 BumpAlloc.PrintStats();
1081 bool NotifyListeners) {
1082 if (NotifyListeners)
1085 Listener->RedefinedHiddenDefinition(ND, M);
1092 if (It == MergedDefModules.end())
1095 auto &Merged = It->second;
1096 llvm::DenseSet<Module*>
Found;
1097 for (
Module *&M : Merged)
1098 if (!
Found.insert(M).second)
1100 llvm::erase(Merged,
nullptr);
1107 if (MergedIt == MergedDefModules.end())
1109 return MergedIt->second;
1112void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1113 if (LazyInitializers.empty())
1117 assert(Source &&
"lazy initializers but no external source");
1119 auto LazyInits = std::move(LazyInitializers);
1120 LazyInitializers.clear();
1122 for (
auto ID : LazyInits)
1123 Initializers.push_back(Source->GetExternalDecl(ID));
1125 assert(LazyInitializers.empty() &&
1126 "GetExternalDecl for lazy module initializer added more inits");
1132 if (
const auto *ID = dyn_cast<ImportDecl>(D)) {
1133 auto It = ModuleInitializers.find(ID->getImportedModule());
1136 if (It == ModuleInitializers.end())
1140 auto &Imported = *It->second;
1141 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1142 Imported.resolve(*
this);
1143 auto *OnlyDecl = Imported.Initializers.front();
1149 auto *&
Inits = ModuleInitializers[M];
1151 Inits =
new (*this) PerModuleInitializers;
1152 Inits->Initializers.push_back(D);
1157 auto *&
Inits = ModuleInitializers[M];
1159 Inits =
new (*this) PerModuleInitializers;
1160 Inits->LazyInitializers.insert(
Inits->LazyInitializers.end(),
1161 IDs.begin(), IDs.end());
1165 auto It = ModuleInitializers.find(M);
1166 if (It == ModuleInitializers.end())
1169 auto *
Inits = It->second;
1170 Inits->resolve(*
this);
1171 return Inits->Initializers;
1176 assert(!CurrentCXXNamedModule &&
1177 "We should set named module for ASTContext for only once");
1178 CurrentCXXNamedModule = M;
1190 auto GetRepresentativeModule = [
this](
const Module *M) {
1191 auto Iter = SameModuleLookupSet.find(M);
1192 if (Iter != SameModuleLookupSet.end())
1193 return Iter->second;
1195 const Module *RepresentativeModule =
1196 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1198 SameModuleLookupSet[M] = RepresentativeModule;
1199 return RepresentativeModule;
1202 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1203 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1207 if (!ExternCContext)
1210 return ExternCContext;
1224#define BuiltinTemplate(BTName) \
1225 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1226 if (!Decl##BTName) \
1228 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1229 return Decl##BTName; \
1231#include "clang/Basic/BuiltinTemplates.inc"
1244 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1245 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1250 StringRef Name)
const {
1274 Types.push_back(Ty);
1279 assert((!this->Target || this->Target == &Target) &&
1280 "Incorrect target reinitialization");
1281 assert(
VoidTy.isNull() &&
"Context reinitialized?");
1283 this->Target = &Target;
1284 this->AuxTarget = AuxTarget;
1286 ABI.reset(createCXXABI(Target));
1290 InitBuiltinType(
VoidTy, BuiltinType::Void);
1293 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1295 if (LangOpts.CharIsSigned)
1296 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1298 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1301 InitBuiltinType(
ShortTy, BuiltinType::Short);
1302 InitBuiltinType(
IntTy, BuiltinType::Int);
1303 InitBuiltinType(
LongTy, BuiltinType::Long);
1304 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1314 InitBuiltinType(
FloatTy, BuiltinType::Float);
1315 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1316 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1319 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1322 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1325 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1328 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1329 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1330 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1334 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1335 InitBuiltinType(
FractTy, BuiltinType::Fract);
1336 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1341 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1347 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1354 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1359 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1361 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1362 if (LangOpts.CPlusPlus && LangOpts.WChar)
1366 WideCharTy = getFromTargetType(Target.getWCharType());
1369 WIntTy = getFromTargetType(Target.getWIntType());
1372 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1374 if (LangOpts.CPlusPlus)
1375 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1377 Char16Ty = getFromTargetType(Target.getChar16Type());
1379 if (LangOpts.CPlusPlus)
1380 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1382 Char32Ty = getFromTargetType(Target.getChar32Type());
1389 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1392 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1404 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1410 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1413 if (LangOpts.OpenMP) {
1420 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1423 if (LangOpts.MatrixTypes)
1431 if (LangOpts.OpenCL) {
1432#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1433 InitBuiltinType(SingletonId, BuiltinType::Id);
1434#include "clang/Basic/OpenCLImageTypes.def"
1436 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1437 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1439 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1442#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1443 InitBuiltinType(Id##Ty, BuiltinType::Id);
1444#include "clang/Basic/OpenCLExtensionTypes.def"
1447 if (LangOpts.HLSL) {
1448#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1449 InitBuiltinType(SingletonId, BuiltinType::Id);
1450#include "clang/Basic/HLSLIntangibleTypes.def"
1453 if (Target.hasAArch64ACLETypes() ||
1454 (AuxTarget && AuxTarget->hasAArch64ACLETypes())) {
1455#define SVE_TYPE(Name, Id, SingletonId) \
1456 InitBuiltinType(SingletonId, BuiltinType::Id);
1457#include "clang/Basic/AArch64ACLETypes.def"
1460 if (Target.getTriple().isPPC64()) {
1461#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1462 InitBuiltinType(Id##Ty, BuiltinType::Id);
1463#include "clang/Basic/PPCTypes.def"
1464#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1465 InitBuiltinType(Id##Ty, BuiltinType::Id);
1466#include "clang/Basic/PPCTypes.def"
1469 if (Target.hasRISCVVTypes()) {
1470#define RVV_TYPE(Name, Id, SingletonId) \
1471 InitBuiltinType(SingletonId, BuiltinType::Id);
1472#include "clang/Basic/RISCVVTypes.def"
1475 if (Target.getTriple().isWasm() && Target.hasFeature(
"reference-types")) {
1476#define WASM_TYPE(Name, Id, SingletonId) \
1477 InitBuiltinType(SingletonId, BuiltinType::Id);
1478#include "clang/Basic/WebAssemblyReferenceTypes.def"
1481 if (Target.hasAMDGPUTypes() || (AuxTarget && (AuxTarget->hasAMDGPUTypes()))) {
1482#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1483 InitBuiltinType(SingletonId, BuiltinType::Id);
1484#include "clang/Basic/AMDGPUTypes.def"
1487 if (Target.getTriple().isSPIRV() ||
1488 (AuxTarget && AuxTarget->getTriple().isSPIRV())) {
1489#define SPIRV_TYPE(Name, Id, SingletonId) \
1490 InitBuiltinType(SingletonId, BuiltinType::Id);
1491#include "clang/Basic/SPIRVTypes.def"
1498 ObjCConstantStringType =
QualType();
1503 if (LangOpts.OpenCLGenericAddressSpace) {
1504 auto Q =
VoidTy.getQualifiers();
1513 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1516 InitBuiltinType(
HalfTy, BuiltinType::Half);
1518 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1524 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1531 return SourceMgr.getDiagnostics();
1546 llvm::DenseMap<const Decl*, AttrVec*>::iterator Pos = DeclAttrs.find(D);
1547 if (Pos != DeclAttrs.end()) {
1548 Pos->second->~AttrVec();
1549 DeclAttrs.erase(Pos);
1555 return CtorClosureDefaultArgs.lookup(CD);
1560 assert(!CtorClosureDefaultArgs.contains(CD));
1561 CtorClosureDefaultArgs[CD] = Args;
1568 if (It != ExplicitInstantiations.end())
1589 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1590 TemplateOrInstantiation.find(Var);
1591 if (Pos == TemplateOrInstantiation.end())
1604 Tmpl, TSK, PointOfInstantiation));
1610 assert(!TemplateOrInstantiation[Inst] &&
1611 "Already noted what the variable was instantiated from");
1612 TemplateOrInstantiation[Inst] = TSI;
1617 return InstantiatedFromUsingDecl.lookup(UUD);
1625 "pattern decl is not a using decl");
1629 "instantiation did not produce a using decl");
1630 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1631 InstantiatedFromUsingDecl[Inst] = Pattern;
1636 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1641 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1642 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1647 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1653 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1654 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1659 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1665 "Instantiated field decl is not unnamed");
1667 "Template field decl is not unnamed");
1668 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1669 "Already noted what unnamed field was instantiated from");
1671 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1687 return Range.end() - Range.begin();
1692 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1693 OverriddenMethods.find(
Method->getCanonicalDecl());
1694 if (Pos == OverriddenMethods.end())
1702 OverriddenMethods[
Method].push_back(Overridden);
1710 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1716 const auto *
Method = dyn_cast<ObjCMethodDecl>(D);
1721 Method->getOverriddenMethods(OverDecls);
1722 Overridden.append(OverDecls.begin(), OverDecls.end());
1725std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1729 auto it = RelocatableClasses.find(D);
1730 if (it != RelocatableClasses.end())
1731 return it->getSecond();
1732 return std::nullopt;
1739 assert(RelocatableClasses.find(D) == RelocatableClasses.end());
1740 RelocatableClasses.insert({D, Info});
1745 if (!Class->isPolymorphic())
1747 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
1748 using AuthAttr = VTablePointerAuthenticationAttr;
1749 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1751 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1752 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1753 ExplicitAuth->getAddressDiscrimination();
1754 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1755 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1756 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1759ASTContext::PointerAuthContent
1760ASTContext::findPointerAuthContent(QualType
T)
const {
1761 assert(isPointerAuthenticationAvailable());
1763 T =
T.getCanonicalType();
1765 return PointerAuthContent::None;
1767 if (
T.hasAddressDiscriminatedPointerAuth())
1768 return PointerAuthContent::AddressDiscriminatedData;
1771 return PointerAuthContent::None;
1774 return PointerAuthContent::None;
1776 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1777 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1778 return Existing->second;
1780 PointerAuthContent
Result = PointerAuthContent::None;
1782 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1783 auto [ResultIter, DidAdd] =
1784 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1790 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1791 static_assert(PointerAuthContent::None <
1792 PointerAuthContent::AddressDiscriminatedVTable);
1793 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1794 PointerAuthContent::AddressDiscriminatedData);
1797 return Result != PointerAuthContent::AddressDiscriminatedData;
1799 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1801 !ShouldContinueAfterUpdate(
1802 PointerAuthContent::AddressDiscriminatedVTable))
1803 return SaveResultAndReturn();
1804 for (
auto Base : CXXRD->bases()) {
1805 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1806 return SaveResultAndReturn();
1809 for (
auto *FieldDecl : RD->
fields()) {
1810 if (!ShouldContinueAfterUpdate(
1811 findPointerAuthContent(FieldDecl->getType())))
1812 return SaveResultAndReturn();
1814 return SaveResultAndReturn();
1818 assert(!Import->getNextLocalImport() &&
1819 "Import declaration already in the chain");
1820 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1821 if (!FirstLocalImport) {
1822 FirstLocalImport = Import;
1823 LastLocalImport = Import;
1827 LastLocalImport->setNextLocalImport(Import);
1828 LastLocalImport = Import;
1840 llvm_unreachable(
"Not a floating point type!");
1841 case BuiltinType::BFloat16:
1842 return Target->getBFloat16Format();
1843 case BuiltinType::Float16:
1844 return Target->getHalfFormat();
1845 case BuiltinType::Half:
1846 return Target->getHalfFormat();
1847 case BuiltinType::Float:
return Target->getFloatFormat();
1848 case BuiltinType::Double:
return Target->getDoubleFormat();
1849 case BuiltinType::Ibm128:
1850 return Target->getIbm128Format();
1851 case BuiltinType::LongDouble:
1853 return AuxTarget->getLongDoubleFormat();
1854 return Target->getLongDoubleFormat();
1855 case BuiltinType::Float128:
1857 return AuxTarget->getFloat128Format();
1858 return Target->getFloat128Format();
1863 unsigned Align = Target->getCharWidth();
1867 Align = AlignFromAttr;
1875 bool UseAlignAttrOnly;
1876 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1878 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1880 UseAlignAttrOnly = AlignFromAttr != 0;
1883 if (UseAlignAttrOnly) {
1885 }
else if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
1889 T = RT->getPointeeType();
1894 if (
T->isFunctionType())
1895 Align = getTypeInfoImpl(
T.getTypePtr()).Align;
1900 unsigned MinWidth = Target->getLargeArrayMinWidth();
1901 if (!ForAlignof && MinWidth) {
1903 Align = std::max(Align, Target->getLargeArrayAlign());
1906 Align = std::max(Align, Target->getLargeArrayAlign());
1911 Align = Target->getCharWidth();
1915 if (
const auto *VD = dyn_cast<VarDecl>(D))
1916 if (VD->hasGlobalStorage() && !ForAlignof) {
1927 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1941 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1942 if (LowBitOfOffset < FieldAlign)
1943 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1946 Align = std::min(Align, FieldAlign);
1954 const auto *VD = dyn_cast<VarDecl>(D);
1955 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1956 Align = std::min(Align, MaxAlignedAttr);
1976 if (
const auto *RD =
T->getAsCXXRecordDecl(); RD && !RD->
isInvalidDecl()) {
1993 (uint64_t)(-1)/Size) &&
1994 "Overflow in array type char size evaluation");
1997 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
1999 Width = llvm::alignTo(Width, Align);
2006 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2024 switch (BT->getKind()) {
2025 case BuiltinType::Bool:
2026 case BuiltinType::Char_S:
2027 case BuiltinType::Char_U:
2028 case BuiltinType::SChar:
2029 case BuiltinType::UChar:
2030 case BuiltinType::Short:
2031 case BuiltinType::UShort:
2032 case BuiltinType::WChar_S:
2033 case BuiltinType::WChar_U:
2034 case BuiltinType::Char8:
2035 case BuiltinType::Char16:
2036 case BuiltinType::Char32:
2044 if (
const auto *ED =
T->getAsEnumDecl()) {
2045 if (
T->isDependentType() || ED->getPromotionType().isNull() ||
2053 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>()) {
2069 bool NeedsPreferredAlignment)
const {
2072 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2077 if (!
T->isIncompleteType())
2083 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2087 if (
const auto *TD =
T->getAsTagDecl())
2088 return TD->getMaxAlignment();
2094 TypeInfoMap::iterator I = MemoizedTypeInfo.find(
T);
2095 if (I != MemoizedTypeInfo.end())
2100 MemoizedTypeInfo[
T] = TI;
2115 switch (
T->getTypeClass()) {
2116#define TYPE(Class, Base)
2117#define ABSTRACT_TYPE(Class, Base)
2118#define NON_CANONICAL_TYPE(Class, Base)
2119#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2120#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
2122 assert(!T->isDependentType() && "should not see dependent types here"); \
2123 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
2124#include "clang/AST/TypeNodes.inc"
2125 llvm_unreachable(
"Should not see dependent types");
2127 case Type::FunctionNoProto:
2128 case Type::FunctionProto:
2134 case Type::IncompleteArray:
2135 case Type::VariableArray:
2136 case Type::ConstantArray:
2137 case Type::ArrayParameter: {
2140 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2141 Size = CAT->getZExtSize();
2144 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2145 "Overflow in array type bit size evaluation");
2146 Width = EltInfo.
Width * Size;
2147 Align = EltInfo.
Align;
2151 Width = llvm::alignTo(Width, Align);
2155 case Type::ExtVector:
2156 case Type::Vector: {
2159 Width = VT->isPackedVectorBoolType(*
this)
2160 ? VT->getNumElements()
2161 : EltInfo.
Width * VT->getNumElements();
2163 Width = std::max<unsigned>(8, Width);
2164 Align = std::max<unsigned>(
2165 8,
Target->vectorsAreElementAligned() ? EltInfo.
Width : Width);
2169 if (Align & (Align-1)) {
2170 Align = llvm::bit_ceil(Align);
2171 Width = llvm::alignTo(Width, Align);
2174 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
2175 if (TargetVectorAlign && TargetVectorAlign < Align)
2176 Align = TargetVectorAlign;
2190 Align = std::min<unsigned>(64, Width);
2194 case Type::ConstantMatrix: {
2196 TypeInfo ElementInfo =
getTypeInfo(MT->getElementType());
2200 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2201 Align = ElementInfo.
Align;
2207 default: llvm_unreachable(
"Unknown builtin type!");
2208 case BuiltinType::Void:
2213 case BuiltinType::Bool:
2214 Width = Target->getBoolWidth();
2215 Align = Target->getBoolAlign();
2217 case BuiltinType::Char_S:
2218 case BuiltinType::Char_U:
2219 case BuiltinType::UChar:
2220 case BuiltinType::SChar:
2221 case BuiltinType::Char8:
2222 Width = Target->getCharWidth();
2223 Align = Target->getCharAlign();
2225 case BuiltinType::WChar_S:
2226 case BuiltinType::WChar_U:
2227 Width = Target->getWCharWidth();
2228 Align = Target->getWCharAlign();
2230 case BuiltinType::Char16:
2231 Width = Target->getChar16Width();
2232 Align = Target->getChar16Align();
2234 case BuiltinType::Char32:
2235 Width = Target->getChar32Width();
2236 Align = Target->getChar32Align();
2238 case BuiltinType::UShort:
2239 case BuiltinType::Short:
2240 Width = Target->getShortWidth();
2241 Align = Target->getShortAlign();
2243 case BuiltinType::UInt:
2244 case BuiltinType::Int:
2245 Width = Target->getIntWidth();
2246 Align = Target->getIntAlign();
2248 case BuiltinType::ULong:
2249 case BuiltinType::Long:
2250 Width = Target->getLongWidth();
2251 Align = Target->getLongAlign();
2253 case BuiltinType::ULongLong:
2254 case BuiltinType::LongLong:
2255 Width = Target->getLongLongWidth();
2256 Align = Target->getLongLongAlign();
2258 case BuiltinType::Int128:
2259 case BuiltinType::UInt128:
2261 Align = Target->getInt128Align();
2263 case BuiltinType::ShortAccum:
2264 case BuiltinType::UShortAccum:
2265 case BuiltinType::SatShortAccum:
2266 case BuiltinType::SatUShortAccum:
2267 Width = Target->getShortAccumWidth();
2268 Align = Target->getShortAccumAlign();
2270 case BuiltinType::Accum:
2271 case BuiltinType::UAccum:
2272 case BuiltinType::SatAccum:
2273 case BuiltinType::SatUAccum:
2274 Width = Target->getAccumWidth();
2275 Align = Target->getAccumAlign();
2277 case BuiltinType::LongAccum:
2278 case BuiltinType::ULongAccum:
2279 case BuiltinType::SatLongAccum:
2280 case BuiltinType::SatULongAccum:
2281 Width = Target->getLongAccumWidth();
2282 Align = Target->getLongAccumAlign();
2284 case BuiltinType::ShortFract:
2285 case BuiltinType::UShortFract:
2286 case BuiltinType::SatShortFract:
2287 case BuiltinType::SatUShortFract:
2288 Width = Target->getShortFractWidth();
2289 Align = Target->getShortFractAlign();
2291 case BuiltinType::Fract:
2292 case BuiltinType::UFract:
2293 case BuiltinType::SatFract:
2294 case BuiltinType::SatUFract:
2295 Width = Target->getFractWidth();
2296 Align = Target->getFractAlign();
2298 case BuiltinType::LongFract:
2299 case BuiltinType::ULongFract:
2300 case BuiltinType::SatLongFract:
2301 case BuiltinType::SatULongFract:
2302 Width = Target->getLongFractWidth();
2303 Align = Target->getLongFractAlign();
2305 case BuiltinType::BFloat16:
2306 if (Target->hasBFloat16Type()) {
2307 Width = Target->getBFloat16Width();
2308 Align = Target->getBFloat16Align();
2312 AuxTarget->hasBFloat16Type()) {
2313 Width = AuxTarget->getBFloat16Width();
2314 Align = AuxTarget->getBFloat16Align();
2317 case BuiltinType::Float16:
2318 case BuiltinType::Half:
2319 if (Target->hasFloat16Type() || !
getLangOpts().OpenMP ||
2321 Width = Target->getHalfWidth();
2322 Align = Target->getHalfAlign();
2325 "Expected OpenMP device compilation.");
2326 Width = AuxTarget->getHalfWidth();
2327 Align = AuxTarget->getHalfAlign();
2330 case BuiltinType::Float:
2331 Width = Target->getFloatWidth();
2332 Align = Target->getFloatAlign();
2334 case BuiltinType::Double:
2335 Width = Target->getDoubleWidth();
2336 Align = Target->getDoubleAlign();
2338 case BuiltinType::Ibm128:
2339 Width = Target->getIbm128Width();
2340 Align = Target->getIbm128Align();
2342 case BuiltinType::LongDouble:
2344 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2345 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2346 Width = AuxTarget->getLongDoubleWidth();
2347 Align = AuxTarget->getLongDoubleAlign();
2349 Width = Target->getLongDoubleWidth();
2350 Align = Target->getLongDoubleAlign();
2353 case BuiltinType::Float128:
2354 if (Target->hasFloat128Type() || !
getLangOpts().OpenMP ||
2356 Width = Target->getFloat128Width();
2357 Align = Target->getFloat128Align();
2360 "Expected OpenMP device compilation.");
2361 Width = AuxTarget->getFloat128Width();
2362 Align = AuxTarget->getFloat128Align();
2365 case BuiltinType::NullPtr:
2370 case BuiltinType::ObjCId:
2371 case BuiltinType::ObjCClass:
2372 case BuiltinType::ObjCSel:
2376 case BuiltinType::OCLSampler:
2377 case BuiltinType::OCLEvent:
2378 case BuiltinType::OCLClkEvent:
2379 case BuiltinType::OCLQueue:
2380 case BuiltinType::OCLReserveID:
2381#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2382 case BuiltinType::Id:
2383#include "clang/Basic/OpenCLImageTypes.def"
2384#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2385 case BuiltinType::Id:
2386#include "clang/Basic/OpenCLExtensionTypes.def"
2388 Width = Target->getPointerWidth(AS);
2389 Align = Target->getPointerAlign(AS);
2399#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2400 case BuiltinType::Id: \
2404#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2405 case BuiltinType::Id: \
2409#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2410 case BuiltinType::Id: \
2414#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2415 case BuiltinType::Id: \
2419#include "clang/Basic/AArch64ACLETypes.def"
2420#define PPC_VECTOR_TYPE(Name, Id, Size) \
2421 case BuiltinType::Id: \
2425#include "clang/Basic/PPCTypes.def"
2426#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2428 case BuiltinType::Id: \
2432#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2433 case BuiltinType::Id: \
2437#include "clang/Basic/RISCVVTypes.def"
2438#define WASM_TYPE(Name, Id, SingletonId) \
2439 case BuiltinType::Id: \
2443#include "clang/Basic/WebAssemblyReferenceTypes.def"
2444#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2445 case BuiltinType::ID: \
2449#include "clang/Basic/AMDGPUTypes.def"
2450#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2451#include "clang/Basic/HLSLIntangibleTypes.def"
2455#define SPIRV_TYPE(Name, Id, SingletonId) \
2456 case BuiltinType::Id: \
2457 Width = Target->getPointerWidth(LangAS::Default); \
2458 Align = Target->getPointerAlign(LangAS::Default); \
2460#include "clang/Basic/SPIRVTypes.def"
2463 case Type::ObjCObjectPointer:
2467 case Type::BlockPointer:
2469 Width = Target->getPointerWidth(AS);
2470 Align = Target->getPointerAlign(AS);
2472 case Type::LValueReference:
2473 case Type::RValueReference:
2477 Width = Target->getPointerWidth(AS);
2478 Align = Target->getPointerAlign(AS);
2482 Width = Target->getPointerWidth(AS);
2483 Align = Target->getPointerAlign(AS);
2485 case Type::MemberPointer: {
2487 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2492 case Type::Complex: {
2496 Width = EltInfo.
Width * 2;
2497 Align = EltInfo.
Align;
2500 case Type::ObjCObject:
2502 case Type::Adjusted:
2505 case Type::ObjCInterface: {
2507 if (ObjCI->getDecl()->isInvalidDecl()) {
2517 case Type::BitInt: {
2519 Align = Target->getBitIntAlign(EIT->getNumBits());
2520 Width = Target->getBitIntWidth(EIT->getNumBits());
2526 const TagDecl *TD = TT->getDecl()->getDefinitionOrSelf();
2539 Info.
Align = AttrAlign;
2549 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2555 case Type::SubstTemplateTypeParm:
2557 getReplacementType().getTypePtr());
2560 case Type::DeducedTemplateSpecialization: {
2562 assert(!A->getDeducedType().isNull() &&
2563 "cannot request the size of an undeduced or dependent auto type");
2564 return getTypeInfo(A->getDeducedType().getTypePtr());
2570 case Type::MacroQualified:
2574 case Type::ObjCTypeParam:
2580 case Type::Typedef: {
2582 TypeInfo Info =
getTypeInfo(TT->desugar().getTypePtr());
2586 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2597 case Type::Attributed:
2601 case Type::CountAttributed:
2604 case Type::LateParsedAttr:
2607 case Type::BTFTagAttributed:
2611 case Type::OverflowBehavior:
2615 case Type::HLSLAttributedResource:
2619 case Type::HLSLInlineSpirv: {
2622 Width = ST->getSize() * 8;
2623 Align = ST->getAlignment();
2624 if (Width == 0 && Align == 0) {
2632 case Type::Atomic: {
2641 Width = Target->getCharWidth();
2643 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2649 Width = llvm::bit_ceil(Width);
2652 Align =
static_cast<unsigned>(Width);
2657 case Type::PredefinedSugar:
2666 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2667 return TypeInfo(Width, Align, AlignRequirement);
2671 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(
T);
2672 if (I != MemoizedUnadjustedAlign.end())
2675 unsigned UnadjustedAlign;
2676 if (
const auto *RT =
T->getAsCanonical<RecordType>()) {
2683 UnadjustedAlign =
getTypeAlign(
T->getUnqualifiedDesugaredType());
2686 MemoizedUnadjustedAlign[
T] = UnadjustedAlign;
2687 return UnadjustedAlign;
2691 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2741 unsigned ABIAlign = TI.
Align;
2743 T =
T->getBaseElementTypeUnsafe();
2746 if (
T->isMemberPointerType())
2749 if (!Target->allowsLargerPreferedTypeAlignment())
2752 if (
const auto *RD =
T->getAsRecordDecl()) {
2761 unsigned PreferredAlign =
static_cast<unsigned>(
2763 assert(PreferredAlign >= ABIAlign &&
2764 "PreferredAlign should be at least as large as ABIAlign.");
2765 return PreferredAlign;
2772 T = CT->getElementType().getTypePtr();
2773 if (
const auto *ED =
T->getAsEnumDecl())
2774 T = ED->getIntegerType().getTypePtr();
2775 if (
T->isSpecificBuiltinType(BuiltinType::Double) ||
2776 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2777 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2778 (
T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2779 Target->defaultsToAIXPowerAlignment()))
2834 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
2838 std::swap(
Base, Derived);
2858 llvm::append_range(Ivars, OI->
ivars());
2861 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2863 Ivars.push_back(Iv);
2871 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2874 for (
auto *Proto : OI->all_referenced_protocols()) {
2879 for (
const auto *Cat : OI->visible_categories())
2885 SD = SD->getSuperClass();
2887 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2888 for (
auto *Proto : OC->protocols()) {
2891 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2893 if (!Protocols.insert(
2897 for (
auto *Proto : OP->protocols())
2904 bool CheckIfTriviallyCopyable) {
2905 assert(RD->
isUnion() &&
"Must be union type");
2907 Context.getTypeSizeInChars(Context.getCanonicalTagType(RD));
2909 for (
const auto *Field : RD->
fields()) {
2910 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2911 CheckIfTriviallyCopyable))
2913 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2914 if (FieldSize != UnionSize)
2923 return Context.getFieldOffset(Field);
2932static std::optional<int64_t>
2934 const RecordDecl *RD,
2935 bool CheckIfTriviallyCopyable);
2937static std::optional<int64_t>
2939 bool CheckIfTriviallyCopyable) {
2940 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2943 CheckIfTriviallyCopyable);
2947 bool IsBitIntType = Field->getType()->isBitIntType();
2948 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2949 !Context.hasUniqueObjectRepresentations(Field->getType(),
2950 CheckIfTriviallyCopyable))
2951 return std::nullopt;
2953 int64_t FieldSizeInBits =
2954 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2955 if (Field->isBitField()) {
2958 if (Field->isUnnamedBitField())
2961 int64_t BitfieldSize = Field->getBitWidthValue();
2963 if ((
unsigned)BitfieldSize >
2965 return std::nullopt;
2966 }
else if (BitfieldSize > FieldSizeInBits) {
2967 return std::nullopt;
2969 FieldSizeInBits = BitfieldSize;
2970 }
else if (IsBitIntType && !Context.hasUniqueObjectRepresentations(
2971 Field->getType(), CheckIfTriviallyCopyable)) {
2972 return std::nullopt;
2974 return FieldSizeInBits;
2977static std::optional<int64_t>
2979 bool CheckIfTriviallyCopyable) {
2981 CheckIfTriviallyCopyable);
2984template <
typename RangeT>
2986 const RangeT &Subobjects, int64_t CurOffsetInBits,
2988 bool CheckIfTriviallyCopyable) {
2989 for (
const auto *Subobject : Subobjects) {
2990 std::optional<int64_t> SizeInBits =
2993 return std::nullopt;
2994 if (*SizeInBits != 0) {
2996 if (Offset != CurOffsetInBits)
2997 return std::nullopt;
2998 CurOffsetInBits += *SizeInBits;
3001 return CurOffsetInBits;
3004static std::optional<int64_t>
3007 bool CheckIfTriviallyCopyable) {
3008 assert(!RD->
isUnion() &&
"Must be struct/class type");
3009 const auto &Layout = Context.getASTRecordLayout(RD);
3011 int64_t CurOffsetInBits = 0;
3012 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3013 if (ClassDecl->isDynamicClass())
3014 return std::nullopt;
3017 for (
const auto &
Base : ClassDecl->bases()) {
3020 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
3024 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
3027 std::optional<int64_t> OffsetAfterBases =
3029 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
3030 if (!OffsetAfterBases)
3031 return std::nullopt;
3032 CurOffsetInBits = *OffsetAfterBases;
3035 std::optional<int64_t> OffsetAfterFields =
3037 RD->
fields(), CurOffsetInBits, Context, Layout,
3038 CheckIfTriviallyCopyable);
3039 if (!OffsetAfterFields)
3040 return std::nullopt;
3041 CurOffsetInBits = *OffsetAfterFields;
3043 return CurOffsetInBits;
3047 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
3064 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
3069 CheckIfTriviallyCopyable);
3072 "hasUniqueObjectRepresentations should not be called with an "
3096 return !ABI->getMemberPointerInfo(MPT).HasPadding;
3099 if (
Record->isInvalidDecl())
3104 CheckIfTriviallyCopyable);
3107 *
this,
Record, CheckIfTriviallyCopyable);
3109 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
3130 count += Ext->ivar_size();
3135 count += ImplDecl->ivar_size();
3161 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3162 I = ObjCImpls.find(D);
3163 if (I != ObjCImpls.end())
3171 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3172 I = ObjCImpls.find(D);
3173 if (I != ObjCImpls.end())
3181 assert(IFaceD && ImplD &&
"Passed null params");
3182 ObjCImpls[IFaceD] = ImplD;
3188 assert(CatD && ImplD &&
"Passed null params");
3189 ObjCImpls[CatD] = ImplD;
3194 return ObjCMethodRedecls.
lookup(MD);
3200 ObjCMethodRedecls[MD] = Redecl;
3205 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3207 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3208 return CD->getClassInterface();
3209 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3210 return IMD->getClassInterface();
3218 assert(VD &&
"Passed null params");
3219 assert(VD->
hasAttr<BlocksAttr>() &&
3220 "getBlockVarCopyInits - not __block var");
3221 auto I = BlockVarCopyInits.find(VD);
3222 if (I != BlockVarCopyInits.end())
3224 return {
nullptr,
false};
3230 assert(VD && CopyExpr &&
"Passed null params");
3231 assert(VD->
hasAttr<BlocksAttr>() &&
3232 "setBlockVarCopyInits - not __block var");
3233 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3237 unsigned DataSize)
const {
3242 "incorrect data size provided to CreateTypeSourceInfo!");
3259 return getObjCLayout(D);
3264 bool &AnyNonCanonArgs) {
3266 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3272 bool AnyNonCanonArgs =
false;
3273 for (
auto &Arg : Args) {
3276 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3278 return AnyNonCanonArgs;
3286ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3291 llvm::FoldingSetNodeID ID;
3293 llvm::FoldingSetInsertToken
Token;
3295 assert(eq->getQualifiers() == quals);
3304 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3307 (void)ExtQualNodes.lookup(ID,
Token);
3310 auto *eq =
new (*
this,
alignof(ExtQuals)) ExtQuals(baseType, canon, quals);
3311 ExtQualNodes.insert(eq, Token);
3312 return QualType(eq, fastQuals);
3316 LangAS AddressSpace)
const {
3329 "Type cannot be in multiple addr spaces!");
3332 return getExtQualType(TypeNode, Quals);
3338 if (!
T.hasAddressSpace())
3342 const Type *TypeNode;
3345 if (
T.getTypePtr()->isArrayType()) {
3347 TypeNode =
T.getTypePtr();
3351 while (
T.hasAddressSpace()) {
3352 TypeNode = Quals.
strip(
T);
3356 if (!
QualType(TypeNode, 0).hasAddressSpace())
3360 T =
T.getSingleStepDesugaredType(*
this);
3370 return getExtQualType(TypeNode, Quals);
3379 "Attempted to get vtable pointer discriminator on a monomorphic type");
3383 llvm::raw_svector_ostream Out(Str);
3384 MC->mangleCXXVTable(RD, Out);
3387 return llvm::getPointerAuthStableSipHash(Str);
3413 switch (
T->getTypeClass()) {
3418 case Type::LValueReference:
3423 case Type::RValueReference:
3437 case Type::ObjCObjectPointer:
3438 case Type::BlockPointer:
3447 case Type::VariableArray:
3448 case Type::ConstantArray:
3449 case Type::IncompleteArray:
3450 case Type::ArrayParameter:
3463 case Type::ObjCInterface:
3464 case Type::ObjCObject:
3465 OS <<
"<objc_object>";
3474 QualType UnderlyingType =
T->castAsEnumDecl()->getIntegerType();
3476 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3479 case Type::FunctionNoProto:
3480 case Type::FunctionProto: {
3496 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3497 for (
QualType Param : FPT->param_types()) {
3501 if (FPT->isVariadic())
3508 case Type::MemberPointer: {
3512 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3516 case Type::ExtVector:
3524 case Type::ConstantMatrix:
3528 case Type::Builtin: {
3530 switch (BTy->getKind()) {
3531#define SIGNED_TYPE(Id, SingletonId) \
3532 case BuiltinType::Id: \
3535#define UNSIGNED_TYPE(Id, SingletonId) \
3536 case BuiltinType::Id: \
3539#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3540#define BUILTIN_TYPE(Id, SingletonId)
3541#include "clang/AST/BuiltinTypes.def"
3542 llvm_unreachable(
"placeholder types should not appear here.");
3544 case BuiltinType::Half:
3547 case BuiltinType::Float:
3550 case BuiltinType::Double:
3553 case BuiltinType::LongDouble:
3556 case BuiltinType::Float16:
3559 case BuiltinType::Float128:
3563 case BuiltinType::Void:
3567 case BuiltinType::ObjCId:
3568 case BuiltinType::ObjCClass:
3569 case BuiltinType::ObjCSel:
3570 case BuiltinType::NullPtr:
3575 case BuiltinType::OCLSampler:
3576 case BuiltinType::OCLEvent:
3577 case BuiltinType::OCLClkEvent:
3578 case BuiltinType::OCLQueue:
3579 case BuiltinType::OCLReserveID:
3580 case BuiltinType::BFloat16:
3581 case BuiltinType::VectorQuad:
3582 case BuiltinType::VectorPair:
3583 case BuiltinType::DMR1024:
3584 case BuiltinType::DMR2048:
3589 case BuiltinType::Ibm128:
3591#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3592 case BuiltinType::Id: \
3594#include "clang/Basic/OpenCLImageTypes.def"
3595#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3596 case BuiltinType::Id: \
3598#include "clang/Basic/OpenCLExtensionTypes.def"
3599#define SVE_TYPE(Name, Id, SingletonId) \
3600 case BuiltinType::Id: \
3602#include "clang/Basic/AArch64ACLETypes.def"
3603#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3604 case BuiltinType::Id: \
3606#include "clang/Basic/HLSLIntangibleTypes.def"
3607 case BuiltinType::Dependent:
3608 llvm_unreachable(
"should never get here");
3609#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3610#include "clang/Basic/AMDGPUTypes.def"
3611 case BuiltinType::WasmExternRef:
3612#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3613#include "clang/Basic/RISCVVTypes.def"
3614#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3615#include "clang/Basic/SPIRVTypes.def"
3616 llvm_unreachable(
"not yet implemented");
3618 llvm_unreachable(
"should never get here");
3620 case Type::Record: {
3621 const RecordDecl *RD =
T->castAsCanonical<RecordType>()->getDecl();
3641 II = Typedef->getDeclName().getAsIdentifierInfo();
3644 OS <<
"<anonymous_record>";
3650 case Type::HLSLAttributedResource:
3651 case Type::HLSLInlineSpirv:
3652 llvm_unreachable(
"should never get here");
3654 case Type::OverflowBehavior:
3655 llvm_unreachable(
"should never get here");
3657 case Type::DeducedTemplateSpecialization:
3659#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3660#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3661#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3662#define ABSTRACT_TYPE(Class, Base)
3663#define TYPE(Class, Base)
3664#include "clang/AST/TypeNodes.inc"
3665 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3671 assert(!
T->isDependentType() &&
3672 "cannot compute type discriminator of a dependent type");
3674 llvm::raw_svector_ostream Out(Str);
3676 if (
T->isFunctionPointerType() ||
T->isFunctionReferenceType())
3677 T =
T->getPointeeType();
3679 if (
T->isFunctionType()) {
3682 T =
T.getUnqualifiedType();
3703 if (MPT->isMemberFunctionPointer()) {
3709 MPT->getMostRecentCXXRecordDecl());
3713 MC->mangleCanonicalTypeName(
T, Out);
3716 return llvm::getPointerAuthStableSipHash(Str);
3741 "Type cannot have multiple ObjCGCs!");
3744 return getExtQualType(TypeNode, Quals);
3749 QualType Pointee = Ptr->getPointeeType();
3758 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3762 llvm::FoldingSetNodeID ID;
3765 llvm::FoldingSetInsertToken
Token;
3771 size_t Size = CountAttributedType::totalSizeToAlloc<TypeCoupledDeclRefInfo>(
3772 DependentDecls.size());
3775 OrNull, DependentDecls);
3776 Types.push_back(CATy);
3777 CountAttributedTypes.insert(CATy,
Token);
3789 Types.push_back(LPATy);
3797 case Type::Attributed: {
3805 case Type::BTFTagAttributed: {
3806 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3811 case Type::OverflowBehavior: {
3812 const auto *OB = dyn_cast<OverflowBehaviorType>(Orig);
3814 adjustType(OB->getUnderlyingType(), Adjust));
3821 case Type::Adjusted: {
3827 case Type::MacroQualified: {
3830 MQT->getMacroIdentifier());
3834 return Adjust(Orig);
3840 if (
T->getExtInfo() == Info)
3844 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(
T)) {
3864 FPT->getExtProtoInfo());
3879 L->DeducedReturnType(FD, ResultType);
3890 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3891 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3907 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
3930 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
3956 if (TSInfo->getType() != FD->
getType())
3964 "TypeLoc size mismatch from updating exception specification");
3965 TSInfo->overrideType(Updated);
3974 llvm::FoldingSetInsertToken
Token;
3981 if (!
T.isCanonical()) {
3984 assert(!ComplexTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
3987 Types.push_back(
New);
3997 llvm::FoldingSetInsertToken
Token;
4004 if (!
T.isCanonical()) {
4007 assert(!PointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4010 Types.push_back(
New);
4016 llvm::FoldingSetInsertToken
Token;
4025 Types.push_back(AT);
4026 AdjustedTypes.insert(AT,
Token);
4031 llvm::FoldingSetInsertToken
Token;
4039 Types.push_back(AT);
4040 AdjustedTypes.insert(AT,
Token);
4045 assert((
T->isArrayType() ||
T->isFunctionType()) &&
"T does not decay");
4054 if (
T->isArrayType())
4061 if (
T->isFunctionType())
4073 llvm::FoldingSetNodeID ID;
4074 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
4075 ATy->getSizeExpr(), ATy->getSizeModifier(),
4076 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
4077 llvm::FoldingSetInsertToken
Token;
4087 AT = ArrayParameterTypes.lookup(ID,
Token);
4088 assert(!AT &&
"Shouldn't be in the map!");
4093 Types.push_back(AT);
4094 ArrayParameterTypes.insert(AT,
Token);
4101 assert(
T->isFunctionType() &&
"block of function types only");
4104 llvm::FoldingSetInsertToken
Token;
4111 if (!
T.isCanonical()) {
4114 assert(!BlockPointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4118 Types.push_back(
New);
4119 BlockPointerTypes.insert(
New,
Token);
4127 assert((!
T->isPlaceholderType() ||
4128 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4129 "Unresolved placeholder type");
4133 llvm::FoldingSetInsertToken
Token;
4135 LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token))
4143 if (!SpelledAsLValue || InnerRef || !
T.isCanonical()) {
4144 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4147 assert(!LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token) &&
4148 "Shouldn't be in the map!");
4153 Types.push_back(
New);
4154 LValueReferenceTypes.insert(
New,
Token);
4162 assert((!
T->isPlaceholderType() ||
4163 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4164 "Unresolved placeholder type");
4168 llvm::FoldingSetInsertToken
Token;
4177 if (InnerRef || !
T.isCanonical()) {
4178 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4181 assert(!RValueReferenceTypes.lookup({T, false},
Token) &&
4182 "Shouldn't be in the map!");
4187 Types.push_back(
New);
4188 RValueReferenceTypes.insert(
New,
Token);
4196 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4199 Cls = Qualifier.getAsRecordDecl();
4203 llvm::FoldingSetNodeID ID;
4206 llvm::FoldingSetInsertToken
Token;
4212 return Qualifier.getCanonical();
4214 assert(R.isCanonical());
4220 if (!
T.isCanonical() || Qualifier != CanonicalQualifier) {
4226 MemberPointerTypes.lookup(ID,
Token);
4227 assert(!NewIP &&
"Shouldn't be in the map!");
4231 Types.push_back(
New);
4232 MemberPointerTypes.insert(
New,
Token);
4239 const llvm::APInt &ArySizeIn,
4240 const Expr *SizeExpr,
4242 unsigned IndexTypeQuals)
const {
4245 "Constant array of VLAs is illegal!");
4253 llvm::APInt ArySize(ArySizeIn);
4254 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
4260 llvm::FoldingSetNodeID ID;
4262 ASM, IndexTypeQuals);
4264 llvm::FoldingSetInsertToken
Token;
4276 ASM, IndexTypeQuals);
4281 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4284 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4285 ASM, IndexTypeQuals);
4286 ConstantArrayTypes.insert(
New,
Token);
4287 Types.push_back(
New);
4296 if (!
type->isVariablyModifiedType())
return type;
4301 const Type *ty = split.
Ty;
4303#define TYPE(Class, Base)
4304#define ABSTRACT_TYPE(Class, Base)
4305#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4306#include "clang/AST/TypeNodes.inc"
4307 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4313 case Type::DependentVector:
4314 case Type::ExtVector:
4315 case Type::DependentSizedExtVector:
4316 case Type::ConstantMatrix:
4317 case Type::DependentSizedMatrix:
4318 case Type::DependentAddressSpace:
4319 case Type::ObjCObject:
4320 case Type::ObjCInterface:
4321 case Type::ObjCObjectPointer:
4324 case Type::UnresolvedUsing:
4325 case Type::TypeOfExpr:
4327 case Type::Decltype:
4328 case Type::UnaryTransform:
4329 case Type::DependentName:
4330 case Type::InjectedClassName:
4331 case Type::TemplateSpecialization:
4332 case Type::TemplateTypeParm:
4333 case Type::SubstTemplateTypeParmPack:
4334 case Type::SubstBuiltinTemplatePack:
4336 case Type::DeducedTemplateSpecialization:
4337 case Type::PackExpansion:
4338 case Type::PackIndexing:
4340 case Type::DependentBitInt:
4341 case Type::ArrayParameter:
4342 case Type::HLSLAttributedResource:
4343 case Type::HLSLInlineSpirv:
4344 case Type::OverflowBehavior:
4345 llvm_unreachable(
"type should never be variably-modified");
4349 case Type::FunctionNoProto:
4350 case Type::FunctionProto:
4351 case Type::BlockPointer:
4352 case Type::MemberPointer:
4365 case Type::LValueReference: {
4369 lv->isSpelledAsLValue());
4373 case Type::RValueReference: {
4380 case Type::Atomic: {
4386 case Type::ConstantArray: {
4392 cat->getSizeModifier(),
4393 cat->getIndexTypeCVRQualifiers());
4397 case Type::DependentSizedArray: {
4401 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4406 case Type::IncompleteArray: {
4411 iat->getIndexTypeCVRQualifiers());
4416 case Type::VariableArray: {
4421 vat->getIndexTypeCVRQualifiers());
4434 unsigned IndexTypeQuals)
const {
4451 VariableArrayTypes.push_back(
New);
4452 Types.push_back(
New);
4462 unsigned elementTypeQuals)
const {
4465 "Size must be type- or value-dependent!");
4469 llvm::FoldingSetInsertToken
Token;
4470 llvm::FoldingSetNodeID ID;
4472 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4473 ASM, elementTypeQuals, numElements);
4488 DependentSizedArrayTypes.insert(newType,
Token);
4489 Types.push_back(newType);
4497 numElements, ASM, elementTypeQuals);
4498 DependentSizedArrayTypes.insert(canonTy,
Token);
4499 Types.push_back(canonTy);
4504 canonElementType.
Quals);
4508 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4517 Types.push_back(sugaredType);
4523 unsigned elementTypeQuals)
const {
4524 llvm::FoldingSetNodeID ID;
4527 llvm::FoldingSetInsertToken
Token;
4540 ASM, elementTypeQuals);
4545 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4551 IncompleteArrayTypes.insert(newType,
Token);
4552 Types.push_back(newType);
4558#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4559 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4562#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4563 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4567 llvm_unreachable(
"Unsupported builtin vector type");
4569#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4570 ElBits, NF, IsSigned) \
4571 case BuiltinType::Id: \
4572 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4573 llvm::ElementCount::getScalable(NumEls), NF};
4574#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4576 case BuiltinType::Id: \
4577 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4578 llvm::ElementCount::getScalable(NumEls), NF};
4579#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4581 case BuiltinType::Id: \
4582 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4583#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4585 case BuiltinType::Id: \
4586 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4587#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4588 case BuiltinType::Id: \
4589 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4590#include "clang/Basic/AArch64ACLETypes.def"
4592#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4594 case BuiltinType::Id: \
4595 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4596 llvm::ElementCount::getScalable(NumEls), NF};
4597#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4598 case BuiltinType::Id: \
4599 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4600 llvm::ElementCount::getScalable(NumEls), NF};
4601#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4602 case BuiltinType::Id: \
4603 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4604#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4605 case BuiltinType::Id: \
4606 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4607#include "clang/Basic/RISCVVTypes.def"
4614 if (Target->getTriple().isWasm() && Target->hasFeature(
"reference-types")) {
4615#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4616 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4618#include "clang/Basic/WebAssemblyReferenceTypes.def"
4621 "shouldn't try to generate type externref outside WebAssembly target");
4628 unsigned NumFields)
const {
4630 if (
auto It = ScalableVecTyMap.find(K); It != ScalableVecTyMap.end())
4633 if (Target->hasAArch64ACLETypes()) {
4636#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4637 ElBits, NF, IsSigned) \
4638 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4639 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4640 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4641 return ScalableVecTyMap[K] = SingletonId; \
4643#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4645 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4646 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4647 return ScalableVecTyMap[K] = SingletonId; \
4649#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4651 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4652 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4653 return ScalableVecTyMap[K] = SingletonId; \
4655#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4657 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4658 NumElts == (NumEls * NF) && NumFields == 1) { \
4659 return ScalableVecTyMap[K] = SingletonId; \
4661#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4662 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4663 return ScalableVecTyMap[K] = SingletonId;
4664#include "clang/Basic/AArch64ACLETypes.def"
4665 }
else if (Target->hasRISCVVTypes()) {
4667#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4669 if (!EltTy->isBooleanType() && \
4670 ((EltTy->hasIntegerRepresentation() && \
4671 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4672 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4674 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4675 IsBF && !IsFP)) && \
4676 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4677 return ScalableVecTyMap[K] = SingletonId;
4678#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4679 if (EltTy->isBooleanType() && NumElts == NumEls) \
4680 return ScalableVecTyMap[K] = SingletonId;
4681#include "clang/Basic/RISCVVTypes.def"
4696 llvm::FoldingSetNodeID ID;
4699 llvm::FoldingSetInsertToken
Token;
4711 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4714 VectorType(vecType, NumElts, Canonical, VecKind);
4716 Types.push_back(
New);
4723 llvm::FoldingSetNodeID ID;
4726 llvm::FoldingSetInsertToken
Token;
4732 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4735 if (CanonVecTy == VecType) {
4740 assert(!CanonCheck &&
4741 "Dependent-sized vector_size canonical type broken");
4743 DependentVectorTypes.insert(
New,
Token);
4752 Types.push_back(
New);
4759 unsigned NumElts)
const {
4766 llvm::FoldingSetNodeID ID;
4769 llvm::FoldingSetInsertToken
Token;
4781 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4786 Types.push_back(
New);
4794 llvm::FoldingSetNodeID ID;
4798 llvm::FoldingSetInsertToken
Token;
4800 DependentSizedExtVectorTypes.lookup(ID,
Token);
4810 if (CanonVecTy == vecType) {
4815 DependentSizedExtVectorTypes.lookup(ID,
Token);
4816 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4818 DependentSizedExtVectorTypes.insert(
New,
Token);
4827 Types.push_back(
New);
4832 unsigned NumColumns)
const {
4833 llvm::FoldingSetNodeID ID;
4835 Type::ConstantMatrix);
4838 "need a valid element type");
4839 assert(NumRows > 0 && NumRows <= LangOpts.MaxMatrixDimension &&
4840 NumColumns > 0 && NumColumns <= LangOpts.MaxMatrixDimension &&
4841 "need valid matrix dimensions");
4842 llvm::FoldingSetInsertToken
Token;
4852 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4859 Types.push_back(
New);
4868 llvm::FoldingSetNodeID ID;
4872 llvm::FoldingSetInsertToken
Token;
4878 ColumnExpr, AttrLoc);
4881 DependentSizedMatrixTypes.lookup(ID,
Token);
4882 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4884 DependentSizedMatrixTypes.insert(Canon,
Token);
4885 Types.push_back(Canon);
4898 ColumnExpr, AttrLoc);
4899 Types.push_back(
New);
4904 Expr *AddrSpaceExpr,
4910 llvm::FoldingSetInsertToken
Token;
4911 llvm::FoldingSetNodeID ID;
4916 DependentAddressSpaceTypes.lookup(ID,
Token);
4922 DependentAddressSpaceTypes.insert(canonTy,
Token);
4923 Types.push_back(canonTy);
4926 if (canonPointeeType == PointeeType &&
4932 AddrSpaceExpr, AttrLoc);
4933 Types.push_back(sugaredType);
4939 return T.isCanonical() &&
4957 llvm::FoldingSetNodeID ID;
4960 llvm::FoldingSetInsertToken
Token;
4971 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4976 Types.push_back(
New);
4977 FunctionNoProtoTypes.insert(
New,
Token);
4993 return CanResultType;
5000 if (!NoexceptInType)
5017 bool AnyPackExpansions =
false;
5021 if (ET->
getAs<PackExpansionType>())
5022 AnyPackExpansions =
true;
5024 return AnyPackExpansions;
5030QualType ASTContext::getFunctionTypeInternal(
5031 QualType ResultTy, ArrayRef<QualType> ArgArray,
5032 const FunctionProtoType::ExtProtoInfo &EPI,
bool OnlyWantCanonical)
const {
5033 size_t NumArgs = ArgArray.size();
5037 llvm::FoldingSetNodeID
ID;
5042 bool Unique =
false;
5044 llvm::FoldingSetInsertToken Token;
5045 if (FunctionProtoType *FPT = FunctionProtoTypes.lookup(ID, Token)) {
5046 QualType Existing = QualType(FPT, 0);
5065 bool IsCanonicalExceptionSpec =
5069 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
5071 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
5072 if (!ArgArray[i].isCanonicalAsParam())
5073 isCanonical =
false;
5075 if (OnlyWantCanonical)
5076 assert(isCanonical &&
5077 "given non-canonical parameters constructing canonical type");
5082 if (!isCanonical && Canonical.
isNull()) {
5083 SmallVector<QualType, 16> CanonicalArgs;
5084 CanonicalArgs.reserve(NumArgs);
5085 for (
unsigned i = 0; i != NumArgs; ++i)
5088 llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
5089 FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
5092 if (IsCanonicalExceptionSpec) {
5094 }
else if (NoexceptInType) {
5107 bool AnyPacks =
false;
5109 if (ET->
getAs<PackExpansionType>())
5130 llvm_unreachable(
"dependent noexcept is already canonical");
5133 CanonicalEPI.
ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
5139 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5142 FunctionProtoType *NewIP = FunctionProtoTypes.lookup(ID, Token);
5143 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5148 auto ESH = FunctionProtoType::getExceptionSpecSize(
5150 size_t Size = FunctionProtoType::totalSizeToAlloc<
5151 QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
5152 FunctionType::FunctionTypeExtraAttributeInfo,
5153 FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
5154 Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, Qualifiers,
5155 FunctionEffect, EffectConditionExpr>(
5159 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5164 auto *FTP = (FunctionProtoType *)
Allocate(Size,
alignof(FunctionProtoType));
5165 FunctionProtoType::ExtProtoInfo newEPI = EPI;
5166 new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
5167 Types.push_back(FTP);
5169 FunctionProtoTypes.insert(FTP, Token);
5171 AnyFunctionEffects =
true;
5172 return QualType(FTP, 0);
5175QualType ASTContext::getPipeType(QualType
T,
bool ReadOnly)
const {
5176 llvm::FoldingSetInsertToken Token;
5177 if (PipeType *PT = PipeTypes.lookup({T, ReadOnly}, Token))
5178 return QualType(PT, 0);
5183 if (!
T.isCanonical()) {
5186 assert(!PipeTypes.lookup({T, ReadOnly}, Token) &&
5187 "Shouldn't be in the map!");
5189 auto *
New =
new (*
this,
alignof(PipeType)) PipeType(
T, Canonical, ReadOnly);
5190 Types.push_back(
New);
5191 PipeTypes.insert(
New, Token);
5192 return QualType(
New, 0);
5202 return getPipeType(
T,
true);
5206 return getPipeType(
T,
false);
5210 auto Key = std::make_pair(
unsigned(IsUnsigned), NumBits);
5212 llvm::FoldingSetInsertToken
Token;
5218 Types.push_back(
New);
5223 Expr *NumBitsExpr)
const {
5225 llvm::FoldingSetNodeID ID;
5228 llvm::FoldingSetInsertToken
Token;
5234 DependentBitIntTypes.insert(
New,
Token);
5236 Types.push_back(
New);
5244 if (
auto *Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5256 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5257 case Kind::SignedSizeT:
5259 case Kind::PtrdiffT:
5262 llvm_unreachable(
"unexpected kind");
5267 Types.push_back(
New);
5268 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5275 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5278 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5280 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5289 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5291 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5293 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5295 assert(TD->TypeForDecl);
5300 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5302 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5303 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5306 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5309 assert(
Decl->TypeForDecl);
5319 std::optional<bool> TypeMatchesDeclOrNone)
const {
5320 if (!TypeMatchesDeclOrNone) {
5321 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5322 assert(!DeclUnderlyingType.
isNull());
5323 if (UnderlyingType.
isNull())
5324 UnderlyingType = DeclUnderlyingType;
5326 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5327 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5331 assert(!UnderlyingType.
isNull());
5335 *TypeMatchesDeclOrNone) {
5336 if (
Decl->TypeForDecl)
5341 !*TypeMatchesDeclOrNone);
5343 Types.push_back(NewType);
5344 Decl->TypeForDecl = NewType;
5348 llvm::FoldingSetNodeID ID;
5350 *TypeMatchesDeclOrNone ?
QualType() : UnderlyingType);
5352 llvm::FoldingSetInsertToken
Token;
5354 TypedefTypes.lookup(ID,
Token))
5355 return QualType(Placeholder->getType(), 0);
5360 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5364 UnderlyingType, !*TypeMatchesDeclOrNone);
5365 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5367 TypedefTypes.insert(Placeholder,
Token);
5368 Types.push_back(NewType);
5377 if (UnderlyingType.
isNull()) {
5385 llvm::FoldingSetNodeID ID;
5388 llvm::FoldingSetInsertToken
Token;
5399 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5403 UsingTypes.insert(
T,
Token);
5409 const TagDecl *TD,
bool OwnsTag,
5411 const Type *CanonicalType,
5412 bool WithFoldingSetNode)
const {
5413 auto [TC, Size] = [&] {
5416 static_assert(
alignof(EnumType) ==
alignof(TagType));
5417 return std::make_tuple(Type::Enum,
sizeof(EnumType));
5418 case Decl::ClassTemplatePartialSpecialization:
5419 case Decl::ClassTemplateSpecialization:
5420 case Decl::CXXRecord:
5421 static_assert(
alignof(RecordType) ==
alignof(TagType));
5422 static_assert(
alignof(InjectedClassNameType) ==
alignof(TagType));
5424 return std::make_tuple(Type::InjectedClassName,
5425 sizeof(InjectedClassNameType));
5428 return std::make_tuple(Type::Record,
sizeof(RecordType));
5430 llvm_unreachable(
"unexpected decl kind");
5440 if (WithFoldingSetNode) {
5448 sizeof(TagTypeFoldingSetPlaceholder) +
5449 TagTypeFoldingSetPlaceholder::getOffset() + Size,
5450 std::max(
alignof(TagTypeFoldingSetPlaceholder),
alignof(TagType)));
5451 auto *
T =
new (Mem) TagTypeFoldingSetPlaceholder();
5452 Mem =
T->getTagType();
5454 Mem =
Allocate(Size,
alignof(TagType));
5457 auto *
T = [&, TC = TC]() -> TagType * {
5461 auto *
T =
new (Mem) EnumType(TC,
Keyword, Qualifier, TD, OwnsTag,
5462 IsInjected, CanonicalType);
5463 assert(
reinterpret_cast<void *
>(
T) ==
5464 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5465 "TagType must be the first base of EnumType");
5468 case Type::Record: {
5470 auto *
T =
new (Mem) RecordType(TC,
Keyword, Qualifier, TD, OwnsTag,
5471 IsInjected, CanonicalType);
5472 assert(
reinterpret_cast<void *
>(
T) ==
5473 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5474 "TagType must be the first base of RecordType");
5477 case Type::InjectedClassName: {
5478 auto *
T =
new (Mem) InjectedClassNameType(
Keyword, Qualifier, TD,
5479 IsInjected, CanonicalType);
5480 assert(
reinterpret_cast<void *
>(
T) ==
5481 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5482 "TagType must be the first base of InjectedClassNameType");
5486 llvm_unreachable(
"unexpected type class");
5489 assert(
T->getKeyword() ==
Keyword);
5490 assert(
T->getQualifier() == Qualifier);
5491 assert(
T->getDecl() == TD);
5492 assert(
T->isInjected() == IsInjected);
5493 assert(
T->isTagOwned() == OwnsTag);
5502 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5503 RD && RD->isInjectedClassName())
5510 if (TD->TypeForDecl)
5511 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5513 const Type *CanonicalType = getTagTypeInternal(
5516 false,
false,
nullptr,
5518 TD->TypeForDecl = CanonicalType;
5524 const TagDecl *TD,
bool OwnsTag)
const {
5527 bool IsInjected = TD != NonInjectedTD;
5534 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5535 if (
const Type *
T = TD->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5541 std::nullopt, NonInjectedTD,
5542 false, IsInjected, CanonicalType,
5544 TD->TypeForDecl =
T;
5548 llvm::FoldingSetNodeID ID;
5549 TagTypeFoldingSetPlaceholder::Profile(ID,
Keyword, Qualifier, NonInjectedTD,
5550 OwnsTag, IsInjected);
5552 llvm::FoldingSetInsertToken
Token;
5553 if (TagTypeFoldingSetPlaceholder *
T = TagTypes.lookup(ID,
Token))
5558 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5559 CanonicalType,
true);
5560 TagTypes.insert(TagTypeFoldingSetPlaceholder::fromTagType(
T),
Token);
5565 unsigned NumPositiveBits,
5568 unsigned IntWidth = Target->getIntWidth();
5569 unsigned CharWidth = Target->getCharWidth();
5570 unsigned ShortWidth = Target->getShortWidth();
5571 bool EnumTooLarge =
false;
5573 if (NumNegativeBits) {
5577 if (IsPacked && NumNegativeBits <= CharWidth &&
5578 NumPositiveBits < CharWidth) {
5580 BestWidth = CharWidth;
5581 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5582 NumPositiveBits < ShortWidth) {
5584 BestWidth = ShortWidth;
5585 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5587 BestWidth = IntWidth;
5589 BestWidth = Target->getLongWidth();
5591 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5594 BestWidth = Target->getLongLongWidth();
5596 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5597 EnumTooLarge =
true;
5601 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5606 if (IsPacked && NumPositiveBits <= CharWidth) {
5608 BestPromotionType =
IntTy;
5609 BestWidth = CharWidth;
5610 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5612 BestPromotionType =
IntTy;
5613 BestWidth = ShortWidth;
5614 }
else if (NumPositiveBits <= IntWidth) {
5616 BestWidth = IntWidth;
5617 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5620 }
else if (NumPositiveBits <= (BestWidth = Target->getLongWidth())) {
5622 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5626 BestWidth = Target->getLongLongWidth();
5627 if (NumPositiveBits > BestWidth) {
5632 EnumTooLarge =
true;
5635 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5640 return EnumTooLarge;
5644 assert((
T->isIntegralType(*
this) ||
T->isEnumeralType()) &&
5645 "Integral type required!");
5648 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5649 if (
T->isSignedIntegerOrEnumerationType())
5651 return Value.getActiveBits() <= BitWidth;
5653 return Value.getSignificantBits() <= BitWidth;
5659 const Type *CanonicalType)
const {
5661 UnresolvedUsingType::totalSizeToAlloc<
5663 !!
Token, !!Qualifier),
5667 auto *Placeholder =
new (
T->getFoldingSetPlaceholder())
5669 UnresolvedUsingTypes.insert(Placeholder,
Token);
5679 return D->TypeForDecl->getCanonicalTypeUnqualified();
5681 const Type *CanonicalType =
5685 D->TypeForDecl = CanonicalType;
5694 if (
const Type *
T = D->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5706 llvm::FoldingSetNodeID ID;
5709 llvm::FoldingSetInsertToken
Token;
5711 UnresolvedUsingTypes.lookup(ID,
Token))
5712 return QualType(Placeholder->getType(), 0);
5725 llvm::FoldingSetNodeID id;
5726 AttributedType::Profile(
id, *
this, attrKind, modifiedType, equivalentType,
5729 llvm::FoldingSetInsertToken
Token;
5730 AttributedType *
type = AttributedTypes.lookup(
id,
Token);
5733 assert(!
attr ||
attr->getKind() == attrKind);
5736 type =
new (*
this,
alignof(AttributedType))
5737 AttributedType(canon, attrKind,
attr, modifiedType, equivalentType);
5739 Types.push_back(
type);
5753 switch (nullability) {
5769 llvm_unreachable(
"Unknown nullability kind");
5774 llvm::FoldingSetNodeID ID;
5775 BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
5777 llvm::FoldingSetInsertToken
Token;
5778 BTFTagAttributedType *Ty = BTFTagAttributedTypes.lookup(ID,
Token);
5783 Ty =
new (*
this,
alignof(BTFTagAttributedType))
5784 BTFTagAttributedType(Canon, Wrapped, BTFAttr);
5786 Types.push_back(Ty);
5787 BTFTagAttributedTypes.insert(Ty,
Token);
5795 StringRef IdentName = II->
getName();
5796 OverflowBehaviorType::OverflowBehaviorKind Kind;
5797 if (IdentName ==
"wrap") {
5798 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
5799 }
else if (IdentName ==
"trap") {
5800 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
5809 OverflowBehaviorType::OverflowBehaviorKind Kind,
5812 "Cannot have underlying types that are themselves OBTs");
5813 llvm::FoldingSetNodeID ID;
5814 OverflowBehaviorType::Profile(ID, Underlying, Kind);
5815 llvm::FoldingSetInsertToken
Token;
5817 if (OverflowBehaviorType *OBT = OverflowBehaviorTypes.lookup(ID,
Token)) {
5826 assert(!OverflowBehaviorTypes.lookup(ID,
Token) &&
5827 "Shouldn't be in the map");
5830 OverflowBehaviorType *Ty =
new (*
this,
alignof(OverflowBehaviorType))
5831 OverflowBehaviorType(Canonical, Underlying, Kind);
5833 Types.push_back(Ty);
5834 OverflowBehaviorTypes.insert(Ty,
Token);
5840 const HLSLAttributedResourceType::Attributes &Attrs) {
5842 llvm::FoldingSetNodeID ID;
5843 HLSLAttributedResourceType::Profile(ID, *
this, Wrapped, Contained, Attrs);
5845 llvm::FoldingSetInsertToken
Token;
5846 HLSLAttributedResourceType *Ty =
5847 HLSLAttributedResourceTypes.lookup(ID,
Token);
5851 Ty =
new (*
this,
alignof(HLSLAttributedResourceType))
5852 HLSLAttributedResourceType(Wrapped, Contained, Attrs);
5854 Types.push_back(Ty);
5855 HLSLAttributedResourceTypes.insert(Ty,
Token);
5863 llvm::FoldingSetNodeID ID;
5864 HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
5866 llvm::FoldingSetInsertToken
Token;
5867 HLSLInlineSpirvType *Ty = HLSLInlineSpirvTypes.lookup(ID,
Token);
5872 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5873 alignof(HLSLInlineSpirvType));
5875 Ty =
new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
5877 Types.push_back(Ty);
5878 HLSLInlineSpirvTypes.insert(Ty,
Token);
5885 Decl *AssociatedDecl,
5890 std::make_tuple(Replacement, AssociatedDecl, Index,
5891 PackIndex.toInternalRepresentation(),
unsigned(Final));
5892 llvm::FoldingSetInsertToken
Token;
5893 SubstTemplateTypeParmType *SubstParm =
5894 SubstTemplateTypeParmTypes.lookup(Key,
Token);
5897 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5898 !Replacement.isCanonical()),
5899 alignof(SubstTemplateTypeParmType));
5900 SubstParm =
new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
5902 Types.push_back(SubstParm);
5903 SubstTemplateTypeParmTypes.insert(SubstParm,
Token);
5911 unsigned Index,
bool Final,
5918 llvm::FoldingSetNodeID ID;
5919 SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
5921 llvm::FoldingSetInsertToken
Token;
5922 if (SubstTemplateTypeParmPackType *SubstParm =
5923 SubstTemplateTypeParmPackTypes.lookup(ID,
Token))
5933 [[maybe_unused]]
const auto *Nothing =
5934 SubstTemplateTypeParmPackTypes.lookup(ID,
Token);
5939 auto *SubstParm =
new (*
this,
alignof(SubstTemplateTypeParmPackType))
5940 SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
5942 Types.push_back(SubstParm);
5943 SubstTemplateTypeParmPackTypes.insert(SubstParm,
Token);
5951 return P.getKind() == TemplateArgument::Type;
5953 "Pack contains a non-type");
5955 llvm::FoldingSetNodeID ID;
5956 SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
5958 llvm::FoldingSetInsertToken
Token;
5959 if (
auto *
T = SubstBuiltinTemplatePackTypes.lookup(ID,
Token))
5968 [[maybe_unused]]
const auto *Nothing =
5969 SubstBuiltinTemplatePackTypes.lookup(ID,
Token);
5973 auto *PackType =
new (*
this,
alignof(SubstBuiltinTemplatePackType))
5974 SubstBuiltinTemplatePackType(Canon, ArgPack);
5975 Types.push_back(PackType);
5976 SubstBuiltinTemplatePackTypes.insert(PackType,
Token);
5986 assert(Depth >= 0 &&
"Depth must be non-negative");
5987 assert(Index >= 0 &&
"Index must be non-negative");
5989 auto Key = std::make_tuple(
unsigned(Depth),
unsigned(Index),
5990 unsigned(ParameterPack), TTPDecl);
5991 llvm::FoldingSetInsertToken
Token;
5992 TemplateTypeParmType *TypeParm = TemplateTypeParmTypes.lookup(Key,
Token);
5999 TypeParm =
new (*
this,
alignof(TemplateTypeParmType))
6000 TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
6002 TypeParm =
new (*
this,
alignof(TemplateTypeParmType)) TemplateTypeParmType(
6003 Depth, Index, ParameterPack,
nullptr,
QualType());
6005 Types.push_back(TypeParm);
6006 TemplateTypeParmTypes.insert(TypeParm,
Token);
6032 llvm_unreachable(
"unexpected keyword kind");
6046 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
6056 SpecifiedArgVec.reserve(SpecifiedArgs.size());
6058 SpecifiedArgVec.push_back(Arg.getArgument());
6061 CanonicalArgs, Underlying);
6064[[maybe_unused]]
static bool
6067 if (Arg.isPackExpansion())
6078 Template.getAsDependentTemplateName()));
6080 for (
const auto &Arg : Args)
6084 llvm::FoldingSetNodeID ID;
6087 llvm::FoldingSetInsertToken
Token;
6088 if (
auto *
T = TemplateSpecializationTypes.lookup(ID,
Token))
6091 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6093 alignof(TemplateSpecializationType));
6097 assert(Spec->isDependentType() &&
6098 "canonical template specialization must be dependent");
6099 Types.push_back(Spec);
6100 TemplateSpecializationTypes.insert(Spec,
Token);
6108 const auto *TD =
Template.getAsTemplateDecl(
true);
6109 bool IsTypeAlias = TD && TD->isTypeAlias();
6110 if (Underlying.
isNull()) {
6117 bool NonCanonical =
Template != CanonTemplate ||
Keyword != CanonKeyword;
6119 if (CanonicalArgs.empty()) {
6122 CanonicalArgs = CanonArgsVec;
6124 NonCanonical |= !llvm::equal(
6125 SpecifiedArgs, CanonicalArgs,
6134 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
6136 "Caller must compute aliased type");
6137 IsTypeAlias =
false;
6140 CanonKeyword, CanonTemplate, CanonicalArgs);
6144 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6146 (IsTypeAlias ?
sizeof(
QualType) : 0),
6147 alignof(TemplateSpecializationType));
6148 auto *Spec =
new (Mem) TemplateSpecializationType(
6150 Types.push_back(Spec);
6156 llvm::FoldingSetInsertToken
Token;
6164 assert(!ParenTypes.lookup(InnerType,
Token) &&
6165 "Paren canonical type broken");
6170 ParenTypes.insert(
T,
Token);
6183 Types.push_back(newType);
6190 llvm::FoldingSetNodeID ID;
6191 DependentNameType::Profile(ID,
Keyword, NNS, Name);
6193 llvm::FoldingSetInsertToken
Token;
6194 if (DependentNameType *
T = DependentNameTypes.lookup(ID,
Token))
6202 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6204 [[maybe_unused]] DependentNameType *
T =
6205 DependentNameTypes.lookup(ID,
Token);
6206 assert(!
T &&
"broken canonicalization");
6210 DependentNameType *
T =
new (*
this,
alignof(DependentNameType))
6211 DependentNameType(
Keyword, NNS, Name, Canon);
6213 DependentNameTypes.insert(
T,
Token);
6219 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6221 if (TTP->isParameterPack())
6225 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6227 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6233 if (
T->isRecordType()) {
6242 Expr *E =
new (*this)
6244 T,
VK, NTTP->getLocation());
6246 if (NTTP->isParameterPack())
6252 std::nullopt,
false,
6254 if (TTP->isParameterPack())
6260 if (Param->isTemplateParameterPack())
6269 bool ExpectPackInType)
const {
6271 "Pack expansions must expand one or more parameter packs");
6275 llvm::FoldingSetInsertToken
Token;
6276 PackExpansionType *
T = PackExpansionTypes.lookup(Key,
Token);
6287 PackExpansionTypes.lookup(Key,
Token);
6290 T =
new (*
this,
alignof(PackExpansionType))
6291 PackExpansionType(Pattern, Canon, NumExpansions);
6293 PackExpansionTypes.insert(
T,
Token);
6305 if (Protocols.empty())
return true;
6310 for (
unsigned i = 1; i != Protocols.size(); ++i)
6320 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6324 P = P->getCanonicalDecl();
6327 auto ProtocolsEnd = llvm::unique(Protocols);
6328 Protocols.erase(ProtocolsEnd, Protocols.end());
6333 unsigned NumProtocols)
const {
6342 bool isKindOf)
const {
6345 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6350 llvm::FoldingSetNodeID ID;
6351 ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
6352 llvm::FoldingSetInsertToken
Token;
6360 if (effectiveTypeArgs.empty()) {
6362 effectiveTypeArgs = baseObject->getTypeArgs();
6369 bool typeArgsAreCanonical = llvm::all_of(
6372 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6376 if (!typeArgsAreCanonical) {
6377 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6378 for (
auto typeArg : effectiveTypeArgs)
6380 canonTypeArgs = canonTypeArgsVec;
6382 canonTypeArgs = effectiveTypeArgs;
6387 if (!protocolsSorted) {
6388 canonProtocolsVec.append(protocols.begin(), protocols.end());
6390 canonProtocols = canonProtocolsVec;
6392 canonProtocols = protocols;
6396 canonProtocols, isKindOf);
6399 ObjCObjectTypes.lookup(ID,
Token);
6402 unsigned size =
sizeof(ObjCObjectTypeImpl);
6403 size += typeArgs.size() *
sizeof(
QualType);
6405 void *mem =
Allocate(size,
alignof(ObjCObjectTypeImpl));
6407 new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
6411 ObjCObjectTypes.insert(
T,
Token);
6421 bool allowOnPointerType)
const {
6424 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6429 if (allowOnPointerType) {
6430 if (
const auto *objPtr =
6431 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6435 protocolsVec.append(objT->qual_begin(),
6437 protocolsVec.append(protocols.begin(), protocols.end());
6440 objT->getBaseType(),
6441 objT->getTypeArgsAsWritten(),
6443 objT->isKindOfTypeAsWritten());
6449 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6454 objT->getTypeArgsAsWritten(),
6456 objT->isKindOfTypeAsWritten());
6460 if (
type->isObjCObjectType()) {
6470 if (
type->isObjCIdType()) {
6473 objPtr->isKindOfType());
6478 if (
type->isObjCClassType()) {
6481 objPtr->isKindOfType());
6494 if (!protocols.empty()) {
6498 Canonical, protocols, hasError,
true ));
6499 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6504 auto Key = std::make_tuple(
Decl, Canonical, protocols);
6505 llvm::FoldingSetInsertToken
Token;
6506 if (ObjCTypeParamType *TypeParam = ObjCTypeParamTypes.lookup(Key,
Token))
6509 unsigned size =
sizeof(ObjCTypeParamType);
6511 void *mem =
Allocate(size,
alignof(ObjCTypeParamType));
6512 auto *newType =
new (mem) ObjCTypeParamType(
Decl, Canonical, protocols);
6514 Types.push_back(newType);
6515 ObjCTypeParamTypes.insert(newType,
Token);
6525 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6540 for (
auto *Proto : OPT->quals()) {
6563 if (InheritedProtocols.empty())
6567 bool Conforms =
false;
6568 for (
auto *Proto : OPT->quals()) {
6570 for (
auto *PI : InheritedProtocols) {
6582 for (
auto *PI : InheritedProtocols) {
6584 bool Adopts =
false;
6585 for (
auto *Proto : OPT->quals()) {
6599 llvm::FoldingSetInsertToken
Token;
6614 Types.push_back(QType);
6615 ObjCObjectPointerTypes.insert(QType,
Token);
6623 if (
Decl->TypeForDecl)
6627 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6628 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6629 return QualType(PrevDecl->TypeForDecl, 0);
6638 Decl->TypeForDecl =
T;
6651 llvm::FoldingSetNodeID ID;
6655 llvm::FoldingSetInsertToken
Token;
6666 DependentTypeOfExprTypes.insert(Canon,
Token);
6674 Types.push_back(toe);
6685 auto *tot =
new (*
this,
alignof(TypeOfType))
6686 TypeOfType(*
this, tofType, Canonical, Kind);
6687 Types.push_back(tot);
6711 llvm_unreachable(
"Unknown value kind");
6726 }
else if (!UnderlyingType.
isNull()) {
6729 llvm::FoldingSetNodeID ID;
6730 DependentDecltypeType::Profile(ID, *
this, E);
6732 llvm::FoldingSetInsertToken
Token;
6733 if (DependentDecltypeType *Canon = DependentDecltypeTypes.lookup(ID,
Token))
6738 new (*
this,
alignof(DependentDecltypeType)) DependentDecltypeType(E);
6739 DependentDecltypeTypes.insert(DT,
Token);
6740 Types.push_back(DT);
6743 auto *DT =
new (*
this,
alignof(DecltypeType))
6744 DecltypeType(E, UnderlyingType, CanonType);
6745 Types.push_back(DT);
6750 bool FullySubstituted,
6754 if (FullySubstituted && Index) {
6757 llvm::FoldingSetNodeID ID;
6758 PackIndexingType::Profile(ID, *
this, Pattern.
getCanonicalType(), IndexExpr,
6759 FullySubstituted, Expansions);
6760 llvm::FoldingSetInsertToken
Token;
6761 PackIndexingType *Canon = DependentPackIndexingTypes.lookup(ID,
Token);
6764 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6768 IndexExpr, FullySubstituted, Expansions);
6769 DependentPackIndexingTypes.insert(Canon,
Token);
6775 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6777 auto *
T =
new (Mem) PackIndexingType(Canonical, Pattern, IndexExpr,
6778 FullySubstituted, Expansions);
6787 UnaryTransformType::UTTKind Kind)
const {
6790 if (BaseType->isDependentType()) {
6791 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6795 auto Key = std::make_tuple(BaseType, UnderlyingType, Kind);
6797 llvm::FoldingSetInsertToken
Token;
6798 if (UnaryTransformType *UT = UnaryTransformTypes.lookup(Key,
Token))
6802 if (!BaseType->isDependentType()) {
6806 BaseType != CanonBase) {
6812 auto *UT =
new (*
this,
alignof(UnaryTransformType))
6813 UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
6814 UnaryTransformTypes.insert(UT,
Token);
6815 Types.push_back(UT);
6828 TypeConstraintConcept.
isNull()) {
6829 assert(DeducedAsType.
isNull() &&
"");
6830 assert(TypeConstraintArgs.empty() &&
"");
6835 llvm::FoldingSetNodeID ID;
6836 AutoType::Profile(ID, *
this, DK, DeducedAsType,
Keyword,
6837 TypeConstraintConcept, TypeConstraintArgs);
6838 if (
auto const AT_iter = AutoTypes.find_as(ID); AT_iter != AutoTypes.end())
6839 return QualType(AT_iter->getSecond(), 0);
6842 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6844 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6845 if (!TypeConstraintConcept.
isNull()) {
6846 bool AnyNonCanonArgs =
false;
6850 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6851 if (TypeConstraintConcept != CanonicalConcept || AnyNonCanonArgs)
6853 CanonicalConceptArgs);
6857 void *Mem =
Allocate(
sizeof(AutoType) +
6860 auto *AT =
new (Mem) AutoType(DK, DeducedAsType,
Keyword,
6861 TypeConstraintConcept, TypeConstraintArgs);
6863 llvm::FoldingSetNodeID InsertedID;
6864 AT->Profile(InsertedID, *
this);
6865 assert(InsertedID == ID &&
"ID does not match");
6867 Types.push_back(AT);
6868 AutoTypes.try_emplace(ID.Intern(BumpAlloc), AT);
6873 QualType CanonT =
T.getNonPackExpansionType().getCanonicalType();
6876 if (
auto *AT = CanonT->
getAs<AutoType>()) {
6877 if (!AT->isConstrained())
6899 llvm::FoldingSetInsertToken
Token;
6900 llvm::FoldingSetNodeID ID;
6901 DeducedTemplateSpecializationType::Profile(ID, DK, DeducedAsType,
Keyword,
6903 if (DeducedTemplateSpecializationType *DTST =
6904 DeducedTemplateSpecializationTypes.lookup(ID,
Token))
6908 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6910 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6919 [[maybe_unused]] DeducedTemplateSpecializationType *DTST =
6920 DeducedTemplateSpecializationTypes.lookup(ID,
Token);
6921 assert(!DTST &&
"broken canonicalization");
6925 auto *DTST =
new (*
this,
alignof(DeducedTemplateSpecializationType))
6926 DeducedTemplateSpecializationType(DK, DeducedAsType,
Keyword,
Template);
6929 llvm::FoldingSetNodeID TempID;
6930 DTST->Profile(TempID);
6931 assert(ID == TempID &&
"ID does not match");
6933 Types.push_back(DTST);
6934 DeducedTemplateSpecializationTypes.insert(DTST,
Token);
6943 llvm::FoldingSetInsertToken
Token;
6950 if (!
T.isCanonical()) {
6953 assert(!AtomicTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
6956 Types.push_back(
New);
6965 new (*
this,
alignof(AutoType))
6989 return getFromTargetType(Target->getSizeType());
7008 return getFromTargetType(Target->getUnsignedPtrDiffType(
LangAS::Default));
7013 return getFromTargetType(Target->getIntMaxType());
7018 return getFromTargetType(Target->getUIntMaxType());
7036 return getFromTargetType(Target->getIntPtrType());
7046 return getFromTargetType(Target->getProcessIDType());
7058 const Type *Ty =
T.getTypePtr();
7086 quals = splitType.
Quals;
7091 QualType elementType = AT->getElementType();
7096 if (elementType == unqualElementType) {
7097 assert(quals.
empty());
7098 quals = splitType.
Quals;
7106 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7108 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7111 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7115 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7117 VAT->getSizeModifier(),
7118 VAT->getIndexTypeCVRQualifiers());
7123 DSAT->getSizeModifier(), 0);
7133 bool AllowPiMismatch)
const {
7148 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7149 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7150 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7163 T1 = AT1->getElementType();
7164 T2 = AT2->getElementType();
7184 bool AllowPiMismatch)
const {
7189 if (T1PtrType && T2PtrType) {
7197 T1MPType && T2MPType) {
7200 if (T1MPType->getQualifier() != T2MPType->getQualifier())
7212 if (T1OPType && T2OPType) {
7244 if (Quals1 != Quals2)
7318 llvm_unreachable(
"bad template name kind!");
7324 if (!TP->hasDefaultArgument())
7326 return &TP->getDefaultArgument().getArgument();
7329 case NamedDecl::TemplateTypeParm:
7331 case NamedDecl::NonTypeTemplateParm:
7333 case NamedDecl::TemplateTemplateParm:
7336 llvm_unreachable(
"Unexpected template parameter kind");
7341 bool IgnoreDeduced)
const {
7342 while (std::optional<TemplateName> UnderlyingOrNone =
7344 Name = *UnderlyingOrNone;
7349 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7361 llvm_unreachable(
"cannot canonicalize overloaded template");
7365 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7394 assert(IgnoreDeduced ==
false);
7401 bool NonCanonical = CanonUnderlying != Underlying;
7407 assert(CanonArgs.size() <= Params.size());
7413 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7422 if (I ==
int(CanonArgs.size() - 1))
7423 CanonArgs.pop_back();
7424 NonCanonical =
true;
7434 llvm_unreachable(
"always sugar node");
7437 llvm_unreachable(
"bad template name!");
7442 bool IgnoreDeduced)
const {
7463 llvm::FoldingSetNodeID XCEID, YCEID;
7464 XCE->
Profile(XCEID, *
this,
true,
true);
7465 YCE->
Profile(YCEID, *
this,
true,
true);
7466 return XCEID == YCEID;
7515 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7517 if (TX->isParameterPack() != TY->isParameterPack())
7519 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7522 TY->getTypeConstraint());
7525 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7527 return TX->isParameterPack() == TY->isParameterPack() &&
7528 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7530 TY->getPlaceholderTypeConstraint());
7535 return TX->isParameterPack() == TY->isParameterPack() &&
7537 TY->getTemplateParameters());
7542 if (
X->size() != Y->
size())
7545 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7559 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7561 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7564 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7565 TTPY->getDefaultArgument().getArgument().getAsType());
7568 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7570 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7573 Expr *DefaultArgumentX =
7574 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7575 Expr *DefaultArgumentY =
7576 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7577 llvm::FoldingSetNodeID XID, YID;
7578 DefaultArgumentX->
Profile(XID, *
this,
true);
7579 DefaultArgumentY->
Profile(YID, *
this,
true);
7586 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7601 auto Kind =
X.getKind();
7609 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7612 NamespaceY->getNamespace()))
7617 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7618 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7627 llvm_unreachable(
"unhandled qualifier kind");
7633 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7635 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7647 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7651 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7652 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7653 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7656 if (!Cand1A || !Cand2A)
7662 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7663 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7667 if (Cand1ID != Cand2ID)
7701 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7702 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7704 TypedefY->getUnderlyingType());
7721 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7723 return (TagX->getTagKind() == TagY->getTagKind()) ||
7735 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7737 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7739 if (CtorX->getInheritedConstructor() &&
7740 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7741 CtorY->getInheritedConstructor().getConstructor()))
7745 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7750 if (FuncX->isMultiVersion()) {
7751 const auto *TAX = FuncX->getAttr<TargetAttr>();
7752 const auto *TAY = FuncY->getAttr<TargetAttr>();
7753 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7755 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7761 if ((FuncX->isMemberLikeConstrainedFriend() ||
7762 FuncY->isMemberLikeConstrainedFriend()) &&
7763 !FuncX->getLexicalDeclContext()->Equals(
7764 FuncY->getLexicalDeclContext())) {
7769 FuncY->getTrailingRequiresClause()))
7777 FD = FD->getCanonicalDecl();
7778 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7781 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7796 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7801 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7803 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7806 if (VarX->getType().isNull() || VarY->getType().isNull())
7809 if (
hasSameType(VarX->getType(), VarY->getType()))
7819 if (!VarXTy || !VarYTy)
7828 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7830 return NamespaceX->isInline() == NamespaceY->isInline();
7835 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7839 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7842 ConceptY->getConstraintExpr()))
7847 TemplateY->getTemplatedDecl()) &&
7849 TemplateY->getTemplateParameters());
7853 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7856 return hasSameType(FDX->getType(), FDY->getType());
7860 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7862 return IFDX->getAnonField()->getCanonicalDecl() ==
7863 IFDY->getAnonField()->getCanonicalDecl();
7872 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7879 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7882 UX->hasTypename() == UY->hasTypename() &&
7883 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7885 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7888 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7890 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7898 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
7900 UX->getInstantiatedFromUsingDecl(),
7905 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
7907 return NAX->getNamespace()->Equals(NAY->getNamespace());
7910 if (
const auto *UX = dyn_cast<UsingEnumDecl>(
X)) {
7961 bool AnyNonCanonArgs =
false;
7964 if (!AnyNonCanonArgs)
7974 llvm_unreachable(
"Unhandled template argument kind");
7984 llvm_unreachable(
"Comparing NULL template argument");
8009 llvm::FoldingSetNodeID ID1, ID2;
8019 return isSameTemplateArgument(Arg1, Arg2);
8023 llvm_unreachable(
"Unhandled template argument kind");
8028 if (!
T.hasLocalQualifiers()) {
8030 if (
const auto *AT = dyn_cast<ArrayType>(
T))
8050 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
8051 if (!ATy || qs.
empty())
8058 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
8061 CAT->getSizeModifier(),
8062 CAT->getIndexTypeCVRQualifiers()));
8063 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
8065 IAT->getSizeModifier(),
8066 IAT->getIndexTypeCVRQualifiers()));
8068 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
8070 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
8071 DSAT->getIndexTypeCVRQualifiers()));
8076 VAT->getIndexTypeCVRQualifiers()));
8084 if (
T->isArrayType() ||
T->isFunctionType())
8092 return T.getUnqualifiedType();
8103 if (
T->isArrayType() ||
T->isFunctionType())
8105 return T.getUnqualifiedType();
8120 assert(PrettyArrayType &&
"Not an array type!");
8154 uint64_t ElementCount = 1;
8157 CA = dyn_cast_if_present<ConstantArrayType>(
8160 return ElementCount;
8168 uint64_t ElementCount = 1;
8172 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8175 return ElementCount;
8185 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8187 case BuiltinType::Half:
return HalfRank;
8188 case BuiltinType::Float:
return FloatRank;
8221unsigned ASTContext::getIntegerRank(
const Type *
T)
const {
8222 assert(
T->isCanonicalUnqualified() &&
"T should be canonicalized");
8226 if (
const auto *EIT = dyn_cast<BitIntType>(
T))
8227 return 0 + (EIT->getNumBits() << 3);
8229 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(
T))
8230 return getIntegerRank(OBT->getUnderlyingType().getTypePtr());
8233 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8234 case BuiltinType::Bool:
8236 case BuiltinType::Char_S:
8237 case BuiltinType::Char_U:
8238 case BuiltinType::SChar:
8239 case BuiltinType::UChar:
8241 case BuiltinType::Short:
8242 case BuiltinType::UShort:
8244 case BuiltinType::Int:
8245 case BuiltinType::UInt:
8247 case BuiltinType::Long:
8248 case BuiltinType::ULong:
8250 case BuiltinType::LongLong:
8251 case BuiltinType::ULongLong:
8253 case BuiltinType::Int128:
8254 case BuiltinType::UInt128:
8259 case BuiltinType::Char8:
8261 case BuiltinType::Char16:
8262 return getIntegerRank(
8264 case BuiltinType::Char32:
8265 return getIntegerRank(
8267 case BuiltinType::WChar_S:
8268 case BuiltinType::WChar_U:
8269 return getIntegerRank(
8299 uint64_t BitWidth = Field->getBitWidthValue();
8325 if (BitWidth < IntSize)
8328 if (BitWidth == IntSize)
8343 assert(!Promotable.
isNull());
8346 return ED->getPromotionType();
8350 if (
const auto *OBT = Promotable->
getAs<OverflowBehaviorType>()) {
8363 if (BT->getKind() == BuiltinType::WChar_S ||
8364 BT->getKind() == BuiltinType::WChar_U ||
8365 BT->getKind() == BuiltinType::Char8 ||
8366 BT->getKind() == BuiltinType::Char16 ||
8367 BT->getKind() == BuiltinType::Char32) {
8368 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8372 for (
const auto &PT : PromoteTypes) {
8374 if (FromSize < ToSize ||
8375 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8378 llvm_unreachable(
"char type should fit into long long");
8385 uint64_t PromotableSize =
getIntWidth(Promotable);
8394 while (!
T.isNull()) {
8396 return T.getObjCLifetime();
8397 if (
T->isArrayType())
8400 T = PT->getPointeeType();
8402 T = RT->getPointeeType();
8427 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8429 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8432 if (LHSC == RHSC)
return 0;
8437 unsigned LHSRank = getIntegerRank(LHSC);
8438 unsigned RHSRank = getIntegerRank(RHSC);
8440 if (LHSUnsigned == RHSUnsigned) {
8441 if (LHSRank == RHSRank)
return 0;
8442 return LHSRank > RHSRank ? 1 : -1;
8448 if (LHSRank >= RHSRank)
8458 if (RHSRank >= LHSRank)
8468 if (CFConstantStringTypeDecl)
8469 return CFConstantStringTypeDecl;
8471 assert(!CFConstantStringTagDecl &&
8472 "tag and typedef should be initialized together");
8474 CFConstantStringTagDecl->startDefinition();
8512 if (
static_cast<unsigned>(CFRuntime) <
8515 Fields[Count++] = {
IntTy,
"flags" };
8517 Fields[Count++] = {
LongTy,
"length" };
8521 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()),
"_swift_rc" };
8525 Fields[Count++] = {
IntTy,
"_ptr" };
8531 for (
unsigned i = 0; i < Count; ++i) {
8535 Fields[i].Type,
nullptr,
8538 CFConstantStringTagDecl->addDecl(Field);
8541 CFConstantStringTagDecl->completeDefinition();
8545 CFConstantStringTypeDecl =
8548 return CFConstantStringTypeDecl;
8552 if (!CFConstantStringTagDecl)
8554 return CFConstantStringTagDecl;
8564 if (ObjCSuperType.isNull()) {
8569 return ObjCSuperType;
8575 CFConstantStringTagDecl = TT->castAsRecordDecl();
8579 if (BlockDescriptorType)
8592 static const char *
const FieldNames[] = {
8597 for (
size_t i = 0; i < 2; ++i) {
8600 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8608 BlockDescriptorType = RD;
8614 if (BlockDescriptorExtendedType)
8629 static const char *
const FieldNames[] = {
8636 for (
size_t i = 0; i < 4; ++i) {
8639 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8648 BlockDescriptorExtendedType = RD;
8653 const auto *BT = dyn_cast<BuiltinType>(
T);
8662 switch (BT->getKind()) {
8663#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8664 case BuiltinType::Id: \
8666#include "clang/Basic/OpenCLImageTypes.def"
8668 case BuiltinType::OCLClkEvent:
8671 case BuiltinType::OCLEvent:
8674 case BuiltinType::OCLQueue:
8677 case BuiltinType::OCLReserveID:
8680 case BuiltinType::OCLSampler:
8699 if (!copyExpr && record->hasTrivialDestructor())
return false;
8730 llvm_unreachable(
"impossible");
8732 llvm_unreachable(
"fell out of lifetime switch!");
8740 bool &HasByrefExtendedLayout)
const {
8745 HasByrefExtendedLayout =
false;
8747 HasByrefExtendedLayout =
true;
8761 assert(Target &&
"Expected target to be initialized");
8762 const llvm::Triple &
T = Target->getTriple();
8764 if (
T.isOSWindows() &&
T.isArch64Bit())
8770 assert(Target &&
"Expected target to be initialized");
8771 const llvm::Triple &
T = Target->getTriple();
8773 if (
T.isOSWindows() &&
T.isArch64Bit())
8779 if (!ObjCInstanceTypeDecl)
8780 ObjCInstanceTypeDecl =
8782 return ObjCInstanceTypeDecl;
8788 if (
const auto *TT = dyn_cast<TypedefType>(
T))
8790 return II->isStr(
"BOOL");
8798 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8807 else if (
type->isArrayType())
8826 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8833 !D->isInlineSpecified() && (D->isConstexpr() ||
First->isConstexpr()))
8864 for (
auto *PI :
Decl->parameters()) {
8869 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8878 ParmOffset = PtrSize;
8879 for (
auto *PVDecl :
Decl->parameters()) {
8880 QualType PType = PVDecl->getOriginalType();
8881 if (
const auto *AT =
8886 PType = PVDecl->getType();
8888 PType = PVDecl->getType();
8908 for (
auto *PI :
Decl->parameters()) {
8915 "getObjCEncodingForFunctionDecl - Incomplete param type");
8922 for (
auto *PVDecl :
Decl->parameters()) {
8923 QualType PType = PVDecl->getOriginalType();
8924 if (
const auto *AT =
8929 PType = PVDecl->getType();
8931 PType = PVDecl->getType();
8945 bool Extended)
const {
8949 ObjCEncOptions Options = ObjCEncOptions()
8950 .setExpandPointedToStructures()
8951 .setExpandStructures()
8952 .setIsOutermostType();
8954 Options.setEncodeBlockParameters().setEncodeClassNames();
8955 getObjCEncodingForTypeImpl(
T, S, Options,
nullptr);
8961 bool Extended)
const {
8966 Decl->getReturnType(), S, Extended);
8975 E =
Decl->sel_param_end(); PI != E; ++PI) {
8982 "getObjCEncodingForMethodDecl - Incomplete param type");
8990 ParmOffset = 2 * PtrSize;
8992 E =
Decl->sel_param_end(); PI != E; ++PI) {
8995 if (
const auto *AT =
9004 PType, S, Extended);
9015 const Decl *Container)
const {
9018 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
9019 for (
auto *PID : CID->property_impls())
9020 if (PID->getPropertyDecl() == PD)
9024 for (
auto *PID : OID->property_impls())
9025 if (PID->getPropertyDecl() == PD)
9059 const Decl *Container)
const {
9061 bool Dynamic =
false;
9069 SynthesizePID = PropertyImpDecl;
9073 std::string S =
"T";
9118 if (SynthesizePID) {
9135 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9138 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9151 getObjCEncodingForTypeImpl(
T, S,
9153 .setExpandPointedToStructures()
9154 .setExpandStructures()
9155 .setIsOutermostType(),
9156 Field, NotEncodedT);
9160 std::string& S)
const {
9164 getObjCEncodingForTypeImpl(
T, S,
9166 .setExpandPointedToStructures()
9167 .setExpandStructures()
9168 .setIsOutermostType()
9169 .setEncodingProperty(),
9177 case BuiltinType::Void:
return 'v';
9178 case BuiltinType::Bool:
return 'B';
9179 case BuiltinType::Char8:
9180 case BuiltinType::Char_U:
9181 case BuiltinType::UChar:
return 'C';
9182 case BuiltinType::Char16:
9183 case BuiltinType::UShort:
return 'S';
9184 case BuiltinType::Char32:
9185 case BuiltinType::UInt:
return 'I';
9186 case BuiltinType::ULong:
9187 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9188 case BuiltinType::UInt128:
return 'T';
9189 case BuiltinType::ULongLong:
return 'Q';
9190 case BuiltinType::Char_S:
9191 case BuiltinType::SChar:
return 'c';
9192 case BuiltinType::Short:
return 's';
9193 case BuiltinType::WChar_S:
9194 case BuiltinType::WChar_U:
9195 case BuiltinType::Int:
return 'i';
9196 case BuiltinType::Long:
9197 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9198 case BuiltinType::LongLong:
return 'q';
9199 case BuiltinType::Int128:
return 't';
9200 case BuiltinType::Float:
return 'f';
9201 case BuiltinType::Double:
return 'd';
9202 case BuiltinType::LongDouble:
return 'D';
9203 case BuiltinType::NullPtr:
return '*';
9205 case BuiltinType::BFloat16:
9206 case BuiltinType::Float16:
9207 case BuiltinType::Float128:
9208 case BuiltinType::Ibm128:
9209 case BuiltinType::Half:
9210 case BuiltinType::ShortAccum:
9211 case BuiltinType::Accum:
9212 case BuiltinType::LongAccum:
9213 case BuiltinType::UShortAccum:
9214 case BuiltinType::UAccum:
9215 case BuiltinType::ULongAccum:
9216 case BuiltinType::ShortFract:
9217 case BuiltinType::Fract:
9218 case BuiltinType::LongFract:
9219 case BuiltinType::UShortFract:
9220 case BuiltinType::UFract:
9221 case BuiltinType::ULongFract:
9222 case BuiltinType::SatShortAccum:
9223 case BuiltinType::SatAccum:
9224 case BuiltinType::SatLongAccum:
9225 case BuiltinType::SatUShortAccum:
9226 case BuiltinType::SatUAccum:
9227 case BuiltinType::SatULongAccum:
9228 case BuiltinType::SatShortFract:
9229 case BuiltinType::SatFract:
9230 case BuiltinType::SatLongFract:
9231 case BuiltinType::SatUShortFract:
9232 case BuiltinType::SatUFract:
9233 case BuiltinType::SatULongFract:
9237#define SVE_TYPE(Name, Id, SingletonId) \
9238 case BuiltinType::Id:
9239#include "clang/Basic/AArch64ACLETypes.def"
9240#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9241#include "clang/Basic/RISCVVTypes.def"
9242#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9243#include "clang/Basic/WebAssemblyReferenceTypes.def"
9244#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9245#include "clang/Basic/AMDGPUTypes.def"
9246#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9247#include "clang/Basic/SPIRVTypes.def"
9250 Diags.
Report(diag::err_unsupported_objc_primitive_encoding)
9255 case BuiltinType::ObjCId:
9256 case BuiltinType::ObjCClass:
9257 case BuiltinType::ObjCSel:
9258 llvm_unreachable(
"@encoding ObjC primitive type");
9261#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9262 case BuiltinType::Id:
9263#include "clang/Basic/OpenCLImageTypes.def"
9264#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9265 case BuiltinType::Id:
9266#include "clang/Basic/OpenCLExtensionTypes.def"
9267 case BuiltinType::OCLEvent:
9268 case BuiltinType::OCLClkEvent:
9269 case BuiltinType::OCLQueue:
9270 case BuiltinType::OCLReserveID:
9271 case BuiltinType::OCLSampler:
9272 case BuiltinType::Dependent:
9273#define PPC_VECTOR_TYPE(Name, Id, Size) \
9274 case BuiltinType::Id:
9275#include "clang/Basic/PPCTypes.def"
9276#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9277#include "clang/Basic/HLSLIntangibleTypes.def"
9278#define BUILTIN_TYPE(KIND, ID)
9279#define PLACEHOLDER_TYPE(KIND, ID) \
9280 case BuiltinType::KIND:
9281#include "clang/AST/BuiltinTypes.def"
9282 llvm_unreachable(
"invalid builtin type for @encode");
9284 llvm_unreachable(
"invalid BuiltinType::Kind value");
9291 if (!
Enum->isFixed())
9301 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9321 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9329 S += llvm::utostr(Offset);
9331 if (
const auto *ET =
T->getAsCanonical<EnumType>())
9344 bool VisitBasesAndFields) {
9345 T =
T->getBaseElementTypeUnsafe();
9349 PT->getPointeeType().getTypePtr(),
false);
9351 auto *CXXRD =
T->getAsCXXRecordDecl();
9359 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9362 for (
const auto &B : CXXRD->bases())
9367 for (
auto *FD : CXXRD->fields())
9376void ASTContext::getObjCEncodingForTypeImpl(QualType
T, std::string &S,
9377 const ObjCEncOptions Options,
9378 const FieldDecl *FD,
9379 QualType *NotEncodedT)
const {
9381 switch (CT->getTypeClass()) {
9386 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9394 getObjCEncodingForTypeImpl(
T->
castAs<ComplexType>()->getElementType(), S,
9401 getObjCEncodingForTypeImpl(
T->
castAs<AtomicType>()->getValueType(), S,
9408 case Type::LValueReference:
9409 case Type::RValueReference: {
9412 const auto *PT =
T->
castAs<PointerType>();
9413 if (PT->isObjCSelType()) {
9422 bool isReadOnly =
false;
9427 if (
T->
getAs<TypedefType>()) {
9428 if (Options.IsOutermostType() &&
T.isConstQualified()) {
9432 }
else if (Options.IsOutermostType()) {
9433 QualType P = PointeeTy;
9434 while (
auto PT = P->
getAs<PointerType>())
9445 if (StringRef(S).ends_with(
"nr"))
9446 S.replace(S.end()-2, S.end(),
"rn");
9456 }
else if (
const auto *RTy = PointeeTy->
getAsCanonical<RecordType>()) {
9457 const IdentifierInfo *II = RTy->getDecl()->getIdentifier();
9459 if (II == &
Idents.get(
"objc_class")) {
9464 if (II == &
Idents.get(
"objc_object")) {
9473 RTy, Options.ExpandPointedToStructures()))) {
9482 ObjCEncOptions NewOptions;
9483 if (Options.ExpandPointedToStructures())
9484 NewOptions.setExpandStructures();
9485 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9486 nullptr, NotEncodedT);
9490 case Type::ConstantArray:
9491 case Type::IncompleteArray:
9492 case Type::VariableArray: {
9499 getObjCEncodingForTypeImpl(
9500 AT->getElementType(), S,
9501 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9505 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9506 S += llvm::utostr(CAT->getZExtSize());
9510 "Unknown array type!");
9514 getObjCEncodingForTypeImpl(
9515 AT->getElementType(), S,
9516 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9523 case Type::FunctionNoProto:
9524 case Type::FunctionProto:
9528 case Type::Record: {
9530 S += RDecl->
isUnion() ?
'(' :
'{';
9534 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9535 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
9536 llvm::raw_string_ostream
OS(S);
9537 printTemplateArgumentList(OS, TemplateArgs.
asArray(),
9543 if (Options.ExpandStructures()) {
9546 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9548 for (
const auto *Field : RDecl->
fields()) {
9551 S +=
Field->getNameAsString();
9556 if (
Field->isBitField()) {
9557 getObjCEncodingForTypeImpl(
Field->getType(), S,
9558 ObjCEncOptions().setExpandStructures(),
9561 QualType qt =
Field->getType();
9563 getObjCEncodingForTypeImpl(
9565 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9571 S += RDecl->
isUnion() ?
')' :
'}';
9575 case Type::BlockPointer: {
9576 const auto *BT =
T->
castAs<BlockPointerType>();
9578 if (Options.EncodeBlockParameters()) {
9579 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
9583 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9584 Options.forComponentType(), FD, NotEncodedT);
9588 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9589 for (
const auto &I : FPT->param_types())
9590 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9598 case Type::ObjCObject: {
9602 S +=
"{objc_object=}";
9606 S +=
"{objc_class=}";
9613 case Type::ObjCInterface: {
9616 ObjCInterfaceDecl *OI =
T->
castAs<ObjCObjectType>()->getInterface();
9619 if (Options.ExpandStructures()) {
9621 SmallVector<const ObjCIvarDecl*, 32> Ivars;
9623 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9624 const FieldDecl *
Field = Ivars[i];
9625 if (
Field->isBitField())
9626 getObjCEncodingForTypeImpl(
Field->getType(), S,
9627 ObjCEncOptions().setExpandStructures(),
9630 getObjCEncodingForTypeImpl(
Field->getType(), S,
9631 ObjCEncOptions().setExpandStructures(), FD,
9639 case Type::ObjCObjectPointer: {
9640 const auto *OPT =
T->
castAs<ObjCObjectPointerType>();
9641 if (OPT->isObjCIdType()) {
9646 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9654 if (OPT->isObjCQualifiedIdType()) {
9655 getObjCEncodingForTypeImpl(
9657 Options.keepingOnly(ObjCEncOptions()
9658 .setExpandPointedToStructures()
9659 .setExpandStructures()),
9661 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9665 for (
const auto *I : OPT->quals()) {
9667 S += I->getObjCRuntimeNameAsString();
9676 if (OPT->getInterfaceDecl() &&
9677 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9679 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9680 for (
const auto *I : OPT->quals()) {
9682 S += I->getObjCRuntimeNameAsString();
9692 case Type::MemberPointer:
9696 case Type::ExtVector:
9702 case Type::ConstantMatrix:
9715 case Type::DeducedTemplateSpecialization:
9718 case Type::HLSLAttributedResource:
9719 case Type::HLSLInlineSpirv:
9720 case Type::OverflowBehavior:
9721 llvm_unreachable(
"unexpected type");
9723 case Type::ArrayParameter:
9725#define ABSTRACT_TYPE(KIND, BASE)
9726#define TYPE(KIND, BASE)
9727#define DEPENDENT_TYPE(KIND, BASE) \
9729#define NON_CANONICAL_TYPE(KIND, BASE) \
9731#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9733#include "clang/AST/TypeNodes.inc"
9734 llvm_unreachable(
"@encode for dependent type!");
9736 llvm_unreachable(
"bad type kind!");
9739void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
9741 const FieldDecl *FD,
9743 QualType *NotEncodedT)
const {
9744 assert(RDecl &&
"Expected non-null RecordDecl");
9745 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9749 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9750 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9754 for (
const auto &BI : CXXRec->bases()) {
9755 if (!BI.isVirtual()) {
9760 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9761 std::make_pair(offs, base));
9766 for (FieldDecl *Field : RDecl->
fields()) {
9767 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9770 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9771 std::make_pair(offs, Field));
9774 if (CXXRec && includeVBases) {
9775 for (
const auto &BI : CXXRec->vbases()) {
9781 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9782 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9783 std::make_pair(offs, base));
9797 std::multimap<uint64_t, NamedDecl *>::iterator
9798 CurLayObj = FieldOrBaseOffsets.begin();
9800 if (CXXRec && CXXRec->isDynamicClass() &&
9801 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9804 std::string recname = CXXRec->getNameAsString();
9805 if (recname.empty()) recname =
"?";
9818 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9819 std::make_pair(offs,
nullptr));
9822 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9824 assert(CurOffs <= CurLayObj->first);
9825 if (CurOffs < CurLayObj->first) {
9826 uint64_t padding = CurLayObj->first - CurOffs;
9838 NamedDecl *dcl = CurLayObj->second;
9842 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9847 getObjCEncodingForStructureImpl(base, S, FD,
false,
9857 S += field->getNameAsString();
9861 if (field->isBitField()) {
9864 CurOffs += field->getBitWidthValue();
9867 QualType qt = field->getType();
9869 getObjCEncodingForTypeImpl(
9870 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9881 std::string& S)
const {
9914 if (!ObjCClassDecl) {
9919 return ObjCClassDecl;
9923 if (!ObjCProtocolClassDecl) {
9924 ObjCProtocolClassDecl
9933 return ObjCProtocolClassDecl;
9954 QualType T = Context->getPointerType(Context->CharTy);
9955 return Context->buildImplicitTypedef(
T, Name);
9964 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 2);
9965 QualType T = Context->getPointerType(Context->CharTy);
9968 return Context->buildImplicitTypedef(
ArrayType,
"__builtin_zos_va_list");
9977 QualType T = Context->getPointerType(Context->VoidTy);
9978 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
9985 if (Context->getLangOpts().CPlusPlus) {
9990 &Context->Idents.get(
"std"),
9998 const size_t NumFields = 5;
10000 const char *FieldNames[NumFields];
10003 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10004 FieldNames[0] =
"__stack";
10007 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10008 FieldNames[1] =
"__gr_top";
10011 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10012 FieldNames[2] =
"__vr_top";
10015 FieldTypes[3] = Context->IntTy;
10016 FieldNames[3] =
"__gr_offs";
10019 FieldTypes[4] = Context->IntTy;
10020 FieldNames[4] =
"__vr_offs";
10023 for (
unsigned i = 0; i < NumFields; ++i) {
10028 &Context->Idents.get(FieldNames[i]),
10029 FieldTypes[i],
nullptr,
10041 return Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10048 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10051 const size_t NumFields = 5;
10053 const char *FieldNames[NumFields];
10056 FieldTypes[0] = Context->UnsignedCharTy;
10057 FieldNames[0] =
"gpr";
10060 FieldTypes[1] = Context->UnsignedCharTy;
10061 FieldNames[1] =
"fpr";
10064 FieldTypes[2] = Context->UnsignedShortTy;
10065 FieldNames[2] =
"reserved";
10068 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10069 FieldNames[3] =
"overflow_arg_area";
10072 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
10073 FieldNames[4] =
"reg_save_area";
10076 for (
unsigned i = 0; i < NumFields; ++i) {
10080 &Context->Idents.get(FieldNames[i]),
10081 FieldTypes[i],
nullptr,
10094 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10098 std::nullopt, VaListTagTypedefDecl);
10101 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10102 QualType VaListTagArrayType = Context->getConstantArrayType(
10104 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10107static TypedefDecl *
10111 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10114 const size_t NumFields = 4;
10116 const char *FieldNames[NumFields];
10119 FieldTypes[0] = Context->UnsignedIntTy;
10120 FieldNames[0] =
"gp_offset";
10123 FieldTypes[1] = Context->UnsignedIntTy;
10124 FieldNames[1] =
"fp_offset";
10127 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10128 FieldNames[2] =
"overflow_arg_area";
10131 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10132 FieldNames[3] =
"reg_save_area";
10135 for (
unsigned i = 0; i < NumFields; ++i) {
10140 &Context->Idents.get(FieldNames[i]),
10141 FieldTypes[i],
nullptr,
10155 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10156 QualType VaListTagArrayType = Context->getConstantArrayType(
10158 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10161static TypedefDecl *
10164 RecordDecl *VaListDecl = Context->buildImplicitRecord(
"__va_list");
10165 if (Context->getLangOpts().CPlusPlus) {
10184 &Context->Idents.get(
"__ap"),
10185 Context->getPointerType(Context->VoidTy),
10195 Context->VaListTagDecl = VaListDecl;
10198 CanQualType T = Context->getCanonicalTagType(VaListDecl);
10199 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10202static TypedefDecl *
10206 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10209 const size_t NumFields = 4;
10211 const char *FieldNames[NumFields];
10214 FieldTypes[0] = Context->LongTy;
10215 FieldNames[0] =
"__gpr";
10218 FieldTypes[1] = Context->LongTy;
10219 FieldNames[1] =
"__fpr";
10222 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10223 FieldNames[2] =
"__overflow_arg_area";
10226 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10227 FieldNames[3] =
"__reg_save_area";
10230 for (
unsigned i = 0; i < NumFields; ++i) {
10235 &Context->Idents.get(FieldNames[i]),
10236 FieldTypes[i],
nullptr,
10250 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10251 QualType VaListTagArrayType = Context->getConstantArrayType(
10254 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10260 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10263 const size_t NumFields = 3;
10265 const char *FieldNames[NumFields];
10268 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10269 FieldNames[0] =
"__current_saved_reg_area_pointer";
10272 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10273 FieldNames[1] =
"__saved_reg_area_end_pointer";
10276 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10277 FieldNames[2] =
"__overflow_area_pointer";
10280 for (
unsigned i = 0; i < NumFields; ++i) {
10283 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
10296 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10300 std::nullopt, VaListTagTypedefDecl);
10303 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10304 QualType VaListTagArrayType = Context->getConstantArrayType(
10307 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10310static TypedefDecl *
10320 constexpr size_t NumFields = 3;
10321 QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
10322 Context->getPointerType(Context->IntTy),
10324 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10327 for (
unsigned i = 0; i < NumFields; ++i) {
10330 &Context->Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
10342 Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10344 return VaListTagTypedefDecl;
10370 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10374 if (!BuiltinVaListDecl) {
10375 BuiltinVaListDecl =
CreateVaListDecl(
this, Target->getBuiltinVaListKind());
10376 assert(BuiltinVaListDecl->isImplicit());
10379 return BuiltinVaListDecl;
10392 if (!BuiltinMSVaListDecl)
10395 return BuiltinMSVaListDecl;
10399 if (!BuiltinZOSVaListDecl)
10402 return BuiltinZOSVaListDecl;
10419 assert(ObjCConstantStringType.isNull() &&
10420 "'NSConstantString' type already set!");
10430 unsigned size = End - Begin;
10431 assert(size > 1 &&
"set is not overloaded!");
10437 NamedDecl **Storage = OT->getStorage();
10460 bool TemplateKeyword,
10465 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10466 assert(!Qualifier &&
"unexpected qualified template template parameter");
10467 assert(TemplateKeyword ==
false);
10472 llvm::FoldingSetNodeID ID;
10475 llvm::FoldingSetInsertToken
Token;
10480 QualifiedTemplateNames.insert(QTN,
Token);
10490 llvm::FoldingSetNodeID ID;
10493 llvm::FoldingSetInsertToken
Token;
10499 DependentTemplateNames.insert(QTN,
Token);
10504 Decl *AssociatedDecl,
10507 bool Final)
const {
10508 llvm::FoldingSetNodeID ID;
10512 llvm::FoldingSetInsertToken
Token;
10514 SubstTemplateTemplateParms.lookup(ID,
Token);
10518 Replacement, AssociatedDecl, Index,
PackIndex, Final);
10519 SubstTemplateTemplateParms.insert(subst,
Token);
10527 Decl *AssociatedDecl,
10528 unsigned Index,
bool Final)
const {
10530 llvm::FoldingSetNodeID ID;
10532 AssociatedDecl, Index, Final);
10534 llvm::FoldingSetInsertToken
Token;
10536 SubstTemplateTemplateParmPacks.lookup(ID,
Token);
10541 SubstTemplateTemplateParmPacks.insert(Subst,
Token);
10555 llvm::FoldingSetNodeID ID;
10558 llvm::FoldingSetInsertToken
Token;
10565 DeducedTemplates.insert(DTS,
Token);
10574 llvm::FoldingSetNodeID ID;
10576 FullySubstituted, Expansions);
10578 llvm::FoldingSetInsertToken
Token;
10582 Allocate(PackIndexingTemplateStorage::totalSizeToAlloc<TemplateName>(
10583 Expansions.size()),
10586 FullySubstituted, Expansions);
10587 PackIndexingTemplates.insert(PI,
Token);
10610 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10640 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10641 CT = AT->getElementType();
10673 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10674 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10731 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
10732 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
10734 if (!LHSOBT && !RHSOBT)
10737 if (LHSOBT && RHSOBT) {
10738 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
10743 QualType LHSUnderlying = LHSOBT ? LHSOBT->desugar() : LHS;
10744 QualType RHSUnderlying = RHSOBT ? RHSOBT->desugar() : RHS;
10746 if (RHSOBT && !LHSOBT) {
10757 auto VScale = Context.getTargetInfo().getVScaleRange(
10764 uint64_t EltSize = Context.getTypeSize(Info.
ElementType);
10768 uint64_t MinElts = Info.
EC.getKnownMinValue();
10769 return VScale->first * MinElts * EltSize;
10777 "Expected RVV builtin type and vector type!");
10817 return IsValidCast(FirstType, SecondType) ||
10818 IsValidCast(SecondType, FirstType);
10826 "Expected RVV builtin type and vector type!");
10833 if (!BT->isRVVVLSBuiltinType())
10853 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10860 return IsLaxCompatible(FirstType, SecondType) ||
10861 IsLaxCompatible(SecondType, FirstType);
10867 if (
const AttributedType *
Attr = dyn_cast<AttributedType>(Ty)) {
10868 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10871 Ty =
Attr->getModifiedType();
10875 Ty =
Paren->getInnerType();
10907 for (
auto *lhsProto : lhs->
quals()) {
10908 bool match =
false;
10909 for (
auto *rhsProto : rhs->
quals()) {
10940 for (
auto *I : lhs->
quals()) {
10944 if (!rhsID->ClassImplementsProtocol(I,
true))
10952 for (
auto *lhsProto : lhs->
quals()) {
10953 bool match =
false;
10958 for (
auto *rhsProto : rhs->
quals()) {
10968 for (
auto *I : lhs->
quals()) {
10972 if (rhsID->ClassImplementsProtocol(I,
true)) {
10989 for (
auto *lhsProto : lhs->
quals()) {
10990 bool match =
false;
10997 for (
auto *rhsProto : rhs->
quals()) {
11016 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
11018 for (
auto *lhsProto : LHSInheritedProtocols) {
11019 bool match =
false;
11020 for (
auto *rhsProto : rhs->
quals()) {
11045 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
11050 auto finish = [&](
bool succeeded) ->
bool {
11054 if (!RHS->isKindOfType())
11065 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
11070 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
11075 if (LHS->isObjCClass() && RHS->isObjCClass()) {
11080 if (LHS->getInterface() && RHS->getInterface()) {
11095 bool BlockReturnType) {
11099 auto finish = [&](
bool succeeded) ->
bool {
11124 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
11128 (!BlockReturnType &&
11132 (BlockReturnType ? LHSOPT : RHSOPT),
11133 (BlockReturnType ? RHSOPT : LHSOPT),
false));
11141 return finish(BlockReturnType);
11143 return finish(!BlockReturnType);
11155 return (*lhs)->getName().compare((*rhs)->getName());
11172 assert(LHS->getInterface() &&
"LHS must have an interface base");
11173 assert(RHS->getInterface() &&
"RHS must have an interface base");
11179 for (
auto *proto : LHS->quals()) {
11180 Context.CollectInheritedProtocols(proto, LHSProtocolSet);
11184 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
11190 for (
auto *proto : RHS->quals()) {
11191 Context.CollectInheritedProtocols(proto, RHSProtocolSet);
11195 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
11198 for (
auto *proto : LHSProtocolSet) {
11199 if (RHSProtocolSet.count(proto))
11200 IntersectionSet.push_back(proto);
11206 Context.CollectInheritedProtocols(CommonBase, ImpliedProtocols);
11209 if (!ImpliedProtocols.empty()) {
11211 return ImpliedProtocols.contains(proto);
11216 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11226 if (lhsOPT && rhsOPT)
11232 if (lhsBlock && rhsBlock)
11237 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11249 bool stripKindOf) {
11250 if (lhsArgs.size() != rhsArgs.size())
11257 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11263 if (!stripKindOf ||
11264 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11265 rhsArgs[i].stripObjCKindOfType(ctx))) {
11293 if (!LDecl || !RDecl)
11299 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
11303 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11308 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
11313 bool anyChanges =
false;
11314 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11317 LHS->getTypeArgs(), RHS->getTypeArgs(),
11320 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11331 if (!Protocols.empty())
11337 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
11340 anyKindOf || LHS->isKindOfType());
11348 QualType LHSSuperType = LHS->getSuperClassType();
11349 if (LHSSuperType.
isNull())
11358 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
11359 if (KnownLHS != LHSAncestors.end()) {
11360 LHS = KnownLHS->second;
11364 bool anyChanges =
false;
11365 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11368 LHS->getTypeArgs(), RHS->getTypeArgs(),
11371 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11382 if (!Protocols.empty())
11387 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
11390 anyKindOf || RHS->isKindOfType());
11398 QualType RHSSuperType = RHS->getSuperClassType();
11399 if (RHSSuperType.
isNull())
11410 assert(LHS->getInterface() &&
"LHS is not an interface type");
11411 assert(RHS->getInterface() &&
"RHS is not an interface type");
11416 bool IsSuperClass = LHSInterface->
isSuperClassOf(RHS->getInterface());
11423 if (LHS->getNumProtocols() > 0) {
11432 for (
auto *RHSPI : RHS->quals())
11435 if (SuperClassInheritedProtocols.empty())
11438 for (
const auto *LHSProto : LHS->quals()) {
11439 bool SuperImplementsProtocol =
false;
11440 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11441 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11442 SuperImplementsProtocol =
true;
11445 if (!SuperImplementsProtocol)
11451 if (LHS->isSpecialized()) {
11456 RHSSuper = RHSSuper->getSuperClassType()->castAs<
ObjCObjectType>();
11459 if (RHSSuper->isSpecialized() &&
11461 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
11475 if (!LHSOPT || !RHSOPT)
11493 bool CompareUnqualified) {
11512 bool OfBlockPointer,
11514 if (
const RecordType *UT =
T->getAsUnionType()) {
11516 if (UD->
hasAttr<TransparentUnionAttr>()) {
11517 for (
const auto *I : UD->
fields()) {
11518 QualType ET = I->getType().getUnqualifiedType();
11532 bool OfBlockPointer,
11553 bool IsConditionalOperator) {
11556 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11557 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11558 bool allLTypes =
true;
11559 bool allRTypes =
true;
11563 if (OfBlockPointer) {
11565 QualType LHS = lbase->getReturnType();
11567 if (!UnqualifiedResult)
11569 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11634 bool NoReturn = IsConditionalOperator
11644 std::optional<FunctionEffectSet> MergedFX;
11646 if (lproto && rproto) {
11647 assert((AllowCXX ||
11648 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11649 "C++ shouldn't be here");
11651 if (lproto->getNumParams() != rproto->getNumParams())
11655 if (lproto->isVariadic() != rproto->isVariadic())
11658 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11662 if (lproto->getExtraAttributeInfo().CFISalt !=
11663 rproto->getExtraAttributeInfo().CFISalt)
11669 if (LHSFX != RHSFX) {
11670 if (IsConditionalOperator)
11679 if (*MergedFX != LHSFX)
11681 if (*MergedFX != RHSFX)
11686 bool canUseLeft, canUseRight;
11698 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11699 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11700 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11702 lParamType, rParamType, OfBlockPointer,
Unqualified);
11709 types.push_back(paramType);
11721 if (allLTypes)
return lhs;
11722 if (allRTypes)
return rhs;
11727 newParamInfos.empty() ?
nullptr : newParamInfos.data();
11733 if (lproto) allRTypes =
false;
11734 if (rproto) allLTypes =
false;
11738 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11746 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11752 paramTy = ED->getIntegerType();
11762 if (allLTypes)
return lhs;
11763 if (allRTypes)
return rhs;
11772 if (allLTypes)
return lhs;
11773 if (allRTypes)
return rhs;
11779 QualType other,
bool isBlockReturnType) {
11785 ET->getDecl()->getDefinitionOrSelf()->getIntegerType();
11786 if (underlyingType.
isNull())
11788 if (Context.hasSameType(underlyingType, other))
11794 Context.getTypeSize(underlyingType) == Context.getTypeSize(other))
11803 if (LangOpts.CPlusPlus || !LangOpts.C23)
11824 bool BlockReturnType,
bool IsConditionalOperator) {
11825 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
11826 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
11828 if (!LHSOBT && !RHSOBT)
11829 return std::nullopt;
11833 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
11837 LHSOBT->getUnderlyingType(), RHSOBT->getUnderlyingType(),
11838 OfBlockPointer,
Unqualified, BlockReturnType, IsConditionalOperator);
11840 if (MergedUnderlying.
isNull())
11844 if (LHSOBT->getUnderlyingType() == RHSOBT->getUnderlyingType())
11847 LHSOBT->getBehaviorKind(),
11856 return mergeTypes(LHSOBT->getUnderlyingType(), RHS, OfBlockPointer,
11857 Unqualified, BlockReturnType, IsConditionalOperator);
11860 return mergeTypes(LHS, RHSOBT->getUnderlyingType(), OfBlockPointer,
11861 Unqualified, BlockReturnType, IsConditionalOperator);
11866 bool IsConditionalOperator) {
11877 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11881 if (LHSRefTy || RHSRefTy)
11884 if (std::optional<QualType> MergedOBT =
11886 BlockReturnType, IsConditionalOperator))
11898 if (LHSCan == RHSCan)
11903 Qualifiers RQuals = RHSCan.getLocalQualifiers();
11904 if (LQuals != RQuals) {
11921 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
11942 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
11943 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
11946 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
11947 LHSClass = Type::ConstantArray;
11948 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
11949 RHSClass = Type::ConstantArray;
11952 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
11953 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
11956 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
11957 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
11960 if (LHSClass != RHSClass) {
11970 if (OfBlockPointer && !BlockReturnType) {
11978 if (
const auto *AT = LHS->
getAs<AutoType>()) {
11979 if (!AT->isDeduced() && AT->isGNUAutoType())
11982 if (
const auto *AT = RHS->
getAs<AutoType>()) {
11983 if (!AT->isDeduced() && AT->isGNUAutoType())
11990 switch (LHSClass) {
11991#define TYPE(Class, Base)
11992#define ABSTRACT_TYPE(Class, Base)
11993#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
11994#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
11995#define DEPENDENT_TYPE(Class, Base) case Type::Class:
11996#include "clang/AST/TypeNodes.inc"
11997 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
12000 case Type::DeducedTemplateSpecialization:
12001 case Type::LValueReference:
12002 case Type::RValueReference:
12003 case Type::MemberPointer:
12004 llvm_unreachable(
"C++ should never be in mergeTypes");
12006 case Type::ObjCInterface:
12007 case Type::IncompleteArray:
12008 case Type::VariableArray:
12009 case Type::FunctionProto:
12010 case Type::ExtVector:
12011 case Type::OverflowBehavior:
12012 llvm_unreachable(
"Types are eliminated above");
12014 case Type::Pointer:
12025 if (ResultType.
isNull())
12033 case Type::BlockPointer:
12058 if (ResultType.
isNull())
12077 if (ResultType.
isNull())
12085 case Type::ConstantArray:
12100 if (ResultType.
isNull())
12108 if (LVAT || RVAT) {
12111 -> std::pair<bool,llvm::APInt> {
12113 std::optional<llvm::APSInt> TheInt;
12116 return std::make_pair(
true, *TheInt);
12117 return std::make_pair(
false, llvm::APSInt());
12120 return std::make_pair(
true, CAT->getSize());
12121 return std::make_pair(
false, llvm::APInt());
12124 bool HaveLSize, HaveRSize;
12125 llvm::APInt LSize, RSize;
12126 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
12127 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
12128 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
12162 case Type::FunctionNoProto:
12164 false, IsConditionalOperator);
12168 case Type::Builtin:
12171 case Type::Complex:
12180 case Type::ConstantMatrix:
12185 case Type::ObjCObject: {
12194 case Type::ObjCObjectPointer:
12195 if (OfBlockPointer) {
12207 assert(LHS != RHS &&
12208 "Equivalent pipe types should have already been handled!");
12210 case Type::ArrayParameter:
12211 assert(LHS != RHS &&
12212 "Equivalent ArrayParameter types should have already been handled!");
12214 case Type::BitInt: {
12222 if (LHSUnsigned != RHSUnsigned)
12225 if (LHSBits != RHSBits)
12229 case Type::HLSLAttributedResource: {
12230 const HLSLAttributedResourceType *LHSTy =
12231 LHS->
castAs<HLSLAttributedResourceType>();
12232 const HLSLAttributedResourceType *RHSTy =
12233 RHS->
castAs<HLSLAttributedResourceType>();
12234 assert(LHSTy->getWrappedType() == RHSTy->getWrappedType() &&
12235 LHSTy->getWrappedType()->isHLSLResourceType() &&
12236 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
12238 if (LHSTy->getAttrs() == RHSTy->getAttrs() &&
12239 LHSTy->getContainedType() == RHSTy->getContainedType())
12243 case Type::HLSLInlineSpirv:
12244 const HLSLInlineSpirvType *LHSTy = LHS->
castAs<HLSLInlineSpirvType>();
12245 const HLSLInlineSpirvType *RHSTy = RHS->
castAs<HLSLInlineSpirvType>();
12247 if (LHSTy->getOpcode() == RHSTy->getOpcode() &&
12248 LHSTy->getSize() == RHSTy->getSize() &&
12249 LHSTy->getAlignment() == RHSTy->getAlignment()) {
12250 for (
size_t I = 0; I < LHSTy->getOperands().size(); I++)
12251 if (LHSTy->getOperands()[I] != RHSTy->getOperands()[I])
12259 llvm_unreachable(
"Invalid Type::Class!");
12264 bool &CanUseFirst,
bool &CanUseSecond,
12266 assert(NewParamInfos.empty() &&
"param info list not empty");
12267 CanUseFirst = CanUseSecond =
true;
12273 if (!FirstHasInfo && !SecondHasInfo)
12276 bool NeedParamInfo =
false;
12280 for (
size_t I = 0; I < E; ++I) {
12291 bool FirstNoEscape = FirstParam.
isNoEscape();
12292 bool SecondNoEscape = SecondParam.
isNoEscape();
12293 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12295 if (NewParamInfos.back().getOpaqueValue())
12296 NeedParamInfo =
true;
12297 if (FirstNoEscape != IsNoEscape)
12298 CanUseFirst =
false;
12299 if (SecondNoEscape != IsNoEscape)
12300 CanUseSecond =
false;
12303 if (!NeedParamInfo)
12304 NewParamInfos.clear();
12310 if (
auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
12311 It->second =
nullptr;
12312 for (
auto *SubClass : ObjCSubClasses.lookup(D))
12324 if (LHSCan == RHSCan)
12326 if (RHSCan->isFunctionType()) {
12335 if (ResReturnType.
isNull())
12337 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12354 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12361 if (LQuals != RQuals) {
12369 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12385 if (ResQT == LHSBaseQT)
12387 if (ResQT == RHSBaseQT)
12398 if (
const auto *ED =
T->getAsEnumDecl())
12399 T = ED->getIntegerType();
12400 if (
T->isBooleanType())
12403 return EIT->getNumBits();
12409 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12410 T->isFixedPointType()) &&
12411 "Unexpected type");
12416 VTy->getNumElements(), VTy->getVectorKind());
12423 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>())
12425 OBT->getBehaviorKind(),
12430 if (
const auto *ED =
T->getAsEnumDecl())
12431 T = ED->getIntegerType();
12434 case BuiltinType::Char_U:
12436 case BuiltinType::Char_S:
12437 case BuiltinType::SChar:
12438 case BuiltinType::Char8:
12440 case BuiltinType::Short:
12442 case BuiltinType::Int:
12444 case BuiltinType::Long:
12446 case BuiltinType::LongLong:
12448 case BuiltinType::Int128:
12453 case BuiltinType::WChar_S:
12456 case BuiltinType::ShortAccum:
12458 case BuiltinType::Accum:
12460 case BuiltinType::LongAccum:
12462 case BuiltinType::SatShortAccum:
12464 case BuiltinType::SatAccum:
12466 case BuiltinType::SatLongAccum:
12468 case BuiltinType::ShortFract:
12470 case BuiltinType::Fract:
12472 case BuiltinType::LongFract:
12474 case BuiltinType::SatShortFract:
12476 case BuiltinType::SatFract:
12478 case BuiltinType::SatLongFract:
12481 assert((
T->hasUnsignedIntegerRepresentation() ||
12482 T->isUnsignedFixedPointType()) &&
12483 "Unexpected signed integer or fixed point type");
12489 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12490 T->isFixedPointType()) &&
12491 "Unexpected type");
12496 VTy->getNumElements(), VTy->getVectorKind());
12504 if (
const auto *ED =
T->getAsEnumDecl())
12505 T = ED->getIntegerType();
12508 case BuiltinType::Char_S:
12510 case BuiltinType::Char_U:
12511 case BuiltinType::UChar:
12512 case BuiltinType::Char8:
12514 case BuiltinType::UShort:
12516 case BuiltinType::UInt:
12518 case BuiltinType::ULong:
12520 case BuiltinType::ULongLong:
12522 case BuiltinType::UInt128:
12527 case BuiltinType::WChar_U:
12530 case BuiltinType::UShortAccum:
12532 case BuiltinType::UAccum:
12534 case BuiltinType::ULongAccum:
12536 case BuiltinType::SatUShortAccum:
12538 case BuiltinType::SatUAccum:
12540 case BuiltinType::SatULongAccum:
12542 case BuiltinType::UShortFract:
12544 case BuiltinType::UFract:
12546 case BuiltinType::ULongFract:
12548 case BuiltinType::SatUShortFract:
12550 case BuiltinType::SatUFract:
12552 case BuiltinType::SatULongFract:
12556 (
T->hasSignedIntegerRepresentation() ||
T->isSignedFixedPointType()) &&
12557 "Unexpected signed integer or fixed point type");
12582 bool AllowTypeModifiers) {
12586 bool IsChar =
false, IsShort =
false;
12587 RequiresICE =
false;
12592 bool IsSpecial =
false;
12596 default: Done =
true; --Str;
break;
12598 RequiresICE =
true;
12601 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12602 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12606 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12607 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12612 assert(!IsSpecial &&
12613 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12614 assert(HowLong == 0 &&
"Can't use both 'L' and 'B' modifiers!");
12622 assert(!IsSpecial &&
12623 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12624 assert(HowLong == 0 &&
"Can't use both 'L' and 'T' modifiers!");
12631 assert(!IsSpecial &&
12632 "Can't use 'L' with 'W', 'N', 'Z', 'O', 'B', or 'T' modifiers");
12633 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12638 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12639 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12643 if (Context.getTargetInfo().getLongWidth() == 32)
12648 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12649 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12653 switch (Context.getTargetInfo().getInt64Type()) {
12655 llvm_unreachable(
"Unexpected integer type");
12666 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12667 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12671 switch (Context.getTargetInfo().getIntTypeByWidth(32,
true)) {
12673 llvm_unreachable(
"Unexpected integer type");
12686 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12687 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12691 if (Context.getLangOpts().OpenCL)
12704 llvm_unreachable(
"Unknown builtin type letter!");
12707 "Bad modifiers used with 'x'!");
12708 Type = Context.Float16Ty;
12712 "Bad modifiers used with 'y'!");
12713 Type = Context.BFloat16Ty;
12717 "Bad modifiers used with 'v'!");
12718 Type = Context.VoidTy;
12722 "Bad modifiers used with 'h'!");
12723 Type = Context.HalfTy;
12727 "Bad modifiers used with 'f'!");
12728 Type = Context.FloatTy;
12732 "Bad modifiers used with 'd'!");
12734 Type = Context.LongDoubleTy;
12735 else if (HowLong == 2)
12736 Type = Context.Float128Ty;
12738 Type = Context.DoubleTy;
12741 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12743 Type = Context.UnsignedShortTy;
12745 Type = Context.ShortTy;
12749 Type =
Unsigned ? Context.UnsignedCharTy : Context.SignedCharTy;
12751 Type =
Unsigned ? Context.UnsignedShortTy : Context.ShortTy;
12752 else if (HowLong == 3)
12753 Type =
Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
12754 else if (HowLong == 2)
12755 Type =
Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
12756 else if (HowLong == 1)
12757 Type =
Unsigned ? Context.UnsignedLongTy : Context.LongTy;
12759 Type =
Unsigned ? Context.UnsignedIntTy : Context.IntTy;
12762 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12764 Type = Context.SignedCharTy;
12766 Type = Context.UnsignedCharTy;
12768 Type = Context.CharTy;
12771 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12772 Type = Context.BoolTy;
12775 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12776 Type = Context.getSizeType();
12779 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12780 Type = Context.getWideCharType();
12783 Type = Context.getCFConstantStringType();
12786 Type = Context.getObjCIdType();
12789 Type = Context.getObjCSelType();
12792 Type = Context.getObjCSuperType();
12795 Type = Context.getBuiltinVaListType();
12796 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12807 Type = Context.getBuiltinVaListType();
12808 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12810 Type = Context.getArrayDecayedType(
Type);
12812 Type = Context.getLValueReferenceType(
Type);
12816 unsigned NumElements = strtoul(Str, &End, 10);
12817 assert(End != Str &&
"Missing vector size");
12821 RequiresICE,
false);
12822 assert(!RequiresICE &&
"Can't require vector ICE");
12824 Type = Context.getScalableVectorType(ElementType, NumElements);
12830 Type = Context.SveCountTy;
12834 Type = Context.AMDGPUBufferRsrcTy;
12838 Type = Context.AMDGPUFeaturePredicateTy;
12842 Type = Context.AMDGPUTextureTy;
12846 Type = Context.HLSLResourceTy;
12850 llvm_unreachable(
"Unexpected target builtin type");
12856 unsigned NumElements = strtoul(Str, &End, 10);
12857 assert(End != Str &&
"Missing vector size");
12861 RequiresICE,
false);
12862 assert(!RequiresICE &&
"Can't require vector ICE");
12871 unsigned NumElements = strtoul(Str, &End, 10);
12872 assert(End != Str &&
"Missing vector size");
12878 Type = Context.getExtVectorType(ElementType, NumElements);
12884 assert(!RequiresICE &&
"Can't require complex ICE");
12885 Type = Context.getComplexType(ElementType);
12889 Type = Context.getPointerDiffType();
12892 Type = Context.getFILEType();
12893 if (
Type.isNull()) {
12900 Type = Context.getsigjmp_bufType();
12902 Type = Context.getjmp_bufType();
12904 if (
Type.isNull()) {
12910 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
12911 Type = Context.getucontext_tType();
12913 if (
Type.isNull()) {
12919 Type = Context.getProcessIDType();
12922 Type = Context.MFloat8Ty;
12927 Done = !AllowTypeModifiers;
12929 switch (
char c = *Str++) {
12930 default: Done =
true; --Str;
break;
12936 unsigned AddrSpace = strtoul(Str, &End, 10);
12939 Type = Context.getAddrSpaceQualType(
12941 Context.getLangASForBuiltinAddressSpace(AddrSpace));
12945 Type = Context.getPointerType(
Type);
12947 Type = Context.getLValueReferenceType(
Type);
12955 Type = Context.getVolatileType(
Type);
12964 "Integer constant 'I' type must be an integer");
12977 bool AllowTypeModifiers)
const {
12984 unsigned *IntegerConstantArgs)
const {
12985 const char *TypeStr =
BuiltinInfo.getTypeString(Id);
12986 if (TypeStr[0] ==
'\0') {
12993 bool RequiresICE =
false;
12996 RequiresICE,
true);
13000 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
13002 while (TypeStr[0] && TypeStr[0] !=
'.') {
13009 if (RequiresICE && IntegerConstantArgs)
13010 *IntegerConstantArgs |= 1 << ArgTypes.size();
13016 ArgTypes.push_back(Ty);
13019 if (Id == Builtin::BI__GetExceptionInfo)
13022 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
13023 "'.' should only occur at end of builtin type list!");
13025 bool Variadic = (TypeStr[0] ==
'.');
13032 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
13082 if ((!Context.getLangOpts().CPlusPlus &&
13083 !Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13084 !FD->
hasAttr<DLLExportAttr>()) ||
13085 FD->
hasAttr<GNUInlineAttr>()) {
13104 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13107 !FD->
hasAttr<DLLExportAttr>()) {
13128 if (D->
hasAttr<DLLImportAttr>()) {
13131 }
else if (D->
hasAttr<DLLExportAttr>()) {
13134 }
else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice) {
13137 if (D->
hasAttr<CUDAGlobalAttr>() &&
13146 if (Context.shouldExternalize(D))
13161 switch (Source->hasExternalDefinitions(D)) {
13188 if (Context.getLangOpts().CPlusPlus &&
13189 Context.getLangOpts().IncrementalExtensions &&
13205 if (!LexicalContext)
13210 auto StaticLocalLinkage =
13222 return StaticLocalLinkage;
13228 if (Context.isMSStaticDataMemberInlineDefinition(VD))
13234 switch (Context.getInlineVariableDefinitionKind(VD)) {
13249 return StrongLinkage;
13252 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13267 llvm_unreachable(
"Invalid Linkage!");
13277 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13278 if (!VD->isFileVarDecl())
13283 if (VD->getDescribedVarTemplate() ||
13286 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13312 if (D->
hasAttr<WeakRefAttr>())
13319 if (LangOpts.SYCLIsDevice)
13321 D->
hasAttr<SYCLExternalAttr>());
13327 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13329 if (!FD->doesThisDeclarationHaveABody())
13330 return FD->doesDeclarationForceExternallyVisibleDefinition();
13333 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13338 if (
getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
13339 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13358 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13362 if (LangOpts.OpenMP &&
13363 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13370 if (VD->shouldEmitInExternalSource())
13383 if (VD->needsDestruction(*
this))
13387 if (VD->hasInitWithSideEffects())
13392 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13393 for (
const auto *BD : DD->flat_bindings())
13394 if (
const auto *BindingVD = BD->getHoldingVar())
13404 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13405 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13406 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13411 for (
auto *CurDecl :
13415 SeenDecls.insert(CurFD).second) {
13422 bool IsCXXMethod)
const {
13425 return ABI->getDefaultMethodCallConv(IsVariadic);
13427 switch (LangOpts.getDefaultCallingConv()) {
13455 return Target->getDefaultCallingConv();
13460 return ABI->isNearlyEmpty(RD);
13465 auto ABI = Target->getCXXABI();
13466 if (ABI.isMicrosoft())
13472 return VTContext.get();
13478 switch (
T->getCXXABI().getKind()) {
13479 case TargetCXXABI::AppleARM64:
13480 case TargetCXXABI::Fuchsia:
13481 case TargetCXXABI::GenericAArch64:
13482 case TargetCXXABI::GenericItanium:
13483 case TargetCXXABI::GenericARM:
13484 case TargetCXXABI::GenericMIPS:
13485 case TargetCXXABI::iOS:
13486 case TargetCXXABI::WebAssembly:
13487 case TargetCXXABI::WatchOS:
13488 case TargetCXXABI::XL:
13490 case TargetCXXABI::Microsoft:
13493 llvm_unreachable(
"Unsupported ABI");
13497 assert(
T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13498 "Device mangle context does not support Microsoft mangling.");
13499 switch (
T.getCXXABI().getKind()) {
13500 case TargetCXXABI::AppleARM64:
13501 case TargetCXXABI::Fuchsia:
13502 case TargetCXXABI::GenericAArch64:
13503 case TargetCXXABI::GenericItanium:
13504 case TargetCXXABI::GenericARM:
13505 case TargetCXXABI::GenericMIPS:
13506 case TargetCXXABI::iOS:
13507 case TargetCXXABI::WebAssembly:
13508 case TargetCXXABI::WatchOS:
13509 case TargetCXXABI::XL:
13513 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13514 return RD->getDeviceLambdaManglingNumber();
13515 return std::nullopt;
13518 case TargetCXXABI::Microsoft:
13522 llvm_unreachable(
"Unsupported ABI");
13540 return ASTRecordLayouts.getMemorySize() +
13541 llvm::capacity_in_bytes(ObjCLayouts) +
13542 llvm::capacity_in_bytes(KeyFunctions) +
13543 llvm::capacity_in_bytes(ObjCImpls) +
13544 llvm::capacity_in_bytes(BlockVarCopyInits) +
13545 llvm::capacity_in_bytes(DeclAttrs) +
13546 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13547 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13548 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13549 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13550 llvm::capacity_in_bytes(OverriddenMethods) +
13551 llvm::capacity_in_bytes(Types) +
13552 llvm::capacity_in_bytes(VariableArrayTypes);
13560 unsigned Signed)
const {
13563 if (!QualTy && DestWidth == 128)
13569 unsigned Signed)
const {
13570 return getFromTargetType(
13598 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13605 MangleNumbers[ND] = Number;
13608 Listener->AddedManglingNumber(ND, Number);
13612 bool ForAuxTarget)
const {
13613 auto I = MangleNumbers.find(ND);
13614 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13617 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13618 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13620 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13621 "number for aux target");
13623 return Res > 1 ? Res : 1;
13630 StaticLocalNumbers[VD] = Number;
13633 Listener->AddedStaticLocalNumbers(VD, Number);
13637 auto I = StaticLocalNumbers.find(VD);
13638 return I != StaticLocalNumbers.end() ? I->second : 1;
13642 bool IsDestroying) {
13643 if (!IsDestroying) {
13655 bool IsTypeAware) {
13656 if (!IsTypeAware) {
13672 OperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] = OperatorDelete;
13675 GlobalOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13679 ArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13683 GlobalArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13693 return OperatorDeletesForVirtualDtor.contains(Dtor->getCanonicalDecl());
13695 return GlobalOperatorDeletesForVirtualDtor.contains(
13696 Dtor->getCanonicalDecl());
13698 return ArrayOperatorDeletesForVirtualDtor.contains(
13699 Dtor->getCanonicalDecl());
13701 return GlobalArrayOperatorDeletesForVirtualDtor.contains(
13702 Dtor->getCanonicalDecl());
13713 if (OperatorDeletesForVirtualDtor.contains(Canon))
13714 return OperatorDeletesForVirtualDtor[Canon];
13717 if (GlobalOperatorDeletesForVirtualDtor.contains(Canon))
13718 return GlobalOperatorDeletesForVirtualDtor[Canon];
13721 if (ArrayOperatorDeletesForVirtualDtor.contains(Canon))
13722 return ArrayOperatorDeletesForVirtualDtor[Canon];
13725 if (GlobalArrayOperatorDeletesForVirtualDtor.contains(Canon))
13726 return GlobalArrayOperatorDeletesForVirtualDtor[Canon];
13737 return MaybeRequireVectorDeletingDtor.count(RD);
13745 MaybeRequireVectorDeletingDtor.insert(RD);
13750 assert(LangOpts.CPlusPlus);
13751 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13759 assert(LangOpts.CPlusPlus);
13760 std::unique_ptr<MangleNumberingContext> &MCtx =
13761 ExtraMangleNumberingContexts[D];
13767std::unique_ptr<MangleNumberingContext>
13769 return ABI->createMangleNumberingContext();
13774 return ABI->getCopyConstructorForExceptionObject(
13780 return ABI->addCopyConstructorForExceptionObject(
13787 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13792 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13797 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13801 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13805 ParamIndices[D] =
index;
13809 ParameterIndexTable::const_iterator I = ParamIndices.find(D);
13810 assert(I != ParamIndices.end() &&
13811 "ParmIndices lacks entry set by ParmVarDecl");
13816 unsigned Length)
const {
13842 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13844 llvm::FoldingSetNodeID ID;
13847 llvm::FoldingSetInsertToken
Token;
13852 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
13859 const APValue &APVal)
const {
13860 llvm::FoldingSetNodeID ID;
13863 llvm::FoldingSetInsertToken
Token;
13865 UnnamedGlobalConstantDecls.lookup(ID,
Token))
13869 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
13870 UnnamedGlobalConstantDecls.insert(
New,
Token);
13876 assert(
T->isRecordType() &&
"template param object of unexpected type");
13882 llvm::FoldingSetNodeID ID;
13885 llvm::FoldingSetInsertToken
Token;
13887 TemplateParamObjectDecls.lookup(ID,
Token))
13891 TemplateParamObjectDecls.insert(
New,
Token);
13897 if (!
T.isOSDarwin())
13900 if (!(
T.isiOS() &&
T.isOSVersionLT(7)) &&
13901 !(
T.isMacOSX() &&
T.isOSVersionLT(10, 9)))
13910 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
13917 if (MethodDecl->
hasAttr<UnavailableAttr>()
13918 || MethodDecl->
hasAttr<DeprecatedAttr>())
13932 IM != EM && IF != EF; ++IM, ++IF) {
13963 llvm::FoldingSetNodeID IDX, IDY;
13964 X->Profile(IDX, *
this,
true);
13965 Y->
Profile(IDY, *
this,
true);
13979 for (
const Decl *DX :
X->redecls()) {
13984 if (DX->isFirstDecl())
13987 llvm_unreachable(
"Corrupt redecls chain");
13990template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
13992 return cast_or_null<T>(
13994 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
13997template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14005 bool IgnoreDeduced =
false) {
14020 bool IgnoreDeduced) {
14022 assert(R.getAsVoidPointer() !=
nullptr);
14028 assert(Xs.size() == Ys.size());
14030 for (
size_t I = 0; I < Rs.size(); ++I)
14037 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
14047 switch (
X.getKind()) {
14077 auto NExpX =
X.getNumTemplateExpansions();
14091 if (Xs.size() != Ys.size())
14093 R.resize(Xs.size());
14094 for (
size_t I = 0; I < R.size(); ++I) {
14107 assert(!Different);
14135 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
14137 return std::nullopt;
14142 assert(Kind == NNS2.
getKind());
14147 auto Kind = Namespace1->getKind();
14148 if (Kind != Namespace2->getKind() ||
14149 (Kind == Decl::NamespaceAlias &&
14154 Namespace2->getNamespace()),
14188 llvm_unreachable(
"singletons did not compare equal");
14190 assert(R.getCanonical() == Canon);
14196 const T *Y,
bool IsSame) {
14197 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
14217 QX +=
X.getQualifiers() - RQ;
14227 Y->getElementType(), QX, QY);
14238 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
14239 return X->getSizeExpr();
14244 return X->getSizeModifier();
14250 return X->getIndexTypeCVRQualifiers();
14260 llvm::DenseMap<QualType, unsigned>
Found;
14261 for (
auto Ts : {
X, Y}) {
14268 Out.emplace_back(
T);
14274FunctionProtoType::ExceptionSpecInfo
14278 bool AcceptDependent)
const {
14304 assert(AcceptDependent &&
14305 "computing composite pointer type of dependent types");
14320 llvm_unreachable(
"These ESTs should be handled above");
14325 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
14329 Result.Exceptions = ExceptionTypeStorage;
14336 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
14339 llvm_unreachable(
"invalid ExceptionSpecificationType");
14348#define UNEXPECTED_TYPE(Class, Kind) \
14349 case Type::Class: \
14350 llvm_unreachable("Unexpected " Kind ": " #Class);
14352#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
14353#define TYPE(Class, Base)
14354#include "clang/AST/TypeNodes.inc"
14356#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
14367#undef SUGAR_FREE_TYPE
14368#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
14371#undef NON_UNIQUE_TYPE
14375#undef UNEXPECTED_TYPE
14379 assert(AX->getDeducedKind() == AY->getDeducedKind());
14381 assert(AX->getKeyword() == AY->getKeyword());
14384 AY->getTypeConstraintConcept().getAsTemplateDecl());
14388 AY->getTypeConstraintArguments())) {
14395 case Type::IncompleteArray: {
14402 case Type::DependentSizedArray: {
14410 case Type::ConstantArray: {
14413 assert(AX->getSize() == AY->getSize());
14414 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14415 ? AX->getSizeExpr()
14421 case Type::ArrayParameter: {
14424 assert(AX->getSize() == AY->getSize());
14425 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14426 ? AX->getSizeExpr()
14433 case Type::Atomic: {
14438 case Type::Complex: {
14442 case Type::Pointer: {
14446 case Type::BlockPointer: {
14450 case Type::ObjCObjectPointer: {
14455 case Type::MemberPointer: {
14459 PY->getMostRecentCXXRecordDecl()));
14463 PX->getMostRecentCXXRecordDecl());
14465 case Type::LValueReference: {
14470 PX->isSpelledAsLValue() ||
14471 PY->isSpelledAsLValue());
14473 case Type::RValueReference: {
14479 case Type::DependentAddressSpace: {
14482 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14484 PX->getAddrSpaceExpr(),
14487 case Type::FunctionNoProto: {
14490 assert(FX->getExtInfo() == FY->getExtInfo());
14495 case Type::FunctionProto: {
14499 EPIY = FY->getExtProtoInfo();
14500 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14507 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14508 assert(EPIX.
Variadic == EPIY.Variadic);
14517 auto P =
getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
14525 case Type::ObjCObject: {
14528 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14529 OY->getProtocols().begin(), OY->getProtocols().end(),
14531 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14533 "protocol lists must be the same");
14535 OY->getTypeArgsAsWritten());
14538 OX->getProtocols(),
14539 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14541 case Type::ConstantMatrix: {
14544 assert(MX->getNumRows() == MY->getNumRows());
14545 assert(MX->getNumColumns() == MY->getNumColumns());
14547 MX->getNumRows(), MX->getNumColumns());
14549 case Type::DependentSizedMatrix: {
14552 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14553 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14558 case Type::Vector: {
14560 assert(VX->getNumElements() == VY->getNumElements());
14561 assert(VX->getVectorKind() == VY->getVectorKind());
14563 VX->getNumElements(), VX->getVectorKind());
14565 case Type::ExtVector: {
14567 assert(VX->getNumElements() == VY->getNumElements());
14569 VX->getNumElements());
14571 case Type::DependentSizedExtVector: {
14578 case Type::DependentVector: {
14581 assert(VX->getVectorKind() == VY->getVectorKind());
14588 case Type::InjectedClassName: {
14595 case Type::TemplateSpecialization: {
14599 TY->template_arguments());
14603 TY->getTemplateName(),
14605 As, {},
X->getCanonicalTypeInternal());
14607 case Type::Decltype: {
14610 assert(DX->isDependentType());
14611 assert(DY->isDependentType());
14612 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14616 case Type::PackIndexing: {
14619 assert(DX->isDependentType());
14620 assert(DY->isDependentType());
14621 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14624 case Type::DependentName: {
14627 assert(NX->getIdentifier() == NY->getIdentifier());
14632 case Type::OverflowBehavior: {
14635 assert(NX->getBehaviorKind() == NY->getBehaviorKind());
14637 NX->getBehaviorKind(),
14639 NY->getUnderlyingType(), QX, QY));
14641 case Type::UnaryTransform: {
14644 assert(TX->getUTTKind() == TY->getUTTKind());
14648 TY->getUnderlyingType()),
14651 case Type::PackExpansion: {
14654 assert(PX->getNumExpansions() == PY->getNumExpansions());
14657 PX->getNumExpansions(),
false);
14661 assert(PX->isReadOnly() == PY->isReadOnly());
14666 case Type::TemplateTypeParm: {
14669 assert(TX->getDepth() == TY->getDepth());
14670 assert(TX->getIndex() == TY->getIndex());
14671 assert(TX->isParameterPack() == TY->isParameterPack());
14673 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14677 llvm_unreachable(
"Unknown Type Class");
14687#define UNEXPECTED_TYPE(Class, Kind) \
14688 case Type::Class: \
14689 llvm_unreachable("Unexpected " Kind ": " #Class);
14690#define TYPE(Class, Base)
14691#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14692#include "clang/AST/TypeNodes.inc"
14694#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14721#undef CANONICAL_TYPE
14723#undef UNEXPECTED_TYPE
14725 case Type::Adjusted: {
14727 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14734 case Type::Decayed: {
14736 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14743 case Type::Attributed: {
14745 AttributedType::Kind Kind = AX->getAttrKind();
14746 if (Kind != AY->getAttrKind())
14748 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14756 case Type::BTFTagAttributed: {
14758 const BTFTypeTagAttr *AX = BX->getAttr();
14760 if (AX->getBTFTypeTag() !=
14771 if (KW != AY->getKeyword())
14776 AY->getTypeConstraintConcept().getAsTemplateDecl());
14780 AY->getTypeConstraintArguments())) {
14791 case Type::PackIndexing:
14792 case Type::Decltype:
14794 case Type::DeducedTemplateSpecialization:
14797 case Type::MacroQualified: {
14801 if (IX != MY->getMacroIdentifier())
14805 case Type::SubstTemplateTypeParm: {
14812 unsigned Index = SX->getIndex();
14813 if (Index != SY->getIndex())
14820 SX->getFinal() && SY->getFinal());
14822 case Type::ObjCTypeParam:
14828 case Type::TemplateSpecialization: {
14833 TY->getTemplateName(),
true);
14838 TY->template_arguments()))
14844 case Type::Typedef: {
14854 case Type::TypeOf: {
14865 case Type::TypeOfExpr:
14868 case Type::UnaryTransform: {
14871 UnaryTransformType::UTTKind KX = UX->getUTTKind();
14872 if (KX != UY->getUTTKind())
14874 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
14881 case Type::Using: {
14890 case Type::MemberPointer: {
14894 assert(Cls == PY->getMostRecentCXXRecordDecl());
14899 case Type::CountAttributed: {
14902 if (DX->isCountInBytes() != DY->isCountInBytes())
14904 if (DX->isOrNull() != DY->isOrNull())
14906 Expr *CEX = DX->getCountExpr();
14907 Expr *CEY = DY->getCountExpr();
14911 DX->isCountInBytes(), DX->isOrNull(),
14922 DX->isCountInBytes(), DX->isOrNull(),
14926 case Type::LateParsedAttr:
14929 case Type::PredefinedSugar:
14934 llvm_unreachable(
"Unhandled Type Class");
14941 QualType NT =
T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
14956 if (
X.isCanonical())
14983 bool KeepCommonQualifiers =
14986 if (SX.
Ty != SY.Ty) {
14994 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
14997 SX = Xs.pop_back_val();
14998 SY = Ys.pop_back_val();
15001 if (KeepCommonQualifiers)
15008 while (!Xs.empty() && !Ys.empty()) {
15011 SX = Xs.pop_back_val();
15012 SY = Ys.pop_back_val();
15017 SX.
Ty = Underlying.Ty;
15020 QX -= Underlying.Quals;
15038 llvm_unreachable(
"Not a saturated fixed point type!");
15039 case BuiltinType::SatShortAccum:
15041 case BuiltinType::SatAccum:
15043 case BuiltinType::SatLongAccum:
15045 case BuiltinType::SatUShortAccum:
15047 case BuiltinType::SatUAccum:
15049 case BuiltinType::SatULongAccum:
15051 case BuiltinType::SatShortFract:
15053 case BuiltinType::SatFract:
15055 case BuiltinType::SatLongFract:
15057 case BuiltinType::SatUShortFract:
15059 case BuiltinType::SatUFract:
15061 case BuiltinType::SatULongFract:
15073 llvm_unreachable(
"Not a fixed point type!");
15074 case BuiltinType::ShortAccum:
15076 case BuiltinType::Accum:
15078 case BuiltinType::LongAccum:
15080 case BuiltinType::UShortAccum:
15082 case BuiltinType::UAccum:
15084 case BuiltinType::ULongAccum:
15086 case BuiltinType::ShortFract:
15088 case BuiltinType::Fract:
15090 case BuiltinType::LongFract:
15092 case BuiltinType::UShortFract:
15094 case BuiltinType::UFract:
15096 case BuiltinType::ULongFract:
15102 if (LangOpts.OpenCL)
15117 llvm_unreachable(
"Not a fixed point type!");
15118 case BuiltinType::ShortAccum:
15119 case BuiltinType::SatShortAccum:
15120 return Target.getShortAccumScale();
15121 case BuiltinType::Accum:
15122 case BuiltinType::SatAccum:
15123 return Target.getAccumScale();
15124 case BuiltinType::LongAccum:
15125 case BuiltinType::SatLongAccum:
15126 return Target.getLongAccumScale();
15127 case BuiltinType::UShortAccum:
15128 case BuiltinType::SatUShortAccum:
15129 return Target.getUnsignedShortAccumScale();
15130 case BuiltinType::UAccum:
15131 case BuiltinType::SatUAccum:
15132 return Target.getUnsignedAccumScale();
15133 case BuiltinType::ULongAccum:
15134 case BuiltinType::SatULongAccum:
15135 return Target.getUnsignedLongAccumScale();
15136 case BuiltinType::ShortFract:
15137 case BuiltinType::SatShortFract:
15138 return Target.getShortFractScale();
15139 case BuiltinType::Fract:
15140 case BuiltinType::SatFract:
15141 return Target.getFractScale();
15142 case BuiltinType::LongFract:
15143 case BuiltinType::SatLongFract:
15144 return Target.getLongFractScale();
15145 case BuiltinType::UShortFract:
15146 case BuiltinType::SatUShortFract:
15147 return Target.getUnsignedShortFractScale();
15148 case BuiltinType::UFract:
15149 case BuiltinType::SatUFract:
15150 return Target.getUnsignedFractScale();
15151 case BuiltinType::ULongFract:
15152 case BuiltinType::SatULongFract:
15153 return Target.getUnsignedLongFractScale();
15163 llvm_unreachable(
"Not a fixed point type!");
15164 case BuiltinType::ShortAccum:
15165 case BuiltinType::SatShortAccum:
15166 return Target.getShortAccumIBits();
15167 case BuiltinType::Accum:
15168 case BuiltinType::SatAccum:
15169 return Target.getAccumIBits();
15170 case BuiltinType::LongAccum:
15171 case BuiltinType::SatLongAccum:
15172 return Target.getLongAccumIBits();
15173 case BuiltinType::UShortAccum:
15174 case BuiltinType::SatUShortAccum:
15175 return Target.getUnsignedShortAccumIBits();
15176 case BuiltinType::UAccum:
15177 case BuiltinType::SatUAccum:
15178 return Target.getUnsignedAccumIBits();
15179 case BuiltinType::ULongAccum:
15180 case BuiltinType::SatULongAccum:
15181 return Target.getUnsignedLongAccumIBits();
15182 case BuiltinType::ShortFract:
15183 case BuiltinType::SatShortFract:
15184 case BuiltinType::Fract:
15185 case BuiltinType::SatFract:
15186 case BuiltinType::LongFract:
15187 case BuiltinType::SatLongFract:
15188 case BuiltinType::UShortFract:
15189 case BuiltinType::SatUShortFract:
15190 case BuiltinType::UFract:
15191 case BuiltinType::SatUFract:
15192 case BuiltinType::ULongFract:
15193 case BuiltinType::SatULongFract:
15198llvm::FixedPointSemantics
15201 "Can only get the fixed point semantics for a "
15202 "fixed point or integer type.");
15204 return llvm::FixedPointSemantics::GetIntegerSemantics(
15208 return llvm::FixedPointSemantics(
15211 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
15226 "Expected unsigned fixed point type");
15229 case BuiltinType::UShortAccum:
15231 case BuiltinType::UAccum:
15233 case BuiltinType::ULongAccum:
15235 case BuiltinType::SatUShortAccum:
15237 case BuiltinType::SatUAccum:
15239 case BuiltinType::SatULongAccum:
15241 case BuiltinType::UShortFract:
15243 case BuiltinType::UFract:
15245 case BuiltinType::ULongFract:
15247 case BuiltinType::SatUShortFract:
15249 case BuiltinType::SatUFract:
15251 case BuiltinType::SatULongFract:
15254 llvm_unreachable(
"Unexpected unsigned fixed point type");
15262 std::vector<std::string> BackendFeats;
15263 llvm::AArch64::ExtensionSet FeatureBits;
15264 for (StringRef F : FMVFeatStrings)
15265 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
15267 FeatureBits.enable(*FMVExt->ID);
15268 FeatureBits.toLLVMFeatureList(BackendFeats);
15269 return BackendFeats;
15274 assert(TD !=
nullptr);
15277 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
15278 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
15289 Target->getTargetOpts().CPU,
15290 Target->getTargetOpts().Features);
15297 StringRef TargetCPU = Target->getTargetOpts().CPU;
15299 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
15305 if (!Target->getTriple().isAArch64())
15308 Target->getTargetOpts().FeaturesAsWritten.begin(),
15309 Target->getTargetOpts().FeaturesAsWritten.end());
15320 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
15322 Target->getCPUSpecificCPUDispatchFeatures(
15324 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
15325 Features.insert(Features.begin(),
15326 Target->getTargetOpts().FeaturesAsWritten.begin(),
15327 Target->getTargetOpts().FeaturesAsWritten.end());
15328 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15329 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
15330 if (Target->getTriple().isAArch64()) {
15334 Features.insert(Features.begin(),
15335 Target->getTargetOpts().FeaturesAsWritten.begin(),
15336 Target->getTargetOpts().FeaturesAsWritten.end());
15337 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15338 }
else if (Target->getTriple().isRISCV()) {
15340 std::vector<std::string> Features;
15341 if (VersionStr !=
"default") {
15343 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15346 Features.insert(Features.begin(),
15347 Target->getTargetOpts().FeaturesAsWritten.begin(),
15348 Target->getTargetOpts().FeaturesAsWritten.end());
15349 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15350 }
else if (Target->getTriple().isOSAIX()) {
15351 std::vector<std::string> Features;
15353 if (VersionStr.starts_with(
"cpu="))
15354 TargetCPU = VersionStr.drop_front(
sizeof(
"cpu=") - 1);
15356 assert(VersionStr ==
"default");
15357 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15359 std::vector<std::string> Features;
15361 if (VersionStr.starts_with(
"arch="))
15362 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
15363 else if (VersionStr !=
"default")
15364 Features.push_back((StringRef{
"+"} + VersionStr).str());
15365 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15367 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
15368 std::vector<std::string> Features;
15369 if (Target->getTriple().isRISCV()) {
15371 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15374 assert(Target->getTriple().isAArch64());
15376 TV->getFeatures(Feats);
15379 Features.insert(Features.begin(),
15380 Target->getTargetOpts().FeaturesAsWritten.begin(),
15381 Target->getTargetOpts().FeaturesAsWritten.end());
15382 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15384 FeatureMap = Target->getTargetOpts().FeatureMap;
15395 auto DeviceDiscriminatorOverrider =
15397 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15399 return RD->getDeviceLambdaManglingNumber();
15400 return std::nullopt;
15403 Context, Context.getDiagnostics(), DeviceDiscriminatorOverrider)};
15411 std::string Buffer;
15412 Buffer.reserve(128);
15413 llvm::raw_string_ostream Out(Buffer);
15414 MC->mangleCanonicalTypeName(KernelNameType, Out);
15415 std::string KernelName = Out.str();
15417 return {KernelNameType, FD, KernelName};
15426 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15427 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15436 "SYCL kernel name conflict");
15451 return &IT->second;
15457 return *OMPTraitInfoVector.back();
15464 return DB << Section.
Decl;
15465 return DB <<
"a prior #pragma section";
15469 bool IsInternalVar =
15472 bool IsExplicitDeviceVar = (D->
hasAttr<CUDADeviceAttr>() &&
15473 !D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15474 (D->
hasAttr<CUDAConstantAttr>() &&
15475 !D->
getAttr<CUDAConstantAttr>()->isImplicit());
15479 return (IsInternalVar &&
15480 (D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15481 (D->
hasAttr<CUDAGlobalAttr>() &&
15488 (D->
hasAttr<HIPManagedAttr>() || D->
hasAttr<CUDAGlobalAttr>() ||
15493 if (!CUIDHash.empty())
15495 if (LangOpts.CUID.empty())
15496 return StringRef();
15497 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.CUID),
true);
15507 assert(PrimaryBase);
15510 auto Base = Layout.getPrimaryBase();
15511 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15513 PrimaryBase =
Base;
15515 return PrimaryBase;
15519 StringRef MangledName) {
15521 assert(
Method->isVirtual());
15522 bool DefaultIncludesPointerAuth =
15523 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15525 if (!DefaultIncludesPointerAuth)
15528 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15529 if (Existing != ThunksToBeAbbreviated.end())
15530 return Existing->second.contains(MangledName.str());
15533 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15535 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15537 for (
const auto &Thunk : *ThunkInfos) {
15539 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15545 Mangler->mangleThunk(
Method, Thunk,
true,
15548 llvm::raw_svector_ostream mangledNameStream(MangledName);
15552 mangledNameStream);
15554 Mangler->mangleThunk(
Method, Thunk,
false,
15555 mangledNameStream);
15557 Thunks[ElidedName].push_back(std::string(MangledName));
15560 llvm::StringSet<> SimplifiedThunkNames;
15561 for (
auto &ThunkList : Thunks) {
15562 llvm::sort(ThunkList.second);
15563 SimplifiedThunkNames.insert(ThunkList.second[0]);
15565 bool Result = SimplifiedThunkNames.contains(MangledName);
15566 ThunksToBeAbbreviated[VirtualMethodDecl] = std::move(SimplifiedThunkNames);
15584 std::vector<PFPField> &Fields,
bool IncludeVBases) {
15586 if (
auto *ElemDecl = AT->getElementType()->getAsCXXRecordDecl()) {
15588 for (
unsigned i = 0; i != AT->getSize(); ++i)
15605 Fields.push_back({FieldOffset, Field});
15612 if (
Base.isVirtual())
15619 if (IncludeVBases) {
15630 std::vector<PFPField> PFPFields;
15640 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->
getParent()))
15642 !FD->
hasAttr<NoFieldProtectionAttr>();
15647 auto *FD = dyn_cast<FieldDecl>(VD);
15670struct PaddingCalculator {
15671 PaddingCalculator(
const ASTContext &Ctx) : Ctx(Ctx) {}
15674 OccuppiedIntervals.clear();
15680 while (!Stack.empty()) {
15681 Data Current = Stack.back();
15685 MergeOccuppiedIntervals();
15688 llvm::SmallVector<ASTContext::BitInterval> GetPaddingIntervals() {
15689 llvm::SmallVector<ASTContext::BitInterval> Results;
15690 if (OccuppiedIntervals.size() == 1 &&
15691 OccuppiedIntervals.front().First == 0 &&
15692 OccuppiedIntervals.front().Last == TySizeInBits) {
15695 Results.reserve(OccuppiedIntervals.size() + 1);
15697 for (
const ASTContext::BitInterval &OccupiedInterval : OccuppiedIntervals) {
15698 if (OccupiedInterval.First > CurrentPos) {
15700 ASTContext::BitInterval{CurrentPos, OccupiedInterval.First});
15702 CurrentPos = OccupiedInterval.Last;
15704 if (TySizeInBits > CurrentPos) {
15705 Results.push_back(ASTContext::BitInterval{CurrentPos, TySizeInBits});
15714 bool VisitVirtualBase;
15740 uint64_t getScalarOccupiedSizeInBits(QualType Ty)
const {
15741 if (
const auto *BIT = Ty->
getAs<BitIntType>())
15742 return BIT->getNumBits();
15744 if (
const auto *BT = Ty->
getAs<BuiltinType>()) {
15745 if (BT->getKind() == BuiltinType::LongDouble &&
15747 &llvm::APFloat::x87DoubleExtended())
15748 return llvm::APFloat::getSizeInBits(
15755 void Visit(
const Data &D) {
15756 if (
auto *AT = dyn_cast<ConstantArrayType>(D.Ty)) {
15757 VisitArray(AT, D.StartBitOffset);
15761 if (
auto *
Record = D.Ty->getAsRecordDecl()) {
15762 VisitStruct(
Record, D.StartBitOffset, D.VisitVirtualBase);
15766 if (D.Ty->isAtomicType()) {
15767 auto Unwrapped = D;
15768 Unwrapped.Ty = D.Ty.getAtomicUnqualifiedType().getCanonicalType();
15769 Stack.push_back(Unwrapped);
15773 if (
const auto *
Complex = D.Ty->getAs<ComplexType>()) {
15774 VisitComplex(
Complex, D.StartBitOffset);
15778 if (
const auto *VT = D.Ty->getAs<clang::VectorType>()) {
15779 VisitVector(VT, D.StartBitOffset);
15783 if (
const auto *BITy = D.Ty->getAs<BitIntType>()) {
15784 VisitBitInt(BITy, D.StartBitOffset);
15788 uint64_t SizeBit = getScalarOccupiedSizeInBits(D.Ty);
15789 OccuppiedIntervals.push_back(
15790 ASTContext::BitInterval{D.StartBitOffset, D.StartBitOffset + SizeBit});
15793 void VisitArray(
const ConstantArrayType *AT, uint64_t StartBitOffset) {
15794 for (uint64_t ArrIndex = 0; ArrIndex < AT->
getSize().getLimitedValue();
15800 auto Offset = ElementSize.
alignTo(ElementAlign);
15802 Stack.push_back(
Data{
15803 StartBitOffset + ArrIndex * Offset.getQuantity() * Ctx.
getCharWidth(),
15808 void VisitStruct(
const RecordDecl *R, uint64_t StartBitOffset,
15809 bool VisitVirtualBase) {
15811 auto *
CXXRecord = dyn_cast<CXXRecordDecl>(R);
15817 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15818 StartBitOffset, StartBitOffset + PointerSizeInBits});
15823 auto StartVBPtr = StartBitOffset + Offset * Ctx.
getCharWidth();
15824 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15825 StartVBPtr, StartVBPtr + PointerSizeInBits});
15828 const auto VisitBase = [&ASTLayout, StartBitOffset,
this](
15829 const CXXBaseSpecifier &
Base,
auto GetOffset) {
15830 auto *BaseRecord =
Base.getType()->getAsCXXRecordDecl();
15835 std::invoke(GetOffset, ASTLayout, BaseRecord).getQuantity();
15839 Base.getType().getCanonicalType(),
15844 if (!
Base.isVirtual()) {
15849 if (VisitVirtualBase) {
15850 for (
auto VBase :
CXXRecord->vbases()) {
15856 for (
auto *Field :
R->fields()) {
15858 if (
Field->isUnnamedBitField())
15862 if (
Field->isBitField()) {
15863 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15864 StartBitOffset + FieldOffset,
15865 StartBitOffset + FieldOffset +
Field->getBitWidthValue()});
15867 Stack.push_back(
Data{StartBitOffset + FieldOffset,
15868 Field->getType().getCanonicalType(),
15874 void VisitComplex(
const ComplexType *CT, uint64_t StartBitOffset) {
15878 auto ImgOffset = ElementSize.
alignTo(ElementAlign);
15881 Data{StartBitOffset, ElementQualType,
true});
15884 ElementQualType,
true});
15887 void VisitVector(
const clang::VectorType *VT, uint64_t StartBitOffset) {
15888 uint64_t SizeBit = [&]() -> uint64_t {
15894 OccuppiedIntervals.push_back(
15895 ASTContext::BitInterval{StartBitOffset, StartBitOffset + SizeBit});
15903 void VisitBitInt(
const BitIntType *Ty, uint64_t StartBitOffset) {
15907 OccuppiedIntervals.push_back(
15908 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
15920 const uint64_t NumFullyPaddingBytes =
15921 (StorageSizeInBits - OccupiedSizeInBits) / CharWidth;
15922 const uint64_t NumFullyOccupiedBytes = OccupiedSizeInBits / CharWidth;
15923 const uint64_t NumRemainingOccupiedBits = OccupiedSizeInBits % CharWidth;
15926 if (NumRemainingOccupiedBits > 0)
15927 OccuppiedIntervals.push_back(
15928 {StartBitOffset + NumFullyPaddingBytes * CharWidth,
15929 StartBitOffset + NumFullyPaddingBytes * CharWidth +
15930 NumRemainingOccupiedBits});
15933 if (NumFullyOccupiedBytes > 0)
15934 OccuppiedIntervals.push_back({StartBitOffset + StorageSizeInBits -
15935 NumFullyOccupiedBytes * CharWidth,
15936 StartBitOffset + StorageSizeInBits});
15939 void MergeOccuppiedIntervals() {
15940 std::sort(OccuppiedIntervals.begin(), OccuppiedIntervals.end(),
15941 [](
const ASTContext::BitInterval &lhs,
15942 const ASTContext::BitInterval &rhs) {
15943 return std::tie(lhs.First, lhs.Last) <
15944 std::tie(rhs.First, rhs.Last);
15947 llvm::SmallVector<ASTContext::BitInterval> Merged;
15948 Merged.reserve(OccuppiedIntervals.size());
15950 for (
const ASTContext::BitInterval &NextInterval : OccuppiedIntervals) {
15951 if (Merged.empty()) {
15952 Merged.push_back(NextInterval);
15955 auto &LastInterval = Merged.back();
15957 if (NextInterval.First > LastInterval.Last) {
15958 Merged.push_back(NextInterval);
15960 LastInterval.Last = std::max(LastInterval.Last, NextInterval.Last);
15964 OccuppiedIntervals = Merged;
15967 const ASTContext &Ctx;
15970 llvm::SmallVector<Data> Stack;
15971 llvm::SmallVector<ASTContext::BitInterval> OccuppiedIntervals;
15975llvm::ArrayRef<ASTContext::BitInterval>
15978 auto cached = PaddingIntervalCache.find(Ty);
15979 if (cached != PaddingIntervalCache.end())
15980 return cached->second;
15982 PaddingCalculator pc{*
this};
15986 PaddingIntervalCache.insert_or_assign(Ty, pc.GetPaddingIntervals());
15987 assert(res &&
"Failed to insert?");
15989 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)
#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 std::string charUnitsToString(const CharUnits &CU)
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 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)
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.
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
MemberSpecializationInfo * getInstantiatedFromStaticDataMember(const VarDecl *Var)
If this variable is an instantiated static data member of a class template specialization,...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
CanQualType ARCUnbridgedCastTy
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, QualType Wrapped) const
llvm::DenseMap< const Decl *, comments::FullComment * > ParsedComments
Mapping from declarations to parsed comments attached to any redeclaration.
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
unsigned getIntWidth(QualType T) const
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
InlineVariableDefinitionKind
@ None
Not an inline variable.
@ Weak
Weak definition of inline variable.
@ Strong
Strong definition.
@ WeakUnknown
Weak for now, might become strong later in this TU.
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
TypedefDecl * getCFConstantStringDecl() const
CanQualType SatUnsignedFractTy
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
ExternCContextDecl * getExternCContextDecl() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
CanQualType UnsignedShortAccumTy
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
bool isPFPField(const FieldDecl *Field) const
QualType adjustFunctionResultType(QualType FunctionType, QualType NewResultType)
Change the result type of a function type, preserving sugar such as attributed types.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
QualType getCanonicalTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
QualType 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...
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
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
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...
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
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
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.
bool isUnaryOverflowPatternExcluded(const UnaryOperator *UO)
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
TemplateName getDeducedTemplateName(TemplateName Underlying, DefaultArguments DefaultArgs) const
Represents a TemplateName which had some of its default arguments deduced.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
CanQualType UnsignedAccumTy
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
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.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isPositive() const
isPositive - Test whether the quantity is greater than zero.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CharUnits alignTo(const CharUnits &Align) const
alignTo - Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is ...
static CharUnits Zero()
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.
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
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.
@ 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)
@ 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