68#include "llvm/ADT/APFixedPoint.h"
69#include "llvm/ADT/APInt.h"
70#include "llvm/ADT/APSInt.h"
71#include "llvm/ADT/ArrayRef.h"
72#include "llvm/ADT/DenseMap.h"
73#include "llvm/ADT/DenseSet.h"
74#include "llvm/ADT/FoldingSet.h"
75#include "llvm/ADT/PointerUnion.h"
76#include "llvm/ADT/STLExtras.h"
77#include "llvm/ADT/SmallPtrSet.h"
78#include "llvm/ADT/SmallVector.h"
79#include "llvm/ADT/StringExtras.h"
80#include "llvm/ADT/StringRef.h"
81#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
82#include "llvm/Support/Capacity.h"
83#include "llvm/Support/Casting.h"
84#include "llvm/Support/Compiler.h"
85#include "llvm/Support/ErrorHandling.h"
86#include "llvm/Support/MD5.h"
87#include "llvm/Support/MathExtras.h"
88#include "llvm/Support/SipHash.h"
89#include "llvm/Support/raw_ostream.h"
90#include "llvm/TargetParser/AArch64TargetParser.h"
91#include "llvm/TargetParser/Triple.h"
104using namespace clang;
128 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
133 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
134 if (VD->isStaticDataMember() &&
139 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(D)) {
144 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
151 if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
155 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
158 if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
190 Locations.emplace_back(BaseLocation);
203 Locations.emplace_back(SourceMgr.getExpansionLoc(BaseLocation));
210 Locations.emplace_back(SourceMgr.getSpellingLoc(D->
getBeginLoc()));
218 const std::map<unsigned, RawComment *> &CommentsInTheFile)
const {
221 if (RepresentativeLocForDecl.
isInvalid() ||
222 !RepresentativeLocForDecl.
isFileID())
226 if (CommentsInTheFile.empty())
232 SourceMgr.getDecomposedLoc(RepresentativeLocForDecl);
235 auto OffsetCommentBehindDecl =
236 CommentsInTheFile.lower_bound(DeclLocDecomp.second);
239 if (OffsetCommentBehindDecl != CommentsInTheFile.end()) {
240 RawComment *CommentBehindDecl = OffsetCommentBehindDecl->second;
242 LangOpts.CommentOpts.ParseAllComments) &&
249 if (SourceMgr.getLineNumber(DeclLocDecomp.first, DeclLocDecomp.second) ==
250 Comments.getCommentBeginLine(CommentBehindDecl, DeclLocDecomp.first,
251 OffsetCommentBehindDecl->first)) {
252 return CommentBehindDecl;
259 if (OffsetCommentBehindDecl == CommentsInTheFile.begin())
262 auto OffsetCommentBeforeDecl = --OffsetCommentBehindDecl;
263 RawComment *CommentBeforeDecl = OffsetCommentBeforeDecl->second;
267 LangOpts.CommentOpts.ParseAllComments) ||
272 const unsigned CommentEndOffset =
273 Comments.getCommentEndOffset(CommentBeforeDecl);
277 const char *Buffer = SourceMgr.getBufferData(DeclLocDecomp.first,
283 StringRef
Text(Buffer + CommentEndOffset,
284 DeclLocDecomp.second - CommentEndOffset);
288 if (
Text.find_last_of(
";{}#@") != StringRef::npos)
291 return CommentBeforeDecl;
297 for (
const auto DeclLoc : DeclLocs) {
300 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
311 const FileID File = SourceMgr.getDecomposedLoc(DeclLoc).first;
315 const auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
316 if (!CommentsInThisFile || CommentsInThisFile->empty())
328 assert(LangOpts.RetainCommentsFromSystemHeaders ||
330 Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
335 const Decl **OriginalDecl)
const {
338 OriginalDecl =
nullptr;
350 return DeclComment->second;
363 *OriginalDecl = RedeclComment->second;
366 "This decl is supposed to have comment attached.");
367 return CommentAtRedecl->second;
372 const Decl *LastCheckedRedecl = [&]() {
374 bool CanUseCommentlessCache =
false;
376 for (
auto *Redecl : CanonicalD->
redecls()) {
378 CanUseCommentlessCache =
true;
381 if (Redecl == LastChecked)
388 return CanUseCommentlessCache ? LastChecked :
nullptr;
394 if (LastCheckedRedecl) {
395 if (LastCheckedRedecl == Redecl) {
396 LastCheckedRedecl =
nullptr;
404 *OriginalDecl = Redecl;
405 return RedeclComment;
411 *OriginalDecl =
nullptr;
417 assert(Comment.
isDocumentation() || LangOpts.CommentOpts.ParseAllComments);
427 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(DC)) {
432 for (
const auto *Ext : ID->known_extensions()) {
436 Redeclared.push_back(RedeclaredMethod);
443 if (
Comments.empty() || Decls.empty())
447 for (
const Decl *D : Decls) {
448 if (D->isInvalidDecl())
456 File = SourceMgr.getDecomposedLoc(Loc).first;
461 if (
File.isInvalid())
464 auto CommentsInThisFile =
Comments.getCommentsInFile(
File);
465 if (!CommentsInThisFile || CommentsInThisFile->empty() ||
466 CommentsInThisFile->rbegin()->second->isAttached())
476 for (
const Decl *D : Decls) {
478 if (D->isInvalidDecl())
488 for (
const auto DeclLoc : DeclLocs) {
489 if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
493 D, DeclLoc, *CommentsInThisFile)) {
504 const Decl *D)
const {
507 ThisDeclInfo->IsFilled =
false;
508 ThisDeclInfo->fill();
509 ThisDeclInfo->CommentDecl = FC->
getDecl();
510 if (!ThisDeclInfo->TemplateParameters)
520 return RC ? RC->
parse(*
this,
nullptr, D) :
nullptr;
531 llvm::DenseMap<const Decl *, comments::FullComment *>::iterator Pos =
535 if (Canonical != D) {
543 const Decl *OriginalDecl =
nullptr;
549 const auto *OMD = dyn_cast<ObjCMethodDecl>(D);
550 if (OMD && OMD->isPropertyAccessor())
557 for (
unsigned i = 0, e = Overridden.size(); i < e; i++)
561 else if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
564 QualType QT = TD->getUnderlyingType();
565 if (
const auto *TT = QT->
getAs<TagType>())
569 else if (
const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
570 while (IC->getSuperClass()) {
571 IC = IC->getSuperClass();
576 else if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(D)) {
581 else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
582 if (!(RD = RD->getDefinition()))
585 for (
const auto &I : RD->bases()) {
586 if (I.isVirtual() || (I.getAccessSpecifier() !=
AS_public))
600 for (
const auto &I : RD->vbases()) {
621 if (D != OriginalDecl && OriginalDecl)
629void ASTContext::CanonicalTemplateTemplateParm::Profile(
638 ID.AddInteger(Params->
size());
640 PEnd = Params->
end();
642 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
644 ID.AddBoolean(TTP->isParameterPack());
646 TTP->getNumExpansionParameters().toInternalRepresentation());
650 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
652 ID.AddBoolean(NTTP->isParameterPack());
653 ID.AddPointer(
C.getUnconstrainedType(
C.getCanonicalType(NTTP->getType()))
655 if (NTTP->isExpandedParameterPack()) {
657 ID.AddInteger(NTTP->getNumExpansionTypes());
658 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
660 ID.AddPointer(
T.getCanonicalType().getAsOpaquePtr());
663 ID.AddBoolean(
false);
673TemplateTemplateParmDecl *
677 llvm::FoldingSetNodeID ID;
678 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
679 void *InsertPos =
nullptr;
680 CanonicalTemplateTemplateParm *Canonical
681 = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
683 return Canonical->getParam();
688 CanonParams.reserve(Params->
size());
690 PEnd = Params->
end();
694 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
699 TTP->getNumExpansionParameters());
700 CanonParams.push_back(NewTTP);
701 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
705 if (NTTP->isExpandedParameterPack()) {
708 for (
unsigned I = 0, N = NTTP->getNumExpansionTypes(); I != N; ++I) {
710 ExpandedTInfos.push_back(
718 NTTP->getPosition(),
nullptr,
728 NTTP->getPosition(),
nullptr,
730 NTTP->isParameterPack(),
733 CanonParams.push_back(Param);
749 Canonical = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
750 assert(!Canonical &&
"Shouldn't be in the map!");
754 Canonical =
new (*this) CanonicalTemplateTemplateParm(CanonTTP);
755 CanonTemplateTemplateParms.InsertNode(Canonical, InsertPos);
762 llvm::FoldingSetNodeID ID;
763 CanonicalTemplateTemplateParm::Profile(ID, *
this, TTP);
764 void *InsertPos =
nullptr;
765 CanonicalTemplateTemplateParm *Canonical =
766 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
767 return Canonical ? Canonical->getParam() :
nullptr;
773 llvm::FoldingSetNodeID ID;
774 CanonicalTemplateTemplateParm::Profile(ID, *
this, CanonTTP);
775 void *InsertPos =
nullptr;
777 CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos))
778 return Existing->getParam();
779 CanonTemplateTemplateParms.InsertNode(
780 new (*
this) CanonicalTemplateTemplateParm(CanonTTP), InsertPos);
789 return NoSanitizeL->containsType(Mask, TyName);
798 if (!LangOpts.CPlusPlus)
return nullptr;
801 case TargetCXXABI::AppleARM64:
802 case TargetCXXABI::Fuchsia:
803 case TargetCXXABI::GenericARM:
804 case TargetCXXABI::iOS:
805 case TargetCXXABI::WatchOS:
806 case TargetCXXABI::GenericAArch64:
807 case TargetCXXABI::GenericMIPS:
808 case TargetCXXABI::GenericItanium:
809 case TargetCXXABI::WebAssembly:
810 case TargetCXXABI::XL:
812 case TargetCXXABI::Microsoft:
815 llvm_unreachable(
"Invalid CXXABI type!");
819 if (!InterpContext) {
822 return *InterpContext;
828 return *ParentMapCtx;
833 switch (LangOpts.getAddressSpaceMapMangling()) {
841 llvm_unreachable(
"getAddressSpaceMapMangling() doesn't cover anything.");
847 : ConstantArrayTypes(this_(), ConstantArrayTypesLog2InitSize),
848 DependentSizedArrayTypes(this_()), DependentSizedExtVectorTypes(this_()),
849 DependentAddressSpaceTypes(this_()), DependentVectorTypes(this_()),
850 DependentSizedMatrixTypes(this_()),
851 FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
852 DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
853 DependentPackIndexingTypes(this_()), TemplateSpecializationTypes(this_()),
854 DependentBitIntTypes(this_()), SubstTemplateTemplateParmPacks(this_()),
855 DeducedTemplates(this_()), ArrayParameterTypes(this_()),
856 CanonTemplateTemplateParms(this_()), SourceMgr(
SM), LangOpts(LOpts),
859 LangOpts.XRayNeverInstrumentFiles,
860 LangOpts.XRayAttrListFiles,
SM)),
864 Comments(
SM), CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
872 ReleaseDeclContextMaps();
875 for (
auto &Pair : Deallocations)
876 (Pair.first)(Pair.second);
877 Deallocations.clear();
883 I = ObjCLayouts.begin(),
884 E = ObjCLayouts.end();
891 for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
892 I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
897 ASTRecordLayouts.clear();
899 for (llvm::DenseMap<const Decl*, AttrVec*>::iterator A = DeclAttrs.begin(),
900 AEnd = DeclAttrs.end();
902 A->second->~AttrVec();
905 for (
const auto &
Value : ModuleInitializers)
906 Value.second->~PerModuleInitializers();
907 ModuleInitializers.
clear();
916 TraversalScope = TopLevelDecls;
921 Deallocations.push_back({Callback,
Data});
930 llvm::errs() <<
"\n*** AST Context Stats:\n";
931 llvm::errs() <<
" " << Types.size() <<
" types total.\n";
933 unsigned counts[] = {
934#define TYPE(Name, Parent) 0,
935#define ABSTRACT_TYPE(Name, Parent)
936#include "clang/AST/TypeNodes.inc"
940 for (
unsigned i = 0, e = Types.size(); i != e; ++i) {
946 unsigned TotalBytes = 0;
947#define TYPE(Name, Parent) \
949 llvm::errs() << " " << counts[Idx] << " " << #Name \
950 << " types, " << sizeof(Name##Type) << " each " \
951 << "(" << counts[Idx] * sizeof(Name##Type) \
953 TotalBytes += counts[Idx] * sizeof(Name##Type); \
955#define ABSTRACT_TYPE(Name, Parent)
956#include "clang/AST/TypeNodes.inc"
958 llvm::errs() <<
"Total bytes = " << TotalBytes <<
"\n";
963 <<
" implicit default constructors created\n";
966 <<
" implicit copy constructors created\n";
970 <<
" implicit move constructors created\n";
973 <<
" implicit copy assignment operators created\n";
977 <<
" implicit move assignment operators created\n";
980 <<
" implicit destructors created\n";
983 llvm::errs() <<
"\n";
987 BumpAlloc.PrintStats();
991 bool NotifyListeners) {
995 Listener->RedefinedHiddenDefinition(ND, M);
1002 if (It == MergedDefModules.end())
1005 auto &Merged = It->second;
1006 llvm::DenseSet<Module*>
Found;
1007 for (
Module *&M : Merged)
1008 if (!
Found.insert(M).second)
1010 llvm::erase(Merged,
nullptr);
1017 if (MergedIt == MergedDefModules.end())
1019 return MergedIt->second;
1022void ASTContext::PerModuleInitializers::resolve(
ASTContext &Ctx) {
1023 if (LazyInitializers.empty())
1027 assert(Source &&
"lazy initializers but no external source");
1029 auto LazyInits = std::move(LazyInitializers);
1030 LazyInitializers.clear();
1032 for (
auto ID : LazyInits)
1033 Initializers.push_back(Source->GetExternalDecl(ID));
1035 assert(LazyInitializers.empty() &&
1036 "GetExternalDecl for lazy module initializer added more inits");
1042 if (
const auto *ID = dyn_cast<ImportDecl>(D)) {
1043 auto It = ModuleInitializers.find(ID->getImportedModule());
1046 if (It == ModuleInitializers.end())
1050 auto &Imported = *It->second;
1051 if (Imported.Initializers.size() + Imported.LazyInitializers.size() == 1) {
1052 Imported.resolve(*
this);
1053 auto *OnlyDecl = Imported.Initializers.front();
1059 auto *&Inits = ModuleInitializers[M];
1061 Inits =
new (*this) PerModuleInitializers;
1062 Inits->Initializers.push_back(D);
1067 auto *&Inits = ModuleInitializers[M];
1069 Inits =
new (*this) PerModuleInitializers;
1070 Inits->LazyInitializers.insert(Inits->LazyInitializers.end(),
1071 IDs.begin(), IDs.end());
1075 auto It = ModuleInitializers.find(M);
1076 if (It == ModuleInitializers.end())
1079 auto *Inits = It->second;
1080 Inits->resolve(*
this);
1081 return Inits->Initializers;
1086 assert(!CurrentCXXNamedModule &&
1087 "We should set named module for ASTContext for only once");
1088 CurrentCXXNamedModule = M;
1100 auto GetRepresentativeModule = [
this](
const Module *M) {
1101 auto Iter = SameModuleLookupSet.find(M);
1102 if (Iter != SameModuleLookupSet.end())
1103 return Iter->second;
1105 const Module *RepresentativeModule =
1106 PrimaryModuleNameMap.try_emplace(M->getPrimaryModuleInterfaceName(), M)
1108 SameModuleLookupSet[M] = RepresentativeModule;
1109 return RepresentativeModule;
1112 assert(M1 &&
"Shouldn't call `isInSameModule` if both M1 and M2 are none.");
1113 return GetRepresentativeModule(M1) == GetRepresentativeModule(M2);
1117 if (!ExternCContext)
1120 return ExternCContext;
1134#define BuiltinTemplate(BTName) \
1135 BuiltinTemplateDecl *ASTContext::get##BTName##Decl() const { \
1136 if (!Decl##BTName) \
1138 buildBuiltinTemplateDecl(BTK##BTName, get##BTName##Name()); \
1139 return Decl##BTName; \
1141#include "clang/Basic/BuiltinTemplates.inc"
1154 NewDecl->
addAttr(TypeVisibilityAttr::CreateImplicit(
1155 const_cast<ASTContext &
>(*
this), TypeVisibilityAttr::Default));
1160 StringRef Name)
const {
1184 Types.push_back(Ty);
1189 assert((!this->Target || this->Target == &Target) &&
1190 "Incorrect target reinitialization");
1191 assert(
VoidTy.isNull() &&
"Context reinitialized?");
1193 this->Target = &Target;
1194 this->AuxTarget = AuxTarget;
1196 ABI.reset(createCXXABI(Target));
1200 InitBuiltinType(
VoidTy, BuiltinType::Void);
1203 InitBuiltinType(
BoolTy, BuiltinType::Bool);
1205 if (LangOpts.CharIsSigned)
1206 InitBuiltinType(
CharTy, BuiltinType::Char_S);
1208 InitBuiltinType(
CharTy, BuiltinType::Char_U);
1211 InitBuiltinType(
ShortTy, BuiltinType::Short);
1212 InitBuiltinType(
IntTy, BuiltinType::Int);
1213 InitBuiltinType(
LongTy, BuiltinType::Long);
1214 InitBuiltinType(
LongLongTy, BuiltinType::LongLong);
1224 InitBuiltinType(
FloatTy, BuiltinType::Float);
1225 InitBuiltinType(
DoubleTy, BuiltinType::Double);
1226 InitBuiltinType(
LongDoubleTy, BuiltinType::LongDouble);
1229 InitBuiltinType(
Float128Ty, BuiltinType::Float128);
1232 InitBuiltinType(
Ibm128Ty, BuiltinType::Ibm128);
1235 InitBuiltinType(
Float16Ty, BuiltinType::Float16);
1238 InitBuiltinType(
ShortAccumTy, BuiltinType::ShortAccum);
1239 InitBuiltinType(
AccumTy, BuiltinType::Accum);
1240 InitBuiltinType(
LongAccumTy, BuiltinType::LongAccum);
1244 InitBuiltinType(
ShortFractTy, BuiltinType::ShortFract);
1245 InitBuiltinType(
FractTy, BuiltinType::Fract);
1246 InitBuiltinType(
LongFractTy, BuiltinType::LongFract);
1251 InitBuiltinType(
SatAccumTy, BuiltinType::SatAccum);
1257 InitBuiltinType(
SatFractTy, BuiltinType::SatFract);
1264 InitBuiltinType(
Int128Ty, BuiltinType::Int128);
1269 InitBuiltinType(
WCharTy, BuiltinType::WChar_S);
1271 InitBuiltinType(
WCharTy, BuiltinType::WChar_U);
1272 if (LangOpts.CPlusPlus && LangOpts.WChar)
1276 WideCharTy = getFromTargetType(Target.getWCharType());
1279 WIntTy = getFromTargetType(Target.getWIntType());
1282 InitBuiltinType(
Char8Ty, BuiltinType::Char8);
1284 if (LangOpts.CPlusPlus)
1285 InitBuiltinType(
Char16Ty, BuiltinType::Char16);
1287 Char16Ty = getFromTargetType(Target.getChar16Type());
1289 if (LangOpts.CPlusPlus)
1290 InitBuiltinType(
Char32Ty, BuiltinType::Char32);
1292 Char32Ty = getFromTargetType(Target.getChar32Type());
1299 InitBuiltinType(
DependentTy, BuiltinType::Dependent);
1302 InitBuiltinType(
OverloadTy, BuiltinType::Overload);
1314 InitBuiltinType(
UnknownAnyTy, BuiltinType::UnknownAny);
1320 InitBuiltinType(
BuiltinFnTy, BuiltinType::BuiltinFn);
1323 if (LangOpts.OpenMP) {
1330 if (LangOpts.OpenACC && !LangOpts.OpenMP) {
1333 if (LangOpts.MatrixTypes)
1341 if (LangOpts.OpenCL) {
1342#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1343 InitBuiltinType(SingletonId, BuiltinType::Id);
1344#include "clang/Basic/OpenCLImageTypes.def"
1346 InitBuiltinType(
OCLSamplerTy, BuiltinType::OCLSampler);
1347 InitBuiltinType(
OCLEventTy, BuiltinType::OCLEvent);
1349 InitBuiltinType(
OCLQueueTy, BuiltinType::OCLQueue);
1352#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1353 InitBuiltinType(Id##Ty, BuiltinType::Id);
1354#include "clang/Basic/OpenCLExtensionTypes.def"
1357 if (LangOpts.HLSL) {
1358#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1359 InitBuiltinType(SingletonId, BuiltinType::Id);
1360#include "clang/Basic/HLSLIntangibleTypes.def"
1363 if (Target.hasAArch64ACLETypes() ||
1364 (AuxTarget && AuxTarget->hasAArch64ACLETypes())) {
1365#define SVE_TYPE(Name, Id, SingletonId) \
1366 InitBuiltinType(SingletonId, BuiltinType::Id);
1367#include "clang/Basic/AArch64ACLETypes.def"
1370 if (Target.getTriple().isPPC64()) {
1371#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
1372 InitBuiltinType(Id##Ty, BuiltinType::Id);
1373#include "clang/Basic/PPCTypes.def"
1374#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
1375 InitBuiltinType(Id##Ty, BuiltinType::Id);
1376#include "clang/Basic/PPCTypes.def"
1379 if (Target.hasRISCVVTypes()) {
1380#define RVV_TYPE(Name, Id, SingletonId) \
1381 InitBuiltinType(SingletonId, BuiltinType::Id);
1382#include "clang/Basic/RISCVVTypes.def"
1385 if (Target.getTriple().isWasm() && Target.hasFeature(
"reference-types")) {
1386#define WASM_TYPE(Name, Id, SingletonId) \
1387 InitBuiltinType(SingletonId, BuiltinType::Id);
1388#include "clang/Basic/WebAssemblyReferenceTypes.def"
1391 if (Target.getTriple().isAMDGPU() ||
1392 (AuxTarget && AuxTarget->getTriple().isAMDGPU())) {
1393#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1394 InitBuiltinType(SingletonId, BuiltinType::Id);
1395#include "clang/Basic/AMDGPUTypes.def"
1402 ObjCConstantStringType =
QualType();
1407 if (LangOpts.OpenCLGenericAddressSpace) {
1408 auto Q =
VoidTy.getQualifiers();
1417 InitBuiltinType(
NullPtrTy, BuiltinType::NullPtr);
1420 InitBuiltinType(
HalfTy, BuiltinType::Half);
1422 InitBuiltinType(
BFloat16Ty, BuiltinType::BFloat16);
1428 if (LangOpts.MicrosoftExt || LangOpts.Borland) {
1435 return SourceMgr.getDiagnostics();
1450 llvm::DenseMap<const Decl*, AttrVec*>::iterator Pos = DeclAttrs.find(D);
1451 if (Pos != DeclAttrs.end()) {
1452 Pos->second->~AttrVec();
1453 DeclAttrs.erase(Pos);
1467 llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo>::iterator Pos =
1468 TemplateOrInstantiation.find(Var);
1469 if (Pos == TemplateOrInstantiation.end())
1482 Tmpl, TSK, PointOfInstantiation));
1488 assert(!TemplateOrInstantiation[Inst] &&
1489 "Already noted what the variable was instantiated from");
1490 TemplateOrInstantiation[Inst] = TSI;
1495 return InstantiatedFromUsingDecl.lookup(UUD);
1503 "pattern decl is not a using decl");
1507 "instantiation did not produce a using decl");
1508 assert(!InstantiatedFromUsingDecl[Inst] &&
"pattern already exists");
1509 InstantiatedFromUsingDecl[Inst] = Pattern;
1514 return InstantiatedFromUsingEnumDecl.lookup(UUD);
1519 assert(!InstantiatedFromUsingEnumDecl[Inst] &&
"pattern already exists");
1520 InstantiatedFromUsingEnumDecl[Inst] = Pattern;
1525 return InstantiatedFromUsingShadowDecl.lookup(Inst);
1531 assert(!InstantiatedFromUsingShadowDecl[Inst] &&
"pattern already exists");
1532 InstantiatedFromUsingShadowDecl[Inst] = Pattern;
1537 return InstantiatedFromUnnamedFieldDecl.lookup(Field);
1543 "Instantiated field decl is not unnamed");
1545 "Template field decl is not unnamed");
1546 assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
1547 "Already noted what unnamed field was instantiated from");
1549 InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
1565 return Range.end() - Range.begin();
1570 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos =
1571 OverriddenMethods.find(
Method->getCanonicalDecl());
1572 if (Pos == OverriddenMethods.end())
1580 OverriddenMethods[
Method].push_back(Overridden);
1588 if (
const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
1594 const auto *
Method = dyn_cast<ObjCMethodDecl>(D);
1599 Method->getOverriddenMethods(OverDecls);
1600 Overridden.append(OverDecls.begin(), OverDecls.end());
1603std::optional<ASTContext::CXXRecordDeclRelocationInfo>
1607 auto it = RelocatableClasses.find(D);
1608 if (it != RelocatableClasses.end())
1609 return it->getSecond();
1610 return std::nullopt;
1617 assert(RelocatableClasses.find(D) == RelocatableClasses.end());
1618 RelocatableClasses.insert({D, Info});
1623 if (!Class->isPolymorphic())
1625 const CXXRecordDecl *BaseType = Context.baseForVTableAuthentication(Class);
1626 using AuthAttr = VTablePointerAuthenticationAttr;
1627 const AuthAttr *ExplicitAuth = BaseType->
getAttr<AuthAttr>();
1629 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1630 AuthAttr::AddressDiscriminationMode AddressDiscrimination =
1631 ExplicitAuth->getAddressDiscrimination();
1632 if (AddressDiscrimination == AuthAttr::DefaultAddressDiscrimination)
1633 return Context.getLangOpts().PointerAuthVTPtrAddressDiscrimination;
1634 return AddressDiscrimination == AuthAttr::AddressDiscrimination;
1637ASTContext::PointerAuthContent
1638ASTContext::findPointerAuthContent(QualType
T)
const {
1639 assert(isPointerAuthenticationAvailable());
1641 T =
T.getCanonicalType();
1643 return PointerAuthContent::None;
1645 if (
T.hasAddressDiscriminatedPointerAuth())
1646 return PointerAuthContent::AddressDiscriminatedData;
1649 return PointerAuthContent::None;
1652 return PointerAuthContent::None;
1654 if (
auto Existing = RecordContainsAddressDiscriminatedPointerAuth.find(RD);
1655 Existing != RecordContainsAddressDiscriminatedPointerAuth.end())
1656 return Existing->second;
1658 PointerAuthContent
Result = PointerAuthContent::None;
1660 auto SaveResultAndReturn = [&]() -> PointerAuthContent {
1661 auto [ResultIter, DidAdd] =
1662 RecordContainsAddressDiscriminatedPointerAuth.try_emplace(RD,
Result);
1668 auto ShouldContinueAfterUpdate = [&](PointerAuthContent NewResult) {
1669 static_assert(PointerAuthContent::None <
1670 PointerAuthContent::AddressDiscriminatedVTable);
1671 static_assert(PointerAuthContent::AddressDiscriminatedVTable <
1672 PointerAuthContent::AddressDiscriminatedData);
1675 return Result != PointerAuthContent::AddressDiscriminatedData;
1677 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1679 !ShouldContinueAfterUpdate(
1680 PointerAuthContent::AddressDiscriminatedVTable))
1681 return SaveResultAndReturn();
1682 for (
auto Base : CXXRD->bases()) {
1683 if (!ShouldContinueAfterUpdate(findPointerAuthContent(
Base.getType())))
1684 return SaveResultAndReturn();
1687 for (
auto *FieldDecl : RD->
fields()) {
1688 if (!ShouldContinueAfterUpdate(
1689 findPointerAuthContent(FieldDecl->getType())))
1690 return SaveResultAndReturn();
1692 return SaveResultAndReturn();
1696 assert(!Import->getNextLocalImport() &&
1697 "Import declaration already in the chain");
1698 assert(!Import->isFromASTFile() &&
"Non-local import declaration");
1699 if (!FirstLocalImport) {
1700 FirstLocalImport = Import;
1701 LastLocalImport = Import;
1705 LastLocalImport->setNextLocalImport(Import);
1706 LastLocalImport = Import;
1718 llvm_unreachable(
"Not a floating point type!");
1719 case BuiltinType::BFloat16:
1720 return Target->getBFloat16Format();
1721 case BuiltinType::Float16:
1722 return Target->getHalfFormat();
1723 case BuiltinType::Half:
1724 return Target->getHalfFormat();
1725 case BuiltinType::Float:
return Target->getFloatFormat();
1726 case BuiltinType::Double:
return Target->getDoubleFormat();
1727 case BuiltinType::Ibm128:
1728 return Target->getIbm128Format();
1729 case BuiltinType::LongDouble:
1731 return AuxTarget->getLongDoubleFormat();
1732 return Target->getLongDoubleFormat();
1733 case BuiltinType::Float128:
1735 return AuxTarget->getFloat128Format();
1736 return Target->getFloat128Format();
1741 unsigned Align = Target->getCharWidth();
1745 Align = AlignFromAttr;
1753 bool UseAlignAttrOnly;
1754 if (
const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1756 FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1758 UseAlignAttrOnly = AlignFromAttr != 0;
1761 if (UseAlignAttrOnly) {
1763 }
else if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
1767 T = RT->getPointeeType();
1772 if (
T->isFunctionType())
1773 Align = getTypeInfoImpl(
T.getTypePtr()).Align;
1778 unsigned MinWidth = Target->getLargeArrayMinWidth();
1779 if (!ForAlignof && MinWidth) {
1781 Align = std::max(Align, Target->getLargeArrayAlign());
1784 Align = std::max(Align, Target->getLargeArrayAlign());
1789 Align = Target->getCharWidth();
1793 if (
const auto *VD = dyn_cast<VarDecl>(D))
1794 if (VD->hasGlobalStorage() && !ForAlignof) {
1805 if (
const auto *Field = dyn_cast<FieldDecl>(VD)) {
1819 uint64_t LowBitOfOffset = Offset & (~Offset + 1);
1820 if (LowBitOfOffset < FieldAlign)
1821 FieldAlign =
static_cast<unsigned>(LowBitOfOffset);
1824 Align = std::min(Align, FieldAlign);
1832 const auto *VD = dyn_cast<VarDecl>(D);
1833 if (MaxAlignedAttr && VD && VD->getStorageClass() ==
SC_Static)
1834 Align = std::min(Align, MaxAlignedAttr);
1854 if (
const auto *RD =
T->getAsCXXRecordDecl(); RD && !RD->
isInvalidDecl()) {
1871 (uint64_t)(-1)/Size) &&
1872 "Overflow in array type char size evaluation");
1875 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
1877 Width = llvm::alignTo(Width, Align);
1884 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
1902 switch (BT->getKind()) {
1903 case BuiltinType::Bool:
1904 case BuiltinType::Char_S:
1905 case BuiltinType::Char_U:
1906 case BuiltinType::SChar:
1907 case BuiltinType::UChar:
1908 case BuiltinType::Short:
1909 case BuiltinType::UShort:
1910 case BuiltinType::WChar_S:
1911 case BuiltinType::WChar_U:
1912 case BuiltinType::Char8:
1913 case BuiltinType::Char16:
1914 case BuiltinType::Char32:
1922 if (
const auto *ED =
T->getAsEnumDecl()) {
1923 if (
T->isDependentType() || ED->getPromotionType().isNull() ||
1942 bool NeedsPreferredAlignment)
const {
1945 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
1950 if (!
T->isIncompleteType())
1956 if (
unsigned Align = TT->getDecl()->getMaxAlignment())
1960 if (
const auto *TD =
T->getAsTagDecl())
1961 return TD->getMaxAlignment();
1967 TypeInfoMap::iterator I = MemoizedTypeInfo.find(
T);
1968 if (I != MemoizedTypeInfo.end())
1973 MemoizedTypeInfo[
T] = TI;
1988 switch (
T->getTypeClass()) {
1989#define TYPE(Class, Base)
1990#define ABSTRACT_TYPE(Class, Base)
1991#define NON_CANONICAL_TYPE(Class, Base)
1992#define DEPENDENT_TYPE(Class, Base) case Type::Class:
1993#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) \
1995 assert(!T->isDependentType() && "should not see dependent types here"); \
1996 return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
1997#include "clang/AST/TypeNodes.inc"
1998 llvm_unreachable(
"Should not see dependent types");
2000 case Type::FunctionNoProto:
2001 case Type::FunctionProto:
2007 case Type::IncompleteArray:
2008 case Type::VariableArray:
2009 case Type::ConstantArray:
2010 case Type::ArrayParameter: {
2013 if (
const auto *CAT = dyn_cast<ConstantArrayType>(
T))
2014 Size = CAT->getZExtSize();
2017 assert((Size == 0 || EltInfo.
Width <= (uint64_t)(-1) / Size) &&
2018 "Overflow in array type bit size evaluation");
2019 Width = EltInfo.
Width * Size;
2020 Align = EltInfo.
Align;
2024 Width = llvm::alignTo(Width, Align);
2028 case Type::ExtVector:
2029 case Type::Vector: {
2032 Width = VT->isPackedVectorBoolType(*
this)
2033 ? VT->getNumElements()
2034 : EltInfo.
Width * VT->getNumElements();
2036 Width = std::max<unsigned>(8, Width);
2037 Align = std::max<unsigned>(8, Width);
2041 if (Align & (Align-1)) {
2042 Align = llvm::bit_ceil(Align);
2043 Width = llvm::alignTo(Width, Align);
2046 uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
2047 if (TargetVectorAlign && TargetVectorAlign < Align)
2048 Align = TargetVectorAlign;
2062 Align = std::min<unsigned>(64, Width);
2066 case Type::ConstantMatrix: {
2068 TypeInfo ElementInfo =
getTypeInfo(MT->getElementType());
2072 Width = ElementInfo.
Width * MT->getNumRows() * MT->getNumColumns();
2073 Align = ElementInfo.
Align;
2079 default: llvm_unreachable(
"Unknown builtin type!");
2080 case BuiltinType::Void:
2085 case BuiltinType::Bool:
2086 Width = Target->getBoolWidth();
2087 Align = Target->getBoolAlign();
2089 case BuiltinType::Char_S:
2090 case BuiltinType::Char_U:
2091 case BuiltinType::UChar:
2092 case BuiltinType::SChar:
2093 case BuiltinType::Char8:
2094 Width = Target->getCharWidth();
2095 Align = Target->getCharAlign();
2097 case BuiltinType::WChar_S:
2098 case BuiltinType::WChar_U:
2099 Width = Target->getWCharWidth();
2100 Align = Target->getWCharAlign();
2102 case BuiltinType::Char16:
2103 Width = Target->getChar16Width();
2104 Align = Target->getChar16Align();
2106 case BuiltinType::Char32:
2107 Width = Target->getChar32Width();
2108 Align = Target->getChar32Align();
2110 case BuiltinType::UShort:
2111 case BuiltinType::Short:
2112 Width = Target->getShortWidth();
2113 Align = Target->getShortAlign();
2115 case BuiltinType::UInt:
2116 case BuiltinType::Int:
2117 Width = Target->getIntWidth();
2118 Align = Target->getIntAlign();
2120 case BuiltinType::ULong:
2121 case BuiltinType::Long:
2122 Width = Target->getLongWidth();
2123 Align = Target->getLongAlign();
2125 case BuiltinType::ULongLong:
2126 case BuiltinType::LongLong:
2127 Width = Target->getLongLongWidth();
2128 Align = Target->getLongLongAlign();
2130 case BuiltinType::Int128:
2131 case BuiltinType::UInt128:
2133 Align = Target->getInt128Align();
2135 case BuiltinType::ShortAccum:
2136 case BuiltinType::UShortAccum:
2137 case BuiltinType::SatShortAccum:
2138 case BuiltinType::SatUShortAccum:
2139 Width = Target->getShortAccumWidth();
2140 Align = Target->getShortAccumAlign();
2142 case BuiltinType::Accum:
2143 case BuiltinType::UAccum:
2144 case BuiltinType::SatAccum:
2145 case BuiltinType::SatUAccum:
2146 Width = Target->getAccumWidth();
2147 Align = Target->getAccumAlign();
2149 case BuiltinType::LongAccum:
2150 case BuiltinType::ULongAccum:
2151 case BuiltinType::SatLongAccum:
2152 case BuiltinType::SatULongAccum:
2153 Width = Target->getLongAccumWidth();
2154 Align = Target->getLongAccumAlign();
2156 case BuiltinType::ShortFract:
2157 case BuiltinType::UShortFract:
2158 case BuiltinType::SatShortFract:
2159 case BuiltinType::SatUShortFract:
2160 Width = Target->getShortFractWidth();
2161 Align = Target->getShortFractAlign();
2163 case BuiltinType::Fract:
2164 case BuiltinType::UFract:
2165 case BuiltinType::SatFract:
2166 case BuiltinType::SatUFract:
2167 Width = Target->getFractWidth();
2168 Align = Target->getFractAlign();
2170 case BuiltinType::LongFract:
2171 case BuiltinType::ULongFract:
2172 case BuiltinType::SatLongFract:
2173 case BuiltinType::SatULongFract:
2174 Width = Target->getLongFractWidth();
2175 Align = Target->getLongFractAlign();
2177 case BuiltinType::BFloat16:
2178 if (Target->hasBFloat16Type()) {
2179 Width = Target->getBFloat16Width();
2180 Align = Target->getBFloat16Align();
2184 AuxTarget->hasBFloat16Type()) {
2185 Width = AuxTarget->getBFloat16Width();
2186 Align = AuxTarget->getBFloat16Align();
2189 case BuiltinType::Float16:
2190 case BuiltinType::Half:
2191 if (Target->hasFloat16Type() || !
getLangOpts().OpenMP ||
2193 Width = Target->getHalfWidth();
2194 Align = Target->getHalfAlign();
2197 "Expected OpenMP device compilation.");
2198 Width = AuxTarget->getHalfWidth();
2199 Align = AuxTarget->getHalfAlign();
2202 case BuiltinType::Float:
2203 Width = Target->getFloatWidth();
2204 Align = Target->getFloatAlign();
2206 case BuiltinType::Double:
2207 Width = Target->getDoubleWidth();
2208 Align = Target->getDoubleAlign();
2210 case BuiltinType::Ibm128:
2211 Width = Target->getIbm128Width();
2212 Align = Target->getIbm128Align();
2214 case BuiltinType::LongDouble:
2216 (Target->getLongDoubleWidth() != AuxTarget->getLongDoubleWidth() ||
2217 Target->getLongDoubleAlign() != AuxTarget->getLongDoubleAlign())) {
2218 Width = AuxTarget->getLongDoubleWidth();
2219 Align = AuxTarget->getLongDoubleAlign();
2221 Width = Target->getLongDoubleWidth();
2222 Align = Target->getLongDoubleAlign();
2225 case BuiltinType::Float128:
2226 if (Target->hasFloat128Type() || !
getLangOpts().OpenMP ||
2228 Width = Target->getFloat128Width();
2229 Align = Target->getFloat128Align();
2232 "Expected OpenMP device compilation.");
2233 Width = AuxTarget->getFloat128Width();
2234 Align = AuxTarget->getFloat128Align();
2237 case BuiltinType::NullPtr:
2242 case BuiltinType::ObjCId:
2243 case BuiltinType::ObjCClass:
2244 case BuiltinType::ObjCSel:
2248 case BuiltinType::OCLSampler:
2249 case BuiltinType::OCLEvent:
2250 case BuiltinType::OCLClkEvent:
2251 case BuiltinType::OCLQueue:
2252 case BuiltinType::OCLReserveID:
2253#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2254 case BuiltinType::Id:
2255#include "clang/Basic/OpenCLImageTypes.def"
2256#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
2257 case BuiltinType::Id:
2258#include "clang/Basic/OpenCLExtensionTypes.def"
2260 Width = Target->getPointerWidth(AS);
2261 Align = Target->getPointerAlign(AS);
2271#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2272 case BuiltinType::Id: \
2276#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2277 case BuiltinType::Id: \
2281#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2282 case BuiltinType::Id: \
2286#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
2287 case BuiltinType::Id: \
2291#include "clang/Basic/AArch64ACLETypes.def"
2292#define PPC_VECTOR_TYPE(Name, Id, Size) \
2293 case BuiltinType::Id: \
2297#include "clang/Basic/PPCTypes.def"
2298#define RVV_VECTOR_TYPE(Name, Id, SingletonId, ElKind, ElBits, NF, IsSigned, \
2300 case BuiltinType::Id: \
2304#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, ElKind) \
2305 case BuiltinType::Id: \
2309#include "clang/Basic/RISCVVTypes.def"
2310#define WASM_TYPE(Name, Id, SingletonId) \
2311 case BuiltinType::Id: \
2315#include "clang/Basic/WebAssemblyReferenceTypes.def"
2316#define AMDGPU_TYPE(NAME, ID, SINGLETONID, WIDTH, ALIGN) \
2317 case BuiltinType::ID: \
2321#include "clang/Basic/AMDGPUTypes.def"
2322#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2323#include "clang/Basic/HLSLIntangibleTypes.def"
2329 case Type::ObjCObjectPointer:
2333 case Type::BlockPointer:
2335 Width = Target->getPointerWidth(AS);
2336 Align = Target->getPointerAlign(AS);
2338 case Type::LValueReference:
2339 case Type::RValueReference:
2343 Width = Target->getPointerWidth(AS);
2344 Align = Target->getPointerAlign(AS);
2348 Width = Target->getPointerWidth(AS);
2349 Align = Target->getPointerAlign(AS);
2351 case Type::MemberPointer: {
2353 CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
2358 case Type::Complex: {
2362 Width = EltInfo.
Width * 2;
2363 Align = EltInfo.
Align;
2366 case Type::ObjCObject:
2368 case Type::Adjusted:
2371 case Type::ObjCInterface: {
2373 if (ObjCI->getDecl()->isInvalidDecl()) {
2383 case Type::BitInt: {
2385 Align = Target->getBitIntAlign(EIT->getNumBits());
2386 Width = Target->getBitIntWidth(EIT->getNumBits());
2392 const TagDecl *TD = TT->getDecl()->getDefinitionOrSelf();
2405 Info.
Align = AttrAlign;
2415 AlignRequirement = RD->
hasAttr<AlignedAttr>()
2421 case Type::SubstTemplateTypeParm:
2423 getReplacementType().getTypePtr());
2426 case Type::DeducedTemplateSpecialization: {
2428 assert(!A->getDeducedType().isNull() &&
2429 "cannot request the size of an undeduced or dependent auto type");
2430 return getTypeInfo(A->getDeducedType().getTypePtr());
2436 case Type::MacroQualified:
2440 case Type::ObjCTypeParam:
2446 case Type::Typedef: {
2448 TypeInfo Info =
getTypeInfo(TT->desugar().getTypePtr());
2452 if (
unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
2463 case Type::Attributed:
2467 case Type::CountAttributed:
2470 case Type::BTFTagAttributed:
2474 case Type::HLSLAttributedResource:
2478 case Type::HLSLInlineSpirv: {
2481 Width = ST->getSize() * 8;
2482 Align = ST->getAlignment();
2483 if (Width == 0 && Align == 0) {
2491 case Type::Atomic: {
2500 Width = Target->getCharWidth();
2502 }
else if (Width <= Target->getMaxAtomicPromoteWidth()) {
2508 Width = llvm::bit_ceil(Width);
2511 Align =
static_cast<unsigned>(Width);
2516 case Type::PredefinedSugar:
2525 assert(llvm::isPowerOf2_32(Align) &&
"Alignment must be power of 2");
2526 return TypeInfo(Width, Align, AlignRequirement);
2530 UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(
T);
2531 if (I != MemoizedUnadjustedAlign.end())
2534 unsigned UnadjustedAlign;
2535 if (
const auto *RT =
T->getAsCanonical<RecordType>()) {
2542 UnadjustedAlign =
getTypeAlign(
T->getUnqualifiedDesugaredType());
2545 MemoizedUnadjustedAlign[
T] = UnadjustedAlign;
2546 return UnadjustedAlign;
2550 unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
2600 unsigned ABIAlign = TI.
Align;
2602 T =
T->getBaseElementTypeUnsafe();
2605 if (
T->isMemberPointerType())
2608 if (!Target->allowsLargerPreferedTypeAlignment())
2611 if (
const auto *RD =
T->getAsRecordDecl()) {
2620 unsigned PreferredAlign =
static_cast<unsigned>(
2622 assert(PreferredAlign >= ABIAlign &&
2623 "PreferredAlign should be at least as large as ABIAlign.");
2624 return PreferredAlign;
2631 T = CT->getElementType().getTypePtr();
2632 if (
const auto *ED =
T->getAsEnumDecl())
2633 T = ED->getIntegerType().getTypePtr();
2634 if (
T->isSpecificBuiltinType(BuiltinType::Double) ||
2635 T->isSpecificBuiltinType(BuiltinType::LongLong) ||
2636 T->isSpecificBuiltinType(BuiltinType::ULongLong) ||
2637 (
T->isSpecificBuiltinType(BuiltinType::LongDouble) &&
2638 Target->defaultsToAIXPowerAlignment()))
2693 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
2697 std::swap(
Base, Derived);
2717 llvm::append_range(Ivars, OI->
ivars());
2720 for (
const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
2722 Ivars.push_back(Iv);
2730 if (
const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
2733 for (
auto *Proto : OI->all_referenced_protocols()) {
2738 for (
const auto *Cat : OI->visible_categories())
2744 SD = SD->getSuperClass();
2746 }
else if (
const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
2747 for (
auto *Proto : OC->protocols()) {
2750 }
else if (
const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
2752 if (!Protocols.insert(
2756 for (
auto *Proto : OP->protocols())
2763 bool CheckIfTriviallyCopyable) {
2764 assert(RD->
isUnion() &&
"Must be union type");
2766 Context.getTypeSizeInChars(Context.getCanonicalTagType(RD));
2768 for (
const auto *Field : RD->
fields()) {
2769 if (!Context.hasUniqueObjectRepresentations(Field->getType(),
2770 CheckIfTriviallyCopyable))
2772 CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
2773 if (FieldSize != UnionSize)
2782 return Context.getFieldOffset(Field);
2791static std::optional<int64_t>
2793 const RecordDecl *RD,
2794 bool CheckIfTriviallyCopyable);
2796static std::optional<int64_t>
2798 bool CheckIfTriviallyCopyable) {
2799 if (
const auto *RD = Field->getType()->getAsRecordDecl();
2802 CheckIfTriviallyCopyable);
2806 bool IsBitIntType = Field->getType()->isBitIntType();
2807 if (!Field->getType()->isReferenceType() && !IsBitIntType &&
2808 !Context.hasUniqueObjectRepresentations(Field->getType(),
2809 CheckIfTriviallyCopyable))
2810 return std::nullopt;
2812 int64_t FieldSizeInBits =
2813 Context.toBits(Context.getTypeSizeInChars(Field->getType()));
2814 if (Field->isBitField()) {
2817 if (Field->isUnnamedBitField())
2820 int64_t BitfieldSize = Field->getBitWidthValue();
2822 if ((
unsigned)BitfieldSize >
2824 return std::nullopt;
2825 }
else if (BitfieldSize > FieldSizeInBits) {
2826 return std::nullopt;
2828 FieldSizeInBits = BitfieldSize;
2829 }
else if (IsBitIntType && !Context.hasUniqueObjectRepresentations(
2830 Field->getType(), CheckIfTriviallyCopyable)) {
2831 return std::nullopt;
2833 return FieldSizeInBits;
2836static std::optional<int64_t>
2838 bool CheckIfTriviallyCopyable) {
2840 CheckIfTriviallyCopyable);
2843template <
typename RangeT>
2845 const RangeT &Subobjects, int64_t CurOffsetInBits,
2847 bool CheckIfTriviallyCopyable) {
2848 for (
const auto *Subobject : Subobjects) {
2849 std::optional<int64_t> SizeInBits =
2852 return std::nullopt;
2853 if (*SizeInBits != 0) {
2855 if (Offset != CurOffsetInBits)
2856 return std::nullopt;
2857 CurOffsetInBits += *SizeInBits;
2860 return CurOffsetInBits;
2863static std::optional<int64_t>
2866 bool CheckIfTriviallyCopyable) {
2867 assert(!RD->
isUnion() &&
"Must be struct/class type");
2868 const auto &Layout = Context.getASTRecordLayout(RD);
2870 int64_t CurOffsetInBits = 0;
2871 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
2872 if (ClassDecl->isDynamicClass())
2873 return std::nullopt;
2876 for (
const auto &
Base : ClassDecl->bases()) {
2879 Bases.emplace_back(
Base.getType()->getAsCXXRecordDecl());
2883 return Layout.getBaseClassOffset(L) < Layout.getBaseClassOffset(R);
2886 std::optional<int64_t> OffsetAfterBases =
2888 Bases, CurOffsetInBits, Context, Layout, CheckIfTriviallyCopyable);
2889 if (!OffsetAfterBases)
2890 return std::nullopt;
2891 CurOffsetInBits = *OffsetAfterBases;
2894 std::optional<int64_t> OffsetAfterFields =
2896 RD->
fields(), CurOffsetInBits, Context, Layout,
2897 CheckIfTriviallyCopyable);
2898 if (!OffsetAfterFields)
2899 return std::nullopt;
2900 CurOffsetInBits = *OffsetAfterFields;
2902 return CurOffsetInBits;
2906 QualType Ty,
bool CheckIfTriviallyCopyable)
const {
2923 assert(!Ty.
isNull() &&
"Null QualType sent to unique object rep check");
2928 CheckIfTriviallyCopyable);
2931 "hasUniqueObjectRepresentations should not be called with an "
2955 return !ABI->getMemberPointerInfo(MPT).HasPadding;
2958 if (
Record->isInvalidDecl())
2963 CheckIfTriviallyCopyable);
2966 *
this,
Record, CheckIfTriviallyCopyable);
2968 return StructSize && *StructSize ==
static_cast<int64_t
>(
getTypeSize(Ty));
2989 count += Ext->ivar_size();
2994 count += ImplDecl->ivar_size();
3020 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3021 I = ObjCImpls.find(D);
3022 if (I != ObjCImpls.end())
3030 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator
3031 I = ObjCImpls.find(D);
3032 if (I != ObjCImpls.end())
3040 assert(IFaceD && ImplD &&
"Passed null params");
3041 ObjCImpls[IFaceD] = ImplD;
3047 assert(CatD && ImplD &&
"Passed null params");
3048 ObjCImpls[CatD] = ImplD;
3053 return ObjCMethodRedecls.
lookup(MD);
3059 ObjCMethodRedecls[MD] = Redecl;
3064 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->
getDeclContext()))
3066 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->
getDeclContext()))
3067 return CD->getClassInterface();
3068 if (
const auto *IMD = dyn_cast<ObjCImplDecl>(ND->
getDeclContext()))
3069 return IMD->getClassInterface();
3077 assert(VD &&
"Passed null params");
3078 assert(VD->
hasAttr<BlocksAttr>() &&
3079 "getBlockVarCopyInits - not __block var");
3080 auto I = BlockVarCopyInits.find(VD);
3081 if (I != BlockVarCopyInits.end())
3083 return {
nullptr,
false};
3089 assert(VD && CopyExpr &&
"Passed null params");
3090 assert(VD->
hasAttr<BlocksAttr>() &&
3091 "setBlockVarCopyInits - not __block var");
3092 BlockVarCopyInits[VD].setExprAndFlag(CopyExpr,
CanThrow);
3096 unsigned DataSize)
const {
3101 "incorrect data size provided to CreateTypeSourceInfo!");
3118 return getObjCLayout(D);
3123 bool &AnyNonCanonArgs) {
3125 AnyNonCanonArgs |=
C.canonicalizeTemplateArguments(CanonArgs);
3131 bool AnyNonCanonArgs =
false;
3132 for (
auto &Arg : Args) {
3135 AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
3137 return AnyNonCanonArgs;
3145ASTContext::getExtQualType(
const Type *baseType,
Qualifiers quals)
const {
3150 llvm::FoldingSetNodeID ID;
3152 void *insertPos =
nullptr;
3153 if (
ExtQuals *eq = ExtQualNodes.FindNodeOrInsertPos(ID, insertPos)) {
3154 assert(eq->getQualifiers() == quals);
3163 canon = getExtQualType(canonSplit.
Ty, canonSplit.
Quals);
3166 (void) ExtQualNodes.FindNodeOrInsertPos(ID, insertPos);
3169 auto *eq =
new (*
this,
alignof(ExtQuals)) ExtQuals(baseType, canon, quals);
3170 ExtQualNodes.InsertNode(eq, insertPos);
3171 return QualType(eq, fastQuals);
3175 LangAS AddressSpace)
const {
3188 "Type cannot be in multiple addr spaces!");
3191 return getExtQualType(TypeNode, Quals);
3197 if (!
T.hasAddressSpace())
3201 const Type *TypeNode;
3204 if (
T.getTypePtr()->isArrayType()) {
3206 TypeNode =
T.getTypePtr();
3210 while (
T.hasAddressSpace()) {
3211 TypeNode = Quals.
strip(
T);
3215 if (!
QualType(TypeNode, 0).hasAddressSpace())
3219 T =
T.getSingleStepDesugaredType(*
this);
3229 return getExtQualType(TypeNode, Quals);
3237 "Attempted to get vtable pointer discriminator on a monomorphic type");
3240 llvm::raw_svector_ostream Out(Str);
3241 MC->mangleCXXVTable(RD, Out);
3242 return llvm::getPointerAuthStableSipHash(Str);
3268 switch (
T->getTypeClass()) {
3273 case Type::LValueReference:
3278 case Type::RValueReference:
3292 case Type::ObjCObjectPointer:
3293 case Type::BlockPointer:
3302 case Type::VariableArray:
3303 case Type::ConstantArray:
3304 case Type::IncompleteArray:
3305 case Type::ArrayParameter:
3318 case Type::ObjCInterface:
3319 case Type::ObjCObject:
3320 OS <<
"<objc_object>";
3329 QualType UnderlyingType =
T->castAsEnumDecl()->getIntegerType();
3331 Ctx, OS, UnderlyingType.
isNull() ? Ctx.
IntTy : UnderlyingType);
3334 case Type::FunctionNoProto:
3335 case Type::FunctionProto: {
3351 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FuncType)) {
3352 for (
QualType Param : FPT->param_types()) {
3356 if (FPT->isVariadic())
3363 case Type::MemberPointer: {
3367 Ctx, OS,
QualType(MPT->getQualifier().getAsType(), 0));
3371 case Type::ExtVector:
3379 case Type::ConstantMatrix:
3383 case Type::Builtin: {
3385 switch (BTy->getKind()) {
3386#define SIGNED_TYPE(Id, SingletonId) \
3387 case BuiltinType::Id: \
3390#define UNSIGNED_TYPE(Id, SingletonId) \
3391 case BuiltinType::Id: \
3394#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
3395#define BUILTIN_TYPE(Id, SingletonId)
3396#include "clang/AST/BuiltinTypes.def"
3397 llvm_unreachable(
"placeholder types should not appear here.");
3399 case BuiltinType::Half:
3402 case BuiltinType::Float:
3405 case BuiltinType::Double:
3408 case BuiltinType::LongDouble:
3411 case BuiltinType::Float16:
3414 case BuiltinType::Float128:
3418 case BuiltinType::Void:
3422 case BuiltinType::ObjCId:
3423 case BuiltinType::ObjCClass:
3424 case BuiltinType::ObjCSel:
3425 case BuiltinType::NullPtr:
3430 case BuiltinType::OCLSampler:
3431 case BuiltinType::OCLEvent:
3432 case BuiltinType::OCLClkEvent:
3433 case BuiltinType::OCLQueue:
3434 case BuiltinType::OCLReserveID:
3435 case BuiltinType::BFloat16:
3436 case BuiltinType::VectorQuad:
3437 case BuiltinType::VectorPair:
3438 case BuiltinType::DMR1024:
3439 case BuiltinType::DMR2048:
3444 case BuiltinType::Ibm128:
3446#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3447 case BuiltinType::Id: \
3449#include "clang/Basic/OpenCLImageTypes.def"
3450#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3451 case BuiltinType::Id: \
3453#include "clang/Basic/OpenCLExtensionTypes.def"
3454#define SVE_TYPE(Name, Id, SingletonId) \
3455 case BuiltinType::Id: \
3457#include "clang/Basic/AArch64ACLETypes.def"
3458#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3459 case BuiltinType::Id: \
3461#include "clang/Basic/HLSLIntangibleTypes.def"
3462 case BuiltinType::Dependent:
3463 llvm_unreachable(
"should never get here");
3464#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
3465#include "clang/Basic/AMDGPUTypes.def"
3466 case BuiltinType::WasmExternRef:
3467#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
3468#include "clang/Basic/RISCVVTypes.def"
3469 llvm_unreachable(
"not yet implemented");
3471 llvm_unreachable(
"should never get here");
3473 case Type::Record: {
3474 const RecordDecl *RD =
T->castAsCanonical<RecordType>()->getDecl();
3494 II = Typedef->getDeclName().getAsIdentifierInfo();
3497 OS <<
"<anonymous_record>";
3503 case Type::HLSLAttributedResource:
3504 case Type::HLSLInlineSpirv:
3505 llvm_unreachable(
"should never get here");
3507 case Type::DeducedTemplateSpecialization:
3509#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3510#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3511#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3512#define ABSTRACT_TYPE(Class, Base)
3513#define TYPE(Class, Base)
3514#include "clang/AST/TypeNodes.inc"
3515 llvm_unreachable(
"unexpected non-canonical or dependent type!");
3521 assert(!
T->isDependentType() &&
3522 "cannot compute type discriminator of a dependent type");
3524 llvm::raw_svector_ostream Out(Str);
3526 if (
T->isFunctionPointerType() ||
T->isFunctionReferenceType())
3527 T =
T->getPointeeType();
3529 if (
T->isFunctionType()) {
3532 T =
T.getUnqualifiedType();
3553 if (MPT->isMemberFunctionPointer()) {
3559 MPT->getMostRecentCXXRecordDecl());
3563 MC->mangleCanonicalTypeName(
T, Out);
3566 return llvm::getPointerAuthStableSipHash(Str);
3591 "Type cannot have multiple ObjCGCs!");
3594 return getExtQualType(TypeNode, Quals);
3608 QualType WrappedTy,
Expr *CountExpr,
bool CountInBytes,
bool OrNull,
3612 llvm::FoldingSetNodeID ID;
3615 void *InsertPos =
nullptr;
3617 CountAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
3622 size_t Size = CountAttributedType::totalSizeToAlloc<TypeCoupledDeclRefInfo>(
3623 DependentDecls.size());
3626 OrNull, DependentDecls);
3627 Types.push_back(CATy);
3628 CountAttributedTypes.InsertNode(CATy, InsertPos);
3637 case Type::Attributed: {
3645 case Type::BTFTagAttributed: {
3646 const auto *BTFT = dyn_cast<BTFTagAttributedType>(Orig);
3655 case Type::Adjusted: {
3661 case Type::MacroQualified: {
3664 MQT->getMacroIdentifier());
3668 return Adjust(Orig);
3674 if (
T->getExtInfo() == Info)
3678 if (
const auto *FNPT = dyn_cast<FunctionNoProtoType>(
T)) {
3698 FPT->getExtProtoInfo());
3713 L->DeducedReturnType(FD, ResultType);
3724 return getFunctionType(Proto->getReturnType(), Proto->getParamTypes(),
3725 Proto->getExtProtoInfo().withExceptionSpec(ESI));
3741 for (
unsigned i = 0, n = Args.size(); i != n; ++i)
3764 return getFunctionType(Proto->getReturnType(), Proto->param_types(), EPI);
3790 if (TSInfo->getType() != FD->
getType())
3798 "TypeLoc size mismatch from updating exception specification");
3799 TSInfo->overrideType(Updated);
3808 llvm::FoldingSetNodeID ID;
3811 void *InsertPos =
nullptr;
3812 if (
ComplexType *CT = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos))
3818 if (!
T.isCanonical()) {
3822 ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos);
3823 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3826 Types.push_back(
New);
3827 ComplexTypes.InsertNode(
New, InsertPos);
3836 llvm::FoldingSetNodeID ID;
3839 void *InsertPos =
nullptr;
3840 if (
PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos))
3846 if (!
T.isCanonical()) {
3850 PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos);
3851 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3854 Types.push_back(
New);
3855 PointerTypes.InsertNode(
New, InsertPos);
3860 llvm::FoldingSetNodeID ID;
3862 void *InsertPos =
nullptr;
3863 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3870 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3871 assert(!AT &&
"Shouldn't be in the map!");
3875 Types.push_back(AT);
3876 AdjustedTypes.InsertNode(AT, InsertPos);
3881 llvm::FoldingSetNodeID ID;
3883 void *InsertPos =
nullptr;
3884 AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3891 AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
3892 assert(!AT &&
"Shouldn't be in the map!");
3895 Types.push_back(AT);
3896 AdjustedTypes.InsertNode(AT, InsertPos);
3901 assert((
T->isArrayType() ||
T->isFunctionType()) &&
"T does not decay");
3910 if (
T->isArrayType())
3917 if (
T->isFunctionType())
3929 llvm::FoldingSetNodeID ID;
3930 ATy->Profile(ID, *
this, ATy->getElementType(), ATy->getZExtSize(),
3931 ATy->getSizeExpr(), ATy->getSizeModifier(),
3932 ATy->getIndexTypeQualifiers().getAsOpaqueValue());
3933 void *InsertPos =
nullptr;
3935 ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
3944 AT = ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos);
3945 assert(!AT &&
"Shouldn't be in the map!");
3950 Types.push_back(AT);
3951 ArrayParameterTypes.InsertNode(AT, InsertPos);
3958 assert(
T->isFunctionType() &&
"block of function types only");
3961 llvm::FoldingSetNodeID ID;
3964 void *InsertPos =
nullptr;
3966 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
3972 if (!
T.isCanonical()) {
3977 BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
3978 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
3982 Types.push_back(
New);
3983 BlockPointerTypes.InsertNode(
New, InsertPos);
3991 assert((!
T->isPlaceholderType() ||
3992 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
3993 "Unresolved placeholder type");
3997 llvm::FoldingSetNodeID ID;
4000 void *InsertPos =
nullptr;
4002 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4010 if (!SpelledAsLValue || InnerRef || !
T.isCanonical()) {
4011 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4016 LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4017 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4022 Types.push_back(
New);
4023 LValueReferenceTypes.InsertNode(
New, InsertPos);
4031 assert((!
T->isPlaceholderType() ||
4032 T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
4033 "Unresolved placeholder type");
4037 llvm::FoldingSetNodeID ID;
4040 void *InsertPos =
nullptr;
4042 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
4050 if (InnerRef || !
T.isCanonical()) {
4051 QualType PointeeType = (InnerRef ? InnerRef->getPointeeType() :
T);
4056 RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
4057 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4062 Types.push_back(
New);
4063 RValueReferenceTypes.InsertNode(
New, InsertPos);
4071 assert(Cls &&
"At least one of Qualifier or Cls must be provided");
4074 Cls = Qualifier.getAsRecordDecl();
4078 llvm::FoldingSetNodeID ID;
4081 void *InsertPos =
nullptr;
4083 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
4088 return Qualifier.getCanonical();
4096 if (!
T.isCanonical() || Qualifier != CanonicalQualifier) {
4102 MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
4103 assert(!NewIP &&
"Shouldn't be in the map!");
4107 Types.push_back(
New);
4108 MemberPointerTypes.InsertNode(
New, InsertPos);
4115 const llvm::APInt &ArySizeIn,
4116 const Expr *SizeExpr,
4118 unsigned IndexTypeQuals)
const {
4121 "Constant array of VLAs is illegal!");
4129 llvm::APInt ArySize(ArySizeIn);
4130 ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
4132 llvm::FoldingSetNodeID ID;
4134 ASM, IndexTypeQuals);
4136 void *InsertPos =
nullptr;
4138 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
4149 ASM, IndexTypeQuals);
4154 ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
4155 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4158 auto *
New = ConstantArrayType::Create(*
this, EltTy, Canon, ArySize, SizeExpr,
4159 ASM, IndexTypeQuals);
4160 ConstantArrayTypes.InsertNode(
New, InsertPos);
4161 Types.push_back(
New);
4170 if (!
type->isVariablyModifiedType())
return type;
4175 const Type *ty = split.
Ty;
4177#define TYPE(Class, Base)
4178#define ABSTRACT_TYPE(Class, Base)
4179#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4180#include "clang/AST/TypeNodes.inc"
4181 llvm_unreachable(
"didn't desugar past all non-canonical types?");
4187 case Type::DependentVector:
4188 case Type::ExtVector:
4189 case Type::DependentSizedExtVector:
4190 case Type::ConstantMatrix:
4191 case Type::DependentSizedMatrix:
4192 case Type::DependentAddressSpace:
4193 case Type::ObjCObject:
4194 case Type::ObjCInterface:
4195 case Type::ObjCObjectPointer:
4198 case Type::UnresolvedUsing:
4199 case Type::TypeOfExpr:
4201 case Type::Decltype:
4202 case Type::UnaryTransform:
4203 case Type::DependentName:
4204 case Type::InjectedClassName:
4205 case Type::TemplateSpecialization:
4206 case Type::TemplateTypeParm:
4207 case Type::SubstTemplateTypeParmPack:
4208 case Type::SubstBuiltinTemplatePack:
4210 case Type::DeducedTemplateSpecialization:
4211 case Type::PackExpansion:
4212 case Type::PackIndexing:
4214 case Type::DependentBitInt:
4215 case Type::ArrayParameter:
4216 case Type::HLSLAttributedResource:
4217 case Type::HLSLInlineSpirv:
4218 llvm_unreachable(
"type should never be variably-modified");
4222 case Type::FunctionNoProto:
4223 case Type::FunctionProto:
4224 case Type::BlockPointer:
4225 case Type::MemberPointer:
4238 case Type::LValueReference: {
4242 lv->isSpelledAsLValue());
4246 case Type::RValueReference: {
4253 case Type::Atomic: {
4259 case Type::ConstantArray: {
4265 cat->getSizeModifier(),
4266 cat->getIndexTypeCVRQualifiers());
4270 case Type::DependentSizedArray: {
4274 dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
4279 case Type::IncompleteArray: {
4284 iat->getIndexTypeCVRQualifiers());
4289 case Type::VariableArray: {
4294 vat->getIndexTypeCVRQualifiers());
4307 unsigned IndexTypeQuals)
const {
4324 VariableArrayTypes.push_back(
New);
4325 Types.push_back(
New);
4335 unsigned elementTypeQuals)
const {
4338 "Size must be type- or value-dependent!");
4342 void *insertPos =
nullptr;
4343 llvm::FoldingSetNodeID ID;
4345 ID, *
this, numElements ?
QualType(canonElementType.
Ty, 0) : elementType,
4346 ASM, elementTypeQuals, numElements);
4350 DependentSizedArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4362 DependentSizedArrayTypes.InsertNode(newType, insertPos);
4363 Types.push_back(newType);
4371 numElements, ASM, elementTypeQuals);
4372 DependentSizedArrayTypes.InsertNode(canonTy, insertPos);
4373 Types.push_back(canonTy);
4378 canonElementType.
Quals);
4382 if (
QualType(canonElementType.
Ty, 0) == elementType &&
4391 Types.push_back(sugaredType);
4397 unsigned elementTypeQuals)
const {
4398 llvm::FoldingSetNodeID ID;
4401 void *insertPos =
nullptr;
4403 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos))
4415 ASM, elementTypeQuals);
4420 IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos);
4421 assert(!existing &&
"Shouldn't be in the map!"); (void) existing;
4427 IncompleteArrayTypes.InsertNode(newType, insertPos);
4428 Types.push_back(newType);
4434#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
4435 {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \
4438#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
4439 {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
4443 llvm_unreachable(
"Unsupported builtin vector type");
4445#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4446 ElBits, NF, IsSigned) \
4447 case BuiltinType::Id: \
4448 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4449 llvm::ElementCount::getScalable(NumEls), NF};
4450#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4452 case BuiltinType::Id: \
4453 return {ElBits == 16 ? HalfTy : (ElBits == 32 ? FloatTy : DoubleTy), \
4454 llvm::ElementCount::getScalable(NumEls), NF};
4455#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4457 case BuiltinType::Id: \
4458 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4459#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4461 case BuiltinType::Id: \
4462 return {MFloat8Ty, llvm::ElementCount::getScalable(NumEls), NF};
4463#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4464 case BuiltinType::Id: \
4465 return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
4466#include "clang/Basic/AArch64ACLETypes.def"
4468#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
4470 case BuiltinType::Id: \
4471 return {getIntTypeForBitwidth(ElBits, IsSigned), \
4472 llvm::ElementCount::getScalable(NumEls), NF};
4473#define RVV_VECTOR_TYPE_FLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4474 case BuiltinType::Id: \
4475 return {ElBits == 16 ? Float16Ty : (ElBits == 32 ? FloatTy : DoubleTy), \
4476 llvm::ElementCount::getScalable(NumEls), NF};
4477#define RVV_VECTOR_TYPE_BFLOAT(Name, Id, SingletonId, NumEls, ElBits, NF) \
4478 case BuiltinType::Id: \
4479 return {BFloat16Ty, llvm::ElementCount::getScalable(NumEls), NF};
4480#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4481 case BuiltinType::Id: \
4482 return {BoolTy, llvm::ElementCount::getScalable(NumEls), 1};
4483#include "clang/Basic/RISCVVTypes.def"
4490 if (Target->getTriple().isWasm() && Target->hasFeature(
"reference-types")) {
4491#define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \
4492 if (BuiltinType::Id == BuiltinType::WasmExternRef) \
4494#include "clang/Basic/WebAssemblyReferenceTypes.def"
4497 "shouldn't try to generate type externref outside WebAssembly target");
4504 unsigned NumFields)
const {
4506 if (
auto It = ScalableVecTyMap.find(K); It != ScalableVecTyMap.end())
4509 if (Target->hasAArch64ACLETypes()) {
4512#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
4513 ElBits, NF, IsSigned) \
4514 if (EltTy->hasIntegerRepresentation() && !EltTy->isBooleanType() && \
4515 EltTy->hasSignedIntegerRepresentation() == IsSigned && \
4516 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4517 return ScalableVecTyMap[K] = SingletonId; \
4519#define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4521 if (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4522 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4523 return ScalableVecTyMap[K] = SingletonId; \
4525#define SVE_VECTOR_TYPE_BFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4527 if (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4528 EltTySize == ElBits && NumElts == (NumEls * NF) && NumFields == 1) { \
4529 return ScalableVecTyMap[K] = SingletonId; \
4531#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
4533 if (EltTy->isMFloat8Type() && EltTySize == ElBits && \
4534 NumElts == (NumEls * NF) && NumFields == 1) { \
4535 return ScalableVecTyMap[K] = SingletonId; \
4537#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
4538 if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
4539 return ScalableVecTyMap[K] = SingletonId;
4540#include "clang/Basic/AArch64ACLETypes.def"
4541 }
else if (Target->hasRISCVVTypes()) {
4543#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
4545 if (!EltTy->isBooleanType() && \
4546 ((EltTy->hasIntegerRepresentation() && \
4547 EltTy->hasSignedIntegerRepresentation() == IsSigned) || \
4548 (EltTy->hasFloatingRepresentation() && !EltTy->isBFloat16Type() && \
4550 (EltTy->hasFloatingRepresentation() && EltTy->isBFloat16Type() && \
4551 IsBF && !IsFP)) && \
4552 EltTySize == ElBits && NumElts == NumEls && NumFields == NF) \
4553 return ScalableVecTyMap[K] = SingletonId;
4554#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
4555 if (EltTy->isBooleanType() && NumElts == NumEls) \
4556 return ScalableVecTyMap[K] = SingletonId;
4557#include "clang/Basic/RISCVVTypes.def"
4572 llvm::FoldingSetNodeID ID;
4575 void *InsertPos =
nullptr;
4576 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4586 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4587 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4590 VectorType(vecType, NumElts, Canonical, VecKind);
4591 VectorTypes.InsertNode(
New, InsertPos);
4592 Types.push_back(
New);
4599 llvm::FoldingSetNodeID ID;
4602 void *InsertPos =
nullptr;
4604 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4609 VecType,
QualType(Canon, 0), SizeExpr, AttrLoc, VecKind);
4612 if (CanonVecTy == VecType) {
4617 DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4618 assert(!CanonCheck &&
4619 "Dependent-sized vector_size canonical type broken");
4621 DependentVectorTypes.InsertNode(
New, InsertPos);
4630 Types.push_back(
New);
4637 unsigned NumElts)
const {
4644 llvm::FoldingSetNodeID ID;
4647 void *InsertPos =
nullptr;
4648 if (
VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
4658 VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4659 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4663 VectorTypes.InsertNode(
New, InsertPos);
4664 Types.push_back(
New);
4672 llvm::FoldingSetNodeID ID;
4676 void *InsertPos =
nullptr;
4678 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4688 if (CanonVecTy == vecType) {
4693 = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
4694 assert(!CanonCheck &&
"Dependent-sized ext_vector canonical type broken");
4696 DependentSizedExtVectorTypes.InsertNode(
New, InsertPos);
4705 Types.push_back(
New);
4710 unsigned NumColumns)
const {
4711 llvm::FoldingSetNodeID ID;
4713 Type::ConstantMatrix);
4716 "need a valid element type");
4717 assert(NumRows > 0 && NumRows <= LangOpts.MaxMatrixDimension &&
4718 NumColumns > 0 && NumColumns <= LangOpts.MaxMatrixDimension &&
4719 "need valid matrix dimensions");
4720 void *InsertPos =
nullptr;
4730 assert(!NewIP &&
"Matrix type shouldn't already exist in the map");
4736 MatrixTypes.InsertNode(
New, InsertPos);
4737 Types.push_back(
New);
4746 llvm::FoldingSetNodeID ID;
4750 void *InsertPos =
nullptr;
4752 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4757 ColumnExpr, AttrLoc);
4760 DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
4761 assert(!CanonCheck &&
"Dependent-sized matrix canonical type broken");
4763 DependentSizedMatrixTypes.InsertNode(Canon, InsertPos);
4764 Types.push_back(Canon);
4777 ColumnExpr, AttrLoc);
4778 Types.push_back(
New);
4783 Expr *AddrSpaceExpr,
4789 void *insertPos =
nullptr;
4790 llvm::FoldingSetNodeID ID;
4795 DependentAddressSpaceTypes.FindNodeOrInsertPos(ID, insertPos);
4801 DependentAddressSpaceTypes.InsertNode(canonTy, insertPos);
4802 Types.push_back(canonTy);
4805 if (canonPointeeType == PointeeType &&
4811 AddrSpaceExpr, AttrLoc);
4812 Types.push_back(sugaredType);
4818 return T.isCanonical() &&
4836 llvm::FoldingSetNodeID ID;
4839 void *InsertPos =
nullptr;
4841 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
4851 FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
4852 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
4857 Types.push_back(
New);
4858 FunctionNoProtoTypes.InsertNode(
New, InsertPos);
4874 return CanResultType;
4881 if (!NoexceptInType)
4898 bool AnyPackExpansions =
false;
4902 if (ET->
getAs<PackExpansionType>())
4903 AnyPackExpansions =
true;
4905 return AnyPackExpansions;
4911QualType ASTContext::getFunctionTypeInternal(
4912 QualType ResultTy, ArrayRef<QualType> ArgArray,
4913 const FunctionProtoType::ExtProtoInfo &EPI,
bool OnlyWantCanonical)
const {
4914 size_t NumArgs = ArgArray.size();
4918 llvm::FoldingSetNodeID
ID;
4923 bool Unique =
false;
4925 void *InsertPos =
nullptr;
4926 if (FunctionProtoType *FPT =
4927 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos)) {
4928 QualType Existing = QualType(FPT, 0);
4947 bool IsCanonicalExceptionSpec =
4951 bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
4953 for (
unsigned i = 0; i != NumArgs && isCanonical; ++i)
4954 if (!ArgArray[i].isCanonicalAsParam())
4955 isCanonical =
false;
4957 if (OnlyWantCanonical)
4958 assert(isCanonical &&
4959 "given non-canonical parameters constructing canonical type");
4964 if (!isCanonical && Canonical.
isNull()) {
4965 SmallVector<QualType, 16> CanonicalArgs;
4966 CanonicalArgs.reserve(NumArgs);
4967 for (
unsigned i = 0; i != NumArgs; ++i)
4970 llvm::SmallVector<QualType, 8> ExceptionTypeStorage;
4971 FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
4974 if (IsCanonicalExceptionSpec) {
4976 }
else if (NoexceptInType) {
4989 bool AnyPacks =
false;
4991 if (ET->
getAs<PackExpansionType>())
5012 llvm_unreachable(
"dependent noexcept is already canonical");
5015 CanonicalEPI.
ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
5021 getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI,
true);
5024 FunctionProtoType *NewIP =
5025 FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
5026 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
5031 auto ESH = FunctionProtoType::getExceptionSpecSize(
5033 size_t Size = FunctionProtoType::totalSizeToAlloc<
5034 QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
5035 FunctionType::FunctionTypeExtraAttributeInfo,
5036 FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
5037 Expr *, FunctionDecl *, FunctionProtoType::ExtParameterInfo, Qualifiers,
5038 FunctionEffect, EffectConditionExpr>(
5042 ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
5047 auto *FTP = (FunctionProtoType *)
Allocate(Size,
alignof(FunctionProtoType));
5048 FunctionProtoType::ExtProtoInfo newEPI = EPI;
5049 new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
5050 Types.push_back(FTP);
5052 FunctionProtoTypes.InsertNode(FTP, InsertPos);
5054 AnyFunctionEffects =
true;
5055 return QualType(FTP, 0);
5058QualType ASTContext::getPipeType(QualType
T,
bool ReadOnly)
const {
5059 llvm::FoldingSetNodeID
ID;
5062 void *InsertPos =
nullptr;
5063 if (PipeType *PT = PipeTypes.FindNodeOrInsertPos(ID, InsertPos))
5064 return QualType(PT, 0);
5069 if (!
T.isCanonical()) {
5073 PipeType *NewIP = PipeTypes.FindNodeOrInsertPos(ID, InsertPos);
5074 assert(!NewIP &&
"Shouldn't be in the map!");
5077 auto *
New =
new (*
this,
alignof(PipeType)) PipeType(
T, Canonical, ReadOnly);
5078 Types.push_back(
New);
5079 PipeTypes.InsertNode(
New, InsertPos);
5080 return QualType(
New, 0);
5090 return getPipeType(
T,
true);
5094 return getPipeType(
T,
false);
5098 llvm::FoldingSetNodeID ID;
5101 void *InsertPos =
nullptr;
5102 if (
BitIntType *EIT = BitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5106 BitIntTypes.InsertNode(
New, InsertPos);
5107 Types.push_back(
New);
5112 Expr *NumBitsExpr)
const {
5114 llvm::FoldingSetNodeID ID;
5117 void *InsertPos =
nullptr;
5119 DependentBitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
5124 DependentBitIntTypes.InsertNode(
New, InsertPos);
5126 Types.push_back(
New);
5134 if (
auto *Target = PredefinedSugarTypes[llvm::to_underlying(KD)];
5146 return Ctx.getFromTargetType(Ctx.Target->
getSizeType());
5147 case Kind::SignedSizeT:
5149 case Kind::PtrdiffT:
5152 llvm_unreachable(
"unexpected kind");
5157 Types.push_back(
New);
5158 PredefinedSugarTypes[llvm::to_underlying(KD)] =
New;
5165 if (
auto *Tag = dyn_cast<TagDecl>(
Decl))
5168 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Decl))
5170 if (
auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5179 if (
auto *Tag = dyn_cast<TagDecl>(TD))
5181 if (
auto *TN = dyn_cast<TypedefNameDecl>(TD))
5183 if (
const auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TD))
5185 assert(TD->TypeForDecl);
5190 if (
const auto *TD = dyn_cast<TagDecl>(
Decl))
5192 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
Decl);
5193 isa_and_nonnull<TypedefDecl, TypeAliasDecl>(TD))
5196 if (
const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(
Decl))
5199 assert(
Decl->TypeForDecl);
5209 std::optional<bool> TypeMatchesDeclOrNone)
const {
5210 if (!TypeMatchesDeclOrNone) {
5211 QualType DeclUnderlyingType =
Decl->getUnderlyingType();
5212 assert(!DeclUnderlyingType.
isNull());
5213 if (UnderlyingType.
isNull())
5214 UnderlyingType = DeclUnderlyingType;
5216 assert(
hasSameType(UnderlyingType, DeclUnderlyingType));
5217 TypeMatchesDeclOrNone = UnderlyingType == DeclUnderlyingType;
5221 assert(!UnderlyingType.
isNull());
5225 *TypeMatchesDeclOrNone) {
5226 if (
Decl->TypeForDecl)
5231 !*TypeMatchesDeclOrNone);
5233 Types.push_back(NewType);
5234 Decl->TypeForDecl = NewType;
5238 llvm::FoldingSetNodeID ID;
5240 *TypeMatchesDeclOrNone ?
QualType() : UnderlyingType);
5242 void *InsertPos =
nullptr;
5244 TypedefTypes.FindNodeOrInsertPos(ID, InsertPos))
5245 return QualType(Placeholder->getType(), 0);
5250 1, !!Qualifier, !*TypeMatchesDeclOrNone),
5254 UnderlyingType, !*TypeMatchesDeclOrNone);
5255 auto *Placeholder =
new (NewType->getFoldingSetPlaceholder())
5257 TypedefTypes.InsertNode(Placeholder, InsertPos);
5258 Types.push_back(NewType);
5267 if (UnderlyingType.
isNull()) {
5275 llvm::FoldingSetNodeID ID;
5278 void *InsertPos =
nullptr;
5279 if (
const UsingType *
T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5289 Allocate(UsingType::totalSizeToAlloc<NestedNameSpecifier>(!!Qualifier),
5293 UsingTypes.InsertNode(
T, InsertPos);
5299 const TagDecl *TD,
bool OwnsTag,
5301 const Type *CanonicalType,
5302 bool WithFoldingSetNode)
const {
5303 auto [TC, Size] = [&] {
5306 static_assert(
alignof(EnumType) ==
alignof(TagType));
5307 return std::make_tuple(Type::Enum,
sizeof(EnumType));
5308 case Decl::ClassTemplatePartialSpecialization:
5309 case Decl::ClassTemplateSpecialization:
5310 case Decl::CXXRecord:
5311 static_assert(
alignof(RecordType) ==
alignof(TagType));
5312 static_assert(
alignof(InjectedClassNameType) ==
alignof(TagType));
5314 return std::make_tuple(Type::InjectedClassName,
5315 sizeof(InjectedClassNameType));
5318 return std::make_tuple(Type::Record,
sizeof(RecordType));
5320 llvm_unreachable(
"unexpected decl kind");
5330 if (WithFoldingSetNode) {
5338 sizeof(TagTypeFoldingSetPlaceholder) +
5339 TagTypeFoldingSetPlaceholder::getOffset() + Size,
5340 std::max(
alignof(TagTypeFoldingSetPlaceholder),
alignof(TagType)));
5341 auto *
T =
new (Mem) TagTypeFoldingSetPlaceholder();
5342 Mem =
T->getTagType();
5344 Mem =
Allocate(Size,
alignof(TagType));
5347 auto *
T = [&, TC = TC]() -> TagType * {
5351 auto *
T =
new (Mem) EnumType(TC,
Keyword, Qualifier, TD, OwnsTag,
5352 IsInjected, CanonicalType);
5353 assert(
reinterpret_cast<void *
>(
T) ==
5354 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5355 "TagType must be the first base of EnumType");
5358 case Type::Record: {
5360 auto *
T =
new (Mem) RecordType(TC,
Keyword, Qualifier, TD, OwnsTag,
5361 IsInjected, CanonicalType);
5362 assert(
reinterpret_cast<void *
>(
T) ==
5363 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5364 "TagType must be the first base of RecordType");
5367 case Type::InjectedClassName: {
5368 auto *
T =
new (Mem) InjectedClassNameType(
Keyword, Qualifier, TD,
5369 IsInjected, CanonicalType);
5370 assert(
reinterpret_cast<void *
>(
T) ==
5371 reinterpret_cast<void *
>(
static_cast<TagType *
>(
T)) &&
5372 "TagType must be the first base of InjectedClassNameType");
5376 llvm_unreachable(
"unexpected type class");
5379 assert(
T->getKeyword() ==
Keyword);
5380 assert(
T->getQualifier() == Qualifier);
5381 assert(
T->getDecl() == TD);
5382 assert(
T->isInjected() == IsInjected);
5383 assert(
T->isTagOwned() == OwnsTag);
5392 if (
const auto *RD = dyn_cast<CXXRecordDecl>(TD);
5393 RD && RD->isInjectedClassName())
5400 if (TD->TypeForDecl)
5401 return TD->TypeForDecl->getCanonicalTypeUnqualified();
5403 const Type *CanonicalType = getTagTypeInternal(
5406 false,
false,
nullptr,
5408 TD->TypeForDecl = CanonicalType;
5414 const TagDecl *TD,
bool OwnsTag)
const {
5417 bool IsInjected = TD != NonInjectedTD;
5424 if (
Keyword == PreferredKeyword && !Qualifier && !OwnsTag) {
5425 if (
const Type *
T = TD->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5431 std::nullopt, NonInjectedTD,
5432 false, IsInjected, CanonicalType,
5434 TD->TypeForDecl =
T;
5438 llvm::FoldingSetNodeID ID;
5439 TagTypeFoldingSetPlaceholder::Profile(ID,
Keyword, Qualifier, NonInjectedTD,
5440 OwnsTag, IsInjected);
5442 void *InsertPos =
nullptr;
5443 if (TagTypeFoldingSetPlaceholder *
T =
5444 TagTypes.FindNodeOrInsertPos(ID, InsertPos))
5449 getTagTypeInternal(
Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
5450 CanonicalType,
true);
5451 TagTypes.InsertNode(TagTypeFoldingSetPlaceholder::fromTagType(
T), InsertPos);
5456 unsigned NumPositiveBits,
5459 unsigned IntWidth = Target->getIntWidth();
5460 unsigned CharWidth = Target->getCharWidth();
5461 unsigned ShortWidth = Target->getShortWidth();
5462 bool EnumTooLarge =
false;
5464 if (NumNegativeBits) {
5468 if (IsPacked && NumNegativeBits <= CharWidth &&
5469 NumPositiveBits < CharWidth) {
5471 BestWidth = CharWidth;
5472 }
else if (IsPacked && NumNegativeBits <= ShortWidth &&
5473 NumPositiveBits < ShortWidth) {
5475 BestWidth = ShortWidth;
5476 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
5478 BestWidth = IntWidth;
5480 BestWidth = Target->getLongWidth();
5482 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
5485 BestWidth = Target->getLongLongWidth();
5487 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
5488 EnumTooLarge =
true;
5492 BestPromotionType = (BestWidth <= IntWidth ?
IntTy : BestType);
5497 if (IsPacked && NumPositiveBits <= CharWidth) {
5499 BestPromotionType =
IntTy;
5500 BestWidth = CharWidth;
5501 }
else if (IsPacked && NumPositiveBits <= ShortWidth) {
5503 BestPromotionType =
IntTy;
5504 BestWidth = ShortWidth;
5505 }
else if (NumPositiveBits <= IntWidth) {
5507 BestWidth = IntWidth;
5508 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5511 }
else if (NumPositiveBits <= (BestWidth = Target->getLongWidth())) {
5513 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5517 BestWidth = Target->getLongLongWidth();
5518 if (NumPositiveBits > BestWidth) {
5523 EnumTooLarge =
true;
5526 BestPromotionType = (NumPositiveBits == BestWidth || !LangOpts.CPlusPlus)
5531 return EnumTooLarge;
5535 assert((
T->isIntegralType(*
this) ||
T->isEnumeralType()) &&
5536 "Integral type required!");
5539 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
5540 if (
T->isSignedIntegerOrEnumerationType())
5542 return Value.getActiveBits() <= BitWidth;
5544 return Value.getSignificantBits() <= BitWidth;
5550 const Type *CanonicalType)
const {
5552 UnresolvedUsingType::totalSizeToAlloc<
5554 !!InsertPos, !!Qualifier),
5558 auto *Placeholder =
new (
T->getFoldingSetPlaceholder())
5560 TypedefTypes.InsertNode(Placeholder, InsertPos);
5570 return D->TypeForDecl->getCanonicalTypeUnqualified();
5572 const Type *CanonicalType = getUnresolvedUsingTypeInternal(
5576 D->TypeForDecl = CanonicalType;
5585 if (
const Type *
T = D->TypeForDecl;
T && !
T->isCanonicalUnqualified())
5592 nullptr, CanonicalType);
5597 llvm::FoldingSetNodeID ID;
5600 void *InsertPos =
nullptr;
5602 UnresolvedUsingTypes.FindNodeOrInsertPos(ID, InsertPos))
5603 return QualType(Placeholder->getType(), 0);
5607 const Type *
T = getUnresolvedUsingTypeInternal(
Keyword, Qualifier, D,
5608 InsertPos, CanonicalType);
5616 llvm::FoldingSetNodeID id;
5617 AttributedType::Profile(
id, attrKind, modifiedType, equivalentType,
attr);
5619 void *insertPos =
nullptr;
5620 AttributedType *
type = AttributedTypes.FindNodeOrInsertPos(
id, insertPos);
5623 assert(!
attr ||
attr->getKind() == attrKind);
5626 type =
new (*
this,
alignof(AttributedType))
5627 AttributedType(canon, attrKind,
attr, modifiedType, equivalentType);
5629 Types.push_back(
type);
5630 AttributedTypes.InsertNode(
type, insertPos);
5643 switch (nullability) {
5659 llvm_unreachable(
"Unknown nullability kind");
5664 llvm::FoldingSetNodeID ID;
5665 BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
5667 void *InsertPos =
nullptr;
5668 BTFTagAttributedType *Ty =
5669 BTFTagAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
5674 Ty =
new (*
this,
alignof(BTFTagAttributedType))
5675 BTFTagAttributedType(Canon, Wrapped, BTFAttr);
5677 Types.push_back(Ty);
5678 BTFTagAttributedTypes.InsertNode(Ty, InsertPos);
5685 const HLSLAttributedResourceType::Attributes &Attrs) {
5687 llvm::FoldingSetNodeID ID;
5688 HLSLAttributedResourceType::Profile(ID, Wrapped, Contained, Attrs);
5690 void *InsertPos =
nullptr;
5691 HLSLAttributedResourceType *Ty =
5692 HLSLAttributedResourceTypes.FindNodeOrInsertPos(ID, InsertPos);
5696 Ty =
new (*
this,
alignof(HLSLAttributedResourceType))
5697 HLSLAttributedResourceType(Wrapped, Contained, Attrs);
5699 Types.push_back(Ty);
5700 HLSLAttributedResourceTypes.InsertNode(Ty, InsertPos);
5708 llvm::FoldingSetNodeID ID;
5709 HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
5711 void *InsertPos =
nullptr;
5712 HLSLInlineSpirvType *Ty =
5713 HLSLInlineSpirvTypes.FindNodeOrInsertPos(ID, InsertPos);
5718 HLSLInlineSpirvType::totalSizeToAlloc<SpirvOperand>(Operands.size()),
5719 alignof(HLSLInlineSpirvType));
5721 Ty =
new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
5723 Types.push_back(Ty);
5724 HLSLInlineSpirvTypes.InsertNode(Ty, InsertPos);
5731 Decl *AssociatedDecl,
5735 llvm::FoldingSetNodeID ID;
5736 SubstTemplateTypeParmType::Profile(ID, Replacement, AssociatedDecl, Index,
5738 void *InsertPos =
nullptr;
5739 SubstTemplateTypeParmType *SubstParm =
5740 SubstTemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5743 void *Mem =
Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
5744 !Replacement.isCanonical()),
5745 alignof(SubstTemplateTypeParmType));
5746 SubstParm =
new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
5747 Index, PackIndex, Final);
5748 Types.push_back(SubstParm);
5749 SubstTemplateTypeParmTypes.InsertNode(SubstParm, InsertPos);
5757 unsigned Index,
bool Final,
5764 llvm::FoldingSetNodeID ID;
5765 SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
5767 void *InsertPos =
nullptr;
5768 if (SubstTemplateTypeParmPackType *SubstParm =
5769 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos))
5779 [[maybe_unused]]
const auto *Nothing =
5780 SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos);
5785 auto *SubstParm =
new (*
this,
alignof(SubstTemplateTypeParmPackType))
5786 SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
5788 Types.push_back(SubstParm);
5789 SubstTemplateTypeParmPackTypes.InsertNode(SubstParm, InsertPos);
5797 return P.getKind() == TemplateArgument::Type;
5799 "Pack contains a non-type");
5801 llvm::FoldingSetNodeID ID;
5802 SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
5804 void *InsertPos =
nullptr;
5806 SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos))
5815 [[maybe_unused]]
const auto *Nothing =
5816 SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos);
5820 auto *PackType =
new (*
this,
alignof(SubstBuiltinTemplatePackType))
5821 SubstBuiltinTemplatePackType(Canon, ArgPack);
5822 Types.push_back(PackType);
5823 SubstBuiltinTemplatePackTypes.InsertNode(PackType, InsertPos);
5833 llvm::FoldingSetNodeID ID;
5834 TemplateTypeParmType::Profile(ID, Depth, Index, ParameterPack, TTPDecl);
5835 void *InsertPos =
nullptr;
5836 TemplateTypeParmType *TypeParm
5837 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5844 TypeParm =
new (*
this,
alignof(TemplateTypeParmType))
5845 TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
5847 TemplateTypeParmType *TypeCheck
5848 = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
5849 assert(!TypeCheck &&
"Template type parameter canonical type broken");
5852 TypeParm =
new (*
this,
alignof(TemplateTypeParmType)) TemplateTypeParmType(
5853 Depth, Index, ParameterPack,
nullptr,
QualType());
5855 Types.push_back(TypeParm);
5856 TemplateTypeParmTypes.InsertNode(TypeParm, InsertPos);
5882 llvm_unreachable(
"unexpected keyword kind");
5896 ElaboratedKeywordLoc, QualifierLoc, TemplateKeywordLoc, NameLoc,
5906 SpecifiedArgVec.reserve(SpecifiedArgs.size());
5908 SpecifiedArgVec.push_back(Arg.getArgument());
5911 CanonicalArgs, Underlying);
5914[[maybe_unused]]
static bool
5917 if (Arg.isPackExpansion())
5928 Template.getAsDependentTemplateName()));
5930 for (
const auto &Arg : Args)
5934 llvm::FoldingSetNodeID ID;
5937 void *InsertPos =
nullptr;
5938 if (
auto *
T = TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
5941 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
5943 alignof(TemplateSpecializationType));
5947 assert(Spec->isDependentType() &&
5948 "canonical template specialization must be dependent");
5949 Types.push_back(Spec);
5950 TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
5958 const auto *TD =
Template.getAsTemplateDecl(
true);
5959 bool IsTypeAlias = TD && TD->isTypeAlias();
5960 if (Underlying.
isNull()) {
5967 bool NonCanonical =
Template != CanonTemplate ||
Keyword != CanonKeyword;
5969 if (CanonicalArgs.empty()) {
5972 CanonicalArgs = CanonArgsVec;
5974 NonCanonical |= !llvm::equal(
5975 SpecifiedArgs, CanonicalArgs,
5984 assert((!isa_and_nonnull<TypeAliasTemplateDecl>(TD) ||
5986 "Caller must compute aliased type");
5987 IsTypeAlias =
false;
5990 CanonKeyword, CanonTemplate, CanonicalArgs);
5994 void *Mem =
Allocate(
sizeof(TemplateSpecializationType) +
5996 (IsTypeAlias ?
sizeof(
QualType) : 0),
5997 alignof(TemplateSpecializationType));
5998 auto *Spec =
new (Mem) TemplateSpecializationType(
6000 Types.push_back(Spec);
6006 llvm::FoldingSetNodeID ID;
6009 void *InsertPos =
nullptr;
6010 ParenType *
T = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6017 ParenType *CheckT = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
6018 assert(!CheckT &&
"Paren canonical type broken");
6024 ParenTypes.InsertNode(
T, InsertPos);
6037 Types.push_back(newType);
6044 llvm::FoldingSetNodeID ID;
6045 DependentNameType::Profile(ID,
Keyword, NNS, Name);
6047 void *InsertPos =
nullptr;
6048 if (DependentNameType *
T =
6049 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos))
6057 if (CanonKeyword !=
Keyword || CanonNNS != NNS) {
6059 [[maybe_unused]] DependentNameType *
T =
6060 DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos);
6061 assert(!
T &&
"broken canonicalization");
6065 DependentNameType *
T =
new (*
this,
alignof(DependentNameType))
6066 DependentNameType(
Keyword, NNS, Name, Canon);
6068 DependentNameTypes.InsertNode(
T, InsertPos);
6074 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
6076 if (TTP->isParameterPack())
6080 }
else if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
6082 NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*
this);
6088 if (
T->isRecordType()) {
6097 Expr *E =
new (*this)
6099 T,
VK, NTTP->getLocation());
6101 if (NTTP->isParameterPack())
6107 std::nullopt,
false,
6109 if (TTP->isParameterPack())
6115 if (Param->isTemplateParameterPack())
6124 bool ExpectPackInType)
const {
6126 "Pack expansions must expand one or more parameter packs");
6128 llvm::FoldingSetNodeID ID;
6129 PackExpansionType::Profile(ID, Pattern, NumExpansions);
6131 void *InsertPos =
nullptr;
6132 PackExpansionType *
T = PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
6143 PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
6146 T =
new (*
this,
alignof(PackExpansionType))
6147 PackExpansionType(Pattern, Canon, NumExpansions);
6149 PackExpansionTypes.InsertNode(
T, InsertPos);
6161 if (Protocols.empty())
return true;
6166 for (
unsigned i = 1; i != Protocols.size(); ++i)
6176 llvm::array_pod_sort(Protocols.begin(), Protocols.end(),
CmpProtocolNames);
6180 P = P->getCanonicalDecl();
6183 auto ProtocolsEnd = llvm::unique(Protocols);
6184 Protocols.erase(ProtocolsEnd, Protocols.end());
6189 unsigned NumProtocols)
const {
6198 bool isKindOf)
const {
6201 if (typeArgs.empty() && protocols.empty() && !isKindOf &&
6206 llvm::FoldingSetNodeID ID;
6207 ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
6208 void *InsertPos =
nullptr;
6209 if (
ObjCObjectType *QT = ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos))
6216 if (effectiveTypeArgs.empty()) {
6218 effectiveTypeArgs = baseObject->getTypeArgs();
6225 bool typeArgsAreCanonical = llvm::all_of(
6228 if (!typeArgsAreCanonical || !protocolsSorted || !baseType.
isCanonical()) {
6232 if (!typeArgsAreCanonical) {
6233 canonTypeArgsVec.reserve(effectiveTypeArgs.size());
6234 for (
auto typeArg : effectiveTypeArgs)
6236 canonTypeArgs = canonTypeArgsVec;
6238 canonTypeArgs = effectiveTypeArgs;
6243 if (!protocolsSorted) {
6244 canonProtocolsVec.append(protocols.begin(), protocols.end());
6246 canonProtocols = canonProtocolsVec;
6248 canonProtocols = protocols;
6252 canonProtocols, isKindOf);
6255 ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos);
6258 unsigned size =
sizeof(ObjCObjectTypeImpl);
6259 size += typeArgs.size() *
sizeof(
QualType);
6261 void *mem =
Allocate(size,
alignof(ObjCObjectTypeImpl));
6263 new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
6267 ObjCObjectTypes.InsertNode(
T, InsertPos);
6277 bool allowOnPointerType)
const {
6280 if (
const auto *objT = dyn_cast<ObjCTypeParamType>(
type.getTypePtr())) {
6285 if (allowOnPointerType) {
6286 if (
const auto *objPtr =
6287 dyn_cast<ObjCObjectPointerType>(
type.getTypePtr())) {
6291 protocolsVec.append(objT->qual_begin(),
6293 protocolsVec.append(protocols.begin(), protocols.end());
6296 objT->getBaseType(),
6297 objT->getTypeArgsAsWritten(),
6299 objT->isKindOfTypeAsWritten());
6305 if (
const auto *objT = dyn_cast<ObjCObjectType>(
type.getTypePtr())){
6310 objT->getTypeArgsAsWritten(),
6312 objT->isKindOfTypeAsWritten());
6316 if (
type->isObjCObjectType()) {
6326 if (
type->isObjCIdType()) {
6329 objPtr->isKindOfType());
6334 if (
type->isObjCClassType()) {
6337 objPtr->isKindOfType());
6349 llvm::FoldingSetNodeID ID;
6350 ObjCTypeParamType::Profile(ID,
Decl,
Decl->getUnderlyingType(), protocols);
6351 void *InsertPos =
nullptr;
6352 if (ObjCTypeParamType *TypeParam =
6353 ObjCTypeParamTypes.FindNodeOrInsertPos(ID, InsertPos))
6358 if (!protocols.empty()) {
6362 Canonical, protocols, hasError,
true ));
6363 assert(!hasError &&
"Error when apply protocol qualifier to bound type");
6366 unsigned size =
sizeof(ObjCTypeParamType);
6368 void *mem =
Allocate(size,
alignof(ObjCTypeParamType));
6369 auto *newType =
new (mem) ObjCTypeParamType(
Decl, Canonical, protocols);
6371 Types.push_back(newType);
6372 ObjCTypeParamTypes.InsertNode(newType, InsertPos);
6382 protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end());
6397 for (
auto *Proto : OPT->quals()) {
6420 if (InheritedProtocols.empty())
6424 bool Conforms =
false;
6425 for (
auto *Proto : OPT->quals()) {
6427 for (
auto *PI : InheritedProtocols) {
6439 for (
auto *PI : InheritedProtocols) {
6441 bool Adopts =
false;
6442 for (
auto *Proto : OPT->quals()) {
6456 llvm::FoldingSetNodeID ID;
6459 void *InsertPos =
nullptr;
6461 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
6470 ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
6479 Types.push_back(QType);
6480 ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
6488 if (
Decl->TypeForDecl)
6492 assert(PrevDecl->TypeForDecl &&
"previous decl has no TypeForDecl");
6493 Decl->TypeForDecl = PrevDecl->TypeForDecl;
6494 return QualType(PrevDecl->TypeForDecl, 0);
6503 Decl->TypeForDecl =
T;
6516 llvm::FoldingSetNodeID ID;
6520 void *InsertPos =
nullptr;
6522 DependentTypeOfExprTypes.FindNodeOrInsertPos(ID, InsertPos);
6532 DependentTypeOfExprTypes.InsertNode(Canon, InsertPos);
6540 Types.push_back(toe);
6551 auto *tot =
new (*
this,
alignof(TypeOfType))
6552 TypeOfType(*
this, tofType, Canonical, Kind);
6553 Types.push_back(tot);
6577 llvm_unreachable(
"Unknown value kind");
6592 }
else if (!UnderlyingType.
isNull()) {
6595 llvm::FoldingSetNodeID ID;
6596 DependentDecltypeType::Profile(ID, *
this, E);
6598 void *InsertPos =
nullptr;
6599 if (DependentDecltypeType *Canon =
6600 DependentDecltypeTypes.FindNodeOrInsertPos(ID, InsertPos))
6605 new (*
this,
alignof(DependentDecltypeType)) DependentDecltypeType(E);
6606 DependentDecltypeTypes.InsertNode(DT, InsertPos);
6607 Types.push_back(DT);
6610 auto *DT =
new (*
this,
alignof(DecltypeType))
6611 DecltypeType(E, UnderlyingType, CanonType);
6612 Types.push_back(DT);
6617 bool FullySubstituted,
6621 if (FullySubstituted && Index) {
6624 llvm::FoldingSetNodeID ID;
6625 PackIndexingType::Profile(ID, *
this, Pattern.
getCanonicalType(), IndexExpr,
6626 FullySubstituted, Expansions);
6627 void *InsertPos =
nullptr;
6628 PackIndexingType *Canon =
6629 DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos);
6632 PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6636 IndexExpr, FullySubstituted, Expansions);
6637 DependentPackIndexingTypes.InsertNode(Canon, InsertPos);
6643 Allocate(PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
6645 auto *
T =
new (Mem) PackIndexingType(Canonical, Pattern, IndexExpr,
6646 FullySubstituted, Expansions);
6655 UnaryTransformType::UTTKind Kind)
const {
6657 llvm::FoldingSetNodeID ID;
6658 UnaryTransformType::Profile(ID, BaseType, UnderlyingType, Kind);
6660 void *InsertPos =
nullptr;
6661 if (UnaryTransformType *UT =
6662 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos))
6666 if (!BaseType->isDependentType()) {
6669 assert(UnderlyingType.
isNull() || BaseType == UnderlyingType);
6672 BaseType != CanonBase) {
6677 [[maybe_unused]] UnaryTransformType *UT =
6678 UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos);
6679 assert(!UT &&
"broken canonicalization");
6683 auto *UT =
new (*
this,
alignof(UnaryTransformType))
6684 UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
6685 UnaryTransformTypes.InsertNode(UT, InsertPos);
6686 Types.push_back(UT);
6690QualType ASTContext::getAutoTypeInternal(
6695 !TypeConstraintConcept && !IsDependent)
6699 llvm::FoldingSetNodeID ID;
6700 bool IsDeducedDependent =
6701 isa_and_nonnull<TemplateTemplateParmDecl>(TypeConstraintConcept) ||
6703 AutoType::Profile(ID, *
this, DeducedType,
Keyword,
6704 IsDependent || IsDeducedDependent, TypeConstraintConcept,
6705 TypeConstraintArgs);
6706 if (
auto const AT_iter = AutoTypes.find(ID); AT_iter != AutoTypes.end())
6707 return QualType(AT_iter->getSecond(), 0);
6711 if (!DeducedType.
isNull()) {
6713 }
else if (TypeConstraintConcept) {
6714 bool AnyNonCanonArgs =
false;
6715 auto *CanonicalConcept =
6718 *
this, TypeConstraintArgs, AnyNonCanonArgs);
6719 if (CanonicalConcept != TypeConstraintConcept || AnyNonCanonArgs) {
6721 CanonicalConcept, CanonicalConceptArgs,
6727 void *Mem =
Allocate(
sizeof(AutoType) +
6728 sizeof(TemplateArgument) * TypeConstraintArgs.size(),
6730 auto *AT =
new (Mem) AutoType(
6732 (IsDependent ? TypeDependence::DependentInstantiation
6733 : TypeDependence::None) |
6734 (IsPack ? TypeDependence::UnexpandedPack : TypeDependence::None),
6735 Canon, TypeConstraintConcept, TypeConstraintArgs);
6737 llvm::FoldingSetNodeID InsertedID;
6738 AT->Profile(InsertedID, *
this);
6739 assert(InsertedID == ID &&
"ID does not match");
6741 Types.push_back(AT);
6742 AutoTypes.try_emplace(ID, AT);
6743 return QualType(AT, 0);
6751 bool IsDependent,
bool IsPack,
6754 assert((!IsPack || IsDependent) &&
"only use IsPack for a dependent pack");
6755 assert((!IsDependent || DeducedType.
isNull()) &&
6756 "A dependent auto should be undeduced");
6757 return getAutoTypeInternal(DeducedType,
Keyword, IsDependent, IsPack,
6758 TypeConstraintConcept, TypeConstraintArgs);
6762 QualType CanonT =
T.getNonPackExpansionType().getCanonicalType();
6765 if (
auto *AT = CanonT->
getAs<AutoType>()) {
6766 if (!AT->isConstrained())
6770 AT->containsUnexpandedParameterPack()),
6782QualType ASTContext::getDeducedTemplateSpecializationTypeInternal(
6784 bool IsDependent,
QualType Canon)
const {
6786 void *InsertPos =
nullptr;
6787 llvm::FoldingSetNodeID ID;
6788 DeducedTemplateSpecializationType::Profile(ID,
Keyword,
Template, DeducedType,
6790 if (DeducedTemplateSpecializationType *DTST =
6791 DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
6794 auto *DTST =
new (*
this,
alignof(DeducedTemplateSpecializationType))
6796 IsDependent, Canon);
6799 llvm::FoldingSetNodeID TempID;
6800 DTST->Profile(TempID);
6801 assert(ID == TempID &&
"ID does not match");
6803 Types.push_back(DTST);
6804 DeducedTemplateSpecializationTypes.InsertNode(DTST, InsertPos);
6813 bool IsDependent)
const {
6820 ? getDeducedTemplateSpecializationTypeInternal(
6824 return getDeducedTemplateSpecializationTypeInternal(
6833 llvm::FoldingSetNodeID ID;
6836 void *InsertPos =
nullptr;
6837 if (
AtomicType *AT = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos))
6843 if (!
T.isCanonical()) {
6847 AtomicType *NewIP = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos);
6848 assert(!NewIP &&
"Shouldn't be in the map!"); (void)NewIP;
6851 Types.push_back(
New);
6852 AtomicTypes.InsertNode(
New, InsertPos);
6883 return getFromTargetType(Target->getSizeType());
6902 return getFromTargetType(Target->getUnsignedPtrDiffType(
LangAS::Default));
6907 return getFromTargetType(Target->getIntMaxType());
6912 return getFromTargetType(Target->getUIntMaxType());
6930 return getFromTargetType(Target->getIntPtrType());
6940 return getFromTargetType(Target->getProcessIDType());
6952 const Type *Ty =
T.getTypePtr();
6980 quals = splitType.
Quals;
6985 QualType elementType = AT->getElementType();
6990 if (elementType == unqualElementType) {
6991 assert(quals.
empty());
6992 quals = splitType.
Quals;
7000 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
7002 CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
7005 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
7009 if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
7011 VAT->getSizeModifier(),
7012 VAT->getIndexTypeCVRQualifiers());
7017 DSAT->getSizeModifier(), 0);
7027 bool AllowPiMismatch)
const {
7042 if (
auto *CAT1 = dyn_cast<ConstantArrayType>(AT1)) {
7043 auto *CAT2 = dyn_cast<ConstantArrayType>(AT2);
7044 if (!((CAT2 && CAT1->getSize() == CAT2->getSize()) ||
7057 T1 = AT1->getElementType();
7058 T2 = AT2->getElementType();
7078 bool AllowPiMismatch)
const {
7083 if (T1PtrType && T2PtrType) {
7091 T1MPType && T2MPType) {
7092 if (
auto *RD1 = T1MPType->getMostRecentCXXRecordDecl(),
7093 *RD2 = T2MPType->getMostRecentCXXRecordDecl();
7094 RD1 != RD2 && RD1->getCanonicalDecl() != RD2->getCanonicalDecl())
7096 if (T1MPType->getQualifier().getCanonical() !=
7097 T2MPType->getQualifier().getCanonical())
7107 if (T1OPType && T2OPType) {
7139 if (Quals1 != Quals2)
7209 llvm_unreachable(
"bad template name kind!");
7215 if (!TP->hasDefaultArgument())
7217 return &TP->getDefaultArgument().getArgument();
7220 case NamedDecl::TemplateTypeParm:
7222 case NamedDecl::NonTypeTemplateParm:
7224 case NamedDecl::TemplateTemplateParm:
7227 llvm_unreachable(
"Unexpected template parameter kind");
7232 bool IgnoreDeduced)
const {
7233 while (std::optional<TemplateName> UnderlyingOrNone =
7235 Name = *UnderlyingOrNone;
7240 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template))
7249 llvm_unreachable(
"cannot canonicalize unresolved template");
7253 assert(DTN &&
"Non-dependent template names must refer to template decls.");
7272 assert(IgnoreDeduced ==
false);
7279 bool NonCanonical = CanonUnderlying != Underlying;
7285 assert(CanonArgs.size() <= Params.size());
7291 for (
int I = CanonArgs.size() - 1; I >= 0; --I) {
7300 if (I ==
int(CanonArgs.size() - 1))
7301 CanonArgs.pop_back();
7302 NonCanonical =
true;
7312 llvm_unreachable(
"always sugar node");
7315 llvm_unreachable(
"bad template name!");
7320 bool IgnoreDeduced)
const {
7341 llvm::FoldingSetNodeID XCEID, YCEID;
7342 XCE->
Profile(XCEID, *
this,
true,
true);
7343 YCE->
Profile(YCEID, *
this,
true,
true);
7344 return XCEID == YCEID;
7393 if (
auto *TX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7395 if (TX->isParameterPack() != TY->isParameterPack())
7397 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
7400 TY->getTypeConstraint());
7403 if (
auto *TX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7405 return TX->isParameterPack() == TY->isParameterPack() &&
7406 TX->getASTContext().hasSameType(TX->getType(), TY->getType()) &&
7408 TY->getPlaceholderTypeConstraint());
7413 return TX->isParameterPack() == TY->isParameterPack() &&
7415 TY->getTemplateParameters());
7420 if (
X->size() != Y->
size())
7423 for (
unsigned I = 0, N =
X->size(); I != N; ++I)
7437 if (
auto *TTPX = dyn_cast<TemplateTypeParmDecl>(
X)) {
7439 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7442 return hasSameType(TTPX->getDefaultArgument().getArgument().getAsType(),
7443 TTPY->getDefaultArgument().getArgument().getAsType());
7446 if (
auto *NTTPX = dyn_cast<NonTypeTemplateParmDecl>(
X)) {
7448 if (!NTTPX->hasDefaultArgument() || !NTTPY->hasDefaultArgument())
7451 Expr *DefaultArgumentX =
7452 NTTPX->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7453 Expr *DefaultArgumentY =
7454 NTTPY->getDefaultArgument().getArgument().getAsExpr()->
IgnoreImpCasts();
7455 llvm::FoldingSetNodeID XID, YID;
7456 DefaultArgumentX->
Profile(XID, *
this,
true);
7457 DefaultArgumentY->
Profile(YID, *
this,
true);
7464 if (!TTPX->hasDefaultArgument() || !TTPY->hasDefaultArgument())
7479 auto Kind =
X.getKind();
7487 auto [NamespaceX, PrefixX] =
X.getAsNamespaceAndPrefix();
7490 NamespaceY->getNamespace()))
7495 const auto *TX =
X.getAsType(), *TY = Y.
getAsType();
7496 if (TX->getCanonicalTypeInternal() != TY->getCanonicalTypeInternal())
7505 llvm_unreachable(
"unhandled qualifier kind");
7511 if (A->
hasAttr<CUDADeviceAttr>() != B->
hasAttr<CUDADeviceAttr>())
7513 if (A->
hasAttr<CUDADeviceAttr>() && B->
hasAttr<CUDADeviceAttr>())
7525 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
7529 for (
auto Pair : zip_longest(AEnableIfAttrs, BEnableIfAttrs)) {
7530 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
7531 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
7534 if (!Cand1A || !Cand2A)
7540 (*Cand1A)->getCond()->Profile(Cand1ID, A->
getASTContext(),
true);
7541 (*Cand2A)->getCond()->Profile(Cand2ID, B->
getASTContext(),
true);
7545 if (Cand1ID != Cand2ID)
7579 if (
const auto *TypedefX = dyn_cast<TypedefNameDecl>(
X))
7580 if (
const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y))
7582 TypedefY->getUnderlyingType());
7599 if (
const auto *TagX = dyn_cast<TagDecl>(
X)) {
7601 return (TagX->getTagKind() == TagY->getTagKind()) ||
7613 if (
const auto *FuncX = dyn_cast<FunctionDecl>(
X)) {
7615 if (
const auto *CtorX = dyn_cast<CXXConstructorDecl>(
X)) {
7617 if (CtorX->getInheritedConstructor() &&
7618 !
isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
7619 CtorY->getInheritedConstructor().getConstructor()))
7623 if (FuncX->isMultiVersion() != FuncY->isMultiVersion())
7628 if (FuncX->isMultiVersion()) {
7629 const auto *TAX = FuncX->getAttr<TargetAttr>();
7630 const auto *TAY = FuncY->getAttr<TargetAttr>();
7631 assert(TAX && TAY &&
"Multiversion Function without target attribute");
7633 if (TAX->getFeaturesStr() != TAY->getFeaturesStr())
7639 if ((FuncX->isMemberLikeConstrainedFriend() ||
7640 FuncY->isMemberLikeConstrainedFriend()) &&
7641 !FuncX->getLexicalDeclContext()->Equals(
7642 FuncY->getLexicalDeclContext())) {
7647 FuncY->getTrailingRequiresClause()))
7655 FD = FD->getCanonicalDecl();
7656 return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType()
7659 QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY);
7674 return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
7679 if (
const auto *VarX = dyn_cast<VarDecl>(
X)) {
7681 if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
7684 if (VarX->getType().isNull() || VarY->getType().isNull())
7687 if (
hasSameType(VarX->getType(), VarY->getType()))
7697 if (!VarXTy || !VarYTy)
7706 if (
const auto *NamespaceX = dyn_cast<NamespaceDecl>(
X)) {
7708 return NamespaceX->isInline() == NamespaceY->isInline();
7713 if (
const auto *TemplateX = dyn_cast<TemplateDecl>(
X)) {
7717 if (
const auto *ConceptX = dyn_cast<ConceptDecl>(
X)) {
7720 ConceptY->getConstraintExpr()))
7725 TemplateY->getTemplatedDecl()) &&
7727 TemplateY->getTemplateParameters());
7731 if (
const auto *FDX = dyn_cast<FieldDecl>(
X)) {
7734 return hasSameType(FDX->getType(), FDY->getType());
7738 if (
const auto *IFDX = dyn_cast<IndirectFieldDecl>(
X)) {
7740 return IFDX->getAnonField()->getCanonicalDecl() ==
7741 IFDY->getAnonField()->getCanonicalDecl();
7750 if (
const auto *USX = dyn_cast<UsingShadowDecl>(
X)) {
7757 if (
const auto *UX = dyn_cast<UsingDecl>(
X)) {
7760 UX->hasTypename() == UY->hasTypename() &&
7761 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7763 if (
const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(
X)) {
7766 UX->isAccessDeclaration() == UY->isAccessDeclaration();
7768 if (
const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(
X)) {
7776 if (
const auto *UX = dyn_cast<UsingPackDecl>(
X)) {
7778 UX->getInstantiatedFromUsingDecl(),
7783 if (
const auto *NAX = dyn_cast<NamespaceAliasDecl>(
X)) {
7785 return NAX->getNamespace()->Equals(NAY->getNamespace());
7833 bool AnyNonCanonArgs =
false;
7836 if (!AnyNonCanonArgs)
7846 llvm_unreachable(
"Unhandled template argument kind");
7856 llvm_unreachable(
"Comparing NULL template argument");
7881 llvm::FoldingSetNodeID ID1, ID2;
7891 return isSameTemplateArgument(Arg1, Arg2);
7895 llvm_unreachable(
"Unhandled template argument kind");
7900 if (!
T.hasLocalQualifiers()) {
7902 if (
const auto *AT = dyn_cast<ArrayType>(
T))
7922 const auto *ATy = dyn_cast<ArrayType>(split.
Ty);
7923 if (!ATy || qs.
empty())
7930 if (
const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
7933 CAT->getSizeModifier(),
7934 CAT->getIndexTypeCVRQualifiers()));
7935 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
7937 IAT->getSizeModifier(),
7938 IAT->getIndexTypeCVRQualifiers()));
7940 if (
const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
7942 NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
7943 DSAT->getIndexTypeCVRQualifiers()));
7948 VAT->getIndexTypeCVRQualifiers()));
7954 if (
T->isArrayType() ||
T->isFunctionType())
7962 return T.getUnqualifiedType();
7973 if (
T->isArrayType() ||
T->isFunctionType())
7975 return T.getUnqualifiedType();
7990 assert(PrettyArrayType &&
"Not an array type!");
8027 uint64_t ElementCount = 1;
8030 CA = dyn_cast_or_null<ConstantArrayType>(
8033 return ElementCount;
8041 uint64_t ElementCount = 1;
8045 AILE = dyn_cast<ArrayInitLoopExpr>(AILE->
getSubExpr());
8048 return ElementCount;
8058 default: llvm_unreachable(
"getFloatingRank(): not a floating type");
8060 case BuiltinType::Half:
return HalfRank;
8061 case BuiltinType::Float:
return FloatRank;
8094unsigned ASTContext::getIntegerRank(
const Type *
T)
const {
8095 assert(
T->isCanonicalUnqualified() &&
"T should be canonicalized");
8099 if (
const auto *EIT = dyn_cast<BitIntType>(
T))
8100 return 0 + (EIT->getNumBits() << 3);
8103 default: llvm_unreachable(
"getIntegerRank(): not a built-in integer");
8104 case BuiltinType::Bool:
8106 case BuiltinType::Char_S:
8107 case BuiltinType::Char_U:
8108 case BuiltinType::SChar:
8109 case BuiltinType::UChar:
8111 case BuiltinType::Short:
8112 case BuiltinType::UShort:
8114 case BuiltinType::Int:
8115 case BuiltinType::UInt:
8117 case BuiltinType::Long:
8118 case BuiltinType::ULong:
8120 case BuiltinType::LongLong:
8121 case BuiltinType::ULongLong:
8123 case BuiltinType::Int128:
8124 case BuiltinType::UInt128:
8129 case BuiltinType::Char8:
8131 case BuiltinType::Char16:
8132 return getIntegerRank(
8134 case BuiltinType::Char32:
8135 return getIntegerRank(
8137 case BuiltinType::WChar_S:
8138 case BuiltinType::WChar_U:
8139 return getIntegerRank(
8169 uint64_t BitWidth = Field->getBitWidthValue();
8195 if (BitWidth < IntSize)
8198 if (BitWidth == IntSize)
8213 assert(!Promotable.
isNull());
8216 return ED->getPromotionType();
8225 if (BT->getKind() == BuiltinType::WChar_S ||
8226 BT->getKind() == BuiltinType::WChar_U ||
8227 BT->getKind() == BuiltinType::Char8 ||
8228 BT->getKind() == BuiltinType::Char16 ||
8229 BT->getKind() == BuiltinType::Char32) {
8230 bool FromIsSigned = BT->getKind() == BuiltinType::WChar_S;
8234 for (
const auto &PT : PromoteTypes) {
8236 if (FromSize < ToSize ||
8237 (FromSize == ToSize && FromIsSigned == PT->isSignedIntegerType()))
8240 llvm_unreachable(
"char type should fit into long long");
8247 uint64_t PromotableSize =
getIntWidth(Promotable);
8256 while (!
T.isNull()) {
8258 return T.getObjCLifetime();
8259 if (
T->isArrayType())
8262 T = PT->getPointeeType();
8264 T = RT->getPointeeType();
8289 if (
const auto *ET = dyn_cast<EnumType>(LHSC))
8291 if (
const auto *ET = dyn_cast<EnumType>(RHSC))
8294 if (LHSC == RHSC)
return 0;
8299 unsigned LHSRank = getIntegerRank(LHSC);
8300 unsigned RHSRank = getIntegerRank(RHSC);
8302 if (LHSUnsigned == RHSUnsigned) {
8303 if (LHSRank == RHSRank)
return 0;
8304 return LHSRank > RHSRank ? 1 : -1;
8310 if (LHSRank >= RHSRank)
8320 if (RHSRank >= LHSRank)
8330 if (CFConstantStringTypeDecl)
8331 return CFConstantStringTypeDecl;
8333 assert(!CFConstantStringTagDecl &&
8334 "tag and typedef should be initialized together");
8336 CFConstantStringTagDecl->startDefinition();
8374 if (
static_cast<unsigned>(CFRuntime) <
8377 Fields[Count++] = {
IntTy,
"flags" };
8379 Fields[Count++] = {
LongTy,
"length" };
8383 Fields[Count++] = { getFromTargetType(Target->getUInt64Type()),
"_swift_rc" };
8387 Fields[Count++] = {
IntTy,
"_ptr" };
8393 for (
unsigned i = 0; i < Count; ++i) {
8397 Fields[i].Type,
nullptr,
8400 CFConstantStringTagDecl->addDecl(Field);
8403 CFConstantStringTagDecl->completeDefinition();
8407 CFConstantStringTypeDecl =
8410 return CFConstantStringTypeDecl;
8414 if (!CFConstantStringTagDecl)
8416 return CFConstantStringTagDecl;
8426 if (ObjCSuperType.isNull()) {
8431 return ObjCSuperType;
8437 CFConstantStringTagDecl = TT->castAsRecordDecl();
8441 if (BlockDescriptorType)
8454 static const char *
const FieldNames[] = {
8459 for (
size_t i = 0; i < 2; ++i) {
8462 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8470 BlockDescriptorType = RD;
8476 if (BlockDescriptorExtendedType)
8491 static const char *
const FieldNames[] = {
8498 for (
size_t i = 0; i < 4; ++i) {
8501 &
Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
8510 BlockDescriptorExtendedType = RD;
8515 const auto *BT = dyn_cast<BuiltinType>(
T);
8524 switch (BT->getKind()) {
8525#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
8526 case BuiltinType::Id: \
8528#include "clang/Basic/OpenCLImageTypes.def"
8530 case BuiltinType::OCLClkEvent:
8533 case BuiltinType::OCLEvent:
8536 case BuiltinType::OCLQueue:
8539 case BuiltinType::OCLReserveID:
8542 case BuiltinType::OCLSampler:
8561 if (!copyExpr && record->hasTrivialDestructor())
return false;
8592 llvm_unreachable(
"impossible");
8594 llvm_unreachable(
"fell out of lifetime switch!");
8602 bool &HasByrefExtendedLayout)
const {
8607 HasByrefExtendedLayout =
false;
8609 HasByrefExtendedLayout =
true;
8623 assert(Target &&
"Expected target to be initialized");
8624 const llvm::Triple &
T = Target->getTriple();
8626 if (
T.isOSWindows() &&
T.isArch64Bit())
8632 assert(Target &&
"Expected target to be initialized");
8633 const llvm::Triple &
T = Target->getTriple();
8635 if (
T.isOSWindows() &&
T.isArch64Bit())
8641 if (!ObjCInstanceTypeDecl)
8642 ObjCInstanceTypeDecl =
8644 return ObjCInstanceTypeDecl;
8650 if (
const auto *TT = dyn_cast<TypedefType>(
T))
8652 return II->isStr(
"BOOL");
8660 if (!
type->isIncompleteArrayType() &&
type->isIncompleteType())
8669 else if (
type->isArrayType())
8688 if (
First->isInlineSpecified() || !
First->isStaticDataMember())
8695 !D->isInlineSpecified() && (D->isConstexpr() ||
First->isConstexpr()))
8726 for (
auto *PI :
Decl->parameters()) {
8731 assert(sz.
isPositive() &&
"BlockExpr - Incomplete param type");
8740 ParmOffset = PtrSize;
8741 for (
auto *PVDecl :
Decl->parameters()) {
8742 QualType PType = PVDecl->getOriginalType();
8743 if (
const auto *AT =
8748 PType = PVDecl->getType();
8750 PType = PVDecl->getType();
8770 for (
auto *PI :
Decl->parameters()) {
8777 "getObjCEncodingForFunctionDecl - Incomplete param type");
8784 for (
auto *PVDecl :
Decl->parameters()) {
8785 QualType PType = PVDecl->getOriginalType();
8786 if (
const auto *AT =
8791 PType = PVDecl->getType();
8793 PType = PVDecl->getType();
8807 bool Extended)
const {
8811 ObjCEncOptions Options = ObjCEncOptions()
8812 .setExpandPointedToStructures()
8813 .setExpandStructures()
8814 .setIsOutermostType();
8816 Options.setEncodeBlockParameters().setEncodeClassNames();
8817 getObjCEncodingForTypeImpl(
T, S, Options,
nullptr);
8823 bool Extended)
const {
8828 Decl->getReturnType(), S, Extended);
8837 E =
Decl->sel_param_end(); PI != E; ++PI) {
8844 "getObjCEncodingForMethodDecl - Incomplete param type");
8852 ParmOffset = 2 * PtrSize;
8854 E =
Decl->sel_param_end(); PI != E; ++PI) {
8857 if (
const auto *AT =
8866 PType, S, Extended);
8877 const Decl *Container)
const {
8880 if (
const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
8881 for (
auto *PID : CID->property_impls())
8882 if (PID->getPropertyDecl() == PD)
8886 for (
auto *PID : OID->property_impls())
8887 if (PID->getPropertyDecl() == PD)
8921 const Decl *Container)
const {
8923 bool Dynamic =
false;
8931 SynthesizePID = PropertyImpDecl;
8935 std::string S =
"T";
8980 if (SynthesizePID) {
8997 if (BT->getKind() == BuiltinType::ULong &&
getIntWidth(PointeeTy) == 32)
9000 if (BT->getKind() == BuiltinType::Long &&
getIntWidth(PointeeTy) == 32)
9013 getObjCEncodingForTypeImpl(
T, S,
9015 .setExpandPointedToStructures()
9016 .setExpandStructures()
9017 .setIsOutermostType(),
9018 Field, NotEncodedT);
9022 std::string& S)
const {
9026 getObjCEncodingForTypeImpl(
T, S,
9028 .setExpandPointedToStructures()
9029 .setExpandStructures()
9030 .setIsOutermostType()
9031 .setEncodingProperty(),
9039 case BuiltinType::Void:
return 'v';
9040 case BuiltinType::Bool:
return 'B';
9041 case BuiltinType::Char8:
9042 case BuiltinType::Char_U:
9043 case BuiltinType::UChar:
return 'C';
9044 case BuiltinType::Char16:
9045 case BuiltinType::UShort:
return 'S';
9046 case BuiltinType::Char32:
9047 case BuiltinType::UInt:
return 'I';
9048 case BuiltinType::ULong:
9049 return C->getTargetInfo().getLongWidth() == 32 ?
'L' :
'Q';
9050 case BuiltinType::UInt128:
return 'T';
9051 case BuiltinType::ULongLong:
return 'Q';
9052 case BuiltinType::Char_S:
9053 case BuiltinType::SChar:
return 'c';
9054 case BuiltinType::Short:
return 's';
9055 case BuiltinType::WChar_S:
9056 case BuiltinType::WChar_U:
9057 case BuiltinType::Int:
return 'i';
9058 case BuiltinType::Long:
9059 return C->getTargetInfo().getLongWidth() == 32 ?
'l' :
'q';
9060 case BuiltinType::LongLong:
return 'q';
9061 case BuiltinType::Int128:
return 't';
9062 case BuiltinType::Float:
return 'f';
9063 case BuiltinType::Double:
return 'd';
9064 case BuiltinType::LongDouble:
return 'D';
9065 case BuiltinType::NullPtr:
return '*';
9067 case BuiltinType::BFloat16:
9068 case BuiltinType::Float16:
9069 case BuiltinType::Float128:
9070 case BuiltinType::Ibm128:
9071 case BuiltinType::Half:
9072 case BuiltinType::ShortAccum:
9073 case BuiltinType::Accum:
9074 case BuiltinType::LongAccum:
9075 case BuiltinType::UShortAccum:
9076 case BuiltinType::UAccum:
9077 case BuiltinType::ULongAccum:
9078 case BuiltinType::ShortFract:
9079 case BuiltinType::Fract:
9080 case BuiltinType::LongFract:
9081 case BuiltinType::UShortFract:
9082 case BuiltinType::UFract:
9083 case BuiltinType::ULongFract:
9084 case BuiltinType::SatShortAccum:
9085 case BuiltinType::SatAccum:
9086 case BuiltinType::SatLongAccum:
9087 case BuiltinType::SatUShortAccum:
9088 case BuiltinType::SatUAccum:
9089 case BuiltinType::SatULongAccum:
9090 case BuiltinType::SatShortFract:
9091 case BuiltinType::SatFract:
9092 case BuiltinType::SatLongFract:
9093 case BuiltinType::SatUShortFract:
9094 case BuiltinType::SatUFract:
9095 case BuiltinType::SatULongFract:
9099#define SVE_TYPE(Name, Id, SingletonId) \
9100 case BuiltinType::Id:
9101#include "clang/Basic/AArch64ACLETypes.def"
9102#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9103#include "clang/Basic/RISCVVTypes.def"
9104#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9105#include "clang/Basic/WebAssemblyReferenceTypes.def"
9106#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
9107#include "clang/Basic/AMDGPUTypes.def"
9111 "cannot yet @encode type %0");
9116 case BuiltinType::ObjCId:
9117 case BuiltinType::ObjCClass:
9118 case BuiltinType::ObjCSel:
9119 llvm_unreachable(
"@encoding ObjC primitive type");
9122#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
9123 case BuiltinType::Id:
9124#include "clang/Basic/OpenCLImageTypes.def"
9125#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
9126 case BuiltinType::Id:
9127#include "clang/Basic/OpenCLExtensionTypes.def"
9128 case BuiltinType::OCLEvent:
9129 case BuiltinType::OCLClkEvent:
9130 case BuiltinType::OCLQueue:
9131 case BuiltinType::OCLReserveID:
9132 case BuiltinType::OCLSampler:
9133 case BuiltinType::Dependent:
9134#define PPC_VECTOR_TYPE(Name, Id, Size) \
9135 case BuiltinType::Id:
9136#include "clang/Basic/PPCTypes.def"
9137#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
9138#include "clang/Basic/HLSLIntangibleTypes.def"
9139#define BUILTIN_TYPE(KIND, ID)
9140#define PLACEHOLDER_TYPE(KIND, ID) \
9141 case BuiltinType::KIND:
9142#include "clang/AST/BuiltinTypes.def"
9143 llvm_unreachable(
"invalid builtin type for @encode");
9145 llvm_unreachable(
"invalid BuiltinType::Kind value");
9152 if (!
Enum->isFixed())
9162 assert(FD->
isBitField() &&
"not a bitfield - getObjCEncodingForTypeImpl");
9182 if (
const auto *IVD = dyn_cast<ObjCIvarDecl>(FD)) {
9190 S += llvm::utostr(Offset);
9192 if (
const auto *ET =
T->getAsCanonical<EnumType>())
9205 bool VisitBasesAndFields) {
9206 T =
T->getBaseElementTypeUnsafe();
9210 PT->getPointeeType().getTypePtr(),
false);
9212 auto *CXXRD =
T->getAsCXXRecordDecl();
9220 if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
9223 for (
const auto &B : CXXRD->bases())
9228 for (
auto *FD : CXXRD->fields())
9237void ASTContext::getObjCEncodingForTypeImpl(QualType
T, std::string &S,
9238 const ObjCEncOptions Options,
9239 const FieldDecl *FD,
9240 QualType *NotEncodedT)
const {
9242 switch (CT->getTypeClass()) {
9247 if (
const auto *BT = dyn_cast<BuiltinType>(CT))
9255 getObjCEncodingForTypeImpl(
T->
castAs<ComplexType>()->getElementType(), S,
9262 getObjCEncodingForTypeImpl(
T->
castAs<AtomicType>()->getValueType(), S,
9269 case Type::LValueReference:
9270 case Type::RValueReference: {
9273 const auto *PT =
T->
castAs<PointerType>();
9274 if (PT->isObjCSelType()) {
9283 bool isReadOnly =
false;
9288 if (
T->
getAs<TypedefType>()) {
9289 if (Options.IsOutermostType() &&
T.isConstQualified()) {
9293 }
else if (Options.IsOutermostType()) {
9294 QualType P = PointeeTy;
9295 while (
auto PT = P->
getAs<PointerType>())
9306 if (StringRef(S).ends_with(
"nr"))
9307 S.replace(S.end()-2, S.end(),
"rn");
9317 }
else if (
const auto *RTy = PointeeTy->
getAsCanonical<RecordType>()) {
9318 const IdentifierInfo *II = RTy->getDecl()->getIdentifier();
9320 if (II == &
Idents.get(
"objc_class")) {
9325 if (II == &
Idents.get(
"objc_object")) {
9334 RTy, Options.ExpandPointedToStructures()))) {
9343 ObjCEncOptions NewOptions;
9344 if (Options.ExpandPointedToStructures())
9345 NewOptions.setExpandStructures();
9346 getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions,
9347 nullptr, NotEncodedT);
9351 case Type::ConstantArray:
9352 case Type::IncompleteArray:
9353 case Type::VariableArray: {
9360 getObjCEncodingForTypeImpl(
9361 AT->getElementType(), S,
9362 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD);
9366 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
9367 S += llvm::utostr(CAT->getZExtSize());
9371 "Unknown array type!");
9375 getObjCEncodingForTypeImpl(
9376 AT->getElementType(), S,
9377 Options.keepingOnly(ObjCEncOptions().setExpandStructures()), FD,
9384 case Type::FunctionNoProto:
9385 case Type::FunctionProto:
9389 case Type::Record: {
9391 S += RDecl->
isUnion() ?
'(' :
'{';
9395 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
9396 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
9397 llvm::raw_string_ostream
OS(S);
9398 printTemplateArgumentList(OS, TemplateArgs.
asArray(),
9404 if (Options.ExpandStructures()) {
9407 getObjCEncodingForStructureImpl(RDecl, S, FD,
true, NotEncodedT);
9409 for (
const auto *Field : RDecl->
fields()) {
9412 S +=
Field->getNameAsString();
9417 if (
Field->isBitField()) {
9418 getObjCEncodingForTypeImpl(
Field->getType(), S,
9419 ObjCEncOptions().setExpandStructures(),
9422 QualType qt =
Field->getType();
9424 getObjCEncodingForTypeImpl(
9426 ObjCEncOptions().setExpandStructures().setIsStructField(), FD,
9432 S += RDecl->
isUnion() ?
')' :
'}';
9436 case Type::BlockPointer: {
9437 const auto *BT =
T->
castAs<BlockPointerType>();
9439 if (Options.EncodeBlockParameters()) {
9440 const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
9444 getObjCEncodingForTypeImpl(FT->getReturnType(), S,
9445 Options.forComponentType(), FD, NotEncodedT);
9449 if (
const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
9450 for (
const auto &I : FPT->param_types())
9451 getObjCEncodingForTypeImpl(I, S, Options.forComponentType(), FD,
9459 case Type::ObjCObject: {
9463 S +=
"{objc_object=}";
9467 S +=
"{objc_class=}";
9474 case Type::ObjCInterface: {
9477 ObjCInterfaceDecl *OI =
T->
castAs<ObjCObjectType>()->getInterface();
9480 if (Options.ExpandStructures()) {
9482 SmallVector<const ObjCIvarDecl*, 32> Ivars;
9484 for (
unsigned i = 0, e = Ivars.size(); i != e; ++i) {
9485 const FieldDecl *
Field = Ivars[i];
9486 if (
Field->isBitField())
9487 getObjCEncodingForTypeImpl(
Field->getType(), S,
9488 ObjCEncOptions().setExpandStructures(),
9491 getObjCEncodingForTypeImpl(
Field->getType(), S,
9492 ObjCEncOptions().setExpandStructures(), FD,
9500 case Type::ObjCObjectPointer: {
9501 const auto *OPT =
T->
castAs<ObjCObjectPointerType>();
9502 if (OPT->isObjCIdType()) {
9507 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
9515 if (OPT->isObjCQualifiedIdType()) {
9516 getObjCEncodingForTypeImpl(
9518 Options.keepingOnly(ObjCEncOptions()
9519 .setExpandPointedToStructures()
9520 .setExpandStructures()),
9522 if (FD || Options.EncodingProperty() || Options.EncodeClassNames()) {
9526 for (
const auto *I : OPT->quals()) {
9528 S += I->getObjCRuntimeNameAsString();
9537 if (OPT->getInterfaceDecl() &&
9538 (FD || Options.EncodingProperty() || Options.EncodeClassNames())) {
9540 S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
9541 for (
const auto *I : OPT->quals()) {
9543 S += I->getObjCRuntimeNameAsString();
9553 case Type::MemberPointer:
9557 case Type::ExtVector:
9563 case Type::ConstantMatrix:
9576 case Type::DeducedTemplateSpecialization:
9579 case Type::HLSLAttributedResource:
9580 case Type::HLSLInlineSpirv:
9581 llvm_unreachable(
"unexpected type");
9583 case Type::ArrayParameter:
9585#define ABSTRACT_TYPE(KIND, BASE)
9586#define TYPE(KIND, BASE)
9587#define DEPENDENT_TYPE(KIND, BASE) \
9589#define NON_CANONICAL_TYPE(KIND, BASE) \
9591#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE) \
9593#include "clang/AST/TypeNodes.inc"
9594 llvm_unreachable(
"@encode for dependent type!");
9596 llvm_unreachable(
"bad type kind!");
9599void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
9601 const FieldDecl *FD,
9603 QualType *NotEncodedT)
const {
9604 assert(RDecl &&
"Expected non-null RecordDecl");
9605 assert(!RDecl->
isUnion() &&
"Should not be called for unions");
9609 const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
9610 std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
9614 for (
const auto &BI : CXXRec->bases()) {
9615 if (!BI.isVirtual()) {
9620 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9621 std::make_pair(offs, base));
9626 for (FieldDecl *Field : RDecl->
fields()) {
9627 if (!
Field->isZeroLengthBitField() &&
Field->isZeroSize(*
this))
9630 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9631 std::make_pair(offs, Field));
9634 if (CXXRec && includeVBases) {
9635 for (
const auto &BI : CXXRec->vbases()) {
9641 FieldOrBaseOffsets.find(offs) == FieldOrBaseOffsets.end())
9642 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.end(),
9643 std::make_pair(offs, base));
9657 std::multimap<uint64_t, NamedDecl *>::iterator
9658 CurLayObj = FieldOrBaseOffsets.begin();
9660 if (CXXRec && CXXRec->isDynamicClass() &&
9661 (CurLayObj == FieldOrBaseOffsets.end() || CurLayObj->first != 0)) {
9664 std::string recname = CXXRec->getNameAsString();
9665 if (recname.empty()) recname =
"?";
9678 FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
9679 std::make_pair(offs,
nullptr));
9682 for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) {
9684 assert(CurOffs <= CurLayObj->first);
9685 if (CurOffs < CurLayObj->first) {
9686 uint64_t padding = CurLayObj->first - CurOffs;
9698 NamedDecl *dcl = CurLayObj->second;
9702 if (
auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
9707 getObjCEncodingForStructureImpl(base, S, FD,
false,
9717 S += field->getNameAsString();
9721 if (field->isBitField()) {
9724 CurOffs += field->getBitWidthValue();
9727 QualType qt = field->getType();
9729 getObjCEncodingForTypeImpl(
9730 qt, S, ObjCEncOptions().setExpandStructures().setIsStructField(),
9741 std::string& S)
const {
9774 if (!ObjCClassDecl) {
9779 return ObjCClassDecl;
9783 if (!ObjCProtocolClassDecl) {
9784 ObjCProtocolClassDecl
9793 return ObjCProtocolClassDecl;
9814 QualType T = Context->getPointerType(Context->CharTy);
9815 return Context->buildImplicitTypedef(
T, Name);
9828 QualType T = Context->getPointerType(Context->VoidTy);
9829 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
9836 if (Context->getLangOpts().CPlusPlus) {
9841 &Context->Idents.get(
"std"),
9849 const size_t NumFields = 5;
9851 const char *FieldNames[NumFields];
9854 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
9855 FieldNames[0] =
"__stack";
9858 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
9859 FieldNames[1] =
"__gr_top";
9862 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
9863 FieldNames[2] =
"__vr_top";
9866 FieldTypes[3] = Context->IntTy;
9867 FieldNames[3] =
"__gr_offs";
9870 FieldTypes[4] = Context->IntTy;
9871 FieldNames[4] =
"__vr_offs";
9874 for (
unsigned i = 0; i < NumFields; ++i) {
9879 &Context->Idents.get(FieldNames[i]),
9880 FieldTypes[i],
nullptr,
9892 return Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
9899 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
9902 const size_t NumFields = 5;
9904 const char *FieldNames[NumFields];
9907 FieldTypes[0] = Context->UnsignedCharTy;
9908 FieldNames[0] =
"gpr";
9911 FieldTypes[1] = Context->UnsignedCharTy;
9912 FieldNames[1] =
"fpr";
9915 FieldTypes[2] = Context->UnsignedShortTy;
9916 FieldNames[2] =
"reserved";
9919 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
9920 FieldNames[3] =
"overflow_arg_area";
9923 FieldTypes[4] = Context->getPointerType(Context->VoidTy);
9924 FieldNames[4] =
"reg_save_area";
9927 for (
unsigned i = 0; i < NumFields; ++i) {
9931 &Context->Idents.get(FieldNames[i]),
9932 FieldTypes[i],
nullptr,
9945 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
9949 std::nullopt, VaListTagTypedefDecl);
9952 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
9953 QualType VaListTagArrayType = Context->getConstantArrayType(
9955 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
9962 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
9965 const size_t NumFields = 4;
9967 const char *FieldNames[NumFields];
9970 FieldTypes[0] = Context->UnsignedIntTy;
9971 FieldNames[0] =
"gp_offset";
9974 FieldTypes[1] = Context->UnsignedIntTy;
9975 FieldNames[1] =
"fp_offset";
9978 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
9979 FieldNames[2] =
"overflow_arg_area";
9982 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
9983 FieldNames[3] =
"reg_save_area";
9986 for (
unsigned i = 0; i < NumFields; ++i) {
9991 &Context->Idents.get(FieldNames[i]),
9992 FieldTypes[i],
nullptr,
10006 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10007 QualType VaListTagArrayType = Context->getConstantArrayType(
10009 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10012static TypedefDecl *
10015 RecordDecl *VaListDecl = Context->buildImplicitRecord(
"__va_list");
10016 if (Context->getLangOpts().CPlusPlus) {
10035 &Context->Idents.get(
"__ap"),
10036 Context->getPointerType(Context->VoidTy),
10046 Context->VaListTagDecl = VaListDecl;
10049 CanQualType T = Context->getCanonicalTagType(VaListDecl);
10050 return Context->buildImplicitTypedef(
T,
"__builtin_va_list");
10053static TypedefDecl *
10057 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10060 const size_t NumFields = 4;
10062 const char *FieldNames[NumFields];
10065 FieldTypes[0] = Context->LongTy;
10066 FieldNames[0] =
"__gpr";
10069 FieldTypes[1] = Context->LongTy;
10070 FieldNames[1] =
"__fpr";
10073 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10074 FieldNames[2] =
"__overflow_arg_area";
10077 FieldTypes[3] = Context->getPointerType(Context->VoidTy);
10078 FieldNames[3] =
"__reg_save_area";
10081 for (
unsigned i = 0; i < NumFields; ++i) {
10086 &Context->Idents.get(FieldNames[i]),
10087 FieldTypes[i],
nullptr,
10101 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10102 QualType VaListTagArrayType = Context->getConstantArrayType(
10105 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10111 VaListTagDecl = Context->buildImplicitRecord(
"__va_list_tag");
10114 const size_t NumFields = 3;
10116 const char *FieldNames[NumFields];
10119 FieldTypes[0] = Context->getPointerType(Context->VoidTy);
10120 FieldNames[0] =
"__current_saved_reg_area_pointer";
10123 FieldTypes[1] = Context->getPointerType(Context->VoidTy);
10124 FieldNames[1] =
"__saved_reg_area_end_pointer";
10127 FieldTypes[2] = Context->getPointerType(Context->VoidTy);
10128 FieldNames[2] =
"__overflow_area_pointer";
10131 for (
unsigned i = 0; i < NumFields; ++i) {
10134 SourceLocation(), &Context->Idents.get(FieldNames[i]), FieldTypes[i],
10147 Context->buildImplicitTypedef(VaListTagType,
"__va_list_tag");
10151 std::nullopt, VaListTagTypedefDecl);
10154 llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1);
10155 QualType VaListTagArrayType = Context->getConstantArrayType(
10158 return Context->buildImplicitTypedef(VaListTagArrayType,
"__builtin_va_list");
10161static TypedefDecl *
10171 constexpr size_t NumFields = 3;
10172 QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
10173 Context->getPointerType(Context->IntTy),
10175 const char *FieldNames[NumFields] = {
"__va_stk",
"__va_reg",
"__va_ndx"};
10178 for (
unsigned i = 0; i < NumFields; ++i) {
10181 &Context->Idents.get(FieldNames[i]), FieldTypes[i],
nullptr,
10193 Context->buildImplicitTypedef(VaListTagType,
"__builtin_va_list");
10195 return VaListTagTypedefDecl;
10221 llvm_unreachable(
"Unhandled __builtin_va_list type kind");
10225 if (!BuiltinVaListDecl) {
10226 BuiltinVaListDecl =
CreateVaListDecl(
this, Target->getBuiltinVaListKind());
10227 assert(BuiltinVaListDecl->isImplicit());
10230 return BuiltinVaListDecl;
10243 if (!BuiltinMSVaListDecl)
10246 return BuiltinMSVaListDecl;
10263 assert(ObjCConstantStringType.isNull() &&
10264 "'NSConstantString' type already set!");
10274 unsigned size = End - Begin;
10275 assert(size > 1 &&
"set is not overloaded!");
10281 NamedDecl **Storage = OT->getStorage();
10304 bool TemplateKeyword,
10309 if (
Template.getAsTemplateDecl()->getKind() == Decl::TemplateTemplateParm) {
10310 assert(!Qualifier &&
"unexpected qualified template template parameter");
10311 assert(TemplateKeyword ==
false);
10316 llvm::FoldingSetNodeID ID;
10319 void *InsertPos =
nullptr;
10321 QualifiedTemplateNames.FindNodeOrInsertPos(ID, InsertPos);
10325 QualifiedTemplateNames.InsertNode(QTN, InsertPos);
10335 llvm::FoldingSetNodeID ID;
10338 void *InsertPos =
nullptr;
10340 DependentTemplateNames.FindNodeOrInsertPos(ID, InsertPos))
10345 DependentTemplateNames.InsertNode(QTN, InsertPos);
10350 Decl *AssociatedDecl,
10353 bool Final)
const {
10354 llvm::FoldingSetNodeID ID;
10356 Index, PackIndex, Final);
10358 void *insertPos =
nullptr;
10360 = SubstTemplateTemplateParms.FindNodeOrInsertPos(ID, insertPos);
10364 Replacement, AssociatedDecl, Index, PackIndex, Final);
10365 SubstTemplateTemplateParms.InsertNode(subst, insertPos);
10373 Decl *AssociatedDecl,
10374 unsigned Index,
bool Final)
const {
10376 llvm::FoldingSetNodeID ID;
10378 AssociatedDecl, Index, Final);
10380 void *InsertPos =
nullptr;
10382 = SubstTemplateTemplateParmPacks.FindNodeOrInsertPos(ID, InsertPos);
10387 SubstTemplateTemplateParmPacks.InsertNode(Subst, InsertPos);
10401 llvm::FoldingSetNodeID ID;
10404 void *InsertPos =
nullptr;
10406 DeducedTemplates.FindNodeOrInsertPos(ID, InsertPos);
10412 DeducedTemplates.InsertNode(DTS, InsertPos);
10435 llvm_unreachable(
"Unhandled TargetInfo::IntType value");
10465 while (
const auto *AT = dyn_cast<ArrayType>(CT))
10466 CT = AT->getElementType();
10498 assert(FirstVec->
isVectorType() &&
"FirstVec should be a vector type");
10499 assert(SecondVec->
isVectorType() &&
"SecondVec should be a vector type");
10551 auto VScale = Context.getTargetInfo().getVScaleRange(
10558 uint64_t EltSize = Context.getTypeSize(Info.
ElementType);
10562 uint64_t MinElts = Info.
EC.getKnownMinValue();
10563 return VScale->first * MinElts * EltSize;
10571 "Expected RVV builtin type and vector type!");
10611 return IsValidCast(FirstType, SecondType) ||
10612 IsValidCast(SecondType, FirstType);
10620 "Expected RVV builtin type and vector type!");
10627 if (!BT->isRVVVLSBuiltinType())
10647 return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
10654 return IsLaxCompatible(FirstType, SecondType) ||
10655 IsLaxCompatible(SecondType, FirstType);
10661 if (
const AttributedType *
Attr = dyn_cast<AttributedType>(Ty)) {
10662 if (
Attr->getAttrKind() == attr::ObjCOwnership)
10665 Ty =
Attr->getModifiedType();
10669 Ty =
Paren->getInnerType();
10701 for (
auto *lhsProto : lhs->
quals()) {
10702 bool match =
false;
10703 for (
auto *rhsProto : rhs->
quals()) {
10734 for (
auto *I : lhs->
quals()) {
10738 if (!rhsID->ClassImplementsProtocol(I,
true))
10746 for (
auto *lhsProto : lhs->
quals()) {
10747 bool match =
false;
10752 for (
auto *rhsProto : rhs->
quals()) {
10762 for (
auto *I : lhs->
quals()) {
10766 if (rhsID->ClassImplementsProtocol(I,
true)) {
10783 for (
auto *lhsProto : lhs->
quals()) {
10784 bool match =
false;
10791 for (
auto *rhsProto : rhs->
quals()) {
10810 if (LHSInheritedProtocols.empty() && lhs->
qual_empty())
10812 for (
auto *lhsProto : LHSInheritedProtocols) {
10813 bool match =
false;
10814 for (
auto *rhsProto : rhs->
quals()) {
10839 if (LHS->isObjCUnqualifiedId() || RHS->isObjCUnqualifiedId())
10844 auto finish = [&](
bool succeeded) ->
bool {
10848 if (!RHS->isKindOfType())
10859 if (LHS->isObjCQualifiedId() || RHS->isObjCQualifiedId()) {
10864 if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
10869 if (LHS->isObjCClass() && RHS->isObjCClass()) {
10874 if (LHS->getInterface() && RHS->getInterface()) {
10889 bool BlockReturnType) {
10893 auto finish = [&](
bool succeeded) ->
bool {
10918 if (
getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
10922 (!BlockReturnType &&
10926 (BlockReturnType ? LHSOPT : RHSOPT),
10927 (BlockReturnType ? RHSOPT : LHSOPT),
false));
10935 return finish(BlockReturnType);
10937 return finish(!BlockReturnType);
10949 return (*lhs)->getName().compare((*rhs)->getName());
10966 assert(LHS->getInterface() &&
"LHS must have an interface base");
10967 assert(RHS->getInterface() &&
"RHS must have an interface base");
10973 for (
auto *proto : LHS->quals()) {
10974 Context.CollectInheritedProtocols(proto, LHSProtocolSet);
10978 Context.CollectInheritedProtocols(LHS->getInterface(), LHSProtocolSet);
10984 for (
auto *proto : RHS->quals()) {
10985 Context.CollectInheritedProtocols(proto, RHSProtocolSet);
10989 Context.CollectInheritedProtocols(RHS->getInterface(), RHSProtocolSet);
10992 for (
auto *proto : LHSProtocolSet) {
10993 if (RHSProtocolSet.count(proto))
10994 IntersectionSet.push_back(proto);
11000 Context.CollectInheritedProtocols(CommonBase, ImpliedProtocols);
11003 if (!ImpliedProtocols.empty()) {
11005 return ImpliedProtocols.contains(proto);
11010 llvm::array_pod_sort(IntersectionSet.begin(), IntersectionSet.end(),
11020 if (lhsOPT && rhsOPT)
11026 if (lhsBlock && rhsBlock)
11031 if ((lhsOPT && lhsOPT->isObjCIdType() && rhsBlock) ||
11043 bool stripKindOf) {
11044 if (lhsArgs.size() != rhsArgs.size())
11051 for (
unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
11057 if (!stripKindOf ||
11058 !ctx.
hasSameType(lhsArgs[i].stripObjCKindOfType(ctx),
11059 rhsArgs[i].stripObjCKindOfType(ctx))) {
11087 if (!LDecl || !RDecl)
11093 bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
11097 llvm::SmallDenseMap<const ObjCInterfaceDecl *, const ObjCObjectType *, 4>
11102 LHSAncestors[LHS->getInterface()->getCanonicalDecl()] = LHS;
11107 bool anyChanges =
false;
11108 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11111 LHS->getTypeArgs(), RHS->getTypeArgs(),
11114 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11125 if (!Protocols.empty())
11131 if (anyChanges || LHS->isKindOfType() != anyKindOf) {
11134 anyKindOf || LHS->isKindOfType());
11142 QualType LHSSuperType = LHS->getSuperClassType();
11143 if (LHSSuperType.
isNull())
11152 auto KnownLHS = LHSAncestors.find(RHS->getInterface()->getCanonicalDecl());
11153 if (KnownLHS != LHSAncestors.end()) {
11154 LHS = KnownLHS->second;
11158 bool anyChanges =
false;
11159 if (LHS->isSpecialized() && RHS->isSpecialized()) {
11162 LHS->getTypeArgs(), RHS->getTypeArgs(),
11165 }
else if (LHS->isSpecialized() != RHS->isSpecialized()) {
11176 if (!Protocols.empty())
11181 if (anyChanges || RHS->isKindOfType() != anyKindOf) {
11184 anyKindOf || RHS->isKindOfType());
11192 QualType RHSSuperType = RHS->getSuperClassType();
11193 if (RHSSuperType.
isNull())
11204 assert(LHS->getInterface() &&
"LHS is not an interface type");
11205 assert(RHS->getInterface() &&
"RHS is not an interface type");
11210 bool IsSuperClass = LHSInterface->
isSuperClassOf(RHS->getInterface());
11217 if (LHS->getNumProtocols() > 0) {
11226 for (
auto *RHSPI : RHS->quals())
11229 if (SuperClassInheritedProtocols.empty())
11232 for (
const auto *LHSProto : LHS->quals()) {
11233 bool SuperImplementsProtocol =
false;
11234 for (
auto *SuperClassProto : SuperClassInheritedProtocols)
11235 if (SuperClassProto->lookupProtocolNamed(LHSProto->getIdentifier())) {
11236 SuperImplementsProtocol =
true;
11239 if (!SuperImplementsProtocol)
11245 if (LHS->isSpecialized()) {
11250 RHSSuper = RHSSuper->getSuperClassType()->castAs<
ObjCObjectType>();
11253 if (RHSSuper->isSpecialized() &&
11255 LHS->getTypeArgs(), RHSSuper->getTypeArgs(),
11269 if (!LHSOPT || !RHSOPT)
11287 bool CompareUnqualified) {
11306 bool OfBlockPointer,
11308 if (
const RecordType *UT =
T->getAsUnionType()) {
11310 if (UD->
hasAttr<TransparentUnionAttr>()) {
11311 for (
const auto *I : UD->
fields()) {
11312 QualType ET = I->getType().getUnqualifiedType();
11326 bool OfBlockPointer,
11347 bool IsConditionalOperator) {
11350 const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
11351 const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
11352 bool allLTypes =
true;
11353 bool allRTypes =
true;
11357 if (OfBlockPointer) {
11359 QualType LHS = lbase->getReturnType();
11361 if (!UnqualifiedResult)
11363 retType =
mergeTypes(LHS, RHS,
true, UnqualifiedResult,
true);
11428 bool NoReturn = IsConditionalOperator
11438 std::optional<FunctionEffectSet> MergedFX;
11440 if (lproto && rproto) {
11441 assert((AllowCXX ||
11442 (!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec())) &&
11443 "C++ shouldn't be here");
11445 if (lproto->getNumParams() != rproto->getNumParams())
11449 if (lproto->isVariadic() != rproto->isVariadic())
11452 if (lproto->getMethodQuals() != rproto->getMethodQuals())
11456 if (lproto->getExtraAttributeInfo().CFISalt !=
11457 rproto->getExtraAttributeInfo().CFISalt)
11463 if (LHSFX != RHSFX) {
11464 if (IsConditionalOperator)
11473 if (*MergedFX != LHSFX)
11475 if (*MergedFX != RHSFX)
11480 bool canUseLeft, canUseRight;
11492 for (
unsigned i = 0, n = lproto->getNumParams(); i < n; i++) {
11493 QualType lParamType = lproto->getParamType(i).getUnqualifiedType();
11494 QualType rParamType = rproto->getParamType(i).getUnqualifiedType();
11496 lParamType, rParamType, OfBlockPointer,
Unqualified);
11503 types.push_back(paramType);
11515 if (allLTypes)
return lhs;
11516 if (allRTypes)
return rhs;
11521 newParamInfos.empty() ?
nullptr : newParamInfos.data();
11527 if (lproto) allRTypes =
false;
11528 if (rproto) allLTypes =
false;
11532 assert((AllowCXX || !proto->
hasExceptionSpec()) &&
"C++ shouldn't be here");
11540 for (
unsigned i = 0, n = proto->
getNumParams(); i < n; ++i) {
11546 paramTy = ED->getIntegerType();
11556 if (allLTypes)
return lhs;
11557 if (allRTypes)
return rhs;
11566 if (allLTypes)
return lhs;
11567 if (allRTypes)
return rhs;
11573 QualType other,
bool isBlockReturnType) {
11579 ET->getDecl()->getDefinitionOrSelf()->getIntegerType();
11580 if (underlyingType.
isNull())
11582 if (Context.hasSameType(underlyingType, other))
11588 Context.getTypeSize(underlyingType) == Context.getTypeSize(other))
11597 if (LangOpts.CPlusPlus || !LangOpts.C23)
11618 bool IsConditionalOperator) {
11629 if (LangOpts.OpenMP && LHSRefTy && RHSRefTy &&
11633 if (LHSRefTy || RHSRefTy)
11645 if (LHSCan == RHSCan)
11650 Qualifiers RQuals = RHSCan.getLocalQualifiers();
11651 if (LQuals != RQuals) {
11668 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
11689 if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
11690 if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
11693 if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
11694 LHSClass = Type::ConstantArray;
11695 if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
11696 RHSClass = Type::ConstantArray;
11699 if (LHSClass == Type::ObjCInterface) LHSClass = Type::ObjCObject;
11700 if (RHSClass == Type::ObjCInterface) RHSClass = Type::ObjCObject;
11703 if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
11704 if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
11707 if (LHSClass != RHSClass) {
11717 if (OfBlockPointer && !BlockReturnType) {
11725 if (
const auto *AT = LHS->
getAs<AutoType>()) {
11726 if (!AT->isDeduced() && AT->isGNUAutoType())
11729 if (
const auto *AT = RHS->
getAs<AutoType>()) {
11730 if (!AT->isDeduced() && AT->isGNUAutoType())
11737 switch (LHSClass) {
11738#define TYPE(Class, Base)
11739#define ABSTRACT_TYPE(Class, Base)
11740#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
11741#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
11742#define DEPENDENT_TYPE(Class, Base) case Type::Class:
11743#include "clang/AST/TypeNodes.inc"
11744 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
11747 case Type::DeducedTemplateSpecialization:
11748 case Type::LValueReference:
11749 case Type::RValueReference:
11750 case Type::MemberPointer:
11751 llvm_unreachable(
"C++ should never be in mergeTypes");
11753 case Type::ObjCInterface:
11754 case Type::IncompleteArray:
11755 case Type::VariableArray:
11756 case Type::FunctionProto:
11757 case Type::ExtVector:
11758 llvm_unreachable(
"Types are eliminated above");
11760 case Type::Pointer:
11771 if (ResultType.
isNull())
11779 case Type::BlockPointer:
11804 if (ResultType.
isNull())
11823 if (ResultType.
isNull())
11831 case Type::ConstantArray:
11846 if (ResultType.
isNull())
11854 if (LVAT || RVAT) {
11857 -> std::pair<bool,llvm::APInt> {
11859 std::optional<llvm::APSInt> TheInt;
11862 return std::make_pair(
true, *TheInt);
11863 return std::make_pair(
false, llvm::APSInt());
11866 return std::make_pair(
true, CAT->getSize());
11867 return std::make_pair(
false, llvm::APInt());
11870 bool HaveLSize, HaveRSize;
11871 llvm::APInt LSize, RSize;
11872 std::tie(HaveLSize, LSize) = SizeFetch(LVAT, LCAT);
11873 std::tie(HaveRSize, RSize) = SizeFetch(RVAT, RCAT);
11874 if (HaveLSize && HaveRSize && !llvm::APInt::isSameValue(LSize, RSize))
11908 case Type::FunctionNoProto:
11910 false, IsConditionalOperator);
11914 case Type::Builtin:
11917 case Type::Complex:
11926 case Type::ConstantMatrix:
11931 case Type::ObjCObject: {
11940 case Type::ObjCObjectPointer:
11941 if (OfBlockPointer) {
11953 assert(LHS != RHS &&
11954 "Equivalent pipe types should have already been handled!");
11956 case Type::ArrayParameter:
11957 assert(LHS != RHS &&
11958 "Equivalent ArrayParameter types should have already been handled!");
11960 case Type::BitInt: {
11968 if (LHSUnsigned != RHSUnsigned)
11971 if (LHSBits != RHSBits)
11975 case Type::HLSLAttributedResource: {
11976 const HLSLAttributedResourceType *LHSTy =
11977 LHS->
castAs<HLSLAttributedResourceType>();
11978 const HLSLAttributedResourceType *RHSTy =
11979 RHS->
castAs<HLSLAttributedResourceType>();
11980 assert(LHSTy->getWrappedType() == RHSTy->getWrappedType() &&
11981 LHSTy->getWrappedType()->isHLSLResourceType() &&
11982 "HLSLAttributedResourceType should always wrap __hlsl_resource_t");
11984 if (LHSTy->getAttrs() == RHSTy->getAttrs() &&
11985 LHSTy->getContainedType() == RHSTy->getContainedType())
11989 case Type::HLSLInlineSpirv:
11990 const HLSLInlineSpirvType *LHSTy = LHS->
castAs<HLSLInlineSpirvType>();
11991 const HLSLInlineSpirvType *RHSTy = RHS->
castAs<HLSLInlineSpirvType>();
11993 if (LHSTy->getOpcode() == RHSTy->getOpcode() &&
11994 LHSTy->getSize() == RHSTy->getSize() &&
11995 LHSTy->getAlignment() == RHSTy->getAlignment()) {
11996 for (
size_t I = 0; I < LHSTy->getOperands().size(); I++)
11997 if (LHSTy->getOperands()[I] != RHSTy->getOperands()[I])
12005 llvm_unreachable(
"Invalid Type::Class!");
12010 bool &CanUseFirst,
bool &CanUseSecond,
12012 assert(NewParamInfos.empty() &&
"param info list not empty");
12013 CanUseFirst = CanUseSecond =
true;
12019 if (!FirstHasInfo && !SecondHasInfo)
12022 bool NeedParamInfo =
false;
12026 for (
size_t I = 0; I < E; ++I) {
12037 bool FirstNoEscape = FirstParam.
isNoEscape();
12038 bool SecondNoEscape = SecondParam.
isNoEscape();
12039 bool IsNoEscape = FirstNoEscape && SecondNoEscape;
12041 if (NewParamInfos.back().getOpaqueValue())
12042 NeedParamInfo =
true;
12043 if (FirstNoEscape != IsNoEscape)
12044 CanUseFirst =
false;
12045 if (SecondNoEscape != IsNoEscape)
12046 CanUseSecond =
false;
12049 if (!NeedParamInfo)
12050 NewParamInfos.clear();
12056 if (
auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
12057 It->second =
nullptr;
12058 for (
auto *SubClass : ObjCSubClasses.lookup(D))
12070 if (LHSCan == RHSCan)
12072 if (RHSCan->isFunctionType()) {
12081 if (ResReturnType.
isNull())
12083 if (ResReturnType == NewReturnType || ResReturnType == OldReturnType) {
12100 Qualifiers RQuals = RHSCan.getLocalQualifiers();
12101 if (LQuals != RQuals) {
12114 assert((GC_L != GC_R) &&
"unequal qualifier sets had only equal elements");
12130 if (ResQT == LHSBaseQT)
12132 if (ResQT == RHSBaseQT)
12143 if (
const auto *ED =
T->getAsEnumDecl())
12144 T = ED->getIntegerType();
12145 if (
T->isBooleanType())
12148 return EIT->getNumBits();
12154 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12155 T->isFixedPointType()) &&
12156 "Unexpected type");
12161 VTy->getNumElements(), VTy->getVectorKind());
12169 if (
const auto *ED =
T->getAsEnumDecl())
12170 T = ED->getIntegerType();
12173 case BuiltinType::Char_U:
12175 case BuiltinType::Char_S:
12176 case BuiltinType::SChar:
12177 case BuiltinType::Char8:
12179 case BuiltinType::Short:
12181 case BuiltinType::Int:
12183 case BuiltinType::Long:
12185 case BuiltinType::LongLong:
12187 case BuiltinType::Int128:
12192 case BuiltinType::WChar_S:
12195 case BuiltinType::ShortAccum:
12197 case BuiltinType::Accum:
12199 case BuiltinType::LongAccum:
12201 case BuiltinType::SatShortAccum:
12203 case BuiltinType::SatAccum:
12205 case BuiltinType::SatLongAccum:
12207 case BuiltinType::ShortFract:
12209 case BuiltinType::Fract:
12211 case BuiltinType::LongFract:
12213 case BuiltinType::SatShortFract:
12215 case BuiltinType::SatFract:
12217 case BuiltinType::SatLongFract:
12220 assert((
T->hasUnsignedIntegerRepresentation() ||
12221 T->isUnsignedFixedPointType()) &&
12222 "Unexpected signed integer or fixed point type");
12228 assert((
T->hasIntegerRepresentation() ||
T->isEnumeralType() ||
12229 T->isFixedPointType()) &&
12230 "Unexpected type");
12235 VTy->getNumElements(), VTy->getVectorKind());
12243 if (
const auto *ED =
T->getAsEnumDecl())
12244 T = ED->getIntegerType();
12247 case BuiltinType::Char_S:
12249 case BuiltinType::Char_U:
12250 case BuiltinType::UChar:
12251 case BuiltinType::Char8:
12253 case BuiltinType::UShort:
12255 case BuiltinType::UInt:
12257 case BuiltinType::ULong:
12259 case BuiltinType::ULongLong:
12261 case BuiltinType::UInt128:
12266 case BuiltinType::WChar_U:
12269 case BuiltinType::UShortAccum:
12271 case BuiltinType::UAccum:
12273 case BuiltinType::ULongAccum:
12275 case BuiltinType::SatUShortAccum:
12277 case BuiltinType::SatUAccum:
12279 case BuiltinType::SatULongAccum:
12281 case BuiltinType::UShortFract:
12283 case BuiltinType::UFract:
12285 case BuiltinType::ULongFract:
12287 case BuiltinType::SatUShortFract:
12289 case BuiltinType::SatUFract:
12291 case BuiltinType::SatULongFract:
12295 (
T->hasSignedIntegerRepresentation() ||
T->isSignedFixedPointType()) &&
12296 "Unexpected signed integer or fixed point type");
12321 bool AllowTypeModifiers) {
12325 RequiresICE =
false;
12330 bool IsSpecial =
false;
12334 default: Done =
true; --Str;
break;
12336 RequiresICE =
true;
12339 assert(!
Unsigned &&
"Can't use both 'S' and 'U' modifiers!");
12340 assert(!
Signed &&
"Can't use 'S' modifier multiple times!");
12344 assert(!
Signed &&
"Can't use both 'S' and 'U' modifiers!");
12345 assert(!
Unsigned &&
"Can't use 'U' modifier multiple times!");
12349 assert(!IsSpecial &&
"Can't use 'L' with 'W', 'N', 'Z' or 'O' modifiers");
12350 assert(HowLong <= 2 &&
"Can't have LLLL modifier");
12355 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12356 assert(HowLong == 0 &&
"Can't use both 'L' and 'N' modifiers!");
12360 if (Context.getTargetInfo().getLongWidth() == 32)
12365 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12366 assert(HowLong == 0 &&
"Can't use both 'L' and 'W' modifiers!");
12370 switch (Context.getTargetInfo().getInt64Type()) {
12372 llvm_unreachable(
"Unexpected integer type");
12383 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12384 assert(HowLong == 0 &&
"Can't use both 'L' and 'Z' modifiers!");
12388 switch (Context.getTargetInfo().getIntTypeByWidth(32,
true)) {
12390 llvm_unreachable(
"Unexpected integer type");
12403 assert(!IsSpecial &&
"Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
12404 assert(HowLong == 0 &&
"Can't use both 'L' and 'O' modifiers!");
12408 if (Context.getLangOpts().OpenCL)
12421 llvm_unreachable(
"Unknown builtin type letter!");
12424 "Bad modifiers used with 'x'!");
12425 Type = Context.Float16Ty;
12429 "Bad modifiers used with 'y'!");
12430 Type = Context.BFloat16Ty;
12434 "Bad modifiers used with 'v'!");
12435 Type = Context.VoidTy;
12439 "Bad modifiers used with 'h'!");
12440 Type = Context.HalfTy;
12444 "Bad modifiers used with 'f'!");
12445 Type = Context.FloatTy;
12449 "Bad modifiers used with 'd'!");
12451 Type = Context.LongDoubleTy;
12452 else if (HowLong == 2)
12453 Type = Context.Float128Ty;
12455 Type = Context.DoubleTy;
12458 assert(HowLong == 0 &&
"Bad modifiers used with 's'!");
12460 Type = Context.UnsignedShortTy;
12462 Type = Context.ShortTy;
12466 Type =
Unsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
12467 else if (HowLong == 2)
12468 Type =
Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
12469 else if (HowLong == 1)
12470 Type =
Unsigned ? Context.UnsignedLongTy : Context.LongTy;
12472 Type =
Unsigned ? Context.UnsignedIntTy : Context.IntTy;
12475 assert(HowLong == 0 &&
"Bad modifiers used with 'c'!");
12477 Type = Context.SignedCharTy;
12479 Type = Context.UnsignedCharTy;
12481 Type = Context.CharTy;
12484 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'b'!");
12485 Type = Context.BoolTy;
12488 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'z'!");
12489 Type = Context.getSizeType();
12492 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'w'!");
12493 Type = Context.getWideCharType();
12496 Type = Context.getCFConstantStringType();
12499 Type = Context.getObjCIdType();
12502 Type = Context.getObjCSelType();
12505 Type = Context.getObjCSuperType();
12508 Type = Context.getBuiltinVaListType();
12509 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12520 Type = Context.getBuiltinVaListType();
12521 assert(!
Type.isNull() &&
"builtin va list type not initialized!");
12523 Type = Context.getArrayDecayedType(
Type);
12525 Type = Context.getLValueReferenceType(
Type);
12529 unsigned NumElements = strtoul(Str, &End, 10);
12530 assert(End != Str &&
"Missing vector size");
12534 RequiresICE,
false);
12535 assert(!RequiresICE &&
"Can't require vector ICE");
12537 Type = Context.getScalableVectorType(ElementType, NumElements);
12543 Type = Context.SveCountTy;
12547 Type = Context.AMDGPUBufferRsrcTy;
12551 Type = Context.AMDGPUTextureTy;
12555 Type = Context.HLSLResourceTy;
12559 llvm_unreachable(
"Unexpected target builtin type");
12565 unsigned NumElements = strtoul(Str, &End, 10);
12566 assert(End != Str &&
"Missing vector size");
12570 RequiresICE,
false);
12571 assert(!RequiresICE &&
"Can't require vector ICE");
12580 unsigned NumElements = strtoul(Str, &End, 10);
12581 assert(End != Str &&
"Missing vector size");
12587 Type = Context.getExtVectorType(ElementType, NumElements);
12593 assert(!RequiresICE &&
"Can't require complex ICE");
12594 Type = Context.getComplexType(ElementType);
12598 Type = Context.getPointerDiffType();
12601 Type = Context.getFILEType();
12602 if (
Type.isNull()) {
12609 Type = Context.getsigjmp_bufType();
12611 Type = Context.getjmp_bufType();
12613 if (
Type.isNull()) {
12619 assert(HowLong == 0 && !
Signed && !
Unsigned &&
"Bad modifiers for 'K'!");
12620 Type = Context.getucontext_tType();
12622 if (
Type.isNull()) {
12628 Type = Context.getProcessIDType();
12631 Type = Context.MFloat8Ty;
12636 Done = !AllowTypeModifiers;
12638 switch (
char c = *Str++) {
12639 default: Done =
true; --Str;
break;
12645 unsigned AddrSpace = strtoul(Str, &End, 10);
12648 Type = Context.getAddrSpaceQualType(
12650 Context.getLangASForBuiltinAddressSpace(AddrSpace));
12654 Type = Context.getPointerType(
Type);
12656 Type = Context.getLValueReferenceType(
Type);
12664 Type = Context.getVolatileType(
Type);
12673 "Integer constant 'I' type must be an integer");
12686 bool AllowTypeModifiers)
const {
12693 unsigned *IntegerConstantArgs)
const {
12694 const char *TypeStr =
BuiltinInfo.getTypeString(Id);
12695 if (TypeStr[0] ==
'\0') {
12702 bool RequiresICE =
false;
12705 RequiresICE,
true);
12709 assert(!RequiresICE &&
"Result of intrinsic cannot be required to be an ICE");
12711 while (TypeStr[0] && TypeStr[0] !=
'.') {
12718 if (RequiresICE && IntegerConstantArgs)
12719 *IntegerConstantArgs |= 1 << ArgTypes.size();
12725 ArgTypes.push_back(Ty);
12728 if (Id == Builtin::BI__GetExceptionInfo)
12731 assert((TypeStr[0] !=
'.' || TypeStr[1] == 0) &&
12732 "'.' should only occur at end of builtin type list!");
12734 bool Variadic = (TypeStr[0] ==
'.');
12741 if (ArgTypes.empty() && Variadic && !
getLangOpts().requiresStrictPrototypes())
12791 if ((!Context.getLangOpts().CPlusPlus &&
12792 !Context.getTargetInfo().getCXXABI().isMicrosoft() &&
12793 !FD->
hasAttr<DLLExportAttr>()) ||
12794 FD->
hasAttr<GNUInlineAttr>()) {
12812 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
12827 if (D->
hasAttr<DLLImportAttr>()) {
12830 }
else if (D->
hasAttr<DLLExportAttr>()) {
12833 }
else if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice) {
12836 if (D->
hasAttr<CUDAGlobalAttr>() &&
12845 if (Context.shouldExternalize(D))
12860 switch (Source->hasExternalDefinitions(D)) {
12887 if (Context.getLangOpts().CPlusPlus &&
12888 Context.getLangOpts().IncrementalExtensions &&
12904 if (!LexicalContext)
12909 auto StaticLocalLinkage =
12921 return StaticLocalLinkage;
12927 if (Context.isMSStaticDataMemberInlineDefinition(VD))
12933 switch (Context.getInlineVariableDefinitionKind(VD)) {
12948 return StrongLinkage;
12951 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
12966 llvm_unreachable(
"Invalid Linkage!");
12976 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
12977 if (!VD->isFileVarDecl())
12982 if (VD->getDescribedVarTemplate() ||
12985 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13011 if (D->
hasAttr<WeakRefAttr>())
13018 if (LangOpts.SYCLIsDevice)
13020 D->
hasAttr<SYCLExternalAttr>());
13026 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13028 if (!FD->doesThisDeclarationHaveABody())
13029 return FD->doesDeclarationForceExternallyVisibleDefinition();
13032 if (FD->
hasAttr<ConstructorAttr>() || FD->
hasAttr<DestructorAttr>())
13037 if (
getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
13038 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
13057 assert(VD->isFileVarDecl() &&
"Expected file scoped var");
13061 if (LangOpts.OpenMP &&
13062 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
13069 if (VD->shouldEmitInExternalSource())
13082 if (VD->needsDestruction(*
this))
13086 if (VD->hasInitWithSideEffects())
13091 if (
const auto *DD = dyn_cast<DecompositionDecl>(VD)) {
13092 for (
const auto *BD : DD->flat_bindings())
13093 if (
const auto *BindingVD = BD->getHoldingVar())
13103 llvm::function_ref<
void(
FunctionDecl *)> Pred)
const {
13104 assert(FD->
isMultiVersion() &&
"Only valid for multiversioned functions");
13105 llvm::SmallDenseSet<const FunctionDecl*, 4> SeenDecls;
13110 for (
auto *CurDecl :
13114 SeenDecls.insert(CurFD).second) {
13121 bool IsCXXMethod)
const {
13124 return ABI->getDefaultMethodCallConv(IsVariadic);
13126 switch (LangOpts.getDefaultCallingConv()) {
13154 return Target->getDefaultCallingConv();
13159 return ABI->isNearlyEmpty(RD);
13164 auto ABI = Target->getCXXABI();
13165 if (ABI.isMicrosoft())
13168 auto ComponentLayout =
getLangOpts().RelativeCXXABIVTables
13174 return VTContext.get();
13180 switch (
T->getCXXABI().getKind()) {
13181 case TargetCXXABI::AppleARM64:
13182 case TargetCXXABI::Fuchsia:
13183 case TargetCXXABI::GenericAArch64:
13184 case TargetCXXABI::GenericItanium:
13185 case TargetCXXABI::GenericARM:
13186 case TargetCXXABI::GenericMIPS:
13187 case TargetCXXABI::iOS:
13188 case TargetCXXABI::WebAssembly:
13189 case TargetCXXABI::WatchOS:
13190 case TargetCXXABI::XL:
13192 case TargetCXXABI::Microsoft:
13195 llvm_unreachable(
"Unsupported ABI");
13199 assert(
T.getCXXABI().getKind() != TargetCXXABI::Microsoft &&
13200 "Device mangle context does not support Microsoft mangling.");
13201 switch (
T.getCXXABI().getKind()) {
13202 case TargetCXXABI::AppleARM64:
13203 case TargetCXXABI::Fuchsia:
13204 case TargetCXXABI::GenericAArch64:
13205 case TargetCXXABI::GenericItanium:
13206 case TargetCXXABI::GenericARM:
13207 case TargetCXXABI::GenericMIPS:
13208 case TargetCXXABI::iOS:
13209 case TargetCXXABI::WebAssembly:
13210 case TargetCXXABI::WatchOS:
13211 case TargetCXXABI::XL:
13215 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
13216 return RD->getDeviceLambdaManglingNumber();
13217 return std::nullopt;
13220 case TargetCXXABI::Microsoft:
13224 llvm_unreachable(
"Unsupported ABI");
13230 return ASTRecordLayouts.getMemorySize() +
13231 llvm::capacity_in_bytes(ObjCLayouts) +
13232 llvm::capacity_in_bytes(KeyFunctions) +
13233 llvm::capacity_in_bytes(ObjCImpls) +
13234 llvm::capacity_in_bytes(BlockVarCopyInits) +
13235 llvm::capacity_in_bytes(DeclAttrs) +
13236 llvm::capacity_in_bytes(TemplateOrInstantiation) +
13237 llvm::capacity_in_bytes(InstantiatedFromUsingDecl) +
13238 llvm::capacity_in_bytes(InstantiatedFromUsingShadowDecl) +
13239 llvm::capacity_in_bytes(InstantiatedFromUnnamedFieldDecl) +
13240 llvm::capacity_in_bytes(OverriddenMethods) +
13241 llvm::capacity_in_bytes(Types) +
13242 llvm::capacity_in_bytes(VariableArrayTypes);
13250 unsigned Signed)
const {
13253 if (!QualTy && DestWidth == 128)
13282 llvm_unreachable(
"Unhandled TargetInfo::RealType value");
13289 MangleNumbers[ND] = Number;
13292 Listener->AddedManglingNumber(ND, Number);
13296 bool ForAuxTarget)
const {
13297 auto I = MangleNumbers.find(ND);
13298 unsigned Res = I != MangleNumbers.end() ? I->second : 1;
13301 if (LangOpts.CUDA && !LangOpts.CUDAIsDevice) {
13302 Res = ForAuxTarget ? Res >> 16 : Res & 0xFFFF;
13304 assert(!ForAuxTarget &&
"Only CUDA/HIP host compilation supports mangling "
13305 "number for aux target");
13307 return Res > 1 ? Res : 1;
13314 StaticLocalNumbers[VD] = Number;
13317 Listener->AddedStaticLocalNumbers(VD, Number);
13321 auto I = StaticLocalNumbers.find(VD);
13322 return I != StaticLocalNumbers.end() ? I->second : 1;
13326 bool IsDestroying) {
13327 if (!IsDestroying) {
13339 bool IsTypeAware) {
13340 if (!IsTypeAware) {
13379 return GlobalOperatorDeletesForVirtualDtor.contains(
13382 return ArrayOperatorDeletesForVirtualDtor.contains(
13385 return GlobalArrayOperatorDeletesForVirtualDtor.contains(
13397 if (OperatorDeletesForVirtualDtor.contains(Canon))
13398 return OperatorDeletesForVirtualDtor[Canon];
13401 if (GlobalOperatorDeletesForVirtualDtor.contains(Canon))
13402 return GlobalOperatorDeletesForVirtualDtor[Canon];
13405 if (ArrayOperatorDeletesForVirtualDtor.contains(Canon))
13406 return ArrayOperatorDeletesForVirtualDtor[Canon];
13409 if (GlobalArrayOperatorDeletesForVirtualDtor.contains(Canon))
13410 return GlobalArrayOperatorDeletesForVirtualDtor[Canon];
13426 return RequireVectorDeletingDtor.count(RD);
13433 RequireVectorDeletingDtor.insert(RD);
13438 assert(LangOpts.CPlusPlus);
13439 std::unique_ptr<MangleNumberingContext> &MCtx = MangleNumberingContexts[DC];
13447 assert(LangOpts.CPlusPlus);
13448 std::unique_ptr<MangleNumberingContext> &MCtx =
13449 ExtraMangleNumberingContexts[D];
13455std::unique_ptr<MangleNumberingContext>
13457 return ABI->createMangleNumberingContext();
13462 return ABI->getCopyConstructorForExceptionObject(
13468 return ABI->addCopyConstructorForExceptionObject(
13475 return ABI->addTypedefNameForUnnamedTagDecl(TD, DD);
13480 return ABI->getTypedefNameForUnnamedTagDecl(TD);
13485 return ABI->addDeclaratorForUnnamedTagDecl(TD, DD);
13489 return ABI->getDeclaratorForUnnamedTagDecl(TD);
13493 ParamIndices[D] =
index;
13497 ParameterIndexTable::const_iterator I = ParamIndices.find(D);
13498 assert(I != ParamIndices.end() &&
13499 "ParmIndices lacks entry set by ParmVarDecl");
13504 unsigned Length)
const {
13530 assert(
MSGuidTagDecl &&
"building MS GUID without MS extensions?");
13532 llvm::FoldingSetNodeID ID;
13536 if (
MSGuidDecl *Existing = MSGuidDecls.FindNodeOrInsertPos(ID, InsertPos))
13540 MSGuidDecl *
New = MSGuidDecl::Create(*
this, GUIDType, Parts);
13541 MSGuidDecls.InsertNode(
New, InsertPos);
13547 const APValue &APVal)
const {
13548 llvm::FoldingSetNodeID ID;
13553 UnnamedGlobalConstantDecls.FindNodeOrInsertPos(ID, InsertPos))
13557 UnnamedGlobalConstantDecl::Create(*
this, Ty, APVal);
13558 UnnamedGlobalConstantDecls.InsertNode(
New, InsertPos);
13564 assert(
T->isRecordType() &&
"template param object of unexpected type");
13570 llvm::FoldingSetNodeID ID;
13575 TemplateParamObjectDecls.FindNodeOrInsertPos(ID, InsertPos))
13579 TemplateParamObjectDecls.InsertNode(
New, InsertPos);
13585 if (!
T.isOSDarwin())
13588 if (!(
T.isiOS() &&
T.isOSVersionLT(7)) &&
13589 !(
T.isMacOSX() &&
T.isOSVersionLT(10, 9)))
13598 return (Size != Align ||
toBits(sizeChars) > MaxInlineWidthInBits);
13605 if (MethodDecl->
hasAttr<UnavailableAttr>()
13606 || MethodDecl->
hasAttr<DeprecatedAttr>())
13620 IM != EM && IF != EF; ++IM, ++IF) {
13651 llvm::FoldingSetNodeID IDX, IDY;
13652 X->Profile(IDX, *
this,
true);
13653 Y->
Profile(IDY, *
this,
true);
13667 for (
const Decl *DX :
X->redecls()) {
13672 if (DX->isFirstDecl())
13675 llvm_unreachable(
"Corrupt redecls chain");
13678template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
13680 return cast_or_null<T>(
13682 const_cast<Decl *
>(cast_or_null<Decl>(Y))));
13685template <
class T, std::enable_if_t<std::is_base_of_v<Decl, T>,
bool> = true>
13693 bool IgnoreDeduced =
false) {
13708 bool IgnoreDeduced) {
13716 assert(Xs.size() == Ys.size());
13718 for (
size_t I = 0; I < Rs.size(); ++I)
13725 return X->getAttributeLoc() == Y->getAttributeLoc() ?
X->getAttributeLoc()
13735 switch (
X.getKind()) {
13765 auto NExpX =
X.getNumTemplateExpansions();
13779 if (Xs.size() != Ys.size())
13781 R.resize(Xs.size());
13782 for (
size_t I = 0; I < R.size(); ++I) {
13795 assert(!Different);
13823 assert(!IsSame &&
"Should be the same NestedNameSpecifier");
13825 return std::nullopt;
13830 assert(Kind == NNS2.
getKind());
13835 auto Kind = Namespace1->getKind();
13836 if (Kind != Namespace2->getKind() ||
13837 (Kind == Decl::NamespaceAlias &&
13842 Namespace2->getNamespace()),
13876 llvm_unreachable(
"singletons did not compare equal");
13884 const T *Y,
bool IsSame) {
13885 return ::getCommonNNS(Ctx,
X->getQualifier(), Y->getQualifier(), IsSame);
13898 QualType EX =
X->getElementType(), EY = Y->getElementType();
13907 QY += EY.getQualifiers() - RQ;
13919 assert(Ctx.
hasSameExpr(
X->getSizeExpr(), Y->getSizeExpr()));
13920 return X->getSizeExpr();
13925 return X->getSizeModifier();
13931 return X->getIndexTypeCVRQualifiers();
13941 llvm::DenseMap<QualType, unsigned>
Found;
13942 for (
auto Ts : {
X, Y}) {
13949 Out.emplace_back(
T);
13955FunctionProtoType::ExceptionSpecInfo
13959 bool AcceptDependent)
const {
13985 assert(AcceptDependent &&
13986 "computing composite pointer type of dependent types");
14001 llvm_unreachable(
"These ESTs should be handled above");
14006 assert(EST2 ==
EST_Dynamic &&
"other cases should already be handled");
14010 Result.Exceptions = ExceptionTypeStorage;
14017 llvm_unreachable(
"shouldn't see unresolved exception specifications here");
14020 llvm_unreachable(
"invalid ExceptionSpecificationType");
14029#define UNEXPECTED_TYPE(Class, Kind) \
14030 case Type::Class: \
14031 llvm_unreachable("Unexpected " Kind ": " #Class);
14033#define NON_CANONICAL_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "non-canonical")
14034#define TYPE(Class, Base)
14035#include "clang/AST/TypeNodes.inc"
14037#define SUGAR_FREE_TYPE(Class) UNEXPECTED_TYPE(Class, "sugar-free")
14048#undef SUGAR_FREE_TYPE
14049#define NON_UNIQUE_TYPE(Class) UNEXPECTED_TYPE(Class, "non-unique")
14052#undef NON_UNIQUE_TYPE
14056#undef UNEXPECTED_TYPE
14060 assert(AX->getDeducedType().isNull());
14061 assert(AY->getDeducedType().isNull());
14062 assert(AX->getKeyword() == AY->getKeyword());
14063 assert(AX->isInstantiationDependentType() ==
14064 AY->isInstantiationDependentType());
14066 AY->getTypeConstraintArguments());
14069 AX->containsUnexpandedParameterPack(),
14071 AY->getTypeConstraintConcept()),
14074 case Type::IncompleteArray: {
14081 case Type::DependentSizedArray: {
14089 case Type::ConstantArray: {
14092 assert(AX->getSize() == AY->getSize());
14093 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14094 ? AX->getSizeExpr()
14100 case Type::ArrayParameter: {
14103 assert(AX->getSize() == AY->getSize());
14104 const Expr *SizeExpr = Ctx.
hasSameExpr(AX->getSizeExpr(), AY->getSizeExpr())
14105 ? AX->getSizeExpr()
14112 case Type::Atomic: {
14117 case Type::Complex: {
14121 case Type::Pointer: {
14125 case Type::BlockPointer: {
14129 case Type::ObjCObjectPointer: {
14134 case Type::MemberPointer: {
14138 PY->getMostRecentCXXRecordDecl()));
14142 PX->getMostRecentCXXRecordDecl());
14144 case Type::LValueReference: {
14149 PX->isSpelledAsLValue() ||
14150 PY->isSpelledAsLValue());
14152 case Type::RValueReference: {
14158 case Type::DependentAddressSpace: {
14161 assert(Ctx.
hasSameExpr(PX->getAddrSpaceExpr(), PY->getAddrSpaceExpr()));
14163 PX->getAddrSpaceExpr(),
14166 case Type::FunctionNoProto: {
14169 assert(FX->getExtInfo() == FY->getExtInfo());
14174 case Type::FunctionProto: {
14178 EPIY = FY->getExtProtoInfo();
14179 assert(EPIX.
ExtInfo == EPIY.ExtInfo);
14186 assert(EPIX.
TypeQuals == EPIY.TypeQuals);
14187 assert(EPIX.
Variadic == EPIY.Variadic);
14196 auto P =
getCommonTypes(Ctx, FX->param_types(), FY->param_types(),
14204 case Type::ObjCObject: {
14207 std::equal(OX->getProtocols().begin(), OX->getProtocols().end(),
14208 OY->getProtocols().begin(), OY->getProtocols().end(),
14210 return P0->getCanonicalDecl() == P1->getCanonicalDecl();
14212 "protocol lists must be the same");
14214 OY->getTypeArgsAsWritten());
14217 OX->getProtocols(),
14218 OX->isKindOfTypeAsWritten() && OY->isKindOfTypeAsWritten());
14220 case Type::ConstantMatrix: {
14223 assert(MX->getNumRows() == MY->getNumRows());
14224 assert(MX->getNumColumns() == MY->getNumColumns());
14226 MX->getNumRows(), MX->getNumColumns());
14228 case Type::DependentSizedMatrix: {
14231 assert(Ctx.
hasSameExpr(MX->getRowExpr(), MY->getRowExpr()));
14232 assert(Ctx.
hasSameExpr(MX->getColumnExpr(), MY->getColumnExpr()));
14237 case Type::Vector: {
14239 assert(VX->getNumElements() == VY->getNumElements());
14240 assert(VX->getVectorKind() == VY->getVectorKind());
14242 VX->getNumElements(), VX->getVectorKind());
14244 case Type::ExtVector: {
14246 assert(VX->getNumElements() == VY->getNumElements());
14248 VX->getNumElements());
14250 case Type::DependentSizedExtVector: {
14257 case Type::DependentVector: {
14260 assert(VX->getVectorKind() == VY->getVectorKind());
14267 case Type::InjectedClassName: {
14274 case Type::TemplateSpecialization: {
14278 TY->template_arguments());
14282 TY->getTemplateName(),
14284 As, {},
X->getCanonicalTypeInternal());
14286 case Type::Decltype: {
14289 assert(DX->isDependentType());
14290 assert(DY->isDependentType());
14291 assert(Ctx.
hasSameExpr(DX->getUnderlyingExpr(), DY->getUnderlyingExpr()));
14295 case Type::PackIndexing: {
14298 assert(DX->isDependentType());
14299 assert(DY->isDependentType());
14300 assert(Ctx.
hasSameExpr(DX->getIndexExpr(), DY->getIndexExpr()));
14303 case Type::DependentName: {
14306 assert(NX->getIdentifier() == NY->getIdentifier());
14311 case Type::UnaryTransform: {
14314 assert(TX->getUTTKind() == TY->getUTTKind());
14318 TY->getUnderlyingType()),
14321 case Type::PackExpansion: {
14324 assert(PX->getNumExpansions() == PY->getNumExpansions());
14327 PX->getNumExpansions(),
false);
14331 assert(PX->isReadOnly() == PY->isReadOnly());
14336 case Type::TemplateTypeParm: {
14339 assert(TX->getDepth() == TY->getDepth());
14340 assert(TX->getIndex() == TY->getIndex());
14341 assert(TX->isParameterPack() == TY->isParameterPack());
14343 TX->getDepth(), TX->getIndex(), TX->isParameterPack(),
14347 llvm_unreachable(
"Unknown Type Class");
14357#define UNEXPECTED_TYPE(Class, Kind) \
14358 case Type::Class: \
14359 llvm_unreachable("Unexpected " Kind ": " #Class);
14360#define TYPE(Class, Base)
14361#define DEPENDENT_TYPE(Class, Base) UNEXPECTED_TYPE(Class, "dependent")
14362#include "clang/AST/TypeNodes.inc"
14364#define CANONICAL_TYPE(Class) UNEXPECTED_TYPE(Class, "canonical")
14390#undef CANONICAL_TYPE
14392#undef UNEXPECTED_TYPE
14394 case Type::Adjusted: {
14396 QualType OX = AX->getOriginalType(), OY = AY->getOriginalType();
14403 case Type::Decayed: {
14405 QualType OX = DX->getOriginalType(), OY = DY->getOriginalType();
14412 case Type::Attributed: {
14414 AttributedType::Kind Kind = AX->getAttrKind();
14415 if (Kind != AY->getAttrKind())
14417 QualType MX = AX->getModifiedType(), MY = AY->getModifiedType();
14425 case Type::BTFTagAttributed: {
14427 const BTFTypeTagAttr *AX = BX->getAttr();
14429 if (AX->getBTFTypeTag() !=
14438 if (KW != AY->getKeyword())
14442 AY->getTypeConstraintConcept());
14446 AY->getTypeConstraintArguments())) {
14454 false,
false, CD, As);
14456 case Type::PackIndexing:
14457 case Type::Decltype:
14459 case Type::DeducedTemplateSpecialization:
14462 case Type::MacroQualified: {
14466 if (IX != MY->getMacroIdentifier())
14470 case Type::SubstTemplateTypeParm: {
14477 unsigned Index = SX->getIndex();
14478 if (Index != SY->getIndex())
14480 auto PackIndex = SX->getPackIndex();
14481 if (PackIndex != SY->getPackIndex())
14484 CD, Index, PackIndex,
14485 SX->getFinal() && SY->getFinal());
14487 case Type::ObjCTypeParam:
14493 case Type::TemplateSpecialization: {
14498 TY->getTemplateName(),
true);
14503 TY->template_arguments()))
14509 case Type::Typedef: {
14519 case Type::TypeOf: {
14530 case Type::TypeOfExpr:
14533 case Type::UnaryTransform: {
14536 UnaryTransformType::UTTKind KX = UX->getUTTKind();
14537 if (KX != UY->getUTTKind())
14539 QualType BX = UX->getBaseType(), BY = UY->getBaseType();
14546 case Type::Using: {
14555 case Type::MemberPointer: {
14559 assert(Cls == PY->getMostRecentCXXRecordDecl());
14564 case Type::CountAttributed: {
14567 if (DX->isCountInBytes() != DY->isCountInBytes())
14569 if (DX->isOrNull() != DY->isOrNull())
14571 Expr *CEX = DX->getCountExpr();
14572 Expr *CEY = DY->getCountExpr();
14576 DX->isCountInBytes(), DX->isOrNull(),
14587 DX->isCountInBytes(), DX->isOrNull(),
14590 case Type::PredefinedSugar:
14595 llvm_unreachable(
"Unhandled Type Class");
14602 QualType NT =
T.Ty->getLocallyUnqualifiedSingleStepDesugaredType();
14617 if (
X.isCanonical())
14646 if (SX.
Ty != SY.Ty) {
14654 while (!Xs.empty() && !Ys.empty() && Xs.back().Ty == Ys.back().Ty) {
14657 SX = Xs.pop_back_val();
14658 SY = Ys.pop_back_val();
14661 if (KeepCommonQualifiers)
14668 while (!Xs.empty() && !Ys.empty()) {
14671 SX = Xs.pop_back_val();
14672 SY = Ys.pop_back_val();
14677 SX.
Ty = Underlying.Ty;
14680 QX -= Underlying.Quals;
14698 llvm_unreachable(
"Not a saturated fixed point type!");
14699 case BuiltinType::SatShortAccum:
14701 case BuiltinType::SatAccum:
14703 case BuiltinType::SatLongAccum:
14705 case BuiltinType::SatUShortAccum:
14707 case BuiltinType::SatUAccum:
14709 case BuiltinType::SatULongAccum:
14711 case BuiltinType::SatShortFract:
14713 case BuiltinType::SatFract:
14715 case BuiltinType::SatLongFract:
14717 case BuiltinType::SatUShortFract:
14719 case BuiltinType::SatUFract:
14721 case BuiltinType::SatULongFract:
14733 llvm_unreachable(
"Not a fixed point type!");
14734 case BuiltinType::ShortAccum:
14736 case BuiltinType::Accum:
14738 case BuiltinType::LongAccum:
14740 case BuiltinType::UShortAccum:
14742 case BuiltinType::UAccum:
14744 case BuiltinType::ULongAccum:
14746 case BuiltinType::ShortFract:
14748 case BuiltinType::Fract:
14750 case BuiltinType::LongFract:
14752 case BuiltinType::UShortFract:
14754 case BuiltinType::UFract:
14756 case BuiltinType::ULongFract:
14762 if (LangOpts.OpenCL)
14786 llvm_unreachable(
"Not a fixed point type!");
14787 case BuiltinType::ShortAccum:
14788 case BuiltinType::SatShortAccum:
14789 return Target.getShortAccumScale();
14790 case BuiltinType::Accum:
14791 case BuiltinType::SatAccum:
14792 return Target.getAccumScale();
14793 case BuiltinType::LongAccum:
14794 case BuiltinType::SatLongAccum:
14795 return Target.getLongAccumScale();
14796 case BuiltinType::UShortAccum:
14797 case BuiltinType::SatUShortAccum:
14798 return Target.getUnsignedShortAccumScale();
14799 case BuiltinType::UAccum:
14800 case BuiltinType::SatUAccum:
14801 return Target.getUnsignedAccumScale();
14802 case BuiltinType::ULongAccum:
14803 case BuiltinType::SatULongAccum:
14804 return Target.getUnsignedLongAccumScale();
14805 case BuiltinType::ShortFract:
14806 case BuiltinType::SatShortFract:
14807 return Target.getShortFractScale();
14808 case BuiltinType::Fract:
14809 case BuiltinType::SatFract:
14810 return Target.getFractScale();
14811 case BuiltinType::LongFract:
14812 case BuiltinType::SatLongFract:
14813 return Target.getLongFractScale();
14814 case BuiltinType::UShortFract:
14815 case BuiltinType::SatUShortFract:
14816 return Target.getUnsignedShortFractScale();
14817 case BuiltinType::UFract:
14818 case BuiltinType::SatUFract:
14819 return Target.getUnsignedFractScale();
14820 case BuiltinType::ULongFract:
14821 case BuiltinType::SatULongFract:
14822 return Target.getUnsignedLongFractScale();
14832 llvm_unreachable(
"Not a fixed point type!");
14833 case BuiltinType::ShortAccum:
14834 case BuiltinType::SatShortAccum:
14835 return Target.getShortAccumIBits();
14836 case BuiltinType::Accum:
14837 case BuiltinType::SatAccum:
14838 return Target.getAccumIBits();
14839 case BuiltinType::LongAccum:
14840 case BuiltinType::SatLongAccum:
14841 return Target.getLongAccumIBits();
14842 case BuiltinType::UShortAccum:
14843 case BuiltinType::SatUShortAccum:
14844 return Target.getUnsignedShortAccumIBits();
14845 case BuiltinType::UAccum:
14846 case BuiltinType::SatUAccum:
14847 return Target.getUnsignedAccumIBits();
14848 case BuiltinType::ULongAccum:
14849 case BuiltinType::SatULongAccum:
14850 return Target.getUnsignedLongAccumIBits();
14851 case BuiltinType::ShortFract:
14852 case BuiltinType::SatShortFract:
14853 case BuiltinType::Fract:
14854 case BuiltinType::SatFract:
14855 case BuiltinType::LongFract:
14856 case BuiltinType::SatLongFract:
14857 case BuiltinType::UShortFract:
14858 case BuiltinType::SatUShortFract:
14859 case BuiltinType::UFract:
14860 case BuiltinType::SatUFract:
14861 case BuiltinType::ULongFract:
14862 case BuiltinType::SatULongFract:
14867llvm::FixedPointSemantics
14870 "Can only get the fixed point semantics for a "
14871 "fixed point or integer type.");
14873 return llvm::FixedPointSemantics::GetIntegerSemantics(
14877 return llvm::FixedPointSemantics(
14880 !isSigned &&
getTargetInfo().doUnsignedFixedPointTypesHavePadding());
14895 "Expected unsigned fixed point type");
14898 case BuiltinType::UShortAccum:
14900 case BuiltinType::UAccum:
14902 case BuiltinType::ULongAccum:
14904 case BuiltinType::SatUShortAccum:
14906 case BuiltinType::SatUAccum:
14908 case BuiltinType::SatULongAccum:
14910 case BuiltinType::UShortFract:
14912 case BuiltinType::UFract:
14914 case BuiltinType::ULongFract:
14916 case BuiltinType::SatUShortFract:
14918 case BuiltinType::SatUFract:
14920 case BuiltinType::SatULongFract:
14923 llvm_unreachable(
"Unexpected unsigned fixed point type");
14931 std::vector<std::string> BackendFeats;
14932 llvm::AArch64::ExtensionSet FeatureBits;
14933 for (StringRef F : FMVFeatStrings)
14934 if (
auto FMVExt = llvm::AArch64::parseFMVExtension(F))
14936 FeatureBits.enable(*FMVExt->ID);
14937 FeatureBits.toLLVMFeatureList(BackendFeats);
14938 return BackendFeats;
14943 assert(TD !=
nullptr);
14946 llvm::erase_if(
ParsedAttr.Features, [&](
const std::string &Feat) {
14947 return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
14958 Target->getTargetOpts().CPU,
14959 Target->getTargetOpts().Features);
14966 StringRef TargetCPU = Target->getTargetOpts().CPU;
14968 if (
const auto *TD = FD->
getAttr<TargetAttr>()) {
14974 if (!Target->getTriple().isAArch64())
14977 Target->getTargetOpts().FeaturesAsWritten.begin(),
14978 Target->getTargetOpts().FeaturesAsWritten.end());
14989 }
else if (
const auto *SD = FD->
getAttr<CPUSpecificAttr>()) {
14991 Target->getCPUSpecificCPUDispatchFeatures(
14993 std::vector<std::string> Features(FeaturesTmp.begin(), FeaturesTmp.end());
14994 Features.insert(Features.begin(),
14995 Target->getTargetOpts().FeaturesAsWritten.begin(),
14996 Target->getTargetOpts().FeaturesAsWritten.end());
14997 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
14998 }
else if (
const auto *TC = FD->
getAttr<TargetClonesAttr>()) {
14999 if (Target->getTriple().isAArch64()) {
15003 Features.insert(Features.begin(),
15004 Target->getTargetOpts().FeaturesAsWritten.begin(),
15005 Target->getTargetOpts().FeaturesAsWritten.end());
15006 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15007 }
else if (Target->getTriple().isRISCV()) {
15009 std::vector<std::string> Features;
15010 if (VersionStr !=
"default") {
15012 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15015 Features.insert(Features.begin(),
15016 Target->getTargetOpts().FeaturesAsWritten.begin(),
15017 Target->getTargetOpts().FeaturesAsWritten.end());
15018 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15020 std::vector<std::string> Features;
15022 if (VersionStr.starts_with(
"arch="))
15023 TargetCPU = VersionStr.drop_front(
sizeof(
"arch=") - 1);
15024 else if (VersionStr !=
"default")
15025 Features.push_back((StringRef{
"+"} + VersionStr).str());
15026 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15028 }
else if (
const auto *TV = FD->
getAttr<TargetVersionAttr>()) {
15029 std::vector<std::string> Features;
15030 if (Target->getTriple().isRISCV()) {
15032 Features.insert(Features.begin(),
ParsedAttr.Features.begin(),
15035 assert(Target->getTriple().isAArch64());
15037 TV->getFeatures(Feats);
15040 Features.insert(Features.begin(),
15041 Target->getTargetOpts().FeaturesAsWritten.begin(),
15042 Target->getTargetOpts().FeaturesAsWritten.end());
15043 Target->initFeatureMap(FeatureMap,
getDiagnostics(), TargetCPU, Features);
15045 FeatureMap = Target->getTargetOpts().FeatureMap;
15056 auto DeviceDiscriminatorOverrider =
15058 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
15060 return RD->getDeviceLambdaManglingNumber();
15061 return std::nullopt;
15064 Context, Context.getDiagnostics(), DeviceDiscriminatorOverrider)};
15072 std::string Buffer;
15073 Buffer.reserve(128);
15074 llvm::raw_string_ostream Out(Buffer);
15075 MC->mangleCanonicalTypeName(KernelNameType, Out);
15076 std::string KernelName = Out.str();
15078 return {KernelNameType, FD, KernelName};
15087 const auto *SKEPAttr = FD->
getAttr<SYCLKernelEntryPointAttr>();
15088 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
15097 "SYCL kernel name conflict");
15112 return &IT->second;
15118 return *OMPTraitInfoVector.back();
15125 return DB << Section.
Decl;
15126 return DB <<
"a prior #pragma section";
15130 bool IsInternalVar =
15133 bool IsExplicitDeviceVar = (D->
hasAttr<CUDADeviceAttr>() &&
15134 !D->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
15135 (D->
hasAttr<CUDAConstantAttr>() &&
15136 !D->
getAttr<CUDAConstantAttr>()->isImplicit());
15140 return (IsInternalVar &&
15141 (D->
hasAttr<HIPManagedAttr>() || IsExplicitDeviceVar)) ||
15142 (D->
hasAttr<CUDAGlobalAttr>() &&
15149 (D->
hasAttr<HIPManagedAttr>() || D->
hasAttr<CUDAGlobalAttr>() ||
15154 if (!CUIDHash.empty())
15156 if (LangOpts.CUID.empty())
15157 return StringRef();
15158 CUIDHash = llvm::utohexstr(llvm::MD5Hash(LangOpts.CUID),
true);
15168 assert(PrimaryBase);
15171 auto Base = Layout.getPrimaryBase();
15172 if (!
Base ||
Base == PrimaryBase || !
Base->isPolymorphic())
15174 PrimaryBase =
Base;
15176 return PrimaryBase;
15180 StringRef MangledName) {
15182 assert(
Method->isVirtual());
15183 bool DefaultIncludesPointerAuth =
15184 LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
15186 if (!DefaultIncludesPointerAuth)
15189 auto Existing = ThunksToBeAbbreviated.find(VirtualMethodDecl);
15190 if (Existing != ThunksToBeAbbreviated.end())
15191 return Existing->second.contains(MangledName.str());
15194 llvm::StringMap<llvm::SmallVector<std::string, 2>> Thunks;
15196 if (
const auto *ThunkInfos = VtableContext->getThunkInfo(VirtualMethodDecl)) {
15198 for (
const auto &Thunk : *ThunkInfos) {
15200 llvm::raw_svector_ostream ElidedNameStream(ElidedName);
15206 Mangler->mangleThunk(
Method, Thunk,
true,
15209 llvm::raw_svector_ostream mangledNameStream(MangledName);
15213 mangledNameStream);
15215 Mangler->mangleThunk(
Method, Thunk,
false,
15216 mangledNameStream);
15218 Thunks[ElidedName].push_back(std::string(MangledName));
15221 llvm::StringSet<> SimplifiedThunkNames;
15222 for (
auto &ThunkList : Thunks) {
15223 llvm::sort(ThunkList.second);
15224 SimplifiedThunkNames.insert(ThunkList.second[0]);
15226 bool Result = SimplifiedThunkNames.contains(MangledName);
15227 ThunksToBeAbbreviated[VirtualMethodDecl] = std::move(SimplifiedThunkNames);
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 const TemplateArgument * getDefaultTemplateArgumentOrNone(const NamedDecl *P)
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 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 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 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 SmallVector< SourceLocation, 2 > getDeclLocsForCommentSearch(const Decl *D, SourceManager &SourceMgr)
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::Record Record
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.
Defines types useful for describing an Objective-C runtime.
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.
__device__ __2f16 float c
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
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>
RawComment * getRawCommentForDeclNoCacheImpl(const Decl *D, const SourceLocation RepresentativeLocForDecl, const std::map< unsigned, RawComment * > &CommentsInFile) const
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.
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.
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
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.
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 classNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
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)
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.
void setClassNeedsVectorDeletingDestructor(const CXXRecordDecl *RD)
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
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
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 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...
CanQualType SatShortFractTy
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
bool canBindObjCObjectType(QualType To, QualType From)
TemplateTemplateParmDecl * insertCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *CanonTTP) const
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const
Compare the rank of two floating point types as above, but compare equal if both types have the same ...
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
void setParameterIndex(const ParmVarDecl *D, unsigned index)
Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
CanQualType getCanonicalSizeType() const
bool typesAreBlockPointerCompatible(QualType, QualType)
CanQualType SatUnsignedAccumTy
bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl, StringRef MangledName)
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
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 cacheRawCommentForDecl(const Decl &OriginalD, const RawComment &Comment) const
Attaches Comment to OriginalD and to its redeclaration chain and removes the redeclaration chain from...
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
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
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
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
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 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.
llvm::DenseSet< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
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
unsigned getAlignOfGlobalVar(QualType T, const VarDecl *VD) const
Return the alignment in bits that should be given to a global variable with type T.
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.
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.
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.
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
CanQualType SatUnsignedShortAccumTy
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
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)
llvm::DenseMap< const Decl *, const RawComment * > DeclRawComments
Mapping from declaration to directly attached comment.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
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
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.
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
RawComment * getRawCommentForDeclNoCache(const Decl *D) const
Return the documentation comment attached to a given declaration, without looking into cache.
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 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.
interp::Context & getInterpContext()
Returns the clang bytecode interpreter context.
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)
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.
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
QualType getDeducedTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
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
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...
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>.
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers in instanc...
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.
bool canonicalizeTemplateArguments(MutableArrayRef< TemplateArgument > Args) const
Canonicalize the given template argument list.
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
QualType 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...
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.
CXXMethodVector::const_iterator overridden_cxx_method_iterator
RawComment * getRawCommentForDeclNoCacheImpl(const Decl *D, const SourceLocation RepresentativeLocForDecl, const std::map< unsigned, RawComment * > &CommentsInFile) const
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)
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/...
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
const CXXRecordDecl * getBaseSharingVBPtr() const
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 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'.
StringRef getName(const PrintingPolicy &Policy) const
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Implements C++ ABI-specific semantic analysis functions.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
CXXDestructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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]).
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
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.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Complex values, per C99 6.2.5p11.
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
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl,...
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
static Decl * castFromDeclContext(const DeclContext *)
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
void setImplicit(bool I=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
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.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
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.
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.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
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.
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.
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)
@ Relative
Components in the vtable are relative offsets between the vtable and the other structs/functions.
@ Pointer
Components in the vtable are pointers to other structs/functions.
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.
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
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...
QualType getElementType() const
Returns type of the elements being stored in the matrix.
static bool isValidElementType(QualType T)
Valid elements types are the following:
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
bool isCanonical() const
Whether this nested name specifier is canonical.
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, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
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...
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.
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.
TargetOptions & getTargetOpts() const
Retrieve the target options.
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
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...
llvm::StringMap< bool > FeatureMap
The map of which features have been enabled disabled based on the command line.
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.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
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.
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, unsigned D, unsigned 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
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 isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
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 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
std::optional< NullabilityKind > 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)
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,...
The JSON file list parser is used to communicate input to InstallAPI.
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.
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.
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.
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.
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 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