34#include "llvm/ADT/StringExtras.h"
35#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/raw_ostream.h"
37#include "llvm/TargetParser/RISCVTargetParser.h"
44static bool isLocalContainerContext(
const DeclContext *DC) {
50 return ftd->getTemplatedDecl();
57 return (fn ? getStructor(fn) :
decl);
60static bool isLambda(
const NamedDecl *ND) {
68static const unsigned UnknownArity = ~0
U;
71 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
72 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
73 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
74 const DiscriminatorOverrideTy DiscriminatorOverride =
nullptr;
75 NamespaceDecl *StdNamespace =
nullptr;
77 bool NeedsUniqueInternalLinkageNames =
false;
80 explicit ItaniumMangleContextImpl(
81 ASTContext &Context, DiagnosticsEngine &Diags,
82 DiscriminatorOverrideTy DiscriminatorOverride,
bool IsAux =
false)
83 : ItaniumMangleContext(Context, Diags, IsAux),
84 DiscriminatorOverride(DiscriminatorOverride) {}
89 bool shouldMangleCXXName(
const NamedDecl *D)
override;
90 bool shouldMangleStringLiteral(
const StringLiteral *)
override {
95 void needsUniqueInternalLinkageNames()
override {
96 NeedsUniqueInternalLinkageNames =
true;
99 void mangleCXXName(GlobalDecl GD, raw_ostream &)
override;
100 void mangleThunk(
const CXXMethodDecl *MD,
const ThunkInfo &Thunk,
bool,
101 raw_ostream &)
override;
103 const ThunkInfo &Thunk,
bool, raw_ostream &)
override;
104 void mangleReferenceTemporary(
const VarDecl *D,
unsigned ManglingNumber,
105 raw_ostream &)
override;
106 void mangleCXXVTable(
const CXXRecordDecl *RD, raw_ostream &)
override;
107 void mangleCXXVTT(
const CXXRecordDecl *RD, raw_ostream &)
override;
108 void mangleCXXCtorVTable(
const CXXRecordDecl *RD, int64_t Offset,
109 const CXXRecordDecl *
Type, raw_ostream &)
override;
110 void mangleCXXRTTI(QualType
T, raw_ostream &)
override;
111 void mangleCXXRTTIName(QualType
T, raw_ostream &,
112 bool NormalizeIntegers)
override;
113 void mangleCanonicalTypeName(QualType
T, raw_ostream &,
114 bool NormalizeIntegers)
override;
116 void mangleCXXCtorComdat(
const CXXConstructorDecl *D, raw_ostream &)
override;
117 void mangleCXXDtorComdat(
const CXXDestructorDecl *D, raw_ostream &)
override;
118 void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &)
override;
119 void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &Out)
override;
120 void mangleDynamicAtExitDestructor(
const VarDecl *D,
121 raw_ostream &Out)
override;
122 void mangleDynamicStermFinalizer(
const VarDecl *D, raw_ostream &Out)
override;
123 void mangleSEHFilterExpression(GlobalDecl EnclosingDecl,
124 raw_ostream &Out)
override;
125 void mangleSEHFinallyBlock(GlobalDecl EnclosingDecl,
126 raw_ostream &Out)
override;
127 void mangleItaniumThreadLocalInit(
const VarDecl *D, raw_ostream &)
override;
128 void mangleItaniumThreadLocalWrapper(
const VarDecl *D,
129 raw_ostream &)
override;
131 void mangleStringLiteral(
const StringLiteral *, raw_ostream &)
override;
133 void mangleLambdaSig(
const CXXRecordDecl *Lambda, raw_ostream &)
override;
135 void mangleModuleInitializer(
const Module *
Module, raw_ostream &)
override;
137 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
143 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
144 if (
Tag->getName().empty() && !
Tag->getTypedefNameForAnonDecl())
150 unsigned discriminator = getASTContext().getManglingNumber(ND, isAux());
151 if (discriminator == 1)
153 disc = discriminator - 2;
158 unsigned &discriminator = Uniquifier[ND];
159 if (!discriminator) {
160 const DeclContext *DC = getEffectiveDeclContext(ND);
161 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
163 if (discriminator == 1)
165 disc = discriminator-2;
169 std::string getLambdaString(
const CXXRecordDecl *Lambda)
override {
172 assert(Lambda->
isLambda() &&
"RD must be a lambda!");
173 std::string Name(
"<lambda");
177 const ParmVarDecl *Parm = dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
178 const FunctionDecl *
Func =
182 unsigned DefaultArgNo =
184 Name += llvm::utostr(DefaultArgNo);
188 if (LambdaManglingNumber)
189 LambdaId = LambdaManglingNumber;
191 LambdaId = getAnonymousStructIdForDebugInfo(Lambda);
193 Name += llvm::utostr(LambdaId);
198 DiscriminatorOverrideTy getDiscriminatorOverride()
const override {
199 return DiscriminatorOverride;
202 NamespaceDecl *getStdNamespace();
204 const DeclContext *getEffectiveDeclContext(
const Decl *D);
205 const DeclContext *getEffectiveParentContext(
const DeclContext *DC) {
206 return getEffectiveDeclContext(
cast<Decl>(DC));
209 bool isInternalLinkageDecl(
const NamedDecl *ND);
215class CXXNameMangler {
216 ItaniumMangleContextImpl &Context;
220 bool NormalizeIntegers =
false;
222 bool NullOut =
false;
227 bool DisableDerivedAbiTags =
false;
232 const NamedDecl *Structor;
233 unsigned StructorType = 0;
238 unsigned TemplateDepthOffset = 0;
243 class FunctionTypeDepthState {
246 enum { InResultTypeMask = 1 };
249 FunctionTypeDepthState() =
default;
252 unsigned getDepth()
const {
257 bool isInResultType()
const {
258 return Bits & InResultTypeMask;
261 FunctionTypeDepthState push() {
262 FunctionTypeDepthState tmp = *
this;
263 Bits = (Bits & ~InResultTypeMask) + 2;
267 void enterResultType() {
268 Bits |= InResultTypeMask;
271 void leaveResultType() {
272 Bits &= ~InResultTypeMask;
275 void pop(FunctionTypeDepthState saved) {
276 assert(getDepth() == saved.getDepth() + 1);
286 typedef SmallVector<StringRef, 4> AbiTagList;
291 class AbiTagState final {
293 explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
299 AbiTagState(
const AbiTagState &) =
delete;
300 AbiTagState &operator=(
const AbiTagState &) =
delete;
302 ~AbiTagState() { pop(); }
304 void write(raw_ostream &Out,
const NamedDecl *ND,
305 const AbiTagList *AdditionalAbiTags) {
309 !AdditionalAbiTags &&
310 "only function and variables need a list of additional abi tags");
311 if (
const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
312 if (
const auto *AbiTag = NS->getAttr<AbiTagAttr>())
313 llvm::append_range(UsedAbiTags, AbiTag->tags());
320 if (
const auto *AbiTag = ND->
getAttr<AbiTagAttr>()) {
321 llvm::append_range(UsedAbiTags, AbiTag->tags());
322 llvm::append_range(TagList, AbiTag->tags());
325 if (AdditionalAbiTags) {
326 llvm::append_range(UsedAbiTags, *AdditionalAbiTags);
327 llvm::append_range(TagList, *AdditionalAbiTags);
331 TagList.erase(llvm::unique(TagList), TagList.end());
333 writeSortedUniqueAbiTags(Out, TagList);
336 const AbiTagList &getUsedAbiTags()
const {
return UsedAbiTags; }
337 void setUsedAbiTags(
const AbiTagList &AbiTags) {
338 UsedAbiTags = AbiTags;
341 const AbiTagList &getEmittedAbiTags()
const {
342 return EmittedAbiTags;
345 const AbiTagList &getSortedUniqueUsedAbiTags() {
346 llvm::sort(UsedAbiTags);
347 UsedAbiTags.erase(llvm::unique(UsedAbiTags), UsedAbiTags.end());
353 AbiTagList UsedAbiTags;
355 AbiTagList EmittedAbiTags;
357 AbiTagState *&LinkHead;
358 AbiTagState *Parent =
nullptr;
361 assert(LinkHead ==
this &&
362 "abi tag link head must point to us on destruction");
364 Parent->UsedAbiTags.insert(Parent->UsedAbiTags.end(),
365 UsedAbiTags.begin(), UsedAbiTags.end());
366 Parent->EmittedAbiTags.insert(Parent->EmittedAbiTags.end(),
367 EmittedAbiTags.begin(),
368 EmittedAbiTags.end());
373 void writeSortedUniqueAbiTags(raw_ostream &Out,
const AbiTagList &AbiTags) {
374 for (
const auto &Tag : AbiTags) {
375 EmittedAbiTags.push_back(Tag);
383 AbiTagState *AbiTags =
nullptr;
384 AbiTagState AbiTagsRoot;
386 llvm::DenseMap<uintptr_t, unsigned> Substitutions;
387 llvm::DenseMap<StringRef, unsigned> ModuleSubstitutions;
389 ASTContext &getASTContext()
const {
return Context.getASTContext(); }
391 bool isCompatibleWith(LangOptions::ClangABI Ver) {
392 return Context.getASTContext().getLangOpts().getClangABICompat() <= Ver;
395 bool isStd(
const NamespaceDecl *NS);
396 bool isStdNamespace(
const DeclContext *DC);
398 const RecordDecl *GetLocalClassDecl(
const Decl *D);
399 bool isSpecializedAs(QualType S, llvm::StringRef Name, QualType A);
400 bool isStdCharSpecialization(
const ClassTemplateSpecializationDecl *SD,
401 llvm::StringRef Name,
bool HasAllocator);
404 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
405 const NamedDecl *D =
nullptr,
bool NullOut_ =
false)
406 : Context(
C), Out(Out_), NullOut(NullOut_), Structor(getStructor(D)),
407 AbiTagsRoot(AbiTags) {
412 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
414 : Context(
C), Out(Out_), Structor(getStructor(D)), StructorType(
Type),
415 AbiTagsRoot(AbiTags) {}
416 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
418 : Context(
C), Out(Out_), Structor(getStructor(D)), StructorType(
Type),
419 AbiTagsRoot(AbiTags) {}
421 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
422 bool NormalizeIntegers_)
423 : Context(
C), Out(Out_), NormalizeIntegers(NormalizeIntegers_),
424 NullOut(
false), Structor(
nullptr), AbiTagsRoot(AbiTags) {}
425 CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
426 : Context(Outer.Context), Out(Out_), Structor(Outer.Structor),
427 StructorType(Outer.StructorType), SeqID(Outer.SeqID),
428 FunctionTypeDepth(Outer.FunctionTypeDepth), AbiTagsRoot(AbiTags),
429 Substitutions(Outer.Substitutions),
430 ModuleSubstitutions(Outer.ModuleSubstitutions) {}
432 CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
433 : CXXNameMangler(Outer, (raw_ostream &)Out_) {
437 struct WithTemplateDepthOffset {
unsigned Offset; };
438 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out,
439 WithTemplateDepthOffset Offset)
440 : CXXNameMangler(
C, Out) {
441 TemplateDepthOffset = Offset.Offset;
444 raw_ostream &getStream() {
return Out; }
446 void disableDerivedAbiTags() { DisableDerivedAbiTags =
true; }
447 static bool shouldHaveAbiTags(ItaniumMangleContextImpl &
C,
const VarDecl *VD);
449 void mangle(GlobalDecl GD);
450 void mangleCallOffset(int64_t NonVirtual, int64_t
Virtual);
451 void mangleNumber(
const llvm::APSInt &I);
452 void mangleNumber(int64_t Number);
453 void mangleFloat(
const llvm::APFloat &F);
454 void mangleFunctionEncoding(GlobalDecl GD);
455 void mangleSeqID(
unsigned SeqID);
456 void mangleName(GlobalDecl GD);
457 void mangleType(QualType
T);
458 void mangleCXXRecordDecl(
const CXXRecordDecl *
Record,
459 bool SuppressSubstitution =
false);
460 void mangleLambdaSig(
const CXXRecordDecl *Lambda);
461 void mangleModuleNamePrefix(StringRef Name,
bool IsPartition =
false);
462 void mangleVendorQualifier(StringRef Name);
463 void mangleVendorType(StringRef Name);
466 bool mangleSubstitution(
const NamedDecl *ND);
467 bool mangleSubstitution(QualType
T);
473 bool mangleStandardSubstitution(
const NamedDecl *ND);
475 void addSubstitution(
const NamedDecl *ND) {
478 addSubstitution(
reinterpret_cast<uintptr_t>(ND));
480 void addSubstitution(QualType
T);
484 void extendSubstitutions(CXXNameMangler*
Other);
486 void mangleUnresolvedPrefix(NestedNameSpecifier Qualifier,
487 bool recursive =
false);
488 void mangleUnresolvedName(NestedNameSpecifier Qualifier, DeclarationName name,
489 const TemplateArgumentLoc *TemplateArgs,
490 unsigned NumTemplateArgs,
491 unsigned KnownArity = UnknownArity);
493 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
495 void mangleNameWithAbiTags(GlobalDecl GD,
496 const AbiTagList *AdditionalAbiTags);
497 void mangleModuleName(
const NamedDecl *ND);
498 void mangleTemplateName(
const TemplateDecl *TD,
499 ArrayRef<TemplateArgument> Args);
500 void mangleUnqualifiedName(GlobalDecl GD,
const DeclContext *DC,
501 const AbiTagList *AdditionalAbiTags) {
503 UnknownArity, AdditionalAbiTags);
505 void mangleUnqualifiedName(GlobalDecl GD, DeclarationName Name,
506 const DeclContext *DC,
unsigned KnownArity,
507 const AbiTagList *AdditionalAbiTags);
508 void mangleUnscopedName(GlobalDecl GD,
const DeclContext *DC,
509 const AbiTagList *AdditionalAbiTags);
510 void mangleUnscopedTemplateName(GlobalDecl GD,
const DeclContext *DC,
511 const AbiTagList *AdditionalAbiTags);
512 void mangleSourceName(
const IdentifierInfo *II);
513 void mangleRegCallName(
const IdentifierInfo *II);
514 void mangleDeviceStubName(
const IdentifierInfo *II);
515 void mangleOCLDeviceStubName(
const IdentifierInfo *II);
516 void mangleSourceNameWithAbiTags(
517 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
518 void mangleLocalName(GlobalDecl GD,
519 const AbiTagList *AdditionalAbiTags);
520 void mangleBlockForPrefix(
const BlockDecl *
Block);
521 void mangleUnqualifiedBlock(
const BlockDecl *
Block);
522 void mangleTemplateParamDecl(
const NamedDecl *Decl);
523 void mangleTemplateParameterList(
const TemplateParameterList *Params);
524 void mangleTypeConstraint(
const TemplateDecl *
Concept,
525 ArrayRef<TemplateArgument> Arguments);
526 void mangleTypeConstraint(
const TypeConstraint *Constraint);
527 void mangleRequiresClause(
const Expr *RequiresClause);
528 void mangleLambda(
const CXXRecordDecl *Lambda);
529 void mangleNestedName(GlobalDecl GD,
const DeclContext *DC,
530 const AbiTagList *AdditionalAbiTags,
531 bool NoFunction=
false);
532 void mangleNestedName(
const TemplateDecl *TD,
533 ArrayRef<TemplateArgument> Args);
534 void mangleNestedNameWithClosurePrefix(GlobalDecl GD,
535 const NamedDecl *PrefixND,
536 const AbiTagList *AdditionalAbiTags);
537 void manglePrefix(NestedNameSpecifier Qualifier);
538 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
539 void manglePrefix(QualType
type);
540 void mangleTemplatePrefix(GlobalDecl GD,
bool NoFunction=
false);
542 const NamedDecl *getClosurePrefix(
const Decl *ND);
543 void mangleClosurePrefix(
const NamedDecl *ND,
bool NoFunction =
false);
544 bool mangleUnresolvedTypeOrSimpleId(QualType DestroyedType,
545 StringRef Prefix =
"");
546 void mangleOperatorName(DeclarationName Name,
unsigned Arity);
548 void mangleQualifiers(Qualifiers Quals,
const DependentAddressSpaceType *DAST =
nullptr);
554#define ABSTRACT_TYPE(CLASS, PARENT)
555#define NON_CANONICAL_TYPE(CLASS, PARENT)
556#define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
557#include "clang/AST/TypeNodes.inc"
559 void mangleType(
const TagType*);
561 static StringRef getCallingConvQualifierName(
CallingConv CC);
564 void mangleSMEAttrs(
unsigned SMEAttrs);
569 void mangleAArch64NeonVectorType(
const VectorType *
T);
571 void mangleAArch64FixedSveVectorType(
const VectorType *
T);
573 void mangleRISCVFixedRVVVectorType(
const VectorType *
T);
577 void mangleFloatLiteral(
QualType T,
const llvm::APFloat &
V);
578 void mangleFixedPointLiteral();
581 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
582 void mangleMemberExpr(
const Expr *base,
bool isArrow,
586 unsigned NumTemplateArgs,
unsigned knownArity);
587 void mangleCastExpression(
const Expr *E, StringRef CastEncoding);
588 void mangleInitListElements(
const InitListExpr *InitList);
591 void mangleExpression(
const Expr *E,
unsigned Arity = UnknownArity,
592 bool AsTemplateArg =
false);
596 struct TemplateArgManglingInfo;
599 unsigned NumTemplateArgs);
602 void mangleTemplateArg(TemplateArgManglingInfo &Info,
unsigned Index,
605 void mangleTemplateArgExpr(
const Expr *E);
607 bool NeedExactType =
false);
609 void mangleTemplateParameter(
unsigned Depth,
unsigned Index);
614 const AbiTagList *AdditionalAbiTags);
617 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
619 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
627 getASTContext(), getASTContext().getTranslationUnitDecl(),
628 false, SourceLocation(), SourceLocation(),
629 &getASTContext().Idents.get(
"std"),
639ItaniumMangleContextImpl::getEffectiveDeclContext(
const Decl *D) {
646 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
648 if (ParmVarDecl *ContextParam =
649 dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
650 return ContextParam->getDeclContext();
654 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
655 if (ParmVarDecl *ContextParam =
656 dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
657 return ContextParam->getDeclContext();
665 if (D == getASTContext().getVaListTagDecl()) {
666 const llvm::Triple &
T = getASTContext().getTargetInfo().getTriple();
667 if (
T.isARM() ||
T.isThumb() ||
T.isAArch64())
668 return getStdNamespace();
674 return getEffectiveDeclContext(
cast<Decl>(DC));
677 if (
const auto *VD = dyn_cast<VarDecl>(D))
679 return getASTContext().getTranslationUnitDecl();
681 if (
const auto *FD = getASTContext().getLangOpts().getClangABICompat() >
682 LangOptions::ClangABI::Ver19
684 : dyn_cast<FunctionDecl>(D)) {
686 return getASTContext().getTranslationUnitDecl();
689 if (FD->isMemberLikeConstrainedFriend() &&
690 getASTContext().getLangOpts().getClangABICompat() >
691 LangOptions::ClangABI::Ver17)
698bool ItaniumMangleContextImpl::isInternalLinkageDecl(
const NamedDecl *ND) {
701 getEffectiveDeclContext(ND)->isFileContext() &&
708bool ItaniumMangleContextImpl::isUniqueInternalLinkageDecl(
709 const NamedDecl *ND) {
710 if (!NeedsUniqueInternalLinkageNames || !ND)
713 const auto *FD = dyn_cast<FunctionDecl>(ND);
719 if (!FD->getType()->getAs<FunctionProtoType>())
722 if (isInternalLinkageDecl(ND))
728bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
729 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
732 if (FD->hasAttr<OverloadableAttr>())
748 if (FD->isMSVCRTEntryPoint())
762 if (!getASTContext().getLangOpts().
CPlusPlus)
765 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
776 const DeclContext *DC = getEffectiveDeclContext(D);
780 DC = getEffectiveParentContext(DC);
782 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
784 !VD->getOwningModuleForLinkage())
791void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
792 const AbiTagList *AdditionalAbiTags) {
793 assert(AbiTags &&
"require AbiTagState");
794 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
797void CXXNameMangler::mangleSourceNameWithAbiTags(
798 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
800 writeAbiTags(ND, AdditionalAbiTags);
803void CXXNameMangler::mangle(GlobalDecl GD) {
809 mangleFunctionEncoding(GD);
810 else if (
isa<VarDecl, FieldDecl, MSGuidDecl, TemplateParamObjectDecl,
813 else if (
const IndirectFieldDecl *IFD =
814 dyn_cast<IndirectFieldDecl>(GD.
getDecl()))
815 mangleName(IFD->getAnonField());
817 llvm_unreachable(
"unexpected kind of global decl");
820void CXXNameMangler::mangleFunctionEncoding(GlobalDecl GD) {
825 if (!Context.shouldMangleDeclName(FD)) {
830 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
831 if (ReturnTypeAbiTags.empty()) {
840 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
842 FunctionTypeDepth.pop(Saved);
843 mangleFunctionEncodingBareType(FD);
850 SmallString<256> FunctionEncodingBuf;
851 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
852 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
854 FunctionEncodingMangler.disableDerivedAbiTags();
856 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
857 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
858 FunctionTypeDepth.pop(Saved);
861 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
862 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
866 const AbiTagList &UsedAbiTags =
867 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
868 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
869 AdditionalAbiTags.erase(
870 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
871 UsedAbiTags.begin(), UsedAbiTags.end(),
872 AdditionalAbiTags.begin()),
873 AdditionalAbiTags.end());
876 Saved = FunctionTypeDepth.push();
877 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
878 FunctionTypeDepth.pop(Saved);
879 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
883 extendSubstitutions(&FunctionEncodingMangler);
886void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
887 if (FD->
hasAttr<EnableIfAttr>()) {
888 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
889 Out <<
"Ua9enable_ifI";
890 for (AttrVec::const_iterator I = FD->
getAttrs().begin(),
893 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
896 if (isCompatibleWith(LangOptions::ClangABI::Ver11)) {
901 mangleExpression(EIA->getCond());
904 mangleTemplateArgExpr(EIA->getCond());
908 FunctionTypeDepth.pop(Saved);
913 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
914 if (
auto Inherited = CD->getInheritedConstructor())
915 FD = Inherited.getConstructor();
933 bool MangleReturnType =
false;
937 MangleReturnType =
true;
940 FD = PrimaryTemplate->getTemplatedDecl();
943 mangleBareFunctionType(FD->
getType()->
castAs<FunctionProtoType>(),
944 MangleReturnType, FD);
948bool CXXNameMangler::isStd(
const NamespaceDecl *NS) {
949 if (!Context.getEffectiveParentContext(NS)->isTranslationUnit())
953 return II && II->
isStr(
"std");
958bool CXXNameMangler::isStdNamespace(
const DeclContext *DC) {
965static const GlobalDecl
969 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
978 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
979 TemplateArgs = &Spec->getTemplateArgs();
980 return GD.
getWithDecl(Spec->getSpecializedTemplate());
985 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
986 TemplateArgs = &Spec->getTemplateArgs();
987 return GD.
getWithDecl(Spec->getSpecializedTemplate());
998void CXXNameMangler::mangleName(GlobalDecl GD) {
1000 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1002 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
1003 if (VariableTypeAbiTags.empty()) {
1005 mangleNameWithAbiTags(VD,
nullptr);
1010 llvm::raw_null_ostream NullOutStream;
1011 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
1012 VariableNameMangler.disableDerivedAbiTags();
1013 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
1016 const AbiTagList &UsedAbiTags =
1017 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
1018 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
1019 AdditionalAbiTags.erase(
1020 std::set_difference(VariableTypeAbiTags.begin(),
1021 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
1022 UsedAbiTags.end(), AdditionalAbiTags.begin()),
1023 AdditionalAbiTags.end());
1026 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
1028 mangleNameWithAbiTags(GD,
nullptr);
1032const RecordDecl *CXXNameMangler::GetLocalClassDecl(
const Decl *D) {
1033 const DeclContext *DC = Context.getEffectiveDeclContext(D);
1035 if (isLocalContainerContext(DC))
1036 return dyn_cast<RecordDecl>(D);
1038 DC = Context.getEffectiveDeclContext(D);
1043void CXXNameMangler::mangleNameWithAbiTags(GlobalDecl GD,
1044 const AbiTagList *AdditionalAbiTags) {
1051 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
1052 bool IsLambda = isLambda(ND);
1058 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !IsLambda)
1060 DC = Context.getEffectiveParentContext(DC);
1061 else if (GetLocalClassDecl(ND) &&
1062 (!IsLambda || isCompatibleWith(LangOptions::ClangABI::Ver18))) {
1063 mangleLocalName(GD, AdditionalAbiTags);
1071 if (
const NamedDecl *PrefixND = getClosurePrefix(ND)) {
1072 mangleNestedNameWithClosurePrefix(GD, PrefixND, AdditionalAbiTags);
1076 if (isLocalContainerContext(DC)) {
1077 mangleLocalName(GD, AdditionalAbiTags);
1086 const TemplateArgumentList *TemplateArgs =
nullptr;
1087 if (GlobalDecl TD =
isTemplate(GD, TemplateArgs)) {
1088 mangleUnscopedTemplateName(TD, DC, AdditionalAbiTags);
1093 mangleUnscopedName(GD, DC, AdditionalAbiTags);
1097 mangleNestedName(GD, DC, AdditionalAbiTags);
1100void CXXNameMangler::mangleModuleName(
const NamedDecl *ND) {
1103 mangleModuleNamePrefix(M->getPrimaryModuleInterfaceName());
1111void CXXNameMangler::mangleModuleNamePrefix(StringRef Name,
bool IsPartition) {
1113 auto It = ModuleSubstitutions.find(Name);
1114 if (It != ModuleSubstitutions.end()) {
1116 mangleSeqID(It->second);
1122 auto Parts = Name.rsplit(
'.');
1123 if (Parts.second.empty())
1124 Parts.second = Parts.first;
1126 mangleModuleNamePrefix(Parts.first, IsPartition);
1127 IsPartition =
false;
1133 Out << Parts.second.size() << Parts.second;
1134 ModuleSubstitutions.insert({Name, SeqID++});
1137void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
1138 ArrayRef<TemplateArgument> Args) {
1139 const DeclContext *DC = Context.getEffectiveDeclContext(TD);
1142 mangleUnscopedTemplateName(TD, DC,
nullptr);
1145 mangleNestedName(TD, Args);
1149void CXXNameMangler::mangleUnscopedName(GlobalDecl GD,
const DeclContext *DC,
1150 const AbiTagList *AdditionalAbiTags) {
1155 if (isStdNamespace(DC)) {
1156 if (getASTContext().getTargetInfo().getTriple().isOSSolaris()) {
1158 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND)) {
1163 if (
const IdentifierInfo *II = RD->getIdentifier()) {
1165 if (llvm::is_contained({
"div_t",
"ldiv_t",
"lconv",
"tm"},
type)) {
1175 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1178void CXXNameMangler::mangleUnscopedTemplateName(
1179 GlobalDecl GD,
const DeclContext *DC,
const AbiTagList *AdditionalAbiTags) {
1183 if (mangleSubstitution(ND))
1187 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1188 assert(!AdditionalAbiTags &&
1189 "template template param cannot have abi tags");
1190 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
1192 mangleUnscopedName(GD, DC, AdditionalAbiTags);
1198 addSubstitution(ND);
1201void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
1215 llvm::APInt valueBits = f.bitcastToAPInt();
1216 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
1217 assert(numCharacters != 0);
1220 SmallVector<char, 20> buffer(numCharacters);
1223 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
1225 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
1228 uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
1229 hexDigit >>= (digitBitIndex % 64);
1233 static const char charForHex[16] = {
1234 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
1235 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'
1237 buffer[stringIndex] = charForHex[hexDigit];
1240 Out.write(buffer.data(), numCharacters);
1243void CXXNameMangler::mangleFloatLiteral(QualType
T,
const llvm::APFloat &
V) {
1250void CXXNameMangler::mangleFixedPointLiteral() {
1251 DiagnosticsEngine &Diags = Context.getDiags();
1257void CXXNameMangler::mangleNullPointer(QualType
T) {
1264void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
1265 if (
Value.isSigned() &&
Value.isNegative()) {
1267 Value.abs().print(Out,
false);
1269 Value.print(Out,
false);
1273void CXXNameMangler::mangleNumber(int64_t Number) {
1283void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t
Virtual) {
1291 mangleNumber(NonVirtual);
1297 mangleNumber(NonVirtual);
1303void CXXNameMangler::manglePrefix(QualType
type) {
1304 if (
const auto *TST =
type->getAs<TemplateSpecializationType>()) {
1305 if (!mangleSubstitution(QualType(TST, 0))) {
1306 mangleTemplatePrefix(TST->getTemplateName());
1311 mangleTemplateArgs(TST->getTemplateName(), TST->template_arguments());
1312 addSubstitution(QualType(TST, 0));
1314 }
else if (
const auto *DNT =
type->getAs<DependentNameType>()) {
1316 bool Clang14Compat = isCompatibleWith(LangOptions::ClangABI::Ver14);
1317 if (!Clang14Compat && mangleSubstitution(QualType(DNT, 0)))
1322 assert(DNT->getQualifier());
1323 manglePrefix(DNT->getQualifier());
1325 mangleSourceName(DNT->getIdentifier());
1328 addSubstitution(QualType(DNT, 0));
1340void CXXNameMangler::mangleUnresolvedPrefix(NestedNameSpecifier Qualifier,
1358 case NestedNameSpecifier::Kind::Null:
1359 llvm_unreachable(
"unexpected null nested name specifier");
1361 case NestedNameSpecifier::Kind::Global:
1371 case NestedNameSpecifier::Kind::MicrosoftSuper:
1372 llvm_unreachable(
"Can't mangle __super specifier");
1374 case NestedNameSpecifier::Kind::Namespace: {
1377 mangleUnresolvedPrefix(Prefix,
1381 mangleSourceNameWithAbiTags(Namespace);
1385 case NestedNameSpecifier::Kind::Type: {
1393 if (NestedNameSpecifier Prefix =
type->getPrefix()) {
1394 mangleUnresolvedPrefix(Prefix,
1401 if (mangleUnresolvedTypeOrSimpleId(QualType(
type, 0), recursive ?
"N" :
""))
1416void CXXNameMangler::mangleUnresolvedName(
1417 NestedNameSpecifier Qualifier, DeclarationName name,
1418 const TemplateArgumentLoc *TemplateArgs,
unsigned NumTemplateArgs,
1419 unsigned knownArity) {
1421 mangleUnresolvedPrefix(Qualifier);
1422 switch (
name.getNameKind()) {
1425 mangleSourceName(
name.getAsIdentifierInfo());
1430 mangleUnresolvedTypeOrSimpleId(
name.getCXXNameType());
1437 mangleOperatorName(name, knownArity);
1440 llvm_unreachable(
"Can't mangle a constructor name!");
1442 llvm_unreachable(
"Can't mangle a using directive name!");
1444 llvm_unreachable(
"Can't mangle a deduction guide name!");
1448 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1454 mangleTemplateArgs(
TemplateName(), TemplateArgs, NumTemplateArgs);
1457void CXXNameMangler::mangleUnqualifiedName(
1458 GlobalDecl GD, DeclarationName Name,
const DeclContext *DC,
1459 unsigned KnownArity,
const AbiTagList *AdditionalAbiTags) {
1460 const NamedDecl *ND = cast_or_null<NamedDecl>(GD.
getDecl());
1467 mangleModuleName(ND);
1471 auto *FD = dyn_cast<FunctionDecl>(ND);
1472 auto *FTD = dyn_cast<FunctionTemplateDecl>(ND);
1474 (FTD && FTD->getTemplatedDecl()->isMemberLikeConstrainedFriend())) {
1475 if (!isCompatibleWith(LangOptions::ClangABI::Ver17))
1479 unsigned Arity = KnownArity;
1485 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1492 for (
auto *BD : DD->bindings())
1493 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1495 writeAbiTags(ND, AdditionalAbiTags);
1499 if (
auto *GD = dyn_cast<MSGuidDecl>(ND)) {
1502 SmallString<
sizeof(
"_GUID_12345678_1234_1234_1234_1234567890ab")> GUID;
1503 llvm::raw_svector_ostream GUIDOS(GUID);
1504 Context.mangleMSGuidDecl(GD, GUIDOS);
1505 Out << GUID.size() << GUID;
1509 if (
auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
1512 mangleValueInTemplateArg(TPO->getType().getUnqualifiedType(),
1513 TPO->getValue(),
true);
1531 if (Context.isInternalLinkageDecl(ND))
1534 bool IsRegCall = FD &&
1538 FD && FD->
hasAttr<CUDAGlobalAttr>() &&
1540 bool IsOCLDeviceStub =
1542 DeviceKernelAttr::isOpenCLSpelling(FD->
getAttr<DeviceKernelAttr>()) &&
1545 mangleDeviceStubName(II);
1546 else if (IsOCLDeviceStub)
1547 mangleOCLDeviceStubName(II);
1549 mangleRegCallName(II);
1551 mangleSourceName(II);
1553 writeAbiTags(ND, AdditionalAbiTags);
1558 assert(ND &&
"mangling empty name without declaration");
1560 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1563 Out <<
"12_GLOBAL__N_1";
1568 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1570 const auto *RD = VD->getType()->castAsRecordDecl();
1581 assert(RD->isAnonymousStructOrUnion()
1582 &&
"Expected anonymous struct or union!");
1583 const FieldDecl *FD = RD->findFirstNamedDataMember();
1589 assert(FD->
getIdentifier() &&
"Data member name isn't an identifier!");
1609 "Typedef should not be in another decl context!");
1610 assert(D->getDeclName().getAsIdentifierInfo() &&
1611 "Typedef was not named!");
1612 mangleSourceName(D->getDeclName().getAsIdentifierInfo());
1613 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1616 writeAbiTags(TD,
nullptr);
1625 if (
const CXXRecordDecl *
Record = dyn_cast<CXXRecordDecl>(TD)) {
1626 UnsignedOrNone DeviceNumber =
1627 Context.getDiscriminatorOverride()(Context.getASTContext(),
Record);
1633 if (
Record->isLambda() &&
1634 ((DeviceNumber && *DeviceNumber > 0) ||
1635 (!DeviceNumber &&
Record->getLambdaManglingNumber() > 0))) {
1636 assert(!AdditionalAbiTags &&
1637 "Lambda type cannot have additional abi tags");
1644 unsigned UnnamedMangle =
1645 getASTContext().getManglingNumber(TD, Context.isAux());
1647 if (UnnamedMangle > 1)
1648 Out << UnnamedMangle - 2;
1650 writeAbiTags(TD, AdditionalAbiTags);
1656 unsigned AnonStructId =
1658 : Context.getAnonymousStructId(TD, dyn_cast<FunctionDecl>(DC));
1665 Str += llvm::utostr(AnonStructId);
1675 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1678 const CXXRecordDecl *InheritedFrom =
nullptr;
1680 const TemplateArgumentList *InheritedTemplateArgs =
nullptr;
1681 if (
auto Inherited =
1683 InheritedFrom = Inherited.getConstructor()->
getParent();
1684 InheritedTemplateName =
1685 TemplateName(Inherited.getConstructor()->getPrimaryTemplate());
1686 InheritedTemplateArgs =
1687 Inherited.getConstructor()->getTemplateSpecializationArgs();
1693 mangleCXXCtorType(
static_cast<CXXCtorType>(StructorType), InheritedFrom);
1701 if (InheritedTemplateArgs)
1702 mangleTemplateArgs(InheritedTemplateName, *InheritedTemplateArgs);
1704 writeAbiTags(ND, AdditionalAbiTags);
1712 mangleCXXDtorType(
static_cast<CXXDtorType>(StructorType));
1718 writeAbiTags(ND, AdditionalAbiTags);
1722 if (ND && Arity == UnknownArity) {
1726 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1727 if (MD->isImplicitObjectMemberFunction())
1733 mangleOperatorName(Name, Arity);
1734 writeAbiTags(ND, AdditionalAbiTags);
1738 llvm_unreachable(
"Can't mangle a deduction guide name!");
1741 llvm_unreachable(
"Can't mangle a using directive name!");
1745void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1749 if (getASTContext().getLangOpts().RegCall4)
1750 Out << II->
getLength() +
sizeof(
"__regcall4__") - 1 <<
"__regcall4__"
1753 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__"
1757void CXXNameMangler::mangleDeviceStubName(
const IdentifierInfo *II) {
1761 Out << II->
getLength() +
sizeof(
"__device_stub__") - 1 <<
"__device_stub__"
1765void CXXNameMangler::mangleOCLDeviceStubName(
const IdentifierInfo *II) {
1769 StringRef OCLDeviceStubNamePrefix =
"__clang_ocl_kern_imp_";
1770 Out << II->
getLength() + OCLDeviceStubNamePrefix.size()
1771 << OCLDeviceStubNamePrefix << II->
getName();
1774void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1781void CXXNameMangler::mangleNestedName(GlobalDecl GD,
1782 const DeclContext *DC,
1783 const AbiTagList *AdditionalAbiTags,
1792 if (
const CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(ND)) {
1793 Qualifiers MethodQuals =
Method->getMethodQualifiers();
1796 if (
Method->isExplicitObjectMemberFunction())
1799 mangleQualifiers(MethodQuals);
1800 mangleRefQualifier(
Method->getRefQualifier());
1804 const TemplateArgumentList *TemplateArgs =
nullptr;
1805 if (GlobalDecl TD =
isTemplate(GD, TemplateArgs)) {
1806 mangleTemplatePrefix(TD, NoFunction);
1809 manglePrefix(DC, NoFunction);
1810 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1815void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1816 ArrayRef<TemplateArgument> Args) {
1821 mangleTemplatePrefix(TD);
1827void CXXNameMangler::mangleNestedNameWithClosurePrefix(
1828 GlobalDecl GD,
const NamedDecl *PrefixND,
1829 const AbiTagList *AdditionalAbiTags) {
1838 mangleClosurePrefix(PrefixND);
1839 mangleUnqualifiedName(GD,
nullptr, AdditionalAbiTags);
1850 if (
auto *CD = dyn_cast<CXXConstructorDecl>(DC))
1852 else if (
auto *DD = dyn_cast<CXXDestructorDecl>(DC))
1859void CXXNameMangler::mangleLocalName(GlobalDecl GD,
1860 const AbiTagList *AdditionalAbiTags) {
1868 const RecordDecl *RD = GetLocalClassDecl(D);
1869 const DeclContext *DC = Context.getEffectiveDeclContext(RD ? RD : D);
1874 AbiTagState LocalAbiTags(AbiTags);
1876 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(DC))
1878 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1879 mangleBlockForPrefix(BD);
1885 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1899 const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD);
1901 if (
const ParmVarDecl *Parm
1903 if (
const FunctionDecl *
Func
1908 mangleNumber(
Num - 2);
1917 mangleUnqualifiedName(RD, DC, AdditionalAbiTags);
1918 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1919 if (
const NamedDecl *PrefixND = getClosurePrefix(BD))
1920 mangleClosurePrefix(PrefixND,
true );
1922 manglePrefix(Context.getEffectiveDeclContext(BD),
true );
1923 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1924 mangleUnqualifiedBlock(BD);
1927 mangleNestedName(GD, Context.getEffectiveDeclContext(ND),
1928 AdditionalAbiTags,
true );
1930 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1933 if (
const ParmVarDecl *Parm
1934 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1935 if (
const FunctionDecl *
Func
1940 mangleNumber(
Num - 2);
1945 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1946 mangleUnqualifiedBlock(BD);
1948 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1951 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1953 if (Context.getNextDiscriminator(ND, disc)) {
1957 Out <<
"__" << disc <<
'_';
1962void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *
Block) {
1963 if (GetLocalClassDecl(
Block)) {
1964 mangleLocalName(
Block,
nullptr);
1967 const DeclContext *DC = Context.getEffectiveDeclContext(
Block);
1968 if (isLocalContainerContext(DC)) {
1969 mangleLocalName(
Block,
nullptr);
1972 if (
const NamedDecl *PrefixND = getClosurePrefix(
Block))
1973 mangleClosurePrefix(PrefixND);
1976 mangleUnqualifiedBlock(
Block);
1979void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *
Block) {
1982 if (Decl *Context =
Block->getBlockManglingContextDecl()) {
1983 if (isCompatibleWith(LangOptions::ClangABI::Ver12) &&
1985 Context->getDeclContext()->isRecord()) {
1988 mangleSourceNameWithAbiTags(ND);
1995 unsigned Number =
Block->getBlockManglingNumber();
1999 Number = Context.getBlockId(
Block,
false);
2017void CXXNameMangler::mangleTemplateParamDecl(
const NamedDecl *Decl) {
2019 if (
auto *Ty = dyn_cast<TemplateTypeParmDecl>(Decl)) {
2020 if (Ty->isParameterPack())
2022 const TypeConstraint *Constraint = Ty->getTypeConstraint();
2023 if (Constraint && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
2026 mangleTypeConstraint(Constraint);
2030 }
else if (
auto *Tn = dyn_cast<NonTypeTemplateParmDecl>(Decl)) {
2031 if (Tn->isExpandedParameterPack()) {
2032 for (
unsigned I = 0, N = Tn->getNumExpansionTypes(); I != N; ++I) {
2034 mangleType(Tn->getExpansionType(I));
2037 QualType
T = Tn->getType();
2038 if (Tn->isParameterPack()) {
2040 if (
auto *PackExpansion =
T->
getAs<PackExpansionType>())
2041 T = PackExpansion->getPattern();
2046 }
else if (
auto *Tt = dyn_cast<TemplateTemplateParmDecl>(Decl)) {
2047 if (Tt->isExpandedParameterPack()) {
2048 for (
unsigned I = 0, N = Tt->getNumExpansionTemplateParameters(); I != N;
2050 mangleTemplateParameterList(Tt->getExpansionTemplateParameters(I));
2052 if (Tt->isParameterPack())
2054 mangleTemplateParameterList(Tt->getTemplateParameters());
2059void CXXNameMangler::mangleTemplateParameterList(
2060 const TemplateParameterList *Params) {
2062 for (
auto *Param : *Params)
2063 mangleTemplateParamDecl(Param);
2064 mangleRequiresClause(Params->getRequiresClause());
2068void CXXNameMangler::mangleTypeConstraint(
2069 const TemplateDecl *
Concept, ArrayRef<TemplateArgument> Arguments) {
2070 const DeclContext *DC = Context.getEffectiveDeclContext(
Concept);
2072 mangleTemplateName(
Concept, Arguments);
2074 mangleUnscopedName(
Concept, DC,
nullptr);
2076 mangleNestedName(
Concept, DC,
nullptr);
2079void CXXNameMangler::mangleTypeConstraint(
const TypeConstraint *Constraint) {
2080 llvm::SmallVector<TemplateArgument, 8> Args;
2082 for (
const TemplateArgumentLoc &ArgLoc :
2084 Args.push_back(ArgLoc.getArgument());
2089void CXXNameMangler::mangleRequiresClause(
const Expr *RequiresClause) {
2091 if (RequiresClause && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
2093 mangleExpression(RequiresClause);
2097void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
2101 if (isCompatibleWith(LangOptions::ClangABI::Ver12) &&
2104 if (
const IdentifierInfo *Name
2106 mangleSourceName(Name);
2107 const TemplateArgumentList *TemplateArgs =
nullptr;
2116 mangleLambdaSig(Lambda);
2130 UnsignedOrNone DeviceNumber =
2131 Context.getDiscriminatorOverride()(Context.getASTContext(), Lambda);
2135 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
2137 mangleNumber(Number - 2);
2141void CXXNameMangler::mangleLambdaSig(
const CXXRecordDecl *Lambda) {
2144 mangleTemplateParamDecl(D);
2148 mangleRequiresClause(TPL->getRequiresClause());
2152 mangleBareFunctionType(Proto,
false,
2156void CXXNameMangler::manglePrefix(NestedNameSpecifier Qualifier) {
2158 case NestedNameSpecifier::Kind::Null:
2159 case NestedNameSpecifier::Kind::Global:
2163 case NestedNameSpecifier::Kind::MicrosoftSuper:
2164 llvm_unreachable(
"Can't mangle __super specifier");
2166 case NestedNameSpecifier::Kind::Namespace:
2167 mangleName(
Qualifier.getAsNamespaceAndPrefix().Namespace->getNamespace());
2170 case NestedNameSpecifier::Kind::Type:
2171 manglePrefix(QualType(
Qualifier.getAsType(), 0));
2175 llvm_unreachable(
"unexpected nested name specifier");
2178void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
2191 if (NoFunction && isLocalContainerContext(DC))
2195 if (mangleSubstitution(ND))
2199 const TemplateArgumentList *TemplateArgs =
nullptr;
2200 if (GlobalDecl TD =
isTemplate(ND, TemplateArgs)) {
2201 mangleTemplatePrefix(TD);
2203 }
else if (
const NamedDecl *PrefixND = getClosurePrefix(ND)) {
2204 mangleClosurePrefix(PrefixND, NoFunction);
2205 mangleUnqualifiedName(ND,
nullptr,
nullptr);
2207 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
2208 manglePrefix(DC, NoFunction);
2209 mangleUnqualifiedName(ND, DC,
nullptr);
2212 addSubstitution(ND);
2219 if (TemplateDecl *TD =
Template.getAsTemplateDecl())
2220 return mangleTemplatePrefix(TD);
2223 assert(
Dependent &&
"unexpected template name kind");
2227 bool Clang11Compat = isCompatibleWith(LangOptions::ClangABI::Ver11);
2228 if (!Clang11Compat && mangleSubstitution(
Template))
2231 manglePrefix(
Dependent->getQualifier());
2233 if (Clang11Compat && mangleSubstitution(
Template))
2236 if (IdentifierOrOverloadedOperator Name =
Dependent->getName();
2237 const IdentifierInfo *Id = Name.getIdentifier())
2238 mangleSourceName(Id);
2240 mangleOperatorName(Name.getOperator(), UnknownArity);
2245void CXXNameMangler::mangleTemplatePrefix(GlobalDecl GD,
2254 if (mangleSubstitution(ND))
2258 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
2259 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
2261 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
2262 manglePrefix(DC, NoFunction);
2264 mangleUnqualifiedName(GD, DC,
nullptr);
2270 addSubstitution(ND);
2273const NamedDecl *CXXNameMangler::getClosurePrefix(
const Decl *ND) {
2274 if (isCompatibleWith(LangOptions::ClangABI::Ver12))
2277 const NamedDecl *Context =
nullptr;
2278 if (
auto *
Block = dyn_cast<BlockDecl>(ND)) {
2279 Context = dyn_cast_or_null<NamedDecl>(
Block->getBlockManglingContextDecl());
2280 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
2282 Context = dyn_cast_or_null<NamedDecl>(RD->getLambdaContextDecl());
2296void CXXNameMangler::mangleClosurePrefix(
const NamedDecl *ND,
bool NoFunction) {
2299 if (mangleSubstitution(ND))
2302 const TemplateArgumentList *TemplateArgs =
nullptr;
2303 if (GlobalDecl TD =
isTemplate(ND, TemplateArgs)) {
2304 mangleTemplatePrefix(TD, NoFunction);
2307 const auto *DC = Context.getEffectiveDeclContext(ND);
2308 manglePrefix(DC, NoFunction);
2309 mangleUnqualifiedName(ND, DC,
nullptr);
2314 addSubstitution(ND);
2323 if (mangleSubstitution(TN))
2326 TemplateDecl *TD =
nullptr;
2336 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TD))
2337 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
2344 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
2353 mangleUnresolvedPrefix(
Dependent->getQualifier());
2354 mangleSourceName(II);
2363 SubstTemplateTemplateParmStorage *subst
2374 Out <<
"_SUBSTPACK_";
2378 llvm_unreachable(
"Unexpected DeducedTemplate");
2381 addSubstitution(TN);
2384bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(QualType Ty,
2390 case Type::Adjusted:
2392 case Type::ArrayParameter:
2394 case Type::BlockPointer:
2395 case Type::LValueReference:
2396 case Type::RValueReference:
2397 case Type::MemberPointer:
2398 case Type::ConstantArray:
2399 case Type::IncompleteArray:
2400 case Type::VariableArray:
2401 case Type::DependentSizedArray:
2402 case Type::DependentAddressSpace:
2403 case Type::DependentVector:
2404 case Type::DependentSizedExtVector:
2406 case Type::ExtVector:
2407 case Type::ConstantMatrix:
2408 case Type::DependentSizedMatrix:
2409 case Type::FunctionProto:
2410 case Type::FunctionNoProto:
2412 case Type::Attributed:
2413 case Type::BTFTagAttributed:
2414 case Type::HLSLAttributedResource:
2415 case Type::HLSLInlineSpirv:
2417 case Type::DeducedTemplateSpecialization:
2418 case Type::PackExpansion:
2419 case Type::ObjCObject:
2420 case Type::ObjCInterface:
2421 case Type::ObjCObjectPointer:
2422 case Type::ObjCTypeParam:
2425 case Type::MacroQualified:
2427 case Type::DependentBitInt:
2428 case Type::CountAttributed:
2429 llvm_unreachable(
"type is illegal as a nested name specifier");
2431 case Type::SubstBuiltinTemplatePack:
2436 Out <<
"_SUBSTBUILTINPACK_";
2438 case Type::SubstTemplateTypeParmPack:
2443 Out <<
"_SUBSTPACK_";
2450 case Type::TypeOfExpr:
2452 case Type::Decltype:
2453 case Type::PackIndexing:
2454 case Type::TemplateTypeParm:
2455 case Type::UnaryTransform:
2468 case Type::SubstTemplateTypeParm: {
2472 if (
auto *TD = dyn_cast<TemplateDecl>(ST->getAssociatedDecl());
2474 return mangleUnresolvedTypeOrSimpleId(ST->getReplacementType(), Prefix);
2475 goto unresolvedType;
2482 case Type::PredefinedSugar:
2486 case Type::UnresolvedUsing:
2487 mangleSourceNameWithAbiTags(
2493 mangleSourceNameWithAbiTags(
2497 case Type::TemplateSpecialization: {
2498 const TemplateSpecializationType *TST =
2508 assert(TD &&
"no template for template specialization type");
2510 goto unresolvedType;
2512 mangleSourceNameWithAbiTags(TD);
2524 llvm_unreachable(
"invalid base for a template specialization type");
2527 SubstTemplateTemplateParmStorage *subst =
2538 Out <<
"_SUBSTPACK_";
2544 mangleSourceNameWithAbiTags(TD);
2554 mangleTemplateArgs(
TemplateName(), TST->template_arguments());
2558 case Type::InjectedClassName:
2564 case Type::DependentName:
2576void CXXNameMangler::mangleOperatorName(DeclarationName Name,
unsigned Arity) {
2586 llvm_unreachable(
"Not an operator name");
2609 case OO_New:
Out <<
"nw";
break;
2611 case OO_Array_New:
Out <<
"na";
break;
2613 case OO_Delete:
Out <<
"dl";
break;
2615 case OO_Array_Delete:
Out <<
"da";
break;
2619 Out << (Arity == 1?
"ps" :
"pl");
break;
2623 Out << (Arity == 1?
"ng" :
"mi");
break;
2627 Out << (Arity == 1?
"ad" :
"an");
break;
2632 Out << (Arity == 1?
"de" :
"ml");
break;
2634 case OO_Tilde:
Out <<
"co";
break;
2636 case OO_Slash:
Out <<
"dv";
break;
2638 case OO_Percent:
Out <<
"rm";
break;
2640 case OO_Pipe:
Out <<
"or";
break;
2642 case OO_Caret:
Out <<
"eo";
break;
2644 case OO_Equal:
Out <<
"aS";
break;
2646 case OO_PlusEqual:
Out <<
"pL";
break;
2648 case OO_MinusEqual:
Out <<
"mI";
break;
2650 case OO_StarEqual:
Out <<
"mL";
break;
2652 case OO_SlashEqual:
Out <<
"dV";
break;
2654 case OO_PercentEqual:
Out <<
"rM";
break;
2656 case OO_AmpEqual:
Out <<
"aN";
break;
2658 case OO_PipeEqual:
Out <<
"oR";
break;
2660 case OO_CaretEqual:
Out <<
"eO";
break;
2662 case OO_LessLess:
Out <<
"ls";
break;
2664 case OO_GreaterGreater:
Out <<
"rs";
break;
2666 case OO_LessLessEqual:
Out <<
"lS";
break;
2668 case OO_GreaterGreaterEqual:
Out <<
"rS";
break;
2670 case OO_EqualEqual:
Out <<
"eq";
break;
2672 case OO_ExclaimEqual:
Out <<
"ne";
break;
2674 case OO_Less:
Out <<
"lt";
break;
2676 case OO_Greater:
Out <<
"gt";
break;
2678 case OO_LessEqual:
Out <<
"le";
break;
2680 case OO_GreaterEqual:
Out <<
"ge";
break;
2682 case OO_Exclaim:
Out <<
"nt";
break;
2684 case OO_AmpAmp:
Out <<
"aa";
break;
2686 case OO_PipePipe:
Out <<
"oo";
break;
2688 case OO_PlusPlus:
Out <<
"pp";
break;
2690 case OO_MinusMinus:
Out <<
"mm";
break;
2692 case OO_Comma:
Out <<
"cm";
break;
2694 case OO_ArrowStar:
Out <<
"pm";
break;
2696 case OO_Arrow:
Out <<
"pt";
break;
2698 case OO_Call:
Out <<
"cl";
break;
2700 case OO_Subscript:
Out <<
"ix";
break;
2705 case OO_Conditional:
Out <<
"qu";
break;
2708 case OO_Coawait:
Out <<
"aw";
break;
2711 case OO_Spaceship:
Out <<
"ss";
break;
2715 llvm_unreachable(
"Not an overloaded operator");
2719void CXXNameMangler::mangleQualifiers(Qualifiers Quals,
const DependentAddressSpaceType *DAST) {
2738 SmallString<64> ASString;
2744 if (TargetAS != 0 ||
2746 ASString =
"AS" + llvm::utostr(TargetAS);
2749 default: llvm_unreachable(
"Not a language specific address space");
2753 case LangAS::opencl_global:
2754 ASString =
"CLglobal";
2756 case LangAS::opencl_global_device:
2757 ASString =
"CLdevice";
2759 case LangAS::opencl_global_host:
2760 ASString =
"CLhost";
2762 case LangAS::opencl_local:
2763 ASString =
"CLlocal";
2765 case LangAS::opencl_constant:
2766 ASString =
"CLconstant";
2768 case LangAS::opencl_private:
2769 ASString =
"CLprivate";
2771 case LangAS::opencl_generic:
2772 ASString =
"CLgeneric";
2776 case LangAS::sycl_global:
2777 ASString =
"SYglobal";
2779 case LangAS::sycl_global_device:
2780 ASString =
"SYdevice";
2782 case LangAS::sycl_global_host:
2783 ASString =
"SYhost";
2785 case LangAS::sycl_local:
2786 ASString =
"SYlocal";
2788 case LangAS::sycl_private:
2789 ASString =
"SYprivate";
2792 case LangAS::cuda_device:
2793 ASString =
"CUdevice";
2795 case LangAS::cuda_constant:
2796 ASString =
"CUconstant";
2798 case LangAS::cuda_shared:
2799 ASString =
"CUshared";
2802 case LangAS::ptr32_sptr:
2803 ASString =
"ptr32_sptr";
2805 case LangAS::ptr32_uptr:
2809 if (!getASTContext().getTargetInfo().getTriple().isOSzOS())
2810 ASString =
"ptr32_uptr";
2817 if (!ASString.empty())
2818 mangleVendorQualifier(ASString);
2831 mangleVendorQualifier(
"__weak");
2835 mangleVendorQualifier(
"__unaligned");
2839 mangleVendorQualifier(
"__ptrauth");
2849 << unsigned(PtrAuth.isAddressDiscriminated())
2852 << PtrAuth.getExtraDiscriminator()
2867 mangleVendorQualifier(
"__strong");
2871 mangleVendorQualifier(
"__autoreleasing");
2894void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2898void CXXNameMangler::mangleVendorType(StringRef name) {
2905 switch (RefQualifier) {
2919void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2920 Context.mangleObjCMethodNameAsSourceName(MD, Out);
2933 Ctx.
getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver17)
2939 if (Ctx.
getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver6 &&
2945 if (
auto *DeducedTST = Ty->
getAs<DeducedTemplateSpecializationType>())
2946 if (DeducedTST->getDeducedType().isNull())
2951void CXXNameMangler::mangleType(QualType
T) {
2985 T =
T.getCanonicalType();
2991 if (
const TemplateSpecializationType *TST
2992 = dyn_cast<TemplateSpecializationType>(
T))
2993 if (!TST->isTypeAlias())
3001 =
T.getSingleStepDesugaredType(Context.getASTContext());
3008 SplitQualType split =
T.split();
3009 Qualifiers quals = split.
Quals;
3010 const Type *ty = split.
Ty;
3012 bool isSubstitutable =
3014 if (isSubstitutable && mangleSubstitution(
T))
3021 quals = Qualifiers();
3028 if (
const DependentAddressSpaceType *DAST =
3029 dyn_cast<DependentAddressSpaceType>(ty)) {
3031 mangleQualifiers(splitDAST.
Quals, DAST);
3032 mangleType(QualType(splitDAST.
Ty, 0));
3034 mangleQualifiers(quals);
3038 mangleType(QualType(ty, 0));
3042#define ABSTRACT_TYPE(CLASS, PARENT)
3043#define NON_CANONICAL_TYPE(CLASS, PARENT) \
3045 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
3047#define TYPE(CLASS, PARENT) \
3049 mangleType(static_cast<const CLASS##Type*>(ty)); \
3051#include "clang/AST/TypeNodes.inc"
3056 if (isSubstitutable)
3060void CXXNameMangler::mangleCXXRecordDecl(
const CXXRecordDecl *
Record,
3061 bool SuppressSubstitution) {
3062 if (mangleSubstitution(
Record))
3065 if (SuppressSubstitution)
3070void CXXNameMangler::mangleType(
const BuiltinType *
T) {
3112 std::string type_name;
3116 if (NormalizeIntegers &&
T->isInteger()) {
3117 if (
T->isSignedInteger()) {
3118 switch (getASTContext().getTypeSize(
T)) {
3122 if (mangleSubstitution(BuiltinType::SChar))
3125 addSubstitution(BuiltinType::SChar);
3128 if (mangleSubstitution(BuiltinType::Short))
3131 addSubstitution(BuiltinType::Short);
3134 if (mangleSubstitution(BuiltinType::Int))
3137 addSubstitution(BuiltinType::Int);
3140 if (mangleSubstitution(BuiltinType::Long))
3143 addSubstitution(BuiltinType::Long);
3146 if (mangleSubstitution(BuiltinType::Int128))
3149 addSubstitution(BuiltinType::Int128);
3152 llvm_unreachable(
"Unknown integer size for normalization");
3155 switch (getASTContext().getTypeSize(
T)) {
3157 if (mangleSubstitution(BuiltinType::UChar))
3160 addSubstitution(BuiltinType::UChar);
3163 if (mangleSubstitution(BuiltinType::UShort))
3166 addSubstitution(BuiltinType::UShort);
3169 if (mangleSubstitution(BuiltinType::UInt))
3172 addSubstitution(BuiltinType::UInt);
3175 if (mangleSubstitution(BuiltinType::ULong))
3178 addSubstitution(BuiltinType::ULong);
3181 if (mangleSubstitution(BuiltinType::UInt128))
3184 addSubstitution(BuiltinType::UInt128);
3187 llvm_unreachable(
"Unknown integer size for normalization");
3192 switch (
T->getKind()) {
3193 case BuiltinType::Void:
3196 case BuiltinType::Bool:
3199 case BuiltinType::Char_U:
3200 case BuiltinType::Char_S:
3203 case BuiltinType::UChar:
3206 case BuiltinType::UShort:
3209 case BuiltinType::UInt:
3212 case BuiltinType::ULong:
3215 case BuiltinType::ULongLong:
3218 case BuiltinType::UInt128:
3221 case BuiltinType::SChar:
3224 case BuiltinType::WChar_S:
3225 case BuiltinType::WChar_U:
3228 case BuiltinType::Char8:
3231 case BuiltinType::Char16:
3234 case BuiltinType::Char32:
3237 case BuiltinType::Short:
3240 case BuiltinType::Int:
3243 case BuiltinType::Long:
3246 case BuiltinType::LongLong:
3249 case BuiltinType::Int128:
3252 case BuiltinType::Float16:
3255 case BuiltinType::ShortAccum:
3258 case BuiltinType::Accum:
3261 case BuiltinType::LongAccum:
3264 case BuiltinType::UShortAccum:
3267 case BuiltinType::UAccum:
3270 case BuiltinType::ULongAccum:
3273 case BuiltinType::ShortFract:
3276 case BuiltinType::Fract:
3279 case BuiltinType::LongFract:
3282 case BuiltinType::UShortFract:
3285 case BuiltinType::UFract:
3288 case BuiltinType::ULongFract:
3291 case BuiltinType::SatShortAccum:
3294 case BuiltinType::SatAccum:
3297 case BuiltinType::SatLongAccum:
3300 case BuiltinType::SatUShortAccum:
3303 case BuiltinType::SatUAccum:
3306 case BuiltinType::SatULongAccum:
3309 case BuiltinType::SatShortFract:
3312 case BuiltinType::SatFract:
3315 case BuiltinType::SatLongFract:
3318 case BuiltinType::SatUShortFract:
3321 case BuiltinType::SatUFract:
3324 case BuiltinType::SatULongFract:
3327 case BuiltinType::Half:
3330 case BuiltinType::Float:
3333 case BuiltinType::Double:
3336 case BuiltinType::LongDouble: {
3337 const TargetInfo *TI =
3338 getASTContext().getLangOpts().OpenMP &&
3339 getASTContext().getLangOpts().OpenMPIsTargetDevice
3340 ? getASTContext().getAuxTargetInfo()
3341 : &getASTContext().getTargetInfo();
3345 case BuiltinType::Float128: {
3346 const TargetInfo *TI =
3347 getASTContext().getLangOpts().OpenMP &&
3348 getASTContext().getLangOpts().OpenMPIsTargetDevice
3349 ? getASTContext().getAuxTargetInfo()
3350 : &getASTContext().getTargetInfo();
3354 case BuiltinType::BFloat16: {
3355 const TargetInfo *TI =
3356 ((getASTContext().getLangOpts().OpenMP &&
3357 getASTContext().getLangOpts().OpenMPIsTargetDevice) ||
3358 getASTContext().getLangOpts().SYCLIsDevice)
3359 ? getASTContext().getAuxTargetInfo()
3360 : &getASTContext().getTargetInfo();
3364 case BuiltinType::Ibm128: {
3365 const TargetInfo *TI = &getASTContext().getTargetInfo();
3369 case BuiltinType::NullPtr:
3373#define BUILTIN_TYPE(Id, SingletonId)
3374#define PLACEHOLDER_TYPE(Id, SingletonId) \
3375 case BuiltinType::Id:
3376#include "clang/AST/BuiltinTypes.def"
3377 case BuiltinType::Dependent:
3379 llvm_unreachable(
"mangling a placeholder type");
3381 case BuiltinType::ObjCId:
3382 Out <<
"11objc_object";
3384 case BuiltinType::ObjCClass:
3385 Out <<
"10objc_class";
3387 case BuiltinType::ObjCSel:
3388 Out <<
"13objc_selector";
3390#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3391 case BuiltinType::Id: \
3392 type_name = "ocl_" #ImgType "_" #Suffix; \
3393 Out << type_name.size() << type_name; \
3395#include "clang/Basic/OpenCLImageTypes.def"
3396 case BuiltinType::OCLSampler:
3397 Out <<
"11ocl_sampler";
3399 case BuiltinType::OCLEvent:
3400 Out <<
"9ocl_event";
3402 case BuiltinType::OCLClkEvent:
3403 Out <<
"12ocl_clkevent";
3405 case BuiltinType::OCLQueue:
3406 Out <<
"9ocl_queue";
3408 case BuiltinType::OCLReserveID:
3409 Out <<
"13ocl_reserveid";
3411#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3412 case BuiltinType::Id: \
3413 type_name = "ocl_" #ExtType; \
3414 Out << type_name.size() << type_name; \
3416#include "clang/Basic/OpenCLExtensionTypes.def"
3420#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
3421 case BuiltinType::Id: \
3422 if (T->getKind() == BuiltinType::SveBFloat16 && \
3423 isCompatibleWith(LangOptions::ClangABI::Ver17)) { \
3425 mangleVendorType("__SVBFloat16_t"); \
3427 type_name = #MangledName; \
3428 Out << (type_name == #Name ? "u" : "") << type_name.size() << type_name; \
3431#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
3432 case BuiltinType::Id: \
3433 type_name = #MangledName; \
3434 Out << (type_name == #Name ? "u" : "") << type_name.size() << type_name; \
3436#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
3437 case BuiltinType::Id: \
3438 type_name = #MangledName; \
3439 Out << (type_name == #Name ? "u" : "") << type_name.size() << type_name; \
3441#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
3442 case BuiltinType::Id: \
3443 type_name = #MangledName; \
3444 Out << (type_name == #Name ? "u" : "") << type_name.size() << type_name; \
3446#include "clang/Basic/AArch64ACLETypes.def"
3447#define PPC_VECTOR_TYPE(Name, Id, Size) \
3448 case BuiltinType::Id: \
3449 mangleVendorType(#Name); \
3451#include "clang/Basic/PPCTypes.def"
3453#define RVV_TYPE(Name, Id, SingletonId) \
3454 case BuiltinType::Id: \
3455 mangleVendorType(Name); \
3457#include "clang/Basic/RISCVVTypes.def"
3458#define WASM_REF_TYPE(InternalName, MangledName, Id, SingletonId, AS) \
3459 case BuiltinType::Id: \
3460 mangleVendorType(MangledName); \
3462#include "clang/Basic/WebAssemblyReferenceTypes.def"
3463#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
3464 case BuiltinType::Id: \
3465 mangleVendorType(Name); \
3467#include "clang/Basic/AMDGPUTypes.def"
3468#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3469 case BuiltinType::Id: \
3470 mangleVendorType(#Name); \
3472#include "clang/Basic/HLSLIntangibleTypes.def"
3476StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
3496#define CC_VLS_CASE(ABI_VLEN) case CC_RISCVVLSCall_##ABI_VLEN:
3532 return "swiftasynccall";
3534 llvm_unreachable(
"bad calling convention");
3537void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *
T) {
3546 StringRef CCQualifier = getCallingConvQualifierName(
T->
getExtInfo().
getCC());
3547 if (!CCQualifier.empty())
3548 mangleVendorQualifier(CCQualifier);
3581 llvm_unreachable(
"Unrecognised SME attribute");
3596void CXXNameMangler::mangleSMEAttrs(
unsigned SMEAttrs) {
3616 Out <<
"Lj" <<
static_cast<unsigned>(Bitmask) <<
"EE";
3620CXXNameMangler::mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo PI) {
3627 case ParameterABI::Ordinary:
3631 case ParameterABI::HLSLOut:
3632 case ParameterABI::HLSLInOut:
3637 case ParameterABI::SwiftContext:
3638 case ParameterABI::SwiftAsyncContext:
3639 case ParameterABI::SwiftErrorResult:
3640 case ParameterABI::SwiftIndirectResult:
3646 mangleVendorQualifier(
"ns_consumed");
3649 mangleVendorQualifier(
"noescape");
3655void CXXNameMangler::mangleType(
const FunctionProtoType *
T) {
3659 Out <<
"11__SME_ATTRSI";
3661 mangleExtFunctionInfo(
T);
3678 mangleType(ExceptTy);
3689 mangleBareFunctionType(
T,
true);
3696 mangleSMEAttrs(SMEAttrs);
3699void CXXNameMangler::mangleType(
const FunctionNoProtoType *
T) {
3705 FunctionTypeDepthState saved = FunctionTypeDepth.push();
3707 FunctionTypeDepth.enterResultType();
3709 FunctionTypeDepth.leaveResultType();
3711 FunctionTypeDepth.pop(saved);
3715void CXXNameMangler::mangleBareFunctionType(
const FunctionProtoType *Proto,
3716 bool MangleReturnType,
3717 const FunctionDecl *FD) {
3720 FunctionTypeDepthState saved = FunctionTypeDepth.push();
3723 if (MangleReturnType) {
3724 FunctionTypeDepth.enterResultType();
3728 mangleVendorQualifier(
"ns_returns_retained");
3733 auto SplitReturnTy = ReturnTy.
split();
3735 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
3737 mangleType(ReturnTy);
3739 FunctionTypeDepth.leaveResultType();
3747 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
3761 assert(Attr->getType() <= 9 && Attr->getType() >= 0);
3762 if (Attr->isDynamic())
3763 Out <<
"U25pass_dynamic_object_size" << Attr->getType();
3765 Out <<
"U17pass_object_size" << Attr->getType();
3776 FunctionTypeDepth.enterResultType();
3780 FunctionTypeDepth.pop(saved);
3785void CXXNameMangler::mangleType(
const UnresolvedUsingType *
T) {
3786 mangleName(
T->getDecl());
3791void CXXNameMangler::mangleType(
const EnumType *
T) {
3792 mangleType(
static_cast<const TagType*
>(
T));
3794void CXXNameMangler::mangleType(
const RecordType *
T) {
3795 mangleType(
static_cast<const TagType*
>(
T));
3797void CXXNameMangler::mangleType(
const TagType *
T) {
3798 mangleName(
T->getOriginalDecl()->getDefinitionOrSelf());
3804void CXXNameMangler::mangleType(
const ConstantArrayType *
T) {
3805 Out <<
'A' <<
T->getSize() <<
'_';
3806 mangleType(
T->getElementType());
3808void CXXNameMangler::mangleType(
const VariableArrayType *
T) {
3811 if (
T->getSizeExpr())
3812 mangleExpression(
T->getSizeExpr());
3814 mangleType(
T->getElementType());
3816void CXXNameMangler::mangleType(
const DependentSizedArrayType *
T) {
3821 if (
T->getSizeExpr())
3822 mangleExpression(
T->getSizeExpr());
3824 mangleType(
T->getElementType());
3826void CXXNameMangler::mangleType(
const IncompleteArrayType *
T) {
3828 mangleType(
T->getElementType());
3833void CXXNameMangler::mangleType(
const MemberPointerType *
T) {
3835 if (
auto *RD =
T->getMostRecentCXXRecordDecl())
3836 mangleCXXRecordDecl(RD);
3838 mangleType(QualType(
T->getQualifier().getAsType(), 0));
3840 if (
const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(PointeeType)) {
3861 mangleType(PointeeType);
3865void CXXNameMangler::mangleType(
const TemplateTypeParmType *
T) {
3866 mangleTemplateParameter(
T->getDepth(),
T->getIndex());
3870void CXXNameMangler::mangleType(
const SubstTemplateTypeParmPackType *
T) {
3875 Out <<
"_SUBSTPACK_";
3878void CXXNameMangler::mangleType(
const SubstBuiltinTemplatePackType *
T) {
3883 Out <<
"_SUBSTBUILTINPACK_";
3887void CXXNameMangler::mangleType(
const PointerType *
T) {
3891void CXXNameMangler::mangleType(
const ObjCObjectPointerType *
T) {
3897void CXXNameMangler::mangleType(
const LValueReferenceType *
T) {
3903void CXXNameMangler::mangleType(
const RValueReferenceType *
T) {
3909void CXXNameMangler::mangleType(
const ComplexType *
T) {
3911 mangleType(
T->getElementType());
3917void CXXNameMangler::mangleNeonVectorType(
const VectorType *
T) {
3918 QualType EltType =
T->getElementType();
3919 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3920 const char *EltName =
nullptr;
3921 if (
T->getVectorKind() == VectorKind::NeonPoly) {
3923 case BuiltinType::SChar:
3924 case BuiltinType::UChar:
3925 EltName =
"poly8_t";
3927 case BuiltinType::Short:
3928 case BuiltinType::UShort:
3929 EltName =
"poly16_t";
3931 case BuiltinType::LongLong:
3932 case BuiltinType::ULongLong:
3933 EltName =
"poly64_t";
3935 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
3939 case BuiltinType::SChar: EltName =
"int8_t";
break;
3940 case BuiltinType::UChar: EltName =
"uint8_t";
break;
3941 case BuiltinType::Short: EltName =
"int16_t";
break;
3942 case BuiltinType::UShort: EltName =
"uint16_t";
break;
3943 case BuiltinType::Int: EltName =
"int32_t";
break;
3944 case BuiltinType::UInt: EltName =
"uint32_t";
break;
3945 case BuiltinType::LongLong: EltName =
"int64_t";
break;
3946 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
3947 case BuiltinType::Double: EltName =
"float64_t";
break;
3948 case BuiltinType::Float: EltName =
"float32_t";
break;
3949 case BuiltinType::Half: EltName =
"float16_t";
break;
3950 case BuiltinType::BFloat16: EltName =
"bfloat16_t";
break;
3951 case BuiltinType::MFloat8:
3952 EltName =
"mfloat8_t";
3955 llvm_unreachable(
"unexpected Neon vector element type");
3958 const char *BaseName =
nullptr;
3959 unsigned BitSize = (
T->getNumElements() *
3960 getASTContext().getTypeSize(EltType));
3962 BaseName =
"__simd64_";
3964 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
3965 BaseName =
"__simd128_";
3967 Out << strlen(BaseName) + strlen(EltName);
3968 Out << BaseName << EltName;
3971void CXXNameMangler::mangleNeonVectorType(
const DependentVectorType *
T) {
3972 DiagnosticsEngine &Diags = Context.getDiags();
3975 "cannot mangle this dependent neon vector type yet");
3976 Diags.
Report(
T->getAttributeLoc(), DiagID);
3981 case BuiltinType::SChar:
3983 case BuiltinType::Short:
3985 case BuiltinType::Int:
3987 case BuiltinType::Long:
3988 case BuiltinType::LongLong:
3990 case BuiltinType::UChar:
3992 case BuiltinType::UShort:
3994 case BuiltinType::UInt:
3996 case BuiltinType::ULong:
3997 case BuiltinType::ULongLong:
3999 case BuiltinType::Half:
4001 case BuiltinType::Float:
4003 case BuiltinType::Double:
4005 case BuiltinType::BFloat16:
4007 case BuiltinType::MFloat8:
4010 llvm_unreachable(
"Unexpected vector element base type");
4017void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *
T) {
4018 QualType EltType =
T->getElementType();
4019 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
4021 (
T->getNumElements() * getASTContext().getTypeSize(EltType));
4024 assert((BitSize == 64 || BitSize == 128) &&
4025 "Neon vector type not 64 or 128 bits");
4028 if (
T->getVectorKind() == VectorKind::NeonPoly) {
4030 case BuiltinType::UChar:
4033 case BuiltinType::UShort:
4036 case BuiltinType::ULong:
4037 case BuiltinType::ULongLong:
4041 llvm_unreachable(
"unexpected Neon polynomial vector element type");
4047 (
"__" + EltName +
"x" + Twine(
T->getNumElements()) +
"_t").str();
4050void CXXNameMangler::mangleAArch64NeonVectorType(
const DependentVectorType *
T) {
4051 DiagnosticsEngine &Diags = Context.getDiags();
4054 "cannot mangle this dependent neon vector type yet");
4055 Diags.
Report(
T->getAttributeLoc(), DiagID);
4082void CXXNameMangler::mangleAArch64FixedSveVectorType(
const VectorType *
T) {
4083 assert((
T->getVectorKind() == VectorKind::SveFixedLengthData ||
4084 T->getVectorKind() == VectorKind::SveFixedLengthPredicate) &&
4085 "expected fixed-length SVE vector!");
4087 QualType EltType =
T->getElementType();
4089 "expected builtin type for fixed-length SVE vector!");
4093 case BuiltinType::SChar:
4096 case BuiltinType::UChar: {
4097 if (
T->getVectorKind() == VectorKind::SveFixedLengthData)
4103 case BuiltinType::Short:
4106 case BuiltinType::UShort:
4109 case BuiltinType::Int:
4112 case BuiltinType::UInt:
4115 case BuiltinType::Long:
4118 case BuiltinType::ULong:
4121 case BuiltinType::Half:
4124 case BuiltinType::Float:
4127 case BuiltinType::Double:
4130 case BuiltinType::BFloat16:
4134 llvm_unreachable(
"unexpected element type for fixed-length SVE vector!");
4137 unsigned VecSizeInBits = getASTContext().getTypeInfo(
T).Width;
4139 if (
T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
4142 Out <<
"9__SVE_VLSI";
4143 mangleVendorType(TypeName);
4144 Out <<
"Lj" << VecSizeInBits <<
"EE";
4147void CXXNameMangler::mangleAArch64FixedSveVectorType(
4148 const DependentVectorType *
T) {
4149 DiagnosticsEngine &Diags = Context.getDiags();
4152 "cannot mangle this dependent fixed-length SVE vector type yet");
4153 Diags.
Report(
T->getAttributeLoc(), DiagID);
4156void CXXNameMangler::mangleRISCVFixedRVVVectorType(
const VectorType *
T) {
4157 assert((
T->getVectorKind() == VectorKind::RVVFixedLengthData ||
4158 T->getVectorKind() == VectorKind::RVVFixedLengthMask ||
4159 T->getVectorKind() == VectorKind::RVVFixedLengthMask_1 ||
4160 T->getVectorKind() == VectorKind::RVVFixedLengthMask_2 ||
4161 T->getVectorKind() == VectorKind::RVVFixedLengthMask_4) &&
4162 "expected fixed-length RVV vector!");
4164 QualType EltType =
T->getElementType();
4166 "expected builtin type for fixed-length RVV vector!");
4168 SmallString<20> TypeNameStr;
4169 llvm::raw_svector_ostream TypeNameOS(TypeNameStr);
4170 TypeNameOS <<
"__rvv_";
4172 case BuiltinType::SChar:
4173 TypeNameOS <<
"int8";
4175 case BuiltinType::UChar:
4176 if (
T->getVectorKind() == VectorKind::RVVFixedLengthData)
4177 TypeNameOS <<
"uint8";
4179 TypeNameOS <<
"bool";
4181 case BuiltinType::Short:
4182 TypeNameOS <<
"int16";
4184 case BuiltinType::UShort:
4185 TypeNameOS <<
"uint16";
4187 case BuiltinType::Int:
4188 TypeNameOS <<
"int32";
4190 case BuiltinType::UInt:
4191 TypeNameOS <<
"uint32";
4193 case BuiltinType::Long:
4194 TypeNameOS <<
"int64";
4196 case BuiltinType::ULong:
4197 TypeNameOS <<
"uint64";
4199 case BuiltinType::Float16:
4200 TypeNameOS <<
"float16";
4202 case BuiltinType::Float:
4203 TypeNameOS <<
"float32";
4205 case BuiltinType::Double:
4206 TypeNameOS <<
"float64";
4209 llvm_unreachable(
"unexpected element type for fixed-length RVV vector!");
4212 unsigned VecSizeInBits;
4213 switch (
T->getVectorKind()) {
4214 case VectorKind::RVVFixedLengthMask_1:
4217 case VectorKind::RVVFixedLengthMask_2:
4220 case VectorKind::RVVFixedLengthMask_4:
4224 VecSizeInBits = getASTContext().getTypeInfo(
T).Width;
4229 auto VScale = getASTContext().getTargetInfo().getVScaleRange(
4230 getASTContext().getLangOpts(),
4231 TargetInfo::ArmStreamingKind::NotStreaming);
4232 unsigned VLen = VScale->first * llvm::RISCV::RVVBitsPerBlock;
4234 if (
T->getVectorKind() == VectorKind::RVVFixedLengthData) {
4236 if (VecSizeInBits >= VLen)
4237 TypeNameOS << (VecSizeInBits / VLen);
4239 TypeNameOS <<
'f' << (VLen / VecSizeInBits);
4241 TypeNameOS << (VLen / VecSizeInBits);
4245 Out <<
"9__RVV_VLSI";
4246 mangleVendorType(TypeNameStr);
4247 Out <<
"Lj" << VecSizeInBits <<
"EE";
4250void CXXNameMangler::mangleRISCVFixedRVVVectorType(
4251 const DependentVectorType *
T) {
4252 DiagnosticsEngine &Diags = Context.getDiags();
4255 "cannot mangle this dependent fixed-length RVV vector type yet");
4256 Diags.
Report(
T->getAttributeLoc(), DiagID);
4267void CXXNameMangler::mangleType(
const VectorType *
T) {
4268 if ((
T->getVectorKind() == VectorKind::Neon ||
4269 T->getVectorKind() == VectorKind::NeonPoly)) {
4270 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
4271 llvm::Triple::ArchType
Arch =
4272 getASTContext().getTargetInfo().getTriple().getArch();
4273 if ((
Arch == llvm::Triple::aarch64 ||
4274 Arch == llvm::Triple::aarch64_be) && !
Target.isOSDarwin())
4275 mangleAArch64NeonVectorType(
T);
4277 mangleNeonVectorType(
T);
4279 }
else if (
T->getVectorKind() == VectorKind::SveFixedLengthData ||
4280 T->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
4281 mangleAArch64FixedSveVectorType(
T);
4283 }
else if (
T->getVectorKind() == VectorKind::RVVFixedLengthData ||
4284 T->getVectorKind() == VectorKind::RVVFixedLengthMask ||
4285 T->getVectorKind() == VectorKind::RVVFixedLengthMask_1 ||
4286 T->getVectorKind() == VectorKind::RVVFixedLengthMask_2 ||
4287 T->getVectorKind() == VectorKind::RVVFixedLengthMask_4) {
4288 mangleRISCVFixedRVVVectorType(
T);
4291 Out <<
"Dv" <<
T->getNumElements() <<
'_';
4292 if (
T->getVectorKind() == VectorKind::AltiVecPixel)
4294 else if (
T->getVectorKind() == VectorKind::AltiVecBool)
4297 mangleType(
T->getElementType());
4300void CXXNameMangler::mangleType(
const DependentVectorType *
T) {
4301 if ((
T->getVectorKind() == VectorKind::Neon ||
4302 T->getVectorKind() == VectorKind::NeonPoly)) {
4303 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
4304 llvm::Triple::ArchType
Arch =
4305 getASTContext().getTargetInfo().getTriple().getArch();
4306 if ((
Arch == llvm::Triple::aarch64 ||
Arch == llvm::Triple::aarch64_be) &&
4308 mangleAArch64NeonVectorType(
T);
4310 mangleNeonVectorType(
T);
4312 }
else if (
T->getVectorKind() == VectorKind::SveFixedLengthData ||
4313 T->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
4314 mangleAArch64FixedSveVectorType(
T);
4316 }
else if (
T->getVectorKind() == VectorKind::RVVFixedLengthData) {
4317 mangleRISCVFixedRVVVectorType(
T);
4322 mangleExpression(
T->getSizeExpr());
4324 if (
T->getVectorKind() == VectorKind::AltiVecPixel)
4326 else if (
T->getVectorKind() == VectorKind::AltiVecBool)
4329 mangleType(
T->getElementType());
4332void CXXNameMangler::mangleType(
const ExtVectorType *
T) {
4333 mangleType(
static_cast<const VectorType*
>(
T));
4335void CXXNameMangler::mangleType(
const DependentSizedExtVectorType *
T) {
4337 mangleExpression(
T->getSizeExpr());
4339 mangleType(
T->getElementType());
4342void CXXNameMangler::mangleType(
const ConstantMatrixType *
T) {
4346 mangleVendorType(
"matrix_type");
4349 auto &ASTCtx = getASTContext();
4350 unsigned BitWidth = ASTCtx.getTypeSize(ASTCtx.getSizeType());
4351 llvm::APSInt Rows(BitWidth);
4352 Rows =
T->getNumRows();
4353 mangleIntegerLiteral(ASTCtx.getSizeType(), Rows);
4354 llvm::APSInt Columns(BitWidth);
4355 Columns =
T->getNumColumns();
4356 mangleIntegerLiteral(ASTCtx.getSizeType(), Columns);
4357 mangleType(
T->getElementType());
4361void CXXNameMangler::mangleType(
const DependentSizedMatrixType *
T) {
4364 mangleVendorType(
"matrix_type");
4367 mangleTemplateArgExpr(
T->getRowExpr());
4368 mangleTemplateArgExpr(
T->getColumnExpr());
4369 mangleType(
T->getElementType());
4373void CXXNameMangler::mangleType(
const DependentAddressSpaceType *
T) {
4375 mangleQualifiers(split.
Quals,
T);
4376 mangleType(QualType(split.
Ty, 0));
4379void CXXNameMangler::mangleType(
const PackExpansionType *
T) {
4382 mangleType(
T->getPattern());
4385void CXXNameMangler::mangleType(
const PackIndexingType *
T) {
4386 if (!
T->hasSelectedType())
4387 mangleType(
T->getPattern());
4389 mangleType(
T->getSelectedType());
4392void CXXNameMangler::mangleType(
const ObjCInterfaceType *
T) {
4393 mangleSourceName(
T->getDecl()->getIdentifier());
4396void CXXNameMangler::mangleType(
const ObjCObjectType *
T) {
4398 if (
T->isKindOfType())
4399 Out <<
"U8__kindof";
4401 if (!
T->qual_empty()) {
4403 SmallString<64> QualStr;
4404 llvm::raw_svector_ostream QualOS(QualStr);
4405 QualOS <<
"objcproto";
4406 for (
const auto *I :
T->quals()) {
4407 StringRef
name = I->getName();
4410 mangleVendorQualifier(QualStr);
4413 mangleType(
T->getBaseType());
4415 if (
T->isSpecialized()) {
4418 for (
auto typeArg :
T->getTypeArgs())
4419 mangleType(typeArg);
4424void CXXNameMangler::mangleType(
const BlockPointerType *
T) {
4425 Out <<
"U13block_pointer";
4429void CXXNameMangler::mangleType(
const InjectedClassNameType *
T) {
4433 mangleType(
T->getOriginalDecl()->getCanonicalTemplateSpecializationType(
4437void CXXNameMangler::mangleType(
const TemplateSpecializationType *
T) {
4438 if (TemplateDecl *TD =
T->getTemplateName().getAsTemplateDecl()) {
4439 mangleTemplateName(TD,
T->template_arguments());
4442 mangleTemplatePrefix(
T->getTemplateName());
4447 mangleTemplateArgs(
T->getTemplateName(),
T->template_arguments());
4452void CXXNameMangler::mangleType(
const DependentNameType *
T) {
4463 switch (
T->getKeyword()) {
4464 case ElaboratedTypeKeyword::None:
4465 case ElaboratedTypeKeyword::Typename:
4467 case ElaboratedTypeKeyword::Struct:
4468 case ElaboratedTypeKeyword::Class:
4469 case ElaboratedTypeKeyword::Interface:
4472 case ElaboratedTypeKeyword::Union:
4475 case ElaboratedTypeKeyword::Enum:
4481 manglePrefix(
T->getQualifier());
4482 mangleSourceName(
T->getIdentifier());
4486void CXXNameMangler::mangleType(
const TypeOfType *
T) {
4492void CXXNameMangler::mangleType(
const TypeOfExprType *
T) {
4498void CXXNameMangler::mangleType(
const DecltypeType *
T) {
4499 Expr *E =
T->getUnderlyingExpr();
4518 mangleExpression(E);
4522void CXXNameMangler::mangleType(
const UnaryTransformType *
T) {
4526 StringRef BuiltinName;
4527 switch (
T->getUTTKind()) {
4528#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
4529 case UnaryTransformType::Enum: \
4530 BuiltinName = "__" #Trait; \
4532#include "clang/Basic/TransformTypeTraits.def"
4534 mangleVendorType(BuiltinName);
4538 mangleType(
T->getBaseType());
4542void CXXNameMangler::mangleType(
const AutoType *
T) {
4543 assert(
T->getDeducedType().isNull() &&
4544 "Deduced AutoType shouldn't be handled here!");
4545 assert(
T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
4546 "shouldn't need to mangle __auto_type!");
4551 if (
T->isConstrained() && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
4552 Out << (
T->isDecltypeAuto() ?
"DK" :
"Dk");
4553 mangleTypeConstraint(
T->getTypeConstraintConcept(),
4554 T->getTypeConstraintArguments());
4556 Out << (
T->isDecltypeAuto() ?
"Dc" :
"Da");
4560void CXXNameMangler::mangleType(
const DeducedTemplateSpecializationType *
T) {
4561 QualType Deduced =
T->getDeducedType();
4563 return mangleType(Deduced);
4567 "shouldn't form deduced TST unless we know we have a template");
4571void CXXNameMangler::mangleType(
const AtomicType *
T) {
4575 mangleType(
T->getValueType());
4578void CXXNameMangler::mangleType(
const PipeType *
T) {
4585void CXXNameMangler::mangleType(
const BitIntType *
T) {
4589 Out <<
"D" << (
T->isUnsigned() ?
"U" :
"B") <<
T->getNumBits() <<
"_";
4592void CXXNameMangler::mangleType(
const DependentBitIntType *
T) {
4596 Out <<
"D" << (
T->isUnsigned() ?
"U" :
"B");
4597 mangleExpression(
T->getNumBitsExpr());
4601void CXXNameMangler::mangleType(
const ArrayParameterType *
T) {
4605void CXXNameMangler::mangleType(
const HLSLAttributedResourceType *
T) {
4606 llvm::SmallString<64> Str(
"_Res");
4607 const HLSLAttributedResourceType::Attributes &Attrs =
T->getAttrs();
4609 switch (Attrs.ResourceClass) {
4610 case llvm::dxil::ResourceClass::UAV:
4613 case llvm::dxil::ResourceClass::SRV:
4616 case llvm::dxil::ResourceClass::CBuffer:
4619 case llvm::dxil::ResourceClass::Sampler:
4625 if (Attrs.RawBuffer)
4627 if (
T->hasContainedType())
4629 mangleVendorQualifier(Str);
4631 if (
T->hasContainedType()) {
4632 mangleType(
T->getContainedType());
4634 mangleType(
T->getWrappedType());
4637void CXXNameMangler::mangleType(
const HLSLInlineSpirvType *
T) {
4638 SmallString<20> TypeNameStr;
4639 llvm::raw_svector_ostream TypeNameOS(TypeNameStr);
4641 TypeNameOS <<
"spirv_type";
4643 TypeNameOS <<
"_" <<
T->getOpcode();
4644 TypeNameOS <<
"_" <<
T->getSize();
4645 TypeNameOS <<
"_" <<
T->getAlignment();
4647 mangleVendorType(TypeNameStr);
4649 for (
auto &Operand :
T->getOperands()) {
4650 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
4653 case SpirvOperandKind::ConstantId:
4654 mangleVendorQualifier(
"_Const");
4655 mangleIntegerLiteral(
Operand.getResultType(),
4656 llvm::APSInt(
Operand.getValue()));
4658 case SpirvOperandKind::Literal:
4659 mangleVendorQualifier(
"_Lit");
4660 mangleIntegerLiteral(Context.getASTContext().
IntTy,
4661 llvm::APSInt(
Operand.getValue()));
4663 case SpirvOperandKind::TypeId:
4664 mangleVendorQualifier(
"_Type");
4665 mangleType(
Operand.getResultType());
4668 llvm_unreachable(
"Invalid SpirvOperand kind");
4671 TypeNameOS <<
Operand.getKind();
4675void CXXNameMangler::mangleIntegerLiteral(QualType
T,
4676 const llvm::APSInt &
Value) {
4683 Out << (
Value.getBoolValue() ?
'1' :
'0');
4685 mangleNumber(
Value);
4690void CXXNameMangler::mangleMemberExprBase(
const Expr *Base,
bool IsArrow) {
4692 while (
const auto *RT =
Base->getType()->getAsCanonical<RecordType>()) {
4693 if (!RT->getOriginalDecl()->isAnonymousStructOrUnion())
4695 const auto *ME = dyn_cast<MemberExpr>(Base);
4698 Base = ME->getBase();
4699 IsArrow = ME->isArrow();
4702 if (
Base->isImplicitCXXThis()) {
4708 Out << (IsArrow ?
"pt" :
"dt");
4709 mangleExpression(Base);
4714void CXXNameMangler::mangleMemberExpr(
const Expr *base,
bool isArrow,
4715 NestedNameSpecifier Qualifier,
4716 NamedDecl *firstQualifierLookup,
4717 DeclarationName member,
4718 const TemplateArgumentLoc *TemplateArgs,
4719 unsigned NumTemplateArgs,
4724 mangleMemberExprBase(base, isArrow);
4725 mangleUnresolvedName(Qualifier, member, TemplateArgs, NumTemplateArgs, arity);
4738 if (callee == fn)
return false;
4742 if (!lookup)
return false;
4759void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
4761 Out << CastEncoding;
4766void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
4768 InitList = Syntactic;
4769 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
4770 mangleExpression(InitList->
getInit(i));
4773void CXXNameMangler::mangleRequirement(SourceLocation RequiresExprLoc,
4774 const concepts::Requirement *Req) {
4775 using concepts::Requirement;
4780 auto HandleSubstitutionFailure =
4781 [&](SourceLocation Loc) {
4782 DiagnosticsEngine &Diags = Context.getDiags();
4785 "containing a substitution failure");
4786 Diags.
Report(Loc, DiagID);
4791 case Requirement::RK_Type: {
4793 if (TR->isSubstitutionFailure())
4794 return HandleSubstitutionFailure(
4795 TR->getSubstitutionDiagnostic()->DiagLoc);
4798 mangleType(TR->getType()->getType());
4802 case Requirement::RK_Simple:
4803 case Requirement::RK_Compound: {
4805 if (ER->isExprSubstitutionFailure())
4806 return HandleSubstitutionFailure(
4807 ER->getExprSubstitutionDiagnostic()->DiagLoc);
4810 mangleExpression(ER->getExpr());
4812 if (ER->hasNoexceptRequirement())
4815 if (!ER->getReturnTypeRequirement().isEmpty()) {
4816 if (ER->getReturnTypeRequirement().isSubstitutionFailure())
4817 return HandleSubstitutionFailure(ER->getReturnTypeRequirement()
4818 .getSubstitutionDiagnostic()
4822 mangleTypeConstraint(ER->getReturnTypeRequirement().getTypeConstraint());
4827 case Requirement::RK_Nested:
4829 if (NR->hasInvalidConstraint()) {
4832 return HandleSubstitutionFailure(RequiresExprLoc);
4836 mangleExpression(NR->getConstraintExpr());
4841void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity,
4842 bool AsTemplateArg) {
4871 QualType ImplicitlyConvertedToType;
4875 bool IsPrimaryExpr =
true;
4876 auto NotPrimaryExpr = [&] {
4877 if (AsTemplateArg && IsPrimaryExpr)
4879 IsPrimaryExpr =
false;
4882 auto MangleDeclRefExpr = [&](
const NamedDecl *D) {
4883 switch (D->getKind()) {
4896 case Decl::EnumConstant: {
4903 case Decl::NonTypeTemplateParm:
4916 case Expr::NoStmtClass:
4917#define ABSTRACT_STMT(Type)
4918#define EXPR(Type, Base)
4919#define STMT(Type, Base) \
4920 case Expr::Type##Class:
4921#include "clang/AST/StmtNodes.inc"
4926 case Expr::AddrLabelExprClass:
4927 case Expr::DesignatedInitUpdateExprClass:
4928 case Expr::ImplicitValueInitExprClass:
4929 case Expr::ArrayInitLoopExprClass:
4930 case Expr::ArrayInitIndexExprClass:
4931 case Expr::NoInitExprClass:
4932 case Expr::ParenListExprClass:
4933 case Expr::MSPropertyRefExprClass:
4934 case Expr::MSPropertySubscriptExprClass:
4935 case Expr::RecoveryExprClass:
4936 case Expr::ArraySectionExprClass:
4937 case Expr::OMPArrayShapingExprClass:
4938 case Expr::OMPIteratorExprClass:
4939 case Expr::CXXInheritedCtorInitExprClass:
4940 case Expr::CXXParenListInitExprClass:
4941 case Expr::PackIndexingExprClass:
4942 llvm_unreachable(
"unexpected statement kind");
4944 case Expr::ConstantExprClass:
4949 case Expr::BlockExprClass:
4950 case Expr::ChooseExprClass:
4951 case Expr::CompoundLiteralExprClass:
4952 case Expr::ExtVectorElementExprClass:
4953 case Expr::GenericSelectionExprClass:
4954 case Expr::ObjCEncodeExprClass:
4955 case Expr::ObjCIsaExprClass:
4956 case Expr::ObjCIvarRefExprClass:
4957 case Expr::ObjCMessageExprClass:
4958 case Expr::ObjCPropertyRefExprClass:
4959 case Expr::ObjCProtocolExprClass:
4960 case Expr::ObjCSelectorExprClass:
4961 case Expr::ObjCStringLiteralClass:
4962 case Expr::ObjCBoxedExprClass:
4963 case Expr::ObjCArrayLiteralClass:
4964 case Expr::ObjCDictionaryLiteralClass:
4965 case Expr::ObjCSubscriptRefExprClass:
4966 case Expr::ObjCIndirectCopyRestoreExprClass:
4967 case Expr::ObjCAvailabilityCheckExprClass:
4968 case Expr::OffsetOfExprClass:
4969 case Expr::PredefinedExprClass:
4970 case Expr::ShuffleVectorExprClass:
4971 case Expr::ConvertVectorExprClass:
4972 case Expr::StmtExprClass:
4973 case Expr::ArrayTypeTraitExprClass:
4974 case Expr::ExpressionTraitExprClass:
4975 case Expr::VAArgExprClass:
4976 case Expr::CUDAKernelCallExprClass:
4977 case Expr::AsTypeExprClass:
4978 case Expr::PseudoObjectExprClass:
4979 case Expr::AtomicExprClass:
4980 case Expr::SourceLocExprClass:
4981 case Expr::EmbedExprClass:
4982 case Expr::BuiltinBitCastExprClass: {
4986 DiagnosticsEngine &Diags = Context.getDiags();
4988 "cannot yet mangle expression type %0");
4996 case Expr::CXXUuidofExprClass: {
5001 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
5002 Out <<
"u8__uuidof";
5011 Out <<
"u8__uuidoft";
5015 Out <<
"u8__uuidofz";
5016 mangleExpression(UuidExp);
5023 case Expr::BinaryConditionalOperatorClass: {
5025 DiagnosticsEngine &Diags = Context.getDiags();
5028 "?: operator with omitted middle operand cannot be mangled");
5035 case Expr::OpaqueValueExprClass:
5036 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
5038 case Expr::InitListExprClass: {
5046 case Expr::DesignatedInitExprClass: {
5049 for (
const auto &Designator : DIE->designators()) {
5050 if (Designator.isFieldDesignator()) {
5052 mangleSourceName(Designator.getFieldName());
5053 }
else if (Designator.isArrayDesignator()) {
5055 mangleExpression(DIE->getArrayIndex(Designator));
5057 assert(Designator.isArrayRangeDesignator() &&
5058 "unknown designator kind");
5060 mangleExpression(DIE->getArrayRangeStart(Designator));
5061 mangleExpression(DIE->getArrayRangeEnd(Designator));
5064 mangleExpression(DIE->getInit());
5068 case Expr::CXXDefaultArgExprClass:
5072 case Expr::CXXDefaultInitExprClass:
5076 case Expr::CXXStdInitializerListExprClass:
5080 case Expr::SubstNonTypeTemplateParmExprClass: {
5084 if (
auto *CE = dyn_cast<ConstantExpr>(SNTTPE->getReplacement())) {
5086 QualType ParamType = SNTTPE->getParameterType(Context.getASTContext());
5087 assert(CE->hasAPValueResult() &&
"expected the NTTP to have an APValue");
5088 mangleValueInTemplateArg(ParamType, CE->getAPValueResult(),
false,
5098 case Expr::UserDefinedLiteralClass:
5101 case Expr::CXXMemberCallExprClass:
5102 case Expr::CallExprClass: {
5124 CallArity = UnknownArity;
5126 mangleExpression(CE->
getCallee(), CallArity);
5128 mangleExpression(Arg);
5133 case Expr::CXXNewExprClass: {
5136 if (
New->isGlobalNew())
Out <<
"gs";
5137 Out << (
New->isArray() ?
"na" :
"nw");
5139 E =
New->placement_arg_end(); I != E; ++I)
5140 mangleExpression(*I);
5142 mangleType(
New->getAllocatedType());
5143 if (
New->hasInitializer()) {
5144 if (
New->getInitializationStyle() == CXXNewInitializationStyle::Braces)
5148 const Expr *
Init =
New->getInitializer();
5149 if (
const CXXConstructExpr *CCE = dyn_cast<CXXConstructExpr>(
Init)) {
5154 mangleExpression(*I);
5155 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(
Init)) {
5156 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
5157 mangleExpression(PLE->getExpr(i));
5158 }
else if (
New->getInitializationStyle() ==
5159 CXXNewInitializationStyle::Braces &&
5164 mangleExpression(
Init);
5170 case Expr::CXXPseudoDestructorExprClass: {
5173 if (
const Expr *Base = PDE->getBase())
5174 mangleMemberExprBase(Base, PDE->isArrow());
5175 NestedNameSpecifier
Qualifier = PDE->getQualifier();
5176 if (TypeSourceInfo *ScopeInfo = PDE->getScopeTypeInfo()) {
5178 mangleUnresolvedPrefix(Qualifier,
5180 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
5184 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
5187 }
else if (Qualifier) {
5188 mangleUnresolvedPrefix(Qualifier);
5192 QualType DestroyedType = PDE->getDestroyedType();
5193 mangleUnresolvedTypeOrSimpleId(DestroyedType);
5197 case Expr::MemberExprClass: {
5208 case Expr::UnresolvedMemberExprClass: {
5219 case Expr::CXXDependentScopeMemberExprClass: {
5221 const CXXDependentScopeMemberExpr *ME
5232 case Expr::UnresolvedLookupExprClass: {
5241 case Expr::CXXUnresolvedConstructExprClass: {
5247 assert(N == 1 &&
"unexpected form for list initialization");
5251 mangleInitListElements(IL);
5258 if (N != 1)
Out <<
'_';
5259 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
5260 if (N != 1)
Out <<
'E';
5264 case Expr::CXXConstructExprClass: {
5271 "implicit CXXConstructExpr must have one argument");
5278 mangleExpression(E);
5283 case Expr::CXXTemporaryObjectExprClass: {
5294 if (!List && N != 1)
5296 if (CE->isStdInitListInitialization()) {
5303 mangleInitListElements(ILE);
5306 mangleExpression(E);
5313 case Expr::CXXScalarValueInitExprClass:
5320 case Expr::CXXNoexceptExprClass:
5326 case Expr::UnaryExprOrTypeTraitExprClass: {
5343 QualType
T = (ImplicitlyConvertedToType.
isNull() ||
5345 : ImplicitlyConvertedToType;
5347 mangleIntegerLiteral(
T,
V);
5353 auto MangleAlignofSizeofArg = [&] {
5363 auto MangleExtensionBuiltin = [&](
const UnaryExprOrTypeTraitExpr *E,
5364 StringRef Name = {}) {
5367 mangleVendorType(Name);
5378 MangleAlignofSizeofArg();
5380 case UETT_PreferredAlignOf:
5384 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
5385 MangleExtensionBuiltin(SAE,
"__alignof__");
5391 MangleAlignofSizeofArg();
5395 case UETT_VectorElements:
5396 case UETT_OpenMPRequiredSimdAlign:
5398 case UETT_PtrAuthTypeDiscriminator:
5399 case UETT_DataSizeOf: {
5400 DiagnosticsEngine &Diags = Context.getDiags();
5410 case Expr::TypeTraitExprClass: {
5415 mangleVendorType(Spelling);
5416 for (TypeSourceInfo *TSI : TTE->
getArgs()) {
5417 mangleType(TSI->getType());
5423 case Expr::CXXThrowExprClass: {
5437 case Expr::CXXTypeidExprClass: {
5452 case Expr::CXXDeleteExprClass: {
5463 case Expr::UnaryOperatorClass: {
5472 case Expr::ArraySubscriptExprClass: {
5479 mangleExpression(AE->
getLHS());
5480 mangleExpression(AE->
getRHS());
5484 case Expr::MatrixSubscriptExprClass: {
5488 mangleExpression(ME->
getBase());
5494 case Expr::CompoundAssignOperatorClass:
5495 case Expr::BinaryOperatorClass: {
5503 mangleExpression(BO->
getLHS());
5504 mangleExpression(BO->
getRHS());
5508 case Expr::CXXRewrittenBinaryOperatorClass: {
5511 CXXRewrittenBinaryOperator::DecomposedForm Decomposed =
5515 mangleExpression(Decomposed.
LHS);
5516 mangleExpression(Decomposed.
RHS);
5520 case Expr::ConditionalOperatorClass: {
5523 mangleOperatorName(OO_Conditional, 3);
5524 mangleExpression(CO->
getCond());
5525 mangleExpression(CO->
getLHS(), Arity);
5526 mangleExpression(CO->
getRHS(), Arity);
5530 case Expr::ImplicitCastExprClass: {
5531 ImplicitlyConvertedToType = E->
getType();
5536 case Expr::ObjCBridgedCastExprClass: {
5542 mangleCastExpression(E,
"cv");
5546 case Expr::CStyleCastExprClass:
5548 mangleCastExpression(E,
"cv");
5551 case Expr::CXXFunctionalCastExprClass: {
5555 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
5556 if (CCE->getParenOrBraceRange().isInvalid())
5557 Sub = CCE->getArg(0)->IgnoreImplicit();
5558 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
5559 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
5560 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
5563 mangleInitListElements(IL);
5566 mangleCastExpression(E,
"cv");
5571 case Expr::CXXStaticCastExprClass:
5573 mangleCastExpression(E,
"sc");
5575 case Expr::CXXDynamicCastExprClass:
5577 mangleCastExpression(E,
"dc");
5579 case Expr::CXXReinterpretCastExprClass:
5581 mangleCastExpression(E,
"rc");
5583 case Expr::CXXConstCastExprClass:
5585 mangleCastExpression(E,
"cc");
5587 case Expr::CXXAddrspaceCastExprClass:
5589 mangleCastExpression(E,
"ac");
5592 case Expr::CXXOperatorCallExprClass: {
5601 for (
unsigned i = 0; i != NumArgs; ++i)
5602 mangleExpression(CE->
getArg(i));
5606 case Expr::ParenExprClass:
5610 case Expr::ConceptSpecializationExprClass: {
5612 if (isCompatibleWith(LangOptions::ClangABI::Ver17)) {
5617 mangleTemplateName(CSE->getNamedConcept(), CSE->getTemplateArguments());
5623 mangleUnresolvedName(
5624 CSE->getNestedNameSpecifierLoc().getNestedNameSpecifier(),
5625 CSE->getConceptNameInfo().getName(),
5626 CSE->getTemplateArgsAsWritten()->getTemplateArgs(),
5627 CSE->getTemplateArgsAsWritten()->getNumTemplateArgs());
5631 case Expr::RequiresExprClass: {
5637 if (RE->getLParenLoc().isValid()) {
5639 FunctionTypeDepthState saved = FunctionTypeDepth.push();
5640 if (RE->getLocalParameters().empty()) {
5643 for (ParmVarDecl *Param : RE->getLocalParameters()) {
5651 FunctionTypeDepth.enterResultType();
5652 for (
const concepts::Requirement *Req : RE->getRequirements())
5653 mangleRequirement(RE->getExprLoc(), Req);
5654 FunctionTypeDepth.pop(saved);
5658 for (
const concepts::Requirement *Req : RE->getRequirements())
5659 mangleRequirement(RE->getExprLoc(), Req);
5665 case Expr::DeclRefExprClass:
5670 case Expr::SubstNonTypeTemplateParmPackExprClass:
5676 Out <<
"_SUBSTPACK_";
5679 case Expr::FunctionParmPackExprClass: {
5683 Out <<
"v110_SUBSTPACK";
5688 case Expr::DependentScopeDeclRefExprClass: {
5697 case Expr::CXXBindTemporaryExprClass:
5701 case Expr::ExprWithCleanupsClass:
5705 case Expr::FloatingLiteralClass: {
5712 case Expr::FixedPointLiteralClass:
5714 mangleFixedPointLiteral();
5717 case Expr::CharacterLiteralClass:
5721 Out << cast<CharacterLiteral>(E)->getValue();
5726 case Expr::ObjCBoolLiteralExprClass:
5729 Out << (cast<ObjCBoolLiteralExpr>(E)->getValue() ?
'1' :
'0');
5733 case Expr::CXXBoolLiteralExprClass:
5736 Out << (cast<CXXBoolLiteralExpr>(E)->getValue() ?
'1' :
'0');
5740 case Expr::IntegerLiteralClass: {
5744 Value.setIsSigned(
true);
5749 case Expr::ImaginaryLiteralClass: {
5756 if (
const FloatingLiteral *Imag =
5757 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
5759 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
5761 mangleFloat(Imag->getValue());
5766 Value.setIsSigned(
true);
5767 mangleNumber(
Value);
5773 case Expr::StringLiteralClass: {
5783 case Expr::GNUNullExprClass:
5786 mangleIntegerLiteral(E->
getType(), llvm::APSInt(32));
5789 case Expr::CXXNullPtrLiteralExprClass: {
5795 case Expr::LambdaExprClass: {
5806 case Expr::PackExpansionExprClass:
5812 case Expr::SizeOfPackExprClass: {
5815 if (SPE->isPartiallySubstituted()) {
5817 for (
const auto &A : SPE->getPartialArguments())
5818 mangleTemplateArg(A,
false);
5824 const NamedDecl *Pack = SPE->getPack();
5825 if (
const TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(Pack))
5826 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
5827 else if (
const NonTypeTemplateParmDecl *NTTP
5828 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
5829 mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
5830 else if (
const TemplateTemplateParmDecl *TempTP
5831 = dyn_cast<TemplateTemplateParmDecl>(Pack))
5832 mangleTemplateParameter(TempTP->getDepth(), TempTP->getIndex());
5838 case Expr::MaterializeTemporaryExprClass:
5842 case Expr::CXXFoldExprClass: {
5845 if (FE->isLeftFold())
5846 Out << (FE->getInit() ?
"fL" :
"fl");
5848 Out << (FE->getInit() ?
"fR" :
"fr");
5850 if (FE->getOperator() == BO_PtrMemD)
5858 mangleExpression(FE->getLHS());
5860 mangleExpression(FE->getRHS());
5864 case Expr::CXXThisExprClass:
5869 case Expr::CoawaitExprClass:
5872 Out <<
"v18co_await";
5876 case Expr::DependentCoawaitExprClass:
5879 Out <<
"v18co_await";
5883 case Expr::CoyieldExprClass:
5886 Out <<
"v18co_yield";
5889 case Expr::SYCLUniqueStableNameExprClass: {
5893 Out <<
"u33__builtin_sycl_unique_stable_name";
5894 mangleType(USN->getTypeSourceInfo()->getType());
5899 case Expr::HLSLOutArgExprClass:
5901 "cannot mangle hlsl temporary value; mangling wrong thing?");
5902 case Expr::OpenACCAsteriskSizeExprClass: {
5904 DiagnosticsEngine &Diags = Context.getDiags();
5907 "cannot yet mangle OpenACC Asterisk Size expression");
5913 if (AsTemplateArg && !IsPrimaryExpr)
5945void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
5952 assert(parmDepth < FunctionTypeDepth.getDepth());
5953 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
5954 if (FunctionTypeDepth.isInResultType())
5957 if (nestingDepth == 0) {
5960 Out <<
"fL" << (nestingDepth - 1) <<
'p';
5968 &&
"parameter's type is still an array type?");
5970 if (
const DependentAddressSpaceType *DAST =
5971 dyn_cast<DependentAddressSpaceType>(parm->
getType())) {
5978 if (parmIndex != 0) {
5979 Out << (parmIndex - 1);
5985 const CXXRecordDecl *InheritedFrom) {
6012 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
6015 mangleName(InheritedFrom);
6074 if (
auto *FTD = dyn_cast_or_null<FunctionTemplateDecl>(
ResolvedTemplate)) {
6075 auto *RD = dyn_cast<CXXRecordDecl>(FTD->getDeclContext());
6076 if (!RD || !RD->isGenericLambda())
6092 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param))
6093 return TTP->hasTypeConstraint();
6110 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param))
6111 return NTTP->getType()->isInstantiationDependentType() ||
6112 NTTP->getType()->getContainedDeducedType();
6119 "A DeducedTemplateName shouldn't escape partial ordering");
6130 auto MangleTemplateParamListToString =
6132 unsigned DepthOffset) {
6133 llvm::raw_svector_ostream Stream(Buffer);
6134 CXXNameMangler(
Mangler.Context, Stream,
6135 WithTemplateDepthOffset{DepthOffset})
6136 .mangleTemplateParameterList(Params);
6139 MangleTemplateParamListToString(ParamTemplateHead,
6140 TTP->getTemplateParameters(), 0);
6144 MangleTemplateParamListToString(ArgTemplateHead,
6146 TTP->getTemplateParameters()->
getDepth());
6147 return ParamTemplateHead != ArgTemplateHead;
6157 return {
true,
nullptr};
6162 assert(ParamIdx < ResolvedTemplate->getTemplateParameters()->size() &&
6163 "no parameter for argument");
6184 return {
true,
nullptr};
6199 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param);
6200 bool NeedExactType = NTTP && NTTP->getType()->getContainedDeducedType();
6201 return {NeedExactType,
nullptr};
6213void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6215 unsigned NumTemplateArgs) {
6218 TemplateArgManglingInfo Info(*
this, TN);
6219 for (
unsigned i = 0; i != NumTemplateArgs; ++i) {
6220 mangleTemplateArg(Info, i, TemplateArgs[i].
getArgument());
6222 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6226void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6227 const TemplateArgumentList &AL) {
6230 TemplateArgManglingInfo Info(*
this, TN);
6231 for (
unsigned i = 0, e = AL.
size(); i != e; ++i) {
6232 mangleTemplateArg(Info, i, AL[i]);
6234 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6238void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6239 ArrayRef<TemplateArgument> Args) {
6242 TemplateArgManglingInfo Info(*
this, TN);
6243 for (
unsigned i = 0; i != Args.size(); ++i) {
6244 mangleTemplateArg(Info, i, Args[i]);
6246 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6250void CXXNameMangler::mangleTemplateArg(TemplateArgManglingInfo &Info,
6251 unsigned Index, TemplateArgument A) {
6252 TemplateArgManglingInfo::Info ArgInfo = Info.getArgInfo(Index, A);
6255 if (ArgInfo.TemplateParameterToMangle &&
6256 !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
6263 mangleTemplateParamDecl(ArgInfo.TemplateParameterToMangle);
6266 mangleTemplateArg(A, ArgInfo.NeedExactType);
6269void CXXNameMangler::mangleTemplateArg(TemplateArgument A,
bool NeedExactType) {
6279 llvm_unreachable(
"Cannot mangle NULL template argument");
6307 mangleValueInTemplateArg(TPO->getType().getUnqualifiedType(),
6308 TPO->getValue(),
true,
6313 ASTContext &Ctx = Context.getASTContext();
6321 !isCompatibleWith(LangOptions::ClangABI::Ver11))
6329 ArrayRef<APValue::LValuePathEntry>(),
6342 true, NeedExactType);
6348 mangleTemplateArg(P, NeedExactType);
6354void CXXNameMangler::mangleTemplateArgExpr(
const Expr *E) {
6355 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6356 mangleExpression(E, UnknownArity,
true);
6371 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
6372 const ValueDecl *D = DRE->getDecl();
6381 mangleExpression(E);
6394 switch (
V.getKind()) {
6402 assert(RD &&
"unexpected type for record value");
6411 if (!FD->isUnnamedBitField() &&
6421 assert(RD &&
"unexpected type for union value");
6424 if (!FD->isUnnamedBitField())
6434 QualType ElemT(
T->getArrayElementTypeNoTypeQual(), 0);
6435 for (
unsigned I = 0, N =
V.getArrayInitializedElts(); I != N; ++I)
6443 for (
unsigned I = 0, N =
V.getVectorLength(); I != N; ++I)
6453 return V.getFloat().isPosZero();
6456 return !
V.getFixedPoint().getValue();
6459 return V.getComplexFloatReal().isPosZero() &&
6460 V.getComplexFloatImag().isPosZero();
6463 return !
V.getComplexIntReal() && !
V.getComplexIntImag();
6466 return V.isNullPointer();
6469 return !
V.getMemberPointerDecl();
6472 llvm_unreachable(
"Unhandled APValue::ValueKind enum");
6479 T = AT->getElementType();
6481 dyn_cast<FieldDecl>(E.getAsBaseOrMember().getPointer()))
6526 Diags.
Report(UnionLoc, DiagID);
6531void CXXNameMangler::mangleValueInTemplateArg(QualType
T,
const APValue &
V,
6533 bool NeedExactType) {
6536 T = getASTContext().getUnqualifiedArrayType(
T, Quals);
6539 bool IsPrimaryExpr =
true;
6540 auto NotPrimaryExpr = [&] {
6541 if (TopLevel && IsPrimaryExpr)
6543 IsPrimaryExpr =
false;
6547 switch (
V.getKind()) {
6556 llvm_unreachable(
"unexpected value kind in template argument");
6560 assert(RD &&
"unexpected type for record value");
6563 llvm::SmallVector<const FieldDecl *, 16> Fields(RD->
fields());
6566 (Fields.back()->isUnnamedBitField() ||
6568 V.getStructField(Fields.back()->getFieldIndex())))) {
6572 if (Fields.empty()) {
6573 while (!Bases.empty() &&
6575 V.getStructBase(Bases.size() - 1)))
6576 Bases = Bases.drop_back();
6583 for (
unsigned I = 0, N = Bases.size(); I != N; ++I)
6584 mangleValueInTemplateArg(Bases[I].
getType(),
V.getStructBase(I),
false);
6585 for (
unsigned I = 0, N = Fields.size(); I != N; ++I) {
6586 if (Fields[I]->isUnnamedBitField())
6588 mangleValueInTemplateArg(Fields[I]->
getType(),
6589 V.getStructField(Fields[I]->getFieldIndex()),
6598 const FieldDecl *FD =
V.getUnionField();
6616 mangleSourceName(II);
6617 mangleValueInTemplateArg(FD->
getType(),
V.getUnionValue(),
false);
6631 unsigned N =
V.getArraySize();
6633 N =
V.getArrayInitializedElts();
6638 for (
unsigned I = 0; I != N; ++I) {
6639 const APValue &Elem = I <
V.getArrayInitializedElts()
6640 ?
V.getArrayInitializedElt(I)
6641 :
V.getArrayFiller();
6642 mangleValueInTemplateArg(ElemT, Elem,
false);
6649 const VectorType *VT =
T->
castAs<VectorType>();
6654 unsigned N =
V.getVectorLength();
6657 for (
unsigned I = 0; I != N; ++I)
6658 mangleValueInTemplateArg(VT->
getElementType(),
V.getVectorElt(I),
false);
6664 mangleIntegerLiteral(
T,
V.getInt());
6668 mangleFloatLiteral(
T,
V.getFloat());
6672 mangleFixedPointLiteral();
6676 const ComplexType *CT =
T->
castAs<ComplexType>();
6680 if (!
V.getComplexFloatReal().isPosZero() ||
6681 !
V.getComplexFloatImag().isPosZero())
6683 if (!
V.getComplexFloatImag().isPosZero())
6690 const ComplexType *CT =
T->
castAs<ComplexType>();
6694 if (
V.getComplexIntReal().getBoolValue() ||
6695 V.getComplexIntImag().getBoolValue())
6697 if (
V.getComplexIntImag().getBoolValue())
6706 "unexpected type for LValue template arg");
6708 if (
V.isNullPointer()) {
6709 mangleNullPointer(
T);
6713 APValue::LValueBase B =
V.getLValueBase();
6717 CharUnits Offset =
V.getLValueOffset();
6735 ASTContext &Ctx = Context.getASTContext();
6738 if (!
V.hasLValuePath()) {
6754 bool IsArrayToPointerDecayMangledAsDecl =
false;
6755 if (TopLevel && Ctx.
getLangOpts().getClangABICompat() <=
6756 LangOptions::ClangABI::Ver11) {
6758 IsArrayToPointerDecayMangledAsDecl =
6759 BType->
isArrayType() &&
V.getLValuePath().size() == 1 &&
6760 V.getLValuePath()[0].getAsArrayIndex() == 0 &&
6764 if ((!
V.getLValuePath().empty() ||
V.isLValueOnePastTheEnd()) &&
6765 !IsArrayToPointerDecayMangledAsDecl) {
6782 if (NeedExactType &&
6784 !isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6797 QualType TypeSoFar = B.
getType();
6798 if (
auto *VD = B.
dyn_cast<
const ValueDecl*>()) {
6802 }
else if (
auto *E = B.
dyn_cast<
const Expr*>()) {
6804 mangleExpression(E);
6805 }
else if (
auto TI = B.
dyn_cast<TypeInfoLValue>()) {
6808 mangleType(QualType(TI.getType(), 0));
6811 llvm_unreachable(
"unexpected lvalue base kind in template argument");
6821 mangleNumber(
V.getLValueOffset().getQuantity());
6828 if (!
V.getLValueOffset().isZero())
6829 mangleNumber(
V.getLValueOffset().getQuantity());
6833 bool OnePastTheEnd =
V.isLValueOnePastTheEnd();
6835 for (APValue::LValuePathEntry E :
V.getLValuePath()) {
6837 if (
auto *CAT = dyn_cast<ConstantArrayType>(AT))
6838 OnePastTheEnd |= CAT->getSize() == E.getAsArrayIndex();
6839 TypeSoFar = AT->getElementType();
6841 const Decl *D = E.getAsBaseOrMember().getPointer();
6842 if (
auto *FD = dyn_cast<FieldDecl>(D)) {
6867 if (!
V.getMemberPointerDecl()) {
6868 mangleNullPointer(
T);
6872 ASTContext &Ctx = Context.getASTContext();
6875 if (!
V.getMemberPointerPath().empty()) {
6878 }
else if (NeedExactType &&
6880 T->
castAs<MemberPointerType>()->getPointeeType(),
6881 V.getMemberPointerDecl()->getType()) &&
6882 !isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6887 mangle(
V.getMemberPointerDecl());
6889 if (!
V.getMemberPointerPath().empty()) {
6899 if (TopLevel && !IsPrimaryExpr)
6903void CXXNameMangler::mangleTemplateParameter(
unsigned Depth,
unsigned Index) {
6913 Depth += TemplateDepthOffset;
6915 Out <<
'L' << (Depth - 1) <<
'_';
6921void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
6924 }
else if (SeqID == 1) {
6931 MutableArrayRef<char> BufferRef(Buffer);
6932 MutableArrayRef<char>::reverse_iterator I = BufferRef.rbegin();
6934 for (; SeqID != 0; SeqID /= 36) {
6935 unsigned C = SeqID % 36;
6936 *I++ = (
C < 10 ?
'0' +
C :
'A' +
C - 10);
6939 Out.write(I.base(), I - BufferRef.rbegin());
6944void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
6945 bool result = mangleSubstitution(tname);
6946 assert(result &&
"no existing substitution for template name");
6952bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
6954 if (mangleStandardSubstitution(ND))
6958 return mangleSubstitution(
reinterpret_cast<uintptr_t>(ND));
6968bool CXXNameMangler::mangleSubstitution(QualType
T) {
6971 return mangleSubstitution(RD);
6976 return mangleSubstitution(TypePtr);
6980 if (TemplateDecl *TD =
Template.getAsTemplateDecl())
6981 return mangleSubstitution(TD);
6984 return mangleSubstitution(
6988bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
6989 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
6990 if (I == Substitutions.end())
6993 unsigned SeqID = I->second;
7002bool CXXNameMangler::isSpecializedAs(QualType S, llvm::StringRef Name,
7011 const ClassTemplateSpecializationDecl *SD =
7012 dyn_cast<ClassTemplateSpecializationDecl>(RT->getOriginalDecl());
7016 if (!isStdNamespace(Context.getEffectiveDeclContext(SD)))
7020 if (TemplateArgs.
size() != 1)
7023 if (TemplateArgs[0].getAsType() != A)
7035bool CXXNameMangler::isStdCharSpecialization(
7036 const ClassTemplateSpecializationDecl *SD, llvm::StringRef Name,
7037 bool HasAllocator) {
7042 if (TemplateArgs.
size() != (HasAllocator ? 3 : 2))
7045 QualType A = TemplateArgs[0].getAsType();
7053 if (!isSpecializedAs(TemplateArgs[1].getAsType(),
"char_traits", A))
7057 !isSpecializedAs(TemplateArgs[2].getAsType(),
"allocator", A))
7066bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
7068 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
7076 if (
const ClassTemplateDecl *TD = dyn_cast<ClassTemplateDecl>(ND)) {
7077 if (!isStdNamespace(Context.getEffectiveDeclContext(TD)))
7097 if (
const ClassTemplateSpecializationDecl *SD =
7098 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
7099 if (!isStdNamespace(Context.getEffectiveDeclContext(SD)))
7108 if (isStdCharSpecialization(SD,
"basic_string",
true)) {
7115 if (isStdCharSpecialization(SD,
"basic_istream",
false)) {
7122 if (isStdCharSpecialization(SD,
"basic_ostream",
false)) {
7129 if (isStdCharSpecialization(SD,
"basic_iostream",
false)) {
7139void CXXNameMangler::addSubstitution(QualType
T) {
7142 addSubstitution(RD);
7148 addSubstitution(TypePtr);
7152 if (TemplateDecl *TD =
Template.getAsTemplateDecl())
7153 return addSubstitution(TD);
7159void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
7160 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
7161 Substitutions[Ptr] = SeqID++;
7164void CXXNameMangler::extendSubstitutions(CXXNameMangler*
Other) {
7165 assert(
Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
7166 if (
Other->SeqID > SeqID) {
7167 Substitutions.swap(
Other->Substitutions);
7168 SeqID =
Other->SeqID;
7172CXXNameMangler::AbiTagList
7173CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
7175 if (DisableDerivedAbiTags)
7176 return AbiTagList();
7178 llvm::raw_null_ostream NullOutStream;
7179 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
7180 TrackReturnTypeTags.disableDerivedAbiTags();
7182 const FunctionProtoType *Proto =
7184 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
7185 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
7187 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
7188 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
7190 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
7193CXXNameMangler::AbiTagList
7194CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
7196 if (DisableDerivedAbiTags)
7197 return AbiTagList();
7199 llvm::raw_null_ostream NullOutStream;
7200 CXXNameMangler TrackVariableType(*
this, NullOutStream);
7201 TrackVariableType.disableDerivedAbiTags();
7203 TrackVariableType.mangleType(VD->
getType());
7205 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
7208bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &
C,
7209 const VarDecl *VD) {
7210 llvm::raw_null_ostream NullOutStream;
7211 CXXNameMangler TrackAbiTags(
C, NullOutStream,
nullptr,
true);
7212 TrackAbiTags.mangle(VD);
7213 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
7226void ItaniumMangleContextImpl::mangleCXXName(GlobalDecl GD,
7230 "Invalid mangleName() call, argument is not a variable or function!");
7232 PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
7233 getASTContext().getSourceManager(),
7234 "Mangling declaration");
7236 if (
auto *CD = dyn_cast<CXXConstructorDecl>(D)) {
7238 CXXNameMangler Mangler(*
this, Out, CD,
Type);
7239 return Mangler.mangle(GlobalDecl(CD,
Type));
7242 if (
auto *DD = dyn_cast<CXXDestructorDecl>(D)) {
7244 CXXNameMangler Mangler(*
this, Out, DD,
Type);
7245 return Mangler.mangle(GlobalDecl(DD,
Type));
7248 CXXNameMangler Mangler(*
this, Out, D);
7252void ItaniumMangleContextImpl::mangleCXXCtorComdat(
const CXXConstructorDecl *D,
7254 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
7258void ItaniumMangleContextImpl::mangleCXXDtorComdat(
const CXXDestructorDecl *D,
7260 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
7282 auto &LangOpts = Context.getLangOpts();
7285 Context.baseForVTableAuthentication(ThisRD);
7286 unsigned TypedDiscriminator =
7287 Context.getPointerAuthVTablePointerDiscriminator(ThisRD);
7288 Mangler.mangleVendorQualifier(
"__vtptrauth");
7289 auto &ManglerStream = Mangler.getStream();
7290 ManglerStream <<
"I";
7291 if (
const auto *ExplicitAuth =
7292 PtrauthClassRD->
getAttr<VTablePointerAuthenticationAttr>()) {
7293 ManglerStream <<
"Lj" << ExplicitAuth->getKey();
7295 if (ExplicitAuth->getAddressDiscrimination() ==
7296 VTablePointerAuthenticationAttr::DefaultAddressDiscrimination)
7297 ManglerStream <<
"Lb" << LangOpts.PointerAuthVTPtrAddressDiscrimination;
7299 ManglerStream <<
"Lb"
7300 << (ExplicitAuth->getAddressDiscrimination() ==
7301 VTablePointerAuthenticationAttr::AddressDiscrimination);
7303 switch (ExplicitAuth->getExtraDiscrimination()) {
7304 case VTablePointerAuthenticationAttr::DefaultExtraDiscrimination: {
7305 if (LangOpts.PointerAuthVTPtrTypeDiscrimination)
7306 ManglerStream <<
"Lj" << TypedDiscriminator;
7308 ManglerStream <<
"Lj" << 0;
7311 case VTablePointerAuthenticationAttr::TypeDiscrimination:
7312 ManglerStream <<
"Lj" << TypedDiscriminator;
7314 case VTablePointerAuthenticationAttr::CustomDiscrimination:
7315 ManglerStream <<
"Lj" << ExplicitAuth->getCustomDiscriminationValue();
7317 case VTablePointerAuthenticationAttr::NoExtraDiscrimination:
7318 ManglerStream <<
"Lj" << 0;
7322 ManglerStream <<
"Lj"
7323 << (
unsigned)VTablePointerAuthenticationAttr::DefaultKey;
7324 ManglerStream <<
"Lb" << LangOpts.PointerAuthVTPtrAddressDiscrimination;
7325 if (LangOpts.PointerAuthVTPtrTypeDiscrimination)
7326 ManglerStream <<
"Lj" << TypedDiscriminator;
7328 ManglerStream <<
"Lj" << 0;
7330 ManglerStream <<
"E";
7333void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
7334 const ThunkInfo &Thunk,
7335 bool ElideOverrideInfo,
7345 "Use mangleCXXDtor for destructor decls!");
7346 CXXNameMangler Mangler(*
this, Out);
7347 Mangler.getStream() <<
"_ZT";
7349 Mangler.getStream() <<
'c';
7360 Mangler.mangleFunctionEncoding(MD);
7361 if (!ElideOverrideInfo)
7365void ItaniumMangleContextImpl::mangleCXXDtorThunk(
const CXXDestructorDecl *DD,
7367 const ThunkInfo &Thunk,
7368 bool ElideOverrideInfo,
7372 CXXNameMangler Mangler(*
this, Out, DD,
Type);
7373 Mangler.getStream() <<
"_ZT";
7375 auto &ThisAdjustment = Thunk.
This;
7377 Mangler.mangleCallOffset(ThisAdjustment.NonVirtual,
7378 ThisAdjustment.Virtual.Itanium.VCallOffsetOffset);
7380 Mangler.mangleFunctionEncoding(GlobalDecl(DD,
Type));
7381 if (!ElideOverrideInfo)
7386void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
7390 CXXNameMangler Mangler(*
this, Out);
7393 Mangler.getStream() <<
"_ZGV";
7394 Mangler.mangleName(D);
7397void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
7402 Out <<
"__cxx_global_var_init";
7405void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
7408 CXXNameMangler Mangler(*
this, Out);
7409 Mangler.getStream() <<
"__dtor_";
7410 if (shouldMangleDeclName(D))
7413 Mangler.getStream() << D->
getName();
7416void ItaniumMangleContextImpl::mangleDynamicStermFinalizer(
const VarDecl *D,
7420 CXXNameMangler Mangler(*
this, Out);
7421 Mangler.getStream() <<
"__finalize_";
7422 if (shouldMangleDeclName(D))
7425 Mangler.getStream() << D->
getName();
7428void ItaniumMangleContextImpl::mangleSEHFilterExpression(
7429 GlobalDecl EnclosingDecl, raw_ostream &Out) {
7430 CXXNameMangler Mangler(*
this, Out);
7431 Mangler.getStream() <<
"__filt_";
7433 if (shouldMangleDeclName(EnclosingFD))
7434 Mangler.mangle(EnclosingDecl);
7436 Mangler.getStream() << EnclosingFD->getName();
7439void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
7440 GlobalDecl EnclosingDecl, raw_ostream &Out) {
7441 CXXNameMangler Mangler(*
this, Out);
7442 Mangler.getStream() <<
"__fin_";
7444 if (shouldMangleDeclName(EnclosingFD))
7445 Mangler.mangle(EnclosingDecl);
7447 Mangler.getStream() << EnclosingFD->getName();
7450void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
7453 CXXNameMangler Mangler(*
this, Out);
7454 Mangler.getStream() <<
"_ZTH";
7455 Mangler.mangleName(D);
7459ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
7462 CXXNameMangler Mangler(*
this, Out);
7463 Mangler.getStream() <<
"_ZTW";
7464 Mangler.mangleName(D);
7467void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
7468 unsigned ManglingNumber,
7472 CXXNameMangler Mangler(*
this, Out);
7473 Mangler.getStream() <<
"_ZGR";
7474 Mangler.mangleName(D);
7475 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
7476 Mangler.mangleSeqID(ManglingNumber - 1);
7479void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
7482 CXXNameMangler Mangler(*
this, Out);
7483 Mangler.getStream() <<
"_ZTV";
7484 Mangler.mangleCXXRecordDecl(RD);
7487void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
7490 CXXNameMangler Mangler(*
this, Out);
7491 Mangler.getStream() <<
"_ZTT";
7492 Mangler.mangleCXXRecordDecl(RD);
7495void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
7497 const CXXRecordDecl *
Type,
7500 CXXNameMangler Mangler(*
this, Out);
7501 Mangler.getStream() <<
"_ZTC";
7504 bool SuppressSubstitution =
7505 getASTContext().getLangOpts().getClangABICompat() <=
7506 LangOptions::ClangABI::Ver19;
7507 Mangler.mangleCXXRecordDecl(RD, SuppressSubstitution);
7508 Mangler.getStream() << Offset;
7509 Mangler.getStream() <<
'_';
7510 Mangler.mangleCXXRecordDecl(
Type);
7513void ItaniumMangleContextImpl::mangleCXXRTTI(QualType Ty, raw_ostream &Out) {
7515 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
7516 CXXNameMangler Mangler(*
this, Out);
7517 Mangler.getStream() <<
"_ZTI";
7518 Mangler.mangleType(Ty);
7521void ItaniumMangleContextImpl::mangleCXXRTTIName(
7522 QualType Ty, raw_ostream &Out,
bool NormalizeIntegers =
false) {
7524 CXXNameMangler Mangler(*
this, Out, NormalizeIntegers);
7525 Mangler.getStream() <<
"_ZTS";
7526 Mangler.mangleType(Ty);
7529void ItaniumMangleContextImpl::mangleCanonicalTypeName(
7530 QualType Ty, raw_ostream &Out,
bool NormalizeIntegers =
false) {
7531 mangleCXXRTTIName(Ty, Out, NormalizeIntegers);
7534void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
7535 llvm_unreachable(
"Can't mangle string literals");
7538void ItaniumMangleContextImpl::mangleLambdaSig(
const CXXRecordDecl *Lambda,
7540 CXXNameMangler Mangler(*
this, Out);
7541 Mangler.mangleLambdaSig(Lambda);
7544void ItaniumMangleContextImpl::mangleModuleInitializer(
const Module *M,
7547 CXXNameMangler Mangler(*
this, Out);
7548 Mangler.getStream() <<
"_ZGI";
7552 auto Partition = M->
Name.find(
':');
7553 Mangler.mangleModuleNamePrefix(
7554 StringRef(&M->
Name[Partition + 1], M->
Name.size() - Partition - 1),
7562 return new ItaniumMangleContextImpl(
7565 return std::nullopt;
7574 return new ItaniumMangleContextImpl(Context, Diags, DiscriminatorOverride,
Enums/classes describing ABI related information about constructors, destructors and thunks.
Defines the clang::ASTContext interface.
static bool isUniqueInternalLinkageDecl(GlobalDecl GD, CodeGenModule &CGM)
@ LLVM_MARK_AS_BITMASK_ENUM
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
static DeclT * getDefinitionOrSelf(DeclT *D)
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.
#define CC_VLS_CASE(ABI_VLEN)
static GlobalDecl getParentOfLocalEntity(const DeclContext *DC)
@ ArmAgnosticSMEZAStateBit
@ ArmStreamingCompatibleBit
static AAPCSBitmaskSME encodeAAPCSZAState(unsigned SMEAttrs)
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
static void mangleOverrideDiscrimination(CXXNameMangler &Mangler, ASTContext &Context, const ThunkInfo &Thunk)
Mangles the pointer authentication override attribute for classes that have explicit overrides for th...
static bool isZeroInitialized(QualType T, const APValue &V)
Determine whether a given value is equivalent to zero-initialization for the purpose of discarding a ...
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static bool isParenthesizedADLCallee(const CallExpr *call)
Look at the callee of the given call expression and determine if it's a parenthesized id-expression w...
static TemplateName asTemplateName(GlobalDecl GD)
static QualType getLValueType(ASTContext &Ctx, const APValue &LV)
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::Module class, which describes a module in the source code.
static StringRef getIdentifier(const Token &Tok)
Enums/classes describing THUNK related information about constructors, destructors and thunks.
Defines the clang::TypeLoc interface and its subclasses.
static const TemplateArgument & getArgument(const TemplateArgument &A)
A non-discriminated union of a base, field, or array index.
static LValuePathEntry ArrayIndex(uint64_t Index)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
ArrayRef< LValuePathEntry > getLValuePath() const
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
CharUnits getMemberPointerPathAdjustment(const APValue &MP) const
Find the 'this' offset for the member path in a pointer-to-member APValue.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
const LangOptions & getLangOpts() const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
bool addressSpaceMapManglingFor(LangAS AS) const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
CanQualType getCanonicalTagType(const TagDecl *TD) const
unsigned getTargetAddressSpace(LangAS AS) const
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.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
ConstExprIterator const_arg_iterator
bool isGlobalDelete() const
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.
ConstExprIterator const_arg_iterator
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,...
const Expr * getSubExpr() const
bool isTypeOperand() const
QualType getTypeOperand(const ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Expr * getExprOperand() const
bool isListInitialization() const
Determine whether this expression models list-initialization.
Expr * getArg(unsigned I)
unsigned getNumArgs() const
Retrieve the number of arguments.
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.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
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.
QualType getElementType() const
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
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 isRequiresExprBody() const
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
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SourceLocation getLocation() const
void setImplicit(bool I=true)
DeclContext * getDeclContext()
bool isInAnonymousNamespace() const
Module * getOwningModuleForLinkage() const
Get the module that owns this declaration for linkage purposes.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Expr * getAddrSpaceExpr() const
QualType getPointeeType() const
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
IdentifierOrOverloadedOperator getName() const
Represents a vector type where either the type or size is dependent.
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.
llvm::APSInt getInitVal() const
This represents one expression.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) 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...
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.
ValueDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
unsigned getAArch64SMEAttributes() const
Return a bitmask describing the SME attributes on the function type, see AArch64SMETypeAttributes for...
bool isVariadic() const
Whether this function prototype is variadic.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
bool isNothrow(bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
ArrayRef< QualType > exceptions() const
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Declaration of a template function.
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?
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
@ SME_AgnosticZAStateMask
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
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.
const Expr * getSubExpr() const
Describes an C or C++ initializer list.
unsigned getNumInits() const
InitListExpr * getSyntacticForm() const
const Expr * getInit(unsigned Init) const
ItaniumMangleContext(ASTContext &C, DiagnosticsEngine &D, bool IsAux=false)
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
UnsignedOrNone(*)(ASTContext &, const NamedDecl *) DiscriminatorOverrideTy
NestedNameSpecifier getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
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.
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
Represent a C++ namespace.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
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.
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.
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
A (possibly-)qualified type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
bool hasUnaligned() const
bool hasAddressSpace() const
PointerAuthQualifier getPointerAuth() const
ObjCLifetime getObjCLifetime() const
LangAS getAddressSpace() const
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
field_range fields() const
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Encodes a location in the source.
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
const char * getStmtClassName() const
TemplateName getReplacement() const
TypedefNameDecl * getTypedefNameForAnonDecl() const
virtual const char * getFloat128Mangling() const
Return the mangled code of __float128.
virtual const char * getIbm128Mangling() const
Return the mangled code of __ibm128.
virtual const char * getLongDoubleMangling() const
Return the mangled code of long double.
virtual const char * getBFloat16Mangling() const
Return the mangled code of bfloat.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Location wrapper for a TemplateArgument.
Represents a template argument.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getIntegralType() const
Retrieve the type of the integral value.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
std::pair< TemplateName, DefaultArguments > getTemplateDeclAndDefaultArgs() const
Retrieves the underlying template name that this template name refers to, along with the deduced defa...
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
TemplateDecl * getNamedConcept() const
QualType getType() const
Return the type wrapped by this type source info.
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
TypeTrait getTrait() const
Determine which type trait this expression uses.
The base class of the type hierarchy.
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
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isVoidPointerType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isOpenCLSpecificType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isPointerOrReferenceType() const
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
QualType getArgumentType() const
bool isArgumentType() const
UnaryExprOrTypeTrait getKind() const
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.
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 a variable declaration or definition.
Represents a variable template specialization, which refers to a variable template with a given set o...
Represents a GCC generic vector type.
QualType getElementType() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
RequirementKind getKind() const
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool Sub(InterpState &S, CodePtr OpPC)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
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.
@ Ctor_Unified
GCC-style unified dtor.
bool isa(CodeGen::Address addr)
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 (&&).
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
CXXDtorType
C++ destructor types.
@ Dtor_Comdat
The COMDAT used for dtors.
@ Dtor_Unified
GCC-style unified dtor.
@ Dtor_Base
Base object dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
@ Type
The name was classified as a type.
@ Concept
The name was classified as a concept name.
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.
U cast(CodeGen::Address addr)
void mangleObjCMethodName(raw_ostream &OS, bool includePrefixByte, bool isInstanceMethod, StringRef ClassName, std::optional< StringRef > CategoryName, StringRef MethodName)
Extract mangling function name from MangleContext such that swift can call it to prepare for ObjCDire...
@ 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
ArrayRef< TemplateArgumentLoc > arguments() const
const Expr * ConstraintExpr
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
union clang::ReturnAdjustment::VirtualAdjustment Virtual
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
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::@103031170252120233124322035264172076254313213024 Itanium
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
struct clang::ThisAdjustment::VirtualAdjustment::@106065375072164260365214033034320247050276346205 Itanium
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset.