34#include "llvm/ADT/StringExtras.h"
35#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/raw_ostream.h"
37#include "llvm/TargetParser/RISCVTargetParser.h"
44static bool isLocalContainerContext(
const DeclContext *DC) {
45 return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
50 return ftd->getTemplatedDecl();
57 return (fn ? getStructor(fn) :
decl);
60static bool isLambda(
const NamedDecl *ND) {
68static const unsigned UnknownArity = ~0
U;
71 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
72 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
73 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
74 const DiscriminatorOverrideTy DiscriminatorOverride =
nullptr;
77 bool NeedsUniqueInternalLinkageNames =
false;
80 explicit ItaniumMangleContextImpl(
82 DiscriminatorOverrideTy DiscriminatorOverride,
bool IsAux =
false)
84 DiscriminatorOverride(DiscriminatorOverride) {}
96 NeedsUniqueInternalLinkageNames =
true;
101 raw_ostream &)
override;
103 const ThunkInfo &Thunk,
bool, raw_ostream &)
override;
105 raw_ostream &)
override;
112 bool NormalizeIntegers)
override;
114 bool NormalizeIntegers)
override;
121 raw_ostream &Out)
override;
124 raw_ostream &Out)
override;
126 raw_ostream &Out)
override;
129 raw_ostream &)
override;
137 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
143 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
144 if (
Tag->getName().empty() && !
Tag->getTypedefNameForAnonDecl())
151 if (discriminator == 1)
153 disc = discriminator - 2;
158 unsigned &discriminator = Uniquifier[ND];
159 if (!discriminator) {
160 const DeclContext *DC = getEffectiveDeclContext(ND);
161 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
163 if (discriminator == 1)
165 disc = discriminator-2;
172 assert(Lambda->
isLambda() &&
"RD must be a lambda!");
173 std::string Name(
"<lambda");
177 const ParmVarDecl *Parm = dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
182 unsigned DefaultArgNo =
184 Name += llvm::utostr(DefaultArgNo);
188 if (LambdaManglingNumber)
189 LambdaId = LambdaManglingNumber;
193 Name += llvm::utostr(LambdaId);
199 return DiscriminatorOverride;
206 return getEffectiveDeclContext(cast<Decl>(DC));
209 bool isInternalLinkageDecl(
const NamedDecl *ND);
215class CXXNameMangler {
216 ItaniumMangleContextImpl &Context;
220 bool NormalizeIntegers =
false;
222 bool NullOut =
false;
227 bool DisableDerivedAbiTags =
false;
233 unsigned StructorType = 0;
238 unsigned TemplateDepthOffset = 0;
243 class FunctionTypeDepthState {
246 enum { InResultTypeMask = 1 };
249 FunctionTypeDepthState() =
default;
252 unsigned getDepth()
const {
257 bool isInResultType()
const {
258 return Bits & InResultTypeMask;
261 FunctionTypeDepthState push() {
262 FunctionTypeDepthState tmp = *
this;
263 Bits = (Bits & ~InResultTypeMask) + 2;
267 void enterResultType() {
268 Bits |= InResultTypeMask;
271 void leaveResultType() {
272 Bits &= ~InResultTypeMask;
275 void pop(FunctionTypeDepthState saved) {
276 assert(getDepth() == saved.getDepth() + 1);
291 class AbiTagState final {
293 explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
299 AbiTagState(
const AbiTagState &) =
delete;
300 AbiTagState &operator=(
const AbiTagState &) =
delete;
302 ~AbiTagState() { pop(); }
304 void write(raw_ostream &Out,
const NamedDecl *ND,
305 const AbiTagList *AdditionalAbiTags) {
307 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
309 !AdditionalAbiTags &&
310 "only function and variables need a list of additional abi tags");
311 if (
const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
312 if (
const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
313 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
314 AbiTag->tags().end());
322 if (
const auto *AbiTag = ND->
getAttr<AbiTagAttr>()) {
323 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
324 AbiTag->tags().end());
325 TagList.insert(TagList.end(), AbiTag->tags().begin(),
326 AbiTag->tags().end());
329 if (AdditionalAbiTags) {
330 UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(),
331 AdditionalAbiTags->end());
332 TagList.insert(TagList.end(), AdditionalAbiTags->begin(),
333 AdditionalAbiTags->end());
337 TagList.erase(std::unique(TagList.begin(), TagList.end()), TagList.end());
339 writeSortedUniqueAbiTags(Out, TagList);
342 const AbiTagList &getUsedAbiTags()
const {
return UsedAbiTags; }
343 void setUsedAbiTags(
const AbiTagList &AbiTags) {
344 UsedAbiTags = AbiTags;
347 const AbiTagList &getEmittedAbiTags()
const {
348 return EmittedAbiTags;
351 const AbiTagList &getSortedUniqueUsedAbiTags() {
352 llvm::sort(UsedAbiTags);
353 UsedAbiTags.erase(std::unique(UsedAbiTags.begin(), UsedAbiTags.end()),
360 AbiTagList UsedAbiTags;
362 AbiTagList EmittedAbiTags;
364 AbiTagState *&LinkHead;
365 AbiTagState *
Parent =
nullptr;
368 assert(LinkHead ==
this &&
369 "abi tag link head must point to us on destruction");
372 UsedAbiTags.begin(), UsedAbiTags.end());
373 Parent->EmittedAbiTags.insert(
Parent->EmittedAbiTags.end(),
374 EmittedAbiTags.begin(),
375 EmittedAbiTags.end());
380 void writeSortedUniqueAbiTags(raw_ostream &Out,
const AbiTagList &AbiTags) {
381 for (
const auto &Tag : AbiTags) {
382 EmittedAbiTags.push_back(Tag);
390 AbiTagState *AbiTags =
nullptr;
391 AbiTagState AbiTagsRoot;
393 llvm::DenseMap<uintptr_t, unsigned> Substitutions;
394 llvm::DenseMap<StringRef, unsigned> ModuleSubstitutions;
396 ASTContext &getASTContext()
const {
return Context.getASTContext(); }
399 return Context.getASTContext().
getLangOpts().getClangABICompat() <= Ver;
408 llvm::StringRef Name,
bool HasAllocator);
411 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
412 const NamedDecl *
D =
nullptr,
bool NullOut_ =
false)
413 : Context(
C), Out(Out_), NullOut(NullOut_), Structor(getStructor(
D)),
414 AbiTagsRoot(AbiTags) {
416 assert(!
D || (!isa<CXXDestructorDecl>(
D) &&
417 !isa<CXXConstructorDecl>(
D)));
419 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
421 : Context(
C), Out(Out_), Structor(getStructor(
D)), StructorType(
Type),
422 AbiTagsRoot(AbiTags) {}
423 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
425 : Context(
C), Out(Out_), Structor(getStructor(
D)), StructorType(
Type),
426 AbiTagsRoot(AbiTags) {}
428 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
429 bool NormalizeIntegers_)
430 : Context(
C), Out(Out_), NormalizeIntegers(NormalizeIntegers_),
431 NullOut(
false), Structor(nullptr), AbiTagsRoot(AbiTags) {}
432 CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
433 : Context(Outer.Context), Out(Out_), Structor(Outer.Structor),
434 StructorType(Outer.StructorType), SeqID(Outer.SeqID),
435 FunctionTypeDepth(Outer.FunctionTypeDepth), AbiTagsRoot(AbiTags),
436 Substitutions(Outer.Substitutions),
437 ModuleSubstitutions(Outer.ModuleSubstitutions) {}
439 CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
440 : CXXNameMangler(Outer, (raw_ostream &)Out_) {
444 struct WithTemplateDepthOffset {
unsigned Offset; };
445 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out,
446 WithTemplateDepthOffset Offset)
447 : CXXNameMangler(
C, Out) {
448 TemplateDepthOffset = Offset.Offset;
451 raw_ostream &getStream() {
return Out; }
453 void disableDerivedAbiTags() { DisableDerivedAbiTags =
true; }
454 static bool shouldHaveAbiTags(ItaniumMangleContextImpl &
C,
const VarDecl *VD);
457 void mangleCallOffset(int64_t NonVirtual, int64_t
Virtual);
458 void mangleNumber(
const llvm::APSInt &I);
459 void mangleNumber(int64_t Number);
460 void mangleFloat(
const llvm::APFloat &F);
462 void mangleSeqID(
unsigned SeqID);
467 void mangleModuleNamePrefix(StringRef Name,
bool IsPartition =
false);
468 void mangleVendorQualifier(StringRef Name);
469 void mangleVendorType(StringRef Name);
473 bool mangleSubstitution(
const NamedDecl *ND);
481 bool mangleStandardSubstitution(
const NamedDecl *ND);
483 void addSubstitution(
const NamedDecl *ND) {
486 addSubstitution(
reinterpret_cast<uintptr_t>(ND));
491 addSubstitution(
reinterpret_cast<uintptr_t>(NNS));
497 void extendSubstitutions(CXXNameMangler*
Other);
500 bool recursive =
false);
504 unsigned NumTemplateArgs,
505 unsigned KnownArity = UnknownArity);
507 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
510 const AbiTagList *AdditionalAbiTags);
511 void mangleModuleName(
const NamedDecl *ND);
515 const AbiTagList *AdditionalAbiTags) {
516 mangleUnqualifiedName(GD, cast<NamedDecl>(GD.
getDecl())->getDeclName(), DC,
517 UnknownArity, AdditionalAbiTags);
521 const AbiTagList *AdditionalAbiTags);
523 const AbiTagList *AdditionalAbiTags);
525 const AbiTagList *AdditionalAbiTags);
529 void mangleSourceNameWithAbiTags(
530 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
532 const AbiTagList *AdditionalAbiTags);
537 void mangleTypeConstraint(
const ConceptDecl *Concept,
540 void mangleRequiresClause(
const Expr *RequiresClause);
543 const AbiTagList *AdditionalAbiTags,
544 bool NoFunction=
false);
547 void mangleNestedNameWithClosurePrefix(
GlobalDecl GD,
549 const AbiTagList *AdditionalAbiTags);
551 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
553 void mangleTemplatePrefix(
GlobalDecl GD,
bool NoFunction=
false);
556 void mangleClosurePrefix(
const NamedDecl *ND,
bool NoFunction =
false);
557 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
558 StringRef Prefix =
"");
567#define ABSTRACT_TYPE(CLASS, PARENT)
568#define NON_CANONICAL_TYPE(CLASS, PARENT)
569#define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
570#include "clang/AST/TypeNodes.inc"
572 void mangleType(
const TagType*);
574 static StringRef getCallingConvQualifierName(
CallingConv CC);
577 void mangleSMEAttrs(
unsigned SMEAttrs);
582 void mangleAArch64NeonVectorType(
const VectorType *
T);
584 void mangleAArch64FixedSveVectorType(
const VectorType *
T);
586 void mangleRISCVFixedRVVVectorType(
const VectorType *
T);
590 void mangleFloatLiteral(
QualType T,
const llvm::APFloat &
V);
591 void mangleFixedPointLiteral();
594 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
595 void mangleMemberExpr(
const Expr *base,
bool isArrow,
600 unsigned NumTemplateArgs,
601 unsigned knownArity);
602 void mangleCastExpression(
const Expr *
E, StringRef CastEncoding);
603 void mangleInitListElements(
const InitListExpr *InitList);
606 void mangleExpression(
const Expr *
E,
unsigned Arity = UnknownArity,
607 bool AsTemplateArg =
false);
611 struct TemplateArgManglingInfo;
614 unsigned NumTemplateArgs);
617 void mangleTemplateArg(TemplateArgManglingInfo &Info,
unsigned Index,
620 void mangleTemplateArgExpr(
const Expr *
E);
622 bool NeedExactType =
false);
624 void mangleTemplateParameter(
unsigned Depth,
unsigned Index);
629 const AbiTagList *AdditionalAbiTags);
632 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
634 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
642 getASTContext(), getASTContext().getTranslationUnitDecl(),
644 &getASTContext().Idents.get(
"std"),
654ItaniumMangleContextImpl::getEffectiveDeclContext(
const Decl *
D) {
664 dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
665 return ContextParam->getDeclContext();
669 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(
D)) {
671 dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
672 return ContextParam->getDeclContext();
680 if (
D == getASTContext().getVaListTagDecl()) {
681 const llvm::Triple &
T = getASTContext().getTargetInfo().getTriple();
682 if (
T.isARM() ||
T.isThumb() ||
T.isAArch64())
683 return getStdNamespace();
687 if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC) ||
688 isa<OMPDeclareMapperDecl>(DC)) {
689 return getEffectiveDeclContext(cast<Decl>(DC));
692 if (
const auto *VD = dyn_cast<VarDecl>(
D))
694 return getASTContext().getTranslationUnitDecl();
696 if (
const auto *FD = getASTContext().getLangOpts().getClangABICompat() >
697 LangOptions::ClangABI::Ver19
699 : dyn_cast<FunctionDecl>(
D)) {
701 return getASTContext().getTranslationUnitDecl();
704 if (FD->isMemberLikeConstrainedFriend() &&
705 getASTContext().getLangOpts().getClangABICompat() >
706 LangOptions::ClangABI::Ver17)
713bool ItaniumMangleContextImpl::isInternalLinkageDecl(
const NamedDecl *ND) {
716 getEffectiveDeclContext(ND)->isFileContext() &&
723bool ItaniumMangleContextImpl::isUniqueInternalLinkageDecl(
725 if (!NeedsUniqueInternalLinkageNames || !ND)
728 const auto *FD = dyn_cast<FunctionDecl>(ND);
737 if (isInternalLinkageDecl(ND))
743bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *
D) {
744 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
747 if (FD->hasAttr<OverloadableAttr>())
763 if (FD->isMSVCRTEntryPoint())
777 if (!getASTContext().getLangOpts().
CPlusPlus)
780 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
782 if (isa<DecompositionDecl>(VD))
795 DC = getEffectiveParentContext(DC);
797 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
798 !isa<VarTemplateSpecializationDecl>(VD) &&
806void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
807 const AbiTagList *AdditionalAbiTags) {
808 assert(AbiTags &&
"require AbiTagState");
809 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
812void CXXNameMangler::mangleSourceNameWithAbiTags(
813 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
815 writeAbiTags(ND, AdditionalAbiTags);
823 if (isa<FunctionDecl>(GD.
getDecl()))
824 mangleFunctionEncoding(GD);
829 dyn_cast<IndirectFieldDecl>(GD.
getDecl()))
830 mangleName(IFD->getAnonField());
832 llvm_unreachable(
"unexpected kind of global decl");
835void CXXNameMangler::mangleFunctionEncoding(
GlobalDecl GD) {
840 if (!Context.shouldMangleDeclName(FD)) {
845 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
846 if (ReturnTypeAbiTags.empty()) {
855 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
857 FunctionTypeDepth.pop(Saved);
858 mangleFunctionEncodingBareType(FD);
866 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
867 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
869 FunctionEncodingMangler.disableDerivedAbiTags();
871 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
872 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
873 FunctionTypeDepth.pop(Saved);
876 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
877 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
881 const AbiTagList &UsedAbiTags =
882 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
883 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
884 AdditionalAbiTags.erase(
885 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
886 UsedAbiTags.begin(), UsedAbiTags.end(),
887 AdditionalAbiTags.begin()),
888 AdditionalAbiTags.end());
891 Saved = FunctionTypeDepth.push();
892 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
893 FunctionTypeDepth.pop(Saved);
894 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
898 extendSubstitutions(&FunctionEncodingMangler);
901void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
902 if (FD->
hasAttr<EnableIfAttr>()) {
903 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
904 Out <<
"Ua9enable_ifI";
905 for (AttrVec::const_iterator I = FD->
getAttrs().begin(),
908 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
911 if (isCompatibleWith(LangOptions::ClangABI::Ver11)) {
916 mangleExpression(EIA->getCond());
919 mangleTemplateArgExpr(EIA->getCond());
923 FunctionTypeDepth.pop(Saved);
928 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
929 if (
auto Inherited = CD->getInheritedConstructor())
930 FD = Inherited.getConstructor();
948 bool MangleReturnType =
false;
950 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
951 isa<CXXConversionDecl>(FD)))
952 MangleReturnType =
true;
955 FD = PrimaryTemplate->getTemplatedDecl();
959 MangleReturnType, FD);
964 if (!Context.getEffectiveParentContext(NS)->isTranslationUnit())
968 return II && II->
isStr(
"std");
973bool CXXNameMangler::isStdNamespace(
const DeclContext *DC) {
977 return isStd(cast<NamespaceDecl>(DC));
984 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
993 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
994 TemplateArgs = &Spec->getTemplateArgs();
995 return GD.
getWithDecl(Spec->getSpecializedTemplate());
1000 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
1001 TemplateArgs = &Spec->getTemplateArgs();
1002 return GD.
getWithDecl(Spec->getSpecializedTemplate());
1013void CXXNameMangler::mangleName(
GlobalDecl GD) {
1015 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1017 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
1018 if (VariableTypeAbiTags.empty()) {
1020 mangleNameWithAbiTags(VD,
nullptr);
1025 llvm::raw_null_ostream NullOutStream;
1026 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
1027 VariableNameMangler.disableDerivedAbiTags();
1028 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
1031 const AbiTagList &UsedAbiTags =
1032 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
1033 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
1034 AdditionalAbiTags.erase(
1035 std::set_difference(VariableTypeAbiTags.begin(),
1036 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
1037 UsedAbiTags.end(), AdditionalAbiTags.begin()),
1038 AdditionalAbiTags.end());
1041 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
1043 mangleNameWithAbiTags(GD,
nullptr);
1048 const DeclContext *DC = Context.getEffectiveDeclContext(
D);
1050 if (isLocalContainerContext(DC))
1051 return dyn_cast<RecordDecl>(
D);
1053 DC = Context.getEffectiveDeclContext(
D);
1058void CXXNameMangler::mangleNameWithAbiTags(
GlobalDecl GD,
1059 const AbiTagList *AdditionalAbiTags) {
1066 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
1067 bool IsLambda = isLambda(ND);
1073 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !IsLambda)
1075 DC = Context.getEffectiveParentContext(DC);
1076 else if (GetLocalClassDecl(ND) &&
1077 (!IsLambda || isCompatibleWith(LangOptions::ClangABI::Ver18))) {
1078 mangleLocalName(GD, AdditionalAbiTags);
1082 assert(!isa<LinkageSpecDecl>(DC) &&
"context cannot be LinkageSpecDecl");
1086 if (
const NamedDecl *PrefixND = getClosurePrefix(ND)) {
1087 mangleNestedNameWithClosurePrefix(GD, PrefixND, AdditionalAbiTags);
1091 if (isLocalContainerContext(DC)) {
1092 mangleLocalName(GD, AdditionalAbiTags);
1100 mangleUnscopedTemplateName(TD, DC, AdditionalAbiTags);
1105 mangleUnscopedName(GD, DC, AdditionalAbiTags);
1109 mangleNestedName(GD, DC, AdditionalAbiTags);
1112void CXXNameMangler::mangleModuleName(
const NamedDecl *ND) {
1115 mangleModuleNamePrefix(M->getPrimaryModuleInterfaceName());
1123void CXXNameMangler::mangleModuleNamePrefix(StringRef Name,
bool IsPartition) {
1125 auto It = ModuleSubstitutions.find(Name);
1126 if (It != ModuleSubstitutions.end()) {
1128 mangleSeqID(It->second);
1134 auto Parts = Name.rsplit(
'.');
1135 if (Parts.second.empty())
1136 Parts.second = Parts.first;
1138 mangleModuleNamePrefix(Parts.first, IsPartition);
1139 IsPartition =
false;
1145 Out << Parts.second.size() << Parts.second;
1146 ModuleSubstitutions.insert({Name, SeqID++});
1149void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
1151 const DeclContext *DC = Context.getEffectiveDeclContext(TD);
1154 mangleUnscopedTemplateName(TD, DC,
nullptr);
1157 mangleNestedName(TD, Args);
1162 const AbiTagList *AdditionalAbiTags) {
1166 assert(!isa<LinkageSpecDecl>(DC) &&
"unskipped LinkageSpecDecl");
1167 if (isStdNamespace(DC)) {
1168 if (getASTContext().getTargetInfo().getTriple().isOSSolaris()) {
1170 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND)) {
1177 if (llvm::is_contained({
"div_t",
"ldiv_t",
"lconv",
"tm"},
type)) {
1187 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1190void CXXNameMangler::mangleUnscopedTemplateName(
1195 if (mangleSubstitution(ND))
1199 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1200 assert(!AdditionalAbiTags &&
1201 "template template param cannot have abi tags");
1202 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
1203 }
else if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND)) {
1204 mangleUnscopedName(GD, DC, AdditionalAbiTags);
1210 addSubstitution(ND);
1213void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
1227 llvm::APInt valueBits = f.bitcastToAPInt();
1228 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
1229 assert(numCharacters != 0);
1235 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
1237 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
1240 uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
1241 hexDigit >>= (digitBitIndex % 64);
1245 static const char charForHex[16] = {
1246 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
1247 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'
1249 buffer[stringIndex] = charForHex[hexDigit];
1252 Out.write(buffer.data(), numCharacters);
1255void CXXNameMangler::mangleFloatLiteral(
QualType T,
const llvm::APFloat &
V) {
1262void CXXNameMangler::mangleFixedPointLiteral() {
1269void CXXNameMangler::mangleNullPointer(
QualType T) {
1276void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
1277 if (
Value.isSigned() &&
Value.isNegative()) {
1285void CXXNameMangler::mangleNumber(int64_t Number) {
1295void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t
Virtual) {
1303 mangleNumber(NonVirtual);
1309 mangleNumber(NonVirtual);
1317 if (!mangleSubstitution(
QualType(TST, 0))) {
1318 mangleTemplatePrefix(TST->getTemplateName());
1323 mangleTemplateArgs(TST->getTemplateName(), TST->template_arguments());
1326 }
else if (
const auto *DTST =
1328 if (!mangleSubstitution(
QualType(DTST, 0))) {
1329 TemplateName Template = getASTContext().getDependentTemplateName(
1330 DTST->getQualifier(), DTST->getIdentifier());
1331 mangleTemplatePrefix(Template);
1336 mangleTemplateArgs(Template, DTST->template_arguments());
1337 addSubstitution(
QualType(DTST, 0));
1367 switch (qualifier->
getKind()) {
1379 llvm_unreachable(
"Can't mangle __super specifier");
1383 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1391 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1408 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1415 if (mangleUnresolvedTypeOrSimpleId(
QualType(
type, 0), recursive ?
"N" :
""))
1424 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1442void CXXNameMangler::mangleUnresolvedName(
1445 unsigned knownArity) {
1446 if (qualifier) mangleUnresolvedPrefix(qualifier);
1447 switch (
name.getNameKind()) {
1450 mangleSourceName(
name.getAsIdentifierInfo());
1455 mangleUnresolvedTypeOrSimpleId(
name.getCXXNameType());
1462 mangleOperatorName(name, knownArity);
1465 llvm_unreachable(
"Can't mangle a constructor name!");
1467 llvm_unreachable(
"Can't mangle a using directive name!");
1469 llvm_unreachable(
"Can't mangle a deduction guide name!");
1473 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1479 mangleTemplateArgs(
TemplateName(), TemplateArgs, NumTemplateArgs);
1482void CXXNameMangler::mangleUnqualifiedName(
1484 unsigned KnownArity,
const AbiTagList *AdditionalAbiTags) {
1492 mangleModuleName(ND);
1496 auto *FD = dyn_cast<FunctionDecl>(ND);
1497 auto *FTD = dyn_cast<FunctionTemplateDecl>(ND);
1499 (FTD && FTD->getTemplatedDecl()->isMemberLikeConstrainedFriend())) {
1500 if (!isCompatibleWith(LangOptions::ClangABI::Ver17))
1504 unsigned Arity = KnownArity;
1505 switch (Name.getNameKind()) {
1510 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1517 for (
auto *BD : DD->bindings())
1518 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1520 writeAbiTags(ND, AdditionalAbiTags);
1524 if (
auto *GD = dyn_cast<MSGuidDecl>(ND)) {
1527 SmallString<
sizeof(
"_GUID_12345678_1234_1234_1234_1234567890ab")> GUID;
1528 llvm::raw_svector_ostream GUIDOS(GUID);
1529 Context.mangleMSGuidDecl(GD, GUIDOS);
1530 Out << GUID.size() << GUID;
1534 if (
auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
1537 mangleValueInTemplateArg(TPO->getType().getUnqualifiedType(),
1538 TPO->getValue(),
true);
1556 if (Context.isInternalLinkageDecl(ND))
1559 bool IsRegCall = FD &&
1563 FD && FD->
hasAttr<CUDAGlobalAttr>() &&
1566 mangleDeviceStubName(II);
1568 mangleRegCallName(II);
1570 mangleSourceName(II);
1572 writeAbiTags(ND, AdditionalAbiTags);
1577 assert(ND &&
"mangling empty name without declaration");
1579 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1582 Out <<
"12_GLOBAL__N_1";
1587 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1601 &&
"Expected anonymous struct or union!");
1608 assert(FD->
getIdentifier() &&
"Data member name isn't an identifier!");
1621 if (isa<ObjCContainerDecl>(ND))
1625 const TagDecl *TD = cast<TagDecl>(ND);
1628 "Typedef should not be in another decl context!");
1629 assert(
D->getDeclName().getAsIdentifierInfo() &&
1630 "Typedef was not named!");
1631 mangleSourceName(
D->getDeclName().getAsIdentifierInfo());
1632 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1635 writeAbiTags(TD,
nullptr);
1645 std::optional<unsigned> DeviceNumber =
1646 Context.getDiscriminatorOverride()(Context.getASTContext(),
Record);
1652 if (
Record->isLambda() &&
1653 ((DeviceNumber && *DeviceNumber > 0) ||
1654 (!DeviceNumber &&
Record->getLambdaManglingNumber() > 0))) {
1655 assert(!AdditionalAbiTags &&
1656 "Lambda type cannot have additional abi tags");
1663 unsigned UnnamedMangle =
1664 getASTContext().getManglingNumber(TD, Context.isAux());
1666 if (UnnamedMangle > 1)
1667 Out << UnnamedMangle - 2;
1669 writeAbiTags(TD, AdditionalAbiTags);
1675 unsigned AnonStructId =
1677 : Context.getAnonymousStructId(TD, dyn_cast<FunctionDecl>(DC));
1684 Str += llvm::utostr(AnonStructId);
1694 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1700 if (
auto Inherited =
1701 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1702 InheritedFrom = Inherited.getConstructor()->
getParent();
1703 InheritedTemplateName =
1704 TemplateName(Inherited.getConstructor()->getPrimaryTemplate());
1705 InheritedTemplateArgs =
1706 Inherited.getConstructor()->getTemplateSpecializationArgs();
1712 mangleCXXCtorType(
static_cast<CXXCtorType>(StructorType), InheritedFrom);
1720 if (InheritedTemplateArgs)
1721 mangleTemplateArgs(InheritedTemplateName, *InheritedTemplateArgs);
1723 writeAbiTags(ND, AdditionalAbiTags);
1731 mangleCXXDtorType(
static_cast<CXXDtorType>(StructorType));
1737 writeAbiTags(ND, AdditionalAbiTags);
1741 if (ND && Arity == UnknownArity) {
1742 Arity = cast<FunctionDecl>(ND)->getNumParams();
1745 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1746 if (MD->isImplicitObjectMemberFunction())
1752 mangleOperatorName(Name, Arity);
1753 writeAbiTags(ND, AdditionalAbiTags);
1757 llvm_unreachable(
"Can't mangle a deduction guide name!");
1760 llvm_unreachable(
"Can't mangle a using directive name!");
1764void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1768 if (getASTContext().getLangOpts().RegCall4)
1769 Out << II->
getLength() +
sizeof(
"__regcall4__") - 1 <<
"__regcall4__"
1772 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__"
1776void CXXNameMangler::mangleDeviceStubName(
const IdentifierInfo *II) {
1780 Out << II->
getLength() +
sizeof(
"__device_stub__") - 1 <<
"__device_stub__"
1791void CXXNameMangler::mangleNestedName(
GlobalDecl GD,
1793 const AbiTagList *AdditionalAbiTags,
1802 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1803 Qualifiers MethodQuals = Method->getMethodQualifiers();
1806 if (Method->isExplicitObjectMemberFunction())
1809 mangleQualifiers(MethodQuals);
1810 mangleRefQualifier(Method->getRefQualifier());
1816 mangleTemplatePrefix(TD, NoFunction);
1819 manglePrefix(DC, NoFunction);
1820 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1825void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1831 mangleTemplatePrefix(TD);
1837void CXXNameMangler::mangleNestedNameWithClosurePrefix(
1839 const AbiTagList *AdditionalAbiTags) {
1848 mangleClosurePrefix(PrefixND);
1849 mangleUnqualifiedName(GD,
nullptr, AdditionalAbiTags);
1860 if (
auto *CD = dyn_cast<CXXConstructorDecl>(DC))
1862 else if (
auto *DD = dyn_cast<CXXDestructorDecl>(DC))
1869void CXXNameMangler::mangleLocalName(
GlobalDecl GD,
1870 const AbiTagList *AdditionalAbiTags) {
1877 assert(isa<NamedDecl>(
D) || isa<BlockDecl>(
D));
1879 const DeclContext *DC = Context.getEffectiveDeclContext(RD ? RD :
D);
1884 AbiTagState LocalAbiTags(AbiTags);
1887 mangleObjCMethodName(MD);
1888 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1889 mangleBlockForPrefix(BD);
1895 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1918 mangleNumber(
Num - 2);
1927 mangleUnqualifiedName(RD, DC, AdditionalAbiTags);
1928 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(
D)) {
1929 if (
const NamedDecl *PrefixND = getClosurePrefix(BD))
1930 mangleClosurePrefix(PrefixND,
true );
1932 manglePrefix(Context.getEffectiveDeclContext(BD),
true );
1933 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1934 mangleUnqualifiedBlock(BD);
1937 mangleNestedName(GD, Context.getEffectiveDeclContext(ND),
1938 AdditionalAbiTags,
true );
1940 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(
D)) {
1944 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1950 mangleNumber(
Num - 2);
1955 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1956 mangleUnqualifiedBlock(BD);
1958 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1961 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD :
D)) {
1963 if (Context.getNextDiscriminator(ND, disc)) {
1967 Out <<
"__" << disc <<
'_';
1972void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *
Block) {
1973 if (GetLocalClassDecl(
Block)) {
1974 mangleLocalName(
Block,
nullptr);
1978 if (isLocalContainerContext(DC)) {
1979 mangleLocalName(
Block,
nullptr);
1983 mangleClosurePrefix(PrefixND);
1986 mangleUnqualifiedBlock(
Block);
1989void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *
Block) {
1992 if (
Decl *Context =
Block->getBlockManglingContextDecl()) {
1993 if (isCompatibleWith(LangOptions::ClangABI::Ver12) &&
1994 (isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1995 Context->getDeclContext()->isRecord()) {
1996 const auto *ND = cast<NamedDecl>(Context);
1998 mangleSourceNameWithAbiTags(ND);
2005 unsigned Number =
Block->getBlockManglingNumber();
2009 Number = Context.getBlockId(
Block,
false);
2027void CXXNameMangler::mangleTemplateParamDecl(
const NamedDecl *
Decl) {
2029 if (
auto *Ty = dyn_cast<TemplateTypeParmDecl>(
Decl)) {
2030 if (Ty->isParameterPack())
2033 if (Constraint && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
2036 mangleTypeConstraint(Constraint);
2040 }
else if (
auto *Tn = dyn_cast<NonTypeTemplateParmDecl>(
Decl)) {
2041 if (Tn->isExpandedParameterPack()) {
2042 for (
unsigned I = 0, N = Tn->getNumExpansionTypes(); I != N; ++I) {
2044 mangleType(Tn->getExpansionType(I));
2048 if (Tn->isParameterPack()) {
2051 T = PackExpansion->getPattern();
2056 }
else if (
auto *Tt = dyn_cast<TemplateTemplateParmDecl>(
Decl)) {
2057 if (Tt->isExpandedParameterPack()) {
2058 for (
unsigned I = 0, N = Tt->getNumExpansionTemplateParameters(); I != N;
2060 mangleTemplateParameterList(Tt->getExpansionTemplateParameters(I));
2062 if (Tt->isParameterPack())
2064 mangleTemplateParameterList(Tt->getTemplateParameters());
2069void CXXNameMangler::mangleTemplateParameterList(
2072 for (
auto *Param : *Params)
2073 mangleTemplateParamDecl(Param);
2074 mangleRequiresClause(Params->getRequiresClause());
2078void CXXNameMangler::mangleTypeConstraint(
2080 const DeclContext *DC = Context.getEffectiveDeclContext(Concept);
2082 mangleTemplateName(Concept, Arguments);
2084 mangleUnscopedName(Concept, DC,
nullptr);
2086 mangleNestedName(Concept, DC,
nullptr);
2089void CXXNameMangler::mangleTypeConstraint(
const TypeConstraint *Constraint) {
2094 Args.push_back(ArgLoc.getArgument());
2099void CXXNameMangler::mangleRequiresClause(
const Expr *RequiresClause) {
2101 if (RequiresClause && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
2103 mangleExpression(RequiresClause);
2107void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
2111 if (isCompatibleWith(LangOptions::ClangABI::Ver12) &&
2112 (isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
2113 !isa<ParmVarDecl>(Context)) {
2116 mangleSourceName(Name);
2126 mangleLambdaSig(Lambda);
2140 std::optional<unsigned> DeviceNumber =
2141 Context.getDiscriminatorOverride()(Context.getASTContext(), Lambda);
2145 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
2147 mangleNumber(Number - 2);
2151void CXXNameMangler::mangleLambdaSig(
const CXXRecordDecl *Lambda) {
2154 mangleTemplateParamDecl(
D);
2158 mangleRequiresClause(TPL->getRequiresClause());
2162 mangleBareFunctionType(Proto,
false,
2167 switch (qualifier->
getKind()) {
2173 llvm_unreachable(
"Can't mangle __super specifier");
2190 bool Clang14Compat = isCompatibleWith(LangOptions::ClangABI::Ver14);
2191 if (!Clang14Compat && mangleSubstitution(qualifier))
2202 addSubstitution(qualifier);
2206 llvm_unreachable(
"unexpected nested name specifier");
2209void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
2217 assert(!isa<LinkageSpecDecl>(DC) &&
"prefix cannot be LinkageSpecDecl");
2222 if (NoFunction && isLocalContainerContext(DC))
2225 const NamedDecl *ND = cast<NamedDecl>(DC);
2226 if (mangleSubstitution(ND))
2232 mangleTemplatePrefix(TD);
2234 }
else if (
const NamedDecl *PrefixND = getClosurePrefix(ND)) {
2235 mangleClosurePrefix(PrefixND, NoFunction);
2236 mangleUnqualifiedName(ND,
nullptr,
nullptr);
2238 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
2239 manglePrefix(DC, NoFunction);
2240 mangleUnqualifiedName(ND, DC,
nullptr);
2243 addSubstitution(ND);
2246void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
2251 return mangleTemplatePrefix(TD);
2254 assert(
Dependent &&
"unexpected template name kind");
2258 bool Clang11Compat = isCompatibleWith(LangOptions::ClangABI::Ver11);
2259 if (!Clang11Compat && mangleSubstitution(Template))
2263 manglePrefix(Qualifier);
2265 if (Clang11Compat && mangleSubstitution(Template))
2269 mangleSourceName(
Id);
2271 mangleOperatorName(
Dependent->getOperator(), UnknownArity);
2273 addSubstitution(Template);
2276void CXXNameMangler::mangleTemplatePrefix(
GlobalDecl GD,
2285 if (mangleSubstitution(ND))
2289 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
2290 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
2292 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
2293 manglePrefix(DC, NoFunction);
2294 if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND))
2295 mangleUnqualifiedName(GD, DC,
nullptr);
2301 addSubstitution(ND);
2304const NamedDecl *CXXNameMangler::getClosurePrefix(
const Decl *ND) {
2305 if (isCompatibleWith(LangOptions::ClangABI::Ver12))
2309 if (
auto *
Block = dyn_cast<BlockDecl>(ND)) {
2310 Context = dyn_cast_or_null<NamedDecl>(
Block->getBlockManglingContextDecl());
2311 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
2313 Context = dyn_cast_or_null<NamedDecl>(RD->getLambdaContextDecl());
2320 if ((isa<VarDecl>(Context) && cast<VarDecl>(Context)->hasGlobalStorage()) ||
2321 isa<FieldDecl>(Context))
2327void CXXNameMangler::mangleClosurePrefix(
const NamedDecl *ND,
bool NoFunction) {
2330 if (mangleSubstitution(ND))
2335 mangleTemplatePrefix(TD, NoFunction);
2338 const auto *DC = Context.getEffectiveDeclContext(ND);
2339 manglePrefix(DC, NoFunction);
2340 mangleUnqualifiedName(ND, DC,
nullptr);
2345 addSubstitution(ND);
2354 if (mangleSubstitution(TN))
2367 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TD))
2368 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
2375 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
2383 mangleUnresolvedPrefix(
Dependent->getQualifier());
2384 mangleSourceName(
Dependent->getIdentifier());
2404 Out <<
"_SUBSTPACK_";
2408 llvm_unreachable(
"Unexpected DeducedTemplate");
2411 addSubstitution(TN);
2414bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
2420 case Type::Adjusted:
2422 case Type::ArrayParameter:
2424 case Type::BlockPointer:
2425 case Type::LValueReference:
2426 case Type::RValueReference:
2427 case Type::MemberPointer:
2428 case Type::ConstantArray:
2429 case Type::IncompleteArray:
2430 case Type::VariableArray:
2431 case Type::DependentSizedArray:
2432 case Type::DependentAddressSpace:
2433 case Type::DependentVector:
2434 case Type::DependentSizedExtVector:
2436 case Type::ExtVector:
2437 case Type::ConstantMatrix:
2438 case Type::DependentSizedMatrix:
2439 case Type::FunctionProto:
2440 case Type::FunctionNoProto:
2442 case Type::Attributed:
2443 case Type::BTFTagAttributed:
2444 case Type::HLSLAttributedResource:
2446 case Type::DeducedTemplateSpecialization:
2447 case Type::PackExpansion:
2448 case Type::ObjCObject:
2449 case Type::ObjCInterface:
2450 case Type::ObjCObjectPointer:
2451 case Type::ObjCTypeParam:
2454 case Type::MacroQualified:
2456 case Type::DependentBitInt:
2457 case Type::CountAttributed:
2458 llvm_unreachable(
"type is illegal as a nested name specifier");
2460 case Type::SubstTemplateTypeParmPack:
2465 Out <<
"_SUBSTPACK_";
2472 case Type::TypeOfExpr:
2474 case Type::Decltype:
2475 case Type::PackIndexing:
2476 case Type::TemplateTypeParm:
2477 case Type::UnaryTransform:
2478 case Type::SubstTemplateTypeParm:
2492 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
2495 case Type::UnresolvedUsing:
2496 mangleSourceNameWithAbiTags(
2497 cast<UnresolvedUsingType>(Ty)->getDecl());
2502 mangleSourceNameWithAbiTags(cast<TagType>(Ty)->getDecl());
2505 case Type::TemplateSpecialization: {
2507 cast<TemplateSpecializationType>(Ty);
2516 assert(TD &&
"no template for template specialization type");
2517 if (isa<TemplateTemplateParmDecl>(TD))
2518 goto unresolvedType;
2520 mangleSourceNameWithAbiTags(TD);
2528 llvm_unreachable(
"invalid base for a template specialization type");
2542 Out <<
"_SUBSTPACK_";
2547 assert(TD && !isa<TemplateTemplateParmDecl>(TD));
2548 mangleSourceNameWithAbiTags(TD);
2562 case Type::InjectedClassName:
2563 mangleSourceNameWithAbiTags(
2564 cast<InjectedClassNameType>(Ty)->getDecl());
2567 case Type::DependentName:
2568 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
2571 case Type::DependentTemplateSpecialization: {
2573 cast<DependentTemplateSpecializationType>(Ty);
2574 TemplateName Template = getASTContext().getDependentTemplateName(
2582 return mangleUnresolvedTypeOrSimpleId(cast<UsingType>(Ty)->desugar(),
2584 case Type::Elaborated:
2585 return mangleUnresolvedTypeOrSimpleId(
2586 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
2592void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
2593 switch (Name.getNameKind()) {
2602 llvm_unreachable(
"Not an operator name");
2607 mangleType(Name.getCXXNameType());
2612 mangleSourceName(Name.getCXXLiteralIdentifier());
2616 mangleOperatorName(Name.getCXXOverloadedOperator(), Arity);
2625 case OO_New: Out <<
"nw";
break;
2627 case OO_Array_New: Out <<
"na";
break;
2629 case OO_Delete: Out <<
"dl";
break;
2631 case OO_Array_Delete: Out <<
"da";
break;
2635 Out << (Arity == 1?
"ps" :
"pl");
break;
2639 Out << (Arity == 1?
"ng" :
"mi");
break;
2643 Out << (Arity == 1?
"ad" :
"an");
break;
2648 Out << (Arity == 1?
"de" :
"ml");
break;
2650 case OO_Tilde: Out <<
"co";
break;
2652 case OO_Slash: Out <<
"dv";
break;
2654 case OO_Percent: Out <<
"rm";
break;
2656 case OO_Pipe: Out <<
"or";
break;
2658 case OO_Caret: Out <<
"eo";
break;
2660 case OO_Equal: Out <<
"aS";
break;
2662 case OO_PlusEqual: Out <<
"pL";
break;
2664 case OO_MinusEqual: Out <<
"mI";
break;
2666 case OO_StarEqual: Out <<
"mL";
break;
2668 case OO_SlashEqual: Out <<
"dV";
break;
2670 case OO_PercentEqual: Out <<
"rM";
break;
2672 case OO_AmpEqual: Out <<
"aN";
break;
2674 case OO_PipeEqual: Out <<
"oR";
break;
2676 case OO_CaretEqual: Out <<
"eO";
break;
2678 case OO_LessLess: Out <<
"ls";
break;
2680 case OO_GreaterGreater: Out <<
"rs";
break;
2682 case OO_LessLessEqual: Out <<
"lS";
break;
2684 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2686 case OO_EqualEqual: Out <<
"eq";
break;
2688 case OO_ExclaimEqual: Out <<
"ne";
break;
2690 case OO_Less: Out <<
"lt";
break;
2692 case OO_Greater: Out <<
"gt";
break;
2694 case OO_LessEqual: Out <<
"le";
break;
2696 case OO_GreaterEqual: Out <<
"ge";
break;
2698 case OO_Exclaim: Out <<
"nt";
break;
2700 case OO_AmpAmp: Out <<
"aa";
break;
2702 case OO_PipePipe: Out <<
"oo";
break;
2704 case OO_PlusPlus: Out <<
"pp";
break;
2706 case OO_MinusMinus: Out <<
"mm";
break;
2708 case OO_Comma: Out <<
"cm";
break;
2710 case OO_ArrowStar: Out <<
"pm";
break;
2712 case OO_Arrow: Out <<
"pt";
break;
2714 case OO_Call: Out <<
"cl";
break;
2716 case OO_Subscript: Out <<
"ix";
break;
2721 case OO_Conditional: Out <<
"qu";
break;
2724 case OO_Coawait: Out <<
"aw";
break;
2727 case OO_Spaceship: Out <<
"ss";
break;
2731 llvm_unreachable(
"Not an overloaded operator");
2760 if (TargetAS != 0 ||
2762 ASString =
"AS" + llvm::utostr(TargetAS);
2765 default: llvm_unreachable(
"Not a language specific address space");
2769 case LangAS::opencl_global:
2770 ASString =
"CLglobal";
2772 case LangAS::opencl_global_device:
2773 ASString =
"CLdevice";
2775 case LangAS::opencl_global_host:
2776 ASString =
"CLhost";
2778 case LangAS::opencl_local:
2779 ASString =
"CLlocal";
2781 case LangAS::opencl_constant:
2782 ASString =
"CLconstant";
2784 case LangAS::opencl_private:
2785 ASString =
"CLprivate";
2787 case LangAS::opencl_generic:
2788 ASString =
"CLgeneric";
2792 case LangAS::sycl_global:
2793 ASString =
"SYglobal";
2795 case LangAS::sycl_global_device:
2796 ASString =
"SYdevice";
2798 case LangAS::sycl_global_host:
2799 ASString =
"SYhost";
2801 case LangAS::sycl_local:
2802 ASString =
"SYlocal";
2804 case LangAS::sycl_private:
2805 ASString =
"SYprivate";
2808 case LangAS::cuda_device:
2809 ASString =
"CUdevice";
2811 case LangAS::cuda_constant:
2812 ASString =
"CUconstant";
2814 case LangAS::cuda_shared:
2815 ASString =
"CUshared";
2818 case LangAS::ptr32_sptr:
2819 ASString =
"ptr32_sptr";
2821 case LangAS::ptr32_uptr:
2825 if (!getASTContext().getTargetInfo().getTriple().isOSzOS())
2826 ASString =
"ptr32_uptr";
2833 if (!ASString.empty())
2834 mangleVendorQualifier(ASString);
2847 mangleVendorQualifier(
"__weak");
2851 mangleVendorQualifier(
"__unaligned");
2863 mangleVendorQualifier(
"__strong");
2867 mangleVendorQualifier(
"__autoreleasing");
2890void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2894void CXXNameMangler::mangleVendorType(StringRef name) {
2901 switch (RefQualifier) {
2915void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2916 Context.mangleObjCMethodNameAsSourceName(MD, Out);
2929 Ctx.
getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver17)
2935 if (Ctx.
getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver6 &&
2942 if (DeducedTST->getDeducedType().isNull())
2947void CXXNameMangler::mangleType(
QualType T) {
2981 T =
T.getCanonicalType();
2988 = dyn_cast<TemplateSpecializationType>(
T))
2997 =
T.getSingleStepDesugaredType(Context.getASTContext());
3006 const Type *ty = split.
Ty;
3008 bool isSubstitutable =
3010 if (isSubstitutable && mangleSubstitution(
T))
3015 if (quals && isa<ArrayType>(
T)) {
3025 dyn_cast<DependentAddressSpaceType>(ty)) {
3027 mangleQualifiers(splitDAST.
Quals, DAST);
3030 mangleQualifiers(quals);
3038#define ABSTRACT_TYPE(CLASS, PARENT)
3039#define NON_CANONICAL_TYPE(CLASS, PARENT) \
3041 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
3043#define TYPE(CLASS, PARENT) \
3045 mangleType(static_cast<const CLASS##Type*>(ty)); \
3047#include "clang/AST/TypeNodes.inc"
3052 if (isSubstitutable)
3057 if (mangleSubstitution(
Record))
3060 if (isCompatibleWith(LangOptions::ClangABI::Ver19))
3107 std::string type_name;
3111 if (NormalizeIntegers &&
T->isInteger()) {
3112 if (
T->isSignedInteger()) {
3113 switch (getASTContext().getTypeSize(
T)) {
3117 if (mangleSubstitution(BuiltinType::SChar))
3120 addSubstitution(BuiltinType::SChar);
3123 if (mangleSubstitution(BuiltinType::Short))
3126 addSubstitution(BuiltinType::Short);
3129 if (mangleSubstitution(BuiltinType::Int))
3132 addSubstitution(BuiltinType::Int);
3135 if (mangleSubstitution(BuiltinType::Long))
3138 addSubstitution(BuiltinType::Long);
3141 if (mangleSubstitution(BuiltinType::Int128))
3144 addSubstitution(BuiltinType::Int128);
3147 llvm_unreachable(
"Unknown integer size for normalization");
3150 switch (getASTContext().getTypeSize(
T)) {
3152 if (mangleSubstitution(BuiltinType::UChar))
3155 addSubstitution(BuiltinType::UChar);
3158 if (mangleSubstitution(BuiltinType::UShort))
3161 addSubstitution(BuiltinType::UShort);
3164 if (mangleSubstitution(BuiltinType::UInt))
3167 addSubstitution(BuiltinType::UInt);
3170 if (mangleSubstitution(BuiltinType::ULong))
3173 addSubstitution(BuiltinType::ULong);
3176 if (mangleSubstitution(BuiltinType::UInt128))
3179 addSubstitution(BuiltinType::UInt128);
3182 llvm_unreachable(
"Unknown integer size for normalization");
3187 switch (
T->getKind()) {
3188 case BuiltinType::Void:
3191 case BuiltinType::Bool:
3194 case BuiltinType::Char_U:
3195 case BuiltinType::Char_S:
3198 case BuiltinType::UChar:
3201 case BuiltinType::UShort:
3204 case BuiltinType::UInt:
3207 case BuiltinType::ULong:
3210 case BuiltinType::ULongLong:
3213 case BuiltinType::UInt128:
3216 case BuiltinType::SChar:
3219 case BuiltinType::WChar_S:
3220 case BuiltinType::WChar_U:
3223 case BuiltinType::Char8:
3226 case BuiltinType::Char16:
3229 case BuiltinType::Char32:
3232 case BuiltinType::Short:
3235 case BuiltinType::Int:
3238 case BuiltinType::Long:
3241 case BuiltinType::LongLong:
3244 case BuiltinType::Int128:
3247 case BuiltinType::Float16:
3250 case BuiltinType::ShortAccum:
3253 case BuiltinType::Accum:
3256 case BuiltinType::LongAccum:
3259 case BuiltinType::UShortAccum:
3262 case BuiltinType::UAccum:
3265 case BuiltinType::ULongAccum:
3268 case BuiltinType::ShortFract:
3271 case BuiltinType::Fract:
3274 case BuiltinType::LongFract:
3277 case BuiltinType::UShortFract:
3280 case BuiltinType::UFract:
3283 case BuiltinType::ULongFract:
3286 case BuiltinType::SatShortAccum:
3289 case BuiltinType::SatAccum:
3292 case BuiltinType::SatLongAccum:
3295 case BuiltinType::SatUShortAccum:
3298 case BuiltinType::SatUAccum:
3301 case BuiltinType::SatULongAccum:
3304 case BuiltinType::SatShortFract:
3307 case BuiltinType::SatFract:
3310 case BuiltinType::SatLongFract:
3313 case BuiltinType::SatUShortFract:
3316 case BuiltinType::SatUFract:
3319 case BuiltinType::SatULongFract:
3322 case BuiltinType::Half:
3325 case BuiltinType::Float:
3328 case BuiltinType::Double:
3331 case BuiltinType::LongDouble: {
3333 getASTContext().getLangOpts().OpenMP &&
3334 getASTContext().getLangOpts().OpenMPIsTargetDevice
3335 ? getASTContext().getAuxTargetInfo()
3336 : &getASTContext().getTargetInfo();
3340 case BuiltinType::Float128: {
3342 getASTContext().getLangOpts().OpenMP &&
3343 getASTContext().getLangOpts().OpenMPIsTargetDevice
3344 ? getASTContext().getAuxTargetInfo()
3345 : &getASTContext().getTargetInfo();
3349 case BuiltinType::BFloat16: {
3351 ((getASTContext().getLangOpts().OpenMP &&
3352 getASTContext().getLangOpts().OpenMPIsTargetDevice) ||
3353 getASTContext().getLangOpts().SYCLIsDevice)
3354 ? getASTContext().getAuxTargetInfo()
3355 : &getASTContext().getTargetInfo();
3359 case BuiltinType::Ibm128: {
3360 const TargetInfo *TI = &getASTContext().getTargetInfo();
3364 case BuiltinType::NullPtr:
3368#define BUILTIN_TYPE(Id, SingletonId)
3369#define PLACEHOLDER_TYPE(Id, SingletonId) \
3370 case BuiltinType::Id:
3371#include "clang/AST/BuiltinTypes.def"
3372 case BuiltinType::Dependent:
3374 llvm_unreachable(
"mangling a placeholder type");
3376 case BuiltinType::ObjCId:
3377 Out <<
"11objc_object";
3379 case BuiltinType::ObjCClass:
3380 Out <<
"10objc_class";
3382 case BuiltinType::ObjCSel:
3383 Out <<
"13objc_selector";
3385#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3386 case BuiltinType::Id: \
3387 type_name = "ocl_" #ImgType "_" #Suffix; \
3388 Out << type_name.size() << type_name; \
3390#include "clang/Basic/OpenCLImageTypes.def"
3391 case BuiltinType::OCLSampler:
3392 Out <<
"11ocl_sampler";
3394 case BuiltinType::OCLEvent:
3395 Out <<
"9ocl_event";
3397 case BuiltinType::OCLClkEvent:
3398 Out <<
"12ocl_clkevent";
3400 case BuiltinType::OCLQueue:
3401 Out <<
"9ocl_queue";
3403 case BuiltinType::OCLReserveID:
3404 Out <<
"13ocl_reserveid";
3406#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3407 case BuiltinType::Id: \
3408 type_name = "ocl_" #ExtType; \
3409 Out << type_name.size() << type_name; \
3411#include "clang/Basic/OpenCLExtensionTypes.def"
3415#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
3416 case BuiltinType::Id: \
3417 if (T->getKind() == BuiltinType::SveBFloat16 && \
3418 isCompatibleWith(LangOptions::ClangABI::Ver17)) { \
3420 mangleVendorType("__SVBFloat16_t"); \
3422 type_name = MangledName; \
3423 Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
3426#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
3427 case BuiltinType::Id: \
3428 type_name = MangledName; \
3429 Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
3431#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
3432 case BuiltinType::Id: \
3433 type_name = MangledName; \
3434 Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
3436#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
3437 case BuiltinType::Id: \
3438 type_name = MangledName; \
3439 Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
3441#include "clang/Basic/AArch64SVEACLETypes.def"
3442#define PPC_VECTOR_TYPE(Name, Id, Size) \
3443 case BuiltinType::Id: \
3444 mangleVendorType(#Name); \
3446#include "clang/Basic/PPCTypes.def"
3448#define RVV_TYPE(Name, Id, SingletonId) \
3449 case BuiltinType::Id: \
3450 mangleVendorType(Name); \
3452#include "clang/Basic/RISCVVTypes.def"
3453#define WASM_REF_TYPE(InternalName, MangledName, Id, SingletonId, AS) \
3454 case BuiltinType::Id: \
3455 mangleVendorType(MangledName); \
3457#include "clang/Basic/WebAssemblyReferenceTypes.def"
3458#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
3459 case BuiltinType::Id: \
3460 mangleVendorType(Name); \
3462#include "clang/Basic/AMDGPUTypes.def"
3463#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3464 case BuiltinType::Id: \
3465 mangleVendorType(#Name); \
3467#include "clang/Basic/HLSLIntangibleTypes.def"
3471StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
3514 return "swiftasynccall";
3516 llvm_unreachable(
"bad calling convention");
3519void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *
T) {
3528 StringRef CCQualifier = getCallingConvQualifierName(
T->
getExtInfo().
getCC());
3529 if (!CCQualifier.empty())
3530 mangleVendorQualifier(CCQualifier);
3563 llvm_unreachable(
"Unrecognised SME attribute");
3578void CXXNameMangler::mangleSMEAttrs(
unsigned SMEAttrs) {
3596 Out <<
"Lj" <<
static_cast<unsigned>(Bitmask) <<
"EE";
3607 case ParameterABI::Ordinary:
3611 case ParameterABI::HLSLOut:
3612 case ParameterABI::HLSLInOut:
3617 case ParameterABI::SwiftContext:
3618 case ParameterABI::SwiftAsyncContext:
3619 case ParameterABI::SwiftErrorResult:
3620 case ParameterABI::SwiftIndirectResult:
3626 mangleVendorQualifier(
"ns_consumed");
3629 mangleVendorQualifier(
"noescape");
3639 Out <<
"11__SME_ATTRSI";
3641 mangleExtFunctionInfo(
T);
3658 mangleType(ExceptTy);
3669 mangleBareFunctionType(
T,
true);
3676 mangleSMEAttrs(SMEAttrs);
3685 FunctionTypeDepthState saved = FunctionTypeDepth.push();
3687 FunctionTypeDepth.enterResultType();
3689 FunctionTypeDepth.leaveResultType();
3691 FunctionTypeDepth.pop(saved);
3696 bool MangleReturnType,
3700 FunctionTypeDepthState saved = FunctionTypeDepth.push();
3703 if (MangleReturnType) {
3704 FunctionTypeDepth.enterResultType();
3708 mangleVendorQualifier(
"ns_returns_retained");
3713 auto SplitReturnTy = ReturnTy.
split();
3715 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
3717 mangleType(ReturnTy);
3719 FunctionTypeDepth.leaveResultType();
3741 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
3742 if (
Attr->isDynamic())
3743 Out <<
"U25pass_dynamic_object_size" <<
Attr->getType();
3745 Out <<
"U17pass_object_size" <<
Attr->getType();
3756 FunctionTypeDepth.enterResultType();
3760 FunctionTypeDepth.pop(saved);
3766 mangleName(
T->getDecl());
3771void CXXNameMangler::mangleType(
const EnumType *
T) {
3772 mangleType(
static_cast<const TagType*
>(
T));
3774void CXXNameMangler::mangleType(
const RecordType *
T) {
3775 mangleType(
static_cast<const TagType*
>(
T));
3777void CXXNameMangler::mangleType(
const TagType *
T) {
3778 mangleName(
T->getDecl());
3785 Out <<
'A' <<
T->getSize() <<
'_';
3786 mangleType(
T->getElementType());
3791 if (
T->getSizeExpr())
3792 mangleExpression(
T->getSizeExpr());
3794 mangleType(
T->getElementType());
3801 if (
T->getSizeExpr())
3802 mangleExpression(
T->getSizeExpr());
3804 mangleType(
T->getElementType());
3808 mangleType(
T->getElementType());
3838 mangleType(PointeeType);
3843 mangleTemplateParameter(
T->getDepth(),
T->getIndex());
3852 Out <<
"_SUBSTPACK_";
3880 mangleType(
T->getElementType());
3886void CXXNameMangler::mangleNeonVectorType(
const VectorType *
T) {
3888 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3889 const char *EltName =
nullptr;
3890 if (
T->getVectorKind() == VectorKind::NeonPoly) {
3891 switch (cast<BuiltinType>(EltType)->
getKind()) {
3892 case BuiltinType::SChar:
3893 case BuiltinType::UChar:
3894 EltName =
"poly8_t";
3896 case BuiltinType::Short:
3897 case BuiltinType::UShort:
3898 EltName =
"poly16_t";
3900 case BuiltinType::LongLong:
3901 case BuiltinType::ULongLong:
3902 EltName =
"poly64_t";
3904 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
3907 switch (cast<BuiltinType>(EltType)->
getKind()) {
3908 case BuiltinType::SChar: EltName =
"int8_t";
break;
3909 case BuiltinType::UChar: EltName =
"uint8_t";
break;
3910 case BuiltinType::Short: EltName =
"int16_t";
break;
3911 case BuiltinType::UShort: EltName =
"uint16_t";
break;
3912 case BuiltinType::Int: EltName =
"int32_t";
break;
3913 case BuiltinType::UInt: EltName =
"uint32_t";
break;
3914 case BuiltinType::LongLong: EltName =
"int64_t";
break;
3915 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
3916 case BuiltinType::Double: EltName =
"float64_t";
break;
3917 case BuiltinType::Float: EltName =
"float32_t";
break;
3918 case BuiltinType::Half: EltName =
"float16_t";
break;
3919 case BuiltinType::BFloat16: EltName =
"bfloat16_t";
break;
3921 llvm_unreachable(
"unexpected Neon vector element type");
3924 const char *BaseName =
nullptr;
3925 unsigned BitSize = (
T->getNumElements() *
3926 getASTContext().getTypeSize(EltType));
3928 BaseName =
"__simd64_";
3930 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
3931 BaseName =
"__simd128_";
3933 Out << strlen(BaseName) + strlen(EltName);
3934 Out << BaseName << EltName;
3941 "cannot mangle this dependent neon vector type yet");
3942 Diags.
Report(
T->getAttributeLoc(), DiagID);
3947 case BuiltinType::SChar:
3949 case BuiltinType::Short:
3951 case BuiltinType::Int:
3953 case BuiltinType::Long:
3954 case BuiltinType::LongLong:
3956 case BuiltinType::UChar:
3958 case BuiltinType::UShort:
3960 case BuiltinType::UInt:
3962 case BuiltinType::ULong:
3963 case BuiltinType::ULongLong:
3965 case BuiltinType::Half:
3967 case BuiltinType::Float:
3969 case BuiltinType::Double:
3971 case BuiltinType::BFloat16:
3974 llvm_unreachable(
"Unexpected vector element base type");
3981void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *
T) {
3983 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3985 (
T->getNumElements() * getASTContext().getTypeSize(EltType));
3988 assert((BitSize == 64 || BitSize == 128) &&
3989 "Neon vector type not 64 or 128 bits");
3992 if (
T->getVectorKind() == VectorKind::NeonPoly) {
3993 switch (cast<BuiltinType>(EltType)->
getKind()) {
3994 case BuiltinType::UChar:
3997 case BuiltinType::UShort:
4000 case BuiltinType::ULong:
4001 case BuiltinType::ULongLong:
4005 llvm_unreachable(
"unexpected Neon polynomial vector element type");
4011 (
"__" + EltName +
"x" + Twine(
T->getNumElements()) +
"_t").str();
4018 "cannot mangle this dependent neon vector type yet");
4019 Diags.
Report(
T->getAttributeLoc(), DiagID);
4046void CXXNameMangler::mangleAArch64FixedSveVectorType(
const VectorType *
T) {
4047 assert((
T->getVectorKind() == VectorKind::SveFixedLengthData ||
4048 T->getVectorKind() == VectorKind::SveFixedLengthPredicate) &&
4049 "expected fixed-length SVE vector!");
4053 "expected builtin type for fixed-length SVE vector!");
4056 switch (cast<BuiltinType>(EltType)->
getKind()) {
4057 case BuiltinType::SChar:
4060 case BuiltinType::UChar: {
4061 if (
T->getVectorKind() == VectorKind::SveFixedLengthData)
4067 case BuiltinType::Short:
4070 case BuiltinType::UShort:
4073 case BuiltinType::Int:
4076 case BuiltinType::UInt:
4079 case BuiltinType::Long:
4082 case BuiltinType::ULong:
4085 case BuiltinType::Half:
4088 case BuiltinType::Float:
4091 case BuiltinType::Double:
4094 case BuiltinType::BFloat16:
4098 llvm_unreachable(
"unexpected element type for fixed-length SVE vector!");
4101 unsigned VecSizeInBits = getASTContext().getTypeInfo(
T).Width;
4103 if (
T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
4106 Out <<
"9__SVE_VLSI";
4107 mangleVendorType(TypeName);
4108 Out <<
"Lj" << VecSizeInBits <<
"EE";
4111void CXXNameMangler::mangleAArch64FixedSveVectorType(
4116 "cannot mangle this dependent fixed-length SVE vector type yet");
4117 Diags.
Report(
T->getAttributeLoc(), DiagID);
4120void CXXNameMangler::mangleRISCVFixedRVVVectorType(
const VectorType *
T) {
4121 assert((
T->getVectorKind() == VectorKind::RVVFixedLengthData ||
4122 T->getVectorKind() == VectorKind::RVVFixedLengthMask ||
4123 T->getVectorKind() == VectorKind::RVVFixedLengthMask_1 ||
4124 T->getVectorKind() == VectorKind::RVVFixedLengthMask_2 ||
4125 T->getVectorKind() == VectorKind::RVVFixedLengthMask_4) &&
4126 "expected fixed-length RVV vector!");
4130 "expected builtin type for fixed-length RVV vector!");
4133 llvm::raw_svector_ostream TypeNameOS(TypeNameStr);
4134 TypeNameOS <<
"__rvv_";
4135 switch (cast<BuiltinType>(EltType)->
getKind()) {
4136 case BuiltinType::SChar:
4137 TypeNameOS <<
"int8";
4139 case BuiltinType::UChar:
4140 if (
T->getVectorKind() == VectorKind::RVVFixedLengthData)
4141 TypeNameOS <<
"uint8";
4143 TypeNameOS <<
"bool";
4145 case BuiltinType::Short:
4146 TypeNameOS <<
"int16";
4148 case BuiltinType::UShort:
4149 TypeNameOS <<
"uint16";
4151 case BuiltinType::Int:
4152 TypeNameOS <<
"int32";
4154 case BuiltinType::UInt:
4155 TypeNameOS <<
"uint32";
4157 case BuiltinType::Long:
4158 TypeNameOS <<
"int64";
4160 case BuiltinType::ULong:
4161 TypeNameOS <<
"uint64";
4163 case BuiltinType::Float16:
4164 TypeNameOS <<
"float16";
4166 case BuiltinType::Float:
4167 TypeNameOS <<
"float32";
4169 case BuiltinType::Double:
4170 TypeNameOS <<
"float64";
4173 llvm_unreachable(
"unexpected element type for fixed-length RVV vector!");
4176 unsigned VecSizeInBits;
4177 switch (
T->getVectorKind()) {
4178 case VectorKind::RVVFixedLengthMask_1:
4181 case VectorKind::RVVFixedLengthMask_2:
4184 case VectorKind::RVVFixedLengthMask_4:
4188 VecSizeInBits = getASTContext().getTypeInfo(
T).Width;
4193 auto VScale = getASTContext().getTargetInfo().getVScaleRange(
4194 getASTContext().getLangOpts());
4195 unsigned VLen = VScale->first * llvm::RISCV::RVVBitsPerBlock;
4197 if (
T->getVectorKind() == VectorKind::RVVFixedLengthData) {
4199 if (VecSizeInBits >= VLen)
4200 TypeNameOS << (VecSizeInBits / VLen);
4202 TypeNameOS <<
'f' << (VLen / VecSizeInBits);
4204 TypeNameOS << (VLen / VecSizeInBits);
4208 Out <<
"9__RVV_VLSI";
4209 mangleVendorType(TypeNameStr);
4210 Out <<
"Lj" << VecSizeInBits <<
"EE";
4213void CXXNameMangler::mangleRISCVFixedRVVVectorType(
4218 "cannot mangle this dependent fixed-length RVV vector type yet");
4219 Diags.
Report(
T->getAttributeLoc(), DiagID);
4230void CXXNameMangler::mangleType(
const VectorType *
T) {
4231 if ((
T->getVectorKind() == VectorKind::Neon ||
4232 T->getVectorKind() == VectorKind::NeonPoly)) {
4233 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
4234 llvm::Triple::ArchType Arch =
4235 getASTContext().getTargetInfo().getTriple().getArch();
4236 if ((Arch == llvm::Triple::aarch64 ||
4237 Arch == llvm::Triple::aarch64_be) && !
Target.isOSDarwin())
4238 mangleAArch64NeonVectorType(
T);
4240 mangleNeonVectorType(
T);
4242 }
else if (
T->getVectorKind() == VectorKind::SveFixedLengthData ||
4243 T->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
4244 mangleAArch64FixedSveVectorType(
T);
4246 }
else if (
T->getVectorKind() == VectorKind::RVVFixedLengthData ||
4247 T->getVectorKind() == VectorKind::RVVFixedLengthMask ||
4248 T->getVectorKind() == VectorKind::RVVFixedLengthMask_1 ||
4249 T->getVectorKind() == VectorKind::RVVFixedLengthMask_2 ||
4250 T->getVectorKind() == VectorKind::RVVFixedLengthMask_4) {
4251 mangleRISCVFixedRVVVectorType(
T);
4254 Out <<
"Dv" <<
T->getNumElements() <<
'_';
4255 if (
T->getVectorKind() == VectorKind::AltiVecPixel)
4257 else if (
T->getVectorKind() == VectorKind::AltiVecBool)
4260 mangleType(
T->getElementType());
4264 if ((
T->getVectorKind() == VectorKind::Neon ||
4265 T->getVectorKind() == VectorKind::NeonPoly)) {
4266 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
4267 llvm::Triple::ArchType Arch =
4268 getASTContext().getTargetInfo().getTriple().getArch();
4269 if ((Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be) &&
4271 mangleAArch64NeonVectorType(
T);
4273 mangleNeonVectorType(
T);
4275 }
else if (
T->getVectorKind() == VectorKind::SveFixedLengthData ||
4276 T->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
4277 mangleAArch64FixedSveVectorType(
T);
4279 }
else if (
T->getVectorKind() == VectorKind::RVVFixedLengthData) {
4280 mangleRISCVFixedRVVVectorType(
T);
4285 mangleExpression(
T->getSizeExpr());
4287 if (
T->getVectorKind() == VectorKind::AltiVecPixel)
4289 else if (
T->getVectorKind() == VectorKind::AltiVecBool)
4292 mangleType(
T->getElementType());
4300 mangleExpression(
T->getSizeExpr());
4302 mangleType(
T->getElementType());
4309 mangleVendorType(
"matrix_type");
4312 auto &ASTCtx = getASTContext();
4313 unsigned BitWidth = ASTCtx.getTypeSize(ASTCtx.getSizeType());
4314 llvm::APSInt Rows(BitWidth);
4315 Rows =
T->getNumRows();
4316 mangleIntegerLiteral(ASTCtx.getSizeType(), Rows);
4317 llvm::APSInt Columns(BitWidth);
4318 Columns =
T->getNumColumns();
4319 mangleIntegerLiteral(ASTCtx.getSizeType(), Columns);
4320 mangleType(
T->getElementType());
4327 mangleVendorType(
"matrix_type");
4330 mangleTemplateArgExpr(
T->getRowExpr());
4331 mangleTemplateArgExpr(
T->getColumnExpr());
4332 mangleType(
T->getElementType());
4338 mangleQualifiers(split.
Quals,
T);
4345 mangleType(
T->getPattern());
4349 if (!
T->hasSelectedType())
4350 mangleType(
T->getPattern());
4352 mangleType(
T->getSelectedType());
4356 mangleSourceName(
T->getDecl()->getIdentifier());
4361 if (
T->isKindOfType())
4362 Out <<
"U8__kindof";
4364 if (!
T->qual_empty()) {
4367 llvm::raw_svector_ostream QualOS(QualStr);
4368 QualOS <<
"objcproto";
4369 for (
const auto *I :
T->quals()) {
4370 StringRef
name = I->getName();
4373 mangleVendorQualifier(QualStr);
4376 mangleType(
T->getBaseType());
4378 if (
T->isSpecialized()) {
4381 for (
auto typeArg :
T->getTypeArgs())
4382 mangleType(typeArg);
4388 Out <<
"U13block_pointer";
4396 mangleType(
T->getInjectedSpecializationType());
4400 if (
TemplateDecl *TD =
T->getTemplateName().getAsTemplateDecl()) {
4401 mangleTemplateName(TD,
T->template_arguments());
4406 mangleTemplatePrefix(
T->getTemplateName());
4411 mangleTemplateArgs(
T->getTemplateName(),
T->template_arguments());
4427 switch (
T->getKeyword()) {
4428 case ElaboratedTypeKeyword::None:
4429 case ElaboratedTypeKeyword::Typename:
4431 case ElaboratedTypeKeyword::Struct:
4432 case ElaboratedTypeKeyword::Class:
4433 case ElaboratedTypeKeyword::Interface:
4436 case ElaboratedTypeKeyword::Union:
4439 case ElaboratedTypeKeyword::Enum:
4445 manglePrefix(
T->getQualifier());
4446 mangleSourceName(
T->getIdentifier());
4456 getASTContext().getDependentTemplateName(
T->getQualifier(),
4457 T->getIdentifier());
4458 mangleTemplatePrefix(Prefix);
4463 mangleTemplateArgs(Prefix,
T->template_arguments());
4467void CXXNameMangler::mangleType(
const TypeOfType *
T) {
4480 Expr *
E =
T->getUnderlyingExpr();
4490 if (isa<DeclRefExpr>(
E) ||
4491 isa<MemberExpr>(
E) ||
4492 isa<UnresolvedLookupExpr>(
E) ||
4493 isa<DependentScopeDeclRefExpr>(
E) ||
4494 isa<CXXDependentScopeMemberExpr>(
E) ||
4495 isa<UnresolvedMemberExpr>(
E))
4499 mangleExpression(
E);
4507 StringRef BuiltinName;
4508 switch (
T->getUTTKind()) {
4509#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
4510 case UnaryTransformType::Enum: \
4511 BuiltinName = "__" #Trait; \
4513#include "clang/Basic/TransformTypeTraits.def"
4515 mangleVendorType(BuiltinName);
4519 mangleType(
T->getBaseType());
4523void CXXNameMangler::mangleType(
const AutoType *
T) {
4524 assert(
T->getDeducedType().isNull() &&
4525 "Deduced AutoType shouldn't be handled here!");
4526 assert(
T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
4527 "shouldn't need to mangle __auto_type!");
4532 if (
T->isConstrained() && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
4533 Out << (
T->isDecltypeAuto() ?
"DK" :
"Dk");
4534 mangleTypeConstraint(
T->getTypeConstraintConcept(),
4535 T->getTypeConstraintArguments());
4537 Out << (
T->isDecltypeAuto() ?
"Dc" :
"Da");
4544 return mangleType(Deduced);
4548 "shouldn't form deduced TST unless we know we have a template");
4552void CXXNameMangler::mangleType(
const AtomicType *
T) {
4556 mangleType(
T->getValueType());
4559void CXXNameMangler::mangleType(
const PipeType *
T) {
4566void CXXNameMangler::mangleType(
const BitIntType *
T) {
4570 Out <<
"D" << (
T->isUnsigned() ?
"U" :
"B") <<
T->getNumBits() <<
"_";
4577 Out <<
"D" << (
T->isUnsigned() ?
"U" :
"B");
4578 mangleExpression(
T->getNumBitsExpr());
4583 mangleType(cast<ConstantArrayType>(
T));
4591 case llvm::dxil::ResourceClass::UAV:
4594 case llvm::dxil::ResourceClass::SRV:
4597 case llvm::dxil::ResourceClass::CBuffer:
4600 case llvm::dxil::ResourceClass::Sampler:
4608 if (
T->hasContainedType())
4610 mangleVendorQualifier(Str);
4612 if (
T->hasContainedType()) {
4613 mangleType(
T->getContainedType());
4615 mangleType(
T->getWrappedType());
4618void CXXNameMangler::mangleIntegerLiteral(
QualType T,
4619 const llvm::APSInt &
Value) {
4626 Out << (
Value.getBoolValue() ?
'1' :
'0');
4628 mangleNumber(
Value);
4634void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
4637 if (!RT->getDecl()->isAnonymousStructOrUnion())
4639 const auto *ME = dyn_cast<MemberExpr>(
Base);
4642 Base = ME->getBase();
4643 IsArrow = ME->isArrow();
4646 if (
Base->isImplicitCXXThis()) {
4652 Out << (IsArrow ?
"pt" :
"dt");
4653 mangleExpression(
Base);
4658void CXXNameMangler::mangleMemberExpr(
const Expr *base,
4664 unsigned NumTemplateArgs,
4669 mangleMemberExprBase(base, isArrow);
4670 mangleUnresolvedName(qualifier, member, TemplateArgs, NumTemplateArgs, arity);
4683 if (callee == fn)
return false;
4687 if (!lookup)
return false;
4704void CXXNameMangler::mangleCastExpression(
const Expr *
E, StringRef CastEncoding) {
4706 Out << CastEncoding;
4711void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
4713 InitList = Syntactic;
4714 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
4715 mangleExpression(InitList->
getInit(i));
4718void CXXNameMangler::mangleRequirement(
SourceLocation RequiresExprLoc,
4725 auto HandleSubstitutionFailure =
4730 "containing a substitution failure");
4736 case Requirement::RK_Type: {
4737 const auto *TR = cast<concepts::TypeRequirement>(Req);
4738 if (TR->isSubstitutionFailure())
4739 return HandleSubstitutionFailure(
4740 TR->getSubstitutionDiagnostic()->DiagLoc);
4743 mangleType(TR->getType()->getType());
4747 case Requirement::RK_Simple:
4748 case Requirement::RK_Compound: {
4749 const auto *ER = cast<concepts::ExprRequirement>(Req);
4750 if (ER->isExprSubstitutionFailure())
4751 return HandleSubstitutionFailure(
4752 ER->getExprSubstitutionDiagnostic()->DiagLoc);
4755 mangleExpression(ER->getExpr());
4757 if (ER->hasNoexceptRequirement())
4760 if (!ER->getReturnTypeRequirement().isEmpty()) {
4761 if (ER->getReturnTypeRequirement().isSubstitutionFailure())
4762 return HandleSubstitutionFailure(ER->getReturnTypeRequirement()
4763 .getSubstitutionDiagnostic()
4767 mangleTypeConstraint(ER->getReturnTypeRequirement().getTypeConstraint());
4772 case Requirement::RK_Nested:
4773 const auto *NR = cast<concepts::NestedRequirement>(Req);
4774 if (NR->hasInvalidConstraint()) {
4777 return HandleSubstitutionFailure(RequiresExprLoc);
4781 mangleExpression(NR->getConstraintExpr());
4786void CXXNameMangler::mangleExpression(
const Expr *
E,
unsigned Arity,
4787 bool AsTemplateArg) {
4816 QualType ImplicitlyConvertedToType;
4820 bool IsPrimaryExpr =
true;
4821 auto NotPrimaryExpr = [&] {
4822 if (AsTemplateArg && IsPrimaryExpr)
4824 IsPrimaryExpr =
false;
4827 auto MangleDeclRefExpr = [&](
const NamedDecl *
D) {
4838 mangleFunctionParam(cast<ParmVarDecl>(
D));
4841 case Decl::EnumConstant: {
4848 case Decl::NonTypeTemplateParm:
4861 case Expr::NoStmtClass:
4862#define ABSTRACT_STMT(Type)
4863#define EXPR(Type, Base)
4864#define STMT(Type, Base) \
4865 case Expr::Type##Class:
4866#include "clang/AST/StmtNodes.inc"
4871 case Expr::AddrLabelExprClass:
4872 case Expr::DesignatedInitUpdateExprClass:
4873 case Expr::ImplicitValueInitExprClass:
4874 case Expr::ArrayInitLoopExprClass:
4875 case Expr::ArrayInitIndexExprClass:
4876 case Expr::NoInitExprClass:
4877 case Expr::ParenListExprClass:
4878 case Expr::MSPropertyRefExprClass:
4879 case Expr::MSPropertySubscriptExprClass:
4880 case Expr::TypoExprClass:
4881 case Expr::RecoveryExprClass:
4882 case Expr::ArraySectionExprClass:
4883 case Expr::OMPArrayShapingExprClass:
4884 case Expr::OMPIteratorExprClass:
4885 case Expr::CXXInheritedCtorInitExprClass:
4886 case Expr::CXXParenListInitExprClass:
4887 case Expr::PackIndexingExprClass:
4888 llvm_unreachable(
"unexpected statement kind");
4890 case Expr::ConstantExprClass:
4891 E = cast<ConstantExpr>(
E)->getSubExpr();
4895 case Expr::BlockExprClass:
4896 case Expr::ChooseExprClass:
4897 case Expr::CompoundLiteralExprClass:
4898 case Expr::ExtVectorElementExprClass:
4899 case Expr::GenericSelectionExprClass:
4900 case Expr::ObjCEncodeExprClass:
4901 case Expr::ObjCIsaExprClass:
4902 case Expr::ObjCIvarRefExprClass:
4903 case Expr::ObjCMessageExprClass:
4904 case Expr::ObjCPropertyRefExprClass:
4905 case Expr::ObjCProtocolExprClass:
4906 case Expr::ObjCSelectorExprClass:
4907 case Expr::ObjCStringLiteralClass:
4908 case Expr::ObjCBoxedExprClass:
4909 case Expr::ObjCArrayLiteralClass:
4910 case Expr::ObjCDictionaryLiteralClass:
4911 case Expr::ObjCSubscriptRefExprClass:
4912 case Expr::ObjCIndirectCopyRestoreExprClass:
4913 case Expr::ObjCAvailabilityCheckExprClass:
4914 case Expr::OffsetOfExprClass:
4915 case Expr::PredefinedExprClass:
4916 case Expr::ShuffleVectorExprClass:
4917 case Expr::ConvertVectorExprClass:
4918 case Expr::StmtExprClass:
4919 case Expr::ArrayTypeTraitExprClass:
4920 case Expr::ExpressionTraitExprClass:
4921 case Expr::VAArgExprClass:
4922 case Expr::CUDAKernelCallExprClass:
4923 case Expr::AsTypeExprClass:
4924 case Expr::PseudoObjectExprClass:
4925 case Expr::AtomicExprClass:
4926 case Expr::SourceLocExprClass:
4927 case Expr::EmbedExprClass:
4928 case Expr::BuiltinBitCastExprClass:
4935 "cannot yet mangle expression type %0");
4943 case Expr::CXXUuidofExprClass: {
4948 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
4949 Out <<
"u8__uuidof";
4958 Out <<
"u8__uuidoft";
4962 Out <<
"u8__uuidofz";
4963 mangleExpression(UuidExp);
4970 case Expr::BinaryConditionalOperatorClass: {
4975 "?: operator with omitted middle operand cannot be mangled");
4982 case Expr::OpaqueValueExprClass:
4983 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
4985 case Expr::InitListExprClass: {
4988 mangleInitListElements(cast<InitListExpr>(
E));
4993 case Expr::DesignatedInitExprClass: {
4995 auto *DIE = cast<DesignatedInitExpr>(
E);
4996 for (
const auto &
Designator : DIE->designators()) {
5002 mangleExpression(DIE->getArrayIndex(
Designator));
5005 "unknown designator kind");
5007 mangleExpression(DIE->getArrayRangeStart(
Designator));
5008 mangleExpression(DIE->getArrayRangeEnd(
Designator));
5011 mangleExpression(DIE->getInit());
5015 case Expr::CXXDefaultArgExprClass:
5016 E = cast<CXXDefaultArgExpr>(
E)->getExpr();
5019 case Expr::CXXDefaultInitExprClass:
5020 E = cast<CXXDefaultInitExpr>(
E)->getExpr();
5023 case Expr::CXXStdInitializerListExprClass:
5024 E = cast<CXXStdInitializerListExpr>(
E)->getSubExpr();
5027 case Expr::SubstNonTypeTemplateParmExprClass: {
5030 auto *SNTTPE = cast<SubstNonTypeTemplateParmExpr>(
E);
5031 if (
auto *CE = dyn_cast<ConstantExpr>(SNTTPE->getReplacement())) {
5033 QualType ParamType = SNTTPE->getParameterType(Context.getASTContext());
5034 assert(CE->hasAPValueResult() &&
"expected the NTTP to have an APValue");
5035 mangleValueInTemplateArg(ParamType, CE->getAPValueResult(),
false,
5041 E = cast<SubstNonTypeTemplateParmExpr>(
E)->getReplacement();
5045 case Expr::UserDefinedLiteralClass:
5048 case Expr::CXXMemberCallExprClass:
5049 case Expr::CallExprClass: {
5070 if (isa<PackExpansionExpr>(Arg))
5071 CallArity = UnknownArity;
5073 mangleExpression(CE->
getCallee(), CallArity);
5075 mangleExpression(Arg);
5080 case Expr::CXXNewExprClass: {
5084 Out << (New->
isArray() ?
"na" :
"nw");
5087 mangleExpression(*I);
5101 mangleExpression(*I);
5103 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
5104 mangleExpression(PLE->getExpr(i));
5106 CXXNewInitializationStyle::Braces &&
5107 isa<InitListExpr>(
Init)) {
5109 mangleInitListElements(cast<InitListExpr>(
Init));
5111 mangleExpression(
Init);
5117 case Expr::CXXPseudoDestructorExprClass: {
5119 const auto *PDE = cast<CXXPseudoDestructorExpr>(
E);
5120 if (
const Expr *
Base = PDE->getBase())
5121 mangleMemberExprBase(
Base, PDE->isArrow());
5125 mangleUnresolvedPrefix(Qualifier,
5127 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
5131 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
5134 }
else if (Qualifier) {
5135 mangleUnresolvedPrefix(Qualifier);
5139 QualType DestroyedType = PDE->getDestroyedType();
5140 mangleUnresolvedTypeOrSimpleId(DestroyedType);
5144 case Expr::MemberExprClass: {
5155 case Expr::UnresolvedMemberExprClass: {
5166 case Expr::CXXDependentScopeMemberExprClass: {
5169 = cast<CXXDependentScopeMemberExpr>(
E);
5179 case Expr::UnresolvedLookupExprClass: {
5188 case Expr::CXXUnresolvedConstructExprClass: {
5194 assert(N == 1 &&
"unexpected form for list initialization");
5195 auto *IL = cast<InitListExpr>(CE->
getArg(0));
5198 mangleInitListElements(IL);
5205 if (N != 1) Out <<
'_';
5206 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
5207 if (N != 1) Out <<
'E';
5211 case Expr::CXXConstructExprClass: {
5213 const auto *CE = cast<CXXConstructExpr>(
E);
5218 "implicit CXXConstructExpr must have one argument");
5219 E = cast<CXXConstructExpr>(
E)->getArg(0);
5225 mangleExpression(
E);
5230 case Expr::CXXTemporaryObjectExprClass: {
5232 const auto *CE = cast<CXXTemporaryObjectExpr>(
E);
5241 if (!List && N != 1)
5243 if (CE->isStdInitListInitialization()) {
5249 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
5250 mangleInitListElements(ILE);
5253 mangleExpression(
E);
5260 case Expr::CXXScalarValueInitExprClass:
5267 case Expr::CXXNoexceptExprClass:
5270 mangleExpression(cast<CXXNoexceptExpr>(
E)->getOperand());
5273 case Expr::UnaryExprOrTypeTraitExprClass: {
5292 : ImplicitlyConvertedToType;
5294 mangleIntegerLiteral(
T,
V);
5300 auto MangleAlignofSizeofArg = [&] {
5313 MangleAlignofSizeofArg();
5315 case UETT_PreferredAlignOf:
5319 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
5320 Out <<
"u11__alignof__";
5331 MangleAlignofSizeofArg();
5333 case UETT_DataSizeOf: {
5337 "cannot yet mangle __datasizeof expression");
5341 case UETT_PtrAuthTypeDiscriminator: {
5345 "cannot yet mangle __builtin_ptrauth_type_discriminator expression");
5349 case UETT_VecStep: {
5352 "cannot yet mangle vec_step expression");
5356 case UETT_OpenMPRequiredSimdAlign: {
5360 "cannot yet mangle __builtin_omp_required_simd_align expression");
5364 case UETT_VectorElements: {
5368 "cannot yet mangle __builtin_vectorelements expression");
5376 case Expr::TypeTraitExprClass: {
5381 mangleVendorType(Spelling);
5383 mangleType(TSI->getType());
5389 case Expr::CXXThrowExprClass: {
5403 case Expr::CXXTypeidExprClass: {
5418 case Expr::CXXDeleteExprClass: {
5429 case Expr::UnaryOperatorClass: {
5438 case Expr::ArraySubscriptExprClass: {
5445 mangleExpression(AE->
getLHS());
5446 mangleExpression(AE->
getRHS());
5450 case Expr::MatrixSubscriptExprClass: {
5454 mangleExpression(ME->
getBase());
5460 case Expr::CompoundAssignOperatorClass:
5461 case Expr::BinaryOperatorClass: {
5469 mangleExpression(BO->
getLHS());
5470 mangleExpression(BO->
getRHS());
5474 case Expr::CXXRewrittenBinaryOperatorClass: {
5478 cast<CXXRewrittenBinaryOperator>(
E)->getDecomposedForm();
5481 mangleExpression(Decomposed.
LHS);
5482 mangleExpression(Decomposed.
RHS);
5486 case Expr::ConditionalOperatorClass: {
5489 mangleOperatorName(OO_Conditional, 3);
5490 mangleExpression(CO->
getCond());
5491 mangleExpression(CO->
getLHS(), Arity);
5492 mangleExpression(CO->
getRHS(), Arity);
5496 case Expr::ImplicitCastExprClass: {
5497 ImplicitlyConvertedToType =
E->
getType();
5498 E = cast<ImplicitCastExpr>(
E)->getSubExpr();
5502 case Expr::ObjCBridgedCastExprClass: {
5506 StringRef
Kind = cast<ObjCBridgedCastExpr>(
E)->getBridgeKindName();
5507 Out <<
"v1U" <<
Kind.size() <<
Kind;
5508 mangleCastExpression(
E,
"cv");
5512 case Expr::CStyleCastExprClass:
5514 mangleCastExpression(
E,
"cv");
5517 case Expr::CXXFunctionalCastExprClass: {
5519 auto *
Sub = cast<ExplicitCastExpr>(
E)->getSubExpr()->IgnoreImplicit();
5521 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
5522 if (CCE->getParenOrBraceRange().isInvalid())
5523 Sub = CCE->getArg(0)->IgnoreImplicit();
5524 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
5525 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
5526 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
5529 mangleInitListElements(IL);
5532 mangleCastExpression(
E,
"cv");
5537 case Expr::CXXStaticCastExprClass:
5539 mangleCastExpression(
E,
"sc");
5541 case Expr::CXXDynamicCastExprClass:
5543 mangleCastExpression(
E,
"dc");
5545 case Expr::CXXReinterpretCastExprClass:
5547 mangleCastExpression(
E,
"rc");
5549 case Expr::CXXConstCastExprClass:
5551 mangleCastExpression(
E,
"cc");
5553 case Expr::CXXAddrspaceCastExprClass:
5555 mangleCastExpression(
E,
"ac");
5558 case Expr::CXXOperatorCallExprClass: {
5567 for (
unsigned i = 0; i != NumArgs; ++i)
5568 mangleExpression(CE->
getArg(i));
5572 case Expr::ParenExprClass:
5573 E = cast<ParenExpr>(
E)->getSubExpr();
5576 case Expr::ConceptSpecializationExprClass: {
5577 auto *CSE = cast<ConceptSpecializationExpr>(
E);
5578 if (isCompatibleWith(LangOptions::ClangABI::Ver17)) {
5583 mangleTemplateName(CSE->getNamedConcept(), CSE->getTemplateArguments());
5589 mangleUnresolvedName(
5590 CSE->getNestedNameSpecifierLoc().getNestedNameSpecifier(),
5591 CSE->getConceptNameInfo().getName(),
5592 CSE->getTemplateArgsAsWritten()->getTemplateArgs(),
5593 CSE->getTemplateArgsAsWritten()->getNumTemplateArgs());
5597 case Expr::RequiresExprClass: {
5599 auto *RE = cast<RequiresExpr>(
E);
5603 if (RE->getLParenLoc().isValid()) {
5605 FunctionTypeDepthState saved = FunctionTypeDepth.push();
5606 if (RE->getLocalParameters().empty()) {
5609 for (
ParmVarDecl *Param : RE->getLocalParameters()) {
5617 FunctionTypeDepth.enterResultType();
5619 mangleRequirement(RE->getExprLoc(), Req);
5620 FunctionTypeDepth.pop(saved);
5625 mangleRequirement(RE->getExprLoc(), Req);
5631 case Expr::DeclRefExprClass:
5633 MangleDeclRefExpr(cast<DeclRefExpr>(
E)->getDecl());
5636 case Expr::SubstNonTypeTemplateParmPackExprClass:
5642 Out <<
"_SUBSTPACK_";
5645 case Expr::FunctionParmPackExprClass: {
5649 Out <<
"v110_SUBSTPACK";
5654 case Expr::DependentScopeDeclRefExprClass: {
5663 case Expr::CXXBindTemporaryExprClass:
5664 E = cast<CXXBindTemporaryExpr>(
E)->getSubExpr();
5667 case Expr::ExprWithCleanupsClass:
5668 E = cast<ExprWithCleanups>(
E)->getSubExpr();
5671 case Expr::FloatingLiteralClass: {
5678 case Expr::FixedPointLiteralClass:
5680 mangleFixedPointLiteral();
5683 case Expr::CharacterLiteralClass:
5687 Out << cast<CharacterLiteral>(
E)->getValue();
5692 case Expr::ObjCBoolLiteralExprClass:
5695 Out << (cast<ObjCBoolLiteralExpr>(
E)->getValue() ?
'1' :
'0');
5699 case Expr::CXXBoolLiteralExprClass:
5702 Out << (cast<CXXBoolLiteralExpr>(
E)->getValue() ?
'1' :
'0');
5706 case Expr::IntegerLiteralClass: {
5708 llvm::APSInt
Value(cast<IntegerLiteral>(
E)->getValue());
5710 Value.setIsSigned(
true);
5715 case Expr::ImaginaryLiteralClass: {
5723 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
5725 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
5727 mangleFloat(Imag->getValue());
5730 llvm::APSInt
Value(cast<IntegerLiteral>(IE->
getSubExpr())->getValue());
5732 Value.setIsSigned(
true);
5733 mangleNumber(
Value);
5739 case Expr::StringLiteralClass: {
5743 assert(isa<ConstantArrayType>(
E->
getType()));
5749 case Expr::GNUNullExprClass:
5752 mangleIntegerLiteral(
E->
getType(), llvm::APSInt(32));
5755 case Expr::CXXNullPtrLiteralExprClass: {
5761 case Expr::LambdaExprClass: {
5766 mangleType(Context.getASTContext().
getRecordType(cast<LambdaExpr>(
E)->getLambdaClass()));
5771 case Expr::PackExpansionExprClass:
5774 mangleExpression(cast<PackExpansionExpr>(
E)->getPattern());
5777 case Expr::SizeOfPackExprClass: {
5779 auto *SPE = cast<SizeOfPackExpr>(
E);
5780 if (SPE->isPartiallySubstituted()) {
5782 for (
const auto &A : SPE->getPartialArguments())
5783 mangleTemplateArg(A,
false);
5791 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
5793 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
5794 mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
5796 = dyn_cast<TemplateTemplateParmDecl>(Pack))
5797 mangleTemplateParameter(TempTP->getDepth(), TempTP->getIndex());
5799 mangleFunctionParam(cast<ParmVarDecl>(Pack));
5803 case Expr::MaterializeTemporaryExprClass:
5804 E = cast<MaterializeTemporaryExpr>(
E)->getSubExpr();
5807 case Expr::CXXFoldExprClass: {
5809 auto *FE = cast<CXXFoldExpr>(
E);
5810 if (FE->isLeftFold())
5811 Out << (FE->getInit() ?
"fL" :
"fl");
5813 Out << (FE->getInit() ?
"fR" :
"fr");
5815 if (FE->getOperator() == BO_PtrMemD)
5823 mangleExpression(FE->getLHS());
5825 mangleExpression(FE->getRHS());
5829 case Expr::CXXThisExprClass:
5834 case Expr::CoawaitExprClass:
5837 Out <<
"v18co_await";
5838 mangleExpression(cast<CoawaitExpr>(
E)->getOperand());
5841 case Expr::DependentCoawaitExprClass:
5844 Out <<
"v18co_await";
5845 mangleExpression(cast<DependentCoawaitExpr>(
E)->getOperand());
5848 case Expr::CoyieldExprClass:
5851 Out <<
"v18co_yield";
5852 mangleExpression(cast<CoawaitExpr>(
E)->getOperand());
5854 case Expr::SYCLUniqueStableNameExprClass: {
5855 const auto *USN = cast<SYCLUniqueStableNameExpr>(
E);
5858 Out <<
"u33__builtin_sycl_unique_stable_name";
5859 mangleType(USN->getTypeSourceInfo()->getType());
5864 case Expr::HLSLOutArgExprClass:
5866 "cannot mangle hlsl temporary value; mangling wrong thing?");
5867 case Expr::OpenACCAsteriskSizeExprClass: {
5872 "cannot yet mangle OpenACC Asterisk Size expression");
5878 if (AsTemplateArg && !IsPrimaryExpr)
5910void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
5917 assert(parmDepth < FunctionTypeDepth.getDepth());
5918 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
5919 if (FunctionTypeDepth.isInResultType())
5922 if (nestingDepth == 0) {
5925 Out <<
"fL" << (nestingDepth - 1) <<
'p';
5933 &&
"parameter's type is still an array type?");
5936 dyn_cast<DependentAddressSpaceType>(parm->
getType())) {
5943 if (parmIndex != 0) {
5944 Out << (parmIndex - 1);
5972 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
5975 mangleName(InheritedFrom);
6029 if (
auto *FTD = dyn_cast_or_null<FunctionTemplateDecl>(
ResolvedTemplate)) {
6030 auto *RD = dyn_cast<CXXRecordDecl>(FTD->getDeclContext());
6031 if (!RD || !RD->isGenericLambda())
6047 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param))
6048 return TTP->hasTypeConstraint();
6065 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param))
6066 return NTTP->getType()->isInstantiationDependentType() ||
6067 NTTP->getType()->getContainedDeducedType();
6071 auto *TTP = cast<TemplateTemplateParmDecl>(Param);
6074 "A DeducedTemplateName shouldn't escape partial ordering");
6085 auto MangleTemplateParamListToString =
6087 unsigned DepthOffset) {
6088 llvm::raw_svector_ostream Stream(Buffer);
6089 CXXNameMangler(
Mangler.Context, Stream,
6090 WithTemplateDepthOffset{DepthOffset})
6091 .mangleTemplateParameterList(Params);
6094 MangleTemplateParamListToString(ParamTemplateHead,
6095 TTP->getTemplateParameters(), 0);
6099 MangleTemplateParamListToString(ArgTemplateHead,
6101 TTP->getTemplateParameters()->
getDepth());
6102 return ParamTemplateHead != ArgTemplateHead;
6112 return {
true,
nullptr};
6117 assert(ParamIdx < ResolvedTemplate->getTemplateParameters()->size() &&
6118 "no parameter for argument");
6139 return {
true,
nullptr};
6154 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param);
6155 bool NeedExactType = NTTP && NTTP->getType()->getContainedDeducedType();
6156 return {NeedExactType,
nullptr};
6168void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6170 unsigned NumTemplateArgs) {
6173 TemplateArgManglingInfo Info(*
this, TN);
6174 for (
unsigned i = 0; i != NumTemplateArgs; ++i) {
6175 mangleTemplateArg(Info, i, TemplateArgs[i].
getArgument());
6177 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6181void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6185 TemplateArgManglingInfo Info(*
this, TN);
6186 for (
unsigned i = 0, e = AL.
size(); i != e; ++i) {
6187 mangleTemplateArg(Info, i, AL[i]);
6189 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6193void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6197 TemplateArgManglingInfo Info(*
this, TN);
6198 for (
unsigned i = 0; i != Args.size(); ++i) {
6199 mangleTemplateArg(Info, i, Args[i]);
6201 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6205void CXXNameMangler::mangleTemplateArg(TemplateArgManglingInfo &Info,
6207 TemplateArgManglingInfo::Info ArgInfo = Info.getArgInfo(Index, A);
6210 if (ArgInfo.TemplateParameterToMangle &&
6211 !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
6218 mangleTemplateParamDecl(ArgInfo.TemplateParameterToMangle);
6221 mangleTemplateArg(A, ArgInfo.NeedExactType);
6224void CXXNameMangler::mangleTemplateArg(
TemplateArgument A,
bool NeedExactType) {
6234 llvm_unreachable(
"Cannot mangle NULL template argument");
6261 auto *TPO = cast<TemplateParamObjectDecl>(
D);
6262 mangleValueInTemplateArg(TPO->getType().getUnqualifiedType(),
6263 TPO->getValue(),
true,
6270 if (
D->isCXXInstanceMember())
6273 else if (
D->getType()->isArrayType() &&
6276 !isCompatibleWith(LangOptions::ClangABI::Ver11))
6297 true, NeedExactType);
6303 mangleTemplateArg(
P, NeedExactType);
6309void CXXNameMangler::mangleTemplateArgExpr(
const Expr *
E) {
6310 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6311 mangleExpression(
E, UnknownArity,
true);
6326 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(
E)) {
6328 if (isa<VarDecl>(
D) || isa<FunctionDecl>(
D)) {
6336 mangleExpression(
E);
6349 switch (
V.getKind()) {
6357 assert(RD &&
"unexpected type for record value");
6366 if (!FD->isUnnamedBitField() &&
6376 assert(RD &&
"unexpected type for union value");
6379 if (!FD->isUnnamedBitField())
6390 for (
unsigned I = 0, N =
V.getArrayInitializedElts(); I != N; ++I)
6398 for (
unsigned I = 0, N =
V.getVectorLength(); I != N; ++I)
6408 return V.getFloat().isPosZero();
6411 return !
V.getFixedPoint().getValue();
6414 return V.getComplexFloatReal().isPosZero() &&
6415 V.getComplexFloatImag().isPosZero();
6418 return !
V.getComplexIntReal() && !
V.getComplexIntImag();
6421 return V.isNullPointer();
6424 return !
V.getMemberPointerDecl();
6427 llvm_unreachable(
"Unhandled APValue::ValueKind enum");
6434 T = AT->getElementType();
6436 dyn_cast<FieldDecl>(
E.getAsBaseOrMember().getPointer()))
6440 cast<CXXRecordDecl>(
E.getAsBaseOrMember().getPointer()));
6481 Diags.
Report(UnionLoc, DiagID);
6488 bool NeedExactType) {
6491 T = getASTContext().getUnqualifiedArrayType(
T, Quals);
6494 bool IsPrimaryExpr =
true;
6495 auto NotPrimaryExpr = [&] {
6496 if (TopLevel && IsPrimaryExpr)
6498 IsPrimaryExpr =
false;
6502 switch (
V.getKind()) {
6511 llvm_unreachable(
"unexpected value kind in template argument");
6515 assert(RD &&
"unexpected type for record value");
6521 (Fields.back()->isUnnamedBitField() ||
6523 V.getStructField(Fields.back()->getFieldIndex())))) {
6527 if (Fields.empty()) {
6528 while (!Bases.empty() &&
6530 V.getStructBase(Bases.size() - 1)))
6531 Bases = Bases.drop_back();
6538 for (
unsigned I = 0, N = Bases.size(); I != N; ++I)
6539 mangleValueInTemplateArg(Bases[I].getType(),
V.getStructBase(I),
false);
6540 for (
unsigned I = 0, N = Fields.size(); I != N; ++I) {
6541 if (Fields[I]->isUnnamedBitField())
6543 mangleValueInTemplateArg(Fields[I]->getType(),
6544 V.getStructField(Fields[I]->getFieldIndex()),
6571 mangleSourceName(II);
6572 mangleValueInTemplateArg(FD->
getType(),
V.getUnionValue(),
false);
6586 unsigned N =
V.getArraySize();
6588 N =
V.getArrayInitializedElts();
6593 for (
unsigned I = 0; I != N; ++I) {
6594 const APValue &Elem = I <
V.getArrayInitializedElts()
6595 ?
V.getArrayInitializedElt(I)
6596 :
V.getArrayFiller();
6597 mangleValueInTemplateArg(ElemT, Elem,
false);
6609 unsigned N =
V.getVectorLength();
6612 for (
unsigned I = 0; I != N; ++I)
6613 mangleValueInTemplateArg(VT->
getElementType(),
V.getVectorElt(I),
false);
6619 mangleIntegerLiteral(
T,
V.getInt());
6623 mangleFloatLiteral(
T,
V.getFloat());
6627 mangleFixedPointLiteral();
6635 if (!
V.getComplexFloatReal().isPosZero() ||
6636 !
V.getComplexFloatImag().isPosZero())
6638 if (!
V.getComplexFloatImag().isPosZero())
6649 if (
V.getComplexIntReal().getBoolValue() ||
6650 V.getComplexIntImag().getBoolValue())
6652 if (
V.getComplexIntImag().getBoolValue())
6661 "unexpected type for LValue template arg");
6663 if (
V.isNullPointer()) {
6664 mangleNullPointer(
T);
6673 if (Offset.isZero()) {
6685 Out << Offset.getQuantity() <<
'E';
6693 if (!
V.hasLValuePath()) {
6709 bool IsArrayToPointerDecayMangledAsDecl =
false;
6710 if (TopLevel && Ctx.
getLangOpts().getClangABICompat() <=
6711 LangOptions::ClangABI::Ver11) {
6713 IsArrayToPointerDecayMangledAsDecl =
6714 BType->
isArrayType() &&
V.getLValuePath().size() == 1 &&
6715 V.getLValuePath()[0].getAsArrayIndex() == 0 &&
6719 if ((!
V.getLValuePath().empty() ||
V.isLValueOnePastTheEnd()) &&
6720 !IsArrayToPointerDecayMangledAsDecl) {
6737 if (NeedExactType &&
6739 !isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6759 mangleExpression(
E);
6763 mangleType(
QualType(TI.getType(), 0));
6766 llvm_unreachable(
"unexpected lvalue base kind in template argument");
6776 mangleNumber(
V.getLValueOffset().getQuantity());
6783 if (!
V.getLValueOffset().isZero())
6784 mangleNumber(
V.getLValueOffset().getQuantity());
6788 bool OnePastTheEnd =
V.isLValueOnePastTheEnd();
6792 if (
auto *CAT = dyn_cast<ConstantArrayType>(AT))
6793 OnePastTheEnd |= CAT->getSize() ==
E.getAsArrayIndex();
6794 TypeSoFar = AT->getElementType();
6796 const Decl *
D =
E.getAsBaseOrMember().getPointer();
6797 if (
auto *FD = dyn_cast<FieldDecl>(
D)) {
6822 if (!
V.getMemberPointerDecl()) {
6823 mangleNullPointer(
T);
6830 if (!
V.getMemberPointerPath().empty()) {
6833 }
else if (NeedExactType &&
6836 V.getMemberPointerDecl()->getType()) &&
6837 !isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6842 mangle(
V.getMemberPointerDecl());
6844 if (!
V.getMemberPointerPath().empty()) {
6847 if (!Offset.isZero())
6848 mangleNumber(Offset.getQuantity());
6854 if (TopLevel && !IsPrimaryExpr)
6858void CXXNameMangler::mangleTemplateParameter(
unsigned Depth,
unsigned Index) {
6868 Depth += TemplateDepthOffset;
6870 Out <<
'L' << (Depth - 1) <<
'_';
6876void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
6879 }
else if (SeqID == 1) {
6889 for (; SeqID != 0; SeqID /= 36) {
6890 unsigned C = SeqID % 36;
6891 *I++ = (
C < 10 ?
'0' +
C :
'A' +
C - 10);
6894 Out.write(I.base(), I - BufferRef.rbegin());
6899void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
6900 bool result = mangleSubstitution(tname);
6901 assert(result &&
"no existing substitution for template name");
6907bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
6909 if (mangleStandardSubstitution(ND))
6913 return mangleSubstitution(
reinterpret_cast<uintptr_t>(ND));
6918 "mangleSubstitution(NestedNameSpecifier *) is only used for "
6919 "identifier nested name specifiers.");
6921 return mangleSubstitution(
reinterpret_cast<uintptr_t>(NNS));
6931bool CXXNameMangler::mangleSubstitution(
QualType T) {
6934 return mangleSubstitution(RT->getDecl());
6939 return mangleSubstitution(TypePtr);
6942bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
6944 return mangleSubstitution(TD);
6947 return mangleSubstitution(
6951bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
6952 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
6953 if (I == Substitutions.end())
6956 unsigned SeqID = I->second;
6965bool CXXNameMangler::isSpecializedAs(
QualType S, llvm::StringRef Name,
6975 dyn_cast<ClassTemplateSpecializationDecl>(RT->
getDecl());
6979 if (!isStdNamespace(Context.getEffectiveDeclContext(SD)))
6983 if (TemplateArgs.
size() != 1)
6986 if (TemplateArgs[0].getAsType() != A)
6998bool CXXNameMangler::isStdCharSpecialization(
7000 bool HasAllocator) {
7005 if (TemplateArgs.
size() != (HasAllocator ? 3 : 2))
7008 QualType A = TemplateArgs[0].getAsType();
7016 if (!isSpecializedAs(TemplateArgs[1].getAsType(),
"char_traits", A))
7020 !isSpecializedAs(TemplateArgs[2].getAsType(),
"allocator", A))
7029bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
7031 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
7040 if (!isStdNamespace(Context.getEffectiveDeclContext(TD)))
7061 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
7062 if (!isStdNamespace(Context.getEffectiveDeclContext(SD)))
7071 if (isStdCharSpecialization(SD,
"basic_string",
true)) {
7078 if (isStdCharSpecialization(SD,
"basic_istream",
false)) {
7085 if (isStdCharSpecialization(SD,
"basic_ostream",
false)) {
7092 if (isStdCharSpecialization(SD,
"basic_iostream",
false)) {
7102void CXXNameMangler::addSubstitution(
QualType T) {
7105 addSubstitution(RT->
getDecl());
7111 addSubstitution(TypePtr);
7114void CXXNameMangler::addSubstitution(
TemplateName Template) {
7116 return addSubstitution(TD);
7122void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
7123 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
7124 Substitutions[Ptr] = SeqID++;
7127void CXXNameMangler::extendSubstitutions(CXXNameMangler*
Other) {
7128 assert(
Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
7129 if (
Other->SeqID > SeqID) {
7130 Substitutions.swap(
Other->Substitutions);
7131 SeqID =
Other->SeqID;
7136CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
7138 if (DisableDerivedAbiTags)
7139 return AbiTagList();
7141 llvm::raw_null_ostream NullOutStream;
7142 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
7143 TrackReturnTypeTags.disableDerivedAbiTags();
7147 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
7148 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
7150 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
7151 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
7153 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
7157CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
7159 if (DisableDerivedAbiTags)
7160 return AbiTagList();
7162 llvm::raw_null_ostream NullOutStream;
7163 CXXNameMangler TrackVariableType(*
this, NullOutStream);
7164 TrackVariableType.disableDerivedAbiTags();
7166 TrackVariableType.mangleType(VD->
getType());
7168 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
7171bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &
C,
7173 llvm::raw_null_ostream NullOutStream;
7174 CXXNameMangler TrackAbiTags(
C, NullOutStream,
nullptr,
true);
7175 TrackAbiTags.mangle(VD);
7176 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
7189void ItaniumMangleContextImpl::mangleCXXName(
GlobalDecl GD,
7192 assert((isa<FunctionDecl, VarDecl, TemplateParamObjectDecl>(
D)) &&
7193 "Invalid mangleName() call, argument is not a variable or function!");
7196 getASTContext().getSourceManager(),
7197 "Mangling declaration");
7199 if (
auto *CD = dyn_cast<CXXConstructorDecl>(
D)) {
7201 CXXNameMangler Mangler(*
this, Out, CD,
Type);
7205 if (
auto *DD = dyn_cast<CXXDestructorDecl>(
D)) {
7207 CXXNameMangler Mangler(*
this, Out, DD,
Type);
7211 CXXNameMangler Mangler(*
this, Out,
D);
7249 unsigned TypedDiscriminator =
7251 Mangler.mangleVendorQualifier(
"__vtptrauth");
7252 auto &ManglerStream = Mangler.getStream();
7253 ManglerStream <<
"I";
7254 if (
const auto *ExplicitAuth =
7255 PtrauthClassRD->
getAttr<VTablePointerAuthenticationAttr>()) {
7256 ManglerStream <<
"Lj" << ExplicitAuth->getKey();
7258 if (ExplicitAuth->getAddressDiscrimination() ==
7259 VTablePointerAuthenticationAttr::DefaultAddressDiscrimination)
7260 ManglerStream <<
"Lb" << LangOpts.PointerAuthVTPtrAddressDiscrimination;
7262 ManglerStream <<
"Lb"
7263 << (ExplicitAuth->getAddressDiscrimination() ==
7264 VTablePointerAuthenticationAttr::AddressDiscrimination);
7266 switch (ExplicitAuth->getExtraDiscrimination()) {
7267 case VTablePointerAuthenticationAttr::DefaultExtraDiscrimination: {
7268 if (LangOpts.PointerAuthVTPtrTypeDiscrimination)
7269 ManglerStream <<
"Lj" << TypedDiscriminator;
7271 ManglerStream <<
"Lj" << 0;
7274 case VTablePointerAuthenticationAttr::TypeDiscrimination:
7275 ManglerStream <<
"Lj" << TypedDiscriminator;
7277 case VTablePointerAuthenticationAttr::CustomDiscrimination:
7278 ManglerStream <<
"Lj" << ExplicitAuth->getCustomDiscriminationValue();
7280 case VTablePointerAuthenticationAttr::NoExtraDiscrimination:
7281 ManglerStream <<
"Lj" << 0;
7285 ManglerStream <<
"Lj"
7286 << (
unsigned)VTablePointerAuthenticationAttr::DefaultKey;
7287 ManglerStream <<
"Lb" << LangOpts.PointerAuthVTPtrAddressDiscrimination;
7288 if (LangOpts.PointerAuthVTPtrTypeDiscrimination)
7289 ManglerStream <<
"Lj" << TypedDiscriminator;
7291 ManglerStream <<
"Lj" << 0;
7293 ManglerStream <<
"E";
7296void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
7298 bool ElideOverrideInfo,
7307 assert(!isa<CXXDestructorDecl>(MD) &&
7308 "Use mangleCXXDtor for destructor decls!");
7309 CXXNameMangler Mangler(*
this, Out);
7310 Mangler.getStream() <<
"_ZT";
7312 Mangler.getStream() <<
'c';
7323 Mangler.mangleFunctionEncoding(MD);
7324 if (!ElideOverrideInfo)
7331 bool ElideOverrideInfo,
7335 CXXNameMangler Mangler(*
this, Out, DD,
Type);
7336 Mangler.getStream() <<
"_ZT";
7344 if (!ElideOverrideInfo)
7349void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *
D,
7353 CXXNameMangler Mangler(*
this, Out);
7356 Mangler.getStream() <<
"_ZGV";
7357 Mangler.mangleName(
D);
7360void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
7365 Out <<
"__cxx_global_var_init";
7368void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *
D,
7371 CXXNameMangler Mangler(*
this, Out);
7372 Mangler.getStream() <<
"__dtor_";
7373 if (shouldMangleDeclName(
D))
7376 Mangler.getStream() <<
D->getName();
7379void ItaniumMangleContextImpl::mangleDynamicStermFinalizer(
const VarDecl *
D,
7383 CXXNameMangler Mangler(*
this, Out);
7384 Mangler.getStream() <<
"__finalize_";
7385 if (shouldMangleDeclName(
D))
7388 Mangler.getStream() <<
D->getName();
7391void ItaniumMangleContextImpl::mangleSEHFilterExpression(
7392 GlobalDecl EnclosingDecl, raw_ostream &Out) {
7393 CXXNameMangler Mangler(*
this, Out);
7394 Mangler.getStream() <<
"__filt_";
7395 auto *EnclosingFD = cast<FunctionDecl>(EnclosingDecl.
getDecl());
7396 if (shouldMangleDeclName(EnclosingFD))
7397 Mangler.mangle(EnclosingDecl);
7399 Mangler.getStream() << EnclosingFD->getName();
7402void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
7403 GlobalDecl EnclosingDecl, raw_ostream &Out) {
7404 CXXNameMangler Mangler(*
this, Out);
7405 Mangler.getStream() <<
"__fin_";
7406 auto *EnclosingFD = cast<FunctionDecl>(EnclosingDecl.
getDecl());
7407 if (shouldMangleDeclName(EnclosingFD))
7408 Mangler.mangle(EnclosingDecl);
7410 Mangler.getStream() << EnclosingFD->getName();
7413void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *
D,
7416 CXXNameMangler Mangler(*
this, Out);
7417 Mangler.getStream() <<
"_ZTH";
7418 Mangler.mangleName(
D);
7422ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *
D,
7425 CXXNameMangler Mangler(*
this, Out);
7426 Mangler.getStream() <<
"_ZTW";
7427 Mangler.mangleName(
D);
7430void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *
D,
7431 unsigned ManglingNumber,
7435 CXXNameMangler Mangler(*
this, Out);
7436 Mangler.getStream() <<
"_ZGR";
7437 Mangler.mangleName(
D);
7438 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
7439 Mangler.mangleSeqID(ManglingNumber - 1);
7442void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
7445 CXXNameMangler Mangler(*
this, Out);
7446 Mangler.getStream() <<
"_ZTV";
7447 Mangler.mangleCXXRecordDecl(RD);
7450void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
7453 CXXNameMangler Mangler(*
this, Out);
7454 Mangler.getStream() <<
"_ZTT";
7455 Mangler.mangleCXXRecordDecl(RD);
7458void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
7463 CXXNameMangler Mangler(*
this, Out);
7464 Mangler.getStream() <<
"_ZTC";
7465 Mangler.mangleCXXRecordDecl(RD);
7466 Mangler.getStream() << Offset;
7467 Mangler.getStream() <<
'_';
7468 Mangler.mangleCXXRecordDecl(
Type);
7471void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
7473 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
7474 CXXNameMangler Mangler(*
this, Out);
7475 Mangler.getStream() <<
"_ZTI";
7476 Mangler.mangleType(Ty);
7479void ItaniumMangleContextImpl::mangleCXXRTTIName(
7480 QualType Ty, raw_ostream &Out,
bool NormalizeIntegers =
false) {
7482 CXXNameMangler Mangler(*
this, Out, NormalizeIntegers);
7483 Mangler.getStream() <<
"_ZTS";
7484 Mangler.mangleType(Ty);
7487void ItaniumMangleContextImpl::mangleCanonicalTypeName(
7488 QualType Ty, raw_ostream &Out,
bool NormalizeIntegers =
false) {
7489 mangleCXXRTTIName(Ty, Out, NormalizeIntegers);
7492void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
7493 llvm_unreachable(
"Can't mangle string literals");
7496void ItaniumMangleContextImpl::mangleLambdaSig(
const CXXRecordDecl *Lambda,
7498 CXXNameMangler Mangler(*
this, Out);
7499 Mangler.mangleLambdaSig(Lambda);
7502void ItaniumMangleContextImpl::mangleModuleInitializer(
const Module *M,
7505 CXXNameMangler Mangler(*
this, Out);
7506 Mangler.getStream() <<
"_ZGI";
7510 auto Partition = M->
Name.find(
':');
7511 Mangler.mangleModuleNamePrefix(
7512 StringRef(&M->
Name[Partition + 1], M->
Name.size() - Partition - 1),
7520 return new ItaniumMangleContextImpl(
7523 return std::nullopt;
7532 return new ItaniumMangleContextImpl(Context, Diags, DiscriminatorOverride,
Enums/classes describing ABI related information about constructors, destructors and thunks.
Defines the clang::ASTContext interface.
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
@ LLVM_MARK_AS_BITMASK_ENUM
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 clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty, ASTContext &Ctx)
static IdentifierInfo * getUnionInitName(SourceLocation UnionLoc, DiagnosticsEngine &Diags, const FieldDecl *FD)
static bool hasMangledSubstitutionQualifiers(QualType T)
Determine whether the given type has any qualifiers that are relevant for substitutions.
static GlobalDecl getParentOfLocalEntity(const DeclContext *DC)
@ ArmAgnosticSMEZAStateBit
@ ArmStreamingCompatibleBit
static AAPCSBitmaskSME encodeAAPCSZAState(unsigned SMEAttrs)
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
static void mangleOverrideDiscrimination(CXXNameMangler &Mangler, ASTContext &Context, const ThunkInfo &Thunk)
Mangles the pointer authentication override attribute for classes that have explicit overrides for th...
static bool isZeroInitialized(QualType T, const APValue &V)
Determine whether a given value is equivalent to zero-initialization for the purpose of discarding a ...
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static bool isParenthesizedADLCallee(const CallExpr *call)
Look at the callee of the given call expression and determine if it's a parenthesized id-expression w...
static TemplateName asTemplateName(GlobalDecl GD)
static QualType getLValueType(ASTContext &Ctx, const APValue &LV)
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::Module class, which describes a module in the source code.
static StringRef getIdentifier(const Token &Tok)
Enums/classes describing THUNK related information about constructors, destructors and thunks.
Defines the clang::TypeLoc interface and its subclasses.
static const TemplateArgument & getArgument(const TemplateArgument &A)
A non-discriminated union of a base, field, or array index.
static LValuePathEntry ArrayIndex(uint64_t Index)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
ArrayRef< LValuePathEntry > getLValuePath() const
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
CharUnits getMemberPointerPathAdjustment(const APValue &MP) const
Find the 'this' offset for the member path in a pointer-to-member APValue.
QualType getRecordType(const RecordDecl *Decl) const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
const LangOptions & getLangOpts() const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given 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...
bool addressSpaceMapManglingFor(LangAS AS) const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass)
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
unsigned getTargetAddressSpace(LangAS AS) const
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers in instanc...
Represents a constant array type that does not decay to a pointer when used as a function parameter.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Attr - This represents one attribute.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
A binding in a decomposition declaration.
A fixed int type of a specified bitwidth.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a call to a C++ constructor.
Represents a C++ constructor within a class.
Represents a delete expression for memory deallocation and destructor calls, e.g.
bool isGlobalDelete() const
Represents a C++ member access expression where the actual member referenced could not be resolved be...
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
QualType getAllocatedType() const
arg_iterator placement_arg_end()
CXXNewInitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
bool hasInitializer() const
Whether this new-expression has any initializer at all.
arg_iterator placement_arg_begin()
Expr * getInitializer()
The initializer of this new-expression.
A call to an overloaded operator written using operator syntax.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Represents a C++ struct/union/class.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
TemplateParameterList * getGenericLambdaTemplateParameterList() const
Retrieve the generic lambda's template parameter list.
base_class_iterator bases_end()
bool isLambda() const
Determine whether this class describes a lambda function object.
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
base_class_iterator bases_begin()
TypeSourceInfo * getLambdaTypeInfo() const
ArrayRef< NamedDecl * > getLambdaExplicitTemplateParameters() const
Retrieve the lambda template parameters that were specified explicitly.
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator,...
A C++ throw-expression (C++ [except.throw]).
const Expr * getSubExpr() const
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
bool isTypeOperand() const
QualType getTypeOperand(const ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Expr * getExprOperand() const
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
bool isListInitialization() const
Determine whether this expression models list-initialization.
Expr * getArg(unsigned I)
unsigned getNumArgs() const
Retrieve the number of arguments.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Expr * getExprOperand() const
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
bool isTypeOperand() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
CharUnits - This is an opaque type for sizes expressed in character units.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
Declaration of a C++20 concept.
ConditionalOperator - The ?: ternary operator.
Expr * getCond() const
getCond - Return the expression representing the condition for the ?: operator.
Represents the canonical version of C arrays with a specified constant size.
Represents a concrete matrix type with constant number of rows and columns.
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 isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool isFunctionOrMethod() const
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
bool isParameterPack() const
Whether this declaration is a parameter pack.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SourceLocation getLocation() const
void setImplicit(bool I=true)
DeclContext * getDeclContext()
bool isInAnonymousNamespace() const
Module * getOwningModuleForLinkage() const
Get the module that owns this declaration for linkage purposes.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
@ CXXConversionFunctionName
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Represents the type decltype(expr) (C++11).
Represents a C++17 deduced template specialization type.
Represents an extended address space qualifier where the input address space value is dependent.
Expr * getAddrSpaceExpr() const
QualType getPointeeType() const
Represents a qualified type name for which the type name is dependent.
A qualified reference to a name whose declaration cannot yet be resolved.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
unsigned getNumTemplateArgs() const
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
TemplateArgumentLoc const * getTemplateArgs() const
Represents an array type in C++ whose size is a value-dependent expression.
Represents an extended vector type where either the type or size is dependent.
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Represents a dependent template name that cannot be resolved prior to template instantiation.
Represents a template specialization type whose template cannot be resolved, e.g.
const IdentifierInfo * getIdentifier() const
ArrayRef< TemplateArgument > template_arguments() const
NestedNameSpecifier * getQualifier() const
Represents a vector type where either the type or size is dependent.
Designator - A designator in a C99 designated initializer.
bool isArrayDesignator() const
bool isArrayRangeDesignator() const
bool isFieldDesignator() const
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.
An instance of this object exists for each enum constant that is defined.
llvm::APSInt getInitVal() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
ExplicitCastExpr - An explicit cast written in the source code.
This represents one expression.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
ExtVectorType - Extended vector type.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
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.
llvm::APFloat getValue() const
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isMemberLikeConstrainedFriend() const
Determine whether a function is a friend function that cannot be redeclared outside of its class,...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
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
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
unsigned getAArch64SMEAttributes() const
Return a bitmask describing the SME attributes on the function type, see AArch64SMETypeAttributes for...
bool isVariadic() const
Whether this function prototype is variadic.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
bool isNothrow(bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
ArrayRef< QualType > exceptions() const
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
CallingConv getCC() const
bool getProducesResult() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
bool isConsumed() const
Is this parameter considered "consumed" by Objective-C ARC? Consumed parameters must have retainable ...
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
QualType getReturnType() const
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
GlobalDecl - represents a global declaration.
CXXCtorType getCtorType() const
KernelReferenceKind getKernelReferenceKind() const
GlobalDecl getWithDecl(const Decl *D)
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.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
const Expr * getSubExpr() const
Represents a C array with an unspecified size.
Represents a field injected from an anonymous union/struct into the parent scope.
Describes an C or C++ initializer list.
unsigned getNumInits() const
InitListExpr * getSyntacticForm() const
const Expr * getInit(unsigned Init) const
The injected class name of a C++ class template or class template partial specialization.
virtual DiscriminatorOverrideTy getDiscriminatorOverride() const =0
virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXVTT(const CXXRecordDecl *RD, raw_ostream &)=0
virtual void mangleItaniumThreadLocalInit(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXCtorComdat(const CXXConstructorDecl *D, raw_ostream &)=0
virtual void mangleLambdaSig(const CXXRecordDecl *Lambda, raw_ostream &)=0
virtual void mangleCXXDtorComdat(const CXXDestructorDecl *D, raw_ostream &)=0
virtual void mangleItaniumThreadLocalWrapper(const VarDecl *D, raw_ostream &)=0
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
virtual void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset, const CXXRecordDecl *Type, raw_ostream &)=0
virtual void mangleModuleInitializer(const Module *Module, raw_ostream &)=0
std::optional< unsigned >(*)(ASTContext &, const NamedDecl *) DiscriminatorOverrideTy
An lvalue reference type, per C++11 [dcl.ref].
ClangABI
Clang versions with different platform ABI conformance.
virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThunkInfo &Thunk, bool ElideOverrideInfo, raw_ostream &)=0
virtual void mangleCXXRTTI(QualType T, raw_ostream &)=0
virtual std::string getLambdaString(const CXXRecordDecl *Lambda)=0
virtual bool shouldMangleStringLiteral(const StringLiteral *SL)=0
ASTContext & getASTContext() const
uint64_t getAnonymousStructIdForDebugInfo(const NamedDecl *D)
virtual void mangleDynamicAtExitDestructor(const VarDecl *D, raw_ostream &)=0
virtual bool isUniqueInternalLinkageDecl(const NamedDecl *ND)
virtual void mangleSEHFilterExpression(GlobalDecl EnclosingDecl, raw_ostream &Out)=0
virtual void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, bool ElideOverrideInfo, raw_ostream &)=0
virtual void mangleCanonicalTypeName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
Generates a unique string for an externally visible type for use with TBAA or type uniquing.
virtual void mangleStringLiteral(const StringLiteral *SL, raw_ostream &)=0
virtual void mangleCXXName(GlobalDecl GD, raw_ostream &)=0
virtual void needsUniqueInternalLinkageNames()
virtual void mangleReferenceTemporary(const VarDecl *D, unsigned ManglingNumber, raw_ostream &)=0
virtual bool shouldMangleCXXName(const NamedDecl *D)=0
virtual void mangleCXXRTTIName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
virtual void mangleDynamicInitializer(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXVTable(const CXXRecordDecl *RD, raw_ostream &)=0
virtual void mangleSEHFinallyBlock(GlobalDecl EnclosingDecl, raw_ostream &Out)=0
virtual void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &)=0
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() const
Describes a module or submodule.
std::string Name
The name of this module.
StringRef getPrimaryModuleInterfaceName() const
Get the primary module interface name from a partition.
bool isModulePartition() const
Is this a module partition.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
bool hasLinkage() const
Determine whether this declaration has linkage.
bool isExternallyVisible() const
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Represent a C++ namespace.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
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.
Interfaces are the core concept in Objective-C for object oriented design.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
Represents a class type in Objective C.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
decls_iterator decls_begin() const
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
TemplateArgumentLoc const * getTemplateArgs() const
unsigned getNumTemplateArgs() const
DeclarationName getName() const
Gets the name looked up.
Represents a pack expansion of types.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
unsigned getFunctionScopeDepth() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
A (possibly-)qualified type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
@ 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 hasUnaligned() const
bool hasAddressSpace() const
ObjCLifetime getObjCLifetime() const
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.
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
field_range fields() const
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Encodes a location in the source.
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
const char * getStmtClassName() const
StringLiteral - This represents a string literal expression, e.g.
A structure for storing the information associated with a substituted template template parameter.
TemplateName getReplacement() const
Represents the result of substituting a set of types for a template type parameter pack.
Represents the declaration of a struct/union/class/enum.
TypedefNameDecl * getTypedefNameForAnonDecl() const
Exposes information about the current target.
virtual const char * getFloat128Mangling() const
Return the mangled code of __float128.
virtual const char * getIbm128Mangling() const
Return the mangled code of __ibm128.
virtual const char * getLongDoubleMangling() const
Return the mangled code of long double.
virtual const char * getBFloat16Mangling() const
Return the mangled code of bfloat.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Location wrapper for a TemplateArgument.
Represents a template argument.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
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.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getIntegralType() const
Retrieve the type of the integral value.
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.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
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.).
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
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.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
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.
std::pair< TemplateDecl *, DefaultArguments > getTemplateDeclAndDefaultArgs() const
Retrieves the underlying template declaration that this template name refers to, along with the deduc...
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
A template parameter object.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Represents a type template specialization; the template must be a class template, a type alias templa...
ArrayRef< TemplateArgument > template_arguments() const
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
ConceptDecl * getNamedConcept() const
Symbolic representation of typeid(T) for some type T.
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
A container of type source information.
QualType getType() const
Return the type wrapped by this type source info.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
TypeTrait getTrait() const
Determine which type trait this expression uses.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBooleanType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isDependentAddressSpaceType() const
bool isVoidPointerType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isOpenCLSpecificType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isPointerOrReferenceType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
Base class for declarations which introduce a typedef-name.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
QualType getArgumentType() const
bool isArgumentType() const
UnaryExprOrTypeTrait getKind() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
Represents the dependent type named by a dependently-scoped typename using declaration,...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void print(llvm::raw_ostream &Out) const
Represents a variable declaration or definition.
Represents a variable template specialization, which refers to a variable template with a given set o...
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
QualType getElementType() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
RequirementKind getKind() const
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool Sub(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
CXXCtorType
C++ constructor types.
@ Ctor_Base
Base object ctor.
@ Ctor_DefaultClosure
Default closure variant of a ctor.
@ Ctor_CopyingClosure
Copying closure variant of a ctor.
@ Ctor_Complete
Complete object ctor.
@ Ctor_Comdat
The COMDAT used for ctors.
llvm::StringRef getParameterABISpelling(ParameterABI kind)
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
CXXDtorType
C++ destructor types.
@ Dtor_Comdat
The COMDAT used for dtors.
@ Dtor_Base
Base object dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
LangAS
Defines the address space values used by the address space qualifier of QualType.
const char * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ Other
Other implicit parameter.
@ EST_Dynamic
throw(T1, T2)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Information about how to mangle a template argument.
bool NeedExactType
Do we need to mangle the template argument with an exactly correct type?
const NamedDecl * TemplateParameterToMangle
If we need to prefix the mangling with a mangling of the template parameter, the corresponding parame...
bool isOverloadable()
Determine whether the resolved template might be overloaded on its template parameter list.
TemplateArgManglingInfo(const CXXNameMangler &Mangler, TemplateName TN)
bool needToMangleTemplateParam(const NamedDecl *Param, const TemplateArgument &Arg)
Determine whether we need to prefix this <template-arg> mangling with a <template-param-decl>.
const NamedDecl * UnresolvedExpandedPack
const CXXNameMangler & Mangler
TemplateDecl * ResolvedTemplate
Info getArgInfo(unsigned ParamIdx, const TemplateArgument &Arg)
Determine information about how this template argument should be mangled.
const Expr * getTrailingRequiresClauseToMangle()
Determine if we should mangle a requires-clause after the template argument list.
bool SeenPackExpansionIntoNonPack
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
llvm::dxil::ResourceClass ResourceClass
union clang::ReturnAdjustment::VirtualAdjustment Virtual
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
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.
Iterator for iterating over Stmt * arrays that contain only T *.
A this pointer adjustment.
union clang::ThisAdjustment::VirtualAdjustment Virtual
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
The this pointer adjustment as well as an optional return adjustment for a thunk.
ThisAdjustment This
The this pointer adjustment.
ReturnAdjustment Return
The return adjustment.
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
struct clang::ReturnAdjustment::VirtualAdjustment::@189 Itanium
struct clang::ThisAdjustment::VirtualAdjustment::@191 Itanium
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset.