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 void *InsertPos =
nullptr;
730 CanonicalTemplateTemplateParm *Canonical
731 = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
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.FindNodeOrInsertPos(ID, InsertPos);
800 assert(!Canonical &&
"Shouldn't be in the map!");
804 Canonical =
new (*this) CanonicalTemplateTemplateParm(CanonTTP);
805 CanonTemplateTemplateParms.InsertNode(Canonical, InsertPos);
812 llvm::FoldingSetNodeID ID;
813 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
814 void *InsertPos =
nullptr;
815 CanonicalTemplateTemplateParm *Canonical =
816 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
817 return Canonical ? Canonical->getParam() :
nullptr;
823 llvm::FoldingSetNodeID ID;
824 CanonicalTemplateTemplateParm::Profile(ID, *
this, CanonTTP);
825 void *InsertPos =
nullptr;
827 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos))
828 return Existing->getParam();
829 CanonTemplateTemplateParms.InsertNode(
830 new (*
this) CanonicalTemplateTemplateParm(CanonTTP), InsertPos);
851 [](
const DynTypedNode &P) { return P.get<WhileStmt>() != nullptr; });
875 return NoSanitizeL->containsType(Mask, TyName);
884 if (!LangOpts.CPlusPlus)
return nullptr;
887 case TargetCXXABI::AppleARM64:
888 case TargetCXXABI::Fuchsia:
889 case TargetCXXABI::GenericARM:
890 case TargetCXXABI::iOS:
891 case TargetCXXABI::WatchOS:
892 case TargetCXXABI::GenericAArch64:
893 case TargetCXXABI::GenericMIPS:
894 case TargetCXXABI::GenericItanium:
895 case TargetCXXABI::WebAssembly:
896 case TargetCXXABI::XL:
898 case TargetCXXABI::Microsoft:
901 llvm_unreachable(
"Invalid CXXABI type!");
905 if (!InterpContext) {
908 return *InterpContext;
914 return *ParentMapCtx;
919 switch (LangOpts.getAddressSpaceMapMangling()) {
927 llvm_unreachable(
"getAddressSpaceMapMangling() doesn't cover anything.");
933 : ConstantArrayTypes(this_(), ConstantArrayTypesLog2InitSize),
934 DependentSizedArrayTypes(this_()), DependentSizedExtVectorTypes(this_()),
935 DependentAddressSpaceTypes(this_()), DependentVectorTypes(this_()),
936 DependentSizedMatrixTypes(this_()),
937 FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
938 DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
939 DependentPackIndexingTypes(this_()), TemplateSpecializationTypes(this_()),
940 AttributedTypes(this_()), DependentBitIntTypes(this_()),
941 SubstTemplateTemplateParmPacks(this_()), DeducedTemplates(this_()),
942 ArrayParameterTypes(this_()), CanonTemplateTemplateParms(this_()),
943 SourceMgr(SM), LangOpts(LOpts),
946 LangOpts.XRayNeverInstrumentFiles,
947 LangOpts.XRayAttrListFiles, SM)),
948 ProfList(new
ProfileList(LangOpts.ProfileListFiles, SM)),
951 Comments(SM), CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
959 ReleaseDeclContextMaps();
962 for (
auto &Pair : Deallocations)
963 (Pair.first)(Pair.second);
964 Deallocations.clear();
970 I = ObjCLayouts.begin(),
971 E = ObjCLayouts.end();
978 for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
979 I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
984 ASTRecordLayouts.clear();
986 for (llvm::DenseMap<const Decl*, AttrVec*>::iterator A = DeclAttrs.begin(),
987 AEnd = DeclAttrs.end();
989 A->second->~AttrVec();
992 CtorClosureDefaultArgs.clear();
994 for (
const auto &
Value : ModuleInitializers)
995 Value.second->~PerModuleInitializers();
996 ModuleInitializers.
clear();
1000 NoSanitizeL.reset();
1006 TraversalScope = TopLevelDecls;
1011 Deallocations.push_back({Callback,
Data});
1020 llvm::errs() <<
"\n*** AST Context Stats:\n";
1021 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
1023 unsigned counts[] = {
1024#define TYPE(Name, Parent) 0,
1025#define ABSTRACT_TYPE(Name, Parent)
1026#include "clang/AST/TypeNodes.inc"
1030 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
1036 unsigned TotalBytes = 0;
1037#define TYPE(Name, Parent) \
1039 llvm::errs() << " " << counts[Idx] << " " << #Name \
1040 << " types, " << sizeof(Name##Type) << " each " \
1041 << "(" << counts[Idx] * sizeof(Name##Type) \
1043 TotalBytes += counts[Idx] * sizeof(Name##Type); \
1045#define ABSTRACT_TYPE(Name, Parent)
1046#include "clang/AST/TypeNodes.inc"
1048 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
1053 <<
" implicit default constructors created\n";
1056 <<
" implicit copy constructors created\n";
1060 <<
" implicit move constructors created\n";
1063 <<
" implicit copy assignment operators created\n";
1067 <<
" implicit move assignment operators created\n";
1070 <<
" implicit destructors created\n";
1073 llvm::errs() <<
"\n";
1077 BumpAlloc.PrintStats();
1081 bool NotifyListeners) {
1082 if (NotifyListeners)
1085 Listener->RedefinedHiddenDefinition(ND, M);
1092 if (It == MergedDefModules.end())
1095 auto &Merged = It->second;
1096 llvm::DenseSet<Module*>
Found;
1097 for (
Module *&M : Merged)
1098 if (!
Found.insert(M).second)
1100 llvm::erase(Merged,
nullptr);
1107 if (MergedIt == MergedDefModules.end())
1109 return MergedIt->second;
1112void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1113 if (LazyInitializers.empty())
1117 assert(Source &&
"lazy initializers but no external source");
1119 auto LazyInits = std::move(LazyInitializers);
1120 LazyInitializers.clear();
1122 for (
auto ID : LazyInits)
1123 Initializers.push_back(Source->GetExternalDecl(ID));
1125 assert(LazyInitializers.empty() &&
1126 "GetExternalDecl for lazy module initializer added more inits");
1132 if (
const auto *ID = dyn_cast<ImportDecl>(D)) {
1133 auto It = ModuleInitializers.find(ID->getImportedModule());
1136 if (It == ModuleInitializers.end())
1140 auto &Imported = *It->second;
1141 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1142 Imported.resolve(*
this);
1143 auto *OnlyDecl = Imported.Initializers.front();
1149 auto *&
Inits = ModuleInitializers[M];
1151 Inits =
new (*this) PerModuleInitializers;
1152 Inits->Initializers.push_back(D);
1157 auto *&
Inits = ModuleInitializers[M];
1159 Inits =
new (*this) PerModuleInitializers;
1160 Inits->LazyInitializers.insert(
Inits->LazyInitializers.end(),
1161 IDs.begin(), IDs.end());
1165 auto It = ModuleInitializers.find(M);
1166 if (It == ModuleInitializers.end())
1169 auto *
Inits = It->second;
1170 Inits->resolve(*
this);
1171 return Inits->Initializers;
1176 assert(!CurrentCXXNamedModule &&
1177 "We should set named module for ASTContext for only once");
1178 CurrentCXXNamedModule = M;
1190 auto GetRepresentativeModule = [
this](
const Module *M) {
1191 auto Iter = SameModuleLookupSet.find(M);
1192 if (Iter != SameModuleLookupSet.end())
1193 return Iter->second;
1195 const Module *RepresentativeModule =
1196 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1198 SameModuleLookupSet[M] = RepresentativeModule;
1199 return RepresentativeModule;
1202 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1203 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1207 if (!ExternCContext)
1210 return ExternCContext;
1224#define BuiltinTemplate(BTName) \
1225 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1226 if (!Decl##BTName) \
1228 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1229 return Decl##BTName; \
1231#include "clang/Basic/BuiltinTemplates.inc"
1244 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1245 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1250 StringRef Name)
const {
1274 Types.push_back(Ty);
1279 assert((!this->Target || this->Target == &Target) &&
1280 "Incorrect target reinitialization");
1281 assert(
VoidTy.isNull() &&
"Context reinitialized?");
1283 this->Target = &Target;
1284 this->AuxTarget = AuxTarget;
1286 ABI.reset(createCXXABI(Target));
1290 InitBuiltinType(
VoidTy, BuiltinType::Void);
1293 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1295 if (LangOpts.CharIsSigned)
1296 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1298 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1301 InitBuiltinType(
ShortTy, BuiltinType::Short);
1302 InitBuiltinType(
IntTy, BuiltinType::Int);
1303 InitBuiltinType(
LongTy, BuiltinType::Long);
1304 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1314 InitBuiltinType(
FloatTy, BuiltinType::Float);
1315 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1316 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1319 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1322 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1325 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1328 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1329 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1330 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1334 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1335 InitBuiltinType(
FractTy, BuiltinType::Fract);
1336 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1341 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1347 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1354 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1359 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1361 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1362 if (LangOpts.CPlusPlus && LangOpts.WChar)
1366 WideCharTy = getFromTargetType(Target.getWCharType());
1369 WIntTy = getFromTargetType(Target.getWIntType());
1372 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1374 if (LangOpts.CPlusPlus)
1375 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1377 Char16Ty = getFromTargetType(Target.getChar16Type());
1379 if (LangOpts.CPlusPlus)
1380 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1382 Char32Ty = getFromTargetType(Target.getChar32Type());
1389 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1392 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1404 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1410 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1413 if (LangOpts.OpenMP) {
1420 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1423 if (LangOpts.MatrixTypes)
1431 if (LangOpts.OpenCL) {
1432#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1433 InitBuiltinType(SingletonId, BuiltinType::Id);
1434#include "clang/Basic/OpenCLImageTypes.def"
1436 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1437 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1439 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1442#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1443 InitBuiltinType(Id##Ty, BuiltinType::Id);
1444#include "clang/Basic/OpenCLExtensionTypes.def"
1447 if (LangOpts.HLSL) {
1448#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1449 InitBuiltinType(SingletonId, BuiltinType::Id);
1450#include "clang/Basic/HLSLIntangibleTypes.def"
1453 if (Target.hasAArch64ACLETypes() ||
1454 (AuxTarget && AuxTarget->hasAArch64ACLETypes())) {
1455#define SVE_TYPE(Name, Id, SingletonId) \
1456 InitBuiltinType(SingletonId, BuiltinType::Id);
1457#include "clang/Basic/AArch64ACLETypes.def"
1460 if (Target.getTriple().isPPC64()) {
1461#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1462 InitBuiltinType(Id##Ty, BuiltinType::Id);
1463#include "clang/Basic/PPCTypes.def"
1464#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1465 InitBuiltinType(Id##Ty, BuiltinType::Id);
1466#include "clang/Basic/PPCTypes.def"
1469 if (Target.hasRISCVVTypes()) {
1470#define RVV_TYPE(Name, Id, SingletonId) \
1471 InitBuiltinType(SingletonId, BuiltinType::Id);
1472#include "clang/Basic/RISCVVTypes.def"
1475 if (Target.getTriple().isWasm() && Target.hasFeature(
"reference-types")) {
1476#define WASM_TYPE(Name, Id, SingletonId) \
1477 InitBuiltinType(SingletonId, BuiltinType::Id);
1478#include "clang/Basic/WebAssemblyReferenceTypes.def"
1481 if (Target.hasAMDGPUTypes() || (AuxTarget && (AuxTarget->hasAMDGPUTypes()))) {
1482#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1483 InitBuiltinType(SingletonId, BuiltinType::Id);
1484#include "clang/Basic/AMDGPUTypes.def"
1487 if (Target.getTriple().isSPIRV() ||
1488 (AuxTarget && AuxTarget->getTriple().isSPIRV())) {
1489#define SPIRV_TYPE(Name, Id, SingletonId) \
1490 InitBuiltinType(SingletonId, BuiltinType::Id);
1491#include "clang/Basic/SPIRVTypes.def"
1498 ObjCConstantStringType =
QualType();
1503 if (LangOpts.OpenCLGenericAddressSpace) {
1504 auto Q =
VoidTy.getQualifiers();
1513 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1516 InitBuiltinType(
HalfTy, BuiltinType::Half);
1518 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1524 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1531 return SourceMgr.getDiagnostics();
1546 llvm::DenseMap<const Decl*, AttrVec*>::iterator Pos = DeclAttrs.find(D);
1547 if (Pos != DeclAttrs.end()) {
1548 Pos->second->~AttrVec();
1549 DeclAttrs.erase(Pos);
1555 return CtorClosureDefaultArgs.lookup(CD);
1560 assert(!CtorClosureDefaultArgs.contains(CD));
1561 CtorClosureDefaultArgs[CD] = Args;
1568 if (It != ExplicitInstantiations.end())
1589 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1590 TemplateOrInstantiation.find(Var);
1591 if (Pos == TemplateOrInstantiation.end())
1604 Tmpl, TSK, PointOfInstantiation));
1610 assert(!TemplateOrInstantiation[Inst] &&
1611 "Already noted what the variable was instantiated from");
1612 TemplateOrInstantiation[Inst] = TSI;
1617 return InstantiatedFromUsingDecl.lookup(UUD);
1625 "pattern decl is not a using decl");
1629 "instantiation did not produce a using decl");
1630 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1631 InstantiatedFromUsingDecl[Inst] = Pattern;
1636 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1641 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1642 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1647 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1653 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1654 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1659 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1665 "Instantiated field decl is not unnamed");
1667 "Template field decl is not unnamed");
1668 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1669 "Already noted what unnamed field was instantiated from");
1671 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1687 return Range.end() - Range.begin();
1692 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1693 OverriddenMethods.find(
Method->getCanonicalDecl());
1694 if (Pos == OverriddenMethods.end())
1702 OverriddenMethods[
Method].push_back(Overridden);
1710 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1716 const auto *
Method = dyn_cast<ObjCMethodDecl>(D);
1721 Method->getOverriddenMethods(OverDecls);
1722 Overridden.append(OverDecls.begin(), OverDecls.end());
1725std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1729 auto it = RelocatableClasses.find(D);
1730 if (it != RelocatableClasses.end())
1731 return it->getSecond();
1732 return std::nullopt;
1739 assert(RelocatableClasses.find(D) == RelocatableClasses.end());
1740 RelocatableClasses.insert({D, Info});
1745 if (!Class->isPolymorphic())
1747 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
1748 using AuthAttr = VTablePointerAuthenticationAttr;
1749 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1751 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1752 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1753 ExplicitAuth->getAddressDiscrimination();
1754 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1755 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1756 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1759ASTContext::PointerAuthContent
1760ASTContext::findPointerAuthContent(QualType
T)
const {
1761 assert(isPointerAuthenticationAvailable());
1763 T =
T.getCanonicalType();
1765 return PointerAuthContent::None;
1767 if (
T.hasAddressDiscriminatedPointerAuth())
1768 return PointerAuthContent::AddressDiscriminatedData;
1771 return PointerAuthContent::None;
1774 return PointerAuthContent::None;
1776 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1777 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1778 return Existing->second;
1780 PointerAuthContent
Result = PointerAuthContent::None;
1782 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1783 auto [ResultIter, DidAdd] =
1784 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1790 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1791 static_assert(PointerAuthContent::None <
1792 PointerAuthContent::AddressDiscriminatedVTable);
1793 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1794 PointerAuthContent::AddressDiscriminatedData);
1797 return Result != PointerAuthContent::AddressDiscriminatedData;
1799 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1801 !ShouldContinueAfterUpdate(
1802 PointerAuthContent::AddressDiscriminatedVTable))
1803 return SaveResultAndReturn();
1804 for (
auto Base : CXXRD->bases()) {
1805 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1806 return SaveResultAndReturn();
1809 for (
auto *FieldDecl : RD->
fields()) {
1810 if (!ShouldContinueAfterUpdate(
1811 findPointerAuthContent(FieldDecl->getType())))
1812 return SaveResultAndReturn();
1814 return SaveResultAndReturn();
1818 assert(!Import->getNextLocalImport() &&
1819 "Import declaration already in the chain");
1820 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1821 if (!FirstLocalImport) {
1822 FirstLocalImport = Import;
1823 LastLocalImport = Import;
1827 LastLocalImport->setNextLocalImport(Import);
1828 LastLocalImport = Import;
1840 llvm_unreachable(
"Not a floating point type!");
1841 case BuiltinType::BFloat16:
1842 return Target->getBFloat16Format();
1843 case BuiltinType::Float16:
1844 return Target->getHalfFormat();
1845 case BuiltinType::Half:
1846 return Target->getHalfFormat();
1847 case BuiltinType::Float:
return Target->getFloatFormat();
1848 case BuiltinType::Double:
return Target->getDoubleFormat();
1849 case BuiltinType::Ibm128:
1850 return Target->getIbm128Format();
1851 case BuiltinType::LongDouble:
1853 return AuxTarget->getLongDoubleFormat();
1854 return Target->getLongDoubleFormat();
1855 case BuiltinType::Float128:
1857 return AuxTarget->getFloat128Format();
1858 return Target->getFloat128Format();
1863 unsigned Align = Target->getCharWidth();
1867 Align = AlignFromAttr;
1875 bool UseAlignAttrOnly;
1876 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1878 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1880 UseAlignAttrOnly = AlignFromAttr != 0;
1883 if (UseAlignAttrOnly) {
1885 }
else if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
1889 T = RT->getPointeeType();
1894 if (
T->isFunctionType())
1895 Align = getTypeInfoImpl(
T.getTypePtr()).Align;
1900 unsigned MinWidth = Target->getLargeArrayMinWidth();
1901 if (!ForAlignof && MinWidth) {
1903 Align = std::max(Align, Target->getLargeArrayAlign());
1906 Align = std::max(Align, Target->getLargeArrayAlign());
1911 Align = Target->getCharWidth();
1915 if (
const auto *VD = dyn_cast<VarDecl>(D))
1916 if (VD->hasGlobalStorage() && !ForAlignof) {
1927 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1941 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1942 if (LowBitOfOffset < FieldAlign)
1943 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1946 Align = std::min(Align, FieldAlign);
1954 const auto *VD = dyn_cast<VarDecl>(D);
1955 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1956 Align = std::min(Align, MaxAlignedAttr);
1976 if (
const auto *RD =
T->getAsCXXRecordDecl(); RD && !RD->
isInvalidDecl()) {
1993 (uint64_t)(-1)/Size) &&
1994 "Overflow in array type char size evaluation");
1997 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
1999 Width = llvm::alignTo(Width, Align);
2006 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2024 switch (BT->getKind()) {
2025 case BuiltinType::Bool:
2026 case BuiltinType::Char_S:
2027 case BuiltinType::Char_U:
2028 case BuiltinType::SChar:
2029 case BuiltinType::UChar:
2030 case BuiltinType::Short:
2031 case BuiltinType::UShort:
2032 case BuiltinType::WChar_S:
2033 case BuiltinType::WChar_U:
2034 case BuiltinType::Char8:
2035 case BuiltinType::Char16:
2036 case BuiltinType::Char32:
2044 if (
const auto *ED =
T->getAsEnumDecl()) {
2045 if (
T->isDependentType() || ED->getPromotionType().isNull() ||
2053 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>()) {
2069 bool NeedsPreferredAlignment)
const {
2072 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2077 if (!
T->isIncompleteType())
2083 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
2087 if (
const auto *TD =
T->getAsTagDecl())
2088 return TD->getMaxAlignment();
2094 TypeInfoMap::iterator I = MemoizedTypeInfo.find(
T);
2095 if (I != MemoizedTypeInfo.end())
2100 MemoizedTypeInfo[
T] = TI;
2115 switch (
T->getTypeClass()) {
2116#define TYPE(Class, Base)
2117#define ABSTRACT_TYPE(Class, Base)
2118#define NON_CANONICAL_TYPE(Class, Base)
2119#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2120#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
2122 assert(!T->isDependentType() && "should not see dependent types here"); \
2123 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
2124#include "clang/AST/TypeNodes.inc"
2125 llvm_unreachable(
"Should not see dependent types");
2127 case Type::FunctionNoProto:
2128 case Type::FunctionProto:
2134 case Type::IncompleteArray:
2135 case Type::VariableArray:
2136 case Type::ConstantArray:
2137 case Type::ArrayParameter: {
2140 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2141 Size = CAT->getZExtSize();
2144 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2145 "Overflow in array type bit size evaluation");
2146 Width = EltInfo.
Width * Size;
2147 Align = EltInfo.
Align;
2151 Width = llvm::alignTo(Width, Align);
2155 case Type::ExtVector:
2156 case Type::Vector: {
2159 Width = VT->isPackedVectorBoolType(*
this)
2160 ? VT->getNumElements()
2161 : EltInfo.
Width * VT->getNumElements();
2163 Width = std::max<unsigned>(8, Width);
2164 Align = std::max<unsigned>(
2165 8,
Target->vectorsAreElementAligned() ? EltInfo.
Width : Width);
2169 if (Align & (Align-1)) {
2170 Align = llvm::bit_ceil(Align);
2171 Width = llvm::alignTo(Width, Align);
2174 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
2175 if (TargetVectorAlign && TargetVectorAlign < Align)
2176 Align = TargetVectorAlign;
2190 Align = std::min<unsigned>(64, Width);
2194 case Type::ConstantMatrix: {
2196 TypeInfo ElementInfo =
getTypeInfo(MT->getElementType());
2200 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2201 Align = ElementInfo.
Align;
2207 default: llvm_unreachable(
"Unknown builtin type!");
2208 case BuiltinType::Void:
2213 case BuiltinType::Bool:
2214 Width = Target->getBoolWidth();
2215 Align = Target->getBoolAlign();
2217 case BuiltinType::Char_S:
2218 case BuiltinType::Char_U:
2219 case BuiltinType::UChar:
2220 case BuiltinType::SChar:
2221 case BuiltinType::Char8:
2222 Width = Target->getCharWidth();
2223 Align = Target->getCharAlign();
2225 case BuiltinType::WChar_S:
2226 case BuiltinType::WChar_U:
2227 Width = Target->getWCharWidth();
2228 Align = Target->getWCharAlign();
2230 case BuiltinType::Char16:
2231 Width = Target->getChar16Width();
2232 Align = Target->getChar16Align();
2234 case BuiltinType::Char32:
2235 Width = Target->getChar32Width();
2236 Align = Target->getChar32Align();
2238 case BuiltinType::UShort:
2239 case BuiltinType::Short:
2240 Width = Target->getShortWidth();
2241 Align = Target->getShortAlign();
2243 case BuiltinType::UInt:
2244 case BuiltinType::Int:
2245 Width = Target->getIntWidth();
2246 Align = Target->getIntAlign();
2248 case BuiltinType::ULong:
2249 case BuiltinType::Long:
2250 Width = Target->getLongWidth();
2251 Align = Target->getLongAlign();
2253 case BuiltinType::ULongLong:
2254 case BuiltinType::LongLong:
2255 Width = Target->getLongLongWidth();
2256 Align = Target->getLongLongAlign();
2258 case BuiltinType::Int128:
2259 case BuiltinType::UInt128:
2261 Align = Target->getInt128Align();
2263 case BuiltinType::ShortAccum:
2264 case BuiltinType::UShortAccum:
2265 case BuiltinType::SatShortAccum:
2266 case BuiltinType::SatUShortAccum:
2267 Width = Target->getShortAccumWidth();
2268 Align = Target->getShortAccumAlign();
2270 case BuiltinType::Accum:
2271 case BuiltinType::UAccum:
2272 case BuiltinType::SatAccum:
2273 case BuiltinType::SatUAccum:
2274 Width = Target->getAccumWidth();
2275 Align = Target->getAccumAlign();
2277 case BuiltinType::LongAccum:
2278 case BuiltinType::ULongAccum:
2279 case BuiltinType::SatLongAccum:
2280 case BuiltinType::SatULongAccum:
2281 Width = Target->getLongAccumWidth();
2282 Align = Target->getLongAccumAlign();
2284 case BuiltinType::ShortFract:
2285 case BuiltinType::UShortFract:
2286 case BuiltinType::SatShortFract:
2287 case BuiltinType::SatUShortFract:
2288 Width = Target->getShortFractWidth();
2289 Align = Target->getShortFractAlign();
2291 case BuiltinType::Fract:
2292 case BuiltinType::UFract:
2293 case BuiltinType::SatFract:
2294 case BuiltinType::SatUFract:
2295 Width = Target->getFractWidth();
2296 Align = Target->getFractAlign();
2298 case BuiltinType::LongFract:
2299 case BuiltinType::ULongFract:
2300 case BuiltinType::SatLongFract:
2301 case BuiltinType::SatULongFract:
2302 Width = Target->getLongFractWidth();
2303 Align = Target->getLongFractAlign();
2305 case BuiltinType::BFloat16:
2306 if (Target->hasBFloat16Type()) {
2307 Width = Target->getBFloat16Width();
2308 Align = Target->getBFloat16Align();
2312 AuxTarget->hasBFloat16Type()) {
2313 Width = AuxTarget->getBFloat16Width();
2314 Align = AuxTarget->getBFloat16Align();
2317 case BuiltinType::Float16:
2318 case BuiltinType::Half:
2319 if (Target->hasFloat16Type() || !
getLangOpts().OpenMP ||
2321 Width = Target->getHalfWidth();
2322 Align = Target->getHalfAlign();
2325 "Expected OpenMP device compilation.");
2326 Width = AuxTarget->getHalfWidth();
2327 Align = AuxTarget->getHalfAlign();
2330 case BuiltinType::Float:
2331 Width = Target->getFloatWidth();
2332 Align = Target->getFloatAlign();
2334 case BuiltinType::Double:
2335 Width = Target->getDoubleWidth();
2336 Align = Target->getDoubleAlign();
2338 case BuiltinType::Ibm128:
2339 Width = Target->getIbm128Width();
2340 Align = Target->getIbm128Align();
2342 case BuiltinType::LongDouble:
2344 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2345 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2346 Width = AuxTarget->getLongDoubleWidth();
2347 Align = AuxTarget->getLongDoubleAlign();
2349 Width = Target->getLongDoubleWidth();
2350 Align = Target->getLongDoubleAlign();
2353 case BuiltinType::Float128:
2354 if (Target->hasFloat128Type() || !
getLangOpts().OpenMP ||
2356 Width = Target->getFloat128Width();
2357 Align = Target->getFloat128Align();
2360 "Expected OpenMP device compilation.");
2361 Width = AuxTarget->getFloat128Width();
2362 Align = AuxTarget->getFloat128Align();
2365 case BuiltinType::NullPtr:
2370 case BuiltinType::ObjCId:
2371 case BuiltinType::ObjCClass:
2372 case BuiltinType::ObjCSel:
2376 case BuiltinType::OCLSampler:
2377 case BuiltinType::OCLEvent:
2378 case BuiltinType::OCLClkEvent:
2379 case BuiltinType::OCLQueue:
2380 case BuiltinType::OCLReserveID:
2381#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2382 case BuiltinType::Id:
2383#include "clang/Basic/OpenCLImageTypes.def"
2384#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2385 case BuiltinType::Id:
2386#include "clang/Basic/OpenCLExtensionTypes.def"
2388 Width = Target->getPointerWidth(AS);
2389 Align = Target->getPointerAlign(AS);
2399#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2400 case BuiltinType::Id: \
2404#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2405 case BuiltinType::Id: \
2409#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2410 case BuiltinType::Id: \
2414#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2415 case BuiltinType::Id: \
2419#include "clang/Basic/AArch64ACLETypes.def"
2420#define PPC_VECTOR_TYPE(Name, Id, Size) \
2421 case BuiltinType::Id: \
2425#include "clang/Basic/PPCTypes.def"
2426#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2428 case BuiltinType::Id: \
2432#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2433 case BuiltinType::Id: \
2437#include "clang/Basic/RISCVVTypes.def"
2438#define WASM_TYPE(Name, Id, SingletonId) \
2439 case BuiltinType::Id: \
2443#include "clang/Basic/WebAssemblyReferenceTypes.def"
2444#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2445 case BuiltinType::ID: \
2449#include "clang/Basic/AMDGPUTypes.def"
2450#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2451#include "clang/Basic/HLSLIntangibleTypes.def"
2455#define SPIRV_TYPE(Name, Id, SingletonId) \
2456 case BuiltinType::Id: \
2457 Width = Target->getPointerWidth(LangAS::Default); \
2458 Align = Target->getPointerAlign(LangAS::Default); \
2460#include "clang/Basic/SPIRVTypes.def"
2463 case Type::ObjCObjectPointer:
2467 case Type::BlockPointer:
2469 Width = Target->getPointerWidth(AS);
2470 Align = Target->getPointerAlign(AS);
2472 case Type::LValueReference:
2473 case Type::RValueReference:
2477 Width = Target->getPointerWidth(AS);
2478 Align = Target->getPointerAlign(AS);
2482 Width = Target->getPointerWidth(AS);
2483 Align = Target->getPointerAlign(AS);
2485 case Type::MemberPointer: {
2487 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2492 case Type::Complex: {
2496 Width = EltInfo.
Width * 2;
2497 Align = EltInfo.
Align;
2500 case Type::ObjCObject:
2502 case Type::Adjusted:
2505 case Type::ObjCInterface: {
2507 if (ObjCI->getDecl()->isInvalidDecl()) {
2517 case Type::BitInt: {
2519 Align = Target->getBitIntAlign(EIT->getNumBits());
2520 Width = Target->getBitIntWidth(EIT->getNumBits());
2526 const TagDecl *TD = TT->getDecl()->getDefinitionOrSelf();
2539 Info.
Align = AttrAlign;
2549 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2555 case Type::SubstTemplateTypeParm:
2557 getReplacementType().getTypePtr());
2560 case Type::DeducedTemplateSpecialization: {
2562 assert(!A->getDeducedType().isNull() &&
2563 "cannot request the size of an undeduced or dependent auto type");
2564 return getTypeInfo(A->getDeducedType().getTypePtr());
2570 case Type::MacroQualified:
2574 case Type::ObjCTypeParam:
2580 case Type::Typedef: {
2582 TypeInfo Info =
getTypeInfo(TT->desugar().getTypePtr());
2586 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2597 case Type::Attributed:
2601 case Type::CountAttributed:
2604 case Type::LateParsedAttr:
2607 case Type::BTFTagAttributed:
2611 case Type::OverflowBehavior:
2615 case Type::HLSLAttributedResource:
2619 case Type::HLSLInlineSpirv: {
2622 Width = ST->getSize() * 8;
2623 Align = ST->getAlignment();
2624 if (Width == 0 && Align == 0) {
2632 case Type::Atomic: {
2641 Width = Target->getCharWidth();
2643 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2649 Width = llvm::bit_ceil(Width);
2652 Align =
static_cast<unsigned>(Width);
2657 case Type::PredefinedSugar:
2666 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2667 return TypeInfo(Width, Align, AlignRequirement);
2671 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(
T);
2672 if (I != MemoizedUnadjustedAlign.end())
2675 unsigned UnadjustedAlign;
2676 if (
const auto *RT =
T->getAsCanonical<RecordType>()) {
2683 UnadjustedAlign =
getTypeAlign(
T->getUnqualifiedDesugaredType());
2686 MemoizedUnadjustedAlign[
T] = UnadjustedAlign;
2687 return UnadjustedAlign;
2691 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2741 unsigned ABIAlign = TI.
Align;
2743 T =
T->getBaseElementTypeUnsafe();
2746 if (
T->isMemberPointerType())
2749 if (!Target->allowsLargerPreferedTypeAlignment())
2752 if (
const auto *RD =
T->getAsRecordDecl()) {
2761 unsigned PreferredAlign =
static_cast<unsigned>(
2763 assert(PreferredAlign >= ABIAlign &&
2764 "PreferredAlign should be at least as large as ABIAlign.");
2765 return PreferredAlign;
2772 T = CT->getElementType().getTypePtr();
2773 if (
const auto *ED =
T->getAsEnumDecl())
2774 T = ED->getIntegerType().getTypePtr();
2775 if (
T->isSpecificBuiltinType(BuiltinType::Double) ||
2776 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2777 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2778 (
T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2779 Target->defaultsToAIXPowerAlignment()))
2834 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
2838 std::swap(
Base, Derived);
2858 llvm::append_range(Ivars, OI->
ivars());
2861 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2863 Ivars.push_back(Iv);
2871 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2874 for (
auto *Proto : OI->all_referenced_protocols()) {
2879 for (
const auto *Cat : OI->visible_categories())
2885 SD = SD->getSuperClass();
2887 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2888 for (
auto *Proto : OC->protocols()) {
2891 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2893 if (!Protocols.insert(
2897 for (
auto *Proto : OP->protocols())
2904 bool CheckIfTriviallyCopyable) {
2905 assert(RD->
isUnion() &&
"Must be union type");
2907 Context.getTypeSizeInChars(Context.getCanonicalTagType(RD));
2909 for (
const auto *Field : RD->
fields()) {
2910 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2911 CheckIfTriviallyCopyable))
2913 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2914 if (FieldSize != UnionSize)
2923 return Context.getFieldOffset(Field);
2932static std::optional<int64_t>
2934 const RecordDecl *RD,
2935 bool CheckIfTriviallyCopyable);
2937static std::optional<int64_t>
2939 bool CheckIfTriviallyCopyable) {
2940 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2943 CheckIfTriviallyCopyable);
2947 bool IsBitIntType = Field->getType()->isBitIntType();
2948 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2949 !Context.hasUniqueObjectRepresentations(Field->getType(),
2950 CheckIfTriviallyCopyable))
2951 return std::nullopt;
2953 int64_t FieldSizeInBits =
2954 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2955 if (Field->isBitField()) {
2958 if (Field->isUnnamedBitField())
2961 int64_t BitfieldSize = Field->getBitWidthValue();
2963 if ((
unsigned)BitfieldSize >
2965 return std::nullopt;
2966 }
else if (BitfieldSize > FieldSizeInBits) {
2967 return std::nullopt;
2969 FieldSizeInBits = BitfieldSize;
2970 }
else if (IsBitIntType && !Context.hasUniqueObjectRepresentations(
2971 Field->getType(), CheckIfTriviallyCopyable)) {
2972 return std::nullopt;
2974 return FieldSizeInBits;
2977static std::optional<int64_t>
2979 bool CheckIfTriviallyCopyable) {
2981 CheckIfTriviallyCopyable);
2984template <
typename RangeT>
2986 const RangeT &Subobjects, int64_t CurOffsetInBits,
2988 bool CheckIfTriviallyCopyable) {
2989 for (
const auto *Subobject : Subobjects) {
2990 std::optional<int64_t> SizeInBits =
2993 return std::nullopt;
2994 if (*SizeInBits != 0) {
2996 if (Offset != CurOffsetInBits)
2997 return std::nullopt;
2998 CurOffsetInBits += *SizeInBits;
3001 return CurOffsetInBits;
3004static std::optional<int64_t>
3007 bool CheckIfTriviallyCopyable) {
3008 assert(!RD->
isUnion() &&
"Must be struct/class type");
3009 const auto &Layout = Context.getASTRecordLayout(RD);
3011 int64_t CurOffsetInBits = 0;
3012 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3013 if (ClassDecl->isDynamicClass())
3014 return std::nullopt;
3017 for (
const auto &
Base : ClassDecl->bases()) {
3020 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
3024 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
3027 std::optional<int64_t> OffsetAfterBases =
3029 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
3030 if (!OffsetAfterBases)
3031 return std::nullopt;
3032 CurOffsetInBits = *OffsetAfterBases;
3035 std::optional<int64_t> OffsetAfterFields =
3037 RD->
fields(), CurOffsetInBits, Context, Layout,
3038 CheckIfTriviallyCopyable);
3039 if (!OffsetAfterFields)
3040 return std::nullopt;
3041 CurOffsetInBits = *OffsetAfterFields;
3043 return CurOffsetInBits;
3047 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
3064 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
3069 CheckIfTriviallyCopyable);
3072 "hasUniqueObjectRepresentations should not be called with an "
3096 return !ABI->getMemberPointerInfo(MPT).HasPadding;
3099 if (
Record->isInvalidDecl())
3104 CheckIfTriviallyCopyable);
3107 *
this,
Record, CheckIfTriviallyCopyable);
3109 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
3130 count += Ext->ivar_size();
3135 count += ImplDecl->ivar_size();
3161 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3162 I = ObjCImpls.find(D);
3163 if (I != ObjCImpls.end())
3171 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3172 I = ObjCImpls.find(D);
3173 if (I != ObjCImpls.end())
3181 assert(IFaceD && ImplD &&
"Passed null params");
3182 ObjCImpls[IFaceD] = ImplD;
3188 assert(CatD && ImplD &&
"Passed null params");
3189 ObjCImpls[CatD] = ImplD;
3194 return ObjCMethodRedecls.
lookup(MD);
3200 ObjCMethodRedecls[MD] = Redecl;
3205 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3207 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3208 return CD->getClassInterface();
3209 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3210 return IMD->getClassInterface();
3218 assert(VD &&
"Passed null params");
3219 assert(VD->
hasAttr<BlocksAttr>() &&
3220 "getBlockVarCopyInits - not __block var");
3221 auto I = BlockVarCopyInits.find(VD);
3222 if (I != BlockVarCopyInits.end())
3224 return {
nullptr,
false};
3230 assert(VD && CopyExpr &&
"Passed null params");
3231 assert(VD->
hasAttr<BlocksAttr>() &&
3232 "setBlockVarCopyInits - not __block var");
3233 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3237 unsigned DataSize)
const {
3242 "incorrect data size provided to CreateTypeSourceInfo!");
3259 return getObjCLayout(D);
3264 bool &AnyNonCanonArgs) {
3266 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3272 bool AnyNonCanonArgs =
false;
3273 for (
auto &Arg : Args) {
3276 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3278 return AnyNonCanonArgs;
3286ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3291 llvm::FoldingSetNodeID ID;
3293 void *insertPos =
nullptr;
3294 if (
ExtQuals *eq = ExtQualNodes.FindNodeOrInsertPos(ID, insertPos)) {
3295 assert(eq->getQualifiers() == quals);
3304 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3307 (void) ExtQualNodes.FindNodeOrInsertPos(ID, insertPos);
3310 auto *eq =
new (*
this,
alignof(ExtQuals)) ExtQuals(baseType, canon, quals);
3311 ExtQualNodes.InsertNode(eq, insertPos);
3312 return QualType(eq, fastQuals);
3316 LangAS AddressSpace)
const {
3329 "Type cannot be in multiple addr spaces!");
3332 return getExtQualType(TypeNode, Quals);
3338 if (!
T.hasAddressSpace())
3342 const Type *TypeNode;
3345 if (
T.getTypePtr()->isArrayType()) {
3347 TypeNode =
T.getTypePtr();
3351 while (
T.hasAddressSpace()) {
3352 TypeNode = Quals.
strip(
T);
3356 if (!
QualType(TypeNode, 0).hasAddressSpace())
3360 T =
T.getSingleStepDesugaredType(*
this);
3370 return getExtQualType(TypeNode, Quals);
3379 "Attempted to get vtable pointer discriminator on a monomorphic type");
3383 llvm::raw_svector_ostream Out(Str);
3384 MC->mangleCXXVTable(RD, Out);
3387 return llvm::getPointerAuthStableSipHash(Str);
3413 switch (
T->getTypeClass()) {
3418 case Type::LValueReference:
3423 case Type::RValueReference:
3437 case Type::ObjCObjectPointer:
3438 case Type::BlockPointer:
3447 case Type::VariableArray:
3448 case Type::ConstantArray:
3449 case Type::IncompleteArray:
3450 case Type::ArrayParameter:
3463 case Type::ObjCInterface:
3464 case Type::ObjCObject:
3465 OS <<
"<objc_object>";
3474 QualType UnderlyingType =
T->castAsEnumDecl()->getIntegerType();
3476 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3479 case Type::FunctionNoProto:
3480 case Type::FunctionProto: {
3496 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3497 for (
QualType Param : FPT->param_types()) {
3501 if (FPT->isVariadic())
3508 case Type::MemberPointer: {
3512 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3516 case Type::ExtVector:
3524 case Type::ConstantMatrix:
3528 case Type::Builtin: {
3530 switch (BTy->getKind()) {
3531#define SIGNED_TYPE(Id, SingletonId) \
3532 case BuiltinType::Id: \
3535#define UNSIGNED_TYPE(Id, SingletonId) \
3536 case BuiltinType::Id: \
3539#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3540#define BUILTIN_TYPE(Id, SingletonId)
3541#include "clang/AST/BuiltinTypes.def"
3542 llvm_unreachable(
"placeholder types should not appear here.");
3544 case BuiltinType::Half:
3547 case BuiltinType::Float:
3550 case BuiltinType::Double:
3553 case BuiltinType::LongDouble:
3556 case BuiltinType::Float16:
3559 case BuiltinType::Float128:
3563 case BuiltinType::Void:
3567 case BuiltinType::ObjCId:
3568 case BuiltinType::ObjCClass:
3569 case BuiltinType::ObjCSel:
3570 case BuiltinType::NullPtr:
3575 case BuiltinType::OCLSampler:
3576 case BuiltinType::OCLEvent:
3577 case BuiltinType::OCLClkEvent:
3578 case BuiltinType::OCLQueue:
3579 case BuiltinType::OCLReserveID:
3580 case BuiltinType::BFloat16:
3581 case BuiltinType::VectorQuad:
3582 case BuiltinType::VectorPair:
3583 case BuiltinType::DMR1024:
3584 case BuiltinType::DMR2048:
3589 case BuiltinType::Ibm128:
3591#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3592 case BuiltinType::Id: \
3594#include "clang/Basic/OpenCLImageTypes.def"
3595#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3596 case BuiltinType::Id: \
3598#include "clang/Basic/OpenCLExtensionTypes.def"
3599#define SVE_TYPE(Name, Id, SingletonId) \
3600 case BuiltinType::Id: \
3602#include "clang/Basic/AArch64ACLETypes.def"
3603#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3604 case BuiltinType::Id: \
3606#include "clang/Basic/HLSLIntangibleTypes.def"
3607 case BuiltinType::Dependent:
3608 llvm_unreachable(
"should never get here");
3609#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3610#include "clang/Basic/AMDGPUTypes.def"
3611 case BuiltinType::WasmExternRef:
3612#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3613#include "clang/Basic/RISCVVTypes.def"
3614#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3615#include "clang/Basic/SPIRVTypes.def"
3616 llvm_unreachable(
"not yet implemented");
3618 llvm_unreachable(
"should never get here");
3620 case Type::Record: {
3621 const RecordDecl *RD =
T->castAsCanonical<RecordType>()->getDecl();
3641 II = Typedef->getDeclName().getAsIdentifierInfo();
3644 OS <<
"<anonymous_record>";
3650 case Type::HLSLAttributedResource:
3651 case Type::HLSLInlineSpirv:
3652 llvm_unreachable(
"should never get here");
3654 case Type::OverflowBehavior:
3655 llvm_unreachable(
"should never get here");
3657 case Type::DeducedTemplateSpecialization:
3659#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3660#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3661#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3662#define ABSTRACT_TYPE(Class, Base)
3663#define TYPE(Class, Base)
3664#include "clang/AST/TypeNodes.inc"
3665 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3671 assert(!
T->isDependentType() &&
3672 "cannot compute type discriminator of a dependent type");
3674 llvm::raw_svector_ostream Out(Str);
3676 if (
T->isFunctionPointerType() ||
T->isFunctionReferenceType())
3677 T =
T->getPointeeType();
3679 if (
T->isFunctionType()) {
3682 T =
T.getUnqualifiedType();
3703 if (MPT->isMemberFunctionPointer()) {
3709 MPT->getMostRecentCXXRecordDecl());
3713 MC->mangleCanonicalTypeName(
T, Out);
3716 return llvm::getPointerAuthStableSipHash(Str);
3741 "Type cannot have multiple ObjCGCs!");
3744 return getExtQualType(TypeNode, Quals);
3758 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3762 llvm::FoldingSetNodeID ID;
3765 void *InsertPos =
nullptr;
3767 CountAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
3772 size_t Size = CountAttributedType::totalSizeToAlloc<TypeCoupledDeclRefInfo>(
3773 DependentDecls.size());
3776 OrNull, DependentDecls);
3777 Types.push_back(CATy);
3778 CountAttributedTypes.InsertNode(CATy, InsertPos);
3790 Types.push_back(LPATy);
3798 case Type::Attributed: {
3806 case Type::BTFTagAttributed: {
3807 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3812 case Type::OverflowBehavior: {
3813 const auto *OB = dyn_cast<OverflowBehaviorType>(Orig);
3815 adjustType(OB->getUnderlyingType(), Adjust));
3822 case Type::Adjusted: {
3828 case Type::MacroQualified: {
3831 MQT->getMacroIdentifier());
3835 return Adjust(Orig);
3841 if (
T->getExtInfo() == Info)
3845 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(
T)) {
3865 FPT->getExtProtoInfo());
3880 L->DeducedReturnType(FD, ResultType);
3891 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3892 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3908 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
3931 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
3957 if (TSInfo->getType() != FD->
getType())
3965 "TypeLoc size mismatch from updating exception specification");
3966 TSInfo->overrideType(Updated);
3975 llvm::FoldingSetNodeID ID;
3978 void *InsertPos =
nullptr;
3979 if (
ComplexType *CT = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos))
3985 if (!
T.isCanonical()) {
3989 ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos);
3990 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3993 Types.push_back(
New);
3994 ComplexTypes.InsertNode(
New, InsertPos);
4003 llvm::FoldingSetNodeID ID;
4006 void *InsertPos =
nullptr;
4007 if (
PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4013 if (!
T.isCanonical()) {
4017 PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4018 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4021 Types.push_back(
New);
4022 PointerTypes.InsertNode(
New, InsertPos);
4027 llvm::FoldingSetNodeID ID;
4029 void *InsertPos =
nullptr;
4030 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
4037 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
4038 assert(!AT &&
"Shouldn't be in the map!");
4042 Types.push_back(AT);
4043 AdjustedTypes.InsertNode(AT, InsertPos);
4048 llvm::FoldingSetNodeID ID;
4050 void *InsertPos =
nullptr;
4051 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
4058 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
4059 assert(!AT &&
"Shouldn't be in the map!");
4062 Types.push_back(AT);
4063 AdjustedTypes.InsertNode(AT, InsertPos);
4068 assert((
T->isArrayType() ||
T->isFunctionType()) &&
"T does not decay");
4077 if (
T->isArrayType())
4084 if (
T->isFunctionType())
4096 llvm::FoldingSetNodeID ID;
4097 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
4098 ATy->getSizeExpr(), ATy->getSizeModifier(),
4099 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
4100 void *InsertPos =
nullptr;
4102 ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
4111 AT = ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
4112 assert(!AT &&
"Shouldn't be in the map!");
4117 Types.push_back(AT);
4118 ArrayParameterTypes.InsertNode(AT, InsertPos);
4125 assert(
T->isFunctionType() &&
"block of function types only");
4128 llvm::FoldingSetNodeID ID;
4131 void *InsertPos =
nullptr;
4133 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4139 if (!
T.isCanonical()) {
4144 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4145 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4149 Types.push_back(
New);
4150 BlockPointerTypes.InsertNode(
New, InsertPos);
4158 assert((!
T->isPlaceholderType() ||
4159 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4160 "Unresolved placeholder type");
4164 llvm::FoldingSetNodeID ID;
4167 void *InsertPos =
nullptr;
4169 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4177 if (!SpelledAsLValue || InnerRef || !
T.isCanonical()) {
4178 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4183 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4184 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4189 Types.push_back(
New);
4190 LValueReferenceTypes.InsertNode(
New, InsertPos);
4198 assert((!
T->isPlaceholderType() ||
4199 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4200 "Unresolved placeholder type");
4204 llvm::FoldingSetNodeID ID;
4207 void *InsertPos =
nullptr;
4209 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4217 if (InnerRef || !
T.isCanonical()) {
4218 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4223 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4224 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4229 Types.push_back(
New);
4230 RValueReferenceTypes.InsertNode(
New, InsertPos);
4238 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4241 Cls = Qualifier.getAsRecordDecl();
4245 llvm::FoldingSetNodeID ID;
4248 void *InsertPos =
nullptr;
4250 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4255 return Qualifier.getCanonical();
4257 assert(R.isCanonical());
4263 if (!
T.isCanonical() || Qualifier != CanonicalQualifier) {
4269 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4270 assert(!NewIP &&
"Shouldn't be in the map!");
4274 Types.push_back(
New);
4275 MemberPointerTypes.InsertNode(
New, InsertPos);
4282 const llvm::APInt &ArySizeIn,
4283 const Expr *SizeExpr,
4285 unsigned IndexTypeQuals)
const {
4288 "Constant array of VLAs is illegal!");
4296 llvm::APInt ArySize(ArySizeIn);
4297 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
4299 llvm::FoldingSetNodeID ID;
4301 ASM, IndexTypeQuals);
4303 void *InsertPos =
nullptr;
4305 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
4316 ASM, IndexTypeQuals);
4321 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
4322 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4325 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4326 ASM, IndexTypeQuals);
4327 ConstantArrayTypes.InsertNode(
New, InsertPos);
4328 Types.push_back(
New);
4337 if (!
type->isVariablyModifiedType())
return type;
4342 const Type *ty = split.
Ty;
4344#define TYPE(Class, Base)
4345#define ABSTRACT_TYPE(Class, Base)
4346#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4347#include "clang/AST/TypeNodes.inc"
4348 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4354 case Type::DependentVector:
4355 case Type::ExtVector:
4356 case Type::DependentSizedExtVector:
4357 case Type::ConstantMatrix:
4358 case Type::DependentSizedMatrix:
4359 case Type::DependentAddressSpace:
4360 case Type::ObjCObject:
4361 case Type::ObjCInterface:
4362 case Type::ObjCObjectPointer:
4365 case Type::UnresolvedUsing:
4366 case Type::TypeOfExpr:
4368 case Type::Decltype:
4369 case Type::UnaryTransform:
4370 case Type::DependentName:
4371 case Type::InjectedClassName:
4372 case Type::TemplateSpecialization:
4373 case Type::TemplateTypeParm:
4374 case Type::SubstTemplateTypeParmPack:
4375 case Type::SubstBuiltinTemplatePack:
4377 case Type::DeducedTemplateSpecialization:
4378 case Type::PackExpansion:
4379 case Type::PackIndexing:
4381 case Type::DependentBitInt:
4382 case Type::ArrayParameter:
4383 case Type::HLSLAttributedResource:
4384 case Type::HLSLInlineSpirv:
4385 case Type::OverflowBehavior:
4386 llvm_unreachable(
"type should never be variably-modified");
4390 case Type::FunctionNoProto:
4391 case Type::FunctionProto:
4392 case Type::BlockPointer:
4393 case Type::MemberPointer:
4406 case Type::LValueReference: {
4410 lv->isSpelledAsLValue());
4414 case Type::RValueReference: {
4421 case Type::Atomic: {
4427 case Type::ConstantArray: {
4433 cat->getSizeModifier(),
4434 cat->getIndexTypeCVRQualifiers());
4438 case Type::DependentSizedArray: {
4442 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4447 case Type::IncompleteArray: {
4452 iat->getIndexTypeCVRQualifiers());
4457 case Type::VariableArray: {
4462 vat->getIndexTypeCVRQualifiers());
4475 unsigned IndexTypeQuals)
const {
4492 VariableArrayTypes.push_back(
New);
4493 Types.push_back(
New);
4503 unsigned elementTypeQuals)
const {
4506 "Size must be type- or value-dependent!");
4510 void *insertPos =
nullptr;
4511 llvm::FoldingSetNodeID ID;
4513 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4514 ASM, elementTypeQuals, numElements);
4518 DependentSizedArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4530 DependentSizedArrayTypes.InsertNode(newType, insertPos);
4531 Types.push_back(newType);
4539 numElements, ASM, elementTypeQuals);
4540 DependentSizedArrayTypes.InsertNode(canonTy, insertPos);
4541 Types.push_back(canonTy);
4546 canonElementType.
Quals);
4550 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4559 Types.push_back(sugaredType);
4565 unsigned elementTypeQuals)
const {
4566 llvm::FoldingSetNodeID ID;
4569 void *insertPos =
nullptr;
4571 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos))
4583 ASM, elementTypeQuals);
4588 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4589 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4595 IncompleteArrayTypes.InsertNode(newType, insertPos);
4596 Types.push_back(newType);
4602#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4603 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4606#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4607 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4611 llvm_unreachable(
"Unsupported builtin vector type");
4613#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4614 ElBits, NF, IsSigned) \
4615 case BuiltinType::Id: \
4616 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4617 llvm::ElementCount::getScalable(NumEls), NF};
4618#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4620 case BuiltinType::Id: \
4621 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4622 llvm::ElementCount::getScalable(NumEls), NF};
4623#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4625 case BuiltinType::Id: \
4626 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4627#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4629 case BuiltinType::Id: \
4630 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4631#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4632 case BuiltinType::Id: \
4633 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4634#include "clang/Basic/AArch64ACLETypes.def"
4636#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4638 case BuiltinType::Id: \
4639 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4640 llvm::ElementCount::getScalable(NumEls), NF};
4641#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4642 case BuiltinType::Id: \
4643 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4644 llvm::ElementCount::getScalable(NumEls), NF};
4645#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4646 case BuiltinType::Id: \
4647 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4648#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4649 case BuiltinType::Id: \
4650 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4651#include "clang/Basic/RISCVVTypes.def"
4658 if (Target->getTriple().isWasm() && Target->hasFeature(
"reference-types")) {
4659#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4660 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4662#include "clang/Basic/WebAssemblyReferenceTypes.def"
4665 "shouldn't try to generate type externref outside WebAssembly target");
4672 unsigned NumFields)
const {
4674 if (
auto It = ScalableVecTyMap.find(K); It != ScalableVecTyMap.end())
4677 if (Target->hasAArch64ACLETypes()) {
4680#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4681 ElBits, NF, IsSigned) \
4682 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4683 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4684 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4685 return ScalableVecTyMap[K] = SingletonId; \
4687#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4689 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4690 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4691 return ScalableVecTyMap[K] = SingletonId; \
4693#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4695 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4696 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4697 return ScalableVecTyMap[K] = SingletonId; \
4699#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4701 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4702 NumElts == (NumEls * NF) && NumFields == 1) { \
4703 return ScalableVecTyMap[K] = SingletonId; \
4705#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4706 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4707 return ScalableVecTyMap[K] = SingletonId;
4708#include "clang/Basic/AArch64ACLETypes.def"
4709 }
else if (Target->hasRISCVVTypes()) {
4711#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4713 if (!EltTy->isBooleanType() && \
4714 ((EltTy->hasIntegerRepresentation() && \
4715 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4716 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4718 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4719 IsBF && !IsFP)) && \
4720 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4721 return ScalableVecTyMap[K] = SingletonId;
4722#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4723 if (EltTy->isBooleanType() && NumElts == NumEls) \
4724 return ScalableVecTyMap[K] = SingletonId;
4725#include "clang/Basic/RISCVVTypes.def"
4740 llvm::FoldingSetNodeID ID;
4743 void *InsertPos =
nullptr;
4744 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4754 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4755 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4758 VectorType(vecType, NumElts, Canonical, VecKind);
4759 VectorTypes.InsertNode(
New, InsertPos);
4760 Types.push_back(
New);
4767 llvm::FoldingSetNodeID ID;
4770 void *InsertPos =
nullptr;
4772 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4777 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4780 if (CanonVecTy == VecType) {
4785 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4786 assert(!CanonCheck &&
4787 "Dependent-sized vector_size canonical type broken");
4789 DependentVectorTypes.InsertNode(
New, InsertPos);
4798 Types.push_back(
New);
4805 unsigned NumElts)
const {
4812 llvm::FoldingSetNodeID ID;
4815 void *InsertPos =
nullptr;
4816 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4826 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4827 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4831 VectorTypes.InsertNode(
New, InsertPos);
4832 Types.push_back(
New);
4840 llvm::FoldingSetNodeID ID;
4844 void *InsertPos =
nullptr;
4846 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4856 if (CanonVecTy == vecType) {
4861 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4862 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4864 DependentSizedExtVectorTypes.InsertNode(
New, InsertPos);
4873 Types.push_back(
New);
4878 unsigned NumColumns)
const {
4879 llvm::FoldingSetNodeID ID;
4881 Type::ConstantMatrix);
4884 "need a valid element type");
4885 assert(NumRows > 0 && NumRows <= LangOpts.MaxMatrixDimension &&
4886 NumColumns > 0 && NumColumns <= LangOpts.MaxMatrixDimension &&
4887 "need valid matrix dimensions");
4888 void *InsertPos =
nullptr;
4898 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4904 MatrixTypes.InsertNode(
New, InsertPos);
4905 Types.push_back(
New);
4914 llvm::FoldingSetNodeID ID;
4918 void *InsertPos =
nullptr;
4920 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4925 ColumnExpr, AttrLoc);
4928 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4929 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4931 DependentSizedMatrixTypes.InsertNode(Canon, InsertPos);
4932 Types.push_back(Canon);
4945 ColumnExpr, AttrLoc);
4946 Types.push_back(
New);
4951 Expr *AddrSpaceExpr,
4957 void *insertPos =
nullptr;
4958 llvm::FoldingSetNodeID ID;
4963 DependentAddressSpaceTypes.FindNodeOrInsertPos(ID, insertPos);
4969 DependentAddressSpaceTypes.InsertNode(canonTy, insertPos);
4970 Types.push_back(canonTy);
4973 if (canonPointeeType == PointeeType &&
4979 AddrSpaceExpr, AttrLoc);
4980 Types.push_back(sugaredType);
4986 return T.isCanonical() &&
5004 llvm::FoldingSetNodeID ID;
5007 void *InsertPos =
nullptr;
5009 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
5019 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
5020 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5025 Types.push_back(
New);
5026 FunctionNoProtoTypes.InsertNode(
New, InsertPos);
5042 return CanResultType;
5049 if (!NoexceptInType)
5066 bool AnyPackExpansions =
false;
5070 if (ET->
getAs<PackExpansionType>())
5071 AnyPackExpansions =
true;
5073 return AnyPackExpansions;
5079QualType ASTContext::getFunctionTypeInternal(
5080 QualType ResultTy, ArrayRef<QualType> ArgArray,
5081 const FunctionProtoType::ExtProtoInfo &EPI,
bool OnlyWantCanonical)
const {
5082 size_t NumArgs = ArgArray.size();
5086 llvm::FoldingSetNodeID
ID;
5091 bool Unique =
false;
5093 void *InsertPos =
nullptr;
5094 if (FunctionProtoType *FPT =
5095 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos)) {
5096 QualType Existing = QualType(FPT, 0);
5115 bool IsCanonicalExceptionSpec =
5119 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
5121 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
5122 if (!ArgArray[i].isCanonicalAsParam())
5123 isCanonical =
false;
5125 if (OnlyWantCanonical)
5126 assert(isCanonical &&
5127 "given non-canonical parameters constructing canonical type");
5132 if (!isCanonical && Canonical.
isNull()) {
5133 SmallVector<QualType, 16> CanonicalArgs;
5134 CanonicalArgs.reserve(NumArgs);
5135 for (
unsigned i = 0; i != NumArgs; ++i)
5138 llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
5139 FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
5142 if (IsCanonicalExceptionSpec) {
5144 }
else if (NoexceptInType) {
5157 bool AnyPacks =
false;
5159 if (ET->
getAs<PackExpansionType>())
5180 llvm_unreachable(
"dependent noexcept is already canonical");
5183 CanonicalEPI.
ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
5189 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5192 FunctionProtoType *NewIP =
5193 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
5194 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5199 auto ESH = FunctionProtoType::getExceptionSpecSize(
5201 size_t Size = FunctionProtoType::totalSizeToAlloc<
5202 QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
5203 FunctionType::FunctionTypeExtraAttributeInfo,
5204 FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
5205 Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, Qualifiers,
5206 FunctionEffect, EffectConditionExpr>(
5210 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5215 auto *FTP = (FunctionProtoType *)
Allocate(Size,
alignof(FunctionProtoType));
5216 FunctionProtoType::ExtProtoInfo newEPI = EPI;
5217 new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
5218 Types.push_back(FTP);
5220 FunctionProtoTypes.InsertNode(FTP, InsertPos);
5222 AnyFunctionEffects =
true;
5223 return QualType(FTP, 0);
5226QualType ASTContext::getPipeType(QualType
T,
bool ReadOnly)
const {
5227 llvm::FoldingSetNodeID
ID;
5230 void *InsertPos =
nullptr;
5231 if (PipeType *PT = PipeTypes.FindNodeOrInsertPos(ID, InsertPos))
5232 return QualType(PT, 0);
5237 if (!
T.isCanonical()) {
5241 PipeType *NewIP = PipeTypes.FindNodeOrInsertPos(ID, InsertPos);
5242 assert(!NewIP &&
"Shouldn't be in the map!");
5245 auto *
New =
new (*
this,
alignof(PipeType)) PipeType(
T, Canonical, ReadOnly);
5246 Types.push_back(
New);
5247 PipeTypes.InsertNode(
New, InsertPos);
5248 return QualType(
New, 0);
5258 return getPipeType(
T,
true);
5262 return getPipeType(
T,
false);
5266 llvm::FoldingSetNodeID ID;
5269 void *InsertPos =
nullptr;
5270 if (
BitIntType *EIT = BitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5274 BitIntTypes.InsertNode(
New, InsertPos);
5275 Types.push_back(
New);
5280 Expr *NumBitsExpr)
const {
5282 llvm::FoldingSetNodeID ID;
5285 void *InsertPos =
nullptr;
5287 DependentBitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5292 DependentBitIntTypes.InsertNode(
New, InsertPos);
5294 Types.push_back(
New);
5302 if (
auto *Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5314 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5315 case Kind::SignedSizeT:
5317 case Kind::PtrdiffT:
5320 llvm_unreachable(
"unexpected kind");
5325 Types.push_back(
New);
5326 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5333 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5336 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5338 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5347 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5349 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5351 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5353 assert(TD->TypeForDecl);
5358 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5360 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5361 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5364 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5367 assert(
Decl->TypeForDecl);
5377 std::optional<bool> TypeMatchesDeclOrNone)
const {
5378 if (!TypeMatchesDeclOrNone) {
5379 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5380 assert(!DeclUnderlyingType.
isNull());
5381 if (UnderlyingType.
isNull())
5382 UnderlyingType = DeclUnderlyingType;
5384 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5385 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5389 assert(!UnderlyingType.
isNull());
5393 *TypeMatchesDeclOrNone) {
5394 if (
Decl->TypeForDecl)
5399 !*TypeMatchesDeclOrNone);
5401 Types.push_back(NewType);
5402 Decl->TypeForDecl = NewType;
5406 llvm::FoldingSetNodeID ID;
5408 *TypeMatchesDeclOrNone ?
QualType() : UnderlyingType);
5410 void *InsertPos =
nullptr;
5412 TypedefTypes.FindNodeOrInsertPos(ID, InsertPos))
5413 return QualType(Placeholder->getType(), 0);
5418 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5422 UnderlyingType, !*TypeMatchesDeclOrNone);
5423 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5425 TypedefTypes.InsertNode(Placeholder, InsertPos);
5426 Types.push_back(NewType);
5435 if (UnderlyingType.
isNull()) {
5443 llvm::FoldingSetNodeID ID;
5446 void *InsertPos =
nullptr;
5447 if (
const UsingType *
T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5457 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5461 UsingTypes.InsertNode(
T, InsertPos);
5467 const TagDecl *TD,
bool OwnsTag,
5469 const Type *CanonicalType,
5470 bool WithFoldingSetNode)
const {
5471 auto [TC, Size] = [&] {
5474 static_assert(
alignof(EnumType) ==
alignof(TagType));
5475 return std::make_tuple(Type::Enum,
sizeof(EnumType));
5476 case Decl::ClassTemplatePartialSpecialization:
5477 case Decl::ClassTemplateSpecialization:
5478 case Decl::CXXRecord:
5479 static_assert(
alignof(RecordType) ==
alignof(TagType));
5480 static_assert(
alignof(InjectedClassNameType) ==
alignof(TagType));
5482 return std::make_tuple(Type::InjectedClassName,
5483 sizeof(InjectedClassNameType));
5486 return std::make_tuple(Type::Record,
sizeof(RecordType));
5488 llvm_unreachable(
"unexpected decl kind");
5498 if (WithFoldingSetNode) {
5506 sizeof(TagTypeFoldingSetPlaceholder) +
5507 TagTypeFoldingSetPlaceholder::getOffset() + Size,
5508 std::max(
alignof(TagTypeFoldingSetPlaceholder),
alignof(TagType)));
5509 auto *
T =
new (Mem) TagTypeFoldingSetPlaceholder();
5510 Mem =
T->getTagType();
5512 Mem =
Allocate(Size,
alignof(TagType));
5515 auto *
T = [&, TC = TC]() -> TagType * {
5519 auto *
T =
new (Mem) EnumType(TC,
Keyword, Qualifier, TD, OwnsTag,
5520 IsInjected, CanonicalType);
5521 assert(
reinterpret_cast<void *
>(
T) ==
5522 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5523 "TagType must be the first base of EnumType");
5526 case Type::Record: {
5528 auto *
T =
new (Mem) RecordType(TC,
Keyword, Qualifier, TD, OwnsTag,
5529 IsInjected, CanonicalType);
5530 assert(
reinterpret_cast<void *
>(
T) ==
5531 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5532 "TagType must be the first base of RecordType");
5535 case Type::InjectedClassName: {
5536 auto *
T =
new (Mem) InjectedClassNameType(
Keyword, Qualifier, TD,
5537 IsInjected, CanonicalType);
5538 assert(
reinterpret_cast<void *
>(
T) ==
5539 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5540 "TagType must be the first base of InjectedClassNameType");
5544 llvm_unreachable(
"unexpected type class");
5547 assert(
T->getKeyword() ==
Keyword);
5548 assert(
T->getQualifier() == Qualifier);
5549 assert(
T->getDecl() == TD);
5550 assert(
T->isInjected() == IsInjected);
5551 assert(
T->isTagOwned() == OwnsTag);
5560 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5561 RD && RD->isInjectedClassName())
5568 if (TD->TypeForDecl)
5569 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5571 const Type *CanonicalType = getTagTypeInternal(
5574 false,
false,
nullptr,
5576 TD->TypeForDecl = CanonicalType;
5582 const TagDecl *TD,
bool OwnsTag)
const {
5585 bool IsInjected = TD != NonInjectedTD;
5592 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5593 if (
const Type *
T = TD->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5599 std::nullopt, NonInjectedTD,
5600 false, IsInjected, CanonicalType,
5602 TD->TypeForDecl =
T;
5606 llvm::FoldingSetNodeID ID;
5607 TagTypeFoldingSetPlaceholder::Profile(ID,
Keyword, Qualifier, NonInjectedTD,
5608 OwnsTag, IsInjected);
5610 void *InsertPos =
nullptr;
5611 if (TagTypeFoldingSetPlaceholder *
T =
5612 TagTypes.FindNodeOrInsertPos(ID, InsertPos))
5617 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5618 CanonicalType,
true);
5619 TagTypes.InsertNode(TagTypeFoldingSetPlaceholder::fromTagType(
T), InsertPos);
5624 unsigned NumPositiveBits,
5627 unsigned IntWidth = Target->getIntWidth();
5628 unsigned CharWidth = Target->getCharWidth();
5629 unsigned ShortWidth = Target->getShortWidth();
5630 bool EnumTooLarge =
false;
5632 if (NumNegativeBits) {
5636 if (IsPacked && NumNegativeBits <= CharWidth &&
5637 NumPositiveBits < CharWidth) {
5639 BestWidth = CharWidth;
5640 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5641 NumPositiveBits < ShortWidth) {
5643 BestWidth = ShortWidth;
5644 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5646 BestWidth = IntWidth;
5648 BestWidth = Target->getLongWidth();
5650 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5653 BestWidth = Target->getLongLongWidth();
5655 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5656 EnumTooLarge =
true;
5660 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5665 if (IsPacked && NumPositiveBits <= CharWidth) {
5667 BestPromotionType =
IntTy;
5668 BestWidth = CharWidth;
5669 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5671 BestPromotionType =
IntTy;
5672 BestWidth = ShortWidth;
5673 }
else if (NumPositiveBits <= IntWidth) {
5675 BestWidth = IntWidth;
5676 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5679 }
else if (NumPositiveBits <= (BestWidth = Target->getLongWidth())) {
5681 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5685 BestWidth = Target->getLongLongWidth();
5686 if (NumPositiveBits > BestWidth) {
5691 EnumTooLarge =
true;
5694 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5699 return EnumTooLarge;
5703 assert((
T->isIntegralType(*
this) ||
T->isEnumeralType()) &&
5704 "Integral type required!");
5707 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5708 if (
T->isSignedIntegerOrEnumerationType())
5710 return Value.getActiveBits() <= BitWidth;
5712 return Value.getSignificantBits() <= BitWidth;
5718 const Type *CanonicalType)
const {
5720 UnresolvedUsingType::totalSizeToAlloc<
5722 !!InsertPos, !!Qualifier),
5726 auto *Placeholder =
new (
T->getFoldingSetPlaceholder())
5728 TypedefTypes.InsertNode(Placeholder, InsertPos);
5738 return D->TypeForDecl->getCanonicalTypeUnqualified();
5740 const Type *CanonicalType = getUnresolvedUsingTypeInternal(
5744 D->TypeForDecl = CanonicalType;
5753 if (
const Type *
T = D->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5760 nullptr, CanonicalType);
5765 llvm::FoldingSetNodeID ID;
5768 void *InsertPos =
nullptr;
5770 UnresolvedUsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5771 return QualType(Placeholder->getType(), 0);
5775 const Type *
T = getUnresolvedUsingTypeInternal(
Keyword, Qualifier, D,
5776 InsertPos, CanonicalType);
5784 llvm::FoldingSetNodeID id;
5785 AttributedType::Profile(
id, *
this, attrKind, modifiedType, equivalentType,
5788 void *insertPos =
nullptr;
5789 AttributedType *
type = AttributedTypes.FindNodeOrInsertPos(
id, insertPos);
5792 assert(!
attr ||
attr->getKind() == attrKind);
5795 type =
new (*
this,
alignof(AttributedType))
5796 AttributedType(canon, attrKind,
attr, modifiedType, equivalentType);
5798 Types.push_back(
type);
5799 AttributedTypes.InsertNode(
type, insertPos);
5812 switch (nullability) {
5828 llvm_unreachable(
"Unknown nullability kind");
5833 llvm::FoldingSetNodeID ID;
5834 BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
5836 void *InsertPos =
nullptr;
5837 BTFTagAttributedType *Ty =
5838 BTFTagAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
5843 Ty =
new (*
this,
alignof(BTFTagAttributedType))
5844 BTFTagAttributedType(Canon, Wrapped, BTFAttr);
5846 Types.push_back(Ty);
5847 BTFTagAttributedTypes.InsertNode(Ty, InsertPos);
5855 StringRef IdentName = II->
getName();
5856 OverflowBehaviorType::OverflowBehaviorKind Kind;
5857 if (IdentName ==
"wrap") {
5858 Kind = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
5859 }
else if (IdentName ==
"trap") {
5860 Kind = OverflowBehaviorType::OverflowBehaviorKind::Trap;
5869 OverflowBehaviorType::OverflowBehaviorKind Kind,
5872 "Cannot have underlying types that are themselves OBTs");
5873 llvm::FoldingSetNodeID ID;
5874 OverflowBehaviorType::Profile(ID, Underlying, Kind);
5875 void *InsertPos =
nullptr;
5877 if (OverflowBehaviorType *OBT =
5878 OverflowBehaviorTypes.FindNodeOrInsertPos(ID, InsertPos)) {
5887 assert(!OverflowBehaviorTypes.FindNodeOrInsertPos(ID, InsertPos) &&
5888 "Shouldn't be in the map");
5891 OverflowBehaviorType *Ty =
new (*
this,
alignof(OverflowBehaviorType))
5892 OverflowBehaviorType(Canonical, Underlying, Kind);
5894 Types.push_back(Ty);
5895 OverflowBehaviorTypes.InsertNode(Ty, InsertPos);
5901 const HLSLAttributedResourceType::Attributes &Attrs) {
5903 llvm::FoldingSetNodeID ID;
5904 HLSLAttributedResourceType::Profile(ID, Wrapped, Contained, Attrs);
5906 void *InsertPos =
nullptr;
5907 HLSLAttributedResourceType *Ty =
5908 HLSLAttributedResourceTypes.FindNodeOrInsertPos(ID, InsertPos);
5912 Ty =
new (*
this,
alignof(HLSLAttributedResourceType))
5913 HLSLAttributedResourceType(Wrapped, Contained, Attrs);
5915 Types.push_back(Ty);
5916 HLSLAttributedResourceTypes.InsertNode(Ty, InsertPos);
5924 llvm::FoldingSetNodeID ID;
5925 HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
5927 void *InsertPos =
nullptr;
5928 HLSLInlineSpirvType *Ty =
5929 HLSLInlineSpirvTypes.FindNodeOrInsertPos(ID, InsertPos);
5934 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5935 alignof(HLSLInlineSpirvType));
5937 Ty =
new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
5939 Types.push_back(Ty);
5940 HLSLInlineSpirvTypes.InsertNode(Ty, InsertPos);
5947 Decl *AssociatedDecl,
5951 llvm::FoldingSetNodeID ID;
5952 SubstTemplateTypeParmType::Profile(ID, Replacement, AssociatedDecl, Index,
5954 void *InsertPos =
nullptr;
5955 SubstTemplateTypeParmType *SubstParm =
5956 SubstTemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5959 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5960 !Replacement.isCanonical()),
5961 alignof(SubstTemplateTypeParmType));
5962 SubstParm =
new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
5964 Types.push_back(SubstParm);
5965 SubstTemplateTypeParmTypes.InsertNode(SubstParm, InsertPos);
5973 unsigned Index,
bool Final,
5980 llvm::FoldingSetNodeID ID;
5981 SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
5983 void *InsertPos =
nullptr;
5984 if (SubstTemplateTypeParmPackType *SubstParm =
5985 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos))
5995 [[maybe_unused]]
const auto *Nothing =
5996 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos);
6001 auto *SubstParm =
new (*
this,
alignof(SubstTemplateTypeParmPackType))
6002 SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
6004 Types.push_back(SubstParm);
6005 SubstTemplateTypeParmPackTypes.InsertNode(SubstParm, InsertPos);
6013 return P.getKind() == TemplateArgument::Type;
6015 "Pack contains a non-type");
6017 llvm::FoldingSetNodeID ID;
6018 SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
6020 void *InsertPos =
nullptr;
6022 SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos))
6031 [[maybe_unused]]
const auto *Nothing =
6032 SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos);
6036 auto *PackType =
new (*
this,
alignof(SubstBuiltinTemplatePackType))
6037 SubstBuiltinTemplatePackType(Canon, ArgPack);
6038 Types.push_back(PackType);
6039 SubstBuiltinTemplatePackTypes.InsertNode(PackType, InsertPos);
6049 assert(Depth >= 0 &&
"Depth must be non-negative");
6050 assert(Index >= 0 &&
"Index must be non-negative");
6052 llvm::FoldingSetNodeID ID;
6053 TemplateTypeParmType::Profile(ID, Depth, Index, ParameterPack, TTPDecl);
6054 void *InsertPos =
nullptr;
6055 TemplateTypeParmType *TypeParm
6056 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
6063 TypeParm =
new (*
this,
alignof(TemplateTypeParmType))
6064 TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
6066 TemplateTypeParmType *TypeCheck
6067 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
6068 assert(!TypeCheck &&
"Template type parameter canonical type broken");
6071 TypeParm =
new (*
this,
alignof(TemplateTypeParmType)) TemplateTypeParmType(
6072 Depth, Index, ParameterPack,
nullptr,
QualType());
6074 Types.push_back(TypeParm);
6075 TemplateTypeParmTypes.InsertNode(TypeParm, InsertPos);
6101 llvm_unreachable(
"unexpected keyword kind");
6115 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
6125 SpecifiedArgVec.reserve(SpecifiedArgs.size());
6127 SpecifiedArgVec.push_back(Arg.getArgument());
6130 CanonicalArgs, Underlying);
6133[[maybe_unused]]
static bool
6136 if (Arg.isPackExpansion())
6147 Template.getAsDependentTemplateName()));
6149 for (
const auto &Arg : Args)
6153 llvm::FoldingSetNodeID ID;
6156 void *InsertPos =
nullptr;
6157 if (
auto *
T = TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
6160 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6162 alignof(TemplateSpecializationType));
6166 assert(Spec->isDependentType() &&
6167 "canonical template specialization must be dependent");
6168 Types.push_back(Spec);
6169 TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
6177 const auto *TD =
Template.getAsTemplateDecl(
true);
6178 bool IsTypeAlias = TD && TD->isTypeAlias();
6179 if (Underlying.
isNull()) {
6186 bool NonCanonical =
Template != CanonTemplate ||
Keyword != CanonKeyword;
6188 if (CanonicalArgs.empty()) {
6191 CanonicalArgs = CanonArgsVec;
6193 NonCanonical |= !llvm::equal(
6194 SpecifiedArgs, CanonicalArgs,
6203 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
6205 "Caller must compute aliased type");
6206 IsTypeAlias =
false;
6209 CanonKeyword, CanonTemplate, CanonicalArgs);
6213 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
6215 (IsTypeAlias ?
sizeof(
QualType) : 0),
6216 alignof(TemplateSpecializationType));
6217 auto *Spec =
new (Mem) TemplateSpecializationType(
6219 Types.push_back(Spec);
6225 llvm::FoldingSetNodeID ID;
6228 void *InsertPos =
nullptr;
6229 ParenType *
T = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6236 ParenType *CheckT = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6237 assert(!CheckT &&
"Paren canonical type broken");
6243 ParenTypes.InsertNode(
T, InsertPos);
6256 Types.push_back(newType);
6263 llvm::FoldingSetNodeID ID;
6264 DependentNameType::Profile(ID,
Keyword, NNS, Name);
6266 void *InsertPos =
nullptr;
6267 if (DependentNameType *
T =
6268 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos))
6276 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6278 [[maybe_unused]] DependentNameType *
T =
6279 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos);
6280 assert(!
T &&
"broken canonicalization");
6284 DependentNameType *
T =
new (*
this,
alignof(DependentNameType))
6285 DependentNameType(
Keyword, NNS, Name, Canon);
6287 DependentNameTypes.InsertNode(
T, InsertPos);
6293 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6295 if (TTP->isParameterPack())
6299 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6301 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6307 if (
T->isRecordType()) {
6316 Expr *E =
new (*this)
6318 T,
VK, NTTP->getLocation());
6320 if (NTTP->isParameterPack())
6326 std::nullopt,
false,
6328 if (TTP->isParameterPack())
6334 if (Param->isTemplateParameterPack())
6343 bool ExpectPackInType)
const {
6345 "Pack expansions must expand one or more parameter packs");
6347 llvm::FoldingSetNodeID ID;
6348 PackExpansionType::Profile(ID, Pattern, NumExpansions);
6350 void *InsertPos =
nullptr;
6351 PackExpansionType *
T = PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
6362 PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
6365 T =
new (*
this,
alignof(PackExpansionType))
6366 PackExpansionType(Pattern, Canon, NumExpansions);
6368 PackExpansionTypes.InsertNode(
T, InsertPos);
6380 if (Protocols.empty())
return true;
6385 for (
unsigned i = 1; i != Protocols.size(); ++i)
6395 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6399 P = P->getCanonicalDecl();
6402 auto ProtocolsEnd = llvm::unique(Protocols);
6403 Protocols.erase(ProtocolsEnd, Protocols.end());
6408 unsigned NumProtocols)
const {
6417 bool isKindOf)
const {
6420 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6425 llvm::FoldingSetNodeID ID;
6426 ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
6427 void *InsertPos =
nullptr;
6428 if (
ObjCObjectType *QT = ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos))
6435 if (effectiveTypeArgs.empty()) {
6437 effectiveTypeArgs = baseObject->getTypeArgs();
6444 bool typeArgsAreCanonical = llvm::all_of(
6447 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6451 if (!typeArgsAreCanonical) {
6452 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6453 for (
auto typeArg : effectiveTypeArgs)
6455 canonTypeArgs = canonTypeArgsVec;
6457 canonTypeArgs = effectiveTypeArgs;
6462 if (!protocolsSorted) {
6463 canonProtocolsVec.append(protocols.begin(), protocols.end());
6465 canonProtocols = canonProtocolsVec;
6467 canonProtocols = protocols;
6471 canonProtocols, isKindOf);
6474 ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos);
6477 unsigned size =
sizeof(ObjCObjectTypeImpl);
6478 size += typeArgs.size() *
sizeof(
QualType);
6480 void *mem =
Allocate(size,
alignof(ObjCObjectTypeImpl));
6482 new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
6486 ObjCObjectTypes.InsertNode(
T, InsertPos);
6496 bool allowOnPointerType)
const {
6499 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6504 if (allowOnPointerType) {
6505 if (
const auto *objPtr =
6506 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6510 protocolsVec.append(objT->qual_begin(),
6512 protocolsVec.append(protocols.begin(), protocols.end());
6515 objT->getBaseType(),
6516 objT->getTypeArgsAsWritten(),
6518 objT->isKindOfTypeAsWritten());
6524 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6529 objT->getTypeArgsAsWritten(),
6531 objT->isKindOfTypeAsWritten());
6535 if (
type->isObjCObjectType()) {
6545 if (
type->isObjCIdType()) {
6548 objPtr->isKindOfType());
6553 if (
type->isObjCClassType()) {
6556 objPtr->isKindOfType());
6568 llvm::FoldingSetNodeID ID;
6569 ObjCTypeParamType::Profile(ID,
Decl,
Decl->getUnderlyingType(), protocols);
6570 void *InsertPos =
nullptr;
6571 if (ObjCTypeParamType *TypeParam =
6572 ObjCTypeParamTypes.FindNodeOrInsertPos(ID, InsertPos))
6577 if (!protocols.empty()) {
6581 Canonical, protocols, hasError,
true ));
6582 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6585 unsigned size =
sizeof(ObjCTypeParamType);
6587 void *mem =
Allocate(size,
alignof(ObjCTypeParamType));
6588 auto *newType =
new (mem) ObjCTypeParamType(
Decl, Canonical, protocols);
6590 Types.push_back(newType);
6591 ObjCTypeParamTypes.InsertNode(newType, InsertPos);
6601 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6616 for (
auto *Proto : OPT->quals()) {
6639 if (InheritedProtocols.empty())
6643 bool Conforms =
false;
6644 for (
auto *Proto : OPT->quals()) {
6646 for (
auto *PI : InheritedProtocols) {
6658 for (
auto *PI : InheritedProtocols) {
6660 bool Adopts =
false;
6661 for (
auto *Proto : OPT->quals()) {
6675 llvm::FoldingSetNodeID ID;
6678 void *InsertPos =
nullptr;
6680 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
6689 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
6698 Types.push_back(QType);
6699 ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
6707 if (
Decl->TypeForDecl)
6711 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6712 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6713 return QualType(PrevDecl->TypeForDecl, 0);
6722 Decl->TypeForDecl =
T;
6735 llvm::FoldingSetNodeID ID;
6739 void *InsertPos =
nullptr;
6741 DependentTypeOfExprTypes.FindNodeOrInsertPos(ID, InsertPos);
6751 DependentTypeOfExprTypes.InsertNode(Canon, InsertPos);
6759 Types.push_back(toe);
6770 auto *tot =
new (*
this,
alignof(TypeOfType))
6771 TypeOfType(*
this, tofType, Canonical, Kind);
6772 Types.push_back(tot);
6796 llvm_unreachable(
"Unknown value kind");
6811 }
else if (!UnderlyingType.
isNull()) {
6814 llvm::FoldingSetNodeID ID;
6815 DependentDecltypeType::Profile(ID, *
this, E);
6817 void *InsertPos =
nullptr;
6818 if (DependentDecltypeType *Canon =
6819 DependentDecltypeTypes.FindNodeOrInsertPos(ID, InsertPos))
6824 new (*
this,
alignof(DependentDecltypeType)) DependentDecltypeType(E);
6825 DependentDecltypeTypes.InsertNode(DT, InsertPos);
6826 Types.push_back(DT);
6829 auto *DT =
new (*
this,
alignof(DecltypeType))
6830 DecltypeType(E, UnderlyingType, CanonType);
6831 Types.push_back(DT);
6836 bool FullySubstituted,
6840 if (FullySubstituted && Index) {
6843 llvm::FoldingSetNodeID ID;
6844 PackIndexingType::Profile(ID, *
this, Pattern.
getCanonicalType(), IndexExpr,
6845 FullySubstituted, Expansions);
6846 void *InsertPos =
nullptr;
6847 PackIndexingType *Canon =
6848 DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos);
6851 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6855 IndexExpr, FullySubstituted, Expansions);
6856 DependentPackIndexingTypes.InsertNode(Canon, InsertPos);
6862 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6864 auto *
T =
new (Mem) PackIndexingType(Canonical, Pattern, IndexExpr,
6865 FullySubstituted, Expansions);
6874 UnaryTransformType::UTTKind Kind)
const {
6876 llvm::FoldingSetNodeID ID;
6877 UnaryTransformType::Profile(ID, BaseType, UnderlyingType, Kind);
6879 void *InsertPos =
nullptr;
6880 if (UnaryTransformType *UT =
6881 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos))
6885 if (!BaseType->isDependentType()) {
6888 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6891 BaseType != CanonBase) {
6896 [[maybe_unused]] UnaryTransformType *UT =
6897 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos);
6898 assert(!UT &&
"broken canonicalization");
6902 auto *UT =
new (*
this,
alignof(UnaryTransformType))
6903 UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
6904 UnaryTransformTypes.InsertNode(UT, InsertPos);
6905 Types.push_back(UT);
6918 !TypeConstraintConcept) {
6919 assert(DeducedAsType.
isNull() &&
"");
6920 assert(TypeConstraintArgs.empty() &&
"");
6925 llvm::FoldingSetNodeID ID;
6926 AutoType::Profile(ID, *
this, DK, DeducedAsType,
Keyword,
6927 TypeConstraintConcept, TypeConstraintArgs);
6928 if (
auto const AT_iter = AutoTypes.find(ID); AT_iter != AutoTypes.end())
6929 return QualType(AT_iter->getSecond(), 0);
6932 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
6934 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
6935 if (TypeConstraintConcept) {
6936 bool AnyNonCanonArgs =
false;
6937 auto *CanonicalConcept =
6940 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6941 if (TypeConstraintConcept != CanonicalConcept || AnyNonCanonArgs)
6943 CanonicalConceptArgs);
6947 void *Mem =
Allocate(
sizeof(AutoType) +
6950 auto *AT =
new (Mem) AutoType(DK, DeducedAsType,
Keyword,
6951 TypeConstraintConcept, TypeConstraintArgs);
6953 llvm::FoldingSetNodeID InsertedID;
6954 AT->Profile(InsertedID, *
this);
6955 assert(InsertedID == ID &&
"ID does not match");
6957 Types.push_back(AT);
6958 AutoTypes.try_emplace(ID, AT);
6963 QualType CanonT =
T.getNonPackExpansionType().getCanonicalType();
6966 if (
auto *AT = CanonT->
getAs<AutoType>()) {
6967 if (!AT->isConstrained())
6989 void *InsertPos =
nullptr;
6990 llvm::FoldingSetNodeID ID;
6991 DeducedTemplateSpecializationType::Profile(ID, DK, DeducedAsType,
Keyword,
6993 if (DeducedTemplateSpecializationType *DTST =
6994 DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
6998 assert(!DeducedAsType.
isNull() &&
"deduced type must be provided");
7000 assert(DeducedAsType.
isNull() &&
"deduced type must not be provided");
7009 [[maybe_unused]] DeducedTemplateSpecializationType *DTST =
7010 DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos);
7011 assert(!DTST &&
"broken canonicalization");
7015 auto *DTST =
new (*
this,
alignof(DeducedTemplateSpecializationType))
7016 DeducedTemplateSpecializationType(DK, DeducedAsType,
Keyword,
Template);
7019 llvm::FoldingSetNodeID TempID;
7020 DTST->Profile(TempID);
7021 assert(ID == TempID &&
"ID does not match");
7023 Types.push_back(DTST);
7024 DeducedTemplateSpecializationTypes.InsertNode(DTST, InsertPos);
7033 llvm::FoldingSetNodeID ID;
7036 void *InsertPos =
nullptr;
7037 if (
AtomicType *AT = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos))
7043 if (!
T.isCanonical()) {
7047 AtomicType *NewIP = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos);
7048 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
7051 Types.push_back(
New);
7052 AtomicTypes.InsertNode(
New, InsertPos);
7084 return getFromTargetType(Target->getSizeType());
7103 return getFromTargetType(Target->getUnsignedPtrDiffType(
LangAS::Default));
7108 return getFromTargetType(Target->getIntMaxType());
7113 return getFromTargetType(Target->getUIntMaxType());
7131 return getFromTargetType(Target->getIntPtrType());
7141 return getFromTargetType(Target->getProcessIDType());
7153 const Type *Ty =
T.getTypePtr();
7181 quals = splitType.
Quals;
7186 QualType elementType = AT->getElementType();
7191 if (elementType == unqualElementType) {
7192 assert(quals.
empty());
7193 quals = splitType.
Quals;
7201 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7203 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7206 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7210 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7212 VAT->getSizeModifier(),
7213 VAT->getIndexTypeCVRQualifiers());
7218 DSAT->getSizeModifier(), 0);
7228 bool AllowPiMismatch)
const {
7243 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7244 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7245 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7258 T1 = AT1->getElementType();
7259 T2 = AT2->getElementType();
7279 bool AllowPiMismatch)
const {
7284 if (T1PtrType && T2PtrType) {
7292 T1MPType && T2MPType) {
7295 if (T1MPType->getQualifier() != T2MPType->getQualifier())
7307 if (T1OPType && T2OPType) {
7339 if (Quals1 != Quals2)
7409 llvm_unreachable(
"bad template name kind!");
7415 if (!TP->hasDefaultArgument())
7417 return &TP->getDefaultArgument().getArgument();
7420 case NamedDecl::TemplateTypeParm:
7422 case NamedDecl::NonTypeTemplateParm:
7424 case NamedDecl::TemplateTemplateParm:
7427 llvm_unreachable(
"Unexpected template parameter kind");
7432 bool IgnoreDeduced)
const {
7433 while (std::optional<TemplateName> UnderlyingOrNone =
7435 Name = *UnderlyingOrNone;
7440 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7452 llvm_unreachable(
"cannot canonicalize overloaded template");
7456 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7475 assert(IgnoreDeduced ==
false);
7482 bool NonCanonical = CanonUnderlying != Underlying;
7488 assert(CanonArgs.size() <= Params.size());
7494 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7503 if (I ==
int(CanonArgs.size() - 1))
7504 CanonArgs.pop_back();
7505 NonCanonical =
true;
7515 llvm_unreachable(
"always sugar node");
7518 llvm_unreachable(
"bad template name!");
7523 bool IgnoreDeduced)
const {
7544 llvm::FoldingSetNodeID XCEID, YCEID;
7545 XCE->
Profile(XCEID, *
this,
true,
true);
7546 YCE->
Profile(YCEID, *
this,
true,
true);
7547 return XCEID == YCEID;
7596 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7598 if (TX->isParameterPack() != TY->isParameterPack())
7600 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7603 TY->getTypeConstraint());
7606 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7608 return TX->isParameterPack() == TY->isParameterPack() &&
7609 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7611 TY->getPlaceholderTypeConstraint());
7616 return TX->isParameterPack() == TY->isParameterPack() &&
7618 TY->getTemplateParameters());
7623 if (
X->size() != Y->
size())
7626 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7640 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7642 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7645 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7646 TTPY->getDefaultArgument().getArgument().getAsType());
7649 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7651 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7654 Expr *DefaultArgumentX =
7655 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7656 Expr *DefaultArgumentY =
7657 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7658 llvm::FoldingSetNodeID XID, YID;
7659 DefaultArgumentX->
Profile(XID, *
this,
true);
7660 DefaultArgumentY->
Profile(YID, *
this,
true);
7667 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7682 auto Kind =
X.getKind();
7690 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7693 NamespaceY->getNamespace()))
7698 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7699 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7708 llvm_unreachable(
"unhandled qualifier kind");
7714 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7716 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7728 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7732 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7733 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7734 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7737 if (!Cand1A || !Cand2A)
7743 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7744 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7748 if (Cand1ID != Cand2ID)
7782 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7783 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7785 TypedefY->getUnderlyingType());
7802 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7804 return (TagX->getTagKind() == TagY->getTagKind()) ||
7816 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7818 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7820 if (CtorX->getInheritedConstructor() &&
7821 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7822 CtorY->getInheritedConstructor().getConstructor()))
7826 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7831 if (FuncX->isMultiVersion()) {
7832 const auto *TAX = FuncX->getAttr<TargetAttr>();
7833 const auto *TAY = FuncY->getAttr<TargetAttr>();
7834 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7836 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7842 if ((FuncX->isMemberLikeConstrainedFriend() ||
7843 FuncY->isMemberLikeConstrainedFriend()) &&
7844 !FuncX->getLexicalDeclContext()->Equals(
7845 FuncY->getLexicalDeclContext())) {
7850 FuncY->getTrailingRequiresClause()))
7858 FD = FD->getCanonicalDecl();
7859 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7862 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7877 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7882 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7884 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7887 if (VarX->getType().isNull() || VarY->getType().isNull())
7890 if (
hasSameType(VarX->getType(), VarY->getType()))
7900 if (!VarXTy || !VarYTy)
7909 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7911 return NamespaceX->isInline() == NamespaceY->isInline();
7916 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7920 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7923 ConceptY->getConstraintExpr()))
7928 TemplateY->getTemplatedDecl()) &&
7930 TemplateY->getTemplateParameters());
7934 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7937 return hasSameType(FDX->getType(), FDY->getType());
7941 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7943 return IFDX->getAnonField()->getCanonicalDecl() ==
7944 IFDY->getAnonField()->getCanonicalDecl();
7953 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7960 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7963 UX->hasTypename() == UY->hasTypename() &&
7964 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7966 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7969 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7971 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7979 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
7981 UX->getInstantiatedFromUsingDecl(),
7986 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
7988 return NAX->getNamespace()->Equals(NAY->getNamespace());
7991 if (
const auto *UX = dyn_cast<UsingEnumDecl>(
X)) {
8042 bool AnyNonCanonArgs =
false;
8045 if (!AnyNonCanonArgs)
8055 llvm_unreachable(
"Unhandled template argument kind");
8065 llvm_unreachable(
"Comparing NULL template argument");
8090 llvm::FoldingSetNodeID ID1, ID2;
8100 return isSameTemplateArgument(Arg1, Arg2);
8104 llvm_unreachable(
"Unhandled template argument kind");
8109 if (!
T.hasLocalQualifiers()) {
8111 if (
const auto *AT = dyn_cast<ArrayType>(
T))
8131 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
8132 if (!ATy || qs.
empty())
8139 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
8142 CAT->getSizeModifier(),
8143 CAT->getIndexTypeCVRQualifiers()));
8144 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
8146 IAT->getSizeModifier(),
8147 IAT->getIndexTypeCVRQualifiers()));
8149 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
8151 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
8152 DSAT->getIndexTypeCVRQualifiers()));
8157 VAT->getIndexTypeCVRQualifiers()));
8165 if (
T->isArrayType() ||
T->isFunctionType())
8173 return T.getUnqualifiedType();
8184 if (
T->isArrayType() ||
T->isFunctionType())
8186 return T.getUnqualifiedType();
8201 assert(PrettyArrayType &&
"Not an array type!");
8237 uint64_t ElementCount = 1;
8240 CA = dyn_cast_or_null<ConstantArrayType>(
8243 return ElementCount;
8251 uint64_t ElementCount = 1;
8255 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8258 return ElementCount;
8268 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8270 case BuiltinType::Half:
return HalfRank;
8271 case BuiltinType::Float:
return FloatRank;
8304unsigned ASTContext::getIntegerRank(
const Type *
T)
const {
8305 assert(
T->isCanonicalUnqualified() &&
"T should be canonicalized");
8309 if (
const auto *EIT = dyn_cast<BitIntType>(
T))
8310 return 0 + (EIT->getNumBits() << 3);
8312 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(
T))
8313 return getIntegerRank(OBT->getUnderlyingType().getTypePtr());
8316 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8317 case BuiltinType::Bool:
8319 case BuiltinType::Char_S:
8320 case BuiltinType::Char_U:
8321 case BuiltinType::SChar:
8322 case BuiltinType::UChar:
8324 case BuiltinType::Short:
8325 case BuiltinType::UShort:
8327 case BuiltinType::Int:
8328 case BuiltinType::UInt:
8330 case BuiltinType::Long:
8331 case BuiltinType::ULong:
8333 case BuiltinType::LongLong:
8334 case BuiltinType::ULongLong:
8336 case BuiltinType::Int128:
8337 case BuiltinType::UInt128:
8342 case BuiltinType::Char8:
8344 case BuiltinType::Char16:
8345 return getIntegerRank(
8347 case BuiltinType::Char32:
8348 return getIntegerRank(
8350 case BuiltinType::WChar_S:
8351 case BuiltinType::WChar_U:
8352 return getIntegerRank(
8382 uint64_t BitWidth = Field->getBitWidthValue();
8408 if (BitWidth < IntSize)
8411 if (BitWidth == IntSize)
8426 assert(!Promotable.
isNull());
8429 return ED->getPromotionType();
8433 if (
const auto *OBT = Promotable->
getAs<OverflowBehaviorType>()) {
8446 if (BT->getKind() == BuiltinType::WChar_S ||
8447 BT->getKind() == BuiltinType::WChar_U ||
8448 BT->getKind() == BuiltinType::Char8 ||
8449 BT->getKind() == BuiltinType::Char16 ||
8450 BT->getKind() == BuiltinType::Char32) {
8451 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8455 for (
const auto &PT : PromoteTypes) {
8457 if (FromSize < ToSize ||
8458 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8461 llvm_unreachable(
"char type should fit into long long");
8468 uint64_t PromotableSize =
getIntWidth(Promotable);
8477 while (!
T.isNull()) {
8479 return T.getObjCLifetime();
8480 if (
T->isArrayType())
8483 T = PT->getPointeeType();
8485 T = RT->getPointeeType();
8510 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8512 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8515 if (LHSC == RHSC)
return 0;
8520 unsigned LHSRank = getIntegerRank(LHSC);
8521 unsigned RHSRank = getIntegerRank(RHSC);
8523 if (LHSUnsigned == RHSUnsigned) {
8524 if (LHSRank == RHSRank)
return 0;
8525 return LHSRank > RHSRank ? 1 : -1;
8531 if (LHSRank >= RHSRank)
8541 if (RHSRank >= LHSRank)
8551 if (CFConstantStringTypeDecl)
8552 return CFConstantStringTypeDecl;
8554 assert(!CFConstantStringTagDecl &&
8555 "tag and typedef should be initialized together");
8557 CFConstantStringTagDecl->startDefinition();
8595 if (
static_cast<unsigned>(CFRuntime) <
8598 Fields[Count++] = {
IntTy,
"flags" };
8600 Fields[Count++] = {
LongTy,
"length" };
8604 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()),
"_swift_rc" };
8608 Fields[Count++] = {
IntTy,
"_ptr" };
8614 for (
unsigned i = 0; i < Count; ++i) {
8618 Fields[i].Type,
nullptr,
8621 CFConstantStringTagDecl->addDecl(Field);
8624 CFConstantStringTagDecl->completeDefinition();
8628 CFConstantStringTypeDecl =
8631 return CFConstantStringTypeDecl;
8635 if (!CFConstantStringTagDecl)
8637 return CFConstantStringTagDecl;
8647 if (ObjCSuperType.isNull()) {
8652 return ObjCSuperType;
8658 CFConstantStringTagDecl = TT->castAsRecordDecl();
8662 if (BlockDescriptorType)
8675 static const char *
const FieldNames[] = {
8680 for (
size_t i = 0; i < 2; ++i) {
8683 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8691 BlockDescriptorType = RD;
8697 if (BlockDescriptorExtendedType)
8712 static const char *
const FieldNames[] = {
8719 for (
size_t i = 0; i < 4; ++i) {
8722 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8731 BlockDescriptorExtendedType = RD;
8736 const auto *BT = dyn_cast<BuiltinType>(
T);
8745 switch (BT->getKind()) {
8746#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8747 case BuiltinType::Id: \
8749#include "clang/Basic/OpenCLImageTypes.def"
8751 case BuiltinType::OCLClkEvent:
8754 case BuiltinType::OCLEvent:
8757 case BuiltinType::OCLQueue:
8760 case BuiltinType::OCLReserveID:
8763 case BuiltinType::OCLSampler:
8782 if (!copyExpr && record->hasTrivialDestructor())
return false;
8813 llvm_unreachable(
"impossible");
8815 llvm_unreachable(
"fell out of lifetime switch!");
8823 bool &HasByrefExtendedLayout)
const {
8828 HasByrefExtendedLayout =
false;
8830 HasByrefExtendedLayout =
true;
8844 assert(Target &&
"Expected target to be initialized");
8845 const llvm::Triple &
T = Target->getTriple();
8847 if (
T.isOSWindows() &&
T.isArch64Bit())
8853 assert(Target &&
"Expected target to be initialized");
8854 const llvm::Triple &
T = Target->getTriple();
8856 if (
T.isOSWindows() &&
T.isArch64Bit())
8862 if (!ObjCInstanceTypeDecl)
8863 ObjCInstanceTypeDecl =
8865 return ObjCInstanceTypeDecl;
8871 if (
const auto *TT = dyn_cast<TypedefType>(
T))
8873 return II->isStr(
"BOOL");
8881 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8890 else if (
type->isArrayType())
8909 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8916 !D->isInlineSpecified() && (D->isConstexpr() ||
First->isConstexpr()))
8947 for (
auto *PI :
Decl->parameters()) {
8952 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8961 ParmOffset = PtrSize;
8962 for (
auto *PVDecl :
Decl->parameters()) {
8963 QualType PType = PVDecl->getOriginalType();
8964 if (
const auto *AT =
8969 PType = PVDecl->getType();
8971 PType = PVDecl->getType();
8991 for (
auto *PI :
Decl->parameters()) {
8998 "getObjCEncodingForFunctionDecl - Incomplete param type");
9005 for (
auto *PVDecl :
Decl->parameters()) {
9006 QualType PType = PVDecl->getOriginalType();
9007 if (
const auto *AT =
9012 PType = PVDecl->getType();
9014 PType = PVDecl->getType();
9028 bool Extended)
const {
9032 ObjCEncOptions Options = ObjCEncOptions()
9033 .setExpandPointedToStructures()
9034 .setExpandStructures()
9035 .setIsOutermostType();
9037 Options.setEncodeBlockParameters().setEncodeClassNames();
9038 getObjCEncodingForTypeImpl(
T, S, Options,
nullptr);
9044 bool Extended)
const {
9049 Decl->getReturnType(), S, Extended);
9058 E =
Decl->sel_param_end(); PI != E; ++PI) {
9065 "getObjCEncodingForMethodDecl - Incomplete param type");
9073 ParmOffset = 2 * PtrSize;
9075 E =
Decl->sel_param_end(); PI != E; ++PI) {
9078 if (
const auto *AT =
9087 PType, S, Extended);
9098 const Decl *Container)
const {
9101 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
9102 for (
auto *PID : CID->property_impls())
9103 if (PID->getPropertyDecl() == PD)
9107 for (
auto *PID : OID->property_impls())
9108 if (PID->getPropertyDecl() == PD)
9142 const Decl *Container)
const {
9144 bool Dynamic =
false;
9152 SynthesizePID = PropertyImpDecl;
9156 std::string S =
"T";
9201 if (SynthesizePID) {
9218 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9221 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9234 getObjCEncodingForTypeImpl(
T, S,
9236 .setExpandPointedToStructures()
9237 .setExpandStructures()
9238 .setIsOutermostType(),
9239 Field, NotEncodedT);
9243 std::string& S)
const {
9247 getObjCEncodingForTypeImpl(
T, S,
9249 .setExpandPointedToStructures()
9250 .setExpandStructures()
9251 .setIsOutermostType()
9252 .setEncodingProperty(),
9260 case BuiltinType::Void:
return 'v';
9261 case BuiltinType::Bool:
return 'B';
9262 case BuiltinType::Char8:
9263 case BuiltinType::Char_U:
9264 case BuiltinType::UChar:
return 'C';
9265 case BuiltinType::Char16:
9266 case BuiltinType::UShort:
return 'S';
9267 case BuiltinType::Char32:
9268 case BuiltinType::UInt:
return 'I';
9269 case BuiltinType::ULong:
9270 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9271 case BuiltinType::UInt128:
return 'T';
9272 case BuiltinType::ULongLong:
return 'Q';
9273 case BuiltinType::Char_S:
9274 case BuiltinType::SChar:
return 'c';
9275 case BuiltinType::Short:
return 's';
9276 case BuiltinType::WChar_S:
9277 case BuiltinType::WChar_U:
9278 case BuiltinType::Int:
return 'i';
9279 case BuiltinType::Long:
9280 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9281 case BuiltinType::LongLong:
return 'q';
9282 case BuiltinType::Int128:
return 't';
9283 case BuiltinType::Float:
return 'f';
9284 case BuiltinType::Double:
return 'd';
9285 case BuiltinType::LongDouble:
return 'D';
9286 case BuiltinType::NullPtr:
return '*';
9288 case BuiltinType::BFloat16:
9289 case BuiltinType::Float16:
9290 case BuiltinType::Float128:
9291 case BuiltinType::Ibm128:
9292 case BuiltinType::Half:
9293 case BuiltinType::ShortAccum:
9294 case BuiltinType::Accum:
9295 case BuiltinType::LongAccum:
9296 case BuiltinType::UShortAccum:
9297 case BuiltinType::UAccum:
9298 case BuiltinType::ULongAccum:
9299 case BuiltinType::ShortFract:
9300 case BuiltinType::Fract:
9301 case BuiltinType::LongFract:
9302 case BuiltinType::UShortFract:
9303 case BuiltinType::UFract:
9304 case BuiltinType::ULongFract:
9305 case BuiltinType::SatShortAccum:
9306 case BuiltinType::SatAccum:
9307 case BuiltinType::SatLongAccum:
9308 case BuiltinType::SatUShortAccum:
9309 case BuiltinType::SatUAccum:
9310 case BuiltinType::SatULongAccum:
9311 case BuiltinType::SatShortFract:
9312 case BuiltinType::SatFract:
9313 case BuiltinType::SatLongFract:
9314 case BuiltinType::SatUShortFract:
9315 case BuiltinType::SatUFract:
9316 case BuiltinType::SatULongFract:
9320#define SVE_TYPE(Name, Id, SingletonId) \
9321 case BuiltinType::Id:
9322#include "clang/Basic/AArch64ACLETypes.def"
9323#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9324#include "clang/Basic/RISCVVTypes.def"
9325#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9326#include "clang/Basic/WebAssemblyReferenceTypes.def"
9327#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9328#include "clang/Basic/AMDGPUTypes.def"
9329#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9330#include "clang/Basic/SPIRVTypes.def"
9333 Diags.
Report(diag::err_unsupported_objc_primitive_encoding)
9338 case BuiltinType::ObjCId:
9339 case BuiltinType::ObjCClass:
9340 case BuiltinType::ObjCSel:
9341 llvm_unreachable(
"@encoding ObjC primitive type");
9344#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9345 case BuiltinType::Id:
9346#include "clang/Basic/OpenCLImageTypes.def"
9347#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9348 case BuiltinType::Id:
9349#include "clang/Basic/OpenCLExtensionTypes.def"
9350 case BuiltinType::OCLEvent:
9351 case BuiltinType::OCLClkEvent:
9352 case BuiltinType::OCLQueue:
9353 case BuiltinType::OCLReserveID:
9354 case BuiltinType::OCLSampler:
9355 case BuiltinType::Dependent:
9356#define PPC_VECTOR_TYPE(Name, Id, Size) \
9357 case BuiltinType::Id:
9358#include "clang/Basic/PPCTypes.def"
9359#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9360#include "clang/Basic/HLSLIntangibleTypes.def"
9361#define BUILTIN_TYPE(KIND, ID)
9362#define PLACEHOLDER_TYPE(KIND, ID) \
9363 case BuiltinType::KIND:
9364#include "clang/AST/BuiltinTypes.def"
9365 llvm_unreachable(
"invalid builtin type for @encode");
9367 llvm_unreachable(
"invalid BuiltinType::Kind value");
9374 if (!
Enum->isFixed())
9384 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9404 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9412 S += llvm::utostr(Offset);
9414 if (
const auto *ET =
T->getAsCanonical<EnumType>())
9427 bool VisitBasesAndFields) {
9428 T =
T->getBaseElementTypeUnsafe();
9432 PT->getPointeeType().getTypePtr(),
false);
9434 auto *CXXRD =
T->getAsCXXRecordDecl();
9442 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9445 for (
const auto &B : CXXRD->bases())
9450 for (
auto *FD : CXXRD->fields())
9459void ASTContext::getObjCEncodingForTypeImpl(QualType
T, std::string &S,
9460 const ObjCEncOptions Options,
9461 const FieldDecl *FD,
9462 QualType *NotEncodedT)
const {
9464 switch (CT->getTypeClass()) {
9469 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9477 getObjCEncodingForTypeImpl(
T->
castAs<ComplexType>()->getElementType(), S,
9484 getObjCEncodingForTypeImpl(
T->
castAs<AtomicType>()->getValueType(), S,
9491 case Type::LValueReference:
9492 case Type::RValueReference: {
9495 const auto *PT =
T->
castAs<PointerType>();
9496 if (PT->isObjCSelType()) {
9505 bool isReadOnly =
false;
9510 if (
T->
getAs<TypedefType>()) {
9511 if (Options.IsOutermostType() &&
T.isConstQualified()) {
9515 }
else if (Options.IsOutermostType()) {
9516 QualType P = PointeeTy;
9517 while (
auto PT = P->
getAs<PointerType>())
9528 if (StringRef(S).ends_with(
"nr"))
9529 S.replace(S.end()-2, S.end(),
"rn");
9539 }
else if (
const auto *RTy = PointeeTy->
getAsCanonical<RecordType>()) {
9540 const IdentifierInfo *II = RTy->getDecl()->getIdentifier();
9542 if (II == &
Idents.get(
"objc_class")) {
9547 if (II == &
Idents.get(
"objc_object")) {
9556 RTy, Options.ExpandPointedToStructures()))) {
9565 ObjCEncOptions NewOptions;
9566 if (Options.ExpandPointedToStructures())
9567 NewOptions.setExpandStructures();
9568 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9569 nullptr, NotEncodedT);
9573 case Type::ConstantArray:
9574 case Type::IncompleteArray:
9575 case Type::VariableArray: {
9582 getObjCEncodingForTypeImpl(
9583 AT->getElementType(), S,
9584 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9588 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9589 S += llvm::utostr(CAT->getZExtSize());
9593 "Unknown array type!");
9597 getObjCEncodingForTypeImpl(
9598 AT->getElementType(), S,
9599 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9606 case Type::FunctionNoProto:
9607 case Type::FunctionProto:
9611 case Type::Record: {
9613 S += RDecl->
isUnion() ?
'(' :
'{';
9617 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9618 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
9619 llvm::raw_string_ostream
OS(S);
9620 printTemplateArgumentList(OS, TemplateArgs.
asArray(),
9626 if (Options.ExpandStructures()) {
9629 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9631 for (
const auto *Field : RDecl->
fields()) {
9634 S +=
Field->getNameAsString();
9639 if (
Field->isBitField()) {
9640 getObjCEncodingForTypeImpl(
Field->getType(), S,
9641 ObjCEncOptions().setExpandStructures(),
9644 QualType qt =
Field->getType();
9646 getObjCEncodingForTypeImpl(
9648 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9654 S += RDecl->
isUnion() ?
')' :
'}';
9658 case Type::BlockPointer: {
9659 const auto *BT =
T->
castAs<BlockPointerType>();
9661 if (Options.EncodeBlockParameters()) {
9662 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
9666 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9667 Options.forComponentType(), FD, NotEncodedT);
9671 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9672 for (
const auto &I : FPT->param_types())
9673 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9681 case Type::ObjCObject: {
9685 S +=
"{objc_object=}";
9689 S +=
"{objc_class=}";
9696 case Type::ObjCInterface: {
9699 ObjCInterfaceDecl *OI =
T->
castAs<ObjCObjectType>()->getInterface();
9702 if (Options.ExpandStructures()) {
9704 SmallVector<const ObjCIvarDecl*, 32> Ivars;
9706 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9707 const FieldDecl *
Field = Ivars[i];
9708 if (
Field->isBitField())
9709 getObjCEncodingForTypeImpl(
Field->getType(), S,
9710 ObjCEncOptions().setExpandStructures(),
9713 getObjCEncodingForTypeImpl(
Field->getType(), S,
9714 ObjCEncOptions().setExpandStructures(), FD,
9722 case Type::ObjCObjectPointer: {
9723 const auto *OPT =
T->
castAs<ObjCObjectPointerType>();
9724 if (OPT->isObjCIdType()) {
9729 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9737 if (OPT->isObjCQualifiedIdType()) {
9738 getObjCEncodingForTypeImpl(
9740 Options.keepingOnly(ObjCEncOptions()
9741 .setExpandPointedToStructures()
9742 .setExpandStructures()),
9744 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9748 for (
const auto *I : OPT->quals()) {
9750 S += I->getObjCRuntimeNameAsString();
9759 if (OPT->getInterfaceDecl() &&
9760 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9762 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9763 for (
const auto *I : OPT->quals()) {
9765 S += I->getObjCRuntimeNameAsString();
9775 case Type::MemberPointer:
9779 case Type::ExtVector:
9785 case Type::ConstantMatrix:
9798 case Type::DeducedTemplateSpecialization:
9801 case Type::HLSLAttributedResource:
9802 case Type::HLSLInlineSpirv:
9803 case Type::OverflowBehavior:
9804 llvm_unreachable(
"unexpected type");
9806 case Type::ArrayParameter:
9808#define ABSTRACT_TYPE(KIND, BASE)
9809#define TYPE(KIND, BASE)
9810#define DEPENDENT_TYPE(KIND, BASE) \
9812#define NON_CANONICAL_TYPE(KIND, BASE) \
9814#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9816#include "clang/AST/TypeNodes.inc"
9817 llvm_unreachable(
"@encode for dependent type!");
9819 llvm_unreachable(
"bad type kind!");
9822void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
9824 const FieldDecl *FD,
9826 QualType *NotEncodedT)
const {
9827 assert(RDecl &&
"Expected non-null RecordDecl");
9828 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9832 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9833 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9837 for (
const auto &BI : CXXRec->bases()) {
9838 if (!BI.isVirtual()) {
9843 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9844 std::make_pair(offs, base));
9849 for (FieldDecl *Field : RDecl->
fields()) {
9850 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9853 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9854 std::make_pair(offs, Field));
9857 if (CXXRec && includeVBases) {
9858 for (
const auto &BI : CXXRec->vbases()) {
9864 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9865 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9866 std::make_pair(offs, base));
9880 std::multimap<uint64_t, NamedDecl *>::iterator
9881 CurLayObj = FieldOrBaseOffsets.begin();
9883 if (CXXRec && CXXRec->isDynamicClass() &&
9884 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9887 std::string recname = CXXRec->getNameAsString();
9888 if (recname.empty()) recname =
"?";
9901 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9902 std::make_pair(offs,
nullptr));
9905 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9907 assert(CurOffs <= CurLayObj->first);
9908 if (CurOffs < CurLayObj->first) {
9909 uint64_t padding = CurLayObj->first - CurOffs;
9921 NamedDecl *dcl = CurLayObj->second;
9925 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9930 getObjCEncodingForStructureImpl(base, S, FD,
false,
9940 S += field->getNameAsString();
9944 if (field->isBitField()) {
9947 CurOffs += field->getBitWidthValue();
9950 QualType qt = field->getType();
9952 getObjCEncodingForTypeImpl(
9953 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9964 std::string& S)
const {
9997 if (!ObjCClassDecl) {
10002 return ObjCClassDecl;
10006 if (!ObjCProtocolClassDecl) {
10007 ObjCProtocolClassDecl
10010 &
Idents.get(
"Protocol"),
10016 return ObjCProtocolClassDecl;
10037 QualType T = Context->getPointerType(Context->CharTy);
10038 return Context->buildImplicitTypedef(
T, Name);
10047 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 2);
10048 QualType T = Context->getPointerType(Context->CharTy);
10051 return Context->buildImplicitTypedef(
ArrayType,
"__builtin_zos_va_list");
10060 QualType T = Context->getPointerType(Context->VoidTy);
10061 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10064static TypedefDecl *
10068 if (Context->getLangOpts().CPlusPlus) {
10073 &Context->Idents.get(
"std"),
10081 const size_t NumFields = 5;
10083 const char *FieldNames[NumFields];
10086 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10087 FieldNames[0] =
"__stack";
10090 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10091 FieldNames[1] =
"__gr_top";
10094 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10095 FieldNames[2] =
"__vr_top";
10098 FieldTypes[3] = Context->IntTy;
10099 FieldNames[3] =
"__gr_offs";
10102 FieldTypes[4] = Context->IntTy;
10103 FieldNames[4] =
"__vr_offs";
10106 for (
unsigned i = 0; i < NumFields; ++i) {
10111 &Context->Idents.get(FieldNames[i]),
10112 FieldTypes[i],
nullptr,
10124 return Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10131 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10134 const size_t NumFields = 5;
10136 const char *FieldNames[NumFields];
10139 FieldTypes[0] = Context->UnsignedCharTy;
10140 FieldNames[0] =
"gpr";
10143 FieldTypes[1] = Context->UnsignedCharTy;
10144 FieldNames[1] =
"fpr";
10147 FieldTypes[2] = Context->UnsignedShortTy;
10148 FieldNames[2] =
"reserved";
10151 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10152 FieldNames[3] =
"overflow_arg_area";
10155 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
10156 FieldNames[4] =
"reg_save_area";
10159 for (
unsigned i = 0; i < NumFields; ++i) {
10163 &Context->Idents.get(FieldNames[i]),
10164 FieldTypes[i],
nullptr,
10177 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10181 std::nullopt, VaListTagTypedefDecl);
10184 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10185 QualType VaListTagArrayType = Context->getConstantArrayType(
10187 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10190static TypedefDecl *
10194 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10197 const size_t NumFields = 4;
10199 const char *FieldNames[NumFields];
10202 FieldTypes[0] = Context->UnsignedIntTy;
10203 FieldNames[0] =
"gp_offset";
10206 FieldTypes[1] = Context->UnsignedIntTy;
10207 FieldNames[1] =
"fp_offset";
10210 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10211 FieldNames[2] =
"overflow_arg_area";
10214 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10215 FieldNames[3] =
"reg_save_area";
10218 for (
unsigned i = 0; i < NumFields; ++i) {
10223 &Context->Idents.get(FieldNames[i]),
10224 FieldTypes[i],
nullptr,
10238 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10239 QualType VaListTagArrayType = Context->getConstantArrayType(
10241 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10244static TypedefDecl *
10247 RecordDecl *VaListDecl = Context->buildImplicitRecord(
"__va_list");
10248 if (Context->getLangOpts().CPlusPlus) {
10267 &Context->Idents.get(
"__ap"),
10268 Context->getPointerType(Context->VoidTy),
10278 Context->VaListTagDecl = VaListDecl;
10281 CanQualType T = Context->getCanonicalTagType(VaListDecl);
10282 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10285static TypedefDecl *
10289 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10292 const size_t NumFields = 4;
10294 const char *FieldNames[NumFields];
10297 FieldTypes[0] = Context->LongTy;
10298 FieldNames[0] =
"__gpr";
10301 FieldTypes[1] = Context->LongTy;
10302 FieldNames[1] =
"__fpr";
10305 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10306 FieldNames[2] =
"__overflow_arg_area";
10309 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10310 FieldNames[3] =
"__reg_save_area";
10313 for (
unsigned i = 0; i < NumFields; ++i) {
10318 &Context->Idents.get(FieldNames[i]),
10319 FieldTypes[i],
nullptr,
10333 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10334 QualType VaListTagArrayType = Context->getConstantArrayType(
10337 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10343 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10346 const size_t NumFields = 3;
10348 const char *FieldNames[NumFields];
10351 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10352 FieldNames[0] =
"__current_saved_reg_area_pointer";
10355 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10356 FieldNames[1] =
"__saved_reg_area_end_pointer";
10359 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10360 FieldNames[2] =
"__overflow_area_pointer";
10363 for (
unsigned i = 0; i < NumFields; ++i) {
10366 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
10379 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10383 std::nullopt, VaListTagTypedefDecl);
10386 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10387 QualType VaListTagArrayType = Context->getConstantArrayType(
10390 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10393static TypedefDecl *
10403 constexpr size_t NumFields = 3;
10404 QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
10405 Context->getPointerType(Context->IntTy),
10407 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10410 for (
unsigned i = 0; i < NumFields; ++i) {
10413 &Context->Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
10425 Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10427 return VaListTagTypedefDecl;
10453 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10457 if (!BuiltinVaListDecl) {
10458 BuiltinVaListDecl =
CreateVaListDecl(
this, Target->getBuiltinVaListKind());
10459 assert(BuiltinVaListDecl->isImplicit());
10462 return BuiltinVaListDecl;
10475 if (!BuiltinMSVaListDecl)
10478 return BuiltinMSVaListDecl;
10482 if (!BuiltinZOSVaListDecl)
10485 return BuiltinZOSVaListDecl;
10502 assert(ObjCConstantStringType.isNull() &&
10503 "'NSConstantString' type already set!");
10513 unsigned size = End - Begin;
10514 assert(size > 1 &&
"set is not overloaded!");
10520 NamedDecl **Storage = OT->getStorage();
10543 bool TemplateKeyword,
10548 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10549 assert(!Qualifier &&
"unexpected qualified template template parameter");
10550 assert(TemplateKeyword ==
false);
10555 llvm::FoldingSetNodeID ID;
10558 void *InsertPos =
nullptr;
10560 QualifiedTemplateNames.FindNodeOrInsertPos(ID, InsertPos);
10564 QualifiedTemplateNames.InsertNode(QTN, InsertPos);
10574 llvm::FoldingSetNodeID ID;
10577 void *InsertPos =
nullptr;
10579 DependentTemplateNames.FindNodeOrInsertPos(ID, InsertPos))
10584 DependentTemplateNames.InsertNode(QTN, InsertPos);
10589 Decl *AssociatedDecl,
10592 bool Final)
const {
10593 llvm::FoldingSetNodeID ID;
10597 void *insertPos =
nullptr;
10599 = SubstTemplateTemplateParms.FindNodeOrInsertPos(ID, insertPos);
10603 Replacement, AssociatedDecl, Index,
PackIndex, Final);
10604 SubstTemplateTemplateParms.InsertNode(subst, insertPos);
10612 Decl *AssociatedDecl,
10613 unsigned Index,
bool Final)
const {
10615 llvm::FoldingSetNodeID ID;
10617 AssociatedDecl, Index, Final);
10619 void *InsertPos =
nullptr;
10621 = SubstTemplateTemplateParmPacks.FindNodeOrInsertPos(ID, InsertPos);
10626 SubstTemplateTemplateParmPacks.InsertNode(Subst, InsertPos);
10640 llvm::FoldingSetNodeID ID;
10643 void *InsertPos =
nullptr;
10645 DeducedTemplates.FindNodeOrInsertPos(ID, InsertPos);
10651 DeducedTemplates.InsertNode(DTS, InsertPos);
10674 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10704 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10705 CT = AT->getElementType();
10737 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10738 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10795 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
10796 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
10798 if (!LHSOBT && !RHSOBT)
10801 if (LHSOBT && RHSOBT) {
10802 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
10807 QualType LHSUnderlying = LHSOBT ? LHSOBT->desugar() : LHS;
10808 QualType RHSUnderlying = RHSOBT ? RHSOBT->desugar() : RHS;
10810 if (RHSOBT && !LHSOBT) {
10821 auto VScale = Context.getTargetInfo().getVScaleRange(
10828 uint64_t EltSize = Context.getTypeSize(Info.
ElementType);
10832 uint64_t MinElts = Info.
EC.getKnownMinValue();
10833 return VScale->first * MinElts * EltSize;
10841 "Expected RVV builtin type and vector type!");
10881 return IsValidCast(FirstType, SecondType) ||
10882 IsValidCast(SecondType, FirstType);
10890 "Expected RVV builtin type and vector type!");
10897 if (!BT->isRVVVLSBuiltinType())
10917 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10924 return IsLaxCompatible(FirstType, SecondType) ||
10925 IsLaxCompatible(SecondType, FirstType);
10931 if (
const AttributedType *
Attr = dyn_cast<AttributedType>(Ty)) {
10932 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10935 Ty =
Attr->getModifiedType();
10939 Ty =
Paren->getInnerType();
10971 for (
auto *lhsProto : lhs->
quals()) {
10972 bool match =
false;
10973 for (
auto *rhsProto : rhs->
quals()) {
11004 for (
auto *I : lhs->
quals()) {
11008 if (!rhsID->ClassImplementsProtocol(I,
true))
11016 for (
auto *lhsProto : lhs->
quals()) {
11017 bool match =
false;
11022 for (
auto *rhsProto : rhs->
quals()) {
11032 for (
auto *I : lhs->
quals()) {
11036 if (rhsID->ClassImplementsProtocol(I,
true)) {
11053 for (
auto *lhsProto : lhs->
quals()) {
11054 bool match =
false;
11061 for (
auto *rhsProto : rhs->
quals()) {
11080 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
11082 for (
auto *lhsProto : LHSInheritedProtocols) {
11083 bool match =
false;
11084 for (
auto *rhsProto : rhs->
quals()) {
11109 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
11114 auto finish = [&](
bool succeeded) ->
bool {
11118 if (!RHS->isKindOfType())
11129 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
11134 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
11139 if (LHS->isObjCClass() && RHS->isObjCClass()) {
11144 if (LHS->getInterface() && RHS->getInterface()) {
11159 bool BlockReturnType) {
11163 auto finish = [&](
bool succeeded) ->
bool {
11188 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
11192 (!BlockReturnType &&
11196 (BlockReturnType ? LHSOPT : RHSOPT),
11197 (BlockReturnType ? RHSOPT : LHSOPT),
false));
11205 return finish(BlockReturnType);
11207 return finish(!BlockReturnType);
11219 return (*lhs)->getName().compare((*rhs)->getName());
11236 assert(LHS->getInterface() &&
"LHS must have an interface base");
11237 assert(RHS->getInterface() &&
"RHS must have an interface base");
11243 for (
auto *proto : LHS->quals()) {
11244 Context.CollectInheritedProtocols(proto, LHSProtocolSet);
11248 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
11254 for (
auto *proto : RHS->quals()) {
11255 Context.CollectInheritedProtocols(proto, RHSProtocolSet);
11259 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
11262 for (
auto *proto : LHSProtocolSet) {
11263 if (RHSProtocolSet.count(proto))
11264 IntersectionSet.push_back(proto);
11270 Context.CollectInheritedProtocols(CommonBase, ImpliedProtocols);
11273 if (!ImpliedProtocols.empty()) {
11275 return ImpliedProtocols.contains(proto);
11280 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11290 if (lhsOPT && rhsOPT)
11296 if (lhsBlock && rhsBlock)
11301 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11313 bool stripKindOf) {
11314 if (lhsArgs.size() != rhsArgs.size())
11321 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11327 if (!stripKindOf ||
11328 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11329 rhsArgs[i].stripObjCKindOfType(ctx))) {
11357 if (!LDecl || !RDecl)
11363 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
11367 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11372 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
11377 bool anyChanges =
false;
11378 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11381 LHS->getTypeArgs(), RHS->getTypeArgs(),
11384 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11395 if (!Protocols.empty())
11401 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
11404 anyKindOf || LHS->isKindOfType());
11412 QualType LHSSuperType = LHS->getSuperClassType();
11413 if (LHSSuperType.
isNull())
11422 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
11423 if (KnownLHS != LHSAncestors.end()) {
11424 LHS = KnownLHS->second;
11428 bool anyChanges =
false;
11429 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11432 LHS->getTypeArgs(), RHS->getTypeArgs(),
11435 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11446 if (!Protocols.empty())
11451 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
11454 anyKindOf || RHS->isKindOfType());
11462 QualType RHSSuperType = RHS->getSuperClassType();
11463 if (RHSSuperType.
isNull())
11474 assert(LHS->getInterface() &&
"LHS is not an interface type");
11475 assert(RHS->getInterface() &&
"RHS is not an interface type");
11480 bool IsSuperClass = LHSInterface->
isSuperClassOf(RHS->getInterface());
11487 if (LHS->getNumProtocols() > 0) {
11496 for (
auto *RHSPI : RHS->quals())
11499 if (SuperClassInheritedProtocols.empty())
11502 for (
const auto *LHSProto : LHS->quals()) {
11503 bool SuperImplementsProtocol =
false;
11504 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11505 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11506 SuperImplementsProtocol =
true;
11509 if (!SuperImplementsProtocol)
11515 if (LHS->isSpecialized()) {
11520 RHSSuper = RHSSuper->getSuperClassType()->castAs<
ObjCObjectType>();
11523 if (RHSSuper->isSpecialized() &&
11525 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
11539 if (!LHSOPT || !RHSOPT)
11557 bool CompareUnqualified) {
11576 bool OfBlockPointer,
11578 if (
const RecordType *UT =
T->getAsUnionType()) {
11580 if (UD->
hasAttr<TransparentUnionAttr>()) {
11581 for (
const auto *I : UD->
fields()) {
11582 QualType ET = I->getType().getUnqualifiedType();
11596 bool OfBlockPointer,
11617 bool IsConditionalOperator) {
11620 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11621 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11622 bool allLTypes =
true;
11623 bool allRTypes =
true;
11627 if (OfBlockPointer) {
11629 QualType LHS = lbase->getReturnType();
11631 if (!UnqualifiedResult)
11633 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11698 bool NoReturn = IsConditionalOperator
11708 std::optional<FunctionEffectSet> MergedFX;
11710 if (lproto && rproto) {
11711 assert((AllowCXX ||
11712 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11713 "C++ shouldn't be here");
11715 if (lproto->getNumParams() != rproto->getNumParams())
11719 if (lproto->isVariadic() != rproto->isVariadic())
11722 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11726 if (lproto->getExtraAttributeInfo().CFISalt !=
11727 rproto->getExtraAttributeInfo().CFISalt)
11733 if (LHSFX != RHSFX) {
11734 if (IsConditionalOperator)
11743 if (*MergedFX != LHSFX)
11745 if (*MergedFX != RHSFX)
11750 bool canUseLeft, canUseRight;
11762 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11763 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11764 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11766 lParamType, rParamType, OfBlockPointer,
Unqualified);
11773 types.push_back(paramType);
11785 if (allLTypes)
return lhs;
11786 if (allRTypes)
return rhs;
11791 newParamInfos.empty() ?
nullptr : newParamInfos.data();
11797 if (lproto) allRTypes =
false;
11798 if (rproto) allLTypes =
false;
11802 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11810 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11816 paramTy = ED->getIntegerType();
11826 if (allLTypes)
return lhs;
11827 if (allRTypes)
return rhs;
11836 if (allLTypes)
return lhs;
11837 if (allRTypes)
return rhs;
11843 QualType other,
bool isBlockReturnType) {
11849 ET->getDecl()->getDefinitionOrSelf()->getIntegerType();
11850 if (underlyingType.
isNull())
11852 if (Context.hasSameType(underlyingType, other))
11858 Context.getTypeSize(underlyingType) == Context.getTypeSize(other))
11867 if (LangOpts.CPlusPlus || !LangOpts.C23)
11888 bool BlockReturnType,
bool IsConditionalOperator) {
11889 const auto *LHSOBT = LHS->
getAs<OverflowBehaviorType>();
11890 const auto *RHSOBT = RHS->
getAs<OverflowBehaviorType>();
11892 if (!LHSOBT && !RHSOBT)
11893 return std::nullopt;
11897 if (LHSOBT->getBehaviorKind() != RHSOBT->getBehaviorKind())
11901 LHSOBT->getUnderlyingType(), RHSOBT->getUnderlyingType(),
11902 OfBlockPointer,
Unqualified, BlockReturnType, IsConditionalOperator);
11904 if (MergedUnderlying.
isNull())
11908 if (LHSOBT->getUnderlyingType() == RHSOBT->getUnderlyingType())
11911 LHSOBT->getBehaviorKind(),
11920 return mergeTypes(LHSOBT->getUnderlyingType(), RHS, OfBlockPointer,
11921 Unqualified, BlockReturnType, IsConditionalOperator);
11924 return mergeTypes(LHS, RHSOBT->getUnderlyingType(), OfBlockPointer,
11925 Unqualified, BlockReturnType, IsConditionalOperator);
11930 bool IsConditionalOperator) {
11941 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11945 if (LHSRefTy || RHSRefTy)
11948 if (std::optional<QualType> MergedOBT =
11950 BlockReturnType, IsConditionalOperator))
11962 if (LHSCan == RHSCan)
11967 Qualifiers RQuals = RHSCan.getLocalQualifiers();
11968 if (LQuals != RQuals) {
11985 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12006 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
12007 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
12010 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
12011 LHSClass = Type::ConstantArray;
12012 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
12013 RHSClass = Type::ConstantArray;
12016 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
12017 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
12020 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
12021 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
12024 if (LHSClass != RHSClass) {
12034 if (OfBlockPointer && !BlockReturnType) {
12042 if (
const auto *AT = LHS->
getAs<AutoType>()) {
12043 if (!AT->isDeduced() && AT->isGNUAutoType())
12046 if (
const auto *AT = RHS->
getAs<AutoType>()) {
12047 if (!AT->isDeduced() && AT->isGNUAutoType())
12054 switch (LHSClass) {
12055#define TYPE(Class, Base)
12056#define ABSTRACT_TYPE(Class, Base)
12057#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
12058#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
12059#define DEPENDENT_TYPE(Class, Base) case Type::Class:
12060#include "clang/AST/TypeNodes.inc"
12061 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
12064 case Type::DeducedTemplateSpecialization:
12065 case Type::LValueReference:
12066 case Type::RValueReference:
12067 case Type::MemberPointer:
12068 llvm_unreachable(
"C++ should never be in mergeTypes");
12070 case Type::ObjCInterface:
12071 case Type::IncompleteArray:
12072 case Type::VariableArray:
12073 case Type::FunctionProto:
12074 case Type::ExtVector:
12075 case Type::OverflowBehavior:
12076 llvm_unreachable(
"Types are eliminated above");
12078 case Type::Pointer:
12089 if (ResultType.
isNull())
12097 case Type::BlockPointer:
12122 if (ResultType.
isNull())
12141 if (ResultType.
isNull())
12149 case Type::ConstantArray:
12164 if (ResultType.
isNull())
12172 if (LVAT || RVAT) {
12175 -> std::pair<bool,llvm::APInt> {
12177 std::optional<llvm::APSInt> TheInt;
12180 return std::make_pair(
true, *TheInt);
12181 return std::make_pair(
false, llvm::APSInt());
12184 return std::make_pair(
true, CAT->getSize());
12185 return std::make_pair(
false, llvm::APInt());
12188 bool HaveLSize, HaveRSize;
12189 llvm::APInt LSize, RSize;
12190 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
12191 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
12192 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
12226 case Type::FunctionNoProto:
12228 false, IsConditionalOperator);
12232 case Type::Builtin:
12235 case Type::Complex:
12244 case Type::ConstantMatrix:
12249 case Type::ObjCObject: {
12258 case Type::ObjCObjectPointer:
12259 if (OfBlockPointer) {
12271 assert(LHS != RHS &&
12272 "Equivalent pipe types should have already been handled!");
12274 case Type::ArrayParameter:
12275 assert(LHS != RHS &&
12276 "Equivalent ArrayParameter types should have already been handled!");
12278 case Type::BitInt: {
12286 if (LHSUnsigned != RHSUnsigned)
12289 if (LHSBits != RHSBits)
12293 case Type::HLSLAttributedResource: {
12294 const HLSLAttributedResourceType *LHSTy =
12295 LHS->
castAs<HLSLAttributedResourceType>();
12296 const HLSLAttributedResourceType *RHSTy =
12297 RHS->
castAs<HLSLAttributedResourceType>();
12298 assert(LHSTy->getWrappedType() == RHSTy->getWrappedType() &&
12299 LHSTy->getWrappedType()->isHLSLResourceType() &&
12300 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
12302 if (LHSTy->getAttrs() == RHSTy->getAttrs() &&
12303 LHSTy->getContainedType() == RHSTy->getContainedType())
12307 case Type::HLSLInlineSpirv:
12308 const HLSLInlineSpirvType *LHSTy = LHS->
castAs<HLSLInlineSpirvType>();
12309 const HLSLInlineSpirvType *RHSTy = RHS->
castAs<HLSLInlineSpirvType>();
12311 if (LHSTy->getOpcode() == RHSTy->getOpcode() &&
12312 LHSTy->getSize() == RHSTy->getSize() &&
12313 LHSTy->getAlignment() == RHSTy->getAlignment()) {
12314 for (
size_t I = 0; I < LHSTy->getOperands().size(); I++)
12315 if (LHSTy->getOperands()[I] != RHSTy->getOperands()[I])
12323 llvm_unreachable(
"Invalid Type::Class!");
12328 bool &CanUseFirst,
bool &CanUseSecond,
12330 assert(NewParamInfos.empty() &&
"param info list not empty");
12331 CanUseFirst = CanUseSecond =
true;
12337 if (!FirstHasInfo && !SecondHasInfo)
12340 bool NeedParamInfo =
false;
12344 for (
size_t I = 0; I < E; ++I) {
12355 bool FirstNoEscape = FirstParam.
isNoEscape();
12356 bool SecondNoEscape = SecondParam.
isNoEscape();
12357 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12359 if (NewParamInfos.back().getOpaqueValue())
12360 NeedParamInfo =
true;
12361 if (FirstNoEscape != IsNoEscape)
12362 CanUseFirst =
false;
12363 if (SecondNoEscape != IsNoEscape)
12364 CanUseSecond =
false;
12367 if (!NeedParamInfo)
12368 NewParamInfos.clear();
12374 if (
auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
12375 It->second =
nullptr;
12376 for (
auto *SubClass : ObjCSubClasses.lookup(D))
12388 if (LHSCan == RHSCan)
12390 if (RHSCan->isFunctionType()) {
12399 if (ResReturnType.
isNull())
12401 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12418 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12419 if (LQuals != RQuals) {
12432 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12448 if (ResQT == LHSBaseQT)
12450 if (ResQT == RHSBaseQT)
12461 if (
const auto *ED =
T->getAsEnumDecl())
12462 T = ED->getIntegerType();
12463 if (
T->isBooleanType())
12466 return EIT->getNumBits();
12472 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12473 T->isFixedPointType()) &&
12474 "Unexpected type");
12479 VTy->getNumElements(), VTy->getVectorKind());
12486 if (
const auto *OBT =
T->getAs<OverflowBehaviorType>())
12488 OBT->getBehaviorKind(),
12493 if (
const auto *ED =
T->getAsEnumDecl())
12494 T = ED->getIntegerType();
12497 case BuiltinType::Char_U:
12499 case BuiltinType::Char_S:
12500 case BuiltinType::SChar:
12501 case BuiltinType::Char8:
12503 case BuiltinType::Short:
12505 case BuiltinType::Int:
12507 case BuiltinType::Long:
12509 case BuiltinType::LongLong:
12511 case BuiltinType::Int128:
12516 case BuiltinType::WChar_S:
12519 case BuiltinType::ShortAccum:
12521 case BuiltinType::Accum:
12523 case BuiltinType::LongAccum:
12525 case BuiltinType::SatShortAccum:
12527 case BuiltinType::SatAccum:
12529 case BuiltinType::SatLongAccum:
12531 case BuiltinType::ShortFract:
12533 case BuiltinType::Fract:
12535 case BuiltinType::LongFract:
12537 case BuiltinType::SatShortFract:
12539 case BuiltinType::SatFract:
12541 case BuiltinType::SatLongFract:
12544 assert((
T->hasUnsignedIntegerRepresentation() ||
12545 T->isUnsignedFixedPointType()) &&
12546 "Unexpected signed integer or fixed point type");
12552 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12553 T->isFixedPointType()) &&
12554 "Unexpected type");
12559 VTy->getNumElements(), VTy->getVectorKind());
12567 if (
const auto *ED =
T->getAsEnumDecl())
12568 T = ED->getIntegerType();
12571 case BuiltinType::Char_S:
12573 case BuiltinType::Char_U:
12574 case BuiltinType::UChar:
12575 case BuiltinType::Char8:
12577 case BuiltinType::UShort:
12579 case BuiltinType::UInt:
12581 case BuiltinType::ULong:
12583 case BuiltinType::ULongLong:
12585 case BuiltinType::UInt128:
12590 case BuiltinType::WChar_U:
12593 case BuiltinType::UShortAccum:
12595 case BuiltinType::UAccum:
12597 case BuiltinType::ULongAccum:
12599 case BuiltinType::SatUShortAccum:
12601 case BuiltinType::SatUAccum:
12603 case BuiltinType::SatULongAccum:
12605 case BuiltinType::UShortFract:
12607 case BuiltinType::UFract:
12609 case BuiltinType::ULongFract:
12611 case BuiltinType::SatUShortFract:
12613 case BuiltinType::SatUFract:
12615 case BuiltinType::SatULongFract:
12619 (
T->hasSignedIntegerRepresentation() ||
T->isSignedFixedPointType()) &&
12620 "Unexpected signed integer or fixed point type");
12645 bool AllowTypeModifiers) {
12649 bool IsChar =
false, IsShort =
false;
12650 RequiresICE =
false;
12655 bool IsSpecial =
false;
12659 default: Done =
true; --Str;
break;
12661 RequiresICE =
true;
12664 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12665 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12669 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12670 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12675 assert(!IsSpecial &&
12676 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12677 assert(HowLong == 0 &&
"Can't use both 'L' and 'B' modifiers!");
12685 assert(!IsSpecial &&
12686 "Can't use two 'N', 'W', 'Z', 'O', 'B', or 'T' modifiers!");
12687 assert(HowLong == 0 &&
"Can't use both 'L' and 'T' modifiers!");
12694 assert(!IsSpecial &&
12695 "Can't use 'L' with 'W', 'N', 'Z', 'O', 'B', or 'T' modifiers");
12696 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12701 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12702 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12706 if (Context.getTargetInfo().getLongWidth() == 32)
12711 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12712 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12716 switch (Context.getTargetInfo().getInt64Type()) {
12718 llvm_unreachable(
"Unexpected integer type");
12729 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12730 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12734 switch (Context.getTargetInfo().getIntTypeByWidth(32,
true)) {
12736 llvm_unreachable(
"Unexpected integer type");
12749 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12750 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12754 if (Context.getLangOpts().OpenCL)
12767 llvm_unreachable(
"Unknown builtin type letter!");
12770 "Bad modifiers used with 'x'!");
12771 Type = Context.Float16Ty;
12775 "Bad modifiers used with 'y'!");
12776 Type = Context.BFloat16Ty;
12780 "Bad modifiers used with 'v'!");
12781 Type = Context.VoidTy;
12785 "Bad modifiers used with 'h'!");
12786 Type = Context.HalfTy;
12790 "Bad modifiers used with 'f'!");
12791 Type = Context.FloatTy;
12795 "Bad modifiers used with 'd'!");
12797 Type = Context.LongDoubleTy;
12798 else if (HowLong == 2)
12799 Type = Context.Float128Ty;
12801 Type = Context.DoubleTy;
12804 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12806 Type = Context.UnsignedShortTy;
12808 Type = Context.ShortTy;
12812 Type =
Unsigned ? Context.UnsignedCharTy : Context.SignedCharTy;
12814 Type =
Unsigned ? Context.UnsignedShortTy : Context.ShortTy;
12815 else if (HowLong == 3)
12816 Type =
Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
12817 else if (HowLong == 2)
12818 Type =
Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
12819 else if (HowLong == 1)
12820 Type =
Unsigned ? Context.UnsignedLongTy : Context.LongTy;
12822 Type =
Unsigned ? Context.UnsignedIntTy : Context.IntTy;
12825 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12827 Type = Context.SignedCharTy;
12829 Type = Context.UnsignedCharTy;
12831 Type = Context.CharTy;
12834 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12835 Type = Context.BoolTy;
12838 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12839 Type = Context.getSizeType();
12842 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12843 Type = Context.getWideCharType();
12846 Type = Context.getCFConstantStringType();
12849 Type = Context.getObjCIdType();
12852 Type = Context.getObjCSelType();
12855 Type = Context.getObjCSuperType();
12858 Type = Context.getBuiltinVaListType();
12859 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12870 Type = Context.getBuiltinVaListType();
12871 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12873 Type = Context.getArrayDecayedType(
Type);
12875 Type = Context.getLValueReferenceType(
Type);
12879 unsigned NumElements = strtoul(Str, &End, 10);
12880 assert(End != Str &&
"Missing vector size");
12884 RequiresICE,
false);
12885 assert(!RequiresICE &&
"Can't require vector ICE");
12887 Type = Context.getScalableVectorType(ElementType, NumElements);
12893 Type = Context.SveCountTy;
12897 Type = Context.AMDGPUBufferRsrcTy;
12901 Type = Context.AMDGPUFeaturePredicateTy;
12905 Type = Context.AMDGPUTextureTy;
12909 Type = Context.HLSLResourceTy;
12913 llvm_unreachable(
"Unexpected target builtin type");
12919 unsigned NumElements = strtoul(Str, &End, 10);
12920 assert(End != Str &&
"Missing vector size");
12924 RequiresICE,
false);
12925 assert(!RequiresICE &&
"Can't require vector ICE");
12934 unsigned NumElements = strtoul(Str, &End, 10);
12935 assert(End != Str &&
"Missing vector size");
12941 Type = Context.getExtVectorType(ElementType, NumElements);
12947 assert(!RequiresICE &&
"Can't require complex ICE");
12948 Type = Context.getComplexType(ElementType);
12952 Type = Context.getPointerDiffType();
12955 Type = Context.getFILEType();
12956 if (
Type.isNull()) {
12963 Type = Context.getsigjmp_bufType();
12965 Type = Context.getjmp_bufType();
12967 if (
Type.isNull()) {
12973 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
12974 Type = Context.getucontext_tType();
12976 if (
Type.isNull()) {
12982 Type = Context.getProcessIDType();
12985 Type = Context.MFloat8Ty;
12990 Done = !AllowTypeModifiers;
12992 switch (
char c = *Str++) {
12993 default: Done =
true; --Str;
break;
12999 unsigned AddrSpace = strtoul(Str, &End, 10);
13002 Type = Context.getAddrSpaceQualType(
13004 Context.getLangASForBuiltinAddressSpace(AddrSpace));
13008 Type = Context.getPointerType(
Type);
13010 Type = Context.getLValueReferenceType(
Type);
13018 Type = Context.getVolatileType(
Type);
13027 "Integer constant 'I' type must be an integer");
13040 bool AllowTypeModifiers)
const {
13047 unsigned *IntegerConstantArgs)
const {
13048 const char *TypeStr =
BuiltinInfo.getTypeString(Id);
13049 if (TypeStr[0] ==
'\0') {
13056 bool RequiresICE =
false;
13059 RequiresICE,
true);
13063 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
13065 while (TypeStr[0] && TypeStr[0] !=
'.') {
13072 if (RequiresICE && IntegerConstantArgs)
13073 *IntegerConstantArgs |= 1 << ArgTypes.size();
13079 ArgTypes.push_back(Ty);
13082 if (Id == Builtin::BI__GetExceptionInfo)
13085 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
13086 "'.' should only occur at end of builtin type list!");
13088 bool Variadic = (TypeStr[0] ==
'.');
13095 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
13145 if ((!Context.getLangOpts().CPlusPlus &&
13146 !Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13147 !FD->
hasAttr<DLLExportAttr>()) ||
13148 FD->
hasAttr<GNUInlineAttr>()) {
13167 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13170 !FD->
hasAttr<DLLExportAttr>()) {
13191 if (D->
hasAttr<DLLImportAttr>()) {
13194 }
else if (D->
hasAttr<DLLExportAttr>()) {
13197 }
else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice) {
13200 if (D->
hasAttr<CUDAGlobalAttr>() &&
13209 if (Context.shouldExternalize(D))
13224 switch (Source->hasExternalDefinitions(D)) {
13251 if (Context.getLangOpts().CPlusPlus &&
13252 Context.getLangOpts().IncrementalExtensions &&
13268 if (!LexicalContext)
13273 auto StaticLocalLinkage =
13285 return StaticLocalLinkage;
13291 if (Context.isMSStaticDataMemberInlineDefinition(VD))
13297 switch (Context.getInlineVariableDefinitionKind(VD)) {
13312 return StrongLinkage;
13315 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
13330 llvm_unreachable(
"Invalid Linkage!");
13340 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
13341 if (!VD->isFileVarDecl())
13346 if (VD->getDescribedVarTemplate() ||
13349 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13375 if (D->
hasAttr<WeakRefAttr>())
13382 if (LangOpts.SYCLIsDevice)
13384 D->
hasAttr<SYCLExternalAttr>());
13390 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13392 if (!FD->doesThisDeclarationHaveABody())
13393 return FD->doesDeclarationForceExternallyVisibleDefinition();
13396 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13401 if (
getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
13402 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13421 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13425 if (LangOpts.OpenMP &&
13426 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13433 if (VD->shouldEmitInExternalSource())
13446 if (VD->needsDestruction(*
this))
13450 if (VD->hasInitWithSideEffects())
13455 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13456 for (
const auto *BD : DD->flat_bindings())
13457 if (
const auto *BindingVD = BD->getHoldingVar())
13467 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13468 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13469 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13474 for (
auto *CurDecl :
13478 SeenDecls.insert(CurFD).second) {
13485 bool IsCXXMethod)
const {
13488 return ABI->getDefaultMethodCallConv(IsVariadic);
13490 switch (LangOpts.getDefaultCallingConv()) {
13518 return Target->getDefaultCallingConv();
13523 return ABI->isNearlyEmpty(RD);
13528 auto ABI = Target->getCXXABI();
13529 if (ABI.isMicrosoft())
13535 return VTContext.get();
13541 switch (
T->getCXXABI().getKind()) {
13542 case TargetCXXABI::AppleARM64:
13543 case TargetCXXABI::Fuchsia:
13544 case TargetCXXABI::GenericAArch64:
13545 case TargetCXXABI::GenericItanium:
13546 case TargetCXXABI::GenericARM:
13547 case TargetCXXABI::GenericMIPS:
13548 case TargetCXXABI::iOS:
13549 case TargetCXXABI::WebAssembly:
13550 case TargetCXXABI::WatchOS:
13551 case TargetCXXABI::XL:
13553 case TargetCXXABI::Microsoft:
13556 llvm_unreachable(
"Unsupported ABI");
13560 assert(
T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13561 "Device mangle context does not support Microsoft mangling.");
13562 switch (
T.getCXXABI().getKind()) {
13563 case TargetCXXABI::AppleARM64:
13564 case TargetCXXABI::Fuchsia:
13565 case TargetCXXABI::GenericAArch64:
13566 case TargetCXXABI::GenericItanium:
13567 case TargetCXXABI::GenericARM:
13568 case TargetCXXABI::GenericMIPS:
13569 case TargetCXXABI::iOS:
13570 case TargetCXXABI::WebAssembly:
13571 case TargetCXXABI::WatchOS:
13572 case TargetCXXABI::XL:
13576 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13577 return RD->getDeviceLambdaManglingNumber();
13578 return std::nullopt;
13581 case TargetCXXABI::Microsoft:
13585 llvm_unreachable(
"Unsupported ABI");
13603 return ASTRecordLayouts.getMemorySize() +
13604 llvm::capacity_in_bytes(ObjCLayouts) +
13605 llvm::capacity_in_bytes(KeyFunctions) +
13606 llvm::capacity_in_bytes(ObjCImpls) +
13607 llvm::capacity_in_bytes(BlockVarCopyInits) +
13608 llvm::capacity_in_bytes(DeclAttrs) +
13609 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13610 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13611 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13612 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13613 llvm::capacity_in_bytes(OverriddenMethods) +
13614 llvm::capacity_in_bytes(Types) +
13615 llvm::capacity_in_bytes(VariableArrayTypes);
13623 unsigned Signed)
const {
13626 if (!QualTy && DestWidth == 128)
13632 unsigned Signed)
const {
13633 return getFromTargetType(
13661 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13668 MangleNumbers[ND] = Number;
13671 Listener->AddedManglingNumber(ND, Number);
13675 bool ForAuxTarget)
const {
13676 auto I = MangleNumbers.find(ND);
13677 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13680 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13681 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13683 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13684 "number for aux target");
13686 return Res > 1 ? Res : 1;
13693 StaticLocalNumbers[VD] = Number;
13696 Listener->AddedStaticLocalNumbers(VD, Number);
13700 auto I = StaticLocalNumbers.find(VD);
13701 return I != StaticLocalNumbers.end() ? I->second : 1;
13705 bool IsDestroying) {
13706 if (!IsDestroying) {
13718 bool IsTypeAware) {
13719 if (!IsTypeAware) {
13735 OperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] = OperatorDelete;
13738 GlobalOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13742 ArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13746 GlobalArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
13756 return OperatorDeletesForVirtualDtor.contains(Dtor->getCanonicalDecl());
13758 return GlobalOperatorDeletesForVirtualDtor.contains(
13759 Dtor->getCanonicalDecl());
13761 return ArrayOperatorDeletesForVirtualDtor.contains(
13762 Dtor->getCanonicalDecl());
13764 return GlobalArrayOperatorDeletesForVirtualDtor.contains(
13765 Dtor->getCanonicalDecl());
13776 if (OperatorDeletesForVirtualDtor.contains(Canon))
13777 return OperatorDeletesForVirtualDtor[Canon];
13780 if (GlobalOperatorDeletesForVirtualDtor.contains(Canon))
13781 return GlobalOperatorDeletesForVirtualDtor[Canon];
13784 if (ArrayOperatorDeletesForVirtualDtor.contains(Canon))
13785 return ArrayOperatorDeletesForVirtualDtor[Canon];
13788 if (GlobalArrayOperatorDeletesForVirtualDtor.contains(Canon))
13789 return GlobalArrayOperatorDeletesForVirtualDtor[Canon];
13800 return MaybeRequireVectorDeletingDtor.count(RD);
13808 MaybeRequireVectorDeletingDtor.insert(RD);
13813 assert(LangOpts.CPlusPlus);
13814 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13822 assert(LangOpts.CPlusPlus);
13823 std::unique_ptr<MangleNumberingContext> &MCtx =
13824 ExtraMangleNumberingContexts[D];
13830std::unique_ptr<MangleNumberingContext>
13832 return ABI->createMangleNumberingContext();
13837 return ABI->getCopyConstructorForExceptionObject(
13843 return ABI->addCopyConstructorForExceptionObject(
13850 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13855 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13860 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13864 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13868 ParamIndices[D] =
index;
13872 ParameterIndexTable::const_iterator I = ParamIndices.find(D);
13873 assert(I != ParamIndices.end() &&
13874 "ParmIndices lacks entry set by ParmVarDecl");
13879 unsigned Length)
const {
13905 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13907 llvm::FoldingSetNodeID ID;
13911 if (
MSGuidDecl *Existing = MSGuidDecls.FindNodeOrInsertPos(ID, InsertPos))
13915 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
13916 MSGuidDecls.InsertNode(
New, InsertPos);
13922 const APValue &APVal)
const {
13923 llvm::FoldingSetNodeID ID;
13928 UnnamedGlobalConstantDecls.FindNodeOrInsertPos(ID, InsertPos))
13932 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
13933 UnnamedGlobalConstantDecls.InsertNode(
New, InsertPos);
13939 assert(
T->isRecordType() &&
"template param object of unexpected type");
13945 llvm::FoldingSetNodeID ID;
13950 TemplateParamObjectDecls.FindNodeOrInsertPos(ID, InsertPos))
13954 TemplateParamObjectDecls.InsertNode(
New, InsertPos);
13960 if (!
T.isOSDarwin())
13963 if (!(
T.isiOS() &&
T.isOSVersionLT(7)) &&
13964 !(
T.isMacOSX() &&
T.isOSVersionLT(10, 9)))
13973 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
13980 if (MethodDecl->
hasAttr<UnavailableAttr>()
13981 || MethodDecl->
hasAttr<DeprecatedAttr>())
13995 IM != EM && IF != EF; ++IM, ++IF) {
14026 llvm::FoldingSetNodeID IDX, IDY;
14027 X->Profile(IDX, *
this,
true);
14028 Y->
Profile(IDY, *
this,
true);
14042 for (
const Decl *DX :
X->redecls()) {
14047 if (DX->isFirstDecl())
14050 llvm_unreachable(
"Corrupt redecls chain");
14053template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14055 return cast_or_null<T>(
14057 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
14060template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
14068 bool IgnoreDeduced =
false) {
14083 bool IgnoreDeduced) {
14085 assert(R.getAsVoidPointer() !=
nullptr);
14091 assert(Xs.size() == Ys.size());
14093 for (
size_t I = 0; I < Rs.size(); ++I)
14100 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
14110 switch (
X.getKind()) {
14140 auto NExpX =
X.getNumTemplateExpansions();
14154 if (Xs.size() != Ys.size())
14156 R.resize(Xs.size());
14157 for (
size_t I = 0; I < R.size(); ++I) {
14170 assert(!Different);
14198 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
14200 return std::nullopt;
14205 assert(Kind == NNS2.
getKind());
14210 auto Kind = Namespace1->getKind();
14211 if (Kind != Namespace2->getKind() ||
14212 (Kind == Decl::NamespaceAlias &&
14217 Namespace2->getNamespace()),
14251 llvm_unreachable(
"singletons did not compare equal");
14253 assert(R.getCanonical() == Canon);
14259 const T *Y,
bool IsSame) {
14260 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
14280 QX +=
X.getQualifiers() - RQ;
14290 Y->getElementType(), QX, QY);
14301 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
14302 return X->getSizeExpr();
14307 return X->getSizeModifier();
14313 return X->getIndexTypeCVRQualifiers();
14323 llvm::DenseMap<QualType, unsigned>
Found;
14324 for (
auto Ts : {
X, Y}) {
14331 Out.emplace_back(
T);
14337FunctionProtoType::ExceptionSpecInfo
14341 bool AcceptDependent)
const {
14367 assert(AcceptDependent &&
14368 "computing composite pointer type of dependent types");
14383 llvm_unreachable(
"These ESTs should be handled above");
14388 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
14392 Result.Exceptions = ExceptionTypeStorage;
14399 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
14402 llvm_unreachable(
"invalid ExceptionSpecificationType");
14411#define UNEXPECTED_TYPE(Class, Kind) \
14412 case Type::Class: \
14413 llvm_unreachable("Unexpected " Kind ": " #Class);
14415#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
14416#define TYPE(Class, Base)
14417#include "clang/AST/TypeNodes.inc"
14419#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
14430#undef SUGAR_FREE_TYPE
14431#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
14434#undef NON_UNIQUE_TYPE
14438#undef UNEXPECTED_TYPE
14442 assert(AX->getDeducedKind() == AY->getDeducedKind());
14444 assert(AX->getKeyword() == AY->getKeyword());
14446 AY->getTypeConstraintConcept());
14450 AY->getTypeConstraintArguments())) {
14457 case Type::IncompleteArray: {
14464 case Type::DependentSizedArray: {
14472 case Type::ConstantArray: {
14475 assert(AX->getSize() == AY->getSize());
14476 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14477 ? AX->getSizeExpr()
14483 case Type::ArrayParameter: {
14486 assert(AX->getSize() == AY->getSize());
14487 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14488 ? AX->getSizeExpr()
14495 case Type::Atomic: {
14500 case Type::Complex: {
14504 case Type::Pointer: {
14508 case Type::BlockPointer: {
14512 case Type::ObjCObjectPointer: {
14517 case Type::MemberPointer: {
14521 PY->getMostRecentCXXRecordDecl()));
14525 PX->getMostRecentCXXRecordDecl());
14527 case Type::LValueReference: {
14532 PX->isSpelledAsLValue() ||
14533 PY->isSpelledAsLValue());
14535 case Type::RValueReference: {
14541 case Type::DependentAddressSpace: {
14544 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14546 PX->getAddrSpaceExpr(),
14549 case Type::FunctionNoProto: {
14552 assert(FX->getExtInfo() == FY->getExtInfo());
14557 case Type::FunctionProto: {
14561 EPIY = FY->getExtProtoInfo();
14562 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14569 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14570 assert(EPIX.
Variadic == EPIY.Variadic);
14579 auto P =
getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
14587 case Type::ObjCObject: {
14590 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14591 OY->getProtocols().begin(), OY->getProtocols().end(),
14593 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14595 "protocol lists must be the same");
14597 OY->getTypeArgsAsWritten());
14600 OX->getProtocols(),
14601 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14603 case Type::ConstantMatrix: {
14606 assert(MX->getNumRows() == MY->getNumRows());
14607 assert(MX->getNumColumns() == MY->getNumColumns());
14609 MX->getNumRows(), MX->getNumColumns());
14611 case Type::DependentSizedMatrix: {
14614 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14615 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14620 case Type::Vector: {
14622 assert(VX->getNumElements() == VY->getNumElements());
14623 assert(VX->getVectorKind() == VY->getVectorKind());
14625 VX->getNumElements(), VX->getVectorKind());
14627 case Type::ExtVector: {
14629 assert(VX->getNumElements() == VY->getNumElements());
14631 VX->getNumElements());
14633 case Type::DependentSizedExtVector: {
14640 case Type::DependentVector: {
14643 assert(VX->getVectorKind() == VY->getVectorKind());
14650 case Type::InjectedClassName: {
14657 case Type::TemplateSpecialization: {
14661 TY->template_arguments());
14665 TY->getTemplateName(),
14667 As, {},
X->getCanonicalTypeInternal());
14669 case Type::Decltype: {
14672 assert(DX->isDependentType());
14673 assert(DY->isDependentType());
14674 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14678 case Type::PackIndexing: {
14681 assert(DX->isDependentType());
14682 assert(DY->isDependentType());
14683 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14686 case Type::DependentName: {
14689 assert(NX->getIdentifier() == NY->getIdentifier());
14694 case Type::OverflowBehavior: {
14697 assert(NX->getBehaviorKind() == NY->getBehaviorKind());
14699 NX->getBehaviorKind(),
14701 NY->getUnderlyingType(), QX, QY));
14703 case Type::UnaryTransform: {
14706 assert(TX->getUTTKind() == TY->getUTTKind());
14710 TY->getUnderlyingType()),
14713 case Type::PackExpansion: {
14716 assert(PX->getNumExpansions() == PY->getNumExpansions());
14719 PX->getNumExpansions(),
false);
14723 assert(PX->isReadOnly() == PY->isReadOnly());
14728 case Type::TemplateTypeParm: {
14731 assert(TX->getDepth() == TY->getDepth());
14732 assert(TX->getIndex() == TY->getIndex());
14733 assert(TX->isParameterPack() == TY->isParameterPack());
14735 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14739 llvm_unreachable(
"Unknown Type Class");
14749#define UNEXPECTED_TYPE(Class, Kind) \
14750 case Type::Class: \
14751 llvm_unreachable("Unexpected " Kind ": " #Class);
14752#define TYPE(Class, Base)
14753#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14754#include "clang/AST/TypeNodes.inc"
14756#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14783#undef CANONICAL_TYPE
14785#undef UNEXPECTED_TYPE
14787 case Type::Adjusted: {
14789 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14796 case Type::Decayed: {
14798 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14805 case Type::Attributed: {
14807 AttributedType::Kind Kind = AX->getAttrKind();
14808 if (Kind != AY->getAttrKind())
14810 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14818 case Type::BTFTagAttributed: {
14820 const BTFTypeTagAttr *AX = BX->getAttr();
14822 if (AX->getBTFTypeTag() !=
14833 if (KW != AY->getKeyword())
14837 AY->getTypeConstraintConcept());
14841 AY->getTypeConstraintArguments())) {
14852 case Type::PackIndexing:
14853 case Type::Decltype:
14855 case Type::DeducedTemplateSpecialization:
14858 case Type::MacroQualified: {
14862 if (IX != MY->getMacroIdentifier())
14866 case Type::SubstTemplateTypeParm: {
14873 unsigned Index = SX->getIndex();
14874 if (Index != SY->getIndex())
14881 SX->getFinal() && SY->getFinal());
14883 case Type::ObjCTypeParam:
14889 case Type::TemplateSpecialization: {
14894 TY->getTemplateName(),
true);
14899 TY->template_arguments()))
14905 case Type::Typedef: {
14915 case Type::TypeOf: {
14926 case Type::TypeOfExpr:
14929 case Type::UnaryTransform: {
14932 UnaryTransformType::UTTKind KX = UX->getUTTKind();
14933 if (KX != UY->getUTTKind())
14935 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
14942 case Type::Using: {
14951 case Type::MemberPointer: {
14955 assert(Cls == PY->getMostRecentCXXRecordDecl());
14960 case Type::CountAttributed: {
14963 if (DX->isCountInBytes() != DY->isCountInBytes())
14965 if (DX->isOrNull() != DY->isOrNull())
14967 Expr *CEX = DX->getCountExpr();
14968 Expr *CEY = DY->getCountExpr();
14972 DX->isCountInBytes(), DX->isOrNull(),
14983 DX->isCountInBytes(), DX->isOrNull(),
14987 case Type::LateParsedAttr:
14990 case Type::PredefinedSugar:
14995 llvm_unreachable(
"Unhandled Type Class");
15002 QualType NT =
T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
15017 if (
X.isCanonical())
15044 bool KeepCommonQualifiers =
15047 if (SX.
Ty != SY.Ty) {
15055 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
15058 SX = Xs.pop_back_val();
15059 SY = Ys.pop_back_val();
15062 if (KeepCommonQualifiers)
15069 while (!Xs.empty() && !Ys.empty()) {
15072 SX = Xs.pop_back_val();
15073 SY = Ys.pop_back_val();
15078 SX.
Ty = Underlying.Ty;
15081 QX -= Underlying.Quals;
15099 llvm_unreachable(
"Not a saturated fixed point type!");
15100 case BuiltinType::SatShortAccum:
15102 case BuiltinType::SatAccum:
15104 case BuiltinType::SatLongAccum:
15106 case BuiltinType::SatUShortAccum:
15108 case BuiltinType::SatUAccum:
15110 case BuiltinType::SatULongAccum:
15112 case BuiltinType::SatShortFract:
15114 case BuiltinType::SatFract:
15116 case BuiltinType::SatLongFract:
15118 case BuiltinType::SatUShortFract:
15120 case BuiltinType::SatUFract:
15122 case BuiltinType::SatULongFract:
15134 llvm_unreachable(
"Not a fixed point type!");
15135 case BuiltinType::ShortAccum:
15137 case BuiltinType::Accum:
15139 case BuiltinType::LongAccum:
15141 case BuiltinType::UShortAccum:
15143 case BuiltinType::UAccum:
15145 case BuiltinType::ULongAccum:
15147 case BuiltinType::ShortFract:
15149 case BuiltinType::Fract:
15151 case BuiltinType::LongFract:
15153 case BuiltinType::UShortFract:
15155 case BuiltinType::UFract:
15157 case BuiltinType::ULongFract:
15163 if (LangOpts.OpenCL)
15187 llvm_unreachable(
"Not a fixed point type!");
15188 case BuiltinType::ShortAccum:
15189 case BuiltinType::SatShortAccum:
15190 return Target.getShortAccumScale();
15191 case BuiltinType::Accum:
15192 case BuiltinType::SatAccum:
15193 return Target.getAccumScale();
15194 case BuiltinType::LongAccum:
15195 case BuiltinType::SatLongAccum:
15196 return Target.getLongAccumScale();
15197 case BuiltinType::UShortAccum:
15198 case BuiltinType::SatUShortAccum:
15199 return Target.getUnsignedShortAccumScale();
15200 case BuiltinType::UAccum:
15201 case BuiltinType::SatUAccum:
15202 return Target.getUnsignedAccumScale();
15203 case BuiltinType::ULongAccum:
15204 case BuiltinType::SatULongAccum:
15205 return Target.getUnsignedLongAccumScale();
15206 case BuiltinType::ShortFract:
15207 case BuiltinType::SatShortFract:
15208 return Target.getShortFractScale();
15209 case BuiltinType::Fract:
15210 case BuiltinType::SatFract:
15211 return Target.getFractScale();
15212 case BuiltinType::LongFract:
15213 case BuiltinType::SatLongFract:
15214 return Target.getLongFractScale();
15215 case BuiltinType::UShortFract:
15216 case BuiltinType::SatUShortFract:
15217 return Target.getUnsignedShortFractScale();
15218 case BuiltinType::UFract:
15219 case BuiltinType::SatUFract:
15220 return Target.getUnsignedFractScale();
15221 case BuiltinType::ULongFract:
15222 case BuiltinType::SatULongFract:
15223 return Target.getUnsignedLongFractScale();
15233 llvm_unreachable(
"Not a fixed point type!");
15234 case BuiltinType::ShortAccum:
15235 case BuiltinType::SatShortAccum:
15236 return Target.getShortAccumIBits();
15237 case BuiltinType::Accum:
15238 case BuiltinType::SatAccum:
15239 return Target.getAccumIBits();
15240 case BuiltinType::LongAccum:
15241 case BuiltinType::SatLongAccum:
15242 return Target.getLongAccumIBits();
15243 case BuiltinType::UShortAccum:
15244 case BuiltinType::SatUShortAccum:
15245 return Target.getUnsignedShortAccumIBits();
15246 case BuiltinType::UAccum:
15247 case BuiltinType::SatUAccum:
15248 return Target.getUnsignedAccumIBits();
15249 case BuiltinType::ULongAccum:
15250 case BuiltinType::SatULongAccum:
15251 return Target.getUnsignedLongAccumIBits();
15252 case BuiltinType::ShortFract:
15253 case BuiltinType::SatShortFract:
15254 case BuiltinType::Fract:
15255 case BuiltinType::SatFract:
15256 case BuiltinType::LongFract:
15257 case BuiltinType::SatLongFract:
15258 case BuiltinType::UShortFract:
15259 case BuiltinType::SatUShortFract:
15260 case BuiltinType::UFract:
15261 case BuiltinType::SatUFract:
15262 case BuiltinType::ULongFract:
15263 case BuiltinType::SatULongFract:
15268llvm::FixedPointSemantics
15271 "Can only get the fixed point semantics for a "
15272 "fixed point or integer type.");
15274 return llvm::FixedPointSemantics::GetIntegerSemantics(
15278 return llvm::FixedPointSemantics(
15281 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
15296 "Expected unsigned fixed point type");
15299 case BuiltinType::UShortAccum:
15301 case BuiltinType::UAccum:
15303 case BuiltinType::ULongAccum:
15305 case BuiltinType::SatUShortAccum:
15307 case BuiltinType::SatUAccum:
15309 case BuiltinType::SatULongAccum:
15311 case BuiltinType::UShortFract:
15313 case BuiltinType::UFract:
15315 case BuiltinType::ULongFract:
15317 case BuiltinType::SatUShortFract:
15319 case BuiltinType::SatUFract:
15321 case BuiltinType::SatULongFract:
15324 llvm_unreachable(
"Unexpected unsigned fixed point type");
15332 std::vector<std::string> BackendFeats;
15333 llvm::AArch64::ExtensionSet FeatureBits;
15334 for (StringRef F : FMVFeatStrings)
15335 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
15337 FeatureBits.enable(*FMVExt->ID);
15338 FeatureBits.toLLVMFeatureList(BackendFeats);
15339 return BackendFeats;
15344 assert(TD !=
nullptr);
15347 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
15348 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
15359 Target->getTargetOpts().CPU,
15360 Target->getTargetOpts().Features);
15367 StringRef TargetCPU = Target->getTargetOpts().CPU;
15369 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
15375 if (!Target->getTriple().isAArch64())
15378 Target->getTargetOpts().FeaturesAsWritten.begin(),
15379 Target->getTargetOpts().FeaturesAsWritten.end());
15390 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
15392 Target->getCPUSpecificCPUDispatchFeatures(
15394 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
15395 Features.insert(Features.begin(),
15396 Target->getTargetOpts().FeaturesAsWritten.begin(),
15397 Target->getTargetOpts().FeaturesAsWritten.end());
15398 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15399 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
15400 if (Target->getTriple().isAArch64()) {
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 (Target->getTriple().isRISCV()) {
15410 std::vector<std::string> Features;
15411 if (VersionStr !=
"default") {
15413 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15416 Features.insert(Features.begin(),
15417 Target->getTargetOpts().FeaturesAsWritten.begin(),
15418 Target->getTargetOpts().FeaturesAsWritten.end());
15419 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15420 }
else if (Target->getTriple().isOSAIX()) {
15421 std::vector<std::string> Features;
15423 if (VersionStr.starts_with(
"cpu="))
15424 TargetCPU = VersionStr.drop_front(
sizeof(
"cpu=") - 1);
15426 assert(VersionStr ==
"default");
15427 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15429 std::vector<std::string> Features;
15431 if (VersionStr.starts_with(
"arch="))
15432 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
15433 else if (VersionStr !=
"default")
15434 Features.push_back((StringRef{
"+"} + VersionStr).str());
15435 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15437 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
15438 std::vector<std::string> Features;
15439 if (Target->getTriple().isRISCV()) {
15441 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15444 assert(Target->getTriple().isAArch64());
15446 TV->getFeatures(Feats);
15449 Features.insert(Features.begin(),
15450 Target->getTargetOpts().FeaturesAsWritten.begin(),
15451 Target->getTargetOpts().FeaturesAsWritten.end());
15452 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15454 FeatureMap = Target->getTargetOpts().FeatureMap;
15465 auto DeviceDiscriminatorOverrider =
15467 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15469 return RD->getDeviceLambdaManglingNumber();
15470 return std::nullopt;
15473 Context, Context.getDiagnostics(), DeviceDiscriminatorOverrider)};
15481 std::string Buffer;
15482 Buffer.reserve(128);
15483 llvm::raw_string_ostream Out(Buffer);
15484 MC->mangleCanonicalTypeName(KernelNameType, Out);
15485 std::string KernelName = Out.str();
15487 return {KernelNameType, FD, KernelName};
15496 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15497 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15506 "SYCL kernel name conflict");
15521 return &IT->second;
15527 return *OMPTraitInfoVector.back();
15534 return DB << Section.
Decl;
15535 return DB <<
"a prior #pragma section";
15539 bool IsInternalVar =
15542 bool IsExplicitDeviceVar = (D->
hasAttr<CUDADeviceAttr>() &&
15543 !D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15544 (D->
hasAttr<CUDAConstantAttr>() &&
15545 !D->
getAttr<CUDAConstantAttr>()->isImplicit());
15549 return (IsInternalVar &&
15550 (D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15551 (D->
hasAttr<CUDAGlobalAttr>() &&
15558 (D->
hasAttr<HIPManagedAttr>() || D->
hasAttr<CUDAGlobalAttr>() ||
15563 if (!CUIDHash.empty())
15565 if (LangOpts.CUID.empty())
15566 return StringRef();
15567 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.CUID),
true);
15577 assert(PrimaryBase);
15580 auto Base = Layout.getPrimaryBase();
15581 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15583 PrimaryBase =
Base;
15585 return PrimaryBase;
15589 StringRef MangledName) {
15591 assert(
Method->isVirtual());
15592 bool DefaultIncludesPointerAuth =
15593 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15595 if (!DefaultIncludesPointerAuth)
15598 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15599 if (Existing != ThunksToBeAbbreviated.end())
15600 return Existing->second.contains(MangledName.str());
15603 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15605 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15607 for (
const auto &Thunk : *ThunkInfos) {
15609 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15615 Mangler->mangleThunk(
Method, Thunk,
true,
15618 llvm::raw_svector_ostream mangledNameStream(MangledName);
15622 mangledNameStream);
15624 Mangler->mangleThunk(
Method, Thunk,
false,
15625 mangledNameStream);
15627 Thunks[ElidedName].push_back(std::string(MangledName));
15630 llvm::StringSet<> SimplifiedThunkNames;
15631 for (
auto &ThunkList : Thunks) {
15632 llvm::sort(ThunkList.second);
15633 SimplifiedThunkNames.insert(ThunkList.second[0]);
15635 bool Result = SimplifiedThunkNames.contains(MangledName);
15636 ThunksToBeAbbreviated[VirtualMethodDecl] = std::move(SimplifiedThunkNames);
15654 std::vector<PFPField> &Fields,
bool IncludeVBases) {
15656 if (
auto *ElemDecl = AT->getElementType()->getAsCXXRecordDecl()) {
15658 for (
unsigned i = 0; i != AT->getSize(); ++i)
15675 Fields.push_back({FieldOffset, Field});
15682 if (
Base.isVirtual())
15689 if (IncludeVBases) {
15700 std::vector<PFPField> PFPFields;
15710 if (
auto *RD = dyn_cast<CXXRecordDecl>(FD->
getParent()))
15712 !FD->
hasAttr<NoFieldProtectionAttr>();
15717 auto *FD = dyn_cast<FieldDecl>(VD);
15740struct PaddingCalculator {
15741 PaddingCalculator(
const ASTContext &Ctx) : Ctx(Ctx) {}
15744 OccuppiedIntervals.clear();
15750 while (!Stack.empty()) {
15751 Data Current = Stack.back();
15755 MergeOccuppiedIntervals();
15758 llvm::SmallVector<ASTContext::BitInterval> GetPaddingIntervals() {
15759 llvm::SmallVector<ASTContext::BitInterval> Results;
15760 if (OccuppiedIntervals.size() == 1 &&
15761 OccuppiedIntervals.front().First == 0 &&
15762 OccuppiedIntervals.front().Last == TySizeInBits) {
15765 Results.reserve(OccuppiedIntervals.size() + 1);
15767 for (
const ASTContext::BitInterval &OccupiedInterval : OccuppiedIntervals) {
15768 if (OccupiedInterval.First > CurrentPos) {
15770 ASTContext::BitInterval{CurrentPos, OccupiedInterval.First});
15772 CurrentPos = OccupiedInterval.Last;
15774 if (TySizeInBits > CurrentPos) {
15775 Results.push_back(ASTContext::BitInterval{CurrentPos, TySizeInBits});
15784 bool VisitVirtualBase;
15810 uint64_t getScalarOccupiedSizeInBits(QualType Ty)
const {
15811 if (
const auto *BIT = Ty->
getAs<BitIntType>())
15812 return BIT->getNumBits();
15814 if (
const auto *BT = Ty->
getAs<BuiltinType>()) {
15815 if (BT->getKind() == BuiltinType::LongDouble &&
15817 &llvm::APFloat::x87DoubleExtended())
15818 return llvm::APFloat::getSizeInBits(
15825 void Visit(
const Data &D) {
15826 if (
auto *AT = dyn_cast<ConstantArrayType>(D.Ty)) {
15827 VisitArray(AT, D.StartBitOffset);
15831 if (
auto *
Record = D.Ty->getAsRecordDecl()) {
15832 VisitStruct(
Record, D.StartBitOffset, D.VisitVirtualBase);
15836 if (D.Ty->isAtomicType()) {
15837 auto Unwrapped = D;
15838 Unwrapped.Ty = D.Ty.getAtomicUnqualifiedType().getCanonicalType();
15839 Stack.push_back(Unwrapped);
15843 if (
const auto *
Complex = D.Ty->getAs<ComplexType>()) {
15844 VisitComplex(
Complex, D.StartBitOffset);
15848 if (
const auto *VT = D.Ty->getAs<clang::VectorType>()) {
15849 VisitVector(VT, D.StartBitOffset);
15853 uint64_t SizeBit = getScalarOccupiedSizeInBits(D.Ty);
15854 OccuppiedIntervals.push_back(
15855 ASTContext::BitInterval{D.StartBitOffset, D.StartBitOffset + SizeBit});
15858 void VisitArray(
const ConstantArrayType *AT, uint64_t StartBitOffset) {
15859 for (uint64_t ArrIndex = 0; ArrIndex < AT->
getSize().getLimitedValue();
15865 auto Offset = ElementSize.
alignTo(ElementAlign);
15867 Stack.push_back(
Data{
15868 StartBitOffset + ArrIndex * Offset.getQuantity() * Ctx.
getCharWidth(),
15873 void VisitStruct(
const RecordDecl *R, uint64_t StartBitOffset,
15874 bool VisitVirtualBase) {
15876 auto *
CXXRecord = dyn_cast<CXXRecordDecl>(R);
15882 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15883 StartBitOffset, StartBitOffset + PointerSizeInBits});
15888 auto StartVBPtr = StartBitOffset + Offset * Ctx.
getCharWidth();
15889 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15890 StartVBPtr, StartVBPtr + PointerSizeInBits});
15893 const auto VisitBase = [&ASTLayout, StartBitOffset,
this](
15894 const CXXBaseSpecifier &
Base,
auto GetOffset) {
15895 auto *BaseRecord =
Base.getType()->getAsCXXRecordDecl();
15900 std::invoke(GetOffset, ASTLayout, BaseRecord).getQuantity();
15904 Base.getType().getCanonicalType(),
15909 if (!
Base.isVirtual()) {
15914 if (VisitVirtualBase) {
15915 for (
auto VBase :
CXXRecord->vbases()) {
15921 for (
auto *Field :
R->fields()) {
15923 if (
Field->isUnnamedBitField())
15927 if (
Field->isBitField()) {
15928 OccuppiedIntervals.push_back(ASTContext::BitInterval{
15929 StartBitOffset + FieldOffset,
15930 StartBitOffset + FieldOffset +
Field->getBitWidthValue()});
15932 Stack.push_back(
Data{StartBitOffset + FieldOffset,
15933 Field->getType().getCanonicalType(),
15939 void VisitComplex(
const ComplexType *CT, uint64_t StartBitOffset) {
15943 auto ImgOffset = ElementSize.
alignTo(ElementAlign);
15946 Data{StartBitOffset, ElementQualType,
true});
15949 ElementQualType,
true});
15952 void VisitVector(
const clang::VectorType *VT, uint64_t StartBitOffset) {
15953 uint64_t SizeBit = [&]() -> uint64_t {
15959 OccuppiedIntervals.push_back(
15960 ASTContext::BitInterval{StartBitOffset, StartBitOffset + SizeBit});
15963 void MergeOccuppiedIntervals() {
15964 std::sort(OccuppiedIntervals.begin(), OccuppiedIntervals.end(),
15965 [](
const ASTContext::BitInterval &lhs,
15966 const ASTContext::BitInterval &rhs) {
15967 return std::tie(lhs.First, lhs.Last) <
15968 std::tie(rhs.First, rhs.Last);
15971 llvm::SmallVector<ASTContext::BitInterval> Merged;
15972 Merged.reserve(OccuppiedIntervals.size());
15974 for (
const ASTContext::BitInterval &NextInterval : OccuppiedIntervals) {
15975 if (Merged.empty()) {
15976 Merged.push_back(NextInterval);
15979 auto &LastInterval = Merged.back();
15981 if (NextInterval.First > LastInterval.Last) {
15982 Merged.push_back(NextInterval);
15984 LastInterval.Last = std::max(LastInterval.Last, NextInterval.Last);
15988 OccuppiedIntervals = Merged;
15991 const ASTContext &Ctx;
15994 llvm::SmallVector<Data> Stack;
15995 llvm::SmallVector<ASTContext::BitInterval> OccuppiedIntervals;
15999llvm::ArrayRef<ASTContext::BitInterval>
16002 auto cached = PaddingIntervalCache.find(Ty);
16003 if (cached != PaddingIntervalCache.end())
16004 return cached->second;
16006 PaddingCalculator pc{*
this};
16010 PaddingIntervalCache.insert_or_assign(Ty, pc.GetPaddingIntervals());
16011 assert(res &&
"Failed to insert?");
16013 return itr->second;
This file provides AST data structures related to concepts.
static void SortAndUniqueProtocols(SmallVectorImpl< ObjCProtocolDecl * > &Protocols)
static bool isCanonicalExceptionSpecification(const FunctionProtoType::ExceptionSpecInfo &ESI, bool NoexceptInType)
static SourceLocation getCommonAttrLoc(const T *X, const T *Y)
static auto getCanonicalTemplateArguments(const ASTContext &C, ArrayRef< TemplateArgument > Args, bool &AnyNonCanonArgs)
static char getObjCEncodingForPrimitiveType(const ASTContext *C, const BuiltinType *BT)
static bool isSameQualifier(const NestedNameSpecifier X, const NestedNameSpecifier Y)
static bool unionHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static TypedefDecl * CreateHexagonBuiltinVaListDecl(const ASTContext *Context)
#define CANONICAL_TYPE(Class)
static ElaboratedTypeKeyword getCommonTypeKeyword(const T *X, const T *Y, bool IsSame)
static Decl * getCommonDecl(Decl *X, Decl *Y)
static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context, const Decl *D, GVALinkage L)
static bool isTypeTypedefedAsBOOL(QualType T)
static void EncodeBitField(const ASTContext *Ctx, std::string &S, QualType T, const FieldDecl *FD)
static GVALinkage basicGVALinkageForVariable(const ASTContext &Context, const VarDecl *VD)
static QualType getCommonArrayElementType(const ASTContext &Ctx, const T *X, Qualifiers &QX, const T *Y, Qualifiers &QY)
#define SUGAR_FREE_TYPE(Class)
static SYCLKernelInfo BuildSYCLKernelInfo(ASTContext &Context, CanQualType KernelNameType, const FunctionDecl *FD)
static bool hasTemplateSpecializationInEncodedString(const Type *T, bool VisitBasesAndFields)
static void getIntersectionOfProtocols(ASTContext &Context, const ObjCInterfaceDecl *CommonBase, const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, SmallVectorImpl< ObjCProtocolDecl * > &IntersectionSet)
getIntersectionOfProtocols - This routine finds the intersection of set of protocols inherited from t...
static bool areCompatMatrixTypes(const ConstantMatrixType *LHS, const ConstantMatrixType *RHS)
areCompatMatrixTypes - Return true if the two specified matrix types are compatible.
static TypedefDecl * CreateAAPCSABIBuiltinVaListDecl(const ASTContext *Context)
static bool sameObjCTypeArgs(ASTContext &ctx, const ObjCInterfaceDecl *iface, ArrayRef< QualType > lhsArgs, ArrayRef< QualType > rhsArgs, bool stripKindOf)
static bool canAssignObjCObjectTypes(ASTContext &ctx, QualType lhs, QualType rhs)
Determine whether the first type is a subtype of the second.
static const Type * getIntegerTypeForEnum(const EnumType *ET)
static SmallVector< SourceLocation, 2 > getLocsForCommentSearch(ASTContext::RawCommentLookupKey Key, SourceManager &SourceMgr)
static bool hasSameCudaAttrs(const FunctionDecl *A, const FunctionDecl *B)
static TemplateName getCommonTemplateName(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced=false)
static int CmpProtocolNames(ObjCProtocolDecl *const *LHS, ObjCProtocolDecl *const *RHS)
CmpProtocolNames - Comparison predicate for sorting protocols alphabetically.
static auto * getCommonSizeExpr(const ASTContext &Ctx, T *X, T *Y)
static TypedefDecl * CreatePowerABIBuiltinVaListDecl(const ASTContext *Context)
static auto getCommonSizeModifier(const ArrayType *X, const ArrayType *Y)
static TemplateArgument getCommonTemplateArgument(const ASTContext &Ctx, const TemplateArgument &X, const TemplateArgument &Y)
static std::optional< int64_t > structHasUniqueObjectRepresentations(const ASTContext &Context, const RecordDecl *RD, bool CheckIfTriviallyCopyable)
static bool hasSameOverloadableAttrs(const FunctionDecl *A, const FunctionDecl *B)
Determine whether the attributes we can overload on are identical for A and B.
static T * getCommonDeclChecked(T *X, T *Y)
static NestedNameSpecifier getCommonNNS(const ASTContext &Ctx, NestedNameSpecifier NNS1, NestedNameSpecifier NNS2, bool IsSame)
Returns a NestedNameSpecifier which has only the common sugar present in both NNS1 and NNS2.
static TypedefDecl * CreateVoidPtrBuiltinVaListDecl(const ASTContext *Context)
static int64_t getSubobjectOffset(const FieldDecl *Field, const ASTContext &Context, const clang::ASTRecordLayout &)
static QualType getCommonSugarTypeNode(const ASTContext &Ctx, const Type *X, const Type *Y, SplitQualType Underlying)
static TypedefDecl * CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X, Qualifiers &QX, const Type *Y, Qualifiers &QY)
static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET, QualType other, bool isBlockReturnType)
Given that we have an enum type and a non-enum type, try to merge them.
static GVALinkage adjustGVALinkageForExternalDefinitionKind(const ASTContext &Ctx, const Decl *D, GVALinkage L)
Adjust the GVALinkage for a declaration based on what an external AST source knows about whether ther...
static TypedefDecl * CreateSystemZBuiltinVaListDecl(const ASTContext *Context)
static std::optional< int64_t > getSubobjectSizeInBits(const FieldDecl *Field, const ASTContext &Context, bool CheckIfTriviallyCopyable)
static GVALinkage basicGVALinkageForFunction(const ASTContext &Context, const FunctionDecl *FD)
#define NON_UNIQUE_TYPE(Class)
static TypedefDecl * CreateX86_64ABIBuiltinVaListDecl(const ASTContext *Context)
static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI, const LangOptions &LangOpts)
static ElaboratedTypeKeyword getCanonicalElaboratedTypeKeyword(ElaboratedTypeKeyword Keyword)
static QualType getCommonPointeeType(const ASTContext &Ctx, const T *X, const T *Y)
static auto getCommonIndexTypeCVRQualifiers(const ArrayType *X, const ArrayType *Y)
static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequiresICE, bool AllowTypeModifiers)
DecodeTypeFromStr - This decodes one type descriptor from Str, advancing the pointer over the consume...
static TypedefDecl * CreateCharPtrBuiltinVaListDecl(const ASTContext *Context)
static bool areSortedAndUniqued(ArrayRef< ObjCProtocolDecl * > Protocols)
static TypeInfoChars getConstantArrayInfoInChars(const ASTContext &Context, const ConstantArrayType *CAT)
getConstantArrayInfoInChars - Performing the computation in CharUnits instead of in bits prevents ove...
static FloatingRank getFloatingRank(QualType T)
getFloatingRank - Return a relative rank for floating point types.
static bool getCommonTemplateArguments(const ASTContext &Ctx, SmallVectorImpl< TemplateArgument > &R, ArrayRef< TemplateArgument > Xs, ArrayRef< TemplateArgument > Ys)
static TypedefDecl * CreateXtensaABIBuiltinVaListDecl(const ASTContext *Context)
static QualType getCommonElementType(const ASTContext &Ctx, const T *X, const T *Y)
static void mergeTypeLists(const ASTContext &Ctx, SmallVectorImpl< QualType > &Out, ArrayRef< QualType > X, ArrayRef< QualType > Y)
static bool matchesPostDecrInWhile(const UnaryOperator *UO, ASTContext &Ctx)
For the purposes of overflow pattern exclusion, does this match the while(i–) pattern?
static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx, raw_ostream &OS, QualType QT)
Encode a function type for use in the discriminator of a function pointer type.
static std::optional< int64_t > structSubobjectsHaveUniqueObjectRepresentations(const RangeT &Subobjects, int64_t CurOffsetInBits, const ASTContext &Context, const clang::ASTRecordLayout &Layout, bool CheckIfTriviallyCopyable)
static uint64_t getRVVTypeSize(ASTContext &Context, const BuiltinType *Ty)
getRVVTypeSize - Return RVV vector register size.
static auto unwrapSugar(SplitQualType &T, Qualifiers &QTotal)
static TemplateName getCommonTemplateNameChecked(const ASTContext &Ctx, TemplateName X, TemplateName Y, bool IgnoreDeduced)
static int compareObjCProtocolsByName(ObjCProtocolDecl *const *lhs, ObjCProtocolDecl *const *rhs)
Comparison routine for Objective-C protocols to be used with llvm::array_pod_sort.
static std::string charUnitsToString(const CharUnits &CU)
static const TagDecl * getNonInjectedClassName(const TagDecl *TD)
static TypedefDecl * CreateZOSVaListDecl(const ASTContext *Context)
static bool hasAnyPackExpansions(ArrayRef< TemplateArgument > Args)
static char ObjCEncodingForEnumDecl(const ASTContext *C, const EnumDecl *ED)
static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod, SmallVectorImpl< const NamedDecl * > &Redeclared)
static QualType getCommonTypeWithQualifierLifting(const ASTContext &Ctx, QualType X, QualType Y, Qualifiers &QX, Qualifiers &QY)
static auto getCommonTypes(const ASTContext &Ctx, ArrayRef< QualType > Xs, ArrayRef< QualType > Ys, bool Unqualified=false)
static bool isCanonicalResultType(QualType T)
Determine whether T is canonical as the result type of a function.
static TypedefDecl * CreateMSVaListDecl(const ASTContext *Context)
static bool areCompatVectorTypes(const VectorType *LHS, const VectorType *RHS)
areCompatVectorTypes - Return true if the two specified vector types are compatible.
static TypedefDecl * CreateCharPtrNamedVaListDecl(const ASTContext *Context, StringRef Name)
static NestedNameSpecifier getCommonQualifier(const ASTContext &Ctx, const T *X, const T *Y, bool IsSame)
#define UNEXPECTED_TYPE(Class, Kind)
static TypedefDecl * CreateVaListDecl(const ASTContext *Context, TargetInfo::BuiltinVaListKind Kind)
static bool primaryBaseHaseAddressDiscriminatedVTableAuthentication(const ASTContext &Context, const CXXRecordDecl *Class)
static std::vector< std::string > getFMVBackendFeaturesFor(const llvm::SmallVectorImpl< StringRef > &FMVFeatStrings)
Defines the clang::ASTContext interface.
#define BuiltinTemplate(BTName)
Provides definitions for the various language-specific address spaces.
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
Defines enum values for all the target-independent builtin functions.
static bool CanThrow(Expr *E, ASTContext &Ctx)
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static const Decl * getCanonicalDecl(const Decl *D)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
Defines the clang::Module class, which describes a module in the source code.
static StringRef getTriple(const Command &Job)
Defines types useful for describing an Objective-C runtime.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
static QualType getUnderlyingType(const SubRegion *R)
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
RawComment * getRawCommentNoCacheImpl(RawCommentLookupKey Key, const SourceLocation RepresentativeLoc, const std::map< unsigned, RawComment * > &CommentsInFile) const
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
bool isMemberPointerToDerivedMember() const
const ValueDecl * getMemberPointerDecl() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const
Returns true, if given type has a known lifetime.
MSGuidDecl * getMSGuidDecl(MSGuidDeclParts Parts) const
Return a declaration for the global GUID object representing the given GUID value.
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl, const ObjCMethodDecl *MethodImp)
CanQualType ObjCBuiltinSelTy
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
void InitBuiltinTypes(const TargetInfo &Target, const TargetInfo *AuxTarget=nullptr)
Initialize built-in types.
ParentMapContext & getParentMapContext()
Returns the dynamic AST node parent map context.
QualType getParenType(QualType NamedType) const
size_t getSideTableAllocatedMemory() const
Return the total memory used for various side tables.
MemberSpecializationInfo * getInstantiatedFromStaticDataMember(const VarDecl *Var)
If this variable is an instantiated static data member of a class template specialization,...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
CanQualType ARCUnbridgedCastTy
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, QualType Wrapped) const
llvm::DenseMap< const Decl *, comments::FullComment * > ParsedComments
Mapping from declarations to parsed comments attached to any redeclaration.
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
unsigned getIntWidth(QualType T) const
CanQualType getCanonicalParamType(QualType T) const
Return the canonical parameter type corresponding to the specific potentially non-canonical one.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
InlineVariableDefinitionKind
@ None
Not an inline variable.
@ Weak
Weak definition of inline variable.
@ Strong
Strong definition.
@ WeakUnknown
Weak for now, might become strong later in this TU.
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
TypedefDecl * getCFConstantStringDecl() const
CanQualType SatUnsignedFractTy
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
ExternCContextDecl * getExternCContextDecl() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
CanQualType UnsignedShortAccumTy
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
bool isPFPField(const FieldDecl *Field) const
QualType adjustFunctionResultType(QualType FunctionType, QualType NewResultType)
Change the result type of a function type, preserving sugar such as attributed types.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
QualType getCanonicalTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > CanonicalArgs) const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
QualType 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.
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
RawComment * getRawCommentNoCache(RawCommentLookupKey Key) const
Return the documentation comment attached to a given declaration or macro, without looking into cache...
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
unsigned NumImplicitCopyAssignmentOperatorsDeclared
The number of implicitly-declared copy assignment operators for which declarations were built.
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
unsigned getTypeUnadjustedAlign(QualType T) const
Return the ABI-specified natural alignment of a (complete) type T, before alignment adjustments,...
unsigned char getFixedPointIBits(QualType Ty) const
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
IntrusiveRefCntPtr< ExternalASTSource > ExternalSource
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes, bool OrNull, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
unsigned NumImplicitDestructorsDeclared
The number of implicitly-declared destructors for which declarations were built.
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
bool ObjCQualifiedClassTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS)
ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and Class<pr1, ...>.
bool shouldExternalize(const Decl *D) const
Whether a C++ static variable or CUDA/HIP kernel should be externalized.
bool propertyTypesAreCompatible(QualType, QualType)
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc, VectorKind VecKind) const
Return the unique reference to the type for a dependently sized vector of the specified element type.
CanQualType SatLongAccumTy
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
OpenCLTypeKind getOpenCLTypeKind(const Type *T) const
Map an AST Type to an OpenCLTypeKind enum value.
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const
Put the string version of the type qualifiers QT into S.
unsigned getPreferredTypeAlign(QualType T) const
Return the "preferred" alignment of the specified type T for the current target, in bits.
std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, bool Extended=false) const
Emit the encoded type for the method declaration Decl into S.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
CanQualType OMPArrayShapingTy
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins, TranslationUnitKind TUKind)
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
std::string getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
getObjCEncodingForPropertyDecl - Return the encoded type for this method declaration.
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
unsigned getStaticLocalNumber(const VarDecl *VD) const
void addComment(const RawComment &RC)
void getLegacyIntegralTypeEncoding(QualType &t) const
getLegacyIntegralTypeEncoding - Another legacy compatibility encoding: 32-bit longs are encoded as 'l...
bool isSameTypeConstraint(const TypeConstraint *XTC, const TypeConstraint *YTC) const
Determine whether two type contraint are similar enough that they could used in declarations of the s...
void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo)
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=RecordDecl::TagKind::Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
CanQualType UnsignedLongFractTy
QualType mergeTagDefinitions(QualType, QualType)
void setClassMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
void setIsTypeAwareOperatorNewOrDelete(const FunctionDecl *FD, bool IsTypeAware)
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const
Return a dependent bit-precise integer type with the specified signedness and bit count.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
StringRef getCUIDHash() const
bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const
Returns true if this is an inline-initialized static data member which is treated as a definition for...
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const
Determine whether two function types are the same, ignoring exception specifications in cases where t...
QualType getBlockDescriptorExtendedType() const
Gets the struct used to keep track of the extended descriptor for pointer to blocks.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent) const
llvm::PointerUnion< const Decl *, const MacroInfo * > RawCommentLookupKey
Key used to look up the raw comment attached to a declaration or macro.
void addLazyModuleInitializers(Module *M, ArrayRef< GlobalDeclID > IDs)
bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
bool BlockRequiresCopying(QualType Ty, const VarDecl *D)
Returns true iff we need copy/dispose helpers for the given type.
QualType getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
std::optional< QualType > tryMergeOverflowBehaviorTypes(QualType LHS, QualType RHS, bool OfBlockPointer, bool Unqualified, bool BlockReturnType, bool IsConditionalOperator)
Attempts to merge two types that may be OverflowBehaviorTypes.
CanQualType OMPIteratorTy
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
QualType getFunctionTypeWithoutPtrSizes(QualType T)
Get a function type and produce the equivalent function type where pointer size address spaces in the...
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
SelectorTable & Selectors
bool isTypeIgnoredBySanitizer(const SanitizerMask &Mask, const QualType &Ty) const
Check if a type can have its sanitizer instrumentation elided based on its presence within an ignorel...
unsigned getMinGlobalAlignOfVar(uint64_t Size, const VarDecl *VD) const
Return the minimum alignment as specified by the target.
RawCommentList Comments
All comments in this translation unit.
bool isSameDefaultTemplateArgument(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two default template arguments are similar enough that they may be used in declarat...
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType getLateParsedAttrType(QualType Wrapped, LateParsedTypeAttribute *LateParsedAttr) const
Return a placeholder type for a late-parsed type attribute.
QualType removePtrSizeAddrSpace(QualType T) const
Remove the existing address space on the type if it is a pointer size address space and return the ty...
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
llvm::ArrayRef< BitInterval > getPaddingIntervals(QualType Ty) const
CanQualType SatShortFractTy
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
bool canBindObjCObjectType(QualType To, QualType From)
TemplateTemplateParmDecl * insertCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *CanonTTP) const
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const
Compare the rank of two floating point types as above, but compare equal if both types have the same ...
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
void setParameterIndex(const ParmVarDecl *D, unsigned index)
Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
CanQualType getCanonicalSizeType() const
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl, StringRef MangledName)
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::SetVector< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
CanQualType ArraySectionTy
CanQualType ObjCBuiltinIdTy
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
VTableContextBase * getVTableContext()
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const
ObjCPropertyImplDecl * getObjCPropertyImplDeclForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container) const
bool isNearlyEmpty(const CXXRecordDecl *RD) const
PointerAuthQualifier getObjCMemberSelTypePtrAuth()
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getCFConstantStringType() const
Return the C structure type used to represent constant CFStrings.
void eraseDeclAttrs(const Decl *D)
Erase the attributes corresponding to the given declaration.
UsingEnumDecl * getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst)
If the given using-enum decl Inst is an instantiation of another using-enum decl, return it.
RecordDecl * getCFConstantStringTagDecl() const
std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const
Emit the encoded type for the function Decl into S.
TypeSourceInfo * getTemplateSpecializationTypeInfo(ElaboratedTypeKeyword Keyword, SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Canon=QualType()) const
CanQualType UnsignedFractTy
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
QualType mergeFunctionParameterTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeFunctionParameterTypes - merge two types which appear as function parameter types
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
TemplateTemplateParmDecl * findCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *TTP) const
const TargetInfo * getAuxTargetInfo() const
CanQualType ObjCBuiltinClassTy
unsigned NumImplicitDefaultConstructorsDeclared
The number of implicitly-declared default constructors for which declarations were built.
CanQualType UnresolvedTemplateTy
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
friend class CXXRecordDecl
CanQualType UnsignedLongTy
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized,...
bool computeBestEnumTypes(bool IsPacked, unsigned NumNegativeBits, unsigned NumPositiveBits, QualType &BestType, QualType &BestPromotionType)
Compute BestType and BestPromotionType for an enum based on the highest number of negative and positi...
llvm::APFixedPoint getFixedPointMin(QualType Ty) const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType adjustType(QualType OldType, llvm::function_ref< QualType(QualType)> Adjust) const
Rebuild a type, preserving any existing type sugar.
void addedLocalImportDecl(ImportDecl *Import)
Notify the AST context that a new import declaration has been parsed or implicitly created within thi...
const TranslationUnitKind TUKind
CanQualType UnsignedLongAccumTy
QualType AutoRRefDeductTy
RawComment * getRawCommentNoCacheImpl(RawCommentLookupKey Key, const SourceLocation RepresentativeLoc, const std::map< unsigned, RawComment * > &CommentsInFile) const
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length.
QualType getCorrespondingSaturatedType(QualType Ty) const
bool arePFPFieldsTriviallyCopyable(const RecordDecl *RD) const
Returns whether this record's PFP fields (if any) are trivially copyable (i.e.
bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const
Determine whether the two declarations refer to the same entity.
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl, unsigned Index, bool Final, const TemplateArgument &ArgPack)
CanQualType BoundMemberTy
CanQualType SatUnsignedShortFractTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
bool hasSameFunctionTypeIgnoringParamABI(QualType T, QualType U) const
Determine if two function types are the same, ignoring parameter ABI annotations.
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
unsigned getOpenMPDefaultSimdAlign(QualType T) const
Get default simd alignment of the specified complete type in bits.
QualType getObjCSuperType() const
Returns the C struct type for objc_super.
QualType getBlockDescriptorType() const
Gets the struct used to keep track of the descriptor for pointer to blocks.
bool CommentsLoaded
True if comments are already loaded from ExternalASTSource.
BlockVarCopyInit getBlockVarCopyInit(const VarDecl *VD) const
Get the copy initialization expression of the VarDecl VD, or nullptr if none exists.
QualType getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size, uint32_t Alignment, ArrayRef< SpirvOperand > Operands)
unsigned NumImplicitMoveConstructorsDeclared
The number of implicitly-declared move constructors for which declarations were built.
bool isInSameModule(const Module *M1, const Module *M2) const
If the two module M1 and M2 are in the same module.
unsigned NumImplicitCopyConstructorsDeclared
The number of implicitly-declared copy constructors for which declarations were built.
QualType getLeastIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
CanQualType PseudoObjectTy
QualType getWebAssemblyExternrefType() const
Return a WebAssembly externref type.
void setTraversalScope(const std::vector< Decl * > &)
CharUnits getTypeUnadjustedAlignInChars(QualType T) const
getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, in characters,...
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
friend class NestedNameSpecifier
MangleContext * cudaNVInitDeviceMC()
unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const
Return the alignment in bits that should be given to a global variable with type T.
bool areCompatibleOverflowBehaviorTypes(QualType LHS, QualType RHS)
Return true if two OverflowBehaviorTypes are compatible for assignment.
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
unsigned NumImplicitDestructors
The number of implicitly-declared destructors.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
MangleContext * createDeviceMangleContext(const TargetInfo &T)
Creates a device mangle context to correctly mangle lambdas in a mixed architecture compile by settin...
CharUnits getExnObjectAlignment() const
Return the alignment (in bytes) of the thrown exception object.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ASTMutationListener * Listener
CanQualType ObjCBuiltinBoolTy
TypeInfoChars getTypeInfoInChars(const Type *T) const
QualType getPredefinedSugarType(PredefinedSugarType::Kind KD) const
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
TemplateParamObjectDecl * getTemplateParamObjectDecl(QualType T, const APValue &V) const
Return the template parameter object of the given type with the given value.
interp::Context & getInterpContext() const
Returns the clang bytecode interpreter context.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
TemplateTemplateParmDecl * getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const
Canonicalize the given TemplateTemplateParmDecl.
CanQualType OCLClkEventTy
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
bool hasPFPFields(QualType Ty) const
const clang::PrintingPolicy & getPrintingPolicy() const
void ResetObjCLayout(const ObjCInterfaceDecl *D)
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
void setCtorClosureDefaultArgs(const CXXConstructorDecl *CD, ArrayRef< CXXDefaultArgExpr * > Args)
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
CharUnits getAlignOfGlobalVarInChars(QualType T, const VarDecl *VD) const
Return the alignment in characters that should be given to a global variable with type T.
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists.
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, UnsignedOrNone Index=std::nullopt) const
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
llvm::PointerUnion< VarTemplateDecl *, MemberSpecializationInfo * > TemplateOrSpecializationInfo
A type synonym for the TemplateOrInstantiation mapping.
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getObjCIdType() const
Represents the Objective-CC id type.
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
QualType getUnsignedWCharType() const
Return the type of "unsigned wchar_t".
QualType getFunctionTypeWithoutParamABIs(QualType T) const
Get or construct a function type that is equivalent to the input type except that the parameter ABI a...
QualType getCorrespondingUnsaturatedType(QualType Ty) const
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl) const
unsigned getTargetDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
llvm::DenseMap< CanQualType, SYCLKernelInfo > SYCLKernels
Map of SYCL kernels indexed by the unique type used to name the kernel.
bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y) const
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
bool isDestroyingOperatorDelete(const FunctionDecl *FD) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
unsigned NumImplicitDefaultConstructors
The number of implicitly-declared default constructors.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::iterator_range< overridden_cxx_method_iterator > overridden_method_range
unsigned NumImplicitMoveAssignmentOperatorsDeclared
The number of implicitly-declared move assignment operators for which declarations were built.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
CanQualType UnsignedCharTy
CanQualType UnsignedShortFractTy
BuiltinTemplateDecl * buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const
void * Allocate(size_t Size, unsigned Align=8) const
ArrayRef< ExplicitInstantiationDecl * > getExplicitInstantiationDecls(const NamedDecl *Spec) const
Get all ExplicitInstantiationDecls for a given specialization.
bool canBuiltinBeRedeclared(const FunctionDecl *) const
Return whether a declaration to a builtin is allowed to be overloaded/redeclared.
CanQualType UnsignedIntTy
unsigned NumImplicitMoveConstructors
The number of implicitly-declared move constructors.
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols) const
void getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT, QualType T, std::string &S, bool Extended) const
getObjCEncodingForMethodParameter - Return the encoded type for a single method parameter or return t...
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const
Return the encoded type for this block declaration.
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
bool isSameAssociatedConstraint(const AssociatedConstraint &ACX, const AssociatedConstraint &ACY) const
Determine whether two 'requires' expressions are similar enough that they may be used in re-declarati...
QualType getExceptionObjectType(QualType T) const
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Note that the static data member Inst is an instantiation of the static data member template Tmpl of ...
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl)
ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's protocol list adopt all protocols in Q...
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType OCLReserveIDTy
bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const
Determine whether two template parameters are similar enough that they may be used in declarations of...
void registerSYCLEntryPointFunction(FunctionDecl *FD)
Generates and stores SYCL kernel metadata for the provided SYCL kernel entry point function.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
CanQualType UnsignedShortTy
FunctionDecl * getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, OperatorDeleteKind K) const
unsigned getTypeAlignIfKnown(QualType T, bool NeedsPreferredAlignment=false) const
Return the alignment of a type, in bits, or 0 if the type is incomplete and we cannot determine the a...
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may both be array types with the same bound (or both be array types ...
bool isRepresentableIntegerValue(llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
llvm::DenseMap< RawCommentLookupKey, const RawComment * > RawComments
Mapping from declaration or macro to directly attached comment.
const SYCLKernelInfo & getSYCLKernelInfo(QualType T) const
Given a type used as a SYCL kernel name, returns a reference to the metadata generated from the corre...
bool canAssignObjCInterfacesInBlockPointer(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, bool BlockReturnType)
canAssignObjCInterfacesInBlockPointer - This routine is specifically written for providing type-safet...
CanQualType SatUnsignedLongFractTy
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD)
QualType getDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttrLoc) const
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
CanQualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
const ObjCInterfaceDecl * getObjContainingInterface(const NamedDecl *ND) const
Returns the Objective-C interface that ND belongs to if it is an Objective-C method/property/ivar etc...
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
CanQualType getCanonicalUnresolvedUsingType(const UnresolvedUsingTypenameDecl *D) const
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
llvm::APFixedPoint getFixedPointMax(QualType Ty) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool classMaybeNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
QualType getTemplateTypeParmType(int Depth, int Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const
Recurses in pointer/array types until it finds an Objective-C retainable type and returns its ownersh...
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
void deduplicateMergedDefinitionsFor(NamedDecl *ND)
Clean up the merged definition list.
DiagnosticsEngine & getDiagnostics() const
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void recordOffsetOfEvaluation(const OffsetOfExpr *E)
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
QualType getUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D) const
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
void getOverriddenMethods(const NamedDecl *Method, SmallVectorImpl< const NamedDecl * > &Overridden) const
Return C++ or ObjC overridden methods for the given Method.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y, bool IgnoreDeduced=false) const
Determine whether the given template names refer to the same template.
CanQualType SatLongFractTy
const TargetInfo & getTargetInfo() const
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
OBTAssignResult checkOBTAssignmentCompatibility(QualType LHS, QualType RHS)
Check overflow behavior type compatibility for assignments.
CanQualType SatShortAccumTy
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
unsigned NumImplicitCopyConstructors
The number of implicitly-declared copy constructors.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
void addExplicitInstantiationDecl(const NamedDecl *Spec, ExplicitInstantiationDecl *EID)
Add an ExplicitInstantiationDecl for a given specialization.
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
CanQualType IncompleteMatrixIdxTy
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
CanQualType getNSIntegerType() const
QualType getCorrespondingUnsignedType(QualType T) const
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
TargetCXXABI::Kind getCXXABIKind() const
Return the C++ ABI kind that should be used.
QualType getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
CanQualType SatUnsignedLongAccumTy
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
CanQualType getCanonicalTagType(const TagDecl *TD) const
bool isSameTemplateArgument(const TemplateArgument &Arg1, const TemplateArgument &Arg2) const
Determine whether the given template arguments Arg1 and Arg2 are equivalent.
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getCorrespondingSignedType(QualType T) const
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
llvm::DenseMap< const Decl *, const Decl * > CommentlessRedeclChains
Keeps track of redeclaration chains that don't have any comment attached.
uint64_t getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE) const
Return number of elements initialized in an ArrayInitLoopExpr.
unsigned getTargetAddressSpace(LangAS AS) const
std::vector< PFPField > findPFPFields(QualType Ty) const
Returns a list of PFP fields for the given type, including subfields in bases or other fields,...
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
void addTranslationUnitDecl()
void getObjCEncodingForPropertyType(QualType T, std::string &S) const
Emit the Objective-C property type encoding for the given type T into S.
unsigned NumImplicitCopyAssignmentOperators
The number of implicitly-declared copy assignment operators.
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
CollectInheritedProtocols - Collect all protocols in current class and those inherited by it.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
llvm::DenseMap< const Decl *, const Decl * > RedeclChainComments
Mapping from canonical declaration to the first redeclaration in chain that has a comment attached.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
std::optional< CXXRecordDeclRelocationInfo > getRelocationInfoForCXXRecord(const CXXRecordDecl *) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
InlineVariableDefinitionKind getInlineVariableDefinitionKind(const VarDecl *VD) const
Determine whether a definition of this inline variable should be treated as a weak or strong definiti...
const RawComment * getRawCommentForAnyRedecl(RawCommentLookupKey Key, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration or macro.
TemplateName getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
CanQualType getUIntMaxType() const
Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in <stdint.h>.
CharUnits getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const
Loading virtual member pointers using the virtual inheritance model always results in an adjustment u...
LangAS getLangASForBuiltinAddressSpace(unsigned AS) const
bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U)
Determine whether two function types are the same, ignoring pointer sizes in the return type and para...
void addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor, FunctionDecl *OperatorDelete, OperatorDeleteKind K) const
unsigned char getFixedPointScale(QualType Ty) const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
QualType DecodeTypeStr(const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequireICE, bool AllowTypeModifiers) const
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
@ GE_Missing_type
Missing a type.
QualType adjustStringLiteralBaseType(QualType StrLTy) const
uint16_t getPointerAuthTypeDiscriminator(QualType T)
Return the "other" type-specific discriminator for the given type.
llvm::SetVector< const FieldDecl * > PFPFieldsWithEvaluatedOffset
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD, bool IsVTTEntry)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers using the ...
bool canonicalizeTemplateArguments(MutableArrayRef< TemplateArgument > Args) const
Canonicalize the given template argument list.
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
bool isUnaryOverflowPatternExcluded(const UnaryOperator *UO)
QualType getSignedWCharType() const
Return the type of "signed wchar_t".
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
TemplateName getDeducedTemplateName(TemplateName Underlying, DefaultArguments DefaultArgs) const
Represents a TemplateName which had some of its default arguments deduced.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
CanQualType UnsignedAccumTy
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
void cacheRawComment(RawCommentLookupKey Original, const RawComment &Comment) const
Attaches Comment to Original (a declaration or macro), and to its redeclaration chain when Original i...
QualType getVariableArrayDecayedType(QualType Ty) const
Returns a vla type where known sizes are replaced with [*].
void setCFConstantStringType(QualType T)
const SYCLKernelInfo * findSYCLKernelInfo(QualType T) const
Returns a pointer to the metadata generated from the corresponding SYCLkernel entry point if the prov...
unsigned getParameterIndex(const ParmVarDecl *D) const
Used by ParmVarDecl to retrieve on the side the index of the parameter when it exceeds the size of th...
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false) const
void AddDeallocation(void(*Callback)(void *), void *Data) const
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
AttrVec & getDeclAttrs(const Decl *D)
Retrieve the attributes for the given declaration.
QualType getDeducedTemplateSpecializationType(DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword, TemplateName Template) const
C++17 deduced class template specialization type.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
QualType mergeTransparentUnionType(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false)
mergeTransparentUnionType - if T is a transparent union type and a member of T is compatible with Sub...
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
bool isSentinelNullExpr(const Expr *E)
CanQualType getNSUIntegerType() const
void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying)
TypedefDecl * getBuiltinZOSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_zos_va_list type.
void recordMemberDataPointerEvaluation(const ValueDecl *VD)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
unsigned NumImplicitMoveAssignmentOperators
The number of implicitly-declared move assignment operators.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
virtual ~ASTMutationListener()
virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType)
A function's return type has been deduced.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool hasOwnVFPtr() const
hasOwnVFPtr - Does this class provide its own virtual-function table pointer, rather than inheriting ...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
bool hasOwnVBPtr() const
hasOwnVBPtr - Does this class provide its own virtual-base table pointer, rather than inheriting one ...
CharUnits getSize() const
getSize - Get the record size in characters.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getVBPtrOffset() const
getVBPtrOffset - Get the offset for virtual base table pointer.
CharUnits getDataSize() const
getDataSize() - Get the record data size, which is the record size without tail padding,...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
CharUnits getUnadjustedAlignment() const
getUnadjustedAlignment - Get the record alignment in characters, before alignment adjustment.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
void Profile(llvm::FoldingSetNodeID &ID)
Represents a loop initializing the elements of an array.
llvm::APInt getArraySize() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
A structure for storing the information associated with a name that has been assumed to be a template...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
void Profile(llvm::FoldingSetNodeID &ID)
Attr - This represents one attribute.
A fixed int type of a specified bitwidth.
void Profile(llvm::FoldingSetNodeID &ID) const
unsigned getNumBits() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
void Profile(llvm::FoldingSetNodeID &ID)
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
This class is used for builtin types like 'int'.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Implements C++ ABI-specific semantic analysis functions.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
CXXRecordDecl * getDefinition() const
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool isDynamicClass() const
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
SplitQualType split() const
static CanQual< Type > CreateUnsafe(QualType Other)
QualType withConst() const
Retrieves a version of this type with const applied.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isPositive() const
isPositive - Test whether the quantity is greater than zero.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CharUnits alignTo(const CharUnits &Align) const
alignTo - Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is ...
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
void Profile(llvm::FoldingSetNodeID &ID)
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Represents the canonical version of C arrays with a specified constant size.
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
void Profile(llvm::FoldingSetNodeID &ID)
unsigned getNumRows() const
Returns the number of rows in the matrix.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
Decl::Kind getDeclKind() const
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isModuleLocal() const
Whether this declaration was a local declaration to a C++20 named module.
ASTContext & getASTContext() const LLVM_READONLY
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.
virtual void CompleteRedeclChain(const Decl *D)
Gives the external AST source an opportunity to complete the redeclaration chain for a declaration.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
unsigned getBitWidthValue() const
Computes the bit width of this field, if this is a bit field.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool isMSExternInline() const
The combination of the extern and inline keywords under MSVC forces the function to be required.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
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.
void Profile(llvm::FoldingSetNodeID &ID)
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
Represents one property declaration in an Objective-C interface.
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
SetterKind getSetterKind() const
getSetterKind - Return the method used for doing assignment in the property setter.
Selector getSetterName() const
Selector getGetterName() const
ObjCPropertyAttribute::Kind getPropertyAttributes() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
ObjCIvarDecl * getPropertyIvarDecl() const
Represents an Objective-C protocol declaration.
protocol_range protocols() const
bool isGNUFamily() const
Is this runtime basically of the GNU family of runtimes?
Represents the declaration of an Objective-C type parameter.
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
const OffsetOfNode & getComponent(unsigned Idx) const
unsigned getNumComponents() const
Helper class for OffsetOfExpr.
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
Sugar for parentheses used when specifying types.
void Profile(llvm::FoldingSetNodeID &ID)
void clear()
Clear parent maps.
DynTypedNodeList getParents(const NodeT &Node)
Returns the parents of the given node (within the traversal scope).
Represents a parameter to a function.
ObjCDeclQualifier getObjCDeclQualifier() const
QualType getOriginalType() const
ParsedAttr - Represents a syntactic attribute.
void Profile(llvm::FoldingSetNodeID &ID)
Pointer-authentication qualifiers.
static PointerAuthQualifier Create(unsigned Key, bool IsAddressDiscriminated, unsigned ExtraDiscriminator, PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer, bool AuthenticatesNullValues)
bool isEquivalent(PointerAuthQualifier Other) const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
void Profile(llvm::FoldingSetNodeID &ID)
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
A (possibly-)qualified type.
bool hasAddressDiscriminatedPointerAuth() const
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
Qualifiers::GC getObjCGCAttr() const
Returns gc attribute of this type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
QualType withConst() const
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
bool isConstQualified() const
Determine whether this type is const-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
const Type * getTypePtrOrNull() const
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Represents a template name as written in source code.
void Profile(llvm::FoldingSetNodeID &ID)
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void removeCVRQualifiers(unsigned mask)
void addAddressSpace(LangAS space)
static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R)
Returns the common set of qualifiers while removing them from the given sets.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
void removeFastQualifiers(unsigned mask)
bool hasUnaligned() const
bool hasAddressSpace() const
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
unsigned getFastQualifiers() const
void removeAddressSpace()
PointerAuthQualifier getPointerAuth() const
bool hasObjCGCAttr() const
uint64_t getAsOpaqueValue() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
void addObjCGCAttr(GC type)
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
bool hasFlexibleArrayMember() const
field_range fields() const
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
RecordDecl * getMostRecentDecl()
virtual void completeDefinition()
Note that the definition of this type is now complete.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
void Profile(llvm::FoldingSetNodeID &ID)
This table allows us to fully hide how we implement multi-keyword caching.
std::string getAsString() const
Derive the full selector name (e.g.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
StringLiteral - This represents a string literal expression, e.g.
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
A structure for storing an already-substituted template template parameter pack.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context)
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
A structure for storing the information associated with a substituted template template parameter.
void Profile(llvm::FoldingSetNodeID &ID)
TemplateTemplateParmDecl * getParameter() const
Represents the declaration of a struct/union/class/enum.
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TagKind getTagKind() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Kind
The basic C++ ABI kind.
static Kind getKind(StringRef Name)
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
unsigned getMaxAtomicInlineWidth() const
Return the maximum width lock-free atomic operation which can be inlined given the supported features...
virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
unsigned getDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
@ AArch64ABIBuiltinVaList
__builtin_va_list as defined by the AArch64 ABI http://infocenter.arm.com/help/topic/com....
@ PowerABIBuiltinVaList
__builtin_va_list as defined by the Power ABI: https://www.power.org /resources/downloads/Power-Arch-...
@ AAPCSABIBuiltinVaList
__builtin_va_list as defined by ARM AAPCS ABI http://infocenter.arm.com
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
@ X86_64ABIBuiltinVaList
__builtin_va_list as defined by the x86-64 ABI: http://refspecs.linuxbase.org/elf/x86_64-abi-0....
virtual uint64_t getNullPointerValue(LangAS AddrSpace) const
Get integer value for null pointer.
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
IntType getPtrDiffType(LangAS AddrSpace) const
IntType getSizeType() const
FloatModeKind getRealTypeByWidth(unsigned BitWidth, FloatModeKind ExplicitType) const
Return floating point type with specified width.
virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return integer type with specified width.
unsigned getMaxAlignedAttribute() const
Get the maximum alignment in bits for a static variable with aligned attribute.
virtual unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
unsigned getTargetAddressSpace(LangAS AS) const
IntType getSignedSizeType() const
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.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
std::optional< TemplateName > desugar(bool IgnoreDeduced) const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
A template parameter object.
static void Profile(llvm::FoldingSetNodeID &ID, QualType T, const APValue &V)
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
ArrayRef< NamedDecl * > asArray()
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TemplateNameKind templateParameterKind() const
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
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)
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
TemplateDecl * getNamedConcept() const
ConceptReference * getConceptReference() const
Represents a declaration of a type.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location.
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
The base class of the type hierarchy.
bool isBlockPointerType() const
bool isObjCBuiltinType() const
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.
A lazy value (of type T) that is within an AST node of type Owner, where the value might change in la...
Contains information gathered from parsing the contents of TargetAttr.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
Store declaration pairs already found to be non-equivalent.
bool IsEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
A this pointer adjustment.
IntType
===-— Target Data Type Query Methods ----------------------------—===//
AlignRequirementKind AlignRequirement
AlignRequirementKind AlignRequirement