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();
991 LastDeclAttrsDecl =
nullptr;
993 CtorClosureDefaultArgs.clear();
995 for (
const auto &
Value : ModuleInitializers)
996 Value.second->~PerModuleInitializers();
997 ModuleInitializers.
clear();
1001 NoSanitizeL.reset();
1007 TraversalScope = TopLevelDecls;
1021 llvm::errs() <<
"\n*** AST Context Stats:\n";
1022 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
1024 unsigned counts[] = {
1025#define TYPE(Name, Parent) 0,
1026#define ABSTRACT_TYPE(Name, Parent)
1027#include "clang/AST/TypeNodes.inc"
1031 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
1037 unsigned TotalBytes = 0;
1038#define TYPE(Name, Parent) \
1040 llvm::errs() << " " << counts[Idx] << " " << #Name \
1041 << " types, " << sizeof(Name##Type) << " each " \
1042 << "(" << counts[Idx] * sizeof(Name##Type) \
1044 TotalBytes += counts[Idx] * sizeof(Name##Type); \
1046#define ABSTRACT_TYPE(Name, Parent)
1047#include "clang/AST/TypeNodes.inc"
1049 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
1054 <<
" implicit default constructors created\n";
1057 <<
" implicit copy constructors created\n";
1061 <<
" implicit move constructors created\n";
1064 <<
" implicit copy assignment operators created\n";
1068 <<
" implicit move assignment operators created\n";
1071 <<
" implicit destructors created\n";
1074 llvm::errs() <<
"\n";
1078 BumpAlloc.PrintStats();
1082 bool NotifyListeners) {
1083 if (NotifyListeners)
1086 Listener->RedefinedHiddenDefinition(ND, M);
1093 if (It == MergedDefModules.end())
1096 auto &Merged = It->second;
1097 llvm::DenseSet<Module*>
Found;
1098 for (
Module *&M : Merged)
1099 if (!
Found.insert(M).second)
1101 llvm::erase(Merged,
nullptr);
1108 if (MergedIt == MergedDefModules.end())
1110 return MergedIt->second;
1113void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1114 if (LazyInitializers.empty())
1118 assert(Source &&
"lazy initializers but no external source");
1120 auto LazyInits = std::move(LazyInitializers);
1121 LazyInitializers.clear();
1123 for (
auto ID : LazyInits)
1124 Initializers.push_back(Source->GetExternalDecl(ID));
1126 assert(LazyInitializers.empty() &&
1127 "GetExternalDecl for lazy module initializer added more inits");
1133 if (
const auto *ID = dyn_cast<ImportDecl>(D)) {
1134 auto It = ModuleInitializers.find(ID->getImportedModule());
1137 if (It == ModuleInitializers.end())
1141 auto &Imported = *It->second;
1142 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1143 Imported.resolve(*
this);
1144 auto *OnlyDecl = Imported.Initializers.front();
1150 auto *&
Inits = ModuleInitializers[M];
1152 Inits =
new (*this) PerModuleInitializers;
1153 Inits->Initializers.push_back(D);
1158 auto *&
Inits = ModuleInitializers[M];
1160 Inits =
new (*this) PerModuleInitializers;
1161 Inits->LazyInitializers.insert(
Inits->LazyInitializers.end(),
1162 IDs.begin(), IDs.end());
1166 auto It = ModuleInitializers.find(M);
1167 if (It == ModuleInitializers.end())
1170 auto *
Inits = It->second;
1171 Inits->resolve(*
this);
1172 return Inits->Initializers;
1177 assert(!CurrentCXXNamedModule &&
1178 "We should set named module for ASTContext for only once");
1179 CurrentCXXNamedModule = M;
1191 auto GetRepresentativeModule = [
this](
const Module *M) {
1192 auto Iter = SameModuleLookupSet.find(M);
1193 if (Iter != SameModuleLookupSet.end())
1194 return Iter->second;
1196 const Module *RepresentativeModule =
1197 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1199 SameModuleLookupSet[M] = RepresentativeModule;
1200 return RepresentativeModule;
1203 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1204 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1208 if (!ExternCContext)
1211 return ExternCContext;
1225#define BuiltinTemplate(BTName) \
1226 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1227 if (!Decl##BTName) \
1229 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1230 return Decl##BTName; \
1232#include "clang/Basic/BuiltinTemplates.inc"
1245 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1246 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1251 StringRef Name)
const {
1275 Types.push_back(Ty);
1280 assert((!this->Target || this->Target == &Target) &&
1281 "Incorrect target reinitialization");
1282 assert(
VoidTy.isNull() &&
"Context reinitialized?");
1284 this->Target = &Target;
1285 this->AuxTarget = AuxTarget;
1287 ABI.reset(createCXXABI(Target));
1291 InitBuiltinType(
VoidTy, BuiltinType::Void);
1294 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1296 if (LangOpts.CharIsSigned)
1297 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1299 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1302 InitBuiltinType(
ShortTy, BuiltinType::Short);
1303 InitBuiltinType(
IntTy, BuiltinType::Int);
1304 InitBuiltinType(
LongTy, BuiltinType::Long);
1305 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1315 InitBuiltinType(
FloatTy, BuiltinType::Float);
1316 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1317 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1320 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1323 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1326 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1329 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1330 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1331 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1335 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1336 InitBuiltinType(
FractTy, BuiltinType::Fract);
1337 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1342 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1348 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1355 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1360 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1362 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1363 if (LangOpts.CPlusPlus && LangOpts.WChar)
1367 WideCharTy = getFromTargetType(Target.getWCharType());
1370 WIntTy = getFromTargetType(Target.getWIntType());
1373 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1375 if (LangOpts.CPlusPlus)
1376 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1378 Char16Ty = getFromTargetType(Target.getChar16Type());
1380 if (LangOpts.CPlusPlus)
1381 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1383 Char32Ty = getFromTargetType(Target.getChar32Type());
1390 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1393 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1405 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1411 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1414 if (LangOpts.OpenMP) {
1421 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1424 if (LangOpts.MatrixTypes)
1432 if (LangOpts.OpenCL) {
1433#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1434 InitBuiltinType(SingletonId, BuiltinType::Id);
1435#include "clang/Basic/OpenCLImageTypes.def"
1437 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1438 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1440 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1443#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1444 InitBuiltinType(Id##Ty, BuiltinType::Id);
1445#include "clang/Basic/OpenCLExtensionTypes.def"
1448 if (LangOpts.HLSL) {
1449#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1450 InitBuiltinType(SingletonId, BuiltinType::Id);
1451#include "clang/Basic/HLSLIntangibleTypes.def"
1454 if (Target.hasAArch64ACLETypes() ||
1455 (AuxTarget && AuxTarget->hasAArch64ACLETypes())) {
1456#define SVE_TYPE(Name, Id, SingletonId) \
1457 InitBuiltinType(SingletonId, BuiltinType::Id);
1458#include "clang/Basic/AArch64ACLETypes.def"
1461 if (Target.getTriple().isPPC64()) {
1462#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1463 InitBuiltinType(Id##Ty, BuiltinType::Id);
1464#include "clang/Basic/PPCTypes.def"
1465#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1466 InitBuiltinType(Id##Ty, BuiltinType::Id);
1467#include "clang/Basic/PPCTypes.def"
1470 if (Target.hasRISCVVTypes()) {
1471#define RVV_TYPE(Name, Id, SingletonId) \
1472 InitBuiltinType(SingletonId, BuiltinType::Id);
1473#include "clang/Basic/RISCVVTypes.def"
1476 if (Target.getTriple().isWasm() && Target.hasFeature(
"reference-types")) {
1477#define WASM_TYPE(Name, Id, SingletonId) \
1478 InitBuiltinType(SingletonId, BuiltinType::Id);
1479#include "clang/Basic/WebAssemblyReferenceTypes.def"
1482 if (Target.hasAMDGPUTypes() || (AuxTarget && (AuxTarget->hasAMDGPUTypes()))) {
1483#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1484 InitBuiltinType(SingletonId, BuiltinType::Id);
1485#include "clang/Basic/AMDGPUTypes.def"
1488 if (Target.getTriple().isSPIRV() ||
1489 (AuxTarget && AuxTarget->getTriple().isSPIRV())) {
1490#define SPIRV_TYPE(Name, Id, SingletonId) \
1491 InitBuiltinType(SingletonId, BuiltinType::Id);
1492#include "clang/Basic/SPIRVTypes.def"
1499 ObjCConstantStringType =
QualType();
1504 if (LangOpts.OpenCLGenericAddressSpace) {
1505 auto Q =
VoidTy.getQualifiers();
1514 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1517 InitBuiltinType(
HalfTy, BuiltinType::Half);
1519 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1525 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1532 return SourceMgr.getDiagnostics();
1537 if (LastDeclAttrsDecl == D) {
1538 assert(LastDeclAttrs !=
nullptr && LastDeclAttrs == DeclAttrs[D]);
1539 return *LastDeclAttrs;
1548 LastDeclAttrsDecl = D;
1555 llvm::DenseMap<const Decl*, AttrVec*>::iterator Pos = DeclAttrs.find(D);
1556 if (Pos != DeclAttrs.end()) {
1557 Pos->second->~AttrVec();
1558 DeclAttrs.erase(Pos);
1560 if (LastDeclAttrsDecl == D)
1561 LastDeclAttrsDecl =
nullptr;
1566 return CtorClosureDefaultArgs.lookup(CD);
1571 assert(!CtorClosureDefaultArgs.contains(CD));
1572 CtorClosureDefaultArgs[CD] = Args;
1579 if (It != ExplicitInstantiations.end())
1600 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1601 TemplateOrInstantiation.find(Var);
1602 if (Pos == TemplateOrInstantiation.end())
1615 Tmpl, TSK, PointOfInstantiation));
1621 assert(!TemplateOrInstantiation[Inst] &&
1622 "Already noted what the variable was instantiated from");
1623 TemplateOrInstantiation[Inst] = TSI;
1628 return InstantiatedFromUsingDecl.lookup(UUD);
1636 "pattern decl is not a using decl");
1640 "instantiation did not produce a using decl");
1641 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1642 InstantiatedFromUsingDecl[Inst] = Pattern;
1647 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1652 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1653 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1658 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1664 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1665 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1670 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1676 "Instantiated field decl is not unnamed");
1678 "Template field decl is not unnamed");
1679 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1680 "Already noted what unnamed field was instantiated from");
1682 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1698 return Range.end() - Range.begin();
1703 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1704 OverriddenMethods.find(
Method->getCanonicalDecl());
1705 if (Pos == OverriddenMethods.end())
1713 OverriddenMethods[
Method].push_back(Overridden);
1721 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1727 const auto *
Method = dyn_cast<ObjCMethodDecl>(D);
1732 Method->getOverriddenMethods(OverDecls);
1733 Overridden.append(OverDecls.begin(), OverDecls.end());
1736std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1740 auto it = RelocatableClasses.find(D);
1741 if (it != RelocatableClasses.end())
1742 return it->getSecond();
1743 return std::nullopt;
1750 assert(RelocatableClasses.find(D) == RelocatableClasses.end());
1751 RelocatableClasses.insert({D, Info});
1756 if (!Class->isPolymorphic())
1758 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
1759 using AuthAttr = VTablePointerAuthenticationAttr;
1760 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1762 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1763 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1764 ExplicitAuth->getAddressDiscrimination();
1765 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1766 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1767 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1770ASTContext::PointerAuthContent
1771ASTContext::findPointerAuthContent(QualType
T)
const {
1772 assert(isPointerAuthenticationAvailable());
1774 T =
T.getCanonicalType();
1776 return PointerAuthContent::None;
1778 if (
T.hasAddressDiscriminatedPointerAuth())
1779 return PointerAuthContent::AddressDiscriminatedData;
1782 return PointerAuthContent::None;
1785 return PointerAuthContent::None;
1787 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1788 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1789 return Existing->second;
1791 PointerAuthContent
Result = PointerAuthContent::None;
1793 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1794 auto [ResultIter, DidAdd] =
1795 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1801 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1802 static_assert(PointerAuthContent::None <
1803 PointerAuthContent::AddressDiscriminatedVTable);
1804 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1805 PointerAuthContent::AddressDiscriminatedData);
1808 return Result != PointerAuthContent::AddressDiscriminatedData;
1810 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1812 !ShouldContinueAfterUpdate(
1813 PointerAuthContent::AddressDiscriminatedVTable))
1814 return SaveResultAndReturn();
1815 for (
auto Base : CXXRD->bases()) {
1816 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1817 return SaveResultAndReturn();
1820 for (
auto *FieldDecl : RD->
fields()) {
1821 if (!ShouldContinueAfterUpdate(
1822 findPointerAuthContent(FieldDecl->getType())))
1823 return SaveResultAndReturn();
1825 return SaveResultAndReturn();
1829 assert(!Import->getNextLocalImport() &&
1830 "Import declaration already in the chain");
1831 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1832 if (!FirstLocalImport) {
1833 FirstLocalImport = Import;
1834 LastLocalImport = Import;
1838 LastLocalImport->setNextLocalImport(Import);
1839 LastLocalImport = Import;
1851 llvm_unreachable(
"Not a floating point type!");
1852 case BuiltinType::BFloat16:
1853 return Target->getBFloat16Format();
1854 case BuiltinType::Float16:
1855 return Target->getHalfFormat();
1856 case BuiltinType::Half:
1857 return Target->getHalfFormat();
1858 case BuiltinType::Float:
return Target->getFloatFormat();
1859 case BuiltinType::Double:
return Target->getDoubleFormat();
1860 case BuiltinType::Ibm128:
1861 return Target->getIbm128Format();
1862 case BuiltinType::LongDouble:
1864 return AuxTarget->getLongDoubleFormat();
1865 return Target->getLongDoubleFormat();
1866 case BuiltinType::Float128:
1868 return AuxTarget->getFloat128Format();
1869 return Target->getFloat128Format();
1874 unsigned Align = Target->getCharWidth();
1878 Align = AlignFromAttr;
1886 bool UseAlignAttrOnly;
1887 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1889 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1891 UseAlignAttrOnly = AlignFromAttr != 0;
1894 if (UseAlignAttrOnly) {
1896 }
else if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
1900 T = RT->getPointeeType();
1905 if (
T->isFunctionType())
1906 Align = getTypeInfoImpl(
T.getTypePtr()).Align;
1911 unsigned MinWidth = Target->getLargeArrayMinWidth();
1912 if (!ForAlignof && MinWidth) {
1914 Align = std::max(Align, Target->getLargeArrayAlign());
1917 Align = std::max(Align, Target->getLargeArrayAlign());
1922 Align = Target->getCharWidth();
1926 if (
const auto *VD = dyn_cast<VarDecl>(D))
1927 if (VD->hasGlobalStorage() && !ForAlignof) {
1938 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1952 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1953 if (LowBitOfOffset < FieldAlign)
1954 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1957 Align = std::min(Align, FieldAlign);
1965 const auto *VD = dyn_cast<VarDecl>(D);
1966 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1967 Align = std::min(Align, MaxAlignedAttr);
1987 if (
const auto *RD =
T->getAsCXXRecordDecl(); RD && !RD->
isInvalidDecl()) {
2004 (uint64_t)(-1)/Size) &&
2005 "Overflow in array type char size evaluation");
2008 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
2010 Width = llvm::alignTo(Width, Align);
2017 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2035 switch (BT->getKind()) {
2036 case BuiltinType::Bool:
2037 case BuiltinType::Char_S:
2038 case BuiltinType::Char_U:
2039 case BuiltinType::SChar:
2040 case BuiltinType::UChar:
2041 case BuiltinType::Short:
2042 case BuiltinType::UShort:
2043 case BuiltinType::WChar_S:
2044 case BuiltinType::WChar_U:
2045 case BuiltinType::Char8:
2046 case BuiltinType::Char16:
2047 case BuiltinType::Char32:
2055 if (
const auto *ED =
T->getAsEnumDecl()) {
2056 if (
T->isDependentType() || ED->getPromotionType().isNull() ||
2064 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>()) {
2080 bool NeedsPreferredAlignment)
const {
2083 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2088 if (!
T->isIncompleteType())
2094 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2098 if (
const auto *TD =
T->getAsTagDecl())
2099 return TD->getMaxAlignment();
2105 TypeInfoMap::iterator I = MemoizedTypeInfo.find(
T);
2106 if (I != MemoizedTypeInfo.end())
2111 MemoizedTypeInfo[
T] = TI;
2126 switch (
T->getTypeClass()) {
2127#define TYPE(Class, Base)
2128#define ABSTRACT_TYPE(Class, Base)
2129#define NON_CANONICAL_TYPE(Class, Base)
2130#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2131#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
2133 assert(!T->isDependentType() && "should not see dependent types here"); \
2134 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
2135#include "clang/AST/TypeNodes.inc"
2136 llvm_unreachable(
"Should not see dependent types");
2138 case Type::FunctionNoProto:
2139 case Type::FunctionProto:
2145 case Type::IncompleteArray:
2146 case Type::VariableArray:
2147 case Type::ConstantArray:
2148 case Type::ArrayParameter: {
2151 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2152 Size = CAT->getZExtSize();
2155 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2156 "Overflow in array type bit size evaluation");
2157 Width = EltInfo.
Width * Size;
2158 Align = EltInfo.
Align;
2162 Width = llvm::alignTo(Width, Align);
2166 case Type::ExtVector:
2167 case Type::Vector: {
2170 Width = VT->isPackedVectorBoolType(*
this)
2171 ? VT->getNumElements()
2172 : EltInfo.
Width * VT->getNumElements();
2174 Width = std::max<unsigned>(8, Width);
2175 Align = std::max<unsigned>(
2176 8,
Target->vectorsAreElementAligned() ? EltInfo.
Width : Width);
2180 if (Align & (Align-1)) {
2181 Align = llvm::bit_ceil(Align);
2182 Width = llvm::alignTo(Width, Align);
2185 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
2186 if (TargetVectorAlign && TargetVectorAlign < Align)
2187 Align = TargetVectorAlign;
2201 Align = std::min<unsigned>(64, Width);
2205 case Type::ConstantMatrix: {
2207 TypeInfo ElementInfo =
getTypeInfo(MT->getElementType());
2211 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2212 Align = ElementInfo.
Align;
2218 default: llvm_unreachable(
"Unknown builtin type!");
2219 case BuiltinType::Void:
2224 case BuiltinType::Bool:
2225 Width = Target->getBoolWidth();
2226 Align = Target->getBoolAlign();
2228 case BuiltinType::Char_S:
2229 case BuiltinType::Char_U:
2230 case BuiltinType::UChar:
2231 case BuiltinType::SChar:
2232 case BuiltinType::Char8:
2233 Width = Target->getCharWidth();
2234 Align = Target->getCharAlign();
2236 case BuiltinType::WChar_S:
2237 case BuiltinType::WChar_U:
2238 Width = Target->getWCharWidth();
2239 Align = Target->getWCharAlign();
2241 case BuiltinType::Char16:
2242 Width = Target->getChar16Width();
2243 Align = Target->getChar16Align();
2245 case BuiltinType::Char32:
2246 Width = Target->getChar32Width();
2247 Align = Target->getChar32Align();
2249 case BuiltinType::UShort:
2250 case BuiltinType::Short:
2251 Width = Target->getShortWidth();
2252 Align = Target->getShortAlign();
2254 case BuiltinType::UInt:
2255 case BuiltinType::Int:
2256 Width = Target->getIntWidth();
2257 Align = Target->getIntAlign();
2259 case BuiltinType::ULong:
2260 case BuiltinType::Long:
2261 Width = Target->getLongWidth();
2262 Align = Target->getLongAlign();
2264 case BuiltinType::ULongLong:
2265 case BuiltinType::LongLong:
2266 Width = Target->getLongLongWidth();
2267 Align = Target->getLongLongAlign();
2269 case BuiltinType::Int128:
2270 case BuiltinType::UInt128:
2272 Align = Target->getInt128Align();
2274 case BuiltinType::ShortAccum:
2275 case BuiltinType::UShortAccum:
2276 case BuiltinType::SatShortAccum:
2277 case BuiltinType::SatUShortAccum:
2278 Width = Target->getShortAccumWidth();
2279 Align = Target->getShortAccumAlign();
2281 case BuiltinType::Accum:
2282 case BuiltinType::UAccum:
2283 case BuiltinType::SatAccum:
2284 case BuiltinType::SatUAccum:
2285 Width = Target->getAccumWidth();
2286 Align = Target->getAccumAlign();
2288 case BuiltinType::LongAccum:
2289 case BuiltinType::ULongAccum:
2290 case BuiltinType::SatLongAccum:
2291 case BuiltinType::SatULongAccum:
2292 Width = Target->getLongAccumWidth();
2293 Align = Target->getLongAccumAlign();
2295 case BuiltinType::ShortFract:
2296 case BuiltinType::UShortFract:
2297 case BuiltinType::SatShortFract:
2298 case BuiltinType::SatUShortFract:
2299 Width = Target->getShortFractWidth();
2300 Align = Target->getShortFractAlign();
2302 case BuiltinType::Fract:
2303 case BuiltinType::UFract:
2304 case BuiltinType::SatFract:
2305 case BuiltinType::SatUFract:
2306 Width = Target->getFractWidth();
2307 Align = Target->getFractAlign();
2309 case BuiltinType::LongFract:
2310 case BuiltinType::ULongFract:
2311 case BuiltinType::SatLongFract:
2312 case BuiltinType::SatULongFract:
2313 Width = Target->getLongFractWidth();
2314 Align = Target->getLongFractAlign();
2316 case BuiltinType::BFloat16:
2317 if (Target->hasBFloat16Type()) {
2318 Width = Target->getBFloat16Width();
2319 Align = Target->getBFloat16Align();
2323 AuxTarget->hasBFloat16Type()) {
2324 Width = AuxTarget->getBFloat16Width();
2325 Align = AuxTarget->getBFloat16Align();
2328 case BuiltinType::Float16:
2329 case BuiltinType::Half:
2330 if (Target->hasFloat16Type() || !
getLangOpts().OpenMP ||
2332 Width = Target->getHalfWidth();
2333 Align = Target->getHalfAlign();
2336 "Expected OpenMP device compilation.");
2337 Width = AuxTarget->getHalfWidth();
2338 Align = AuxTarget->getHalfAlign();
2341 case BuiltinType::Float:
2342 Width = Target->getFloatWidth();
2343 Align = Target->getFloatAlign();
2345 case BuiltinType::Double:
2346 Width = Target->getDoubleWidth();
2347 Align = Target->getDoubleAlign();
2349 case BuiltinType::Ibm128:
2350 Width = Target->getIbm128Width();
2351 Align = Target->getIbm128Align();
2353 case BuiltinType::LongDouble:
2355 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2356 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2357 Width = AuxTarget->getLongDoubleWidth();
2358 Align = AuxTarget->getLongDoubleAlign();
2360 Width = Target->getLongDoubleWidth();
2361 Align = Target->getLongDoubleAlign();
2364 case BuiltinType::Float128:
2365 if (Target->hasFloat128Type() || !
getLangOpts().OpenMP ||
2367 Width = Target->getFloat128Width();
2368 Align = Target->getFloat128Align();
2371 "Expected OpenMP device compilation.");
2372 Width = AuxTarget->getFloat128Width();
2373 Align = AuxTarget->getFloat128Align();
2376 case BuiltinType::NullPtr:
2381 case BuiltinType::ObjCId:
2382 case BuiltinType::ObjCClass:
2383 case BuiltinType::ObjCSel:
2387 case BuiltinType::OCLSampler:
2388 case BuiltinType::OCLEvent:
2389 case BuiltinType::OCLClkEvent:
2390 case BuiltinType::OCLQueue:
2391 case BuiltinType::OCLReserveID:
2392#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2393 case BuiltinType::Id:
2394#include "clang/Basic/OpenCLImageTypes.def"
2395#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2396 case BuiltinType::Id:
2397#include "clang/Basic/OpenCLExtensionTypes.def"
2399 Width = Target->getPointerWidth(AS);
2400 Align = Target->getPointerAlign(AS);
2410#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2411 case BuiltinType::Id: \
2415#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2416 case BuiltinType::Id: \
2420#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2421 case BuiltinType::Id: \
2425#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2426 case BuiltinType::Id: \
2430#include "clang/Basic/AArch64ACLETypes.def"
2431#define PPC_VECTOR_TYPE(Name, Id, Size) \
2432 case BuiltinType::Id: \
2436#include "clang/Basic/PPCTypes.def"
2437#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2439 case BuiltinType::Id: \
2443#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2444 case BuiltinType::Id: \
2448#include "clang/Basic/RISCVVTypes.def"
2449#define WASM_TYPE(Name, Id, SingletonId) \
2450 case BuiltinType::Id: \
2454#include "clang/Basic/WebAssemblyReferenceTypes.def"
2455#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2456 case BuiltinType::ID: \
2460#include "clang/Basic/AMDGPUTypes.def"
2461#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2462#include "clang/Basic/HLSLIntangibleTypes.def"
2466#define SPIRV_TYPE(Name, Id, SingletonId) \
2467 case BuiltinType::Id: \
2468 Width = Target->getPointerWidth(LangAS::Default); \
2469 Align = Target->getPointerAlign(LangAS::Default); \
2471#include "clang/Basic/SPIRVTypes.def"
2474 case Type::ObjCObjectPointer:
2478 case Type::BlockPointer:
2480 Width = Target->getPointerWidth(AS);
2481 Align = Target->getPointerAlign(AS);
2483 case Type::LValueReference:
2484 case Type::RValueReference:
2488 Width = Target->getPointerWidth(AS);
2489 Align = Target->getPointerAlign(AS);
2493 Width = Target->getPointerWidth(AS);
2494 Align = Target->getPointerAlign(AS);
2496 case Type::MemberPointer: {
2498 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2503 case Type::Complex: {
2507 Width = EltInfo.
Width * 2;
2508 Align = EltInfo.
Align;
2511 case Type::ObjCObject:
2513 case Type::Adjusted:
2516 case Type::ObjCInterface: {
2518 if (ObjCI->getDecl()->isInvalidDecl()) {
2528 case Type::BitInt: {
2530 Align = Target->getBitIntAlign(EIT->getNumBits());
2531 Width = Target->getBitIntWidth(EIT->getNumBits());
2537 const TagDecl *TD = TT->getDecl()->getDefinitionOrSelf();
2550 Info.
Align = AttrAlign;
2560 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2566 case Type::SubstTemplateTypeParm:
2568 getReplacementType().getTypePtr());
2571 case Type::DeducedTemplateSpecialization: {
2573 assert(!A->getDeducedType().isNull() &&
2574 "cannot request the size of an undeduced or dependent auto type");
2575 return getTypeInfo(A->getDeducedType().getTypePtr());
2581 case Type::MacroQualified:
2585 case Type::ObjCTypeParam:
2591 case Type::Typedef: {
2593 TypeInfo Info =
getTypeInfo(TT->desugar().getTypePtr());
2597 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2608 case Type::Attributed:
2612 case Type::CountAttributed:
2615 case Type::LateParsedAttr:
2618 case Type::BTFTagAttributed:
2622 case Type::OverflowBehavior:
2626 case Type::HLSLAttributedResource:
2630 case Type::HLSLInlineSpirv: {
2633 Width = ST->getSize() * 8;
2634 Align = ST->getAlignment();
2635 if (Width == 0 && Align == 0) {
2643 case Type::Atomic: {
2652 Width = Target->getCharWidth();
2654 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2660 Width = llvm::bit_ceil(Width);
2663 Align =
static_cast<unsigned>(Width);
2668 case Type::PredefinedSugar:
2677 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2678 return TypeInfo(Width, Align, AlignRequirement);
2682 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(
T);
2683 if (I != MemoizedUnadjustedAlign.end())
2686 unsigned UnadjustedAlign;
2687 if (
const auto *RT =
T->getAsCanonical<RecordType>()) {
2694 UnadjustedAlign =
getTypeAlign(
T->getUnqualifiedDesugaredType());
2697 MemoizedUnadjustedAlign[
T] = UnadjustedAlign;
2698 return UnadjustedAlign;
2702 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2752 unsigned ABIAlign = TI.
Align;
2754 T =
T->getBaseElementTypeUnsafe();
2757 if (
T->isMemberPointerType())
2760 if (!Target->allowsLargerPreferedTypeAlignment())
2763 if (
const auto *RD =
T->getAsRecordDecl()) {
2772 unsigned PreferredAlign =
static_cast<unsigned>(
2774 assert(PreferredAlign >= ABIAlign &&
2775 "PreferredAlign should be at least as large as ABIAlign.");
2776 return PreferredAlign;
2783 T = CT->getElementType().getTypePtr();
2784 if (
const auto *ED =
T->getAsEnumDecl())
2785 T = ED->getIntegerType().getTypePtr();
2786 if (
T->isSpecificBuiltinType(BuiltinType::Double) ||
2787 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2788 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2789 (
T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2790 Target->defaultsToAIXPowerAlignment()))
2845 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
2849 std::swap(
Base, Derived);
2869 llvm::append_range(Ivars, OI->
ivars());
2872 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2874 Ivars.push_back(Iv);
2882 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2885 for (
auto *Proto : OI->all_referenced_protocols()) {
2890 for (
const auto *Cat : OI->visible_categories())
2896 SD = SD->getSuperClass();
2898 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2899 for (
auto *Proto : OC->protocols()) {
2902 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2904 if (!Protocols.insert(
2908 for (
auto *Proto : OP->protocols())
2915 bool CheckIfTriviallyCopyable) {
2916 assert(RD->
isUnion() &&
"Must be union type");
2918 Context.getTypeSizeInChars(Context.getCanonicalTagType(RD));
2920 for (
const auto *Field : RD->
fields()) {
2921 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2922 CheckIfTriviallyCopyable))
2924 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2925 if (FieldSize != UnionSize)
2934 return Context.getFieldOffset(Field);
2943static std::optional<int64_t>
2945 const RecordDecl *RD,
2946 bool CheckIfTriviallyCopyable);
2948static std::optional<int64_t>
2950 bool CheckIfTriviallyCopyable) {
2951 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2954 CheckIfTriviallyCopyable);
2958 bool IsBitIntType = Field->getType()->isBitIntType();
2959 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2960 !Context.hasUniqueObjectRepresentations(Field->getType(),
2961 CheckIfTriviallyCopyable))
2962 return std::nullopt;
2964 int64_t FieldSizeInBits =
2965 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2966 if (Field->isBitField()) {
2969 if (Field->isUnnamedBitField())
2972 int64_t BitfieldSize = Field->getBitWidthValue();
2974 if ((
unsigned)BitfieldSize >
2976 return std::nullopt;
2977 }
else if (BitfieldSize > FieldSizeInBits) {
2978 return std::nullopt;
2980 FieldSizeInBits = BitfieldSize;
2981 }
else if (IsBitIntType && !Context.hasUniqueObjectRepresentations(
2982 Field->getType(), CheckIfTriviallyCopyable)) {
2983 return std::nullopt;
2985 return FieldSizeInBits;
2988static std::optional<int64_t>
2990 bool CheckIfTriviallyCopyable) {
2992 CheckIfTriviallyCopyable);
2995template <
typename RangeT>
2997 const RangeT &Subobjects, int64_t CurOffsetInBits,
2999 bool CheckIfTriviallyCopyable) {
3000 for (
const auto *Subobject : Subobjects) {
3001 std::optional<int64_t> SizeInBits =
3004 return std::nullopt;
3005 if (*SizeInBits != 0) {
3007 if (Offset != CurOffsetInBits)
3008 return std::nullopt;
3009 CurOffsetInBits += *SizeInBits;
3012 return CurOffsetInBits;
3015static std::optional<int64_t>
3018 bool CheckIfTriviallyCopyable) {
3019 assert(!RD->
isUnion() &&
"Must be struct/class type");
3020 const auto &Layout = Context.getASTRecordLayout(RD);
3022 int64_t CurOffsetInBits = 0;
3023 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3024 if (ClassDecl->isDynamicClass())
3025 return std::nullopt;
3028 for (
const auto &
Base : ClassDecl->bases()) {
3031 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
3035 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
3038 std::optional<int64_t> OffsetAfterBases =
3040 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
3041 if (!OffsetAfterBases)
3042 return std::nullopt;
3043 CurOffsetInBits = *OffsetAfterBases;
3046 std::optional<int64_t> OffsetAfterFields =
3048 RD->
fields(), CurOffsetInBits, Context, Layout,
3049 CheckIfTriviallyCopyable);
3050 if (!OffsetAfterFields)
3051 return std::nullopt;
3052 CurOffsetInBits = *OffsetAfterFields;
3054 return CurOffsetInBits;
3058 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
3075 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
3080 CheckIfTriviallyCopyable);
3083 "hasUniqueObjectRepresentations should not be called with an "
3107 return !ABI->getMemberPointerInfo(MPT).HasPadding;
3110 if (
Record->isInvalidDecl())
3115 CheckIfTriviallyCopyable);
3118 *
this,
Record, CheckIfTriviallyCopyable);
3120 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
3141 count += Ext->ivar_size();
3146 count += ImplDecl->ivar_size();
3172 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3173 I = ObjCImpls.find(D);
3174 if (I != ObjCImpls.end())
3182 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3183 I = ObjCImpls.find(D);
3184 if (I != ObjCImpls.end())
3192 assert(IFaceD && ImplD &&
"Passed null params");
3193 ObjCImpls[IFaceD] = ImplD;
3199 assert(CatD && ImplD &&
"Passed null params");
3200 ObjCImpls[CatD] = ImplD;
3205 return ObjCMethodRedecls.
lookup(MD);
3211 ObjCMethodRedecls[MD] = Redecl;
3216 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3218 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3219 return CD->getClassInterface();
3220 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3221 return IMD->getClassInterface();
3229 assert(VD &&
"Passed null params");
3230 assert(VD->
hasAttr<BlocksAttr>() &&
3231 "getBlockVarCopyInits - not __block var");
3232 auto I = BlockVarCopyInits.find(VD);
3233 if (I != BlockVarCopyInits.end())
3235 return {
nullptr,
false};
3241 assert(VD && CopyExpr &&
"Passed null params");
3242 assert(VD->
hasAttr<BlocksAttr>() &&
3243 "setBlockVarCopyInits - not __block var");
3244 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3248 unsigned DataSize)
const {
3253 "incorrect data size provided to CreateTypeSourceInfo!");
3270 return getObjCLayout(D);
3275 bool &AnyNonCanonArgs) {
3277 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3283 bool AnyNonCanonArgs =
false;
3284 for (
auto &Arg : Args) {
3287 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3289 return AnyNonCanonArgs;
3297ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3302 llvm::FoldingSetNodeID ID;
3304 llvm::FoldingSetInsertToken
Token;
3306 assert(eq->getQualifiers() == quals);
3315 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3318 (void)ExtQualNodes.lookup(ID,
Token);
3321 auto *eq =
new (*
this,
alignof(ExtQuals)) ExtQuals(baseType, canon, quals);
3322 ExtQualNodes.insert(eq, Token);
3323 return QualType(eq, fastQuals);
3327 LangAS AddressSpace)
const {
3340 "Type cannot be in multiple addr spaces!");
3343 return getExtQualType(TypeNode, Quals);
3349 if (!
T.hasAddressSpace())
3353 const Type *TypeNode;
3356 if (
T.getTypePtr()->isArrayType()) {
3358 TypeNode =
T.getTypePtr();
3362 while (
T.hasAddressSpace()) {
3363 TypeNode = Quals.
strip(
T);
3367 if (!
QualType(TypeNode, 0).hasAddressSpace())
3371 T =
T.getSingleStepDesugaredType(*
this);
3381 return getExtQualType(TypeNode, Quals);
3390 "Attempted to get vtable pointer discriminator on a monomorphic type");
3394 llvm::raw_svector_ostream Out(Str);
3395 MC->mangleCXXVTable(RD, Out);
3398 return llvm::getPointerAuthStableSipHash(Str);
3424 switch (
T->getTypeClass()) {
3429 case Type::LValueReference:
3434 case Type::RValueReference:
3448 case Type::ObjCObjectPointer:
3449 case Type::BlockPointer:
3458 case Type::VariableArray:
3459 case Type::ConstantArray:
3460 case Type::IncompleteArray:
3461 case Type::ArrayParameter:
3474 case Type::ObjCInterface:
3475 case Type::ObjCObject:
3476 OS <<
"<objc_object>";
3485 QualType UnderlyingType =
T->castAsEnumDecl()->getIntegerType();
3487 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3490 case Type::FunctionNoProto:
3491 case Type::FunctionProto: {
3507 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3508 for (
QualType Param : FPT->param_types()) {
3512 if (FPT->isVariadic())
3519 case Type::MemberPointer: {
3523 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3527 case Type::ExtVector:
3535 case Type::ConstantMatrix:
3539 case Type::Builtin: {
3541 switch (BTy->getKind()) {
3542#define SIGNED_TYPE(Id, SingletonId) \
3543 case BuiltinType::Id: \
3546#define UNSIGNED_TYPE(Id, SingletonId) \
3547 case BuiltinType::Id: \
3550#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3551#define BUILTIN_TYPE(Id, SingletonId)
3552#include "clang/AST/BuiltinTypes.def"
3553 llvm_unreachable(
"placeholder types should not appear here.");
3555 case BuiltinType::Half:
3558 case BuiltinType::Float:
3561 case BuiltinType::Double:
3564 case BuiltinType::LongDouble:
3567 case BuiltinType::Float16:
3570 case BuiltinType::Float128:
3574 case BuiltinType::Void:
3578 case BuiltinType::ObjCId:
3579 case BuiltinType::ObjCClass:
3580 case BuiltinType::ObjCSel:
3581 case BuiltinType::NullPtr:
3586 case BuiltinType::OCLSampler:
3587 case BuiltinType::OCLEvent:
3588 case BuiltinType::OCLClkEvent:
3589 case BuiltinType::OCLQueue:
3590 case BuiltinType::OCLReserveID:
3591 case BuiltinType::BFloat16:
3592 case BuiltinType::VectorQuad:
3593 case BuiltinType::VectorPair:
3594 case BuiltinType::DMR1024:
3595 case BuiltinType::DMR2048:
3600 case BuiltinType::Ibm128:
3602#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3603 case BuiltinType::Id: \
3605#include "clang/Basic/OpenCLImageTypes.def"
3606#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3607 case BuiltinType::Id: \
3609#include "clang/Basic/OpenCLExtensionTypes.def"
3610#define SVE_TYPE(Name, Id, SingletonId) \
3611 case BuiltinType::Id: \
3613#include "clang/Basic/AArch64ACLETypes.def"
3614#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3615 case BuiltinType::Id: \
3617#include "clang/Basic/HLSLIntangibleTypes.def"
3618 case BuiltinType::Dependent:
3619 llvm_unreachable(
"should never get here");
3620#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3621#include "clang/Basic/AMDGPUTypes.def"
3622 case BuiltinType::WasmExternRef:
3623#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3624#include "clang/Basic/RISCVVTypes.def"
3625#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3626#include "clang/Basic/SPIRVTypes.def"
3627 llvm_unreachable(
"not yet implemented");
3629 llvm_unreachable(
"should never get here");
3631 case Type::Record: {
3632 const RecordDecl *RD =
T->castAsCanonical<RecordType>()->getDecl();
3652 II = Typedef->getDeclName().getAsIdentifierInfo();
3655 OS <<
"<anonymous_record>";
3661 case Type::HLSLAttributedResource:
3662 case Type::HLSLInlineSpirv:
3663 llvm_unreachable(
"should never get here");
3665 case Type::OverflowBehavior:
3666 llvm_unreachable(
"should never get here");
3668 case Type::DeducedTemplateSpecialization:
3670#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3671#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3672#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3673#define ABSTRACT_TYPE(Class, Base)
3674#define TYPE(Class, Base)
3675#include "clang/AST/TypeNodes.inc"
3676 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3682 assert(!
T->isDependentType() &&
3683 "cannot compute type discriminator of a dependent type");
3685 llvm::raw_svector_ostream Out(Str);
3687 if (
T->isFunctionPointerType() ||
T->isFunctionReferenceType())
3688 T =
T->getPointeeType();
3690 if (
T->isFunctionType()) {
3693 T =
T.getUnqualifiedType();
3714 if (MPT->isMemberFunctionPointer()) {
3720 MPT->getMostRecentCXXRecordDecl());
3724 MC->mangleCanonicalTypeName(
T, Out);
3727 return llvm::getPointerAuthStableSipHash(Str);
3752 "Type cannot have multiple ObjCGCs!");
3755 return getExtQualType(TypeNode, Quals);
3760 QualType Pointee = Ptr->getPointeeType();
3769 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3772 assert(CountExpr &&
"use getIncompleteCountAttributedType for a null count");
3779 llvm::FoldingSetNodeID ID;
3782 llvm::FoldingSetInsertToken
Token;
3788 CATy = CountAttributedType::Create(*
this, WrappedTy, CanonTy, CountExpr,
3789 CountInBytes, OrNull, DependentDecls);
3790 Types.push_back(CATy);
3791 CountAttributedTypes.insert(CATy,
Token);
3797 QualType WrappedTy,
bool CountInBytes,
bool OrNull)
const {
3812 return CountAttributedType::Create(
3814 nullptr, CountInBytes, OrNull,
3821 CATy->complete(*
this, CountExpr, DependentDecls);
3832 Types.push_back(CATy);
3842 Types.push_back(LPATy);
3850 case Type::Attributed: {
3858 case Type::BTFTagAttributed: {
3859 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3864 case Type::OverflowBehavior: {
3865 const auto *OB = dyn_cast<OverflowBehaviorType>(Orig);
3867 adjustType(OB->getUnderlyingType(), Adjust));
3874 case Type::Adjusted: {
3880 case Type::MacroQualified: {
3883 MQT->getMacroIdentifier());
3887 return Adjust(Orig);
3893 if (
T->getExtInfo() == Info)
3897 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(
T)) {
3917 FPT->getExtProtoInfo());
3932 L->DeducedReturnType(FD, ResultType);
3943 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3944 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3960 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
3983 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
4009 if (TSInfo->getType() != FD->
getType())
4017 "TypeLoc size mismatch from updating exception specification");
4018 TSInfo->overrideType(Updated);
4027 llvm::FoldingSetInsertToken
Token;
4034 if (!
T.isCanonical()) {
4037 assert(!ComplexTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4040 Types.push_back(
New);
4050 llvm::FoldingSetInsertToken
Token;
4057 if (!
T.isCanonical()) {
4060 assert(!PointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4063 Types.push_back(
New);
4069 llvm::FoldingSetInsertToken
Token;
4078 Types.push_back(AT);
4079 AdjustedTypes.insert(AT,
Token);
4084 llvm::FoldingSetInsertToken
Token;
4092 Types.push_back(AT);
4093 AdjustedTypes.insert(AT,
Token);
4098 assert((
T->isArrayType() ||
T->isFunctionType()) &&
"T does not decay");
4107 if (
T->isArrayType())
4114 if (
T->isFunctionType())
4126 llvm::FoldingSetNodeID ID;
4127 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
4128 ATy->getSizeExpr(), ATy->getSizeModifier(),
4129 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
4130 llvm::FoldingSetInsertToken
Token;
4140 AT = ArrayParameterTypes.lookup(ID,
Token);
4141 assert(!AT &&
"Shouldn't be in the map!");
4146 Types.push_back(AT);
4147 ArrayParameterTypes.insert(AT,
Token);
4154 assert(
T->isFunctionType() &&
"block of function types only");
4157 llvm::FoldingSetInsertToken
Token;
4164 if (!
T.isCanonical()) {
4167 assert(!BlockPointerTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
4171 Types.push_back(
New);
4172 BlockPointerTypes.insert(
New,
Token);
4180 assert((!
T->isPlaceholderType() ||
4181 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4182 "Unresolved placeholder type");
4186 llvm::FoldingSetInsertToken
Token;
4188 LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token))
4196 if (!SpelledAsLValue || InnerRef || !
T.isCanonical()) {
4197 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4200 assert(!LValueReferenceTypes.lookup({T, SpelledAsLValue},
Token) &&
4201 "Shouldn't be in the map!");
4206 Types.push_back(
New);
4207 LValueReferenceTypes.insert(
New,
Token);
4215 assert((!
T->isPlaceholderType() ||
4216 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4217 "Unresolved placeholder type");
4221 llvm::FoldingSetInsertToken
Token;
4230 if (InnerRef || !
T.isCanonical()) {
4231 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4234 assert(!RValueReferenceTypes.lookup({T, false},
Token) &&
4235 "Shouldn't be in the map!");
4240 Types.push_back(
New);
4241 RValueReferenceTypes.insert(
New,
Token);
4249 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4252 Cls = Qualifier.getAsRecordDecl();
4256 llvm::FoldingSetNodeID ID;
4259 llvm::FoldingSetInsertToken
Token;
4265 return Qualifier.getCanonical();
4267 assert(R.isCanonical());
4273 if (!
T.isCanonical() || Qualifier != CanonicalQualifier) {
4279 MemberPointerTypes.lookup(ID,
Token);
4280 assert(!NewIP &&
"Shouldn't be in the map!");
4284 Types.push_back(
New);
4285 MemberPointerTypes.insert(
New,
Token);
4292 const llvm::APInt &ArySizeIn,
4293 const Expr *SizeExpr,
4295 unsigned IndexTypeQuals)
const {
4298 "Constant array of VLAs is illegal!");
4306 llvm::APInt ArySize(ArySizeIn);
4307 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
4313 llvm::FoldingSetNodeID ID;
4315 ASM, IndexTypeQuals);
4317 llvm::FoldingSetInsertToken
Token;
4329 ASM, IndexTypeQuals);
4334 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4337 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4338 ASM, IndexTypeQuals);
4339 ConstantArrayTypes.insert(
New,
Token);
4340 Types.push_back(
New);
4349 if (!
type->isVariablyModifiedType())
return type;
4354 const Type *ty = split.
Ty;
4356#define TYPE(Class, Base)
4357#define ABSTRACT_TYPE(Class, Base)
4358#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4359#include "clang/AST/TypeNodes.inc"
4360 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4366 case Type::DependentVector:
4367 case Type::ExtVector:
4368 case Type::DependentSizedExtVector:
4369 case Type::ConstantMatrix:
4370 case Type::DependentSizedMatrix:
4371 case Type::DependentAddressSpace:
4372 case Type::ObjCObject:
4373 case Type::ObjCInterface:
4374 case Type::ObjCObjectPointer:
4377 case Type::UnresolvedUsing:
4378 case Type::TypeOfExpr:
4380 case Type::Decltype:
4381 case Type::UnaryTransform:
4382 case Type::DependentName:
4383 case Type::InjectedClassName:
4384 case Type::TemplateSpecialization:
4385 case Type::TemplateTypeParm:
4386 case Type::SubstTemplateTypeParmPack:
4387 case Type::SubstBuiltinTemplatePack:
4389 case Type::DeducedTemplateSpecialization:
4390 case Type::PackExpansion:
4391 case Type::PackIndexing:
4393 case Type::DependentBitInt:
4394 case Type::ArrayParameter:
4395 case Type::HLSLAttributedResource:
4396 case Type::HLSLInlineSpirv:
4397 case Type::OverflowBehavior:
4398 llvm_unreachable(
"type should never be variably-modified");
4402 case Type::FunctionNoProto:
4403 case Type::FunctionProto:
4404 case Type::BlockPointer:
4405 case Type::MemberPointer:
4418 case Type::LValueReference: {
4422 lv->isSpelledAsLValue());
4426 case Type::RValueReference: {
4433 case Type::Atomic: {
4439 case Type::ConstantArray: {
4445 cat->getSizeModifier(),
4446 cat->getIndexTypeCVRQualifiers());
4450 case Type::DependentSizedArray: {
4454 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4459 case Type::IncompleteArray: {
4464 iat->getIndexTypeCVRQualifiers());
4469 case Type::VariableArray: {
4474 vat->getIndexTypeCVRQualifiers());
4487 unsigned IndexTypeQuals)
const {
4504 VariableArrayTypes.push_back(
New);
4505 Types.push_back(
New);
4515 unsigned elementTypeQuals)
const {
4518 "Size must be type- or value-dependent!");
4522 llvm::FoldingSetInsertToken
Token;
4523 llvm::FoldingSetNodeID ID;
4525 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4526 ASM, elementTypeQuals, numElements);
4541 DependentSizedArrayTypes.insert(newType,
Token);
4542 Types.push_back(newType);
4550 numElements, ASM, elementTypeQuals);
4551 DependentSizedArrayTypes.insert(canonTy,
Token);
4552 Types.push_back(canonTy);
4557 canonElementType.
Quals);
4561 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4570 Types.push_back(sugaredType);
4576 unsigned elementTypeQuals)
const {
4577 llvm::FoldingSetNodeID ID;
4580 llvm::FoldingSetInsertToken
Token;
4593 ASM, elementTypeQuals);
4598 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4604 IncompleteArrayTypes.insert(newType,
Token);
4605 Types.push_back(newType);
4611#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4612 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4615#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4616 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4620 llvm_unreachable(
"Unsupported builtin vector type");
4622#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4623 ElBits, NF, IsSigned) \
4624 case BuiltinType::Id: \
4625 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4626 llvm::ElementCount::getScalable(NumEls), NF};
4627#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4629 case BuiltinType::Id: \
4630 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4631 llvm::ElementCount::getScalable(NumEls), NF};
4632#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4634 case BuiltinType::Id: \
4635 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4636#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4638 case BuiltinType::Id: \
4639 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4640#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4641 case BuiltinType::Id: \
4642 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4643#include "clang/Basic/AArch64ACLETypes.def"
4645#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4647 case BuiltinType::Id: \
4648 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4649 llvm::ElementCount::getScalable(NumEls), NF};
4650#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4651 case BuiltinType::Id: \
4652 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4653 llvm::ElementCount::getScalable(NumEls), NF};
4654#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4655 case BuiltinType::Id: \
4656 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4657#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4658 case BuiltinType::Id: \
4659 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4660#include "clang/Basic/RISCVVTypes.def"
4667 if (Target->getTriple().isWasm() && Target->hasFeature(
"reference-types")) {
4668#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4669 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4671#include "clang/Basic/WebAssemblyReferenceTypes.def"
4674 "shouldn't try to generate type externref outside WebAssembly target");
4681 unsigned NumFields)
const {
4683 if (
auto It = ScalableVecTyMap.find(K); It != ScalableVecTyMap.end())
4686 if (Target->hasAArch64ACLETypes()) {
4689#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4690 ElBits, NF, IsSigned) \
4691 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4692 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4693 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4694 return ScalableVecTyMap[K] = SingletonId; \
4696#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4698 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4699 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4700 return ScalableVecTyMap[K] = SingletonId; \
4702#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4704 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4705 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4706 return ScalableVecTyMap[K] = SingletonId; \
4708#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4710 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4711 NumElts == (NumEls * NF) && NumFields == 1) { \
4712 return ScalableVecTyMap[K] = SingletonId; \
4714#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4715 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4716 return ScalableVecTyMap[K] = SingletonId;
4717#include "clang/Basic/AArch64ACLETypes.def"
4718 }
else if (Target->hasRISCVVTypes()) {
4720#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4722 if (!EltTy->isBooleanType() && \
4723 ((EltTy->hasIntegerRepresentation() && \
4724 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4725 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4727 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4728 IsBF && !IsFP)) && \
4729 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4730 return ScalableVecTyMap[K] = SingletonId;
4731#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4732 if (EltTy->isBooleanType() && NumElts == NumEls) \
4733 return ScalableVecTyMap[K] = SingletonId;
4734#include "clang/Basic/RISCVVTypes.def"
4749 llvm::FoldingSetNodeID ID;
4752 llvm::FoldingSetInsertToken
Token;
4764 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4767 VectorType(vecType, NumElts, Canonical, VecKind);
4769 Types.push_back(
New);
4776 llvm::FoldingSetNodeID ID;
4779 llvm::FoldingSetInsertToken
Token;
4785 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4788 if (CanonVecTy == VecType) {
4793 assert(!CanonCheck &&
4794 "Dependent-sized vector_size canonical type broken");
4796 DependentVectorTypes.insert(
New,
Token);
4805 Types.push_back(
New);
4812 unsigned NumElts)
const {
4819 llvm::FoldingSetNodeID ID;
4822 llvm::FoldingSetInsertToken
Token;
4834 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4839 Types.push_back(
New);
4847 llvm::FoldingSetNodeID ID;
4851 llvm::FoldingSetInsertToken
Token;
4853 DependentSizedExtVectorTypes.lookup(ID,
Token);
4863 if (CanonVecTy == vecType) {
4868 DependentSizedExtVectorTypes.lookup(ID,
Token);
4869 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4871 DependentSizedExtVectorTypes.insert(
New,
Token);
4880 Types.push_back(
New);
4885 QualType ElementTy,
unsigned NumRows,
unsigned NumColumns,
4886 std::optional<MatrixType::LayoutKind> Layout)
const {
4887 llvm::FoldingSetNodeID ID;
4889 Type::ConstantMatrix);
4892 "need a valid element type");
4893 assert(NumRows > 0 && NumRows <= LangOpts.MaxMatrixDimension &&
4894 NumColumns > 0 && NumColumns <= LangOpts.MaxMatrixDimension &&
4895 "need valid matrix dimensions");
4896 llvm::FoldingSetInsertToken
Token;
4903 NumColumns, std::nullopt);
4906 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4913 Types.push_back(
New);
4922 llvm::FoldingSetNodeID ID;
4926 llvm::FoldingSetInsertToken
Token;
4932 ColumnExpr, AttrLoc);
4935 DependentSizedMatrixTypes.lookup(ID,
Token);
4936 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4938 DependentSizedMatrixTypes.insert(Canon,
Token);
4939 Types.push_back(Canon);
4952 ColumnExpr, AttrLoc);
4953 Types.push_back(
New);
4961 const Type *Ty =
T->getUnqualifiedDesugaredType();
4963 if (
const auto *MT = dyn_cast<ConstantMatrixType>(Ty))
4966 MT->getNumColumns(), Layout),
4969 const auto *CAT = dyn_cast<ConstantArrayType>(Ty);
4975 CAT->getSizeExpr(), CAT->getSizeModifier(),
4976 CAT->getIndexTypeCVRQualifiers());
4984 Expr *AddrSpaceExpr,
4990 llvm::FoldingSetInsertToken
Token;
4991 llvm::FoldingSetNodeID ID;
4996 DependentAddressSpaceTypes.lookup(ID,
Token);
5002 DependentAddressSpaceTypes.insert(canonTy,
Token);
5003 Types.push_back(canonTy);
5006 if (canonPointeeType == PointeeType &&
5012 AddrSpaceExpr, AttrLoc);
5013 Types.push_back(sugaredType);
5019 return T.isCanonical() &&
5037 llvm::FoldingSetNodeID ID;
5040 llvm::FoldingSetInsertToken
Token;
5051 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5056 Types.push_back(
New);
5057 FunctionNoProtoTypes.insert(
New,
Token);
5073 return CanResultType;
5080 if (!NoexceptInType)
5097 bool AnyPackExpansions =
false;
5101 if (ET->
getAs<PackExpansionType>())
5102 AnyPackExpansions =
true;
5104 return AnyPackExpansions;
5110QualType ASTContext::getFunctionTypeInternal(
5111 QualType ResultTy, ArrayRef<QualType> ArgArray,
5112 const FunctionProtoType::ExtProtoInfo &EPI,
bool OnlyWantCanonical)
const {
5113 size_t NumArgs = ArgArray.size();
5117 llvm::FoldingSetNodeID
ID;
5122 bool Unique =
false;
5124 llvm::FoldingSetInsertToken Token;
5125 if (FunctionProtoType *FPT = FunctionProtoTypes.lookup(ID, Token)) {
5126 QualType Existing = QualType(FPT, 0);
5145 bool IsCanonicalExceptionSpec =
5149 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
5151 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
5152 if (!ArgArray[i].isCanonicalAsParam())
5153 isCanonical =
false;
5155 if (OnlyWantCanonical)
5156 assert(isCanonical &&
5157 "given non-canonical parameters constructing canonical type");
5162 if (!isCanonical && Canonical.
isNull()) {
5163 SmallVector<QualType, 16> CanonicalArgs;
5164 CanonicalArgs.reserve(NumArgs);
5165 for (
unsigned i = 0; i != NumArgs; ++i)
5168 llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
5169 FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
5172 if (IsCanonicalExceptionSpec) {
5174 }
else if (NoexceptInType) {
5187 bool AnyPacks =
false;
5189 if (ET->
getAs<PackExpansionType>())
5210 llvm_unreachable(
"dependent noexcept is already canonical");
5213 CanonicalEPI.
ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
5219 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5222 FunctionProtoType *NewIP = FunctionProtoTypes.lookup(ID, Token);
5223 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5228 auto ESH = FunctionProtoType::getExceptionSpecSize(
5230 size_t Size = FunctionProtoType::totalSizeToAlloc<
5231 QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
5232 FunctionType::FunctionTypeExtraAttributeInfo,
5233 FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
5234 Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, Qualifiers,
5235 FunctionEffect, EffectConditionExpr>(
5239 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5244 auto *FTP = (FunctionProtoType *)
Allocate(Size,
alignof(FunctionProtoType));
5245 FunctionProtoType::ExtProtoInfo newEPI = EPI;
5246 new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
5247 Types.push_back(FTP);
5249 FunctionProtoTypes.insert(FTP, Token);
5251 AnyFunctionEffects =
true;
5252 return QualType(FTP, 0);
5255QualType ASTContext::getPipeType(QualType
T,
bool ReadOnly)
const {
5256 llvm::FoldingSetInsertToken Token;
5257 if (PipeType *PT = PipeTypes.lookup({T, ReadOnly}, Token))
5258 return QualType(PT, 0);
5263 if (!
T.isCanonical()) {
5266 assert(!PipeTypes.lookup({T, ReadOnly}, Token) &&
5267 "Shouldn't be in the map!");
5269 auto *
New =
new (*
this,
alignof(PipeType)) PipeType(
T, Canonical, ReadOnly);
5270 Types.push_back(
New);
5271 PipeTypes.insert(
New, Token);
5272 return QualType(
New, 0);
5282 return getPipeType(
T,
true);
5286 return getPipeType(
T,
false);
5290 auto Key = std::make_pair(
unsigned(IsUnsigned), NumBits);
5292 llvm::FoldingSetInsertToken
Token;
5298 Types.push_back(
New);
5303 Expr *NumBitsExpr)
const {
5305 llvm::FoldingSetNodeID ID;
5308 llvm::FoldingSetInsertToken
Token;
5314 DependentBitIntTypes.insert(
New,
Token);
5316 Types.push_back(
New);
5324 if (
auto *Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5336 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5337 case Kind::SignedSizeT:
5339 case Kind::PtrdiffT:
5342 llvm_unreachable(
"unexpected kind");
5347 Types.push_back(
New);
5348 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5355 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5358 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5360 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5369 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5371 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5373 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5375 assert(TD->TypeForDecl);
5380 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5382 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5383 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5386 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5389 assert(
Decl->TypeForDecl);
5399 std::optional<bool> TypeMatchesDeclOrNone)
const {
5400 if (!TypeMatchesDeclOrNone) {
5401 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5402 assert(!DeclUnderlyingType.
isNull());
5403 if (UnderlyingType.
isNull())
5404 UnderlyingType = DeclUnderlyingType;
5406 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5407 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5411 assert(!UnderlyingType.
isNull());
5415 *TypeMatchesDeclOrNone) {
5416 if (
Decl->TypeForDecl)
5421 !*TypeMatchesDeclOrNone);
5423 Types.push_back(NewType);
5424 Decl->TypeForDecl = NewType;
5428 llvm::FoldingSetNodeID ID;
5430 *TypeMatchesDeclOrNone ?
QualType() : UnderlyingType);
5432 llvm::FoldingSetInsertToken
Token;
5434 TypedefTypes.lookup(ID,
Token))
5435 return QualType(Placeholder->getType(), 0);
5440 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5444 UnderlyingType, !*TypeMatchesDeclOrNone);
5445 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5447 TypedefTypes.insert(Placeholder,
Token);
5448 Types.push_back(NewType);
5457 if (UnderlyingType.
isNull()) {
5465 llvm::FoldingSetNodeID ID;
5468 llvm::FoldingSetInsertToken
Token;
5479 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5483 UsingTypes.insert(
T,
Token);
5489 const TagDecl *TD,
bool OwnsTag,
5491 const Type *CanonicalType,
5492 bool WithFoldingSetNode)
const {
5493 auto [TC, Size] = [&] {
5496 static_assert(
alignof(EnumType) ==
alignof(TagType));
5497 return std::make_tuple(Type::Enum,
sizeof(EnumType));
5498 case Decl::ClassTemplatePartialSpecialization:
5499 case Decl::ClassTemplateSpecialization:
5500 case Decl::CXXRecord:
5501 static_assert(
alignof(RecordType) ==
alignof(TagType));
5502 static_assert(
alignof(InjectedClassNameType) ==
alignof(TagType));
5504 return std::make_tuple(Type::InjectedClassName,
5505 sizeof(InjectedClassNameType));
5508 return std::make_tuple(Type::Record,
sizeof(RecordType));
5510 llvm_unreachable(
"unexpected decl kind");
5520 if (WithFoldingSetNode) {
5528 sizeof(TagTypeFoldingSetPlaceholder) +
5529 TagTypeFoldingSetPlaceholder::getOffset() + Size,
5530 std::max(
alignof(TagTypeFoldingSetPlaceholder),
alignof(TagType)));
5531 auto *
T =
new (Mem) TagTypeFoldingSetPlaceholder();
5532 Mem =
T->getTagType();
5534 Mem =
Allocate(Size,
alignof(TagType));
5537 auto *
T = [&, TC = TC]() -> TagType * {
5541 auto *
T =
new (Mem) EnumType(TC,
Keyword, Qualifier, TD, OwnsTag,
5542 IsInjected, CanonicalType);
5543 assert(
reinterpret_cast<void *
>(
T) ==
5544 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5545 "TagType must be the first base of EnumType");
5548 case Type::Record: {
5550 auto *
T =
new (Mem) RecordType(TC,
Keyword, Qualifier, TD, OwnsTag,
5551 IsInjected, CanonicalType);
5552 assert(
reinterpret_cast<void *
>(
T) ==
5553 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5554 "TagType must be the first base of RecordType");
5557 case Type::InjectedClassName: {
5558 auto *
T =
new (Mem) InjectedClassNameType(
Keyword, Qualifier, TD,
5559 IsInjected, CanonicalType);
5560 assert(
reinterpret_cast<void *
>(
T) ==
5561 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5562 "TagType must be the first base of InjectedClassNameType");
5566 llvm_unreachable(
"unexpected type class");
5569 assert(
T->getKeyword() ==
Keyword);
5570 assert(
T->getQualifier() == Qualifier);
5571 assert(
T->getDecl() == TD);
5572 assert(
T->isInjected() == IsInjected);
5573 assert(
T->isTagOwned() == OwnsTag);
5582 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5583 RD && RD->isInjectedClassName())
5590 if (TD->TypeForDecl)
5591 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5593 const Type *CanonicalType = getTagTypeInternal(
5596 false,
false,
nullptr,
5598 TD->TypeForDecl = CanonicalType;
5604 const TagDecl *TD,
bool OwnsTag)
const {
5607 bool IsInjected = TD != NonInjectedTD;
5614 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5615 if (
const Type *
T = TD->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5621 std::nullopt, NonInjectedTD,
5622 false, IsInjected, CanonicalType,
5624 TD->TypeForDecl =
T;
5628 llvm::FoldingSetNodeID ID;
5629 TagTypeFoldingSetPlaceholder::Profile(ID,
Keyword, Qualifier, NonInjectedTD,
5630 OwnsTag, IsInjected);
5632 llvm::FoldingSetInsertToken
Token;
5633 if (TagTypeFoldingSetPlaceholder *
T = TagTypes.lookup(ID,
Token))
5638 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5639 CanonicalType,
true);
5640 TagTypes.insert(TagTypeFoldingSetPlaceholder::fromTagType(
T),
Token);
5645 unsigned NumPositiveBits,
5648 unsigned IntWidth = Target->getIntWidth();
5649 unsigned CharWidth = Target->getCharWidth();
5650 unsigned ShortWidth = Target->getShortWidth();
5651 bool EnumTooLarge =
false;
5653 if (NumNegativeBits) {
5657 if (IsPacked && NumNegativeBits <= CharWidth &&
5658 NumPositiveBits < CharWidth) {
5660 BestWidth = CharWidth;
5661 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5662 NumPositiveBits < ShortWidth) {
5664 BestWidth = ShortWidth;
5665 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5667 BestWidth = IntWidth;
5669 BestWidth = Target->getLongWidth();
5671 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5674 BestWidth = Target->getLongLongWidth();
5676 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5677 EnumTooLarge =
true;
5681 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5686 if (IsPacked && NumPositiveBits <= CharWidth) {
5688 BestPromotionType =
IntTy;
5689 BestWidth = CharWidth;
5690 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5692 BestPromotionType =
IntTy;
5693 BestWidth = ShortWidth;
5694 }
else if (NumPositiveBits <= IntWidth) {
5696 BestWidth = IntWidth;
5697 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5700 }
else if (NumPositiveBits <= (BestWidth = Target->getLongWidth())) {
5702 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5706 BestWidth = Target->getLongLongWidth();
5707 if (NumPositiveBits > BestWidth) {
5712 EnumTooLarge =
true;
5715 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5720 return EnumTooLarge;
5724 assert((
T->isIntegralType(*
this) ||
T->isEnumeralType()) &&
5725 "Integral type required!");
5728 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5729 if (
T->isSignedIntegerOrEnumerationType())
5731 return Value.getActiveBits() <= BitWidth;
5733 return Value.getSignificantBits() <= BitWidth;
5739 const Type *CanonicalType)
const {
5741 UnresolvedUsingType::totalSizeToAlloc<
5743 !!
Token, !!Qualifier),
5747 auto *Placeholder =
new (
T->getFoldingSetPlaceholder())
5749 UnresolvedUsingTypes.insert(Placeholder,
Token);
5759 return D->TypeForDecl->getCanonicalTypeUnqualified();
5761 const Type *CanonicalType =
5765 D->TypeForDecl = CanonicalType;
5774 if (
const Type *
T = D->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5786 llvm::FoldingSetNodeID ID;
5789 llvm::FoldingSetInsertToken
Token;
5791 UnresolvedUsingTypes.lookup(ID,
Token))
5792 return QualType(Placeholder->getType(), 0);
5805 llvm::FoldingSetNodeID id;
5806 AttributedType::Profile(
id, *
this, attrKind, modifiedType, equivalentType,
5809 llvm::FoldingSetInsertToken
Token;
5810 AttributedType *
type = AttributedTypes.lookup(
id,
Token);
5813 assert(!
attr ||
attr->getKind() == attrKind);
5816 type =
new (*
this,
alignof(AttributedType))
5817 AttributedType(canon, attrKind,
attr, modifiedType, equivalentType);
5819 Types.push_back(
type);
5833 switch (nullability) {
5849 llvm_unreachable(
"Unknown nullability kind");
5854 llvm::FoldingSetNodeID ID;
5855 BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
5857 llvm::FoldingSetInsertToken
Token;
5858 BTFTagAttributedType *Ty = BTFTagAttributedTypes.lookup(ID,
Token);
5863 Ty =
new (*
this,
alignof(BTFTagAttributedType))
5864 BTFTagAttributedType(Canon, Wrapped, BTFAttr);
5866 Types.push_back(Ty);
5867 BTFTagAttributedTypes.insert(Ty,
Token);
5875 StringRef IdentName = II->
getName();
5876 OverflowBehaviorType::OverflowBehaviorKind Kind;
5877 if (IdentName ==
"wrap") {
5878 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
5879 }
else if (IdentName ==
"trap") {
5880 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
5889 OverflowBehaviorType::OverflowBehaviorKind Kind,
5892 "Cannot have underlying types that are themselves OBTs");
5894 llvm::FoldingSetInsertToken
Token;
5895 if (OverflowBehaviorType *OBT =
5896 OverflowBehaviorTypes.lookup({Underlying, Kind},
Token)) {
5905 assert(!OverflowBehaviorTypes.lookup({Underlying, Kind},
Token) &&
5906 "Shouldn't be in the map");
5909 OverflowBehaviorType *Ty =
new (*
this,
alignof(OverflowBehaviorType))
5910 OverflowBehaviorType(*
this, Canonical, Underlying, Kind);
5912 Types.push_back(Ty);
5913 OverflowBehaviorTypes.insert(Ty,
Token);
5919 const HLSLAttributedResourceType::Attributes &Attrs) {
5921 llvm::FoldingSetNodeID ID;
5922 HLSLAttributedResourceType::Profile(ID, *
this, Wrapped, Contained, Attrs);
5924 llvm::FoldingSetInsertToken
Token;
5925 HLSLAttributedResourceType *Ty =
5926 HLSLAttributedResourceTypes.lookup(ID,
Token);
5930 Ty =
new (*
this,
alignof(HLSLAttributedResourceType))
5931 HLSLAttributedResourceType(Wrapped, Contained, Attrs);
5933 Types.push_back(Ty);
5934 HLSLAttributedResourceTypes.insert(Ty,
Token);
5942 llvm::FoldingSetNodeID ID;
5943 HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
5945 llvm::FoldingSetInsertToken
Token;
5946 HLSLInlineSpirvType *Ty = HLSLInlineSpirvTypes.lookup(ID,
Token);
5951 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5952 alignof(HLSLInlineSpirvType));
5954 Ty =
new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
5956 Types.push_back(Ty);
5957 HLSLInlineSpirvTypes.insert(Ty,
Token);
5964 Decl *AssociatedDecl,
5969 std::make_tuple(Replacement, AssociatedDecl, Index,
5970 PackIndex.toInternalRepresentation(),
unsigned(Final));
5971 llvm::FoldingSetInsertToken
Token;
5972 SubstTemplateTypeParmType *SubstParm =
5973 SubstTemplateTypeParmTypes.lookup(Key,
Token);
5976 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5977 !Replacement.isCanonical()),
5978 alignof(SubstTemplateTypeParmType));
5979 SubstParm =
new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
5981 Types.push_back(SubstParm);
5982 SubstTemplateTypeParmTypes.insert(SubstParm,
Token);
5990 unsigned Index,
bool Final,
5997 llvm::FoldingSetNodeID ID;
5998 SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
6000 llvm::FoldingSetInsertToken
Token;
6001 if (SubstTemplateTypeParmPackType *SubstParm =
6002 SubstTemplateTypeParmPackTypes.lookup(ID,
Token))
6012 [[maybe_unused]]
const auto *Nothing =
6013 SubstTemplateTypeParmPackTypes.lookup(ID,
Token);
6018 auto *SubstParm =
new (*
this,
alignof(SubstTemplateTypeParmPackType))
6019 SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
6021 Types.push_back(SubstParm);
6022 SubstTemplateTypeParmPackTypes.insert(SubstParm,
Token);
6030 return P.getKind() == TemplateArgument::Type;
6032 "Pack contains a non-type");
6034 llvm::FoldingSetNodeID ID;
6035 SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
6037 llvm::FoldingSetInsertToken
Token;
6038 if (
auto *
T = SubstBuiltinTemplatePackTypes.lookup(ID,
Token))
6047 [[maybe_unused]]
const auto *Nothing =
6048 SubstBuiltinTemplatePackTypes.lookup(ID,
Token);
6052 auto *PackType =
new (*
this,
alignof(SubstBuiltinTemplatePackType))
6053 SubstBuiltinTemplatePackType(Canon, ArgPack);
6054 Types.push_back(PackType);
6055 SubstBuiltinTemplatePackTypes.insert(PackType,
Token);
6065 assert(Depth >= 0 &&
"Depth must be non-negative");
6066 assert(Index >= 0 &&
"Index must be non-negative");
6068 auto Key = std::make_tuple(
unsigned(Depth),
unsigned(Index),
6069 unsigned(ParameterPack), TTPDecl);
6070 llvm::FoldingSetInsertToken
Token;
6071 TemplateTypeParmType *TypeParm = TemplateTypeParmTypes.lookup(Key,
Token);
6078 TypeParm =
new (*
this,
alignof(TemplateTypeParmType))
6079 TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
6081 TypeParm =
new (*
this,
alignof(TemplateTypeParmType)) TemplateTypeParmType(
6082 Depth, Index, ParameterPack,
nullptr,
QualType());
6084 Types.push_back(TypeParm);
6085 TemplateTypeParmTypes.insert(TypeParm,
Token);
6111 llvm_unreachable(
"unexpected keyword kind");
6125 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
6135 SpecifiedArgVec.reserve(SpecifiedArgs.size());
6137 SpecifiedArgVec.push_back(Arg.getArgument());
6140 CanonicalArgs, Underlying);
6143[[maybe_unused]]
static bool
6146 if (Arg.isPackExpansion())
6157 Template.getAsDependentTemplateName()));
6159 for (
const auto &Arg : Args)
6163 llvm::FoldingSetNodeID ID;
6166 llvm::FoldingSetInsertToken
Token;
6167 if (
auto *
T = TemplateSpecializationTypes.lookup(ID,
Token))
6170 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6172 alignof(TemplateSpecializationType));
6176 assert(Spec->isDependentType() &&
6177 "canonical template specialization must be dependent");
6178 Types.push_back(Spec);
6179 TemplateSpecializationTypes.insert(Spec,
Token);
6187 const auto *TD =
Template.getAsTemplateDecl(
true);
6188 bool IsTypeAlias = TD && TD->isTypeAlias();
6189 if (Underlying.
isNull()) {
6196 bool NonCanonical =
Template != CanonTemplate ||
Keyword != CanonKeyword;
6198 if (CanonicalArgs.empty()) {
6201 CanonicalArgs = CanonArgsVec;
6203 NonCanonical |= !llvm::equal(
6204 SpecifiedArgs, CanonicalArgs,
6213 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
6215 "Caller must compute aliased type");
6216 IsTypeAlias =
false;
6219 CanonKeyword, CanonTemplate, CanonicalArgs);
6223 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6225 (IsTypeAlias ?
sizeof(
QualType) : 0),
6226 alignof(TemplateSpecializationType));
6227 auto *Spec =
new (Mem) TemplateSpecializationType(
6229 Types.push_back(Spec);
6235 llvm::FoldingSetInsertToken
Token;
6243 assert(!ParenTypes.lookup(InnerType,
Token) &&
6244 "Paren canonical type broken");
6249 ParenTypes.insert(
T,
Token);
6262 Types.push_back(newType);
6269 llvm::FoldingSetNodeID ID;
6270 DependentNameType::Profile(ID,
Keyword, NNS, Name);
6272 llvm::FoldingSetInsertToken
Token;
6273 if (DependentNameType *
T = DependentNameTypes.lookup(ID,
Token))
6281 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6283 [[maybe_unused]] DependentNameType *
T =
6284 DependentNameTypes.lookup(ID,
Token);
6285 assert(!
T &&
"broken canonicalization");
6289 DependentNameType *
T =
new (*
this,
alignof(DependentNameType))
6290 DependentNameType(
Keyword, NNS, Name, Canon);
6292 DependentNameTypes.insert(
T,
Token);
6298 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6300 if (TTP->isParameterPack())
6304 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6306 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6312 if (
T->isRecordType()) {
6321 Expr *E =
new (*this)
6323 T,
VK, NTTP->getLocation());
6325 if (NTTP->isParameterPack())
6331 std::nullopt,
false,
6333 if (TTP->isParameterPack())
6339 if (Param->isTemplateParameterPack())
6348 bool ExpectPackInType)
const {
6350 "Pack expansions must expand one or more parameter packs");
6354 llvm::FoldingSetInsertToken
Token;
6355 PackExpansionType *
T = PackExpansionTypes.lookup(Key,
Token);
6366 PackExpansionTypes.lookup(Key,
Token);
6369 T =
new (*
this,
alignof(PackExpansionType))
6370 PackExpansionType(Pattern, Canon, NumExpansions);
6372 PackExpansionTypes.insert(
T,
Token);
6384 if (Protocols.empty())
return true;
6389 for (
unsigned i = 1; i != Protocols.size(); ++i)
6399 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6403 P = P->getCanonicalDecl();
6406 auto ProtocolsEnd = llvm::unique(Protocols);
6407 Protocols.erase(ProtocolsEnd, Protocols.end());
6412 unsigned NumProtocols)
const {
6421 bool isKindOf)
const {
6424 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6429 llvm::FoldingSetNodeID ID;
6430 ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
6431 llvm::FoldingSetInsertToken
Token;
6439 if (effectiveTypeArgs.empty()) {
6441 effectiveTypeArgs = baseObject->getTypeArgs();
6448 bool typeArgsAreCanonical = llvm::all_of(
6451 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6455 if (!typeArgsAreCanonical) {
6456 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6457 for (
auto typeArg : effectiveTypeArgs)
6459 canonTypeArgs = canonTypeArgsVec;
6461 canonTypeArgs = effectiveTypeArgs;
6466 if (!protocolsSorted) {
6467 canonProtocolsVec.append(protocols.begin(), protocols.end());
6469 canonProtocols = canonProtocolsVec;
6471 canonProtocols = protocols;
6475 canonProtocols, isKindOf);
6478 ObjCObjectTypes.lookup(ID,
Token);
6481 unsigned size =
sizeof(ObjCObjectTypeImpl);
6482 size += typeArgs.size() *
sizeof(
QualType);
6484 void *mem =
Allocate(size,
alignof(ObjCObjectTypeImpl));
6486 new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
6490 ObjCObjectTypes.insert(
T,
Token);
6500 bool allowOnPointerType)
const {
6503 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6508 if (allowOnPointerType) {
6509 if (
const auto *objPtr =
6510 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6514 protocolsVec.append(objT->qual_begin(),
6516 protocolsVec.append(protocols.begin(), protocols.end());
6519 objT->getBaseType(),
6520 objT->getTypeArgsAsWritten(),
6522 objT->isKindOfTypeAsWritten());
6528 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6533 objT->getTypeArgsAsWritten(),
6535 objT->isKindOfTypeAsWritten());
6539 if (
type->isObjCObjectType()) {
6549 if (
type->isObjCIdType()) {
6552 objPtr->isKindOfType());
6557 if (
type->isObjCClassType()) {
6560 objPtr->isKindOfType());
6573 if (!protocols.empty()) {
6577 Canonical, protocols, hasError,
true ));
6578 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6583 auto Key = std::make_tuple(
Decl, Canonical, protocols);
6584 llvm::FoldingSetInsertToken
Token;
6585 if (ObjCTypeParamType *TypeParam = ObjCTypeParamTypes.lookup(Key,
Token))
6588 unsigned size =
sizeof(ObjCTypeParamType);
6590 void *mem =
Allocate(size,
alignof(ObjCTypeParamType));
6591 auto *newType =
new (mem) ObjCTypeParamType(
Decl, Canonical, protocols);
6593 Types.push_back(newType);
6594 ObjCTypeParamTypes.insert(newType,
Token);
6604 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6619 for (
auto *Proto : OPT->quals()) {
6642 if (InheritedProtocols.empty())
6646 bool Conforms =
false;
6647 for (
auto *Proto : OPT->quals()) {
6649 for (
auto *PI : InheritedProtocols) {
6661 for (
auto *PI : InheritedProtocols) {
6663 bool Adopts =
false;
6664 for (
auto *Proto : OPT->quals()) {
6678 llvm::FoldingSetInsertToken
Token;
6693 Types.push_back(QType);
6694 ObjCObjectPointerTypes.insert(QType,
Token);
6702 if (
Decl->TypeForDecl)
6706 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6707 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6708 return QualType(PrevDecl->TypeForDecl, 0);
6717 Decl->TypeForDecl =
T;
6730 llvm::FoldingSetNodeID ID;
6734 llvm::FoldingSetInsertToken
Token;
6745 DependentTypeOfExprTypes.insert(Canon,
Token);
6753 Types.push_back(toe);
6764 auto *tot =
new (*
this,
alignof(TypeOfType))
6765 TypeOfType(*
this, tofType, Canonical, Kind);
6766 Types.push_back(tot);
6790 llvm_unreachable(
"Unknown value kind");
6805 }
else if (!UnderlyingType.
isNull()) {
6808 llvm::FoldingSetNodeID ID;
6809 DependentDecltypeType::Profile(ID, *
this, E);
6811 llvm::FoldingSetInsertToken
Token;
6812 if (DependentDecltypeType *Canon = DependentDecltypeTypes.lookup(ID,
Token))
6817 new (*
this,
alignof(DependentDecltypeType)) DependentDecltypeType(E);
6818 DependentDecltypeTypes.insert(DT,
Token);
6819 Types.push_back(DT);
6822 auto *DT =
new (*
this,
alignof(DecltypeType))
6823 DecltypeType(E, UnderlyingType, CanonType);
6824 Types.push_back(DT);
6829 bool FullySubstituted,
6833 if (FullySubstituted && Index) {
6836 llvm::FoldingSetNodeID ID;
6837 PackIndexingType::Profile(ID, *
this, Pattern.
getCanonicalType(), IndexExpr,
6838 FullySubstituted, Expansions);
6839 llvm::FoldingSetInsertToken
Token;
6840 PackIndexingType *Canon = DependentPackIndexingTypes.lookup(ID,
Token);
6843 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6847 IndexExpr, FullySubstituted, Expansions);
6848 DependentPackIndexingTypes.insert(Canon,
Token);
6854 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6856 auto *
T =
new (Mem) PackIndexingType(Canonical, Pattern, IndexExpr,
6857 FullySubstituted, Expansions);
6866 UnaryTransformType::UTTKind Kind)
const {
6869 if (BaseType->isDependentType()) {
6870 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6874 auto Key = std::make_tuple(BaseType, UnderlyingType, Kind);
6876 llvm::FoldingSetInsertToken
Token;
6877 if (UnaryTransformType *UT = UnaryTransformTypes.lookup(Key,
Token))
6881 if (!BaseType->isDependentType()) {
6885 BaseType != CanonBase) {
6891 auto *UT =
new (*
this,
alignof(UnaryTransformType))
6892 UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
6893 UnaryTransformTypes.insert(UT,
Token);
6894 Types.push_back(UT);
6907 TypeConstraintConcept.
isNull()) {
6908 assert(DeducedAsType.
isNull() &&
"");
6909 assert(TypeConstraintArgs.empty() &&
"");
6914 llvm::FoldingSetNodeID ID;
6915 AutoType::Profile(ID, *
this, DK, DeducedAsType,
Keyword,
6916 TypeConstraintConcept, TypeConstraintArgs);
6917 if (
auto const AT_iter = AutoTypes.find_as(ID); AT_iter != AutoTypes.end())
6918 return QualType(AT_iter->getSecond(), 0);
6921 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6923 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6924 if (!TypeConstraintConcept.
isNull()) {
6925 bool AnyNonCanonArgs =
false;
6929 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6930 if (TypeConstraintConcept != CanonicalConcept || AnyNonCanonArgs)
6932 CanonicalConceptArgs);
6936 void *Mem =
Allocate(
sizeof(AutoType) +
6939 auto *AT =
new (Mem) AutoType(DK, DeducedAsType,
Keyword,
6940 TypeConstraintConcept, TypeConstraintArgs);
6942 llvm::FoldingSetNodeID InsertedID;
6943 AT->Profile(InsertedID, *
this);
6944 assert(InsertedID == ID &&
"ID does not match");
6946 Types.push_back(AT);
6947 AutoTypes.try_emplace(ID.Intern(BumpAlloc), AT);
6952 QualType CanonT =
T.getNonPackExpansionType().getCanonicalType();
6955 if (
auto *AT = CanonT->
getAs<AutoType>()) {
6956 if (!AT->isConstrained())
6978 llvm::FoldingSetInsertToken
Token;
6979 llvm::FoldingSetNodeID ID;
6980 DeducedTemplateSpecializationType::Profile(ID, DK, DeducedAsType,
Keyword,
6982 if (DeducedTemplateSpecializationType *DTST =
6983 DeducedTemplateSpecializationTypes.lookup(ID,
Token))
6987 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6989 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6998 [[maybe_unused]] DeducedTemplateSpecializationType *DTST =
6999 DeducedTemplateSpecializationTypes.lookup(ID,
Token);
7000 assert(!DTST &&
"broken canonicalization");
7004 auto *DTST =
new (*
this,
alignof(DeducedTemplateSpecializationType))
7005 DeducedTemplateSpecializationType(DK, DeducedAsType,
Keyword,
Template);
7008 llvm::FoldingSetNodeID TempID;
7009 DTST->Profile(TempID);
7010 assert(ID == TempID &&
"ID does not match");
7012 Types.push_back(DTST);
7013 DeducedTemplateSpecializationTypes.insert(DTST,
Token);
7022 llvm::FoldingSetInsertToken
Token;
7029 if (!
T.isCanonical()) {
7032 assert(!AtomicTypes.lookup(
T,
Token) &&
"Shouldn't be in the map!");
7035 Types.push_back(
New);
7044 new (*
this,
alignof(AutoType))
7068 return getFromTargetType(Target->getSizeType());
7087 return getFromTargetType(Target->getUnsignedPtrDiffType(
LangAS::Default));
7092 return getFromTargetType(Target->getIntMaxType());
7097 return getFromTargetType(Target->getUIntMaxType());
7115 return getFromTargetType(Target->getIntPtrType());
7125 return getFromTargetType(Target->getProcessIDType());
7137 const Type *Ty =
T.getTypePtr();
7165 quals = splitType.
Quals;
7170 QualType elementType = AT->getElementType();
7175 if (elementType == unqualElementType) {
7176 assert(quals.
empty());
7177 quals = splitType.
Quals;
7185 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7187 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7190 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7194 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7196 VAT->getSizeModifier(),
7197 VAT->getIndexTypeCVRQualifiers());
7202 DSAT->getSizeModifier(), 0);
7212 bool AllowPiMismatch)
const {
7227 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7228 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7229 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7242 T1 = AT1->getElementType();
7243 T2 = AT2->getElementType();
7263 bool AllowPiMismatch)
const {
7268 if (T1PtrType && T2PtrType) {
7276 T1MPType && T2MPType) {
7279 if (T1MPType->getQualifier() != T2MPType->getQualifier())
7291 if (T1OPType && T2OPType) {
7323 if (Quals1 != Quals2)
7397 llvm_unreachable(
"bad template name kind!");
7403 if (!TP->hasDefaultArgument())
7405 return &TP->getDefaultArgument().getArgument();
7408 case NamedDecl::TemplateTypeParm:
7410 case NamedDecl::NonTypeTemplateParm:
7412 case NamedDecl::TemplateTemplateParm:
7415 llvm_unreachable(
"Unexpected template parameter kind");
7420 bool IgnoreDeduced)
const {
7421 while (std::optional<TemplateName> UnderlyingOrNone =
7423 Name = *UnderlyingOrNone;
7428 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7440 llvm_unreachable(
"cannot canonicalize overloaded template");
7444 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7473 assert(IgnoreDeduced ==
false);
7480 bool NonCanonical = CanonUnderlying != Underlying;
7486 assert(CanonArgs.size() <= Params.size());
7492 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7501 if (I ==
int(CanonArgs.size() - 1))
7502 CanonArgs.pop_back();
7503 NonCanonical =
true;
7513 llvm_unreachable(
"always sugar node");
7516 llvm_unreachable(
"bad template name!");
7521 bool IgnoreDeduced)
const {
7542 llvm::FoldingSetNodeID XCEID, YCEID;
7543 XCE->
Profile(XCEID, *
this,
true,
true);
7544 YCE->
Profile(YCEID, *
this,
true,
true);
7545 return XCEID == YCEID;
7594 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7596 if (TX->isParameterPack() != TY->isParameterPack())
7598 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7601 TY->getTypeConstraint());
7604 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7606 return TX->isParameterPack() == TY->isParameterPack() &&
7607 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7609 TY->getPlaceholderTypeConstraint());
7614 return TX->isParameterPack() == TY->isParameterPack() &&
7616 TY->getTemplateParameters());
7621 if (
X->size() != Y->
size())
7624 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7638 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7640 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7643 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7644 TTPY->getDefaultArgument().getArgument().getAsType());
7647 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7649 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7652 Expr *DefaultArgumentX =
7653 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7654 Expr *DefaultArgumentY =
7655 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7656 llvm::FoldingSetNodeID XID, YID;
7657 DefaultArgumentX->
Profile(XID, *
this,
true);
7658 DefaultArgumentY->
Profile(YID, *
this,
true);
7665 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7680 auto Kind =
X.getKind();
7688 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7691 NamespaceY->getNamespace()))
7696 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7697 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7706 llvm_unreachable(
"unhandled qualifier kind");
7712 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7714 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7726 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7730 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7731 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7732 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7735 if (!Cand1A || !Cand2A)
7741 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7742 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7746 if (Cand1ID != Cand2ID)
7780 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7781 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7783 TypedefY->getUnderlyingType());
7800 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7802 return (TagX->getTagKind() == TagY->getTagKind()) ||
7814 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7816 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7818 if (CtorX->getInheritedConstructor() &&
7819 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7820 CtorY->getInheritedConstructor().getConstructor()))
7824 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7829 if (FuncX->isMultiVersion()) {
7830 const auto *TAX = FuncX->getAttr<TargetAttr>();
7831 const auto *TAY = FuncY->getAttr<TargetAttr>();
7832 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7834 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7840 if ((FuncX->isMemberLikeConstrainedFriend() ||
7841 FuncY->isMemberLikeConstrainedFriend()) &&
7842 !FuncX->getLexicalDeclContext()->Equals(
7843 FuncY->getLexicalDeclContext())) {
7848 FuncY->getTrailingRequiresClause()))
7856 FD = FD->getCanonicalDecl();
7857 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7860 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7875 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7880 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7882 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7885 if (VarX->getType().isNull() || VarY->getType().isNull())
7888 if (
hasSameType(VarX->getType(), VarY->getType()))
7898 if (!VarXTy || !VarYTy)
7907 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7909 return NamespaceX->isInline() == NamespaceY->isInline();
7914 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7918 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7921 ConceptY->getConstraintExpr()))
7926 TemplateY->getTemplatedDecl()) &&
7928 TemplateY->getTemplateParameters());
7932 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7935 return hasSameType(FDX->getType(), FDY->getType());
7939 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7941 return IFDX->getAnonField()->getCanonicalDecl() ==
7942 IFDY->getAnonField()->getCanonicalDecl();
7951 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7958 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7961 UX->hasTypename() == UY->hasTypename() &&
7962 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7964 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7967 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7969 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7977 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
7979 UX->getInstantiatedFromUsingDecl(),
7984 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
7986 return NAX->getNamespace()->Equals(NAY->getNamespace());
7989 if (
const auto *UX = dyn_cast<UsingEnumDecl>(
X)) {
8040 bool AnyNonCanonArgs =
false;
8043 if (!AnyNonCanonArgs)
8053 llvm_unreachable(
"Unhandled template argument kind");
8063 llvm_unreachable(
"Comparing NULL template argument");
8088 llvm::FoldingSetNodeID ID1, ID2;
8098 return isSameTemplateArgument(Arg1, Arg2);
8102 llvm_unreachable(
"Unhandled template argument kind");
8107 if (!
T.hasLocalQualifiers()) {
8109 if (
const auto *AT = dyn_cast<ArrayType>(
T))
8129 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
8130 if (!ATy || qs.
empty())
8137 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
8140 CAT->getSizeModifier(),
8141 CAT->getIndexTypeCVRQualifiers()));
8142 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
8144 IAT->getSizeModifier(),
8145 IAT->getIndexTypeCVRQualifiers()));
8147 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
8149 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
8150 DSAT->getIndexTypeCVRQualifiers()));
8155 VAT->getIndexTypeCVRQualifiers()));
8163 if (
T->isArrayType() ||
T->isFunctionType())
8171 return T.getUnqualifiedType();
8182 if (
T->isArrayType() ||
T->isFunctionType())
8184 return T.getUnqualifiedType();
8199 assert(PrettyArrayType &&
"Not an array type!");
8233 uint64_t ElementCount = 1;
8236 CA = dyn_cast_if_present<ConstantArrayType>(
8239 return ElementCount;
8247 uint64_t ElementCount = 1;
8251 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8254 return ElementCount;
8264 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8266 case BuiltinType::Half:
return HalfRank;
8267 case BuiltinType::Float:
return FloatRank;
8300unsigned ASTContext::getIntegerRank(
const Type *
T)
const {
8301 assert(
T->isCanonicalUnqualified() &&
"T should be canonicalized");
8305 if (
const auto *EIT = dyn_cast<BitIntType>(
T))
8306 return 0 + (EIT->getNumBits() << 3);
8308 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(
T))
8309 return getIntegerRank(OBT->getUnderlyingType().getTypePtr());
8312 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8313 case BuiltinType::Bool:
8315 case BuiltinType::Char_S:
8316 case BuiltinType::Char_U:
8317 case BuiltinType::SChar:
8318 case BuiltinType::UChar:
8320 case BuiltinType::Short:
8321 case BuiltinType::UShort:
8323 case BuiltinType::Int:
8324 case BuiltinType::UInt:
8326 case BuiltinType::Long:
8327 case BuiltinType::ULong:
8329 case BuiltinType::LongLong:
8330 case BuiltinType::ULongLong:
8332 case BuiltinType::Int128:
8333 case BuiltinType::UInt128:
8338 case BuiltinType::Char8:
8340 case BuiltinType::Char16:
8341 return getIntegerRank(
8343 case BuiltinType::Char32:
8344 return getIntegerRank(
8346 case BuiltinType::WChar_S:
8347 case BuiltinType::WChar_U:
8348 return getIntegerRank(
8378 uint64_t BitWidth = Field->getBitWidthValue();
8404 if (BitWidth < IntSize)
8407 if (BitWidth == IntSize)
8422 assert(!Promotable.
isNull());
8425 return ED->getPromotionType();
8429 if (
const auto *OBT = Promotable->
getAs<OverflowBehaviorType>()) {
8442 if (BT->getKind() == BuiltinType::WChar_S ||
8443 BT->getKind() == BuiltinType::WChar_U ||
8444 BT->getKind() == BuiltinType::Char8 ||
8445 BT->getKind() == BuiltinType::Char16 ||
8446 BT->getKind() == BuiltinType::Char32) {
8447 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8451 for (
const auto &PT : PromoteTypes) {
8453 if (FromSize < ToSize ||
8454 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8457 llvm_unreachable(
"char type should fit into long long");
8464 uint64_t PromotableSize =
getIntWidth(Promotable);
8473 while (!
T.isNull()) {
8475 return T.getObjCLifetime();
8476 if (
T->isArrayType())
8479 T = PT->getPointeeType();
8481 T = RT->getPointeeType();
8506 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8508 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8511 if (LHSC == RHSC)
return 0;
8516 unsigned LHSRank = getIntegerRank(LHSC);
8517 unsigned RHSRank = getIntegerRank(RHSC);
8519 if (LHSUnsigned == RHSUnsigned) {
8520 if (LHSRank == RHSRank)
return 0;
8521 return LHSRank > RHSRank ? 1 : -1;
8527 if (LHSRank >= RHSRank)
8537 if (RHSRank >= LHSRank)
8547 if (CFConstantStringTypeDecl)
8548 return CFConstantStringTypeDecl;
8550 assert(!CFConstantStringTagDecl &&
8551 "tag and typedef should be initialized together");
8553 CFConstantStringTagDecl->startDefinition();
8591 if (
static_cast<unsigned>(CFRuntime) <
8594 Fields[Count++] = {
IntTy,
"flags" };
8596 Fields[Count++] = {
LongTy,
"length" };
8600 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()),
"_swift_rc" };
8604 Fields[Count++] = {
IntTy,
"_ptr" };
8610 for (
unsigned i = 0; i < Count; ++i) {
8614 Fields[i].Type,
nullptr,
8617 CFConstantStringTagDecl->addDecl(Field);
8620 CFConstantStringTagDecl->completeDefinition();
8624 CFConstantStringTypeDecl =
8627 return CFConstantStringTypeDecl;
8631 if (!CFConstantStringTagDecl)
8633 return CFConstantStringTagDecl;
8643 if (ObjCSuperType.isNull()) {
8648 return ObjCSuperType;
8654 CFConstantStringTagDecl = TT->castAsRecordDecl();
8658 if (BlockDescriptorType)
8671 static const char *
const FieldNames[] = {
8676 for (
size_t i = 0; i < 2; ++i) {
8679 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8687 BlockDescriptorType = RD;
8693 if (BlockDescriptorExtendedType)
8708 static const char *
const FieldNames[] = {
8715 for (
size_t i = 0; i < 4; ++i) {
8718 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8727 BlockDescriptorExtendedType = RD;
8732 const auto *BT = dyn_cast<BuiltinType>(
T);
8741 switch (BT->getKind()) {
8742#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8743 case BuiltinType::Id: \
8745#include "clang/Basic/OpenCLImageTypes.def"
8747 case BuiltinType::OCLClkEvent:
8750 case BuiltinType::OCLEvent:
8753 case BuiltinType::OCLQueue:
8756 case BuiltinType::OCLReserveID:
8759 case BuiltinType::OCLSampler:
8778 if (!copyExpr && record->hasTrivialDestructor())
return false;
8809 llvm_unreachable(
"impossible");
8811 llvm_unreachable(
"fell out of lifetime switch!");
8819 bool &HasByrefExtendedLayout)
const {
8824 HasByrefExtendedLayout =
false;
8826 HasByrefExtendedLayout =
true;
8840 assert(Target &&
"Expected target to be initialized");
8841 const llvm::Triple &
T = Target->getTriple();
8843 if (
T.isOSWindows() &&
T.isArch64Bit())
8849 assert(Target &&
"Expected target to be initialized");
8850 const llvm::Triple &
T = Target->getTriple();
8852 if (
T.isOSWindows() &&
T.isArch64Bit())
8858 if (!ObjCInstanceTypeDecl)
8859 ObjCInstanceTypeDecl =
8861 return ObjCInstanceTypeDecl;
8867 if (
const auto *TT = dyn_cast<TypedefType>(
T))
8869 return II->isStr(
"BOOL");
8877 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8886 else if (
type->isArrayType())
8905 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8912 !D->isInlineSpecified() && (D->isConstexpr() ||
First->isConstexpr()))
8943 for (
auto *PI :
Decl->parameters()) {
8948 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8957 ParmOffset = PtrSize;
8958 for (
auto *PVDecl :
Decl->parameters()) {
8959 QualType PType = PVDecl->getOriginalType();
8960 if (
const auto *AT =
8965 PType = PVDecl->getType();
8967 PType = PVDecl->getType();
8987 for (
auto *PI :
Decl->parameters()) {
8994 "getObjCEncodingForFunctionDecl - Incomplete param type");
9001 for (
auto *PVDecl :
Decl->parameters()) {
9002 QualType PType = PVDecl->getOriginalType();
9003 if (
const auto *AT =
9008 PType = PVDecl->getType();
9010 PType = PVDecl->getType();
9024 bool Extended)
const {
9028 ObjCEncOptions Options = ObjCEncOptions()
9029 .setExpandPointedToStructures()
9030 .setExpandStructures()
9031 .setIsOutermostType();
9033 Options.setEncodeBlockParameters().setEncodeClassNames();
9034 getObjCEncodingForTypeImpl(
T, S, Options,
nullptr);
9040 bool Extended)
const {
9045 Decl->getReturnType(), S, Extended);
9054 E =
Decl->sel_param_end(); PI != E; ++PI) {
9061 "getObjCEncodingForMethodDecl - Incomplete param type");
9069 ParmOffset = 2 * PtrSize;
9071 E =
Decl->sel_param_end(); PI != E; ++PI) {
9074 if (
const auto *AT =
9083 PType, S, Extended);
9094 const Decl *Container)
const {
9097 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
9098 for (
auto *PID : CID->property_impls())
9099 if (PID->getPropertyDecl() == PD)
9103 for (
auto *PID : OID->property_impls())
9104 if (PID->getPropertyDecl() == PD)
9138 const Decl *Container)
const {
9140 bool Dynamic =
false;
9148 SynthesizePID = PropertyImpDecl;
9152 std::string S =
"T";
9197 if (SynthesizePID) {
9214 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9217 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9230 getObjCEncodingForTypeImpl(
T, S,
9232 .setExpandPointedToStructures()
9233 .setExpandStructures()
9234 .setIsOutermostType(),
9235 Field, NotEncodedT);
9239 std::string& S)
const {
9243 getObjCEncodingForTypeImpl(
T, S,
9245 .setExpandPointedToStructures()
9246 .setExpandStructures()
9247 .setIsOutermostType()
9248 .setEncodingProperty(),
9256 case BuiltinType::Void:
return 'v';
9257 case BuiltinType::Bool:
return 'B';
9258 case BuiltinType::Char8:
9259 case BuiltinType::Char_U:
9260 case BuiltinType::UChar:
return 'C';
9261 case BuiltinType::Char16:
9262 case BuiltinType::UShort:
return 'S';
9263 case BuiltinType::Char32:
9264 case BuiltinType::UInt:
return 'I';
9265 case BuiltinType::ULong:
9266 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9267 case BuiltinType::UInt128:
return 'T';
9268 case BuiltinType::ULongLong:
return 'Q';
9269 case BuiltinType::Char_S:
9270 case BuiltinType::SChar:
return 'c';
9271 case BuiltinType::Short:
return 's';
9272 case BuiltinType::WChar_S:
9273 case BuiltinType::WChar_U:
9274 case BuiltinType::Int:
return 'i';
9275 case BuiltinType::Long:
9276 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9277 case BuiltinType::LongLong:
return 'q';
9278 case BuiltinType::Int128:
return 't';
9279 case BuiltinType::Float:
return 'f';
9280 case BuiltinType::Double:
return 'd';
9281 case BuiltinType::LongDouble:
return 'D';
9282 case BuiltinType::NullPtr:
return '*';
9284 case BuiltinType::BFloat16:
9285 case BuiltinType::Float16:
9286 case BuiltinType::Float128:
9287 case BuiltinType::Ibm128:
9288 case BuiltinType::Half:
9289 case BuiltinType::ShortAccum:
9290 case BuiltinType::Accum:
9291 case BuiltinType::LongAccum:
9292 case BuiltinType::UShortAccum:
9293 case BuiltinType::UAccum:
9294 case BuiltinType::ULongAccum:
9295 case BuiltinType::ShortFract:
9296 case BuiltinType::Fract:
9297 case BuiltinType::LongFract:
9298 case BuiltinType::UShortFract:
9299 case BuiltinType::UFract:
9300 case BuiltinType::ULongFract:
9301 case BuiltinType::SatShortAccum:
9302 case BuiltinType::SatAccum:
9303 case BuiltinType::SatLongAccum:
9304 case BuiltinType::SatUShortAccum:
9305 case BuiltinType::SatUAccum:
9306 case BuiltinType::SatULongAccum:
9307 case BuiltinType::SatShortFract:
9308 case BuiltinType::SatFract:
9309 case BuiltinType::SatLongFract:
9310 case BuiltinType::SatUShortFract:
9311 case BuiltinType::SatUFract:
9312 case BuiltinType::SatULongFract:
9316#define SVE_TYPE(Name, Id, SingletonId) \
9317 case BuiltinType::Id:
9318#include "clang/Basic/AArch64ACLETypes.def"
9319#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9320#include "clang/Basic/RISCVVTypes.def"
9321#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9322#include "clang/Basic/WebAssemblyReferenceTypes.def"
9323#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9324#include "clang/Basic/AMDGPUTypes.def"
9325#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9326#include "clang/Basic/SPIRVTypes.def"
9329 Diags.
Report(diag::err_unsupported_objc_primitive_encoding)
9334 case BuiltinType::ObjCId:
9335 case BuiltinType::ObjCClass:
9336 case BuiltinType::ObjCSel:
9337 llvm_unreachable(
"@encoding ObjC primitive type");
9340#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9341 case BuiltinType::Id:
9342#include "clang/Basic/OpenCLImageTypes.def"
9343#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9344 case BuiltinType::Id:
9345#include "clang/Basic/OpenCLExtensionTypes.def"
9346 case BuiltinType::OCLEvent:
9347 case BuiltinType::OCLClkEvent:
9348 case BuiltinType::OCLQueue:
9349 case BuiltinType::OCLReserveID:
9350 case BuiltinType::OCLSampler:
9351 case BuiltinType::Dependent:
9352#define PPC_VECTOR_TYPE(Name, Id, Size) \
9353 case BuiltinType::Id:
9354#include "clang/Basic/PPCTypes.def"
9355#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9356#include "clang/Basic/HLSLIntangibleTypes.def"
9357#define BUILTIN_TYPE(KIND, ID)
9358#define PLACEHOLDER_TYPE(KIND, ID) \
9359 case BuiltinType::KIND:
9360#include "clang/AST/BuiltinTypes.def"
9361 llvm_unreachable(
"invalid builtin type for @encode");
9363 llvm_unreachable(
"invalid BuiltinType::Kind value");
9370 if (!
Enum->isFixed())
9380 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9400 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9408 S += llvm::utostr(Offset);
9410 if (
const auto *ET =
T->getAsCanonical<EnumType>())
9423 bool VisitBasesAndFields) {
9424 T =
T->getBaseElementTypeUnsafe();
9428 PT->getPointeeType().getTypePtr(),
false);
9430 auto *CXXRD =
T->getAsCXXRecordDecl();
9438 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9441 for (
const auto &B : CXXRD->bases())
9446 for (
auto *FD : CXXRD->fields())
9455void ASTContext::getObjCEncodingForTypeImpl(QualType
T, std::string &S,
9456 const ObjCEncOptions Options,
9457 const FieldDecl *FD,
9458 QualType *NotEncodedT)
const {
9460 switch (CT->getTypeClass()) {
9465 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9473 getObjCEncodingForTypeImpl(
T->
castAs<ComplexType>()->getElementType(), S,
9480 getObjCEncodingForTypeImpl(
T->
castAs<AtomicType>()->getValueType(), S,
9487 case Type::LValueReference:
9488 case Type::RValueReference: {
9491 const auto *PT =
T->
castAs<PointerType>();
9492 if (PT->isObjCSelType()) {
9501 bool isReadOnly =
false;
9506 if (
T->
getAs<TypedefType>()) {
9507 if (Options.IsOutermostType() &&
T.isConstQualified()) {
9511 }
else if (Options.IsOutermostType()) {
9512 QualType P = PointeeTy;
9513 while (
auto PT = P->
getAs<PointerType>())
9524 if (StringRef(S).ends_with(
"nr"))
9525 S.replace(S.end()-2, S.end(),
"rn");
9535 }
else if (
const auto *RTy = PointeeTy->
getAsCanonical<RecordType>()) {
9536 const IdentifierInfo *II = RTy->getDecl()->getIdentifier();
9538 if (II == &
Idents.get(
"objc_class")) {
9543 if (II == &
Idents.get(
"objc_object")) {
9552 RTy, Options.ExpandPointedToStructures()))) {
9561 ObjCEncOptions NewOptions;
9562 if (Options.ExpandPointedToStructures())
9563 NewOptions.setExpandStructures();
9564 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9565 nullptr, NotEncodedT);
9569 case Type::ConstantArray:
9570 case Type::IncompleteArray:
9571 case Type::VariableArray: {
9578 getObjCEncodingForTypeImpl(
9579 AT->getElementType(), S,
9580 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9584 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9585 S += llvm::utostr(CAT->getZExtSize());
9589 "Unknown array type!");
9593 getObjCEncodingForTypeImpl(
9594 AT->getElementType(), S,
9595 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9602 case Type::FunctionNoProto:
9603 case Type::FunctionProto:
9607 case Type::Record: {
9609 S += RDecl->
isUnion() ?
'(' :
'{';
9613 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9614 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
9615 llvm::raw_string_ostream
OS(S);
9616 printTemplateArgumentList(OS, TemplateArgs.
asArray(),
9622 if (Options.ExpandStructures()) {
9625 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9627 for (
const auto *Field : RDecl->
fields()) {
9630 S +=
Field->getNameAsString();
9635 if (
Field->isBitField()) {
9636 getObjCEncodingForTypeImpl(
Field->getType(), S,
9637 ObjCEncOptions().setExpandStructures(),
9640 QualType qt =
Field->getType();
9642 getObjCEncodingForTypeImpl(
9644 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9650 S += RDecl->
isUnion() ?
')' :
'}';
9654 case Type::BlockPointer: {
9655 const auto *BT =
T->
castAs<BlockPointerType>();
9657 if (Options.EncodeBlockParameters()) {
9658 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
9662 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9663 Options.forComponentType(), FD, NotEncodedT);
9667 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9668 for (
const auto &I : FPT->param_types())
9669 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9677 case Type::ObjCObject: {
9681 S +=
"{objc_object=}";
9685 S +=
"{objc_class=}";
9692 case Type::ObjCInterface: {
9695 ObjCInterfaceDecl *OI =
T->
castAs<ObjCObjectType>()->getInterface();
9698 if (Options.ExpandStructures()) {
9700 SmallVector<const ObjCIvarDecl*, 32> Ivars;
9702 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9703 const FieldDecl *
Field = Ivars[i];
9704 if (
Field->isBitField())
9705 getObjCEncodingForTypeImpl(
Field->getType(), S,
9706 ObjCEncOptions().setExpandStructures(),
9709 getObjCEncodingForTypeImpl(
Field->getType(), S,
9710 ObjCEncOptions().setExpandStructures(), FD,
9718 case Type::ObjCObjectPointer: {
9719 const auto *OPT =
T->
castAs<ObjCObjectPointerType>();
9720 if (OPT->isObjCIdType()) {
9725 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9733 if (OPT->isObjCQualifiedIdType()) {
9734 getObjCEncodingForTypeImpl(
9736 Options.keepingOnly(ObjCEncOptions()
9737 .setExpandPointedToStructures()
9738 .setExpandStructures()),
9740 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9744 for (
const auto *I : OPT->quals()) {
9746 S += I->getObjCRuntimeNameAsString();
9755 if (OPT->getInterfaceDecl() &&
9756 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9758 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9759 for (
const auto *I : OPT->quals()) {
9761 S += I->getObjCRuntimeNameAsString();
9771 case Type::MemberPointer:
9775 case Type::ExtVector:
9781 case Type::ConstantMatrix:
9794 case Type::DeducedTemplateSpecialization:
9797 case Type::HLSLAttributedResource:
9798 case Type::HLSLInlineSpirv:
9799 case Type::OverflowBehavior:
9800 llvm_unreachable(
"unexpected type");
9802 case Type::ArrayParameter:
9804#define ABSTRACT_TYPE(KIND, BASE)
9805#define TYPE(KIND, BASE)
9806#define DEPENDENT_TYPE(KIND, BASE) \
9808#define NON_CANONICAL_TYPE(KIND, BASE) \
9810#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9812#include "clang/AST/TypeNodes.inc"
9813 llvm_unreachable(
"@encode for dependent type!");
9815 llvm_unreachable(
"bad type kind!");
9818void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
9820 const FieldDecl *FD,
9822 QualType *NotEncodedT)
const {
9823 assert(RDecl &&
"Expected non-null RecordDecl");
9824 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9828 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9829 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9833 for (
const auto &BI : CXXRec->bases()) {
9834 if (!BI.isVirtual()) {
9839 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9840 std::make_pair(offs, base));
9845 for (FieldDecl *Field : RDecl->
fields()) {
9846 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9849 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9850 std::make_pair(offs, Field));
9853 if (CXXRec && includeVBases) {
9854 for (
const auto &BI : CXXRec->vbases()) {
9860 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9861 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9862 std::make_pair(offs, base));
9876 std::multimap<uint64_t, NamedDecl *>::iterator
9877 CurLayObj = FieldOrBaseOffsets.begin();
9879 if (CXXRec && CXXRec->isDynamicClass() &&
9880 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9883 std::string recname = CXXRec->getNameAsString();
9884 if (recname.empty()) recname =
"?";
9897 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9898 std::make_pair(offs,
nullptr));
9901 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9903 assert(CurOffs <= CurLayObj->first);
9904 if (CurOffs < CurLayObj->first) {
9905 uint64_t padding = CurLayObj->first - CurOffs;
9917 NamedDecl *dcl = CurLayObj->second;
9921 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9926 getObjCEncodingForStructureImpl(base, S, FD,
false,
9936 S += field->getNameAsString();
9940 if (field->isBitField()) {
9943 CurOffs += field->getBitWidthValue();
9946 QualType qt = field->getType();
9948 getObjCEncodingForTypeImpl(
9949 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9960 std::string& S)
const {
9993 if (!ObjCClassDecl) {
9998 return ObjCClassDecl;
10002 if (!ObjCProtocolClassDecl) {
10003 ObjCProtocolClassDecl
10006 &
Idents.get(
"Protocol"),
10012 return ObjCProtocolClassDecl;
10033 QualType T = Context->getPointerType(Context->CharTy);
10034 return Context->buildImplicitTypedef(
T, Name);
10043 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 2);
10044 QualType T = Context->getPointerType(Context->CharTy);
10047 return Context->buildImplicitTypedef(
ArrayType,
"__builtin_zos_va_list");
10056 QualType T = Context->getPointerType(Context->VoidTy);
10057 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10060static TypedefDecl *
10064 if (Context->getLangOpts().CPlusPlus) {
10069 &Context->Idents.get(
"std"),
10077 const size_t NumFields = 5;
10079 const char *FieldNames[NumFields];
10082 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10083 FieldNames[0] =
"__stack";
10086 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10087 FieldNames[1] =
"__gr_top";
10090 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10091 FieldNames[2] =
"__vr_top";
10094 FieldTypes[3] = Context->IntTy;
10095 FieldNames[3] =
"__gr_offs";
10098 FieldTypes[4] = Context->IntTy;
10099 FieldNames[4] =
"__vr_offs";
10102 for (
unsigned i = 0; i < NumFields; ++i) {
10107 &Context->Idents.get(FieldNames[i]),
10108 FieldTypes[i],
nullptr,
10120 return Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10127 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10130 const size_t NumFields = 5;
10132 const char *FieldNames[NumFields];
10135 FieldTypes[0] = Context->UnsignedCharTy;
10136 FieldNames[0] =
"gpr";
10139 FieldTypes[1] = Context->UnsignedCharTy;
10140 FieldNames[1] =
"fpr";
10143 FieldTypes[2] = Context->UnsignedShortTy;
10144 FieldNames[2] =
"reserved";
10147 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10148 FieldNames[3] =
"overflow_arg_area";
10151 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
10152 FieldNames[4] =
"reg_save_area";
10155 for (
unsigned i = 0; i < NumFields; ++i) {
10159 &Context->Idents.get(FieldNames[i]),
10160 FieldTypes[i],
nullptr,
10173 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10177 std::nullopt, VaListTagTypedefDecl);
10180 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10181 QualType VaListTagArrayType = Context->getConstantArrayType(
10183 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10186static TypedefDecl *
10190 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10193 const size_t NumFields = 4;
10195 const char *FieldNames[NumFields];
10198 FieldTypes[0] = Context->UnsignedIntTy;
10199 FieldNames[0] =
"gp_offset";
10202 FieldTypes[1] = Context->UnsignedIntTy;
10203 FieldNames[1] =
"fp_offset";
10206 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10207 FieldNames[2] =
"overflow_arg_area";
10210 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10211 FieldNames[3] =
"reg_save_area";
10214 for (
unsigned i = 0; i < NumFields; ++i) {
10219 &Context->Idents.get(FieldNames[i]),
10220 FieldTypes[i],
nullptr,
10234 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10235 QualType VaListTagArrayType = Context->getConstantArrayType(
10237 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10240static TypedefDecl *
10243 RecordDecl *VaListDecl = Context->buildImplicitRecord(
"__va_list");
10244 if (Context->getLangOpts().CPlusPlus) {
10263 &Context->Idents.get(
"__ap"),
10264 Context->getPointerType(Context->VoidTy),
10274 Context->VaListTagDecl = VaListDecl;
10277 CanQualType T = Context->getCanonicalTagType(VaListDecl);
10278 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10281static TypedefDecl *
10285 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10288 const size_t NumFields = 4;
10290 const char *FieldNames[NumFields];
10293 FieldTypes[0] = Context->LongTy;
10294 FieldNames[0] =
"__gpr";
10297 FieldTypes[1] = Context->LongTy;
10298 FieldNames[1] =
"__fpr";
10301 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10302 FieldNames[2] =
"__overflow_arg_area";
10305 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10306 FieldNames[3] =
"__reg_save_area";
10309 for (
unsigned i = 0; i < NumFields; ++i) {
10314 &Context->Idents.get(FieldNames[i]),
10315 FieldTypes[i],
nullptr,
10329 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10330 QualType VaListTagArrayType = Context->getConstantArrayType(
10333 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10339 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10342 const size_t NumFields = 3;
10344 const char *FieldNames[NumFields];
10347 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10348 FieldNames[0] =
"__current_saved_reg_area_pointer";
10351 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10352 FieldNames[1] =
"__saved_reg_area_end_pointer";
10355 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10356 FieldNames[2] =
"__overflow_area_pointer";
10359 for (
unsigned i = 0; i < NumFields; ++i) {
10362 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
10375 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10379 std::nullopt, VaListTagTypedefDecl);
10382 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10383 QualType VaListTagArrayType = Context->getConstantArrayType(
10386 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10389static TypedefDecl *
10399 constexpr size_t NumFields = 3;
10400 QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
10401 Context->getPointerType(Context->IntTy),
10403 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10406 for (
unsigned i = 0; i < NumFields; ++i) {
10409 &Context->Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
10421 Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10423 return VaListTagTypedefDecl;
10449 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10453 if (!BuiltinVaListDecl) {
10454 BuiltinVaListDecl =
CreateVaListDecl(
this, Target->getBuiltinVaListKind());
10455 assert(BuiltinVaListDecl->isImplicit());
10458 return BuiltinVaListDecl;
10471 if (!BuiltinMSVaListDecl)
10474 return BuiltinMSVaListDecl;
10478 if (!BuiltinZOSVaListDecl)
10481 return BuiltinZOSVaListDecl;
10498 assert(ObjCConstantStringType.isNull() &&
10499 "'NSConstantString' type already set!");
10509 unsigned size = End - Begin;
10510 assert(size > 1 &&
"set is not overloaded!");
10516 NamedDecl **Storage = OT->getStorage();
10539 bool TemplateKeyword,
10544 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10545 assert(!Qualifier &&
"unexpected qualified template template parameter");
10546 assert(TemplateKeyword ==
false);
10551 llvm::FoldingSetNodeID ID;
10554 llvm::FoldingSetInsertToken
Token;
10559 QualifiedTemplateNames.insert(QTN,
Token);
10569 llvm::FoldingSetNodeID ID;
10572 llvm::FoldingSetInsertToken
Token;
10578 DependentTemplateNames.insert(QTN,
Token);
10583 Decl *AssociatedDecl,
10586 bool Final)
const {
10587 llvm::FoldingSetNodeID ID;
10591 llvm::FoldingSetInsertToken
Token;
10593 SubstTemplateTemplateParms.lookup(ID,
Token);
10597 Replacement, AssociatedDecl, Index,
PackIndex, Final);
10598 SubstTemplateTemplateParms.insert(subst,
Token);
10606 Decl *AssociatedDecl,
10607 unsigned Index,
bool Final)
const {
10609 llvm::FoldingSetNodeID ID;
10611 AssociatedDecl, Index, Final);
10613 llvm::FoldingSetInsertToken
Token;
10615 SubstTemplateTemplateParmPacks.lookup(ID,
Token);
10620 SubstTemplateTemplateParmPacks.insert(Subst,
Token);
10634 llvm::FoldingSetNodeID ID;
10637 llvm::FoldingSetInsertToken
Token;
10644 DeducedTemplates.insert(DTS,
Token);
10653 llvm::FoldingSetNodeID ID;
10655 FullySubstituted, Expansions);
10657 llvm::FoldingSetInsertToken
Token;
10661 Allocate(PackIndexingTemplateStorage::totalSizeToAlloc<TemplateName>(
10662 Expansions.size()),
10665 FullySubstituted, Expansions);
10666 PackIndexingTemplates.insert(PI,
Token);
10689 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10719 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10720 CT = AT->getElementType();
10752 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10753 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10810 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
10811 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
10813 if (!LHSOBT && !RHSOBT)
10816 if (LHSOBT && RHSOBT) {
10817 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
10822 QualType LHSUnderlying = LHSOBT ? LHSOBT->desugar() : LHS;
10823 QualType RHSUnderlying = RHSOBT ? RHSOBT->desugar() : RHS;
10825 if (RHSOBT && !LHSOBT) {
10836 auto VScale = Context.getTargetInfo().getVScaleRange(
10843 uint64_t EltSize = Context.getTypeSize(Info.
ElementType);
10847 uint64_t MinElts = Info.
EC.getKnownMinValue();
10848 return VScale->first * MinElts * EltSize;
10856 "Expected RVV builtin type and vector type!");
10896 return IsValidCast(FirstType, SecondType) ||
10897 IsValidCast(SecondType, FirstType);
10905 "Expected RVV builtin type and vector type!");
10912 if (!BT->isRVVVLSBuiltinType())
10932 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10939 return IsLaxCompatible(FirstType, SecondType) ||
10940 IsLaxCompatible(SecondType, FirstType);
10946 if (
const AttributedType *
Attr = dyn_cast<AttributedType>(Ty)) {
10947 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10950 Ty =
Attr->getModifiedType();
10954 Ty =
Paren->getInnerType();
10986 for (
auto *lhsProto : lhs->
quals()) {
10987 bool match =
false;
10988 for (
auto *rhsProto : rhs->
quals()) {
11019 for (
auto *I : lhs->
quals()) {
11023 if (!rhsID->ClassImplementsProtocol(I,
true))
11031 for (
auto *lhsProto : lhs->
quals()) {
11032 bool match =
false;
11037 for (
auto *rhsProto : rhs->
quals()) {
11047 for (
auto *I : lhs->
quals()) {
11051 if (rhsID->ClassImplementsProtocol(I,
true)) {
11068 for (
auto *lhsProto : lhs->
quals()) {
11069 bool match =
false;
11076 for (
auto *rhsProto : rhs->
quals()) {
11095 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
11097 for (
auto *lhsProto : LHSInheritedProtocols) {
11098 bool match =
false;
11099 for (
auto *rhsProto : rhs->
quals()) {
11124 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
11129 auto finish = [&](
bool succeeded) ->
bool {
11133 if (!RHS->isKindOfType())
11144 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
11149 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
11154 if (LHS->isObjCClass() && RHS->isObjCClass()) {
11159 if (LHS->getInterface() && RHS->getInterface()) {
11174 bool BlockReturnType) {
11178 auto finish = [&](
bool succeeded) ->
bool {
11203 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
11207 (!BlockReturnType &&
11211 (BlockReturnType ? LHSOPT : RHSOPT),
11212 (BlockReturnType ? RHSOPT : LHSOPT),
false));
11220 return finish(BlockReturnType);
11222 return finish(!BlockReturnType);
11234 return (*lhs)->getName().compare((*rhs)->getName());
11251 assert(LHS->getInterface() &&
"LHS must have an interface base");
11252 assert(RHS->getInterface() &&
"RHS must have an interface base");
11258 for (
auto *proto : LHS->quals()) {
11259 Context.CollectInheritedProtocols(proto, LHSProtocolSet);
11263 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
11269 for (
auto *proto : RHS->quals()) {
11270 Context.CollectInheritedProtocols(proto, RHSProtocolSet);
11274 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
11277 for (
auto *proto : LHSProtocolSet) {
11278 if (RHSProtocolSet.count(proto))
11279 IntersectionSet.push_back(proto);
11285 Context.CollectInheritedProtocols(CommonBase, ImpliedProtocols);
11288 if (!ImpliedProtocols.empty()) {
11290 return ImpliedProtocols.contains(proto);
11295 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11305 if (lhsOPT && rhsOPT)
11311 if (lhsBlock && rhsBlock)
11316 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11328 bool stripKindOf) {
11329 if (lhsArgs.size() != rhsArgs.size())
11336 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11342 if (!stripKindOf ||
11343 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11344 rhsArgs[i].stripObjCKindOfType(ctx))) {
11372 if (!LDecl || !RDecl)
11378 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
11382 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11387 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
11392 bool anyChanges =
false;
11393 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11396 LHS->getTypeArgs(), RHS->getTypeArgs(),
11399 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11410 if (!Protocols.empty())
11416 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
11419 anyKindOf || LHS->isKindOfType());
11427 QualType LHSSuperType = LHS->getSuperClassType();
11428 if (LHSSuperType.
isNull())
11437 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
11438 if (KnownLHS != LHSAncestors.end()) {
11439 LHS = KnownLHS->second;
11443 bool anyChanges =
false;
11444 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11447 LHS->getTypeArgs(), RHS->getTypeArgs(),
11450 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11461 if (!Protocols.empty())
11466 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
11469 anyKindOf || RHS->isKindOfType());
11477 QualType RHSSuperType = RHS->getSuperClassType();
11478 if (RHSSuperType.
isNull())
11489 assert(LHS->getInterface() &&
"LHS is not an interface type");
11490 assert(RHS->getInterface() &&
"RHS is not an interface type");
11495 bool IsSuperClass = LHSInterface->
isSuperClassOf(RHS->getInterface());
11502 if (LHS->getNumProtocols() > 0) {
11511 for (
auto *RHSPI : RHS->quals())
11514 if (SuperClassInheritedProtocols.empty())
11517 for (
const auto *LHSProto : LHS->quals()) {
11518 bool SuperImplementsProtocol =
false;
11519 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11520 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11521 SuperImplementsProtocol =
true;
11524 if (!SuperImplementsProtocol)
11530 if (LHS->isSpecialized()) {
11535 RHSSuper = RHSSuper->getSuperClassType()->castAs<
ObjCObjectType>();
11538 if (RHSSuper->isSpecialized() &&
11540 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
11554 if (!LHSOPT || !RHSOPT)
11572 bool CompareUnqualified) {
11591 bool OfBlockPointer,
11593 if (
const RecordType *UT =
T->getAsUnionType()) {
11595 if (UD->
hasAttr<TransparentUnionAttr>()) {
11596 for (
const auto *I : UD->
fields()) {
11597 QualType ET = I->getType().getUnqualifiedType();
11611 bool OfBlockPointer,
11632 bool IsConditionalOperator) {
11635 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11636 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11637 bool allLTypes =
true;
11638 bool allRTypes =
true;
11642 if (OfBlockPointer) {
11644 QualType LHS = lbase->getReturnType();
11646 if (!UnqualifiedResult)
11648 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11713 bool NoReturn = IsConditionalOperator
11723 std::optional<FunctionEffectSet> MergedFX;
11725 if (lproto && rproto) {
11726 assert((AllowCXX ||
11727 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11728 "C++ shouldn't be here");
11730 if (lproto->getNumParams() != rproto->getNumParams())
11734 if (lproto->isVariadic() != rproto->isVariadic())
11737 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11741 if (lproto->getExtraAttributeInfo().CFISalt !=
11742 rproto->getExtraAttributeInfo().CFISalt)
11748 if (LHSFX != RHSFX) {
11749 if (IsConditionalOperator)
11758 if (*MergedFX != LHSFX)
11760 if (*MergedFX != RHSFX)
11765 bool canUseLeft, canUseRight;
11777 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11778 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11779 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11781 lParamType, rParamType, OfBlockPointer,
Unqualified);
11788 types.push_back(paramType);
11800 if (allLTypes)
return lhs;
11801 if (allRTypes)
return rhs;
11806 newParamInfos.empty() ?
nullptr : newParamInfos.data();
11812 if (lproto) allRTypes =
false;
11813 if (rproto) allLTypes =
false;
11817 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11825 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11831 paramTy = ED->getIntegerType();
11841 if (allLTypes)
return lhs;
11842 if (allRTypes)
return rhs;
11851 if (allLTypes)
return lhs;
11852 if (allRTypes)
return rhs;
11858 QualType other,
bool isBlockReturnType) {
11864 ET->getDecl()->getDefinitionOrSelf()->getIntegerType();
11865 if (underlyingType.
isNull())
11867 if (Context.hasSameType(underlyingType, other))
11873 Context.getTypeSize(underlyingType) == Context.getTypeSize(other))
11882 if (LangOpts.CPlusPlus || !LangOpts.C23)
11903 bool BlockReturnType,
bool IsConditionalOperator) {
11904 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
11905 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
11907 if (!LHSOBT && !RHSOBT)
11908 return std::nullopt;
11912 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
11916 LHSOBT->getUnderlyingType(), RHSOBT->getUnderlyingType(),
11917 OfBlockPointer,
Unqualified, BlockReturnType, IsConditionalOperator);
11919 if (MergedUnderlying.
isNull())
11923 if (LHSOBT->getUnderlyingType() == RHSOBT->getUnderlyingType())
11926 LHSOBT->getBehaviorKind(),
11935 return mergeTypes(LHSOBT->getUnderlyingType(), RHS, OfBlockPointer,
11936 Unqualified, BlockReturnType, IsConditionalOperator);
11939 return mergeTypes(LHS, RHSOBT->getUnderlyingType(), OfBlockPointer,
11940 Unqualified, BlockReturnType, IsConditionalOperator);
11945 bool IsConditionalOperator) {
11956 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11960 if (LHSRefTy || RHSRefTy)
11963 if (std::optional<QualType> MergedOBT =
11965 BlockReturnType, IsConditionalOperator))
11977 if (LHSCan == RHSCan)
11982 Qualifiers RQuals = RHSCan.getLocalQualifiers();
11983 if (LQuals != RQuals) {
12000 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12021 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
12022 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
12025 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
12026 LHSClass = Type::ConstantArray;
12027 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
12028 RHSClass = Type::ConstantArray;
12031 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
12032 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
12035 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
12036 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
12039 if (LHSClass != RHSClass) {
12049 if (OfBlockPointer && !BlockReturnType) {
12057 if (
const auto *AT = LHS->
getAs<AutoType>()) {
12058 if (!AT->isDeduced() && AT->isGNUAutoType())
12061 if (
const auto *AT = RHS->
getAs<AutoType>()) {
12062 if (!AT->isDeduced() && AT->isGNUAutoType())
12069 switch (LHSClass) {
12070#define TYPE(Class, Base)
12071#define ABSTRACT_TYPE(Class, Base)
12072#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
12073#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
12074#define DEPENDENT_TYPE(Class, Base) case Type::Class:
12075#include "clang/AST/TypeNodes.inc"
12076 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
12079 case Type::DeducedTemplateSpecialization:
12080 case Type::LValueReference:
12081 case Type::RValueReference:
12082 case Type::MemberPointer:
12083 llvm_unreachable(
"C++ should never be in mergeTypes");
12085 case Type::ObjCInterface:
12086 case Type::IncompleteArray:
12087 case Type::VariableArray:
12088 case Type::FunctionProto:
12089 case Type::ExtVector:
12090 case Type::OverflowBehavior:
12091 llvm_unreachable(
"Types are eliminated above");
12093 case Type::Pointer:
12104 if (ResultType.
isNull())
12112 case Type::BlockPointer:
12137 if (ResultType.
isNull())
12156 if (ResultType.
isNull())
12164 case Type::ConstantArray:
12179 if (ResultType.
isNull())
12187 if (LVAT || RVAT) {
12190 -> std::pair<bool,llvm::APInt> {
12192 std::optional<llvm::APSInt> TheInt;
12195 return std::make_pair(
true, *TheInt);
12196 return std::make_pair(
false, llvm::APSInt());
12199 return std::make_pair(
true, CAT->getSize());
12200 return std::make_pair(
false, llvm::APInt());
12203 bool HaveLSize, HaveRSize;
12204 llvm::APInt LSize, RSize;
12205 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
12206 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
12207 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
12241 case Type::FunctionNoProto:
12243 false, IsConditionalOperator);
12247 case Type::Builtin:
12250 case Type::Complex:
12259 case Type::ConstantMatrix:
12264 case Type::ObjCObject: {
12273 case Type::ObjCObjectPointer:
12274 if (OfBlockPointer) {
12286 assert(LHS != RHS &&
12287 "Equivalent pipe types should have already been handled!");
12289 case Type::ArrayParameter:
12290 assert(LHS != RHS &&
12291 "Equivalent ArrayParameter types should have already been handled!");
12293 case Type::BitInt: {
12301 if (LHSUnsigned != RHSUnsigned)
12304 if (LHSBits != RHSBits)
12308 case Type::HLSLAttributedResource: {
12309 const HLSLAttributedResourceType *LHSTy =
12310 LHS->
castAs<HLSLAttributedResourceType>();
12311 const HLSLAttributedResourceType *RHSTy =
12312 RHS->
castAs<HLSLAttributedResourceType>();
12313 assert(LHSTy->getWrappedType() == RHSTy->getWrappedType() &&
12314 LHSTy->getWrappedType()->isHLSLResourceType() &&
12315 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
12317 if (LHSTy->getAttrs() == RHSTy->getAttrs() &&
12318 LHSTy->getContainedType() == RHSTy->getContainedType())
12322 case Type::HLSLInlineSpirv:
12323 const HLSLInlineSpirvType *LHSTy = LHS->
castAs<HLSLInlineSpirvType>();
12324 const HLSLInlineSpirvType *RHSTy = RHS->
castAs<HLSLInlineSpirvType>();
12326 if (LHSTy->getOpcode() == RHSTy->getOpcode() &&
12327 LHSTy->getSize() == RHSTy->getSize() &&
12328 LHSTy->getAlignment() == RHSTy->getAlignment()) {
12329 for (
size_t I = 0; I < LHSTy->getOperands().size(); I++)
12330 if (LHSTy->getOperands()[I] != RHSTy->getOperands()[I])
12338 llvm_unreachable(
"Invalid Type::Class!");
12343 bool &CanUseFirst,
bool &CanUseSecond,
12345 assert(NewParamInfos.empty() &&
"param info list not empty");
12346 CanUseFirst = CanUseSecond =
true;
12352 if (!FirstHasInfo && !SecondHasInfo)
12355 bool NeedParamInfo =
false;
12359 for (
size_t I = 0; I < E; ++I) {
12370 bool FirstNoEscape = FirstParam.
isNoEscape();
12371 bool SecondNoEscape = SecondParam.
isNoEscape();
12372 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12374 if (NewParamInfos.back().getOpaqueValue())
12375 NeedParamInfo =
true;
12376 if (FirstNoEscape != IsNoEscape)
12377 CanUseFirst =
false;
12378 if (SecondNoEscape != IsNoEscape)
12379 CanUseSecond =
false;
12382 if (!NeedParamInfo)
12383 NewParamInfos.clear();
12389 if (
auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
12390 It->second =
nullptr;
12391 for (
auto *SubClass : ObjCSubClasses.lookup(D))
12403 if (LHSCan == RHSCan)
12405 if (RHSCan->isFunctionType()) {
12414 if (ResReturnType.
isNull())
12416 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12433 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12440 if (LQuals != RQuals) {
12448 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12464 if (ResQT == LHSBaseQT)
12466 if (ResQT == RHSBaseQT)
12477 if (
const auto *ED =
T->getAsEnumDecl())
12478 T = ED->getIntegerType();
12479 if (
T->isBooleanType())
12482 return EIT->getNumBits();
12488 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12489 T->isFixedPointType()) &&
12490 "Unexpected type");
12495 VTy->getNumElements(), VTy->getVectorKind());
12502 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>())
12504 OBT->getBehaviorKind(),
12509 if (
const auto *ED =
T->getAsEnumDecl())
12510 T = ED->getIntegerType();
12513 case BuiltinType::Char_U:
12515 case BuiltinType::Char_S:
12516 case BuiltinType::SChar:
12517 case BuiltinType::Char8:
12519 case BuiltinType::Short:
12521 case BuiltinType::Int:
12523 case BuiltinType::Long:
12525 case BuiltinType::LongLong:
12527 case BuiltinType::Int128:
12532 case BuiltinType::WChar_S:
12535 case BuiltinType::ShortAccum:
12537 case BuiltinType::Accum:
12539 case BuiltinType::LongAccum:
12541 case BuiltinType::SatShortAccum:
12543 case BuiltinType::SatAccum:
12545 case BuiltinType::SatLongAccum:
12547 case BuiltinType::ShortFract:
12549 case BuiltinType::Fract:
12551 case BuiltinType::LongFract:
12553 case BuiltinType::SatShortFract:
12555 case BuiltinType::SatFract:
12557 case BuiltinType::SatLongFract:
12560 assert((
T->hasUnsignedIntegerRepresentation() ||
12561 T->isUnsignedFixedPointType()) &&
12562 "Unexpected signed integer or fixed point type");
12568 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12569 T->isFixedPointType()) &&
12570 "Unexpected type");
12575 VTy->getNumElements(), VTy->getVectorKind());
12583 if (
const auto *ED =
T->getAsEnumDecl())
12584 T = ED->getIntegerType();
12587 case BuiltinType::Char_S:
12589 case BuiltinType::Char_U:
12590 case BuiltinType::UChar:
12591 case BuiltinType::Char8:
12593 case BuiltinType::UShort:
12595 case BuiltinType::UInt:
12597 case BuiltinType::ULong:
12599 case BuiltinType::ULongLong:
12601 case BuiltinType::UInt128:
12606 case BuiltinType::WChar_U:
12609 case BuiltinType::UShortAccum:
12611 case BuiltinType::UAccum:
12613 case BuiltinType::ULongAccum:
12615 case BuiltinType::SatUShortAccum:
12617 case BuiltinType::SatUAccum:
12619 case BuiltinType::SatULongAccum:
12621 case BuiltinType::UShortFract:
12623 case BuiltinType::UFract:
12625 case BuiltinType::ULongFract:
12627 case BuiltinType::SatUShortFract:
12629 case BuiltinType::SatUFract:
12631 case BuiltinType::SatULongFract:
12635 (
T->hasSignedIntegerRepresentation() ||
T->isSignedFixedPointType()) &&
12636 "Unexpected signed integer or fixed point type");
12661 bool AllowTypeModifiers) {
12665 bool IsChar =
false, IsShort =
false;
12666 RequiresICE =
false;
12671 bool IsSpecial =
false;
12675 default: Done =
true; --Str;
break;
12677 RequiresICE =
true;
12680 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12681 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12685 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12686 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12691 assert(!IsSpecial &&
12692 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12693 assert(HowLong == 0 &&
"Can't use both 'L' and 'B' modifiers!");
12701 assert(!IsSpecial &&
12702 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12703 assert(HowLong == 0 &&
"Can't use both 'L' and 'T' modifiers!");
12710 assert(!IsSpecial &&
12711 "Can't use 'L' with 'W', 'N', 'Z', 'O', 'B', or 'T' modifiers");
12712 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12717 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12718 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12722 if (Context.getTargetInfo().getLongWidth() == 32)
12727 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12728 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12732 switch (Context.getTargetInfo().getInt64Type()) {
12734 llvm_unreachable(
"Unexpected integer type");
12745 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12746 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12750 switch (Context.getTargetInfo().getIntTypeByWidth(32,
true)) {
12752 llvm_unreachable(
"Unexpected integer type");
12765 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12766 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12770 if (Context.getLangOpts().OpenCL)
12783 llvm_unreachable(
"Unknown builtin type letter!");
12786 "Bad modifiers used with 'x'!");
12787 Type = Context.Float16Ty;
12791 "Bad modifiers used with 'y'!");
12792 Type = Context.BFloat16Ty;
12796 "Bad modifiers used with 'v'!");
12797 Type = Context.VoidTy;
12801 "Bad modifiers used with 'h'!");
12802 Type = Context.HalfTy;
12806 "Bad modifiers used with 'f'!");
12807 Type = Context.FloatTy;
12811 "Bad modifiers used with 'd'!");
12813 Type = Context.LongDoubleTy;
12814 else if (HowLong == 2)
12815 Type = Context.Float128Ty;
12817 Type = Context.DoubleTy;
12820 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12822 Type = Context.UnsignedShortTy;
12824 Type = Context.ShortTy;
12828 Type =
Unsigned ? Context.UnsignedCharTy : Context.SignedCharTy;
12830 Type =
Unsigned ? Context.UnsignedShortTy : Context.ShortTy;
12831 else if (HowLong == 3)
12832 Type =
Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
12833 else if (HowLong == 2)
12834 Type =
Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
12835 else if (HowLong == 1)
12836 Type =
Unsigned ? Context.UnsignedLongTy : Context.LongTy;
12838 Type =
Unsigned ? Context.UnsignedIntTy : Context.IntTy;
12841 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12843 Type = Context.SignedCharTy;
12845 Type = Context.UnsignedCharTy;
12847 Type = Context.CharTy;
12850 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12851 Type = Context.BoolTy;
12854 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12855 Type = Context.getSizeType();
12858 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12859 Type = Context.getWideCharType();
12862 Type = Context.getCFConstantStringType();
12865 Type = Context.getObjCIdType();
12868 Type = Context.getObjCSelType();
12871 Type = Context.getObjCSuperType();
12874 Type = Context.getBuiltinVaListType();
12875 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12886 Type = Context.getBuiltinVaListType();
12887 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12889 Type = Context.getArrayDecayedType(
Type);
12891 Type = Context.getLValueReferenceType(
Type);
12895 unsigned NumElements = strtoul(Str, &End, 10);
12896 assert(End != Str &&
"Missing vector size");
12900 RequiresICE,
false);
12901 assert(!RequiresICE &&
"Can't require vector ICE");
12903 Type = Context.getScalableVectorType(ElementType, NumElements);
12909 Type = Context.SveCountTy;
12913 Type = Context.AMDGPUBufferRsrcTy;
12917 Type = Context.AMDGPUFeaturePredicateTy;
12921 Type = Context.AMDGPUTextureTy;
12925 Type = Context.HLSLResourceTy;
12929 llvm_unreachable(
"Unexpected target builtin type");
12935 unsigned NumElements = strtoul(Str, &End, 10);
12936 assert(End != Str &&
"Missing vector size");
12940 RequiresICE,
false);
12941 assert(!RequiresICE &&
"Can't require vector ICE");
12950 unsigned NumElements = strtoul(Str, &End, 10);
12951 assert(End != Str &&
"Missing vector size");
12957 Type = Context.getExtVectorType(ElementType, NumElements);
12963 assert(!RequiresICE &&
"Can't require complex ICE");
12964 Type = Context.getComplexType(ElementType);
12968 Type = Context.getPointerDiffType();
12971 Type = Context.getFILEType();
12972 if (
Type.isNull()) {
12979 Type = Context.getsigjmp_bufType();
12981 Type = Context.getjmp_bufType();
12983 if (
Type.isNull()) {
12989 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
12990 Type = Context.getucontext_tType();
12992 if (
Type.isNull()) {
12998 Type = Context.getProcessIDType();
13001 Type = Context.MFloat8Ty;
13006 Done = !AllowTypeModifiers;
13008 switch (
char c = *Str++) {
13009 default: Done =
true; --Str;
break;
13015 unsigned AddrSpace = strtoul(Str, &End, 10);
13018 Type = Context.getAddrSpaceQualType(
13020 Context.getLangASForBuiltinAddressSpace(AddrSpace));
13024 Type = Context.getPointerType(
Type);
13026 Type = Context.getLValueReferenceType(
Type);
13034 Type = Context.getVolatileType(
Type);
13043 "Integer constant 'I' type must be an integer");
13056 bool AllowTypeModifiers)
const {
13063 unsigned *IntegerConstantArgs)
const {
13064 const char *TypeStr =
BuiltinInfo.getTypeString(Id);
13065 if (TypeStr[0] ==
'\0') {
13072 bool RequiresICE =
false;
13075 RequiresICE,
true);
13079 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
13081 while (TypeStr[0] && TypeStr[0] !=
'.') {
13088 if (RequiresICE && IntegerConstantArgs)
13089 *IntegerConstantArgs |= 1 << ArgTypes.size();
13095 ArgTypes.push_back(Ty);
13098 if (Id == Builtin::BI__GetExceptionInfo)
13101 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
13102 "'.' should only occur at end of builtin type list!");
13104 bool Variadic = (TypeStr[0] ==
'.');
13111 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
13161 if ((!Context.getLangOpts().CPlusPlus &&
13162 !Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13163 !FD->
hasAttr<DLLExportAttr>()) ||
13164 FD->
hasAttr<GNUInlineAttr>()) {
13183 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13186 !FD->
hasAttr<DLLExportAttr>()) {
13207 if (D->
hasAttr<DLLImportAttr>()) {
13210 }
else if (D->
hasAttr<DLLExportAttr>()) {
13213 }
else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice) {
13216 if (D->
hasAttr<CUDAGlobalAttr>() &&
13225 if (Context.shouldExternalize(D))
13240 switch (Source->hasExternalDefinitions(D)) {
13267 if (Context.getLangOpts().CPlusPlus &&
13268 Context.getLangOpts().IncrementalExtensions &&
13284 if (!LexicalContext)
13289 auto StaticLocalLinkage =
13301 return StaticLocalLinkage;
13307 if (Context.isMSStaticDataMemberInlineDefinition(VD))
13313 switch (Context.getInlineVariableDefinitionKind(VD)) {
13328 return StrongLinkage;
13331 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13346 llvm_unreachable(
"Invalid Linkage!");
13356 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13357 if (!VD->isFileVarDecl())
13362 if (VD->getDescribedVarTemplate() ||
13365 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13391 if (D->
hasAttr<WeakRefAttr>())
13398 if (LangOpts.SYCLIsDevice)
13400 D->
hasAttr<SYCLExternalAttr>());
13406 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13408 if (!FD->doesThisDeclarationHaveABody())
13409 return FD->doesDeclarationForceExternallyVisibleDefinition();
13412 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13417 if (
getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
13418 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13437 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13441 if (LangOpts.OpenMP &&
13442 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13449 if (VD->shouldEmitInExternalSource())
13462 if (VD->needsDestruction(*
this))
13466 if (VD->hasInitWithSideEffects())
13471 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13472 for (
const auto *BD : DD->flat_bindings())
13473 if (
const auto *BindingVD = BD->getHoldingVar())
13483 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13484 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13485 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13490 for (
auto *CurDecl :
13494 SeenDecls.insert(CurFD).second) {
13501 bool IsCXXMethod)
const {
13504 return ABI->getDefaultMethodCallConv(IsVariadic);
13506 switch (LangOpts.getDefaultCallingConv()) {
13534 return Target->getDefaultCallingConv();
13539 return ABI->isNearlyEmpty(RD);
13544 auto ABI = Target->getCXXABI();
13545 if (ABI.isMicrosoft())
13551 return VTContext.get();
13557 switch (
T->getCXXABI().getKind()) {
13558 case TargetCXXABI::AppleARM64:
13559 case TargetCXXABI::Fuchsia:
13560 case TargetCXXABI::GenericAArch64:
13561 case TargetCXXABI::GenericItanium:
13562 case TargetCXXABI::GenericARM:
13563 case TargetCXXABI::GenericMIPS:
13564 case TargetCXXABI::iOS:
13565 case TargetCXXABI::WebAssembly:
13566 case TargetCXXABI::WatchOS:
13567 case TargetCXXABI::XL:
13569 case TargetCXXABI::Microsoft:
13572 llvm_unreachable(
"Unsupported ABI");
13576 assert(
T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13577 "Device mangle context does not support Microsoft mangling.");
13578 switch (
T.getCXXABI().getKind()) {
13579 case TargetCXXABI::AppleARM64:
13580 case TargetCXXABI::Fuchsia:
13581 case TargetCXXABI::GenericAArch64:
13582 case TargetCXXABI::GenericItanium:
13583 case TargetCXXABI::GenericARM:
13584 case TargetCXXABI::GenericMIPS:
13585 case TargetCXXABI::iOS:
13586 case TargetCXXABI::WebAssembly:
13587 case TargetCXXABI::WatchOS:
13588 case TargetCXXABI::XL:
13592 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13593 return RD->getDeviceLambdaManglingNumber();
13594 return std::nullopt;
13597 case TargetCXXABI::Microsoft:
13601 llvm_unreachable(
"Unsupported ABI");
13619 return ASTRecordLayouts.getMemorySize() +
13620 llvm::capacity_in_bytes(ObjCLayouts) +
13621 llvm::capacity_in_bytes(KeyFunctions) +
13622 llvm::capacity_in_bytes(ObjCImpls) +
13623 llvm::capacity_in_bytes(BlockVarCopyInits) +
13624 llvm::capacity_in_bytes(DeclAttrs) +
13625 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13626 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13627 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13628 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13629 llvm::capacity_in_bytes(OverriddenMethods) +
13630 llvm::capacity_in_bytes(Types) +
13631 llvm::capacity_in_bytes(VariableArrayTypes);
13639 unsigned Signed)
const {
13642 if (!QualTy && DestWidth == 128)
13648 unsigned Signed)
const {
13649 return getFromTargetType(
13677 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13684 MangleNumbers[ND] = Number;
13687 Listener->AddedManglingNumber(ND, Number);
13691 bool ForAuxTarget)
const {
13692 auto I = MangleNumbers.find(ND);
13693 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13696 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13697 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13699 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13700 "number for aux target");
13702 return Res > 1 ? Res : 1;
13709 StaticLocalNumbers[VD] = Number;
13712 Listener->AddedStaticLocalNumbers(VD, Number);
13716 auto I = StaticLocalNumbers.find(VD);
13717 return I != StaticLocalNumbers.end() ? I->second : 1;
13721 bool IsDestroying) {
13722 if (!IsDestroying) {
13734 bool IsTypeAware) {
13735 if (!IsTypeAware) {
13751 OperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] = OperatorDelete;
13754 GlobalOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13758 ArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13762 GlobalArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13772 return OperatorDeletesForVirtualDtor.contains(Dtor->getCanonicalDecl());
13774 return GlobalOperatorDeletesForVirtualDtor.contains(
13775 Dtor->getCanonicalDecl());
13777 return ArrayOperatorDeletesForVirtualDtor.contains(
13778 Dtor->getCanonicalDecl());
13780 return GlobalArrayOperatorDeletesForVirtualDtor.contains(
13781 Dtor->getCanonicalDecl());
13792 if (OperatorDeletesForVirtualDtor.contains(Canon))
13793 return OperatorDeletesForVirtualDtor[Canon];
13796 if (GlobalOperatorDeletesForVirtualDtor.contains(Canon))
13797 return GlobalOperatorDeletesForVirtualDtor[Canon];
13800 if (ArrayOperatorDeletesForVirtualDtor.contains(Canon))
13801 return ArrayOperatorDeletesForVirtualDtor[Canon];
13804 if (GlobalArrayOperatorDeletesForVirtualDtor.contains(Canon))
13805 return GlobalArrayOperatorDeletesForVirtualDtor[Canon];
13816 return MaybeRequireVectorDeletingDtor.count(RD);
13824 MaybeRequireVectorDeletingDtor.insert(RD);
13829 assert(LangOpts.CPlusPlus);
13830 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13838 assert(LangOpts.CPlusPlus);
13839 std::unique_ptr<MangleNumberingContext> &MCtx =
13840 ExtraMangleNumberingContexts[D];
13846std::unique_ptr<MangleNumberingContext>
13848 return ABI->createMangleNumberingContext();
13853 return ABI->getCopyConstructorForExceptionObject(
13859 return ABI->addCopyConstructorForExceptionObject(
13866 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13871 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13876 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13880 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13884 ParamIndices[D] =
index;
13888 ParameterIndexTable::const_iterator I = ParamIndices.find(D);
13889 assert(I != ParamIndices.end() &&
13890 "ParmIndices lacks entry set by ParmVarDecl");
13895 unsigned Length)
const {
13921 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13923 llvm::FoldingSetNodeID ID;
13926 llvm::FoldingSetInsertToken
Token;
13931 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
13938 const APValue &APVal)
const {
13939 llvm::FoldingSetNodeID ID;
13942 llvm::FoldingSetInsertToken
Token;
13944 UnnamedGlobalConstantDecls.lookup(ID,
Token))
13948 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
13949 UnnamedGlobalConstantDecls.insert(
New,
Token);
13955 assert(
T->isRecordType() &&
"template param object of unexpected type");
13961 llvm::FoldingSetNodeID ID;
13964 llvm::FoldingSetInsertToken
Token;
13966 TemplateParamObjectDecls.lookup(ID,
Token))
13970 TemplateParamObjectDecls.insert(
New,
Token);
13976 if (!
T.isOSDarwin())
13979 if (!(
T.isiOS() &&
T.isOSVersionLT(7)) &&
13980 !(
T.isMacOSX() &&
T.isOSVersionLT(10, 9)))
13989 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
13996 if (MethodDecl->
hasAttr<UnavailableAttr>()
13997 || MethodDecl->
hasAttr<DeprecatedAttr>())
14011 IM != EM && IF != EF; ++IM, ++IF) {
14042 llvm::FoldingSetNodeID IDX, IDY;
14043 X->Profile(IDX, *
this,
true);
14044 Y->
Profile(IDY, *
this,
true);
14058 for (
const Decl *DX :
X->redecls()) {
14063 if (DX->isFirstDecl())
14066 llvm_unreachable(
"Corrupt redecls chain");
14069template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14071 return cast_or_null<T>(
14073 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
14076template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14084 bool IgnoreDeduced =
false) {
14099 bool IgnoreDeduced) {
14101 assert(R.getAsVoidPointer() !=
nullptr);
14107 assert(Xs.size() == Ys.size());
14109 for (
size_t I = 0; I < Rs.size(); ++I)
14116 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
14126 switch (
X.getKind()) {
14156 auto NExpX =
X.getNumTemplateExpansions();
14170 if (Xs.size() != Ys.size())
14172 R.resize(Xs.size());
14173 for (
size_t I = 0; I < R.size(); ++I) {
14186 assert(!Different);
14214 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
14216 return std::nullopt;
14221 assert(Kind == NNS2.
getKind());
14226 auto Kind = Namespace1->getKind();
14227 if (Kind != Namespace2->getKind() ||
14228 (Kind == Decl::NamespaceAlias &&
14233 Namespace2->getNamespace()),
14267 llvm_unreachable(
"singletons did not compare equal");
14269 assert(R.getCanonical() == Canon);
14275 const T *Y,
bool IsSame) {
14276 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
14296 QX +=
X.getQualifiers() - RQ;
14306 Y->getElementType(), QX, QY);
14317 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
14318 return X->getSizeExpr();
14323 return X->getSizeModifier();
14329 return X->getIndexTypeCVRQualifiers();
14339 llvm::DenseMap<QualType, unsigned>
Found;
14340 for (
auto Ts : {
X, Y}) {
14347 Out.emplace_back(
T);
14353FunctionProtoType::ExceptionSpecInfo
14357 bool AcceptDependent)
const {
14383 assert(AcceptDependent &&
14384 "computing composite pointer type of dependent types");
14399 llvm_unreachable(
"These ESTs should be handled above");
14404 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
14408 Result.Exceptions = ExceptionTypeStorage;
14415 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
14418 llvm_unreachable(
"invalid ExceptionSpecificationType");
14427#define UNEXPECTED_TYPE(Class, Kind) \
14428 case Type::Class: \
14429 llvm_unreachable("Unexpected " Kind ": " #Class);
14431#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
14432#define TYPE(Class, Base)
14433#include "clang/AST/TypeNodes.inc"
14435#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
14446#undef SUGAR_FREE_TYPE
14447#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
14450#undef NON_UNIQUE_TYPE
14454#undef UNEXPECTED_TYPE
14458 assert(AX->getDeducedKind() == AY->getDeducedKind());
14460 assert(AX->getKeyword() == AY->getKeyword());
14463 AY->getTypeConstraintConcept().getAsTemplateDecl());
14467 AY->getTypeConstraintArguments())) {
14474 case Type::IncompleteArray: {
14481 case Type::DependentSizedArray: {
14489 case Type::ConstantArray: {
14492 assert(AX->getSize() == AY->getSize());
14493 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14494 ? AX->getSizeExpr()
14500 case Type::ArrayParameter: {
14503 assert(AX->getSize() == AY->getSize());
14504 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14505 ? AX->getSizeExpr()
14512 case Type::Atomic: {
14517 case Type::Complex: {
14521 case Type::Pointer: {
14525 case Type::BlockPointer: {
14529 case Type::ObjCObjectPointer: {
14534 case Type::MemberPointer: {
14538 PY->getMostRecentCXXRecordDecl()));
14542 PX->getMostRecentCXXRecordDecl());
14544 case Type::LValueReference: {
14549 PX->isSpelledAsLValue() ||
14550 PY->isSpelledAsLValue());
14552 case Type::RValueReference: {
14558 case Type::DependentAddressSpace: {
14561 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14563 PX->getAddrSpaceExpr(),
14566 case Type::FunctionNoProto: {
14569 assert(FX->getExtInfo() == FY->getExtInfo());
14574 case Type::FunctionProto: {
14578 EPIY = FY->getExtProtoInfo();
14579 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14586 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14587 assert(EPIX.
Variadic == EPIY.Variadic);
14596 auto P =
getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
14604 case Type::ObjCObject: {
14607 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14608 OY->getProtocols().begin(), OY->getProtocols().end(),
14610 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14612 "protocol lists must be the same");
14614 OY->getTypeArgsAsWritten());
14617 OX->getProtocols(),
14618 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14620 case Type::ConstantMatrix: {
14623 assert(MX->getNumRows() == MY->getNumRows());
14624 assert(MX->getNumColumns() == MY->getNumColumns());
14626 MX->getNumRows(), MX->getNumColumns());
14628 case Type::DependentSizedMatrix: {
14631 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14632 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14637 case Type::Vector: {
14639 assert(VX->getNumElements() == VY->getNumElements());
14640 assert(VX->getVectorKind() == VY->getVectorKind());
14642 VX->getNumElements(), VX->getVectorKind());
14644 case Type::ExtVector: {
14646 assert(VX->getNumElements() == VY->getNumElements());
14648 VX->getNumElements());
14650 case Type::DependentSizedExtVector: {
14657 case Type::DependentVector: {
14660 assert(VX->getVectorKind() == VY->getVectorKind());
14667 case Type::InjectedClassName: {
14674 case Type::TemplateSpecialization: {
14678 TY->template_arguments());
14682 TY->getTemplateName(),
14684 As, {},
X->getCanonicalTypeInternal());
14686 case Type::Decltype: {
14689 assert(DX->isDependentType());
14690 assert(DY->isDependentType());
14691 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14695 case Type::PackIndexing: {
14698 assert(DX->isDependentType());
14699 assert(DY->isDependentType());
14700 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14703 case Type::DependentName: {
14706 assert(NX->getIdentifier() == NY->getIdentifier());
14711 case Type::OverflowBehavior: {
14714 assert(NX->getBehaviorKind() == NY->getBehaviorKind());
14716 NX->getBehaviorKind(),
14718 NY->getUnderlyingType(), QX, QY));
14720 case Type::UnaryTransform: {
14723 assert(TX->getUTTKind() == TY->getUTTKind());
14727 TY->getUnderlyingType()),
14730 case Type::PackExpansion: {
14733 assert(PX->getNumExpansions() == PY->getNumExpansions());
14736 PX->getNumExpansions(),
false);
14740 assert(PX->isReadOnly() == PY->isReadOnly());
14745 case Type::TemplateTypeParm: {
14748 assert(TX->getDepth() == TY->getDepth());
14749 assert(TX->getIndex() == TY->getIndex());
14750 assert(TX->isParameterPack() == TY->isParameterPack());
14752 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14756 llvm_unreachable(
"Unknown Type Class");
14766#define UNEXPECTED_TYPE(Class, Kind) \
14767 case Type::Class: \
14768 llvm_unreachable("Unexpected " Kind ": " #Class);
14769#define TYPE(Class, Base)
14770#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14771#include "clang/AST/TypeNodes.inc"
14773#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14800#undef CANONICAL_TYPE
14802#undef UNEXPECTED_TYPE
14804 case Type::Adjusted: {
14806 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14813 case Type::Decayed: {
14815 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14822 case Type::Attributed: {
14824 AttributedType::Kind Kind = AX->getAttrKind();
14825 if (Kind != AY->getAttrKind())
14827 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14835 case Type::BTFTagAttributed: {
14837 const BTFTypeTagAttr *AX = BX->getAttr();
14839 if (AX->getBTFTypeTag() !=
14850 if (KW != AY->getKeyword())
14855 AY->getTypeConstraintConcept().getAsTemplateDecl());
14859 AY->getTypeConstraintArguments())) {
14870 case Type::PackIndexing:
14871 case Type::Decltype:
14873 case Type::DeducedTemplateSpecialization:
14876 case Type::MacroQualified: {
14880 if (IX != MY->getMacroIdentifier())
14884 case Type::SubstTemplateTypeParm: {
14891 unsigned Index = SX->getIndex();
14892 if (Index != SY->getIndex())
14899 SX->getFinal() && SY->getFinal());
14901 case Type::ObjCTypeParam:
14907 case Type::TemplateSpecialization: {
14912 TY->getTemplateName(),
true);
14917 TY->template_arguments()))
14923 case Type::Typedef: {
14933 case Type::TypeOf: {
14944 case Type::TypeOfExpr:
14947 case Type::UnaryTransform: {
14950 UnaryTransformType::UTTKind KX = UX->getUTTKind();
14951 if (KX != UY->getUTTKind())
14953 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
14960 case Type::Using: {
14969 case Type::MemberPointer: {
14973 assert(Cls == PY->getMostRecentCXXRecordDecl());
14978 case Type::CountAttributed: {
14981 if (DX->isCountInBytes() != DY->isCountInBytes())
14983 if (DX->isOrNull() != DY->isOrNull())
14985 Expr *CEX = DX->getCountExpr();
14986 Expr *CEY = DY->getCountExpr();
14990 DX->isCountInBytes(), DX->isOrNull(),
15001 DX->isCountInBytes(), DX->isOrNull(),
15005 case Type::LateParsedAttr:
15008 case Type::PredefinedSugar:
15013 llvm_unreachable(
"Unhandled Type Class");
15020 QualType NT =
T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
15035 if (
X.isCanonical())
15062 bool KeepCommonQualifiers =
15065 if (SX.
Ty != SY.Ty) {
15073 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
15076 SX = Xs.pop_back_val();
15077 SY = Ys.pop_back_val();
15080 if (KeepCommonQualifiers)
15087 while (!Xs.empty() && !Ys.empty()) {
15090 SX = Xs.pop_back_val();
15091 SY = Ys.pop_back_val();
15096 SX.
Ty = Underlying.Ty;
15099 QX -= Underlying.Quals;
15117 llvm_unreachable(
"Not a saturated fixed point type!");
15118 case BuiltinType::SatShortAccum:
15120 case BuiltinType::SatAccum:
15122 case BuiltinType::SatLongAccum:
15124 case BuiltinType::SatUShortAccum:
15126 case BuiltinType::SatUAccum:
15128 case BuiltinType::SatULongAccum:
15130 case BuiltinType::SatShortFract:
15132 case BuiltinType::SatFract:
15134 case BuiltinType::SatLongFract:
15136 case BuiltinType::SatUShortFract:
15138 case BuiltinType::SatUFract:
15140 case BuiltinType::SatULongFract:
15152 llvm_unreachable(
"Not a fixed point type!");
15153 case BuiltinType::ShortAccum:
15155 case BuiltinType::Accum:
15157 case BuiltinType::LongAccum:
15159 case BuiltinType::UShortAccum:
15161 case BuiltinType::UAccum:
15163 case BuiltinType::ULongAccum:
15165 case BuiltinType::ShortFract:
15167 case BuiltinType::Fract:
15169 case BuiltinType::LongFract:
15171 case BuiltinType::UShortFract:
15173 case BuiltinType::UFract:
15175 case BuiltinType::ULongFract:
15181 if (LangOpts.OpenCL)
15196 llvm_unreachable(
"Not a fixed point type!");
15197 case BuiltinType::ShortAccum:
15198 case BuiltinType::SatShortAccum:
15199 return Target.getShortAccumScale();
15200 case BuiltinType::Accum:
15201 case BuiltinType::SatAccum:
15202 return Target.getAccumScale();
15203 case BuiltinType::LongAccum:
15204 case BuiltinType::SatLongAccum:
15205 return Target.getLongAccumScale();
15206 case BuiltinType::UShortAccum:
15207 case BuiltinType::SatUShortAccum:
15208 return Target.getUnsignedShortAccumScale();
15209 case BuiltinType::UAccum:
15210 case BuiltinType::SatUAccum:
15211 return Target.getUnsignedAccumScale();
15212 case BuiltinType::ULongAccum:
15213 case BuiltinType::SatULongAccum:
15214 return Target.getUnsignedLongAccumScale();
15215 case BuiltinType::ShortFract:
15216 case BuiltinType::SatShortFract:
15217 return Target.getShortFractScale();
15218 case BuiltinType::Fract:
15219 case BuiltinType::SatFract:
15220 return Target.getFractScale();
15221 case BuiltinType::LongFract:
15222 case BuiltinType::SatLongFract:
15223 return Target.getLongFractScale();
15224 case BuiltinType::UShortFract:
15225 case BuiltinType::SatUShortFract:
15226 return Target.getUnsignedShortFractScale();
15227 case BuiltinType::UFract:
15228 case BuiltinType::SatUFract:
15229 return Target.getUnsignedFractScale();
15230 case BuiltinType::ULongFract:
15231 case BuiltinType::SatULongFract:
15232 return Target.getUnsignedLongFractScale();
15242 llvm_unreachable(
"Not a fixed point type!");
15243 case BuiltinType::ShortAccum:
15244 case BuiltinType::SatShortAccum:
15245 return Target.getShortAccumIBits();
15246 case BuiltinType::Accum:
15247 case BuiltinType::SatAccum:
15248 return Target.getAccumIBits();
15249 case BuiltinType::LongAccum:
15250 case BuiltinType::SatLongAccum:
15251 return Target.getLongAccumIBits();
15252 case BuiltinType::UShortAccum:
15253 case BuiltinType::SatUShortAccum:
15254 return Target.getUnsignedShortAccumIBits();
15255 case BuiltinType::UAccum:
15256 case BuiltinType::SatUAccum:
15257 return Target.getUnsignedAccumIBits();
15258 case BuiltinType::ULongAccum:
15259 case BuiltinType::SatULongAccum:
15260 return Target.getUnsignedLongAccumIBits();
15261 case BuiltinType::ShortFract:
15262 case BuiltinType::SatShortFract:
15263 case BuiltinType::Fract:
15264 case BuiltinType::SatFract:
15265 case BuiltinType::LongFract:
15266 case BuiltinType::SatLongFract:
15267 case BuiltinType::UShortFract:
15268 case BuiltinType::SatUShortFract:
15269 case BuiltinType::UFract:
15270 case BuiltinType::SatUFract:
15271 case BuiltinType::ULongFract:
15272 case BuiltinType::SatULongFract:
15277llvm::FixedPointSemantics
15280 "Can only get the fixed point semantics for a "
15281 "fixed point or integer type.");
15283 return llvm::FixedPointSemantics::GetIntegerSemantics(
15287 return llvm::FixedPointSemantics(
15290 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
15305 "Expected unsigned fixed point type");
15308 case BuiltinType::UShortAccum:
15310 case BuiltinType::UAccum:
15312 case BuiltinType::ULongAccum:
15314 case BuiltinType::SatUShortAccum:
15316 case BuiltinType::SatUAccum:
15318 case BuiltinType::SatULongAccum:
15320 case BuiltinType::UShortFract:
15322 case BuiltinType::UFract:
15324 case BuiltinType::ULongFract:
15326 case BuiltinType::SatUShortFract:
15328 case BuiltinType::SatUFract:
15330 case BuiltinType::SatULongFract:
15333 llvm_unreachable(
"Unexpected unsigned fixed point type");
15341 std::vector<std::string> BackendFeats;
15342 llvm::AArch64::ExtensionSet FeatureBits;
15343 for (StringRef F : FMVFeatStrings)
15344 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
15346 FeatureBits.enable(*FMVExt->ID);
15347 FeatureBits.toLLVMFeatureList(BackendFeats);
15348 return BackendFeats;
15353 assert(TD !=
nullptr);
15356 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
15357 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
15368 Target->getTargetOpts().CPU,
15369 Target->getTargetOpts().Features);
15376 StringRef TargetCPU = Target->getTargetOpts().CPU;
15378 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
15384 if (!Target->getTriple().isAArch64())
15387 Target->getTargetOpts().FeaturesAsWritten.begin(),
15388 Target->getTargetOpts().FeaturesAsWritten.end());
15399 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
15401 Target->getCPUSpecificCPUDispatchFeatures(
15403 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
15404 Features.insert(Features.begin(),
15405 Target->getTargetOpts().FeaturesAsWritten.begin(),
15406 Target->getTargetOpts().FeaturesAsWritten.end());
15407 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15408 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
15409 if (Target->getTriple().isAArch64()) {
15413 Features.insert(Features.begin(),
15414 Target->getTargetOpts().FeaturesAsWritten.begin(),
15415 Target->getTargetOpts().FeaturesAsWritten.end());
15416 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15417 }
else if (Target->getTriple().isRISCV()) {
15419 std::vector<std::string> Features;
15420 if (VersionStr !=
"default") {
15422 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15425 Features.insert(Features.begin(),
15426 Target->getTargetOpts().FeaturesAsWritten.begin(),
15427 Target->getTargetOpts().FeaturesAsWritten.end());
15428 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15429 }
else if (Target->getTriple().isOSAIX()) {
15430 std::vector<std::string> Features;
15432 if (VersionStr.starts_with(
"cpu="))
15433 TargetCPU = VersionStr.drop_front(
sizeof(
"cpu=") - 1);
15434 else if (VersionStr !=
"default")
15435 Features = Target->parseTargetAttr(VersionStr).Features;
15436 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15438 std::vector<std::string> Features;
15440 if (VersionStr.starts_with(
"arch="))
15441 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
15442 else if (VersionStr !=
"default")
15443 Features.push_back((StringRef{
"+"} + VersionStr).str());
15444 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15446 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
15447 std::vector<std::string> Features;
15448 if (Target->getTriple().isRISCV()) {
15450 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15453 assert(Target->getTriple().isAArch64());
15455 TV->getFeatures(Feats);
15458 Features.insert(Features.begin(),
15459 Target->getTargetOpts().FeaturesAsWritten.begin(),
15460 Target->getTargetOpts().FeaturesAsWritten.end());
15461 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15463 FeatureMap = Target->getTargetOpts().FeatureMap;
15474 auto DeviceDiscriminatorOverrider =
15476 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15478 return RD->getDeviceLambdaManglingNumber();
15479 return std::nullopt;
15482 Context, Context.getDiagnostics(), DeviceDiscriminatorOverrider)};
15490 std::string Buffer;
15491 Buffer.reserve(128);
15492 llvm::raw_string_ostream Out(Buffer);
15493 MC->mangleCanonicalTypeName(KernelNameType, Out);
15494 std::string KernelName = Out.str();
15496 return {KernelNameType, FD, KernelName};
15505 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15506 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15515 "SYCL kernel name conflict");
15530 return &IT->second;
15536 return *OMPTraitInfoVector.back();
15543 return DB << Section.
Decl;
15544 return DB <<
"a prior #pragma section";
15548 bool IsInternalVar =
15551 bool IsExplicitDeviceVar = (D->
hasAttr<CUDADeviceAttr>() &&
15552 !D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15553 (D->
hasAttr<CUDAConstantAttr>() &&
15554 !D->
getAttr<CUDAConstantAttr>()->isImplicit());
15558 return (IsInternalVar &&
15559 (D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15560 (D->
hasAttr<CUDAGlobalAttr>() &&
15567 (D->
hasAttr<HIPManagedAttr>() || D->
hasAttr<CUDAGlobalAttr>() ||
15572 if (!CUIDHash.empty())
15574 if (LangOpts.CUID.empty())
15575 return StringRef();
15576 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.CUID),
true);
15586 assert(PrimaryBase);
15589 auto Base = Layout.getPrimaryBase();
15590 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15592 PrimaryBase =
Base;
15594 return PrimaryBase;
15598 StringRef MangledName) {
15600 assert(
Method->isVirtual());
15601 bool DefaultIncludesPointerAuth =
15602 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15604 if (!DefaultIncludesPointerAuth)
15607 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15608 if (Existing != ThunksToBeAbbreviated.end())
15609 return Existing->second.contains(MangledName.str());
15612 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15614 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15616 for (
const auto &Thunk : *ThunkInfos) {
15618 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15624 Mangler->mangleThunk(
Method, Thunk,
true,
15627 llvm::raw_svector_ostream mangledNameStream(MangledName);
15631 mangledNameStream);
15633 Mangler->mangleThunk(
Method, Thunk,
false,
15634 mangledNameStream);
15636 Thunks[ElidedName].push_back(std::string(MangledName));
15639 llvm::StringSet<> SimplifiedThunkNames;
15640 for (
auto &ThunkList : Thunks) {
15641 llvm::sort(ThunkList.second);
15642 SimplifiedThunkNames.insert(ThunkList.second[0]);
15644 bool Result = SimplifiedThunkNames.contains(MangledName);
15645 ThunksToBeAbbreviated[VirtualMethodDecl] = std::move(SimplifiedThunkNames);
15663 std::vector<PFPField> &Fields,
bool IncludeVBases) {
15665 if (
auto *ElemDecl = AT->getElementType()->getAsCXXRecordDecl()) {
15667 for (
unsigned i = 0; i != AT->getSize(); ++i)
15684 Fields.push_back({FieldOffset, Field});
15691 if (
Base.isVirtual())
15698 if (IncludeVBases) {
15709 std::vector<PFPField> PFPFields;
15719 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->
getParent()))
15721 !FD->
hasAttr<NoFieldProtectionAttr>();
15726 auto *FD = dyn_cast<FieldDecl>(VD);
15749struct PaddingCalculator {
15750 PaddingCalculator(
const ASTContext &Ctx) : Ctx(Ctx) {}
15753 OccuppiedIntervals.clear();
15759 while (!Stack.empty()) {
15760 Data Current = Stack.back();
15764 MergeOccuppiedIntervals();
15767 llvm::SmallVector<ASTContext::BitInterval> GetPaddingIntervals() {
15768 llvm::SmallVector<ASTContext::BitInterval> Results;
15769 if (OccuppiedIntervals.size() == 1 &&
15770 OccuppiedIntervals.front().First == 0 &&
15771 OccuppiedIntervals.front().Last == TySizeInBits) {
15774 Results.reserve(OccuppiedIntervals.size() + 1);
15776 for (
const ASTContext::BitInterval &OccupiedInterval : OccuppiedIntervals) {
15777 if (OccupiedInterval.First > CurrentPos) {
15779 ASTContext::BitInterval{CurrentPos, OccupiedInterval.First});
15781 CurrentPos = OccupiedInterval.Last;
15783 if (TySizeInBits > CurrentPos) {
15784 Results.push_back(ASTContext::BitInterval{CurrentPos, TySizeInBits});
15793 bool VisitVirtualBase;
15819 uint64_t getScalarOccupiedSizeInBits(QualType Ty)
const {
15820 if (
const auto *BIT = Ty->
getAs<BitIntType>())
15821 return BIT->getNumBits();
15823 if (
const auto *BT = Ty->
getAs<BuiltinType>()) {
15824 if (BT->getKind() == BuiltinType::LongDouble &&
15826 &llvm::APFloat::x87DoubleExtended())
15827 return llvm::APFloat::getSizeInBits(
15834 void Visit(
const Data &D) {
15835 if (
auto *AT = dyn_cast<ConstantArrayType>(D.Ty)) {
15836 VisitArray(AT, D.StartBitOffset);
15840 if (
auto *
Record = D.Ty->getAsRecordDecl()) {
15841 VisitStruct(
Record, D.StartBitOffset, D.VisitVirtualBase);
15845 if (D.Ty->isAtomicType()) {
15846 auto Unwrapped = D;
15847 Unwrapped.Ty = D.Ty.getAtomicUnqualifiedType().getCanonicalType();
15848 Stack.push_back(Unwrapped);
15852 if (
const auto *
Complex = D.Ty->getAs<ComplexType>()) {
15853 VisitComplex(
Complex, D.StartBitOffset);
15857 if (
const auto *VT = D.Ty->getAs<clang::VectorType>()) {
15858 VisitVector(VT, D.StartBitOffset);
15862 if (
const auto *BITy = D.Ty->getAs<BitIntType>()) {
15863 VisitBitInt(BITy, D.StartBitOffset);
15867 uint64_t SizeBit = getScalarOccupiedSizeInBits(D.Ty);
15868 OccuppiedIntervals.push_back(
15869 ASTContext::BitInterval{D.StartBitOffset, D.StartBitOffset + SizeBit});
15872 void VisitArray(
const ConstantArrayType *AT, uint64_t StartBitOffset) {
15873 for (uint64_t ArrIndex = 0; ArrIndex < AT->
getSize().getLimitedValue();
15879 auto Offset = ElementSize.
alignTo(ElementAlign);
15881 Stack.push_back(
Data{
15882 StartBitOffset + ArrIndex * Offset.getQuantity() * Ctx.
getCharWidth(),
15887 void VisitStruct(
const RecordDecl *R, uint64_t StartBitOffset,
15888 bool VisitVirtualBase) {
15890 auto *
CXXRecord = dyn_cast<CXXRecordDecl>(R);
15896 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15897 StartBitOffset, StartBitOffset + PointerSizeInBits});
15902 auto StartVBPtr = StartBitOffset + Offset * Ctx.
getCharWidth();
15903 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15904 StartVBPtr, StartVBPtr + PointerSizeInBits});
15907 const auto VisitBase = [&ASTLayout, StartBitOffset,
this](
15908 const CXXBaseSpecifier &
Base,
auto GetOffset) {
15909 auto *BaseRecord =
Base.getType()->getAsCXXRecordDecl();
15914 std::invoke(GetOffset, ASTLayout, BaseRecord).getQuantity();
15918 Base.getType().getCanonicalType(),
15923 if (!
Base.isVirtual()) {
15928 if (VisitVirtualBase) {
15929 for (
auto VBase :
CXXRecord->vbases()) {
15935 for (
auto *Field :
R->fields()) {
15937 if (
Field->isUnnamedBitField())
15941 if (
Field->isBitField()) {
15942 VisitBitfield(Field, StartBitOffset + FieldOffset);
15944 Stack.push_back(
Data{StartBitOffset + FieldOffset,
15945 Field->getType().getCanonicalType(),
15951 void VisitBitfield(
const FieldDecl *Field, uint64_t StartBitOffset) {
15952 assert(
Field->isBitField() && !
Field->isUnnamedBitField());
15953 if (
Field->isZeroLengthBitField())
15956 const uint64_t DeclaredSizeInBits =
Field->getBitWidthValue();
15962 const uint64_t OccupiedSizeInBits =
15963 std::min(DeclaredSizeInBits,
15967 OccuppiedIntervals.push_back(
15968 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
15989 StartBitOffset + DeclaredSizeInBits - OccupiedSizeInBits;
15990 const uint64_t End = Start + OccupiedSizeInBits;
15994 const uint64_t ByteStart = llvm::alignDown(Start, CharWidth);
15995 const uint64_t ByteEnd = llvm::alignTo(End, CharWidth);
15996 if (ByteStart == ByteEnd - CharWidth) {
15997 const uint64_t Length = End - Start;
15998 const uint64_t Offset = Start - ByteStart;
15999 OccuppiedIntervals.push_back(
16000 {ByteEnd - Offset - Length, ByteEnd - Offset});
16006 const uint64_t MiddleIntervalStart = llvm::alignTo(Start, CharWidth);
16007 const uint64_t MiddleIntervalEnd = llvm::alignDown(End, CharWidth);
16008 if (MiddleIntervalStart != MiddleIntervalEnd)
16009 OccuppiedIntervals.push_back({MiddleIntervalStart, MiddleIntervalEnd});
16013 if (Start != MiddleIntervalStart) {
16014 const uint64_t Length = MiddleIntervalStart - Start;
16015 OccuppiedIntervals.push_back({ByteStart, ByteStart + Length});
16020 if (End != MiddleIntervalEnd) {
16021 const uint64_t Length = End - MiddleIntervalEnd;
16022 OccuppiedIntervals.push_back({ByteEnd - Length, ByteEnd});
16026 void VisitComplex(
const ComplexType *CT, uint64_t StartBitOffset) {
16030 auto ImgOffset = ElementSize.
alignTo(ElementAlign);
16033 Data{StartBitOffset, ElementQualType,
true});
16036 ElementQualType,
true});
16039 void VisitVector(
const clang::VectorType *VT, uint64_t StartBitOffset) {
16041 VisitPackedBooleanVector(VT, StartBitOffset);
16047 OccuppiedIntervals.push_back(
16048 ASTContext::BitInterval{StartBitOffset, StartBitOffset + SizeBit});
16056 void VisitBitInt(
const BitIntType *Ty, uint64_t StartBitOffset) {
16060 OccuppiedIntervals.push_back(
16061 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16073 const uint64_t NumFullyPaddingBytes =
16074 (StorageSizeInBits - OccupiedSizeInBits) / CharWidth;
16075 const uint64_t NumFullyOccupiedBytes = OccupiedSizeInBits / CharWidth;
16076 const uint64_t NumRemainingOccupiedBits = OccupiedSizeInBits % CharWidth;
16079 if (NumRemainingOccupiedBits > 0)
16080 OccuppiedIntervals.push_back(
16081 {StartBitOffset + NumFullyPaddingBytes * CharWidth,
16082 StartBitOffset + NumFullyPaddingBytes * CharWidth +
16083 NumRemainingOccupiedBits});
16086 if (NumFullyOccupiedBytes > 0)
16087 OccuppiedIntervals.push_back({StartBitOffset + StorageSizeInBits -
16088 NumFullyOccupiedBytes * CharWidth,
16089 StartBitOffset + StorageSizeInBits});
16092 void VisitPackedBooleanVector(
const VectorType *VTy,
16093 uint64_t StartBitOffset) {
16095 assert(StartBitOffset % CharWidth == 0 &&
16096 "Expected aligned packed boolean vector");
16101 OccuppiedIntervals.push_back(
16102 {StartBitOffset, StartBitOffset + OccupiedSizeInBits});
16110 const uint64_t NumFullyOccupiedBytes = OccupiedSizeInBits / CharWidth;
16111 const uint64_t NumRemainingOccupiedBits = OccupiedSizeInBits % CharWidth;
16115 if (NumRemainingOccupiedBits > 0) {
16116 const uint64_t ByteEnd = Start + CharWidth;
16117 OccuppiedIntervals.push_back({Start, Start + NumRemainingOccupiedBits});
16122 if (NumFullyOccupiedBytes > 0) {
16123 OccuppiedIntervals.push_back(
16124 {Start, Start + NumFullyOccupiedBytes * CharWidth});
16128 void MergeOccuppiedIntervals() {
16129 std::sort(OccuppiedIntervals.begin(), OccuppiedIntervals.end(),
16130 [](
const ASTContext::BitInterval &lhs,
16131 const ASTContext::BitInterval &rhs) {
16132 return std::tie(lhs.First, lhs.Last) <
16133 std::tie(rhs.First, rhs.Last);
16136 llvm::SmallVector<ASTContext::BitInterval> Merged;
16137 Merged.reserve(OccuppiedIntervals.size());
16139 for (
const ASTContext::BitInterval &NextInterval : OccuppiedIntervals) {
16140 if (Merged.empty()) {
16141 Merged.push_back(NextInterval);
16144 auto &LastInterval = Merged.back();
16146 if (NextInterval.First > LastInterval.Last) {
16147 Merged.push_back(NextInterval);
16149 LastInterval.Last = std::max(LastInterval.Last, NextInterval.Last);
16153 OccuppiedIntervals = Merged;
16156 const ASTContext &Ctx;
16159 llvm::SmallVector<Data> Stack;
16160 llvm::SmallVector<ASTContext::BitInterval> OccuppiedIntervals;
16164llvm::ArrayRef<ASTContext::BitInterval>
16167 auto cached = PaddingIntervalCache.find(Ty);
16168 if (cached != PaddingIntervalCache.end())
16169 return cached->second;
16171 PaddingCalculator pc{*
this};
16175 PaddingIntervalCache.insert_or_assign(Ty, pc.GetPaddingIntervals());
16176 assert(res &&
"Failed to insert?");
16178 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 const TagDecl * getNonInjectedClassName(const TagDecl *TD)
static TypedefDecl * CreateZOSVaListDecl(const ASTContext *Context)
static bool hasAnyPackExpansions(ArrayRef< TemplateArgument > Args)
static char ObjCEncodingForEnumDecl(const ASTContext *C, const EnumDecl *ED)
static std::string charUnitsToString(CharUnits CU)
static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod, SmallVectorImpl< const NamedDecl * > &Redeclared)
static QualType getCommonTypeWithQualifierLifting(const ASTContext &Ctx, QualType X, QualType Y, Qualifiers &QX, Qualifiers &QY)
static auto getCommonTypes(const ASTContext &Ctx, ArrayRef< QualType > Xs, ArrayRef< QualType > Ys, bool Unqualified=false)
static bool isCanonicalResultType(QualType T)
Determine whether T is canonical as the result type of a function.
static TypedefDecl * CreateMSVaListDecl(const ASTContext *Context)
static bool areCompatVectorTypes(const VectorType *LHS, const VectorType *RHS)
areCompatVectorTypes - Return true if the two specified vector types are compatible.
static TypedefDecl * CreateCharPtrNamedVaListDecl(const ASTContext *Context, StringRef Name)
static NestedNameSpecifier getCommonQualifier(const ASTContext &Ctx, const T *X, const T *Y, bool IsSame)
#define UNEXPECTED_TYPE(Class, Kind)
static TypedefDecl * CreateVaListDecl(const ASTContext *Context, TargetInfo::BuiltinVaListKind Kind)
static bool primaryBaseHaseAddressDiscriminatedVTableAuthentication(const ASTContext &Context, const CXXRecordDecl *Class)
static std::vector< std::string > getFMVBackendFeaturesFor(const llvm::SmallVectorImpl< StringRef > &FMVFeatStrings)
Defines the clang::ASTContext interface.
#define BuiltinTemplate(BTName)
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...
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns, std::optional< MatrixType::LayoutKind > Layout=std::nullopt) const
Return the unique reference to the matrix type of the specified element type and size.
ExternCContextDecl * getExternCContextDecl() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
CanQualType UnsignedShortAccumTy
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
QualType adjustFunctionResultType(QualType FunctionType, QualType NewResultType)
Change the result type of a function type, preserving sugar such as attributed types.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
QualType getCanonicalTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateName TypeConstraintConcept=TemplateName(), ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getAutoRRefDeductType() const
C++11 deduction pattern for 'auto &&' type.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type.
bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool AllowCXX=false, bool IsConditionalOperator=false)
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
comments::FullComment * cloneFullComment(comments::FullComment *FC, const Decl *D) const
CharUnits getObjCEncodingTypeSize(QualType T) const
Return the size of type T for Objective-C encoding purpose, in characters.
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
const TemplateArgument * getDefaultTemplateArgumentOrNone(const NamedDecl *P) const
Return the default argument of a template parameter, if one exists.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
void setCurrentNamedModule(Module *M)
Set the (C++20) module we are building.
QualType getProcessIDType() const
Return the unique type for "pid_t" defined in <sys/types.h>.
CharUnits getMemberPointerPathAdjustment(const APValue &MP) const
Find the 'this' offset for the member path in a pointer-to-member APValue.
bool mayExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel may be externalized.
std::unique_ptr< MangleNumberingContext > createMangleNumberingContext() const
ArrayRef< CXXDefaultArgExpr * > getCtorClosureDefaultArgs(const CXXConstructorDecl *CD)
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
bool hasSameExpr(const Expr *X, const Expr *Y) const
Determine whether the given expressions X and Y are equivalent.
TemplateName getPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< TemplateName > Expansions={}) const
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
RawComment * getRawCommentNoCache(RawCommentLookupKey Key) const
Return the documentation comment attached to a given declaration or macro, without looking into cache...
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
unsigned getTypeUnadjustedAlign(QualType T) const
Return the ABI-specified natural alignment of a (complete) type T, before alignment adjustments,...
unsigned char getFixedPointIBits(QualType Ty) const
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes, bool OrNull, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
bool ObjCQualifiedClassTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS)
ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and Class<pr1, ...>.
bool shouldExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel should be externalized.
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type.
CanQualType SatLongAccumTy
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
OpenCLTypeKind getOpenCLTypeKind(const Type *T) const
Map an AST Type to an OpenCLTypeKind enum value.
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const
Put the string version of the type qualifiers QT into S.
unsigned getPreferredTypeAlign(QualType T) const
Return the "preferred" alignment of the specified type T for the current target, in bits.
std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, bool Extended=false) const
Emit the encoded type for the method declaration Decl into S.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
CanQualType OMPArrayShapingTy
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
std::string getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
getObjCEncodingForPropertyDecl - Return the encoded type for this method declaration.
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
unsigned getStaticLocalNumber(const VarDecl *VD) const
void addComment(const RawComment &RC)
void getLegacyIntegralTypeEncoding(QualType &t) const
getLegacyIntegralTypeEncoding - Another legacy compatibility encoding: 32-bit longs are encoded as 'l...
bool isSameTypeConstraint(const TypeConstraint *XTC, const TypeConstraint *YTC) const
Determine whether two type contraint are similar enough that they could used in declarations of the s...
void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo)
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=RecordDecl::TagKind::Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
void completeCountAttributedType(CountAttributedType *CATy, Expr *CountExpr, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
Supply the count expression and coupled declarations for a type created by getIncompleteCountAttribut...
CanQualType UnsignedLongFractTy
QualType mergeTagDefinitions(QualType, QualType)
void setClassMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
void setIsTypeAwareOperatorNewOrDelete(const FunctionDecl *FD, bool IsTypeAware)
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const
Return a dependent bit-precise integer type with the specified signedness and bit count.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
StringRef getCUIDHash() const
bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const
Returns true if this is an inline-initialized static data member which is treated as a definition for...
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const
Determine whether two function types are the same, ignoring exception specifications in cases where t...
QualType getBlockDescriptorExtendedType() const
Gets the struct used to keep track of the extended descriptor for pointer to blocks.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent) const
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
void addLazyModuleInitializers(Module *M, ArrayRef< GlobalDeclID > IDs)
bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
QualType getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
std::optional< QualType > tryMergeOverflowBehaviorTypes(QualType LHS, QualType RHS, bool OfBlockPointer, bool Unqualified, bool BlockReturnType, bool IsConditionalOperator)
Attempts to merge two types that may be OverflowBehaviorTypes.
CanQualType OMPIteratorTy
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
SelectorTable & Selectors
bool isTypeIgnoredBySanitizer(const SanitizerMask &Mask, const QualType &Ty) const
Check if a type can have its sanitizer instrumentation elided based on its presence within an ignorel...
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const
Return the minimum alignment as specified by the target.
RawCommentList Comments
All comments in this translation unit.
bool isSameDefaultTemplateArgument(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two default template arguments are similar enough that they may be used in declarat...
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType getLateParsedAttrType(QualType Wrapped, LateParsedTypeAttribute *LateParsedAttr) const
Return a placeholder type for a late-parsed type attribute.
QualType removePtrSizeAddrSpace(QualType T) const
Remove the existing address space on the type if it is a pointer size address space and return the ty...
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
llvm::ArrayRef< BitInterval > getPaddingIntervals(QualType Ty) const
CanQualType SatShortFractTy
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
bool canBindObjCObjectType(QualType To, QualType From)
TemplateTemplateParmDecl * insertCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *CanonTTP) const
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const
Compare the rank of two floating point types as above, but compare equal if both types have the same ...
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
void setParameterIndex(const ParmVarDecl *D, unsigned index)
Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
CanQualType getCanonicalSizeType() const
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl, StringRef MangledName)
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::SetVector< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
CanQualType ArraySectionTy
CanQualType ObjCBuiltinIdTy
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const
ObjCPropertyImplDecl * getObjCPropertyImplDeclForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
bool isNearlyEmpty(const CXXRecordDecl *RD) const
PointerAuthQualifier getObjCMemberSelTypePtrAuth()
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.
void eraseDeclAttrs(const Decl *D)
Erase the attributes corresponding to the given declaration.
UsingEnumDecl * getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst)
If the given using-enum decl Inst is an instantiation of another using-enum decl, return it.
RecordDecl * getCFConstantStringTagDecl() const
std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const
Emit the encoded type for the function Decl into S.
TypeSourceInfo * getTemplateSpecializationTypeInfo(ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Canon=QualType()) const
CanQualType UnsignedFractTy
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
QualType mergeFunctionParameterTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeFunctionParameterTypes - merge two types which appear as function parameter types
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
TemplateTemplateParmDecl * findCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *TTP) const
const TargetInfo * getAuxTargetInfo() const
CanQualType ObjCBuiltinClassTy
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
CanQualType UnresolvedTemplateTy
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
friend class CXXRecordDecl
CanQualType UnsignedLongTy
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized,...
bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits, unsigned NumPositiveBits, QualType &BestType, QualType &BestPromotionType)
Compute BestType and BestPromotionType for an enum based on the highest number of negative and positi...
llvm::APFixedPoint getFixedPointMin(QualType Ty) const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType adjustType(QualType OldType, llvm::function_ref< QualType(QualType)> Adjust) const
Rebuild a type, preserving any existing type sugar.
void addedLocalImportDecl(ImportDecl *Import)
Notify the AST context that a new import declaration has been parsed or implicitly created within thi...
const TranslationUnitKind TUKind
CanQualType UnsignedLongAccumTy
QualType AutoRRefDeductTy
RawComment * getRawCommentNoCacheImpl(RawCommentLookupKey Key, const SourceLocation RepresentativeLoc, const std::map< unsigned, RawComment * > &CommentsInFile) const
CountAttributedType * getIncompleteCountAttributedType(QualType WrappedTy, bool CountInBytes, bool OrNull) const
Return a CountAttributedType whose count expression has not been parsed yet, for use by a late-parsed...
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length.
QualType getCorrespondingSaturatedType(QualType Ty) const
bool arePFPFieldsTriviallyCopyable(const RecordDecl *RD) const
Returns whether this record's PFP fields (if any) are trivially copyable (i.e.
bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const
Determine whether the two declarations refer to the same entity.
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl, unsigned Index, bool Final, const TemplateArgument &ArgPack)
CanQualType BoundMemberTy
CanQualType SatUnsignedShortFractTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
bool hasSameFunctionTypeIgnoringParamABI(QualType T, QualType U) const
Determine if two function types are the same, ignoring parameter ABI annotations.
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
unsigned getOpenMPDefaultSimdAlign(QualType T) const
Get default simd alignment of the specified complete type in bits.
QualType getObjCSuperType() const
Returns the C struct type for objc_super.
QualType getBlockDescriptorType() const
Gets the struct used to keep track of the descriptor for pointer to blocks.
bool CommentsLoaded
True if comments are already loaded from ExternalASTSource.
BlockVarCopyInit getBlockVarCopyInit(const VarDecl *VD) const
Get the copy initialization expression of the VarDecl VD, or nullptr if none exists.
QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size, uint32_t Alignment, ArrayRef< SpirvOperand > Operands)
unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
bool isInSameModule(const Module *M1, const Module *M2) const
If the two module M1 and M2 are in the same module.
unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
QualType getLeastIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
CanQualType PseudoObjectTy
QualType getWebAssemblyExternrefType() const
Return a WebAssembly externref type.
void setTraversalScope(const std::vector< Decl * > &)
CharUnits getTypeUnadjustedAlignInChars(QualType T) const
getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, in characters,...
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
friend class NestedNameSpecifier
MangleContext * cudaNVInitDeviceMC()
unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const
Return the alignment in bits that should be given to a global variable with type T.
bool areCompatibleOverflowBehaviorTypes(QualType LHS, QualType RHS)
Return true if two OverflowBehaviorTypes are compatible for assignment.
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
MangleContext * createDeviceMangleContext(const TargetInfo &T)
Creates a device mangle context to correctly mangle lambdas in a mixed architecture compile by settin...
CharUnits getExnObjectAlignment() const
Return the alignment (in bytes) of the thrown exception object.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ASTMutationListener * Listener
CanQualType ObjCBuiltinBoolTy
TypeInfoChars getTypeInfoInChars(const Type *T) const
QualType getPredefinedSugarType(PredefinedSugarType::Kind KD) const
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
TemplateParamObjectDecl * getTemplateParamObjectDecl(QualType T, const APValue &V) const
Return the template parameter object of the given type with the given value.
interp::Context & getInterpContext() const
Returns the clang bytecode interpreter context.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
TemplateTemplateParmDecl * getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const
Canonicalize the given TemplateTemplateParmDecl.
CanQualType OCLClkEventTy
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
bool hasPFPFields(QualType Ty) const
const clang::PrintingPolicy & getPrintingPolicy() const
void ResetObjCLayout(const ObjCInterfaceDecl *D)
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
void setCtorClosureDefaultArgs(const CXXConstructorDecl *CD, ArrayRef< CXXDefaultArgExpr * > Args)
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
CharUnits getAlignOfGlobalVarInChars(QualType T, const VarDecl *VD) const
Return the alignment in characters that should be given to a global variable with type T.
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists.
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, UnsignedOrNone Index=std::nullopt) const
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getObjCIdType() const
Represents the Objective-CC id type.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
QualType getFunctionTypeWithoutParamABIs(QualType T) const
Get or construct a function type that is equivalent to the input type except that the parameter ABI a...
QualType getCorrespondingUnsaturatedType(QualType Ty) const
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl) const
unsigned getTargetDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
llvm::DenseMap< CanQualType, SYCLKernelInfo > SYCLKernels
Map of SYCL kernels indexed by the unique type used to name the kernel.
bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y) const
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
bool isDestroyingOperatorDelete(const FunctionDecl *FD) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
CanQualType UnsignedCharTy
CanQualType UnsignedShortFractTy
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
void * Allocate(size_t Size, unsigned Align=8) const
ArrayRef< ExplicitInstantiationDecl * > getExplicitInstantiationDecls(const NamedDecl *Spec) const
Get all ExplicitInstantiationDecls for a given specialization.
bool canBuiltinBeRedeclared(const FunctionDecl *) const
Return whether a declaration to a builtin is allowed to be overloaded/redeclared.
CanQualType UnsignedIntTy
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols) const
void getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT, QualType T, std::string &S, bool Extended) const
getObjCEncodingForMethodParameter - Return the encoded type for a single method parameter or return t...
static bool isPFPField(const FieldDecl *Field)
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const
Return the encoded type for this block declaration.
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
bool isSameAssociatedConstraint(const AssociatedConstraint &ACX, const AssociatedConstraint &ACY) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
QualType getExceptionObjectType(QualType T) const
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Note that the static data member Inst is an instantiation of the static data member template Tmpl of ...
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl)
ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's protocol list adopt all protocols in Q...
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType OCLReserveIDTy
bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two template parameters are similar enough that they may be used in declarations of...
void registerSYCLEntryPointFunction(FunctionDecl *FD)
Generates and stores SYCL kernel metadata for the provided SYCL kernel entry point function.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
CanQualType UnsignedShortTy
FunctionDecl * getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
unsigned getTypeAlignIfKnown(QualType T, bool NeedsPreferredAlignment=false) const
Return the alignment of a type, in bits, or 0 if the type is incomplete and we cannot determine the a...
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may both be array types with the same bound (or both be array types ...
bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
llvm::DenseMap< RawCommentLookupKey, const RawComment * > RawComments
Mapping from declaration or macro to directly attached comment.
const SYCLKernelInfo & getSYCLKernelInfo(QualType T) const
Given a type used as a SYCL kernel name, returns a reference to the metadata generated from the corre...
bool canAssignObjCInterfacesInBlockPointer(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, bool BlockReturnType)
canAssignObjCInterfacesInBlockPointer - This routine is specifically written for providing type-safet...
CanQualType SatUnsignedLongFractTy
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
CanQualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
const ObjCInterfaceDecl * getObjContainingInterface(const NamedDecl *ND) const
Returns the Objective-C interface that ND belongs to if it is an Objective-C method/property/ivar etc...
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
CanQualType getCanonicalUnresolvedUsingType(const UnresolvedUsingTypenameDecl *D) const
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
llvm::APFixedPoint getFixedPointMax(QualType Ty) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool classMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
QualType getTemplateTypeParmType(int Depth, int Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
void deduplicateMergedDefinitionsFor(NamedDecl *ND)
Clean up the merged definition list.
static uint64_t getConstantArrayElementCount(const ConstantArrayType *CA)
Return number of (potentially nested) constant array elements.
DiagnosticsEngine & getDiagnostics() const
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void recordOffsetOfEvaluation(const OffsetOfExpr *E)
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
QualType getUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D) const
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
void getOverriddenMethods(const NamedDecl *Method, SmallVectorImpl< const NamedDecl * > &Overridden) const
Return C++ or ObjC overridden methods for the given Method.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y, bool IgnoreDeduced=false) const
Determine whether the given template names refer to the same template.
CanQualType SatLongFractTy
const TargetInfo & getTargetInfo() const
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
OBTAssignResult checkOBTAssignmentCompatibility(QualType LHS, QualType RHS)
Check overflow behavior type compatibility for assignments.
CanQualType SatShortAccumTy
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
static uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE)
Return number of elements initialized in a (potentially nested) ArrayInitLoopExpr.
void addExplicitInstantiationDecl(const NamedDecl *Spec, ExplicitInstantiationDecl *EID)
Add an ExplicitInstantiationDecl for a given specialization.
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
CanQualType IncompleteMatrixIdxTy
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
CanQualType getNSIntegerType() const
QualType getCorrespondingUnsignedType(QualType T) const
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
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.
QualType getMatrixTypeWithLayout(QualType T, MatrixType::LayoutKind Layout) const
bool isUnaryOverflowPatternExcluded(const UnaryOperator *UO)
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
TemplateName getDeducedTemplateName(TemplateName Underlying, DefaultArguments DefaultArgs) const
Represents a TemplateName which had some of its default arguments deduced.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
CanQualType UnsignedAccumTy
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
void cacheRawComment(RawCommentLookupKey Original, const RawComment &Comment) const
Attaches Comment to Original (a declaration or macro), and to its redeclaration chain when Original i...
QualType getVariableArrayDecayedType(QualType Ty) const
Returns a vla type where known sizes are replaced with [*].
void setCFConstantStringType(QualType T)
const SYCLKernelInfo * findSYCLKernelInfo(QualType T) const
Returns a pointer to the metadata generated from the corresponding SYCLkernel entry point if the prov...
unsigned getParameterIndex(const ParmVarDecl *D) const
Used by ParmVarDecl to retrieve on the side the index of the parameter when it exceeds the size of th...
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false) const
void AddDeallocation(void(*Callback)(void *), void *Data) const
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
AttrVec & getDeclAttrs(const Decl *D)
Retrieve the attributes for the given declaration.
QualType getDeducedTemplateSpecializationType(DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword, TemplateName Template) const
C++17 deduced class template specialization type.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
QualType mergeTransparentUnionType(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeTransparentUnionType - if T is a transparent union type and a member of T is compatible with Sub...
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
bool isSentinelNullExpr(const Expr *E)
CanQualType getNSUIntegerType() const
void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying)
TypedefDecl * getBuiltinZOSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_zos_va_list type.
void recordMemberDataPointerEvaluation(const ValueDecl *VD)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
virtual ~ASTMutationListener()
virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType)
A function's return type has been deduced.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool hasOwnVFPtr() const
hasOwnVFPtr - Does this class provide its own virtual-function table pointer, rather than inheriting ...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
bool hasOwnVBPtr() const
hasOwnVBPtr - Does this class provide its own virtual-base table pointer, rather than inheriting one ...
CharUnits getSize() const
getSize - Get the record size in characters.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding,...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
CharUnits getUnadjustedAlignment() const
getUnadjustedAlignment - Get the record alignment in characters, before alignment adjustment.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Represents a loop initializing the elements of an array.
llvm::APInt getArraySize() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
A structure for storing the information associated with a name that has been assumed to be a template...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Attr - This represents one attribute.
A fixed int type of a specified bitwidth.
unsigned getNumBits() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
This class is used for builtin types like 'int'.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Implements C++ ABI-specific semantic analysis functions.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
CXXRecordDecl * getDefinition() const
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isDynamicClass() const
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
SplitQualType split() const
static CanQual< Type > CreateUnsafe(QualType Other)
QualType withConst() const
Retrieves a version of this type with const applied.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
This is an opaque type for sizes expressed in character units.
bool isPositive() const
Test whether the quantity is greater than zero.
bool isZero() const
Test whether the quantity equals zero.
CharUnits alignTo(CharUnits Align) const
Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is a multiple...
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
static CharUnits Zero()
Construct a CharUnits quantity of zero.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Represents the canonical version of C arrays with a specified constant size.
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
void Profile(llvm::FoldingSetNodeID &ID)
unsigned getNumRows() const
Returns the number of rows in the matrix.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
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