36#include "llvm/ADT/StringExtras.h"
37#include "llvm/Support/ErrorHandling.h"
38#include "llvm/Support/raw_ostream.h"
39#include "llvm/TargetParser/RISCVTargetParser.h"
46static bool isLocalContainerContext(
const DeclContext *DC) {
47 return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
52 return ftd->getTemplatedDecl();
59 return (fn ? getStructor(fn) :
decl);
62static bool isLambda(
const NamedDecl *ND) {
70static const unsigned UnknownArity = ~0
U;
73 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
74 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
75 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
76 const DiscriminatorOverrideTy DiscriminatorOverride =
nullptr;
79 bool NeedsUniqueInternalLinkageNames =
false;
82 explicit ItaniumMangleContextImpl(
84 DiscriminatorOverrideTy DiscriminatorOverride,
bool IsAux =
false)
86 DiscriminatorOverride(DiscriminatorOverride) {}
98 NeedsUniqueInternalLinkageNames =
true;
103 raw_ostream &)
override;
106 raw_ostream &)
override;
108 raw_ostream &)
override;
115 bool NormalizeIntegers)
override;
117 bool NormalizeIntegers)
override;
124 raw_ostream &Out)
override;
127 raw_ostream &Out)
override;
129 raw_ostream &Out)
override;
132 raw_ostream &)
override;
140 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
146 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
147 if (Tag->getName().empty() && !Tag->getTypedefNameForAnonDecl())
154 if (discriminator == 1)
156 disc = discriminator - 2;
161 unsigned &discriminator = Uniquifier[ND];
162 if (!discriminator) {
163 const DeclContext *DC = getEffectiveDeclContext(ND);
164 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
166 if (discriminator == 1)
168 disc = discriminator-2;
175 assert(Lambda->
isLambda() &&
"RD must be a lambda!");
176 std::string Name(
"<lambda");
180 const ParmVarDecl *Parm = dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
185 unsigned DefaultArgNo =
187 Name += llvm::utostr(DefaultArgNo);
191 if (LambdaManglingNumber)
192 LambdaId = LambdaManglingNumber;
196 Name += llvm::utostr(LambdaId);
202 return DiscriminatorOverride;
209 return getEffectiveDeclContext(cast<Decl>(DC));
212 bool isInternalLinkageDecl(
const NamedDecl *ND);
218class CXXNameMangler {
219 ItaniumMangleContextImpl &Context;
223 bool NormalizeIntegers =
false;
225 bool NullOut =
false;
230 bool DisableDerivedAbiTags =
false;
236 unsigned StructorType = 0;
241 unsigned TemplateDepthOffset = 0;
246 class FunctionTypeDepthState {
249 enum { InResultTypeMask = 1 };
252 FunctionTypeDepthState() =
default;
255 unsigned getDepth()
const {
260 bool isInResultType()
const {
261 return Bits & InResultTypeMask;
264 FunctionTypeDepthState push() {
265 FunctionTypeDepthState tmp = *
this;
266 Bits = (Bits & ~InResultTypeMask) + 2;
270 void enterResultType() {
271 Bits |= InResultTypeMask;
274 void leaveResultType() {
275 Bits &= ~InResultTypeMask;
278 void pop(FunctionTypeDepthState saved) {
279 assert(getDepth() == saved.getDepth() + 1);
294 class AbiTagState final {
296 explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
302 AbiTagState(
const AbiTagState &) =
delete;
303 AbiTagState &operator=(
const AbiTagState &) =
delete;
305 ~AbiTagState() { pop(); }
307 void write(raw_ostream &Out,
const NamedDecl *ND,
308 const AbiTagList *AdditionalAbiTags) {
310 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
312 !AdditionalAbiTags &&
313 "only function and variables need a list of additional abi tags");
314 if (
const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
315 if (
const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
316 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
317 AbiTag->tags().end());
325 if (
const auto *AbiTag = ND->
getAttr<AbiTagAttr>()) {
326 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
327 AbiTag->tags().end());
328 TagList.insert(TagList.end(), AbiTag->tags().begin(),
329 AbiTag->tags().end());
332 if (AdditionalAbiTags) {
333 UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(),
334 AdditionalAbiTags->end());
335 TagList.insert(TagList.end(), AdditionalAbiTags->begin(),
336 AdditionalAbiTags->end());
340 TagList.erase(std::unique(TagList.begin(), TagList.end()), TagList.end());
342 writeSortedUniqueAbiTags(Out, TagList);
345 const AbiTagList &getUsedAbiTags()
const {
return UsedAbiTags; }
346 void setUsedAbiTags(
const AbiTagList &AbiTags) {
347 UsedAbiTags = AbiTags;
350 const AbiTagList &getEmittedAbiTags()
const {
351 return EmittedAbiTags;
354 const AbiTagList &getSortedUniqueUsedAbiTags() {
355 llvm::sort(UsedAbiTags);
356 UsedAbiTags.erase(std::unique(UsedAbiTags.begin(), UsedAbiTags.end()),
363 AbiTagList UsedAbiTags;
365 AbiTagList EmittedAbiTags;
367 AbiTagState *&LinkHead;
368 AbiTagState *
Parent =
nullptr;
371 assert(LinkHead ==
this &&
372 "abi tag link head must point to us on destruction");
375 UsedAbiTags.begin(), UsedAbiTags.end());
376 Parent->EmittedAbiTags.insert(
Parent->EmittedAbiTags.end(),
377 EmittedAbiTags.begin(),
378 EmittedAbiTags.end());
383 void writeSortedUniqueAbiTags(raw_ostream &Out,
const AbiTagList &AbiTags) {
384 for (
const auto &Tag : AbiTags) {
385 EmittedAbiTags.push_back(Tag);
393 AbiTagState *AbiTags =
nullptr;
394 AbiTagState AbiTagsRoot;
396 llvm::DenseMap<uintptr_t, unsigned> Substitutions;
397 llvm::DenseMap<StringRef, unsigned> ModuleSubstitutions;
399 ASTContext &getASTContext()
const {
return Context.getASTContext(); }
402 return Context.getASTContext().
getLangOpts().getClangABICompat() <= Ver;
411 llvm::StringRef Name,
bool HasAllocator);
414 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
415 const NamedDecl *D =
nullptr,
bool NullOut_ =
false)
416 : Context(
C), Out(Out_), NullOut(NullOut_), Structor(getStructor(D)),
417 AbiTagsRoot(AbiTags) {
419 assert(!D || (!isa<CXXDestructorDecl>(D) &&
420 !isa<CXXConstructorDecl>(D)));
422 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
424 : Context(
C), Out(Out_), Structor(getStructor(D)), StructorType(
Type),
425 AbiTagsRoot(AbiTags) {}
426 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
428 : Context(
C), Out(Out_), Structor(getStructor(D)), StructorType(
Type),
429 AbiTagsRoot(AbiTags) {}
431 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
432 bool NormalizeIntegers_)
433 : Context(
C), Out(Out_), NormalizeIntegers(NormalizeIntegers_),
434 NullOut(
false), Structor(nullptr), AbiTagsRoot(AbiTags) {}
435 CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
436 : Context(Outer.Context), Out(Out_), Structor(Outer.Structor),
437 StructorType(Outer.StructorType), SeqID(Outer.SeqID),
438 FunctionTypeDepth(Outer.FunctionTypeDepth), AbiTagsRoot(AbiTags),
439 Substitutions(Outer.Substitutions),
440 ModuleSubstitutions(Outer.ModuleSubstitutions) {}
442 CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
443 : CXXNameMangler(Outer, (raw_ostream &)Out_) {
447 struct WithTemplateDepthOffset {
unsigned Offset; };
448 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out,
449 WithTemplateDepthOffset Offset)
450 : CXXNameMangler(
C, Out) {
451 TemplateDepthOffset = Offset.Offset;
454 raw_ostream &getStream() {
return Out; }
456 void disableDerivedAbiTags() { DisableDerivedAbiTags =
true; }
457 static bool shouldHaveAbiTags(ItaniumMangleContextImpl &
C,
const VarDecl *VD);
460 void mangleCallOffset(int64_t NonVirtual, int64_t
Virtual);
461 void mangleNumber(
const llvm::APSInt &I);
462 void mangleNumber(int64_t Number);
463 void mangleFloat(
const llvm::APFloat &F);
465 void mangleSeqID(
unsigned SeqID);
468 void mangleNameOrStandardSubstitution(
const NamedDecl *ND);
470 void mangleModuleNamePrefix(StringRef Name,
bool IsPartition =
false);
474 bool mangleSubstitution(
const NamedDecl *ND);
476 bool mangleSubstitution(
QualType T);
482 bool mangleStandardSubstitution(
const NamedDecl *ND);
484 void addSubstitution(
const NamedDecl *ND) {
487 addSubstitution(
reinterpret_cast<uintptr_t>(ND));
492 addSubstitution(
reinterpret_cast<uintptr_t>(NNS));
498 void extendSubstitutions(CXXNameMangler*
Other);
501 bool recursive =
false);
505 unsigned NumTemplateArgs,
506 unsigned KnownArity = UnknownArity);
508 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
511 const AbiTagList *AdditionalAbiTags);
512 void mangleModuleName(
const NamedDecl *ND);
516 const AbiTagList *AdditionalAbiTags) {
517 mangleUnqualifiedName(GD, cast<NamedDecl>(GD.
getDecl())->getDeclName(), DC,
518 UnknownArity, AdditionalAbiTags);
522 const AbiTagList *AdditionalAbiTags);
524 const AbiTagList *AdditionalAbiTags);
526 const AbiTagList *AdditionalAbiTags);
530 void mangleSourceNameWithAbiTags(
531 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
533 const AbiTagList *AdditionalAbiTags);
538 void mangleTypeConstraint(
const ConceptDecl *Concept,
541 void mangleRequiresClause(
const Expr *RequiresClause);
544 const AbiTagList *AdditionalAbiTags,
545 bool NoFunction=
false);
548 void mangleNestedNameWithClosurePrefix(
GlobalDecl GD,
550 const AbiTagList *AdditionalAbiTags);
552 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
554 void mangleTemplatePrefix(
GlobalDecl GD,
bool NoFunction=
false);
557 void mangleClosurePrefix(
const NamedDecl *ND,
bool NoFunction =
false);
558 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
559 StringRef Prefix =
"");
562 void mangleVendorQualifier(StringRef qualifier);
569#define ABSTRACT_TYPE(CLASS, PARENT)
570#define NON_CANONICAL_TYPE(CLASS, PARENT)
571#define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
572#include "clang/AST/TypeNodes.inc"
574 void mangleType(
const TagType*);
576 static StringRef getCallingConvQualifierName(
CallingConv CC);
581 void mangleNeonVectorType(
const VectorType *T);
583 void mangleAArch64NeonVectorType(
const VectorType *T);
585 void mangleAArch64FixedSveVectorType(
const VectorType *T);
587 void mangleRISCVFixedRVVVectorType(
const VectorType *T);
590 void mangleIntegerLiteral(
QualType T,
const llvm::APSInt &
Value);
591 void mangleFloatLiteral(
QualType T,
const llvm::APFloat &
V);
592 void mangleFixedPointLiteral();
595 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
596 void mangleMemberExpr(
const Expr *base,
bool isArrow,
601 unsigned NumTemplateArgs,
602 unsigned knownArity);
603 void mangleCastExpression(
const Expr *E, StringRef CastEncoding);
604 void mangleInitListElements(
const InitListExpr *InitList);
607 void mangleExpression(
const Expr *E,
unsigned Arity = UnknownArity,
608 bool AsTemplateArg =
false);
612 struct TemplateArgManglingInfo;
615 unsigned NumTemplateArgs);
618 void mangleTemplateArg(TemplateArgManglingInfo &Info,
unsigned Index,
621 void mangleTemplateArgExpr(
const Expr *E);
623 bool NeedExactType =
false);
625 void mangleTemplateParameter(
unsigned Depth,
unsigned Index);
630 const AbiTagList *AdditionalAbiTags);
633 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
635 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
643 getASTContext(), getASTContext().getTranslationUnitDecl(),
645 &getASTContext().Idents.get(
"std"),
655ItaniumMangleContextImpl::getEffectiveDeclContext(
const Decl *D) {
665 dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
666 return ContextParam->getDeclContext();
670 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
672 dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
673 return ContextParam->getDeclContext();
681 if (D == getASTContext().getVaListTagDecl()) {
682 const llvm::Triple &T = getASTContext().getTargetInfo().getTriple();
683 if (T.isARM() || T.isThumb() || T.isAArch64())
684 return getStdNamespace();
688 if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC) ||
689 isa<OMPDeclareMapperDecl>(DC)) {
690 return getEffectiveDeclContext(cast<Decl>(DC));
693 if (
const auto *VD = dyn_cast<VarDecl>(D))
695 return getASTContext().getTranslationUnitDecl();
697 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
699 return getASTContext().getTranslationUnitDecl();
702 if (FD->isMemberLikeConstrainedFriend() &&
703 getASTContext().getLangOpts().getClangABICompat() >
704 LangOptions::ClangABI::Ver17)
711bool ItaniumMangleContextImpl::isInternalLinkageDecl(
const NamedDecl *ND) {
714 getEffectiveDeclContext(ND)->isFileContext() &&
721bool ItaniumMangleContextImpl::isUniqueInternalLinkageDecl(
723 if (!NeedsUniqueInternalLinkageNames || !ND)
726 const auto *FD = dyn_cast<FunctionDecl>(ND);
735 if (isInternalLinkageDecl(ND))
741bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
742 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
745 if (FD->hasAttr<OverloadableAttr>())
761 if (FD->isMSVCRTEntryPoint())
775 if (!getASTContext().getLangOpts().
CPlusPlus)
778 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
780 if (isa<DecompositionDecl>(VD))
789 const DeclContext *DC = getEffectiveDeclContext(D);
793 DC = getEffectiveParentContext(DC);
795 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
796 !isa<VarTemplateSpecializationDecl>(VD) &&
797 !VD->getOwningModuleForLinkage())
804void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
805 const AbiTagList *AdditionalAbiTags) {
806 assert(AbiTags &&
"require AbiTagState");
807 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
810void CXXNameMangler::mangleSourceNameWithAbiTags(
811 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
813 writeAbiTags(ND, AdditionalAbiTags);
821 if (isa<FunctionDecl>(GD.
getDecl()))
822 mangleFunctionEncoding(GD);
827 dyn_cast<IndirectFieldDecl>(GD.
getDecl()))
828 mangleName(IFD->getAnonField());
830 llvm_unreachable(
"unexpected kind of global decl");
833void CXXNameMangler::mangleFunctionEncoding(
GlobalDecl GD) {
838 if (!Context.shouldMangleDeclName(FD)) {
843 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
844 if (ReturnTypeAbiTags.empty()) {
853 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
855 FunctionTypeDepth.pop(Saved);
856 mangleFunctionEncodingBareType(FD);
864 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
865 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
867 FunctionEncodingMangler.disableDerivedAbiTags();
869 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
870 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
871 FunctionTypeDepth.pop(Saved);
874 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
875 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
879 const AbiTagList &UsedAbiTags =
880 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
881 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
882 AdditionalAbiTags.erase(
883 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
884 UsedAbiTags.begin(), UsedAbiTags.end(),
885 AdditionalAbiTags.begin()),
886 AdditionalAbiTags.end());
889 Saved = FunctionTypeDepth.push();
890 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
891 FunctionTypeDepth.pop(Saved);
892 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
896 extendSubstitutions(&FunctionEncodingMangler);
899void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
900 if (FD->
hasAttr<EnableIfAttr>()) {
901 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
902 Out <<
"Ua9enable_ifI";
903 for (AttrVec::const_iterator I = FD->
getAttrs().begin(),
906 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
909 if (isCompatibleWith(LangOptions::ClangABI::Ver11)) {
914 mangleExpression(EIA->getCond());
917 mangleTemplateArgExpr(EIA->getCond());
921 FunctionTypeDepth.pop(Saved);
926 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
927 if (
auto Inherited = CD->getInheritedConstructor())
928 FD = Inherited.getConstructor();
946 bool MangleReturnType =
false;
948 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
949 isa<CXXConversionDecl>(FD)))
950 MangleReturnType =
true;
953 FD = PrimaryTemplate->getTemplatedDecl();
957 MangleReturnType, FD);
962 if (!Context.getEffectiveParentContext(NS)->isTranslationUnit())
966 return II && II->
isStr(
"std");
971bool CXXNameMangler::isStdNamespace(
const DeclContext *DC) {
975 return isStd(cast<NamespaceDecl>(DC));
982 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
991 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
992 TemplateArgs = &Spec->getTemplateArgs();
993 return GD.
getWithDecl(Spec->getSpecializedTemplate());
998 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
999 TemplateArgs = &Spec->getTemplateArgs();
1000 return GD.
getWithDecl(Spec->getSpecializedTemplate());
1011void CXXNameMangler::mangleName(
GlobalDecl GD) {
1013 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1015 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
1016 if (VariableTypeAbiTags.empty()) {
1018 mangleNameWithAbiTags(VD,
nullptr);
1023 llvm::raw_null_ostream NullOutStream;
1024 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
1025 VariableNameMangler.disableDerivedAbiTags();
1026 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
1029 const AbiTagList &UsedAbiTags =
1030 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
1031 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
1032 AdditionalAbiTags.erase(
1033 std::set_difference(VariableTypeAbiTags.begin(),
1034 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
1035 UsedAbiTags.end(), AdditionalAbiTags.begin()),
1036 AdditionalAbiTags.end());
1039 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
1041 mangleNameWithAbiTags(GD,
nullptr);
1045const RecordDecl *CXXNameMangler::GetLocalClassDecl(
const Decl *D) {
1046 const DeclContext *DC = Context.getEffectiveDeclContext(D);
1048 if (isLocalContainerContext(DC))
1049 return dyn_cast<RecordDecl>(D);
1051 DC = Context.getEffectiveDeclContext(D);
1056void CXXNameMangler::mangleNameWithAbiTags(
GlobalDecl GD,
1057 const AbiTagList *AdditionalAbiTags) {
1064 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
1070 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
1072 DC = Context.getEffectiveParentContext(DC);
1073 else if (GetLocalClassDecl(ND)) {
1074 mangleLocalName(GD, AdditionalAbiTags);
1078 assert(!isa<LinkageSpecDecl>(DC) &&
"context cannot be LinkageSpecDecl");
1080 if (isLocalContainerContext(DC)) {
1081 mangleLocalName(GD, AdditionalAbiTags);
1087 if (
const NamedDecl *PrefixND = getClosurePrefix(ND)) {
1088 mangleNestedNameWithClosurePrefix(GD, PrefixND, AdditionalAbiTags);
1096 mangleUnscopedTemplateName(TD, DC, AdditionalAbiTags);
1101 mangleUnscopedName(GD, DC, AdditionalAbiTags);
1105 mangleNestedName(GD, DC, AdditionalAbiTags);
1108void CXXNameMangler::mangleModuleName(
const NamedDecl *ND) {
1111 mangleModuleNamePrefix(M->getPrimaryModuleInterfaceName());
1119void CXXNameMangler::mangleModuleNamePrefix(StringRef Name,
bool IsPartition) {
1121 auto It = ModuleSubstitutions.find(Name);
1122 if (It != ModuleSubstitutions.end()) {
1124 mangleSeqID(It->second);
1130 auto Parts = Name.rsplit(
'.');
1131 if (Parts.second.empty())
1132 Parts.second = Parts.first;
1134 mangleModuleNamePrefix(Parts.first, IsPartition);
1135 IsPartition =
false;
1141 Out << Parts.second.size() << Parts.second;
1142 ModuleSubstitutions.insert({Name, SeqID++});
1145void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
1147 const DeclContext *DC = Context.getEffectiveDeclContext(TD);
1150 mangleUnscopedTemplateName(TD, DC,
nullptr);
1153 mangleNestedName(TD, Args);
1158 const AbiTagList *AdditionalAbiTags) {
1162 assert(!isa<LinkageSpecDecl>(DC) &&
"unskipped LinkageSpecDecl");
1163 if (isStdNamespace(DC))
1166 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1169void CXXNameMangler::mangleUnscopedTemplateName(
1174 if (mangleSubstitution(ND))
1178 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1179 assert(!AdditionalAbiTags &&
1180 "template template param cannot have abi tags");
1181 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
1182 }
else if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND)) {
1183 mangleUnscopedName(GD, DC, AdditionalAbiTags);
1189 addSubstitution(ND);
1192void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
1206 llvm::APInt valueBits = f.bitcastToAPInt();
1207 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
1208 assert(numCharacters != 0);
1214 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
1216 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
1219 uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
1220 hexDigit >>= (digitBitIndex % 64);
1224 static const char charForHex[16] = {
1225 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
1226 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'
1228 buffer[stringIndex] = charForHex[hexDigit];
1231 Out.write(buffer.data(), numCharacters);
1234void CXXNameMangler::mangleFloatLiteral(
QualType T,
const llvm::APFloat &
V) {
1241void CXXNameMangler::mangleFixedPointLiteral() {
1248void CXXNameMangler::mangleNullPointer(
QualType T) {
1255void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
1256 if (
Value.isSigned() &&
Value.isNegative()) {
1264void CXXNameMangler::mangleNumber(int64_t Number) {
1274void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t
Virtual) {
1282 mangleNumber(NonVirtual);
1288 mangleNumber(NonVirtual);
1296 if (!mangleSubstitution(
QualType(TST, 0))) {
1297 mangleTemplatePrefix(TST->getTemplateName());
1302 mangleTemplateArgs(TST->getTemplateName(), TST->template_arguments());
1305 }
else if (
const auto *DTST =
1307 if (!mangleSubstitution(
QualType(DTST, 0))) {
1308 TemplateName Template = getASTContext().getDependentTemplateName(
1309 DTST->getQualifier(), DTST->getIdentifier());
1310 mangleTemplatePrefix(Template);
1315 mangleTemplateArgs(Template, DTST->template_arguments());
1316 addSubstitution(
QualType(DTST, 0));
1346 switch (qualifier->
getKind()) {
1358 llvm_unreachable(
"Can't mangle __super specifier");
1362 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1370 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1387 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1394 if (mangleUnresolvedTypeOrSimpleId(
QualType(
type, 0), recursive ?
"N" :
""))
1403 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1421void CXXNameMangler::mangleUnresolvedName(
1424 unsigned knownArity) {
1425 if (qualifier) mangleUnresolvedPrefix(qualifier);
1426 switch (
name.getNameKind()) {
1429 mangleSourceName(
name.getAsIdentifierInfo());
1434 mangleUnresolvedTypeOrSimpleId(
name.getCXXNameType());
1441 mangleOperatorName(name, knownArity);
1444 llvm_unreachable(
"Can't mangle a constructor name!");
1446 llvm_unreachable(
"Can't mangle a using directive name!");
1448 llvm_unreachable(
"Can't mangle a deduction guide name!");
1452 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1458 mangleTemplateArgs(
TemplateName(), TemplateArgs, NumTemplateArgs);
1461void CXXNameMangler::mangleUnqualifiedName(
1463 unsigned KnownArity,
const AbiTagList *AdditionalAbiTags) {
1471 mangleModuleName(ND);
1475 auto *FD = dyn_cast<FunctionDecl>(ND);
1476 auto *FTD = dyn_cast<FunctionTemplateDecl>(ND);
1478 (FTD && FTD->getTemplatedDecl()->isMemberLikeConstrainedFriend())) {
1479 if (!isCompatibleWith(LangOptions::ClangABI::Ver17))
1483 unsigned Arity = KnownArity;
1484 switch (Name.getNameKind()) {
1489 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1496 for (
auto *BD : DD->bindings())
1497 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1499 writeAbiTags(ND, AdditionalAbiTags);
1503 if (
auto *GD = dyn_cast<MSGuidDecl>(ND)) {
1506 SmallString<
sizeof(
"_GUID_12345678_1234_1234_1234_1234567890ab")> GUID;
1507 llvm::raw_svector_ostream GUIDOS(GUID);
1508 Context.mangleMSGuidDecl(GD, GUIDOS);
1509 Out << GUID.size() << GUID;
1513 if (
auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
1516 mangleValueInTemplateArg(TPO->getType().getUnqualifiedType(),
1517 TPO->getValue(),
true);
1535 if (Context.isInternalLinkageDecl(ND))
1538 bool IsRegCall = FD &&
1542 FD && FD->
hasAttr<CUDAGlobalAttr>() &&
1545 mangleDeviceStubName(II);
1547 mangleRegCallName(II);
1549 mangleSourceName(II);
1551 writeAbiTags(ND, AdditionalAbiTags);
1556 assert(ND &&
"mangling empty name without declaration");
1558 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1561 Out <<
"12_GLOBAL__N_1";
1566 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1580 &&
"Expected anonymous struct or union!");
1587 assert(FD->
getIdentifier() &&
"Data member name isn't an identifier!");
1600 if (isa<ObjCContainerDecl>(ND))
1604 const TagDecl *TD = cast<TagDecl>(ND);
1607 "Typedef should not be in another decl context!");
1608 assert(D->getDeclName().getAsIdentifierInfo() &&
1609 "Typedef was not named!");
1610 mangleSourceName(D->getDeclName().getAsIdentifierInfo());
1611 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1614 writeAbiTags(TD,
nullptr);
1624 std::optional<unsigned> DeviceNumber =
1625 Context.getDiscriminatorOverride()(Context.getASTContext(),
Record);
1631 if (
Record->isLambda() &&
1632 ((DeviceNumber && *DeviceNumber > 0) ||
1633 (!DeviceNumber &&
Record->getLambdaManglingNumber() > 0))) {
1634 assert(!AdditionalAbiTags &&
1635 "Lambda type cannot have additional abi tags");
1642 unsigned UnnamedMangle =
1643 getASTContext().getManglingNumber(TD, Context.isAux());
1645 if (UnnamedMangle > 1)
1646 Out << UnnamedMangle - 2;
1648 writeAbiTags(TD, AdditionalAbiTags);
1654 unsigned AnonStructId =
1656 : Context.getAnonymousStructId(TD, dyn_cast<FunctionDecl>(DC));
1663 Str += llvm::utostr(AnonStructId);
1673 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1679 if (
auto Inherited =
1680 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1681 InheritedFrom = Inherited.getConstructor()->
getParent();
1682 InheritedTemplateName =
1683 TemplateName(Inherited.getConstructor()->getPrimaryTemplate());
1684 InheritedTemplateArgs =
1685 Inherited.getConstructor()->getTemplateSpecializationArgs();
1691 mangleCXXCtorType(
static_cast<CXXCtorType>(StructorType), InheritedFrom);
1699 if (InheritedTemplateArgs)
1700 mangleTemplateArgs(InheritedTemplateName, *InheritedTemplateArgs);
1702 writeAbiTags(ND, AdditionalAbiTags);
1710 mangleCXXDtorType(
static_cast<CXXDtorType>(StructorType));
1716 writeAbiTags(ND, AdditionalAbiTags);
1720 if (ND && Arity == UnknownArity) {
1721 Arity = cast<FunctionDecl>(ND)->getNumParams();
1724 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1725 if (MD->isImplicitObjectMemberFunction())
1731 mangleOperatorName(Name, Arity);
1732 writeAbiTags(ND, AdditionalAbiTags);
1736 llvm_unreachable(
"Can't mangle a deduction guide name!");
1739 llvm_unreachable(
"Can't mangle a using directive name!");
1743void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1747 if (getASTContext().getLangOpts().RegCall4)
1748 Out << II->
getLength() +
sizeof(
"__regcall4__") - 1 <<
"__regcall4__"
1751 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__"
1755void CXXNameMangler::mangleDeviceStubName(
const IdentifierInfo *II) {
1759 Out << II->
getLength() +
sizeof(
"__device_stub__") - 1 <<
"__device_stub__"
1770void CXXNameMangler::mangleNestedName(
GlobalDecl GD,
1772 const AbiTagList *AdditionalAbiTags,
1781 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1782 Qualifiers MethodQuals = Method->getMethodQualifiers();
1785 if (Method->isExplicitObjectMemberFunction())
1788 mangleQualifiers(MethodQuals);
1789 mangleRefQualifier(Method->getRefQualifier());
1795 mangleTemplatePrefix(TD, NoFunction);
1798 manglePrefix(DC, NoFunction);
1799 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1804void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1810 mangleTemplatePrefix(TD);
1816void CXXNameMangler::mangleNestedNameWithClosurePrefix(
1818 const AbiTagList *AdditionalAbiTags) {
1827 mangleClosurePrefix(PrefixND);
1828 mangleUnqualifiedName(GD,
nullptr, AdditionalAbiTags);
1839 if (
auto *CD = dyn_cast<CXXConstructorDecl>(DC))
1841 else if (
auto *DD = dyn_cast<CXXDestructorDecl>(DC))
1848void CXXNameMangler::mangleLocalName(
GlobalDecl GD,
1849 const AbiTagList *AdditionalAbiTags) {
1856 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1858 const DeclContext *DC = Context.getEffectiveDeclContext(RD ? RD : D);
1863 AbiTagState LocalAbiTags(AbiTags);
1866 mangleObjCMethodName(MD);
1867 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1868 mangleBlockForPrefix(BD);
1874 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1897 mangleNumber(Num - 2);
1906 mangleUnqualifiedName(RD, DC, AdditionalAbiTags);
1907 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1908 if (
const NamedDecl *PrefixND = getClosurePrefix(BD))
1909 mangleClosurePrefix(PrefixND,
true );
1911 manglePrefix(Context.getEffectiveDeclContext(BD),
true );
1912 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1913 mangleUnqualifiedBlock(BD);
1915 const NamedDecl *ND = cast<NamedDecl>(D);
1916 mangleNestedName(GD, Context.getEffectiveDeclContext(ND),
1917 AdditionalAbiTags,
true );
1919 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1923 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1929 mangleNumber(Num - 2);
1934 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1935 mangleUnqualifiedBlock(BD);
1937 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1940 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1942 if (Context.getNextDiscriminator(ND, disc)) {
1946 Out <<
"__" << disc <<
'_';
1951void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *
Block) {
1952 if (GetLocalClassDecl(
Block)) {
1953 mangleLocalName(
Block,
nullptr);
1957 if (isLocalContainerContext(DC)) {
1958 mangleLocalName(
Block,
nullptr);
1962 mangleClosurePrefix(PrefixND);
1965 mangleUnqualifiedBlock(
Block);
1968void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *
Block) {
1971 if (
Decl *Context =
Block->getBlockManglingContextDecl()) {
1972 if (isCompatibleWith(LangOptions::ClangABI::Ver12) &&
1973 (isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1974 Context->getDeclContext()->isRecord()) {
1975 const auto *ND = cast<NamedDecl>(Context);
1977 mangleSourceNameWithAbiTags(ND);
1984 unsigned Number =
Block->getBlockManglingNumber();
1988 Number = Context.getBlockId(
Block,
false);
2006void CXXNameMangler::mangleTemplateParamDecl(
const NamedDecl *
Decl) {
2008 if (
auto *Ty = dyn_cast<TemplateTypeParmDecl>(
Decl)) {
2009 if (Ty->isParameterPack())
2012 if (Constraint && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
2015 mangleTypeConstraint(Constraint);
2019 }
else if (
auto *Tn = dyn_cast<NonTypeTemplateParmDecl>(
Decl)) {
2020 if (Tn->isExpandedParameterPack()) {
2021 for (
unsigned I = 0, N = Tn->getNumExpansionTypes(); I != N; ++I) {
2023 mangleType(Tn->getExpansionType(I));
2027 if (Tn->isParameterPack()) {
2030 T = PackExpansion->getPattern();
2035 }
else if (
auto *Tt = dyn_cast<TemplateTemplateParmDecl>(
Decl)) {
2036 if (Tt->isExpandedParameterPack()) {
2037 for (
unsigned I = 0, N = Tt->getNumExpansionTemplateParameters(); I != N;
2039 mangleTemplateParameterList(Tt->getExpansionTemplateParameters(I));
2041 if (Tt->isParameterPack())
2043 mangleTemplateParameterList(Tt->getTemplateParameters());
2048void CXXNameMangler::mangleTemplateParameterList(
2051 for (
auto *Param : *Params)
2052 mangleTemplateParamDecl(Param);
2053 mangleRequiresClause(Params->getRequiresClause());
2057void CXXNameMangler::mangleTypeConstraint(
2059 const DeclContext *DC = Context.getEffectiveDeclContext(Concept);
2061 mangleTemplateName(Concept, Arguments);
2063 mangleUnscopedName(Concept, DC,
nullptr);
2065 mangleNestedName(Concept, DC,
nullptr);
2068void CXXNameMangler::mangleTypeConstraint(
const TypeConstraint *Constraint) {
2073 Args.push_back(ArgLoc.getArgument());
2078void CXXNameMangler::mangleRequiresClause(
const Expr *RequiresClause) {
2080 if (RequiresClause && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
2082 mangleExpression(RequiresClause);
2086void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
2090 if (isCompatibleWith(LangOptions::ClangABI::Ver12) &&
2091 (isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
2092 !isa<ParmVarDecl>(Context)) {
2095 mangleSourceName(Name);
2105 mangleLambdaSig(Lambda);
2119 std::optional<unsigned> DeviceNumber =
2120 Context.getDiscriminatorOverride()(Context.getASTContext(), Lambda);
2124 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
2126 mangleNumber(Number - 2);
2130void CXXNameMangler::mangleLambdaSig(
const CXXRecordDecl *Lambda) {
2133 mangleTemplateParamDecl(D);
2137 mangleRequiresClause(TPL->getRequiresClause());
2141 mangleBareFunctionType(Proto,
false,
2146 switch (qualifier->
getKind()) {
2152 llvm_unreachable(
"Can't mangle __super specifier");
2169 bool Clang14Compat = isCompatibleWith(LangOptions::ClangABI::Ver14);
2170 if (!Clang14Compat && mangleSubstitution(qualifier))
2181 addSubstitution(qualifier);
2185 llvm_unreachable(
"unexpected nested name specifier");
2188void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
2196 assert(!isa<LinkageSpecDecl>(DC) &&
"prefix cannot be LinkageSpecDecl");
2201 if (NoFunction && isLocalContainerContext(DC))
2204 assert(!isLocalContainerContext(DC));
2206 const NamedDecl *ND = cast<NamedDecl>(DC);
2207 if (mangleSubstitution(ND))
2213 mangleTemplatePrefix(TD);
2215 }
else if (
const NamedDecl *PrefixND = getClosurePrefix(ND)) {
2216 mangleClosurePrefix(PrefixND, NoFunction);
2217 mangleUnqualifiedName(ND,
nullptr,
nullptr);
2219 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
2220 manglePrefix(DC, NoFunction);
2221 mangleUnqualifiedName(ND, DC,
nullptr);
2224 addSubstitution(ND);
2227void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
2232 return mangleTemplatePrefix(TD);
2235 assert(Dependent &&
"unexpected template name kind");
2239 bool Clang11Compat = isCompatibleWith(LangOptions::ClangABI::Ver11);
2240 if (!Clang11Compat && mangleSubstitution(Template))
2244 manglePrefix(Qualifier);
2246 if (Clang11Compat && mangleSubstitution(Template))
2250 mangleSourceName(
Id);
2252 mangleOperatorName(Dependent->getOperator(), UnknownArity);
2254 addSubstitution(Template);
2257void CXXNameMangler::mangleTemplatePrefix(
GlobalDecl GD,
2266 if (mangleSubstitution(ND))
2270 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
2271 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
2273 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
2274 manglePrefix(DC, NoFunction);
2275 if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND))
2276 mangleUnqualifiedName(GD, DC,
nullptr);
2282 addSubstitution(ND);
2285const NamedDecl *CXXNameMangler::getClosurePrefix(
const Decl *ND) {
2286 if (isCompatibleWith(LangOptions::ClangABI::Ver12))
2290 if (
auto *
Block = dyn_cast<BlockDecl>(ND)) {
2291 Context = dyn_cast_or_null<NamedDecl>(
Block->getBlockManglingContextDecl());
2292 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
2294 Context = dyn_cast_or_null<NamedDecl>(RD->getLambdaContextDecl());
2301 if ((isa<VarDecl>(Context) && cast<VarDecl>(Context)->hasGlobalStorage()) ||
2302 isa<FieldDecl>(Context))
2308void CXXNameMangler::mangleClosurePrefix(
const NamedDecl *ND,
bool NoFunction) {
2311 if (mangleSubstitution(ND))
2316 mangleTemplatePrefix(TD, NoFunction);
2319 const auto *DC = Context.getEffectiveDeclContext(ND);
2320 manglePrefix(DC, NoFunction);
2321 mangleUnqualifiedName(ND, DC,
nullptr);
2326 addSubstitution(ND);
2335 if (mangleSubstitution(TN))
2348 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TD))
2349 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
2356 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
2360 assert(Dependent->isIdentifier());
2364 mangleUnresolvedPrefix(Dependent->getQualifier());
2365 mangleSourceName(Dependent->getIdentifier());
2385 Out <<
"_SUBSTPACK_";
2390 addSubstitution(TN);
2393bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
2399 case Type::Adjusted:
2402 case Type::BlockPointer:
2403 case Type::LValueReference:
2404 case Type::RValueReference:
2405 case Type::MemberPointer:
2406 case Type::ConstantArray:
2407 case Type::IncompleteArray:
2408 case Type::VariableArray:
2409 case Type::DependentSizedArray:
2410 case Type::DependentAddressSpace:
2411 case Type::DependentVector:
2412 case Type::DependentSizedExtVector:
2414 case Type::ExtVector:
2415 case Type::ConstantMatrix:
2416 case Type::DependentSizedMatrix:
2417 case Type::FunctionProto:
2418 case Type::FunctionNoProto:
2420 case Type::Attributed:
2421 case Type::BTFTagAttributed:
2423 case Type::DeducedTemplateSpecialization:
2424 case Type::PackExpansion:
2425 case Type::ObjCObject:
2426 case Type::ObjCInterface:
2427 case Type::ObjCObjectPointer:
2428 case Type::ObjCTypeParam:
2431 case Type::MacroQualified:
2433 case Type::DependentBitInt:
2434 llvm_unreachable(
"type is illegal as a nested name specifier");
2436 case Type::SubstTemplateTypeParmPack:
2441 Out <<
"_SUBSTPACK_";
2448 case Type::TypeOfExpr:
2450 case Type::Decltype:
2451 case Type::PackIndexing:
2452 case Type::TemplateTypeParm:
2453 case Type::UnaryTransform:
2454 case Type::SubstTemplateTypeParm:
2468 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
2471 case Type::UnresolvedUsing:
2472 mangleSourceNameWithAbiTags(
2473 cast<UnresolvedUsingType>(Ty)->getDecl());
2478 mangleSourceNameWithAbiTags(cast<TagType>(Ty)->getDecl());
2481 case Type::TemplateSpecialization: {
2483 cast<TemplateSpecializationType>(Ty);
2492 assert(TD &&
"no template for template specialization type");
2493 if (isa<TemplateTemplateParmDecl>(TD))
2494 goto unresolvedType;
2496 mangleSourceNameWithAbiTags(TD);
2503 llvm_unreachable(
"invalid base for a template specialization type");
2517 Out <<
"_SUBSTPACK_";
2522 assert(TD && !isa<TemplateTemplateParmDecl>(TD));
2523 mangleSourceNameWithAbiTags(TD);
2537 case Type::InjectedClassName:
2538 mangleSourceNameWithAbiTags(
2539 cast<InjectedClassNameType>(Ty)->getDecl());
2542 case Type::DependentName:
2543 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
2546 case Type::DependentTemplateSpecialization: {
2548 cast<DependentTemplateSpecializationType>(Ty);
2549 TemplateName Template = getASTContext().getDependentTemplateName(
2557 return mangleUnresolvedTypeOrSimpleId(cast<UsingType>(Ty)->desugar(),
2559 case Type::Elaborated:
2560 return mangleUnresolvedTypeOrSimpleId(
2561 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
2567void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
2568 switch (Name.getNameKind()) {
2577 llvm_unreachable(
"Not an operator name");
2582 mangleType(Name.getCXXNameType());
2587 mangleSourceName(Name.getCXXLiteralIdentifier());
2591 mangleOperatorName(Name.getCXXOverloadedOperator(), Arity);
2600 case OO_New: Out <<
"nw";
break;
2602 case OO_Array_New: Out <<
"na";
break;
2604 case OO_Delete: Out <<
"dl";
break;
2606 case OO_Array_Delete: Out <<
"da";
break;
2610 Out << (Arity == 1?
"ps" :
"pl");
break;
2614 Out << (Arity == 1?
"ng" :
"mi");
break;
2618 Out << (Arity == 1?
"ad" :
"an");
break;
2623 Out << (Arity == 1?
"de" :
"ml");
break;
2625 case OO_Tilde: Out <<
"co";
break;
2627 case OO_Slash: Out <<
"dv";
break;
2629 case OO_Percent: Out <<
"rm";
break;
2631 case OO_Pipe: Out <<
"or";
break;
2633 case OO_Caret: Out <<
"eo";
break;
2635 case OO_Equal: Out <<
"aS";
break;
2637 case OO_PlusEqual: Out <<
"pL";
break;
2639 case OO_MinusEqual: Out <<
"mI";
break;
2641 case OO_StarEqual: Out <<
"mL";
break;
2643 case OO_SlashEqual: Out <<
"dV";
break;
2645 case OO_PercentEqual: Out <<
"rM";
break;
2647 case OO_AmpEqual: Out <<
"aN";
break;
2649 case OO_PipeEqual: Out <<
"oR";
break;
2651 case OO_CaretEqual: Out <<
"eO";
break;
2653 case OO_LessLess: Out <<
"ls";
break;
2655 case OO_GreaterGreater: Out <<
"rs";
break;
2657 case OO_LessLessEqual: Out <<
"lS";
break;
2659 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2661 case OO_EqualEqual: Out <<
"eq";
break;
2663 case OO_ExclaimEqual: Out <<
"ne";
break;
2665 case OO_Less: Out <<
"lt";
break;
2667 case OO_Greater: Out <<
"gt";
break;
2669 case OO_LessEqual: Out <<
"le";
break;
2671 case OO_GreaterEqual: Out <<
"ge";
break;
2673 case OO_Exclaim: Out <<
"nt";
break;
2675 case OO_AmpAmp: Out <<
"aa";
break;
2677 case OO_PipePipe: Out <<
"oo";
break;
2679 case OO_PlusPlus: Out <<
"pp";
break;
2681 case OO_MinusMinus: Out <<
"mm";
break;
2683 case OO_Comma: Out <<
"cm";
break;
2685 case OO_ArrowStar: Out <<
"pm";
break;
2687 case OO_Arrow: Out <<
"pt";
break;
2689 case OO_Call: Out <<
"cl";
break;
2691 case OO_Subscript: Out <<
"ix";
break;
2696 case OO_Conditional: Out <<
"qu";
break;
2699 case OO_Coawait: Out <<
"aw";
break;
2702 case OO_Spaceship: Out <<
"ss";
break;
2706 llvm_unreachable(
"Not an overloaded operator");
2735 if (TargetAS != 0 ||
2737 ASString =
"AS" + llvm::utostr(TargetAS);
2740 default: llvm_unreachable(
"Not a language specific address space");
2744 case LangAS::opencl_global:
2745 ASString =
"CLglobal";
2747 case LangAS::opencl_global_device:
2748 ASString =
"CLdevice";
2750 case LangAS::opencl_global_host:
2751 ASString =
"CLhost";
2753 case LangAS::opencl_local:
2754 ASString =
"CLlocal";
2756 case LangAS::opencl_constant:
2757 ASString =
"CLconstant";
2759 case LangAS::opencl_private:
2760 ASString =
"CLprivate";
2762 case LangAS::opencl_generic:
2763 ASString =
"CLgeneric";
2767 case LangAS::sycl_global:
2768 ASString =
"SYglobal";
2770 case LangAS::sycl_global_device:
2771 ASString =
"SYdevice";
2773 case LangAS::sycl_global_host:
2774 ASString =
"SYhost";
2776 case LangAS::sycl_local:
2777 ASString =
"SYlocal";
2779 case LangAS::sycl_private:
2780 ASString =
"SYprivate";
2783 case LangAS::cuda_device:
2784 ASString =
"CUdevice";
2786 case LangAS::cuda_constant:
2787 ASString =
"CUconstant";
2789 case LangAS::cuda_shared:
2790 ASString =
"CUshared";
2793 case LangAS::ptr32_sptr:
2794 ASString =
"ptr32_sptr";
2796 case LangAS::ptr32_uptr:
2797 ASString =
"ptr32_uptr";
2804 if (!ASString.empty())
2805 mangleVendorQualifier(ASString);
2818 mangleVendorQualifier(
"__weak");
2822 mangleVendorQualifier(
"__unaligned");
2834 mangleVendorQualifier(
"__strong");
2838 mangleVendorQualifier(
"__autoreleasing");
2861void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2868 switch (RefQualifier) {
2882void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2883 Context.mangleObjCMethodNameAsSourceName(MD, Out);
2896 Ctx.
getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver17)
2902 if (Ctx.
getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver6 &&
2909 if (DeducedTST->getDeducedType().isNull())
2914void CXXNameMangler::mangleType(
QualType T) {
2955 = dyn_cast<TemplateSpecializationType>(T))
2973 const Type *ty = split.
Ty;
2975 bool isSubstitutable =
2977 if (isSubstitutable && mangleSubstitution(T))
2982 if (quals && isa<ArrayType>(T)) {
2992 dyn_cast<DependentAddressSpaceType>(ty)) {
2994 mangleQualifiers(splitDAST.
Quals, DAST);
2997 mangleQualifiers(quals);
3005#define ABSTRACT_TYPE(CLASS, PARENT)
3006#define NON_CANONICAL_TYPE(CLASS, PARENT) \
3008 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
3010#define TYPE(CLASS, PARENT) \
3012 mangleType(static_cast<const CLASS##Type*>(ty)); \
3014#include "clang/AST/TypeNodes.inc"
3019 if (isSubstitutable)
3023void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
3024 if (!mangleStandardSubstitution(ND))
3028void CXXNameMangler::mangleType(
const BuiltinType *T) {
3070 std::string type_name;
3074 if (NormalizeIntegers && T->
isInteger()) {
3076 switch (getASTContext().getTypeSize(T)) {
3080 if (mangleSubstitution(BuiltinType::SChar))
3083 addSubstitution(BuiltinType::SChar);
3086 if (mangleSubstitution(BuiltinType::Short))
3089 addSubstitution(BuiltinType::Short);
3092 if (mangleSubstitution(BuiltinType::Int))
3095 addSubstitution(BuiltinType::Int);
3098 if (mangleSubstitution(BuiltinType::Long))
3101 addSubstitution(BuiltinType::Long);
3104 if (mangleSubstitution(BuiltinType::Int128))
3107 addSubstitution(BuiltinType::Int128);
3110 llvm_unreachable(
"Unknown integer size for normalization");
3113 switch (getASTContext().getTypeSize(T)) {
3115 if (mangleSubstitution(BuiltinType::UChar))
3118 addSubstitution(BuiltinType::UChar);
3121 if (mangleSubstitution(BuiltinType::UShort))
3124 addSubstitution(BuiltinType::UShort);
3127 if (mangleSubstitution(BuiltinType::UInt))
3130 addSubstitution(BuiltinType::UInt);
3133 if (mangleSubstitution(BuiltinType::ULong))
3136 addSubstitution(BuiltinType::ULong);
3139 if (mangleSubstitution(BuiltinType::UInt128))
3142 addSubstitution(BuiltinType::UInt128);
3145 llvm_unreachable(
"Unknown integer size for normalization");
3151 case BuiltinType::Void:
3154 case BuiltinType::Bool:
3157 case BuiltinType::Char_U:
3158 case BuiltinType::Char_S:
3161 case BuiltinType::UChar:
3164 case BuiltinType::UShort:
3167 case BuiltinType::UInt:
3170 case BuiltinType::ULong:
3173 case BuiltinType::ULongLong:
3176 case BuiltinType::UInt128:
3179 case BuiltinType::SChar:
3182 case BuiltinType::WChar_S:
3183 case BuiltinType::WChar_U:
3186 case BuiltinType::Char8:
3189 case BuiltinType::Char16:
3192 case BuiltinType::Char32:
3195 case BuiltinType::Short:
3198 case BuiltinType::Int:
3201 case BuiltinType::Long:
3204 case BuiltinType::LongLong:
3207 case BuiltinType::Int128:
3210 case BuiltinType::Float16:
3213 case BuiltinType::ShortAccum:
3216 case BuiltinType::Accum:
3219 case BuiltinType::LongAccum:
3222 case BuiltinType::UShortAccum:
3225 case BuiltinType::UAccum:
3228 case BuiltinType::ULongAccum:
3231 case BuiltinType::ShortFract:
3234 case BuiltinType::Fract:
3237 case BuiltinType::LongFract:
3240 case BuiltinType::UShortFract:
3243 case BuiltinType::UFract:
3246 case BuiltinType::ULongFract:
3249 case BuiltinType::SatShortAccum:
3252 case BuiltinType::SatAccum:
3255 case BuiltinType::SatLongAccum:
3258 case BuiltinType::SatUShortAccum:
3261 case BuiltinType::SatUAccum:
3264 case BuiltinType::SatULongAccum:
3267 case BuiltinType::SatShortFract:
3270 case BuiltinType::SatFract:
3273 case BuiltinType::SatLongFract:
3276 case BuiltinType::SatUShortFract:
3279 case BuiltinType::SatUFract:
3282 case BuiltinType::SatULongFract:
3285 case BuiltinType::Half:
3288 case BuiltinType::Float:
3291 case BuiltinType::Double:
3294 case BuiltinType::LongDouble: {
3296 getASTContext().getLangOpts().OpenMP &&
3297 getASTContext().getLangOpts().OpenMPIsTargetDevice
3298 ? getASTContext().getAuxTargetInfo()
3299 : &getASTContext().getTargetInfo();
3303 case BuiltinType::Float128: {
3305 getASTContext().getLangOpts().OpenMP &&
3306 getASTContext().getLangOpts().OpenMPIsTargetDevice
3307 ? getASTContext().getAuxTargetInfo()
3308 : &getASTContext().getTargetInfo();
3312 case BuiltinType::BFloat16: {
3314 ((getASTContext().getLangOpts().OpenMP &&
3315 getASTContext().getLangOpts().OpenMPIsTargetDevice) ||
3316 getASTContext().getLangOpts().SYCLIsDevice)
3317 ? getASTContext().getAuxTargetInfo()
3318 : &getASTContext().getTargetInfo();
3322 case BuiltinType::Ibm128: {
3323 const TargetInfo *TI = &getASTContext().getTargetInfo();
3327 case BuiltinType::NullPtr:
3331#define BUILTIN_TYPE(Id, SingletonId)
3332#define PLACEHOLDER_TYPE(Id, SingletonId) \
3333 case BuiltinType::Id:
3334#include "clang/AST/BuiltinTypes.def"
3335 case BuiltinType::Dependent:
3337 llvm_unreachable(
"mangling a placeholder type");
3339 case BuiltinType::ObjCId:
3340 Out <<
"11objc_object";
3342 case BuiltinType::ObjCClass:
3343 Out <<
"10objc_class";
3345 case BuiltinType::ObjCSel:
3346 Out <<
"13objc_selector";
3348#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3349 case BuiltinType::Id: \
3350 type_name = "ocl_" #ImgType "_" #Suffix; \
3351 Out << type_name.size() << type_name; \
3353#include "clang/Basic/OpenCLImageTypes.def"
3354 case BuiltinType::OCLSampler:
3355 Out <<
"11ocl_sampler";
3357 case BuiltinType::OCLEvent:
3358 Out <<
"9ocl_event";
3360 case BuiltinType::OCLClkEvent:
3361 Out <<
"12ocl_clkevent";
3363 case BuiltinType::OCLQueue:
3364 Out <<
"9ocl_queue";
3366 case BuiltinType::OCLReserveID:
3367 Out <<
"13ocl_reserveid";
3369#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3370 case BuiltinType::Id: \
3371 type_name = "ocl_" #ExtType; \
3372 Out << type_name.size() << type_name; \
3374#include "clang/Basic/OpenCLExtensionTypes.def"
3378#define SVE_VECTOR_TYPE(InternalName, MangledName, Id, SingletonId, NumEls, \
3379 ElBits, IsSigned, IsFP, IsBF) \
3380 case BuiltinType::Id: \
3381 if (T->getKind() == BuiltinType::SveBFloat16 && \
3382 isCompatibleWith(LangOptions::ClangABI::Ver17)) { \
3384 type_name = "__SVBFloat16_t"; \
3385 Out << "u" << type_name.size() << type_name; \
3387 type_name = MangledName; \
3388 Out << (type_name == InternalName ? "u" : "") << type_name.size() \
3392#define SVE_PREDICATE_TYPE(InternalName, MangledName, Id, SingletonId, NumEls) \
3393 case BuiltinType::Id: \
3394 type_name = MangledName; \
3395 Out << (type_name == InternalName ? "u" : "") << type_name.size() \
3398#define SVE_OPAQUE_TYPE(InternalName, MangledName, Id, SingletonId) \
3399 case BuiltinType::Id: \
3400 type_name = MangledName; \
3401 Out << (type_name == InternalName ? "u" : "") << type_name.size() \
3404#include "clang/Basic/AArch64SVEACLETypes.def"
3405#define PPC_VECTOR_TYPE(Name, Id, Size) \
3406 case BuiltinType::Id: \
3407 type_name = #Name; \
3408 Out << 'u' << type_name.size() << type_name; \
3410#include "clang/Basic/PPCTypes.def"
3412#define RVV_TYPE(Name, Id, SingletonId) \
3413 case BuiltinType::Id: \
3415 Out << 'u' << type_name.size() << type_name; \
3417#include "clang/Basic/RISCVVTypes.def"
3418#define WASM_REF_TYPE(InternalName, MangledName, Id, SingletonId, AS) \
3419 case BuiltinType::Id: \
3420 type_name = MangledName; \
3421 Out << 'u' << type_name.size() << type_name; \
3423#include "clang/Basic/WebAssemblyReferenceTypes.def"
3427StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
3469 return "swiftasynccall";
3471 llvm_unreachable(
"bad calling convention");
3474void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *T) {
3483 StringRef CCQualifier = getCallingConvQualifierName(T->
getExtInfo().
getCC());
3484 if (!CCQualifier.empty())
3485 mangleVendorQualifier(CCQualifier);
3499 case ParameterABI::Ordinary:
3503 case ParameterABI::SwiftContext:
3504 case ParameterABI::SwiftAsyncContext:
3505 case ParameterABI::SwiftErrorResult:
3506 case ParameterABI::SwiftIndirectResult:
3512 mangleVendorQualifier(
"ns_consumed");
3515 mangleVendorQualifier(
"noescape");
3522 mangleExtFunctionInfo(T);
3539 mangleType(ExceptTy);
3550 mangleBareFunctionType(T,
true);
3564 FunctionTypeDepthState saved = FunctionTypeDepth.push();
3566 FunctionTypeDepth.enterResultType();
3568 FunctionTypeDepth.leaveResultType();
3570 FunctionTypeDepth.pop(saved);
3575 bool MangleReturnType,
3579 FunctionTypeDepthState saved = FunctionTypeDepth.push();
3582 if (MangleReturnType) {
3583 FunctionTypeDepth.enterResultType();
3587 mangleVendorQualifier(
"ns_returns_retained");
3592 auto SplitReturnTy = ReturnTy.
split();
3594 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
3596 mangleType(ReturnTy);
3598 FunctionTypeDepth.leaveResultType();
3606 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
3620 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
3621 if (
Attr->isDynamic())
3622 Out <<
"U25pass_dynamic_object_size" <<
Attr->getType();
3624 Out <<
"U17pass_object_size" <<
Attr->getType();
3635 FunctionTypeDepth.enterResultType();
3639 FunctionTypeDepth.pop(saved);
3650void CXXNameMangler::mangleType(
const EnumType *T) {
3651 mangleType(
static_cast<const TagType*
>(T));
3653void CXXNameMangler::mangleType(
const RecordType *T) {
3654 mangleType(
static_cast<const TagType*
>(T));
3656void CXXNameMangler::mangleType(
const TagType *T) {
3664 Out <<
'A' << T->
getSize() <<
'_';
3717 mangleType(PointeeType);
3731 Out <<
"_SUBSTPACK_";
3735void CXXNameMangler::mangleType(
const PointerType *T) {
3757void CXXNameMangler::mangleType(
const ComplexType *T) {
3765void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
3767 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3768 const char *EltName =
nullptr;
3770 switch (cast<BuiltinType>(EltType)->
getKind()) {
3771 case BuiltinType::SChar:
3772 case BuiltinType::UChar:
3773 EltName =
"poly8_t";
3775 case BuiltinType::Short:
3776 case BuiltinType::UShort:
3777 EltName =
"poly16_t";
3779 case BuiltinType::LongLong:
3780 case BuiltinType::ULongLong:
3781 EltName =
"poly64_t";
3783 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
3786 switch (cast<BuiltinType>(EltType)->
getKind()) {
3787 case BuiltinType::SChar: EltName =
"int8_t";
break;
3788 case BuiltinType::UChar: EltName =
"uint8_t";
break;
3789 case BuiltinType::Short: EltName =
"int16_t";
break;
3790 case BuiltinType::UShort: EltName =
"uint16_t";
break;
3791 case BuiltinType::Int: EltName =
"int32_t";
break;
3792 case BuiltinType::UInt: EltName =
"uint32_t";
break;
3793 case BuiltinType::LongLong: EltName =
"int64_t";
break;
3794 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
3795 case BuiltinType::Double: EltName =
"float64_t";
break;
3796 case BuiltinType::Float: EltName =
"float32_t";
break;
3797 case BuiltinType::Half: EltName =
"float16_t";
break;
3798 case BuiltinType::BFloat16: EltName =
"bfloat16_t";
break;
3800 llvm_unreachable(
"unexpected Neon vector element type");
3803 const char *BaseName =
nullptr;
3805 getASTContext().getTypeSize(EltType));
3807 BaseName =
"__simd64_";
3809 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
3810 BaseName =
"__simd128_";
3812 Out << strlen(BaseName) + strlen(EltName);
3813 Out << BaseName << EltName;
3820 "cannot mangle this dependent neon vector type yet");
3826 case BuiltinType::SChar:
3828 case BuiltinType::Short:
3830 case BuiltinType::Int:
3832 case BuiltinType::Long:
3833 case BuiltinType::LongLong:
3835 case BuiltinType::UChar:
3837 case BuiltinType::UShort:
3839 case BuiltinType::UInt:
3841 case BuiltinType::ULong:
3842 case BuiltinType::ULongLong:
3844 case BuiltinType::Half:
3846 case BuiltinType::Float:
3848 case BuiltinType::Double:
3850 case BuiltinType::BFloat16:
3853 llvm_unreachable(
"Unexpected vector element base type");
3860void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
3862 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3867 assert((BitSize == 64 || BitSize == 128) &&
3868 "Neon vector type not 64 or 128 bits");
3872 switch (cast<BuiltinType>(EltType)->
getKind()) {
3873 case BuiltinType::UChar:
3876 case BuiltinType::UShort:
3879 case BuiltinType::ULong:
3880 case BuiltinType::ULongLong:
3884 llvm_unreachable(
"unexpected Neon polynomial vector element type");
3890 (
"__" + EltName +
"x" + Twine(T->
getNumElements()) +
"_t").str();
3897 "cannot mangle this dependent neon vector type yet");
3925void CXXNameMangler::mangleAArch64FixedSveVectorType(
const VectorType *T) {
3926 assert((T->
getVectorKind() == VectorKind::SveFixedLengthData ||
3927 T->
getVectorKind() == VectorKind::SveFixedLengthPredicate) &&
3928 "expected fixed-length SVE vector!");
3932 "expected builtin type for fixed-length SVE vector!");
3935 switch (cast<BuiltinType>(EltType)->
getKind()) {
3936 case BuiltinType::SChar:
3939 case BuiltinType::UChar: {
3946 case BuiltinType::Short:
3949 case BuiltinType::UShort:
3952 case BuiltinType::Int:
3955 case BuiltinType::UInt:
3958 case BuiltinType::Long:
3961 case BuiltinType::ULong:
3964 case BuiltinType::Half:
3967 case BuiltinType::Float:
3970 case BuiltinType::Double:
3973 case BuiltinType::BFloat16:
3977 llvm_unreachable(
"unexpected element type for fixed-length SVE vector!");
3980 unsigned VecSizeInBits = getASTContext().getTypeInfo(T).Width;
3982 if (T->
getVectorKind() == VectorKind::SveFixedLengthPredicate)
3986 << VecSizeInBits <<
"EE";
3989void CXXNameMangler::mangleAArch64FixedSveVectorType(
3994 "cannot mangle this dependent fixed-length SVE vector type yet");
3998void CXXNameMangler::mangleRISCVFixedRVVVectorType(
const VectorType *T) {
3999 assert((T->
getVectorKind() == VectorKind::RVVFixedLengthData ||
4001 "expected fixed-length RVV vector!");
4005 "expected builtin type for fixed-length RVV vector!");
4008 llvm::raw_svector_ostream TypeNameOS(TypeNameStr);
4009 TypeNameOS <<
"__rvv_";
4010 switch (cast<BuiltinType>(EltType)->
getKind()) {
4011 case BuiltinType::SChar:
4012 TypeNameOS <<
"int8";
4014 case BuiltinType::UChar:
4016 TypeNameOS <<
"uint8";
4018 TypeNameOS <<
"bool";
4020 case BuiltinType::Short:
4021 TypeNameOS <<
"int16";
4023 case BuiltinType::UShort:
4024 TypeNameOS <<
"uint16";
4026 case BuiltinType::Int:
4027 TypeNameOS <<
"int32";
4029 case BuiltinType::UInt:
4030 TypeNameOS <<
"uint32";
4032 case BuiltinType::Long:
4033 TypeNameOS <<
"int64";
4035 case BuiltinType::ULong:
4036 TypeNameOS <<
"uint64";
4038 case BuiltinType::Float16:
4039 TypeNameOS <<
"float16";
4041 case BuiltinType::Float:
4042 TypeNameOS <<
"float32";
4044 case BuiltinType::Double:
4045 TypeNameOS <<
"float64";
4048 llvm_unreachable(
"unexpected element type for fixed-length RVV vector!");
4051 unsigned VecSizeInBits = getASTContext().getTypeInfo(T).Width;
4054 auto VScale = getASTContext().getTargetInfo().getVScaleRange(
4055 getASTContext().getLangOpts());
4056 unsigned VLen = VScale->first * llvm::RISCV::RVVBitsPerBlock;
4060 if (VecSizeInBits >= VLen)
4061 TypeNameOS << (VecSizeInBits / VLen);
4063 TypeNameOS <<
'f' << (VLen / VecSizeInBits);
4065 TypeNameOS << (VLen / VecSizeInBits);
4069 Out <<
"9__RVV_VLSI" <<
'u' << TypeNameStr.size() << TypeNameStr <<
"Lj"
4070 << VecSizeInBits <<
"EE";
4073void CXXNameMangler::mangleRISCVFixedRVVVectorType(
4078 "cannot mangle this dependent fixed-length RVV vector type yet");
4090void CXXNameMangler::mangleType(
const VectorType *T) {
4093 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
4094 llvm::Triple::ArchType Arch =
4095 getASTContext().getTargetInfo().getTriple().getArch();
4096 if ((Arch == llvm::Triple::aarch64 ||
4097 Arch == llvm::Triple::aarch64_be) && !
Target.isOSDarwin())
4098 mangleAArch64NeonVectorType(T);
4100 mangleNeonVectorType(T);
4102 }
else if (T->
getVectorKind() == VectorKind::SveFixedLengthData ||
4103 T->
getVectorKind() == VectorKind::SveFixedLengthPredicate) {
4104 mangleAArch64FixedSveVectorType(T);
4106 }
else if (T->
getVectorKind() == VectorKind::RVVFixedLengthData ||
4108 mangleRISCVFixedRVVVectorType(T);
4123 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
4124 llvm::Triple::ArchType Arch =
4125 getASTContext().getTargetInfo().getTriple().getArch();
4126 if ((Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be) &&
4128 mangleAArch64NeonVectorType(T);
4130 mangleNeonVectorType(T);
4132 }
else if (T->
getVectorKind() == VectorKind::SveFixedLengthData ||
4133 T->
getVectorKind() == VectorKind::SveFixedLengthPredicate) {
4134 mangleAArch64FixedSveVectorType(T);
4136 }
else if (T->
getVectorKind() == VectorKind::RVVFixedLengthData) {
4137 mangleRISCVFixedRVVVectorType(T);
4153 mangleType(
static_cast<const VectorType*
>(T));
4166 StringRef VendorQualifier =
"matrix_type";
4167 Out <<
"u" << VendorQualifier.size() << VendorQualifier;
4170 auto &ASTCtx = getASTContext();
4171 unsigned BitWidth = ASTCtx.getTypeSize(ASTCtx.getSizeType());
4172 llvm::APSInt Rows(BitWidth);
4174 mangleIntegerLiteral(ASTCtx.getSizeType(), Rows);
4175 llvm::APSInt Columns(BitWidth);
4177 mangleIntegerLiteral(ASTCtx.getSizeType(), Columns);
4185 StringRef VendorQualifier =
"matrix_type";
4186 Out <<
"u" << VendorQualifier.size() << VendorQualifier;
4197 mangleQualifiers(split.
Quals, T);
4221 Out <<
"U8__kindof";
4226 llvm::raw_svector_ostream QualOS(QualStr);
4227 QualOS <<
"objcproto";
4228 for (
const auto *I : T->
quals()) {
4229 StringRef
name = I->getName();
4232 Out <<
'U' << QualStr.size() << QualStr;
4241 mangleType(typeArg);
4247 Out <<
"U13block_pointer";
4262 if (mangleSubstitution(
QualType(T, 0)))
4287 case ElaboratedTypeKeyword::None:
4288 case ElaboratedTypeKeyword::Typename:
4290 case ElaboratedTypeKeyword::Struct:
4291 case ElaboratedTypeKeyword::Class:
4292 case ElaboratedTypeKeyword::Interface:
4295 case ElaboratedTypeKeyword::Union:
4298 case ElaboratedTypeKeyword::Enum:
4315 getASTContext().getDependentTemplateName(T->
getQualifier(),
4317 mangleTemplatePrefix(Prefix);
4326void CXXNameMangler::mangleType(
const TypeOfType *T) {
4338void CXXNameMangler::mangleType(
const DecltypeType *T) {
4349 if (isa<DeclRefExpr>(E) ||
4350 isa<MemberExpr>(E) ||
4351 isa<UnresolvedLookupExpr>(E) ||
4352 isa<DependentScopeDeclRefExpr>(E) ||
4353 isa<CXXDependentScopeMemberExpr>(E) ||
4354 isa<UnresolvedMemberExpr>(E))
4358 mangleExpression(E);
4368 StringRef BuiltinName;
4370#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
4371 case UnaryTransformType::Enum: \
4372 BuiltinName = "__" #Trait; \
4374#include "clang/Basic/TransformTypeTraits.def"
4376 Out << BuiltinName.size() << BuiltinName;
4384void CXXNameMangler::mangleType(
const AutoType *T) {
4386 "Deduced AutoType shouldn't be handled here!");
4387 assert(T->
getKeyword() != AutoTypeKeyword::GNUAutoType &&
4388 "shouldn't need to mangle __auto_type!");
4393 if (T->
isConstrained() && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
4405 return mangleType(Deduced);
4408 assert(TD &&
"shouldn't form deduced TST unless we know we have a template");
4410 if (mangleSubstitution(TD))
4414 addSubstitution(TD);
4417void CXXNameMangler::mangleType(
const AtomicType *T) {
4424void CXXNameMangler::mangleType(
const PipeType *T) {
4431void CXXNameMangler::mangleType(
const BitIntType *T) {
4447void CXXNameMangler::mangleIntegerLiteral(
QualType T,
4448 const llvm::APSInt &
Value) {
4455 Out << (
Value.getBoolValue() ?
'1' :
'0');
4457 mangleNumber(
Value);
4463void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
4466 if (!RT->getDecl()->isAnonymousStructOrUnion())
4468 const auto *ME = dyn_cast<MemberExpr>(
Base);
4471 Base = ME->getBase();
4472 IsArrow = ME->isArrow();
4475 if (
Base->isImplicitCXXThis()) {
4481 Out << (IsArrow ?
"pt" :
"dt");
4482 mangleExpression(
Base);
4487void CXXNameMangler::mangleMemberExpr(
const Expr *base,
4493 unsigned NumTemplateArgs,
4498 mangleMemberExprBase(base, isArrow);
4499 mangleUnresolvedName(qualifier, member, TemplateArgs, NumTemplateArgs, arity);
4512 if (callee == fn)
return false;
4516 if (!lookup)
return false;
4533void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
4535 Out << CastEncoding;
4540void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
4542 InitList = Syntactic;
4543 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
4544 mangleExpression(InitList->
getInit(i));
4547void CXXNameMangler::mangleRequirement(
SourceLocation RequiresExprLoc,
4554 auto HandleSubstitutionFailure =
4559 "containing a substitution failure");
4560 Diags.
Report(Loc, DiagID);
4565 case Requirement::RK_Type: {
4566 const auto *TR = cast<concepts::TypeRequirement>(Req);
4567 if (TR->isSubstitutionFailure())
4568 return HandleSubstitutionFailure(
4569 TR->getSubstitutionDiagnostic()->DiagLoc);
4572 mangleType(TR->getType()->getType());
4576 case Requirement::RK_Simple:
4577 case Requirement::RK_Compound: {
4578 const auto *ER = cast<concepts::ExprRequirement>(Req);
4579 if (ER->isExprSubstitutionFailure())
4580 return HandleSubstitutionFailure(
4581 ER->getExprSubstitutionDiagnostic()->DiagLoc);
4584 mangleExpression(ER->getExpr());
4586 if (ER->hasNoexceptRequirement())
4589 if (!ER->getReturnTypeRequirement().isEmpty()) {
4590 if (ER->getReturnTypeRequirement().isSubstitutionFailure())
4591 return HandleSubstitutionFailure(ER->getReturnTypeRequirement()
4592 .getSubstitutionDiagnostic()
4596 mangleTypeConstraint(ER->getReturnTypeRequirement().getTypeConstraint());
4601 case Requirement::RK_Nested:
4602 const auto *NR = cast<concepts::NestedRequirement>(Req);
4603 if (NR->hasInvalidConstraint()) {
4606 return HandleSubstitutionFailure(RequiresExprLoc);
4610 mangleExpression(NR->getConstraintExpr());
4615void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity,
4616 bool AsTemplateArg) {
4645 QualType ImplicitlyConvertedToType;
4649 bool IsPrimaryExpr =
true;
4650 auto NotPrimaryExpr = [&] {
4651 if (AsTemplateArg && IsPrimaryExpr)
4653 IsPrimaryExpr =
false;
4656 auto MangleDeclRefExpr = [&](
const NamedDecl *D) {
4657 switch (D->getKind()) {
4667 mangleFunctionParam(cast<ParmVarDecl>(D));
4670 case Decl::EnumConstant: {
4677 case Decl::NonTypeTemplateParm:
4690 case Expr::NoStmtClass:
4691#define ABSTRACT_STMT(Type)
4692#define EXPR(Type, Base)
4693#define STMT(Type, Base) \
4694 case Expr::Type##Class:
4695#include "clang/AST/StmtNodes.inc"
4700 case Expr::AddrLabelExprClass:
4701 case Expr::DesignatedInitUpdateExprClass:
4702 case Expr::ImplicitValueInitExprClass:
4703 case Expr::ArrayInitLoopExprClass:
4704 case Expr::ArrayInitIndexExprClass:
4705 case Expr::NoInitExprClass:
4706 case Expr::ParenListExprClass:
4707 case Expr::MSPropertyRefExprClass:
4708 case Expr::MSPropertySubscriptExprClass:
4709 case Expr::TypoExprClass:
4710 case Expr::RecoveryExprClass:
4711 case Expr::OMPArraySectionExprClass:
4712 case Expr::OMPArrayShapingExprClass:
4713 case Expr::OMPIteratorExprClass:
4714 case Expr::CXXInheritedCtorInitExprClass:
4715 case Expr::CXXParenListInitExprClass:
4716 case Expr::PackIndexingExprClass:
4717 llvm_unreachable(
"unexpected statement kind");
4719 case Expr::ConstantExprClass:
4720 E = cast<ConstantExpr>(E)->getSubExpr();
4724 case Expr::BlockExprClass:
4725 case Expr::ChooseExprClass:
4726 case Expr::CompoundLiteralExprClass:
4727 case Expr::ExtVectorElementExprClass:
4728 case Expr::GenericSelectionExprClass:
4729 case Expr::ObjCEncodeExprClass:
4730 case Expr::ObjCIsaExprClass:
4731 case Expr::ObjCIvarRefExprClass:
4732 case Expr::ObjCMessageExprClass:
4733 case Expr::ObjCPropertyRefExprClass:
4734 case Expr::ObjCProtocolExprClass:
4735 case Expr::ObjCSelectorExprClass:
4736 case Expr::ObjCStringLiteralClass:
4737 case Expr::ObjCBoxedExprClass:
4738 case Expr::ObjCArrayLiteralClass:
4739 case Expr::ObjCDictionaryLiteralClass:
4740 case Expr::ObjCSubscriptRefExprClass:
4741 case Expr::ObjCIndirectCopyRestoreExprClass:
4742 case Expr::ObjCAvailabilityCheckExprClass:
4743 case Expr::OffsetOfExprClass:
4744 case Expr::PredefinedExprClass:
4745 case Expr::ShuffleVectorExprClass:
4746 case Expr::ConvertVectorExprClass:
4747 case Expr::StmtExprClass:
4748 case Expr::ArrayTypeTraitExprClass:
4749 case Expr::ExpressionTraitExprClass:
4750 case Expr::VAArgExprClass:
4751 case Expr::CUDAKernelCallExprClass:
4752 case Expr::AsTypeExprClass:
4753 case Expr::PseudoObjectExprClass:
4754 case Expr::AtomicExprClass:
4755 case Expr::SourceLocExprClass:
4756 case Expr::BuiltinBitCastExprClass:
4763 "cannot yet mangle expression type %0");
4771 case Expr::CXXUuidofExprClass: {
4776 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
4777 Out <<
"u8__uuidof";
4786 Out <<
"u8__uuidoft";
4790 Out <<
"u8__uuidofz";
4791 mangleExpression(UuidExp);
4798 case Expr::BinaryConditionalOperatorClass: {
4803 "?: operator with omitted middle operand cannot be mangled");
4810 case Expr::OpaqueValueExprClass:
4811 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
4813 case Expr::InitListExprClass: {
4816 mangleInitListElements(cast<InitListExpr>(E));
4821 case Expr::DesignatedInitExprClass: {
4823 auto *DIE = cast<DesignatedInitExpr>(E);
4824 for (
const auto &
Designator : DIE->designators()) {
4830 mangleExpression(DIE->getArrayIndex(
Designator));
4833 "unknown designator kind");
4835 mangleExpression(DIE->getArrayRangeStart(
Designator));
4836 mangleExpression(DIE->getArrayRangeEnd(
Designator));
4839 mangleExpression(DIE->getInit());
4843 case Expr::CXXDefaultArgExprClass:
4844 E = cast<CXXDefaultArgExpr>(E)->getExpr();
4847 case Expr::CXXDefaultInitExprClass:
4848 E = cast<CXXDefaultInitExpr>(E)->getExpr();
4851 case Expr::CXXStdInitializerListExprClass:
4852 E = cast<CXXStdInitializerListExpr>(E)->getSubExpr();
4855 case Expr::SubstNonTypeTemplateParmExprClass: {
4858 auto *SNTTPE = cast<SubstNonTypeTemplateParmExpr>(E);
4859 if (
auto *CE = dyn_cast<ConstantExpr>(SNTTPE->getReplacement())) {
4861 QualType ParamType = SNTTPE->getParameterType(Context.getASTContext());
4862 assert(CE->hasAPValueResult() &&
"expected the NTTP to have an APValue");
4863 mangleValueInTemplateArg(ParamType, CE->getAPValueResult(),
false,
4869 E = cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement();
4873 case Expr::UserDefinedLiteralClass:
4876 case Expr::CXXMemberCallExprClass:
4877 case Expr::CallExprClass: {
4879 const CallExpr *CE = cast<CallExpr>(E);
4898 if (isa<PackExpansionExpr>(Arg))
4899 CallArity = UnknownArity;
4901 mangleExpression(CE->
getCallee(), CallArity);
4903 mangleExpression(Arg);
4908 case Expr::CXXNewExprClass: {
4912 Out << (New->
isArray() ?
"na" :
"nw");
4915 mangleExpression(*I);
4929 mangleExpression(*I);
4931 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
4932 mangleExpression(PLE->getExpr(i));
4934 CXXNewInitializationStyle::Braces &&
4935 isa<InitListExpr>(
Init)) {
4937 mangleInitListElements(cast<InitListExpr>(
Init));
4939 mangleExpression(
Init);
4945 case Expr::CXXPseudoDestructorExprClass: {
4947 const auto *PDE = cast<CXXPseudoDestructorExpr>(E);
4948 if (
const Expr *
Base = PDE->getBase())
4949 mangleMemberExprBase(
Base, PDE->isArrow());
4953 mangleUnresolvedPrefix(Qualifier,
4955 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
4959 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
4962 }
else if (Qualifier) {
4963 mangleUnresolvedPrefix(Qualifier);
4967 QualType DestroyedType = PDE->getDestroyedType();
4968 mangleUnresolvedTypeOrSimpleId(DestroyedType);
4972 case Expr::MemberExprClass: {
4983 case Expr::UnresolvedMemberExprClass: {
4994 case Expr::CXXDependentScopeMemberExprClass: {
4997 = cast<CXXDependentScopeMemberExpr>(E);
5007 case Expr::UnresolvedLookupExprClass: {
5016 case Expr::CXXUnresolvedConstructExprClass: {
5022 assert(N == 1 &&
"unexpected form for list initialization");
5023 auto *IL = cast<InitListExpr>(CE->
getArg(0));
5026 mangleInitListElements(IL);
5033 if (N != 1) Out <<
'_';
5034 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
5035 if (N != 1) Out <<
'E';
5039 case Expr::CXXConstructExprClass: {
5041 const auto *CE = cast<CXXConstructExpr>(E);
5046 "implicit CXXConstructExpr must have one argument");
5047 E = cast<CXXConstructExpr>(E)->getArg(0);
5053 mangleExpression(E);
5058 case Expr::CXXTemporaryObjectExprClass: {
5060 const auto *CE = cast<CXXTemporaryObjectExpr>(E);
5069 if (!List && N != 1)
5071 if (CE->isStdInitListInitialization()) {
5077 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
5078 mangleInitListElements(ILE);
5081 mangleExpression(E);
5088 case Expr::CXXScalarValueInitExprClass:
5095 case Expr::CXXNoexceptExprClass:
5098 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
5101 case Expr::UnaryExprOrTypeTraitExprClass: {
5120 : ImplicitlyConvertedToType;
5122 mangleIntegerLiteral(T,
V);
5128 auto MangleAlignofSizeofArg = [&] {
5141 MangleAlignofSizeofArg();
5143 case UETT_PreferredAlignOf:
5147 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
5148 Out <<
"u11__alignof__";
5159 MangleAlignofSizeofArg();
5161 case UETT_DataSizeOf: {
5165 "cannot yet mangle __datasizeof expression");
5169 case UETT_VecStep: {
5172 "cannot yet mangle vec_step expression");
5176 case UETT_OpenMPRequiredSimdAlign: {
5180 "cannot yet mangle __builtin_omp_required_simd_align expression");
5184 case UETT_VectorElements: {
5188 "cannot yet mangle __builtin_vectorelements expression");
5196 case Expr::TypeTraitExprClass: {
5202 Out << Spelling.size() << Spelling;
5204 mangleType(TSI->getType());
5210 case Expr::CXXThrowExprClass: {
5224 case Expr::CXXTypeidExprClass: {
5239 case Expr::CXXDeleteExprClass: {
5250 case Expr::UnaryOperatorClass: {
5259 case Expr::ArraySubscriptExprClass: {
5266 mangleExpression(AE->
getLHS());
5267 mangleExpression(AE->
getRHS());
5271 case Expr::MatrixSubscriptExprClass: {
5275 mangleExpression(ME->
getBase());
5281 case Expr::CompoundAssignOperatorClass:
5282 case Expr::BinaryOperatorClass: {
5290 mangleExpression(BO->
getLHS());
5291 mangleExpression(BO->
getRHS());
5295 case Expr::CXXRewrittenBinaryOperatorClass: {
5299 cast<CXXRewrittenBinaryOperator>(E)->getDecomposedForm();
5302 mangleExpression(Decomposed.
LHS);
5303 mangleExpression(Decomposed.
RHS);
5307 case Expr::ConditionalOperatorClass: {
5310 mangleOperatorName(OO_Conditional, 3);
5311 mangleExpression(CO->
getCond());
5312 mangleExpression(CO->
getLHS(), Arity);
5313 mangleExpression(CO->
getRHS(), Arity);
5317 case Expr::ImplicitCastExprClass: {
5318 ImplicitlyConvertedToType = E->
getType();
5319 E = cast<ImplicitCastExpr>(E)->getSubExpr();
5323 case Expr::ObjCBridgedCastExprClass: {
5327 StringRef
Kind = cast<ObjCBridgedCastExpr>(E)->getBridgeKindName();
5328 Out <<
"v1U" <<
Kind.size() <<
Kind;
5329 mangleCastExpression(E,
"cv");
5333 case Expr::CStyleCastExprClass:
5335 mangleCastExpression(E,
"cv");
5338 case Expr::CXXFunctionalCastExprClass: {
5340 auto *
Sub = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreImplicit();
5342 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
5343 if (CCE->getParenOrBraceRange().isInvalid())
5344 Sub = CCE->getArg(0)->IgnoreImplicit();
5345 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
5346 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
5347 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
5350 mangleInitListElements(IL);
5353 mangleCastExpression(E,
"cv");
5358 case Expr::CXXStaticCastExprClass:
5360 mangleCastExpression(E,
"sc");
5362 case Expr::CXXDynamicCastExprClass:
5364 mangleCastExpression(E,
"dc");
5366 case Expr::CXXReinterpretCastExprClass:
5368 mangleCastExpression(E,
"rc");
5370 case Expr::CXXConstCastExprClass:
5372 mangleCastExpression(E,
"cc");
5374 case Expr::CXXAddrspaceCastExprClass:
5376 mangleCastExpression(E,
"ac");
5379 case Expr::CXXOperatorCallExprClass: {
5388 for (
unsigned i = 0; i != NumArgs; ++i)
5389 mangleExpression(CE->
getArg(i));
5393 case Expr::ParenExprClass:
5394 E = cast<ParenExpr>(E)->getSubExpr();
5397 case Expr::ConceptSpecializationExprClass: {
5398 auto *CSE = cast<ConceptSpecializationExpr>(E);
5399 if (isCompatibleWith(LangOptions::ClangABI::Ver17)) {
5404 mangleTemplateName(CSE->getNamedConcept(), CSE->getTemplateArguments());
5410 mangleUnresolvedName(
5411 CSE->getNestedNameSpecifierLoc().getNestedNameSpecifier(),
5412 CSE->getConceptNameInfo().getName(),
5413 CSE->getTemplateArgsAsWritten()->getTemplateArgs(),
5414 CSE->getTemplateArgsAsWritten()->getNumTemplateArgs());
5418 case Expr::RequiresExprClass: {
5420 auto *RE = cast<RequiresExpr>(E);
5424 if (RE->getLParenLoc().isValid()) {
5426 FunctionTypeDepthState saved = FunctionTypeDepth.push();
5427 if (RE->getLocalParameters().empty()) {
5430 for (
ParmVarDecl *Param : RE->getLocalParameters()) {
5438 FunctionTypeDepth.enterResultType();
5440 mangleRequirement(RE->getExprLoc(), Req);
5441 FunctionTypeDepth.pop(saved);
5446 mangleRequirement(RE->getExprLoc(), Req);
5452 case Expr::DeclRefExprClass:
5454 MangleDeclRefExpr(cast<DeclRefExpr>(E)->getDecl());
5457 case Expr::SubstNonTypeTemplateParmPackExprClass:
5463 Out <<
"_SUBSTPACK_";
5466 case Expr::FunctionParmPackExprClass: {
5470 Out <<
"v110_SUBSTPACK";
5475 case Expr::DependentScopeDeclRefExprClass: {
5484 case Expr::CXXBindTemporaryExprClass:
5485 E = cast<CXXBindTemporaryExpr>(E)->getSubExpr();
5488 case Expr::ExprWithCleanupsClass:
5489 E = cast<ExprWithCleanups>(E)->getSubExpr();
5492 case Expr::FloatingLiteralClass: {
5499 case Expr::FixedPointLiteralClass:
5501 mangleFixedPointLiteral();
5504 case Expr::CharacterLiteralClass:
5508 Out << cast<CharacterLiteral>(E)->getValue();
5513 case Expr::ObjCBoolLiteralExprClass:
5516 Out << (cast<ObjCBoolLiteralExpr>(E)->getValue() ?
'1' :
'0');
5520 case Expr::CXXBoolLiteralExprClass:
5523 Out << (cast<CXXBoolLiteralExpr>(E)->getValue() ?
'1' :
'0');
5527 case Expr::IntegerLiteralClass: {
5529 llvm::APSInt
Value(cast<IntegerLiteral>(E)->getValue());
5531 Value.setIsSigned(
true);
5536 case Expr::ImaginaryLiteralClass: {
5544 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
5546 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
5548 mangleFloat(Imag->getValue());
5551 llvm::APSInt
Value(cast<IntegerLiteral>(IE->
getSubExpr())->getValue());
5553 Value.setIsSigned(
true);
5554 mangleNumber(
Value);
5560 case Expr::StringLiteralClass: {
5564 assert(isa<ConstantArrayType>(E->
getType()));
5570 case Expr::GNUNullExprClass:
5573 mangleIntegerLiteral(E->
getType(), llvm::APSInt(32));
5576 case Expr::CXXNullPtrLiteralExprClass: {
5582 case Expr::LambdaExprClass: {
5587 mangleType(Context.getASTContext().
getRecordType(cast<LambdaExpr>(E)->getLambdaClass()));
5592 case Expr::PackExpansionExprClass:
5595 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
5598 case Expr::SizeOfPackExprClass: {
5600 auto *SPE = cast<SizeOfPackExpr>(E);
5601 if (SPE->isPartiallySubstituted()) {
5603 for (
const auto &A : SPE->getPartialArguments())
5604 mangleTemplateArg(A,
false);
5612 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
5614 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
5615 mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
5617 = dyn_cast<TemplateTemplateParmDecl>(Pack))
5618 mangleTemplateParameter(TempTP->getDepth(), TempTP->getIndex());
5620 mangleFunctionParam(cast<ParmVarDecl>(Pack));
5624 case Expr::MaterializeTemporaryExprClass:
5625 E = cast<MaterializeTemporaryExpr>(E)->getSubExpr();
5628 case Expr::CXXFoldExprClass: {
5630 auto *FE = cast<CXXFoldExpr>(E);
5631 if (FE->isLeftFold())
5632 Out << (FE->getInit() ?
"fL" :
"fl");
5634 Out << (FE->getInit() ?
"fR" :
"fr");
5636 if (FE->getOperator() == BO_PtrMemD)
5644 mangleExpression(FE->getLHS());
5646 mangleExpression(FE->getRHS());
5650 case Expr::CXXThisExprClass:
5655 case Expr::CoawaitExprClass:
5658 Out <<
"v18co_await";
5659 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
5662 case Expr::DependentCoawaitExprClass:
5665 Out <<
"v18co_await";
5666 mangleExpression(cast<DependentCoawaitExpr>(E)->getOperand());
5669 case Expr::CoyieldExprClass:
5672 Out <<
"v18co_yield";
5673 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
5675 case Expr::SYCLUniqueStableNameExprClass: {
5676 const auto *USN = cast<SYCLUniqueStableNameExpr>(E);
5679 Out <<
"u33__builtin_sycl_unique_stable_name";
5680 mangleType(USN->getTypeSourceInfo()->getType());
5687 if (AsTemplateArg && !IsPrimaryExpr)
5719void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
5726 assert(parmDepth < FunctionTypeDepth.getDepth());
5727 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
5728 if (FunctionTypeDepth.isInResultType())
5731 if (nestingDepth == 0) {
5734 Out <<
"fL" << (nestingDepth - 1) <<
'p';
5742 &&
"parameter's type is still an array type?");
5745 dyn_cast<DependentAddressSpaceType>(parm->
getType())) {
5752 if (parmIndex != 0) {
5753 Out << (parmIndex - 1);
5758void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T,
5781 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
5784 mangleName(InheritedFrom);
5787void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
5838 if (
auto *FTD = dyn_cast_or_null<FunctionTemplateDecl>(
ResolvedTemplate)) {
5839 auto *RD = dyn_cast<CXXRecordDecl>(FTD->getDeclContext());
5840 if (!RD || !RD->isGenericLambda())
5856 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param))
5857 return TTP->hasTypeConstraint();
5874 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param))
5875 return NTTP->getType()->isInstantiationDependentType() ||
5876 NTTP->getType()->getContainedDeducedType();
5880 auto *TTP = cast<TemplateTemplateParmDecl>(Param);
5891 auto MangleTemplateParamListToString =
5893 unsigned DepthOffset) {
5894 llvm::raw_svector_ostream Stream(Buffer);
5895 CXXNameMangler(
Mangler.Context, Stream,
5896 WithTemplateDepthOffset{DepthOffset})
5897 .mangleTemplateParameterList(Params);
5900 MangleTemplateParamListToString(ParamTemplateHead,
5901 TTP->getTemplateParameters(), 0);
5905 MangleTemplateParamListToString(ArgTemplateHead,
5907 TTP->getTemplateParameters()->
getDepth());
5908 return ParamTemplateHead != ArgTemplateHead;
5918 return {
true,
nullptr};
5923 assert(ParamIdx < ResolvedTemplate->getTemplateParameters()->size() &&
5924 "no parameter for argument");
5945 return {
true,
nullptr};
5960 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param);
5961 bool NeedExactType = NTTP && NTTP->getType()->getContainedDeducedType();
5962 return {NeedExactType,
nullptr};
5974void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
5976 unsigned NumTemplateArgs) {
5979 TemplateArgManglingInfo Info(*
this, TN);
5980 for (
unsigned i = 0; i != NumTemplateArgs; ++i) {
5981 mangleTemplateArg(Info, i, TemplateArgs[i].
getArgument());
5983 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
5987void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
5991 TemplateArgManglingInfo Info(*
this, TN);
5992 for (
unsigned i = 0, e = AL.
size(); i != e; ++i) {
5993 mangleTemplateArg(Info, i, AL[i]);
5995 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
5999void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6003 TemplateArgManglingInfo Info(*
this, TN);
6004 for (
unsigned i = 0; i != Args.size(); ++i) {
6005 mangleTemplateArg(Info, i, Args[i]);
6007 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6011void CXXNameMangler::mangleTemplateArg(TemplateArgManglingInfo &Info,
6013 TemplateArgManglingInfo::Info ArgInfo = Info.getArgInfo(Index, A);
6016 if (ArgInfo.TemplateParameterToMangle &&
6017 !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
6024 mangleTemplateParamDecl(ArgInfo.TemplateParameterToMangle);
6027 mangleTemplateArg(A, ArgInfo.NeedExactType);
6030void CXXNameMangler::mangleTemplateArg(
TemplateArgument A,
bool NeedExactType) {
6040 llvm_unreachable(
"Cannot mangle NULL template argument");
6067 auto *TPO = cast<TemplateParamObjectDecl>(D);
6068 mangleValueInTemplateArg(TPO->getType().getUnqualifiedType(),
6069 TPO->getValue(),
true,
6082 !isCompatibleWith(LangOptions::ClangABI::Ver11))
6103 true, NeedExactType);
6109 mangleTemplateArg(
P, NeedExactType);
6115void CXXNameMangler::mangleTemplateArgExpr(
const Expr *E) {
6116 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6117 mangleExpression(E, UnknownArity,
true);
6132 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
6134 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
6142 mangleExpression(E);
6155 switch (
V.getKind()) {
6163 assert(RD &&
"unexpected type for record value");
6172 if (!FD->isUnnamedBitfield() &&
6182 assert(RD &&
"unexpected type for union value");
6185 if (!FD->isUnnamedBitfield())
6196 for (
unsigned I = 0, N =
V.getArrayInitializedElts(); I != N; ++I)
6204 for (
unsigned I = 0, N =
V.getVectorLength(); I != N; ++I)
6214 return V.getFloat().isPosZero();
6217 return !
V.getFixedPoint().getValue();
6220 return V.getComplexFloatReal().isPosZero() &&
6221 V.getComplexFloatImag().isPosZero();
6224 return !
V.getComplexIntReal() && !
V.getComplexIntImag();
6227 return V.isNullPointer();
6230 return !
V.getMemberPointerDecl();
6233 llvm_unreachable(
"Unhandled APValue::ValueKind enum");
6240 T = AT->getElementType();
6242 dyn_cast<FieldDecl>(E.getAsBaseOrMember().getPointer()))
6246 cast<CXXRecordDecl>(E.getAsBaseOrMember().getPointer()));
6287 Diags.
Report(UnionLoc, DiagID);
6294 bool NeedExactType) {
6297 T = getASTContext().getUnqualifiedArrayType(T, Quals);
6300 bool IsPrimaryExpr =
true;
6301 auto NotPrimaryExpr = [&] {
6302 if (TopLevel && IsPrimaryExpr)
6304 IsPrimaryExpr =
false;
6308 switch (
V.getKind()) {
6317 llvm_unreachable(
"unexpected value kind in template argument");
6321 assert(RD &&
"unexpected type for record value");
6327 (Fields.back()->isUnnamedBitfield() ||
6329 V.getStructField(Fields.back()->getFieldIndex())))) {
6333 if (Fields.empty()) {
6334 while (!Bases.empty() &&
6336 V.getStructBase(Bases.size() - 1)))
6337 Bases = Bases.drop_back();
6344 for (
unsigned I = 0, N = Bases.size(); I != N; ++I)
6345 mangleValueInTemplateArg(Bases[I].getType(),
V.getStructBase(I),
false);
6346 for (
unsigned I = 0, N = Fields.size(); I != N; ++I) {
6347 if (Fields[I]->isUnnamedBitfield())
6349 mangleValueInTemplateArg(Fields[I]->getType(),
6350 V.getStructField(Fields[I]->getFieldIndex()),
6377 mangleSourceName(II);
6378 mangleValueInTemplateArg(FD->
getType(),
V.getUnionValue(),
false);
6392 unsigned N =
V.getArraySize();
6394 N =
V.getArrayInitializedElts();
6399 for (
unsigned I = 0; I != N; ++I) {
6400 const APValue &Elem = I <
V.getArrayInitializedElts()
6401 ?
V.getArrayInitializedElt(I)
6402 :
V.getArrayFiller();
6403 mangleValueInTemplateArg(ElemT, Elem,
false);
6415 unsigned N =
V.getVectorLength();
6418 for (
unsigned I = 0; I != N; ++I)
6419 mangleValueInTemplateArg(VT->
getElementType(),
V.getVectorElt(I),
false);
6425 mangleIntegerLiteral(T,
V.getInt());
6429 mangleFloatLiteral(T,
V.getFloat());
6433 mangleFixedPointLiteral();
6441 if (!
V.getComplexFloatReal().isPosZero() ||
6442 !
V.getComplexFloatImag().isPosZero())
6444 if (!
V.getComplexFloatImag().isPosZero())
6455 if (
V.getComplexIntReal().getBoolValue() ||
6456 V.getComplexIntImag().getBoolValue())
6458 if (
V.getComplexIntImag().getBoolValue())
6467 "unexpected type for LValue template arg");
6469 if (
V.isNullPointer()) {
6470 mangleNullPointer(T);
6479 if (Offset.isZero()) {
6491 Out << Offset.getQuantity() <<
'E';
6499 if (!
V.hasLValuePath()) {
6515 bool IsArrayToPointerDecayMangledAsDecl =
false;
6516 if (TopLevel && Ctx.
getLangOpts().getClangABICompat() <=
6517 LangOptions::ClangABI::Ver11) {
6519 IsArrayToPointerDecayMangledAsDecl =
6520 BType->
isArrayType() &&
V.getLValuePath().size() == 1 &&
6521 V.getLValuePath()[0].getAsArrayIndex() == 0 &&
6525 if ((!
V.getLValuePath().empty() ||
V.isLValueOnePastTheEnd()) &&
6526 !IsArrayToPointerDecayMangledAsDecl) {
6543 if (NeedExactType &&
6545 !isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6565 mangleExpression(E);
6569 mangleType(
QualType(TI.getType(), 0));
6572 llvm_unreachable(
"unexpected lvalue base kind in template argument");
6582 mangleNumber(
V.getLValueOffset().getQuantity());
6589 if (!
V.getLValueOffset().isZero())
6590 mangleNumber(
V.getLValueOffset().getQuantity());
6594 bool OnePastTheEnd =
V.isLValueOnePastTheEnd();
6598 if (
auto *CAT = dyn_cast<ConstantArrayType>(AT))
6599 OnePastTheEnd |= CAT->getSize() == E.getAsArrayIndex();
6600 TypeSoFar = AT->getElementType();
6602 const Decl *D = E.getAsBaseOrMember().getPointer();
6603 if (
auto *FD = dyn_cast<FieldDecl>(D)) {
6628 if (!
V.getMemberPointerDecl()) {
6629 mangleNullPointer(T);
6636 if (!
V.getMemberPointerPath().empty()) {
6639 }
else if (NeedExactType &&
6642 V.getMemberPointerDecl()->getType()) &&
6643 !isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6648 mangle(
V.getMemberPointerDecl());
6650 if (!
V.getMemberPointerPath().empty()) {
6653 if (!Offset.isZero())
6654 mangleNumber(Offset.getQuantity());
6660 if (TopLevel && !IsPrimaryExpr)
6664void CXXNameMangler::mangleTemplateParameter(
unsigned Depth,
unsigned Index) {
6674 Depth += TemplateDepthOffset;
6676 Out <<
'L' << (Depth - 1) <<
'_';
6682void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
6685 }
else if (SeqID == 1) {
6695 for (; SeqID != 0; SeqID /= 36) {
6696 unsigned C = SeqID % 36;
6697 *I++ = (
C < 10 ?
'0' +
C :
'A' +
C - 10);
6700 Out.write(I.base(), I - BufferRef.rbegin());
6705void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
6706 bool result = mangleSubstitution(tname);
6707 assert(result &&
"no existing substitution for template name");
6713bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
6715 if (mangleStandardSubstitution(ND))
6719 return mangleSubstitution(
reinterpret_cast<uintptr_t>(ND));
6724 "mangleSubstitution(NestedNameSpecifier *) is only used for "
6725 "identifier nested name specifiers.");
6727 return mangleSubstitution(
reinterpret_cast<uintptr_t>(NNS));
6737bool CXXNameMangler::mangleSubstitution(
QualType T) {
6740 return mangleSubstitution(RT->getDecl());
6745 return mangleSubstitution(TypePtr);
6748bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
6750 return mangleSubstitution(TD);
6753 return mangleSubstitution(
6757bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
6758 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
6759 if (I == Substitutions.end())
6762 unsigned SeqID = I->second;
6771bool CXXNameMangler::isSpecializedAs(
QualType S, llvm::StringRef Name,
6781 dyn_cast<ClassTemplateSpecializationDecl>(RT->
getDecl());
6785 if (!isStdNamespace(Context.getEffectiveDeclContext(SD)))
6789 if (TemplateArgs.
size() != 1)
6792 if (TemplateArgs[0].getAsType() != A)
6804bool CXXNameMangler::isStdCharSpecialization(
6806 bool HasAllocator) {
6811 if (TemplateArgs.
size() != (HasAllocator ? 3 : 2))
6814 QualType A = TemplateArgs[0].getAsType();
6822 if (!isSpecializedAs(TemplateArgs[1].getAsType(),
"char_traits", A))
6826 !isSpecializedAs(TemplateArgs[2].getAsType(),
"allocator", A))
6835bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
6837 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
6846 if (!isStdNamespace(Context.getEffectiveDeclContext(TD)))
6867 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
6868 if (!isStdNamespace(Context.getEffectiveDeclContext(SD)))
6877 if (isStdCharSpecialization(SD,
"basic_string",
true)) {
6884 if (isStdCharSpecialization(SD,
"basic_istream",
false)) {
6891 if (isStdCharSpecialization(SD,
"basic_ostream",
false)) {
6898 if (isStdCharSpecialization(SD,
"basic_iostream",
false)) {
6908void CXXNameMangler::addSubstitution(
QualType T) {
6911 addSubstitution(RT->
getDecl());
6917 addSubstitution(TypePtr);
6920void CXXNameMangler::addSubstitution(
TemplateName Template) {
6922 return addSubstitution(TD);
6928void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
6929 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
6930 Substitutions[Ptr] = SeqID++;
6933void CXXNameMangler::extendSubstitutions(CXXNameMangler*
Other) {
6934 assert(
Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
6935 if (
Other->SeqID > SeqID) {
6936 Substitutions.swap(
Other->Substitutions);
6937 SeqID =
Other->SeqID;
6942CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
6944 if (DisableDerivedAbiTags)
6945 return AbiTagList();
6947 llvm::raw_null_ostream NullOutStream;
6948 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
6949 TrackReturnTypeTags.disableDerivedAbiTags();
6953 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
6954 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
6956 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
6957 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
6959 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
6963CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
6965 if (DisableDerivedAbiTags)
6966 return AbiTagList();
6968 llvm::raw_null_ostream NullOutStream;
6969 CXXNameMangler TrackVariableType(*
this, NullOutStream);
6970 TrackVariableType.disableDerivedAbiTags();
6972 TrackVariableType.mangleType(VD->
getType());
6974 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
6977bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &
C,
6979 llvm::raw_null_ostream NullOutStream;
6980 CXXNameMangler TrackAbiTags(
C, NullOutStream,
nullptr,
true);
6981 TrackAbiTags.mangle(VD);
6982 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
6995void ItaniumMangleContextImpl::mangleCXXName(
GlobalDecl GD,
6998 assert((isa<FunctionDecl, VarDecl, TemplateParamObjectDecl>(D)) &&
6999 "Invalid mangleName() call, argument is not a variable or function!");
7002 getASTContext().getSourceManager(),
7003 "Mangling declaration");
7005 if (
auto *CD = dyn_cast<CXXConstructorDecl>(D)) {
7007 CXXNameMangler Mangler(*
this, Out, CD,
Type);
7011 if (
auto *DD = dyn_cast<CXXDestructorDecl>(D)) {
7013 CXXNameMangler Mangler(*
this, Out, DD,
Type);
7017 CXXNameMangler Mangler(*
this, Out, D);
7023 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
7029 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
7033void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
7043 assert(!isa<CXXDestructorDecl>(MD) &&
7044 "Use mangleCXXDtor for destructor decls!");
7045 CXXNameMangler Mangler(*
this, Out);
7046 Mangler.getStream() <<
"_ZT";
7048 Mangler.getStream() <<
'c';
7059 Mangler.mangleFunctionEncoding(MD);
7062void ItaniumMangleContextImpl::mangleCXXDtorThunk(
7067 CXXNameMangler Mangler(*
this, Out, DD,
Type);
7068 Mangler.getStream() <<
"_ZT";
7078void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
7082 CXXNameMangler Mangler(*
this, Out);
7085 Mangler.getStream() <<
"_ZGV";
7086 Mangler.mangleName(D);
7089void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
7094 Out <<
"__cxx_global_var_init";
7097void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
7100 CXXNameMangler Mangler(*
this, Out);
7101 Mangler.getStream() <<
"__dtor_";
7102 if (shouldMangleDeclName(D))
7105 Mangler.getStream() << D->
getName();
7108void ItaniumMangleContextImpl::mangleDynamicStermFinalizer(
const VarDecl *D,
7112 CXXNameMangler Mangler(*
this, Out);
7113 Mangler.getStream() <<
"__finalize_";
7114 if (shouldMangleDeclName(D))
7117 Mangler.getStream() << D->
getName();
7120void ItaniumMangleContextImpl::mangleSEHFilterExpression(
7121 GlobalDecl EnclosingDecl, raw_ostream &Out) {
7122 CXXNameMangler Mangler(*
this, Out);
7123 Mangler.getStream() <<
"__filt_";
7124 auto *EnclosingFD = cast<FunctionDecl>(EnclosingDecl.
getDecl());
7125 if (shouldMangleDeclName(EnclosingFD))
7126 Mangler.mangle(EnclosingDecl);
7128 Mangler.getStream() << EnclosingFD->getName();
7131void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
7132 GlobalDecl EnclosingDecl, raw_ostream &Out) {
7133 CXXNameMangler Mangler(*
this, Out);
7134 Mangler.getStream() <<
"__fin_";
7135 auto *EnclosingFD = cast<FunctionDecl>(EnclosingDecl.
getDecl());
7136 if (shouldMangleDeclName(EnclosingFD))
7137 Mangler.mangle(EnclosingDecl);
7139 Mangler.getStream() << EnclosingFD->getName();
7142void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
7145 CXXNameMangler Mangler(*
this, Out);
7146 Mangler.getStream() <<
"_ZTH";
7147 Mangler.mangleName(D);
7151ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
7154 CXXNameMangler Mangler(*
this, Out);
7155 Mangler.getStream() <<
"_ZTW";
7156 Mangler.mangleName(D);
7159void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
7160 unsigned ManglingNumber,
7164 CXXNameMangler Mangler(*
this, Out);
7165 Mangler.getStream() <<
"_ZGR";
7166 Mangler.mangleName(D);
7167 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
7168 Mangler.mangleSeqID(ManglingNumber - 1);
7171void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
7174 CXXNameMangler Mangler(*
this, Out);
7175 Mangler.getStream() <<
"_ZTV";
7176 Mangler.mangleNameOrStandardSubstitution(RD);
7179void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
7182 CXXNameMangler Mangler(*
this, Out);
7183 Mangler.getStream() <<
"_ZTT";
7184 Mangler.mangleNameOrStandardSubstitution(RD);
7187void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
7192 CXXNameMangler Mangler(*
this, Out);
7193 Mangler.getStream() <<
"_ZTC";
7194 Mangler.mangleNameOrStandardSubstitution(RD);
7195 Mangler.getStream() << Offset;
7196 Mangler.getStream() <<
'_';
7197 Mangler.mangleNameOrStandardSubstitution(
Type);
7200void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
7202 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
7203 CXXNameMangler Mangler(*
this, Out);
7204 Mangler.getStream() <<
"_ZTI";
7205 Mangler.mangleType(Ty);
7208void ItaniumMangleContextImpl::mangleCXXRTTIName(
7209 QualType Ty, raw_ostream &Out,
bool NormalizeIntegers =
false) {
7211 CXXNameMangler Mangler(*
this, Out, NormalizeIntegers);
7212 Mangler.getStream() <<
"_ZTS";
7213 Mangler.mangleType(Ty);
7216void ItaniumMangleContextImpl::mangleCanonicalTypeName(
7217 QualType Ty, raw_ostream &Out,
bool NormalizeIntegers =
false) {
7218 mangleCXXRTTIName(Ty, Out, NormalizeIntegers);
7221void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
7222 llvm_unreachable(
"Can't mangle string literals");
7225void ItaniumMangleContextImpl::mangleLambdaSig(
const CXXRecordDecl *Lambda,
7227 CXXNameMangler Mangler(*
this, Out);
7228 Mangler.mangleLambdaSig(Lambda);
7231void ItaniumMangleContextImpl::mangleModuleInitializer(
const Module *M,
7234 CXXNameMangler Mangler(*
this, Out);
7235 Mangler.getStream() <<
"_ZGI";
7239 auto Partition = M->
Name.find(
':');
7240 Mangler.mangleModuleNamePrefix(
7241 StringRef(&M->
Name[Partition + 1], M->
Name.size() - Partition - 1),
7249 return new ItaniumMangleContextImpl(
7252 return std::nullopt;
7261 return new ItaniumMangleContextImpl(Context, Diags, DiscriminatorOverride,
Enums/classes describing ABI related information about constructors, destructors and thunks.
Defines the clang::ASTContext interface.
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)
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
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)
Defines the SourceManager interface.
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
bool hasSimilarType(QualType T1, QualType T2)
Determine if two types are similar, according to the C++ rules.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
TemplateName getCanonicalTemplateName(const TemplateName &Name) const
Retrieves the "canonical" template name that refers to a given template.
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.
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.
unsigned getTargetAddressSpace(LangAS AS) const
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
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.
QualType getElementType() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Attr - This represents one attribute.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
bool isDecltypeAuto() const
ConceptDecl * getTypeConstraintConcept() const
AutoTypeKeyword getKeyword() const
bool isConstrained() const
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.
unsigned getNumBits() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
QualType getPointeeType() const
This class is used for builtin types like 'int'.
bool isSignedInteger() const
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...
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
bool isTypeOperand() const
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.
const llvm::APInt & getSize() const
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
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.
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
bool isParameterPack() const
Whether this declaration is a parameter pack.
SourceLocation getLocation() const
void setImplicit(bool I=true)
DeclContext * getDeclContext()
bool isInAnonymousNamespace() const
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).
Expr * getUnderlyingExpr() const
Represents a C++17 deduced template specialization type.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
Represents an extended address space qualifier where the input address space value is dependent.
Expr * getAddrSpaceExpr() const
QualType getPointeeType() const
Expr * getNumBitsExpr() const
Represents a qualified type name for which the type name is dependent.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
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.
Expr * getSizeExpr() const
Represents an extended vector type where either the type or size is dependent.
Expr * getSizeExpr() const
QualType getElementType() const
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Expr * getColumnExpr() const
Expr * getRowExpr() const
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.
Expr * getSizeExpr() const
VectorKind getVectorKind() const
SourceLocation getAttributeLoc() const
QualType getElementType() const
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
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
QualType getReturnType() const
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.
QualType getInjectedSpecializationType() const
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 mangleCXXVTable(const CXXRecordDecl *RD, 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 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 mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThisAdjustment &ThisAdjustment, 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 mangleSEHFinallyBlock(GlobalDecl EnclosingDecl, raw_ostream &Out)=0
virtual void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &)=0
virtual void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, raw_ostream &)=0
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
QualType getElementType() const
Returns type of the elements being stored in the matrix.
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
const Type * getClass() 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.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
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 isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
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.
NamespaceDecl * getOriginalNamespace()
Get the original (first) 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.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Represents a class type in Objective C.
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
QualType getBaseType() const
Gets the base type of this object type.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
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.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
bool hasSelectedType() const
QualType getPattern() const
QualType getSelectedType() const
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.
QualType getPointeeType() const
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.
QualType getCanonicalType() const
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
void * getAsOpaquePtr() const
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
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
QualType getPointeeType() const
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
TagDecl * getDecl() 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() 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,...
@ 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.
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.
unsigned getIndex() const
unsigned getDepth() const
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.
ElaboratedTypeKeyword getKeyword() const
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 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.
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,...
UnresolvedUsingTypenameDecl * getDecl() const
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.
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
VectorKind getVectorKind() const
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.
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
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.
struct clang::ReturnAdjustment::VirtualAdjustment::@183 Itanium
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
struct clang::ThisAdjustment::VirtualAdjustment::@185 Itanium
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset.