34#include "llvm/ADT/StringExtras.h"
35#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/raw_ostream.h"
37#include "llvm/TargetParser/RISCVTargetParser.h"
44static bool isLocalContainerContext(
const DeclContext *DC) {
45 return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
50 return ftd->getTemplatedDecl();
57 return (fn ? getStructor(fn) :
decl);
60static bool isLambda(
const NamedDecl *ND) {
68static const unsigned UnknownArity = ~0
U;
71 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
72 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
73 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
74 const DiscriminatorOverrideTy DiscriminatorOverride =
nullptr;
77 bool NeedsUniqueInternalLinkageNames =
false;
80 explicit ItaniumMangleContextImpl(
82 DiscriminatorOverrideTy DiscriminatorOverride,
bool IsAux =
false)
84 DiscriminatorOverride(DiscriminatorOverride) {}
96 NeedsUniqueInternalLinkageNames =
true;
101 raw_ostream &)
override;
103 const ThunkInfo &Thunk,
bool, raw_ostream &)
override;
105 raw_ostream &)
override;
112 bool NormalizeIntegers)
override;
114 bool NormalizeIntegers)
override;
121 raw_ostream &Out)
override;
124 raw_ostream &Out)
override;
126 raw_ostream &Out)
override;
129 raw_ostream &)
override;
137 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
143 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
144 if (
Tag->getName().empty() && !
Tag->getTypedefNameForAnonDecl())
151 if (discriminator == 1)
153 disc = discriminator - 2;
158 unsigned &discriminator = Uniquifier[ND];
159 if (!discriminator) {
160 const DeclContext *DC = getEffectiveDeclContext(ND);
161 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
163 if (discriminator == 1)
165 disc = discriminator-2;
172 assert(Lambda->
isLambda() &&
"RD must be a lambda!");
173 std::string Name(
"<lambda");
177 const ParmVarDecl *Parm = dyn_cast_or_null<ParmVarDecl>(LambdaContextDecl);
182 unsigned DefaultArgNo =
184 Name += llvm::utostr(DefaultArgNo);
188 if (LambdaManglingNumber)
189 LambdaId = LambdaManglingNumber;
193 Name += llvm::utostr(LambdaId);
199 return DiscriminatorOverride;
206 return getEffectiveDeclContext(cast<Decl>(DC));
209 bool isInternalLinkageDecl(
const NamedDecl *ND);
215class CXXNameMangler {
216 ItaniumMangleContextImpl &Context;
220 bool NormalizeIntegers =
false;
222 bool NullOut =
false;
227 bool DisableDerivedAbiTags =
false;
233 unsigned StructorType = 0;
238 unsigned TemplateDepthOffset = 0;
243 class FunctionTypeDepthState {
246 enum { InResultTypeMask = 1 };
249 FunctionTypeDepthState() =
default;
252 unsigned getDepth()
const {
257 bool isInResultType()
const {
258 return Bits & InResultTypeMask;
261 FunctionTypeDepthState push() {
262 FunctionTypeDepthState tmp = *
this;
263 Bits = (Bits & ~InResultTypeMask) + 2;
267 void enterResultType() {
268 Bits |= InResultTypeMask;
271 void leaveResultType() {
272 Bits &= ~InResultTypeMask;
275 void pop(FunctionTypeDepthState saved) {
276 assert(getDepth() == saved.getDepth() + 1);
291 class AbiTagState final {
293 explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
299 AbiTagState(
const AbiTagState &) =
delete;
300 AbiTagState &operator=(
const AbiTagState &) =
delete;
302 ~AbiTagState() { pop(); }
304 void write(raw_ostream &Out,
const NamedDecl *ND,
305 const AbiTagList *AdditionalAbiTags) {
307 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
309 !AdditionalAbiTags &&
310 "only function and variables need a list of additional abi tags");
311 if (
const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
312 if (
const auto *AbiTag = NS->getAttr<AbiTagAttr>())
313 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");
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(); }
392 return Context.getASTContext().
getLangOpts().getClangABICompat() <= Ver;
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) {
409 assert(!
D || (!isa<CXXDestructorDecl>(
D) &&
410 !isa<CXXConstructorDecl>(
D)));
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);
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);
455 void mangleSeqID(
unsigned SeqID);
459 bool SuppressSubstitution =
false);
461 void mangleModuleNamePrefix(StringRef Name,
bool IsPartition =
false);
462 void mangleVendorQualifier(StringRef Name);
463 void mangleVendorType(StringRef Name);
466 bool mangleSubstitution(
const NamedDecl *ND);
473 bool mangleStandardSubstitution(
const NamedDecl *ND);
475 void addSubstitution(
const NamedDecl *ND) {
478 addSubstitution(
reinterpret_cast<uintptr_t>(ND));
484 void extendSubstitutions(CXXNameMangler*
Other);
487 bool recursive =
false);
490 unsigned NumTemplateArgs,
491 unsigned KnownArity = UnknownArity);
493 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
496 const AbiTagList *AdditionalAbiTags);
497 void mangleModuleName(
const NamedDecl *ND);
501 const AbiTagList *AdditionalAbiTags) {
502 mangleUnqualifiedName(GD, cast<NamedDecl>(GD.
getDecl())->getDeclName(), DC,
503 UnknownArity, AdditionalAbiTags);
507 const AbiTagList *AdditionalAbiTags);
509 const AbiTagList *AdditionalAbiTags);
511 const AbiTagList *AdditionalAbiTags);
516 void mangleSourceNameWithAbiTags(
517 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
519 const AbiTagList *AdditionalAbiTags);
527 void mangleRequiresClause(
const Expr *RequiresClause);
530 const AbiTagList *AdditionalAbiTags,
531 bool NoFunction=
false);
534 void mangleNestedNameWithClosurePrefix(
GlobalDecl GD,
536 const AbiTagList *AdditionalAbiTags);
538 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
540 void mangleTemplatePrefix(
GlobalDecl GD,
bool NoFunction=
false);
543 void mangleClosurePrefix(
const NamedDecl *ND,
bool NoFunction =
false);
544 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
545 StringRef Prefix =
"");
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(),
629 &getASTContext().Idents.get(
"std"),
639ItaniumMangleContextImpl::getEffectiveDeclContext(
const Decl *
D) {
649 dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
650 return ContextParam->getDeclContext();
654 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(
D)) {
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();
672 if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC) ||
673 isa<OMPDeclareMapperDecl>(DC)) {
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(
710 if (!NeedsUniqueInternalLinkageNames || !ND)
713 const auto *FD = dyn_cast<FunctionDecl>(ND);
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)) {
767 if (isa<DecompositionDecl>(VD))
780 DC = getEffectiveParentContext(DC);
782 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
783 !isa<VarTemplateSpecializationDecl>(VD) &&
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);
808 if (isa<FunctionDecl>(GD.
getDecl()))
809 mangleFunctionEncoding(GD);
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);
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;
935 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
936 isa<CXXConversionDecl>(FD)))
937 MangleReturnType =
true;
940 FD = PrimaryTemplate->getTemplatedDecl();
944 MangleReturnType, FD);
949 if (!Context.getEffectiveParentContext(NS)->isTranslationUnit())
953 return II && II->
isStr(
"std");
958bool CXXNameMangler::isStdNamespace(
const DeclContext *DC) {
962 return isStd(cast<NamespaceDecl>(DC));
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);
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);
1067 assert(!isa<LinkageSpecDecl>(DC) &&
"context cannot be LinkageSpecDecl");
1071 if (
const NamedDecl *PrefixND = getClosurePrefix(ND)) {
1072 mangleNestedNameWithClosurePrefix(GD, PrefixND, AdditionalAbiTags);
1076 if (isLocalContainerContext(DC)) {
1077 mangleLocalName(GD, AdditionalAbiTags);
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,
1139 const DeclContext *DC = Context.getEffectiveDeclContext(TD);
1142 mangleUnscopedTemplateName(TD, DC,
nullptr);
1145 mangleNestedName(TD, Args);
1150 const AbiTagList *AdditionalAbiTags) {
1154 assert(!isa<LinkageSpecDecl>(DC) &&
"unskipped LinkageSpecDecl");
1155 if (isStdNamespace(DC)) {
1156 if (getASTContext().getTargetInfo().getTriple().isOSSolaris()) {
1158 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND)) {
1165 if (llvm::is_contained({
"div_t",
"ldiv_t",
"lconv",
"tm"},
type)) {
1175 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1178void CXXNameMangler::mangleUnscopedTemplateName(
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());
1191 }
else if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND)) {
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);
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() {
1257void CXXNameMangler::mangleNullPointer(
QualType T) {
1264void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
1265 if (
Value.isSigned() &&
Value.isNegative()) {
1273void CXXNameMangler::mangleNumber(int64_t Number) {
1283void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t
Virtual) {
1291 mangleNumber(NonVirtual);
1297 mangleNumber(NonVirtual);
1305 if (!mangleSubstitution(
QualType(TST, 0))) {
1306 mangleTemplatePrefix(TST->getTemplateName());
1311 mangleTemplateArgs(TST->getTemplateName(), TST->template_arguments());
1314 }
else if (
const auto *DTST =
1316 if (!mangleSubstitution(
QualType(DTST, 0))) {
1318 DTST->getDependentTemplateName());
1324 mangleTemplateArgs(
Template, DTST->template_arguments());
1325 addSubstitution(
QualType(DTST, 0));
1329 bool Clang14Compat = isCompatibleWith(LangOptions::ClangABI::Ver14);
1330 if (!Clang14Compat && mangleSubstitution(
QualType(DNT, 0)))
1335 assert(DNT->getQualifier());
1336 manglePrefix(DNT->getQualifier());
1338 mangleSourceName(DNT->getIdentifier());
1371 case NestedNameSpecifier::Kind::Null:
1372 llvm_unreachable(
"unexpected null nested name specifier");
1374 case NestedNameSpecifier::Kind::Global:
1384 case NestedNameSpecifier::Kind::MicrosoftSuper:
1385 llvm_unreachable(
"Can't mangle __super specifier");
1387 case NestedNameSpecifier::Kind::Namespace: {
1390 mangleUnresolvedPrefix(Prefix,
1394 mangleSourceNameWithAbiTags(Namespace);
1398 case NestedNameSpecifier::Kind::Type: {
1407 mangleUnresolvedPrefix(Prefix,
1414 if (mangleUnresolvedTypeOrSimpleId(
QualType(
type, 0), recursive ?
"N" :
""))
1429void CXXNameMangler::mangleUnresolvedName(
1432 unsigned knownArity) {
1434 mangleUnresolvedPrefix(Qualifier);
1435 switch (
name.getNameKind()) {
1438 mangleSourceName(
name.getAsIdentifierInfo());
1443 mangleUnresolvedTypeOrSimpleId(
name.getCXXNameType());
1450 mangleOperatorName(name, knownArity);
1453 llvm_unreachable(
"Can't mangle a constructor name!");
1455 llvm_unreachable(
"Can't mangle a using directive name!");
1457 llvm_unreachable(
"Can't mangle a deduction guide name!");
1461 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1467 mangleTemplateArgs(
TemplateName(), TemplateArgs, NumTemplateArgs);
1470void CXXNameMangler::mangleUnqualifiedName(
1472 unsigned KnownArity,
const AbiTagList *AdditionalAbiTags) {
1480 mangleModuleName(ND);
1484 auto *FD = dyn_cast<FunctionDecl>(ND);
1485 auto *FTD = dyn_cast<FunctionTemplateDecl>(ND);
1487 (FTD && FTD->getTemplatedDecl()->isMemberLikeConstrainedFriend())) {
1488 if (!isCompatibleWith(LangOptions::ClangABI::Ver17))
1492 unsigned Arity = KnownArity;
1493 switch (Name.getNameKind()) {
1498 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1505 for (
auto *BD : DD->bindings())
1506 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1508 writeAbiTags(ND, AdditionalAbiTags);
1512 if (
auto *GD = dyn_cast<MSGuidDecl>(ND)) {
1515 SmallString<
sizeof(
"_GUID_12345678_1234_1234_1234_1234567890ab")> GUID;
1516 llvm::raw_svector_ostream GUIDOS(GUID);
1517 Context.mangleMSGuidDecl(GD, GUIDOS);
1518 Out << GUID.size() << GUID;
1522 if (
auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
1525 mangleValueInTemplateArg(TPO->getType().getUnqualifiedType(),
1526 TPO->getValue(),
true);
1544 if (Context.isInternalLinkageDecl(ND))
1547 bool IsRegCall = FD &&
1551 FD && FD->
hasAttr<CUDAGlobalAttr>() &&
1553 bool IsOCLDeviceStub =
1555 DeviceKernelAttr::isOpenCLSpelling(FD->
getAttr<DeviceKernelAttr>()) &&
1558 mangleDeviceStubName(II);
1559 else if (IsOCLDeviceStub)
1560 mangleOCLDeviceStubName(II);
1562 mangleRegCallName(II);
1564 mangleSourceName(II);
1566 writeAbiTags(ND, AdditionalAbiTags);
1571 assert(ND &&
"mangling empty name without declaration");
1573 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1576 Out <<
"12_GLOBAL__N_1";
1581 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1583 const auto *RD = VD->getType()->castAsRecordDecl();
1594 assert(RD->isAnonymousStructOrUnion()
1595 &&
"Expected anonymous struct or union!");
1596 const FieldDecl *FD = RD->findFirstNamedDataMember();
1602 assert(FD->
getIdentifier() &&
"Data member name isn't an identifier!");
1615 if (isa<ObjCContainerDecl>(ND))
1619 const TagDecl *TD = cast<TagDecl>(ND);
1622 "Typedef should not be in another decl context!");
1623 assert(
D->getDeclName().getAsIdentifierInfo() &&
1624 "Typedef was not named!");
1625 mangleSourceName(
D->getDeclName().getAsIdentifierInfo());
1626 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1629 writeAbiTags(TD,
nullptr);
1640 Context.getDiscriminatorOverride()(Context.getASTContext(),
Record);
1646 if (
Record->isLambda() &&
1647 ((DeviceNumber && *DeviceNumber > 0) ||
1648 (!DeviceNumber &&
Record->getLambdaManglingNumber() > 0))) {
1649 assert(!AdditionalAbiTags &&
1650 "Lambda type cannot have additional abi tags");
1657 unsigned UnnamedMangle =
1658 getASTContext().getManglingNumber(TD, Context.isAux());
1660 if (UnnamedMangle > 1)
1661 Out << UnnamedMangle - 2;
1663 writeAbiTags(TD, AdditionalAbiTags);
1669 unsigned AnonStructId =
1671 : Context.getAnonymousStructId(TD, dyn_cast<FunctionDecl>(DC));
1678 Str += llvm::utostr(AnonStructId);
1688 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1694 if (
auto Inherited =
1695 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1696 InheritedFrom = Inherited.getConstructor()->
getParent();
1697 InheritedTemplateName =
1698 TemplateName(Inherited.getConstructor()->getPrimaryTemplate());
1699 InheritedTemplateArgs =
1700 Inherited.getConstructor()->getTemplateSpecializationArgs();
1706 mangleCXXCtorType(
static_cast<CXXCtorType>(StructorType), InheritedFrom);
1714 if (InheritedTemplateArgs)
1715 mangleTemplateArgs(InheritedTemplateName, *InheritedTemplateArgs);
1717 writeAbiTags(ND, AdditionalAbiTags);
1725 mangleCXXDtorType(
static_cast<CXXDtorType>(StructorType));
1731 writeAbiTags(ND, AdditionalAbiTags);
1735 if (ND && Arity == UnknownArity) {
1736 Arity = cast<FunctionDecl>(ND)->getNumParams();
1739 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1740 if (MD->isImplicitObjectMemberFunction())
1746 mangleOperatorName(Name, Arity);
1747 writeAbiTags(ND, AdditionalAbiTags);
1751 llvm_unreachable(
"Can't mangle a deduction guide name!");
1754 llvm_unreachable(
"Can't mangle a using directive name!");
1758void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1762 if (getASTContext().getLangOpts().RegCall4)
1763 Out << II->
getLength() +
sizeof(
"__regcall4__") - 1 <<
"__regcall4__"
1766 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__"
1770void CXXNameMangler::mangleDeviceStubName(
const IdentifierInfo *II) {
1774 Out << II->
getLength() +
sizeof(
"__device_stub__") - 1 <<
"__device_stub__"
1778void CXXNameMangler::mangleOCLDeviceStubName(
const IdentifierInfo *II) {
1782 StringRef OCLDeviceStubNamePrefix =
"__clang_ocl_kern_imp_";
1783 Out << II->
getLength() + OCLDeviceStubNamePrefix.size()
1784 << OCLDeviceStubNamePrefix << II->
getName();
1794void CXXNameMangler::mangleNestedName(
GlobalDecl GD,
1796 const AbiTagList *AdditionalAbiTags,
1805 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1809 if (
Method->isExplicitObjectMemberFunction())
1812 mangleQualifiers(MethodQuals);
1813 mangleRefQualifier(
Method->getRefQualifier());
1819 mangleTemplatePrefix(TD, NoFunction);
1822 manglePrefix(DC, NoFunction);
1823 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1828void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1834 mangleTemplatePrefix(TD);
1840void CXXNameMangler::mangleNestedNameWithClosurePrefix(
1842 const AbiTagList *AdditionalAbiTags) {
1851 mangleClosurePrefix(PrefixND);
1852 mangleUnqualifiedName(GD,
nullptr, AdditionalAbiTags);
1863 if (
auto *CD = dyn_cast<CXXConstructorDecl>(DC))
1865 else if (
auto *DD = dyn_cast<CXXDestructorDecl>(DC))
1872void CXXNameMangler::mangleLocalName(
GlobalDecl GD,
1873 const AbiTagList *AdditionalAbiTags) {
1880 assert(isa<NamedDecl>(
D) || isa<BlockDecl>(
D));
1882 const DeclContext *DC = Context.getEffectiveDeclContext(RD ? RD :
D);
1887 AbiTagState LocalAbiTags(AbiTags);
1891 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1892 mangleBlockForPrefix(BD);
1898 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1921 mangleNumber(
Num - 2);
1930 mangleUnqualifiedName(RD, DC, AdditionalAbiTags);
1931 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(
D)) {
1932 if (
const NamedDecl *PrefixND = getClosurePrefix(BD))
1933 mangleClosurePrefix(PrefixND,
true );
1935 manglePrefix(Context.getEffectiveDeclContext(BD),
true );
1936 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1937 mangleUnqualifiedBlock(BD);
1940 mangleNestedName(GD, Context.getEffectiveDeclContext(ND),
1941 AdditionalAbiTags,
true );
1943 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(
D)) {
1947 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1953 mangleNumber(
Num - 2);
1958 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1959 mangleUnqualifiedBlock(BD);
1961 mangleUnqualifiedName(GD, DC, AdditionalAbiTags);
1964 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD :
D)) {
1966 if (Context.getNextDiscriminator(ND, disc)) {
1970 Out <<
"__" << disc <<
'_';
1975void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *
Block) {
1976 if (GetLocalClassDecl(
Block)) {
1977 mangleLocalName(
Block,
nullptr);
1981 if (isLocalContainerContext(DC)) {
1982 mangleLocalName(
Block,
nullptr);
1986 mangleClosurePrefix(PrefixND);
1989 mangleUnqualifiedBlock(
Block);
1992void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *
Block) {
1995 if (
Decl *Context =
Block->getBlockManglingContextDecl()) {
1996 if (isCompatibleWith(LangOptions::ClangABI::Ver12) &&
1997 (isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1998 Context->getDeclContext()->isRecord()) {
1999 const auto *ND = cast<NamedDecl>(Context);
2001 mangleSourceNameWithAbiTags(ND);
2008 unsigned Number =
Block->getBlockManglingNumber();
2012 Number = Context.getBlockId(
Block,
false);
2030void CXXNameMangler::mangleTemplateParamDecl(
const NamedDecl *
Decl) {
2032 if (
auto *Ty = dyn_cast<TemplateTypeParmDecl>(
Decl)) {
2033 if (Ty->isParameterPack())
2036 if (Constraint && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
2039 mangleTypeConstraint(Constraint);
2043 }
else if (
auto *Tn = dyn_cast<NonTypeTemplateParmDecl>(
Decl)) {
2044 if (Tn->isExpandedParameterPack()) {
2045 for (
unsigned I = 0, N = Tn->getNumExpansionTypes(); I != N; ++I) {
2047 mangleType(Tn->getExpansionType(I));
2051 if (Tn->isParameterPack()) {
2054 T = PackExpansion->getPattern();
2059 }
else if (
auto *Tt = dyn_cast<TemplateTemplateParmDecl>(
Decl)) {
2060 if (Tt->isExpandedParameterPack()) {
2061 for (
unsigned I = 0, N = Tt->getNumExpansionTemplateParameters(); I != N;
2063 mangleTemplateParameterList(Tt->getExpansionTemplateParameters(I));
2065 if (Tt->isParameterPack())
2067 mangleTemplateParameterList(Tt->getTemplateParameters());
2072void CXXNameMangler::mangleTemplateParameterList(
2075 for (
auto *Param : *Params)
2076 mangleTemplateParamDecl(Param);
2077 mangleRequiresClause(Params->getRequiresClause());
2081void CXXNameMangler::mangleTypeConstraint(
2085 mangleTemplateName(
Concept, Arguments);
2087 mangleUnscopedName(
Concept, DC,
nullptr);
2089 mangleNestedName(
Concept, DC,
nullptr);
2092void CXXNameMangler::mangleTypeConstraint(
const TypeConstraint *Constraint) {
2097 Args.push_back(ArgLoc.getArgument());
2102void CXXNameMangler::mangleRequiresClause(
const Expr *RequiresClause) {
2104 if (RequiresClause && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
2106 mangleExpression(RequiresClause);
2110void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
2114 if (isCompatibleWith(LangOptions::ClangABI::Ver12) &&
2115 (isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
2116 !isa<ParmVarDecl>(Context)) {
2119 mangleSourceName(Name);
2129 mangleLambdaSig(Lambda);
2144 Context.getDiscriminatorOverride()(Context.getASTContext(), Lambda);
2148 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
2150 mangleNumber(Number - 2);
2154void CXXNameMangler::mangleLambdaSig(
const CXXRecordDecl *Lambda) {
2157 mangleTemplateParamDecl(
D);
2161 mangleRequiresClause(TPL->getRequiresClause());
2165 mangleBareFunctionType(Proto,
false,
2171 case NestedNameSpecifier::Kind::Null:
2172 case NestedNameSpecifier::Kind::Global:
2176 case NestedNameSpecifier::Kind::MicrosoftSuper:
2177 llvm_unreachable(
"Can't mangle __super specifier");
2179 case NestedNameSpecifier::Kind::Namespace:
2180 mangleName(
Qualifier.getAsNamespaceAndPrefix().Namespace->getNamespace());
2183 case NestedNameSpecifier::Kind::Type:
2188 llvm_unreachable(
"unexpected nested name specifier");
2191void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
2199 assert(!isa<LinkageSpecDecl>(DC) &&
"prefix cannot be LinkageSpecDecl");
2204 if (NoFunction && isLocalContainerContext(DC))
2207 const NamedDecl *ND = cast<NamedDecl>(DC);
2208 if (mangleSubstitution(ND))
2214 mangleTemplatePrefix(TD);
2216 }
else if (
const NamedDecl *PrefixND = getClosurePrefix(ND)) {
2217 mangleClosurePrefix(PrefixND, NoFunction);
2218 mangleUnqualifiedName(ND,
nullptr,
nullptr);
2220 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
2221 manglePrefix(DC, NoFunction);
2222 mangleUnqualifiedName(ND, DC,
nullptr);
2225 addSubstitution(ND);
2233 return mangleTemplatePrefix(TD);
2236 assert(
Dependent &&
"unexpected template name kind");
2240 bool Clang11Compat = isCompatibleWith(LangOptions::ClangABI::Ver11);
2241 if (!Clang11Compat && mangleSubstitution(
Template))
2244 manglePrefix(
Dependent->getQualifier());
2246 if (Clang11Compat && mangleSubstitution(
Template))
2251 mangleSourceName(
Id);
2253 mangleOperatorName(Name.getOperator(), UnknownArity);
2258void CXXNameMangler::mangleTemplatePrefix(
GlobalDecl GD,
2267 if (mangleSubstitution(ND))
2271 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
2272 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
2274 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
2275 manglePrefix(DC, NoFunction);
2276 if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND))
2277 mangleUnqualifiedName(GD, DC,
nullptr);
2283 addSubstitution(ND);
2286const NamedDecl *CXXNameMangler::getClosurePrefix(
const Decl *ND) {
2287 if (isCompatibleWith(LangOptions::ClangABI::Ver12))
2291 if (
auto *
Block = dyn_cast<BlockDecl>(ND)) {
2292 Context = dyn_cast_or_null<NamedDecl>(
Block->getBlockManglingContextDecl());
2293 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
2295 Context = dyn_cast_or_null<NamedDecl>(RD->getLambdaContextDecl());
2302 if ((isa<VarDecl>(Context) && cast<VarDecl>(Context)->hasGlobalStorage()) ||
2303 isa<FieldDecl>(Context))
2309void CXXNameMangler::mangleClosurePrefix(
const NamedDecl *ND,
bool NoFunction) {
2312 if (mangleSubstitution(ND))
2317 mangleTemplatePrefix(TD, NoFunction);
2320 const auto *DC = Context.getEffectiveDeclContext(ND);
2321 manglePrefix(DC, NoFunction);
2322 mangleUnqualifiedName(ND, DC,
nullptr);
2327 addSubstitution(ND);
2336 if (mangleSubstitution(TN))
2349 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TD))
2350 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
2357 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
2366 mangleUnresolvedPrefix(
Dependent->getQualifier());
2367 mangleSourceName(II);
2387 Out <<
"_SUBSTPACK_";
2391 llvm_unreachable(
"Unexpected DeducedTemplate");
2394 addSubstitution(TN);
2397bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
2403 case Type::Adjusted:
2405 case Type::ArrayParameter:
2407 case Type::BlockPointer:
2408 case Type::LValueReference:
2409 case Type::RValueReference:
2410 case Type::MemberPointer:
2411 case Type::ConstantArray:
2412 case Type::IncompleteArray:
2413 case Type::VariableArray:
2414 case Type::DependentSizedArray:
2415 case Type::DependentAddressSpace:
2416 case Type::DependentVector:
2417 case Type::DependentSizedExtVector:
2419 case Type::ExtVector:
2420 case Type::ConstantMatrix:
2421 case Type::DependentSizedMatrix:
2422 case Type::FunctionProto:
2423 case Type::FunctionNoProto:
2425 case Type::Attributed:
2426 case Type::BTFTagAttributed:
2427 case Type::HLSLAttributedResource:
2428 case Type::HLSLInlineSpirv:
2430 case Type::DeducedTemplateSpecialization:
2431 case Type::PackExpansion:
2432 case Type::ObjCObject:
2433 case Type::ObjCInterface:
2434 case Type::ObjCObjectPointer:
2435 case Type::ObjCTypeParam:
2438 case Type::MacroQualified:
2440 case Type::DependentBitInt:
2441 case Type::CountAttributed:
2442 llvm_unreachable(
"type is illegal as a nested name specifier");
2444 case Type::SubstBuiltinTemplatePack:
2449 Out <<
"_SUBSTBUILTINPACK_";
2451 case Type::SubstTemplateTypeParmPack:
2456 Out <<
"_SUBSTPACK_";
2463 case Type::TypeOfExpr:
2465 case Type::Decltype:
2466 case Type::PackIndexing:
2467 case Type::TemplateTypeParm:
2468 case Type::UnaryTransform:
2481 case Type::SubstTemplateTypeParm: {
2482 auto *ST = cast<SubstTemplateTypeParmType>(Ty);
2485 if (
auto *TD = dyn_cast<TemplateDecl>(ST->getAssociatedDecl());
2487 return mangleUnresolvedTypeOrSimpleId(ST->getReplacementType(), Prefix);
2488 goto unresolvedType;
2492 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
2495 case Type::PredefinedSugar:
2496 mangleType(cast<PredefinedSugarType>(Ty)->desugar());
2499 case Type::UnresolvedUsing:
2500 mangleSourceNameWithAbiTags(
2501 cast<UnresolvedUsingType>(Ty)->getDecl());
2506 mangleSourceNameWithAbiTags(
2510 case Type::TemplateSpecialization: {
2512 cast<TemplateSpecializationType>(Ty);
2521 assert(TD &&
"no template for template specialization type");
2522 if (isa<TemplateTemplateParmDecl>(TD))
2523 goto unresolvedType;
2525 mangleSourceNameWithAbiTags(TD);
2533 llvm_unreachable(
"invalid base for a template specialization type");
2547 Out <<
"_SUBSTPACK_";
2552 assert(TD && !isa<TemplateTemplateParmDecl>(TD));
2553 mangleSourceNameWithAbiTags(TD);
2567 case Type::InjectedClassName:
2568 mangleSourceNameWithAbiTags(cast<InjectedClassNameType>(Ty)
2573 case Type::DependentName:
2574 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
2577 case Type::DependentTemplateSpecialization: {
2579 cast<DependentTemplateSpecializationType>(Ty);
2583 mangleSourceName(S.getName().getIdentifier());
2589 return mangleUnresolvedTypeOrSimpleId(cast<UsingType>(Ty)->desugar(),
2596void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
2597 switch (Name.getNameKind()) {
2606 llvm_unreachable(
"Not an operator name");
2611 mangleType(Name.getCXXNameType());
2616 mangleSourceName(Name.getCXXLiteralIdentifier());
2620 mangleOperatorName(Name.getCXXOverloadedOperator(), Arity);
2629 case OO_New: Out <<
"nw";
break;
2631 case OO_Array_New: Out <<
"na";
break;
2633 case OO_Delete: Out <<
"dl";
break;
2635 case OO_Array_Delete: Out <<
"da";
break;
2639 Out << (Arity == 1?
"ps" :
"pl");
break;
2643 Out << (Arity == 1?
"ng" :
"mi");
break;
2647 Out << (Arity == 1?
"ad" :
"an");
break;
2652 Out << (Arity == 1?
"de" :
"ml");
break;
2654 case OO_Tilde: Out <<
"co";
break;
2656 case OO_Slash: Out <<
"dv";
break;
2658 case OO_Percent: Out <<
"rm";
break;
2660 case OO_Pipe: Out <<
"or";
break;
2662 case OO_Caret: Out <<
"eo";
break;
2664 case OO_Equal: Out <<
"aS";
break;
2666 case OO_PlusEqual: Out <<
"pL";
break;
2668 case OO_MinusEqual: Out <<
"mI";
break;
2670 case OO_StarEqual: Out <<
"mL";
break;
2672 case OO_SlashEqual: Out <<
"dV";
break;
2674 case OO_PercentEqual: Out <<
"rM";
break;
2676 case OO_AmpEqual: Out <<
"aN";
break;
2678 case OO_PipeEqual: Out <<
"oR";
break;
2680 case OO_CaretEqual: Out <<
"eO";
break;
2682 case OO_LessLess: Out <<
"ls";
break;
2684 case OO_GreaterGreater: Out <<
"rs";
break;
2686 case OO_LessLessEqual: Out <<
"lS";
break;
2688 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2690 case OO_EqualEqual: Out <<
"eq";
break;
2692 case OO_ExclaimEqual: Out <<
"ne";
break;
2694 case OO_Less: Out <<
"lt";
break;
2696 case OO_Greater: Out <<
"gt";
break;
2698 case OO_LessEqual: Out <<
"le";
break;
2700 case OO_GreaterEqual: Out <<
"ge";
break;
2702 case OO_Exclaim: Out <<
"nt";
break;
2704 case OO_AmpAmp: Out <<
"aa";
break;
2706 case OO_PipePipe: Out <<
"oo";
break;
2708 case OO_PlusPlus: Out <<
"pp";
break;
2710 case OO_MinusMinus: Out <<
"mm";
break;
2712 case OO_Comma: Out <<
"cm";
break;
2714 case OO_ArrowStar: Out <<
"pm";
break;
2716 case OO_Arrow: Out <<
"pt";
break;
2718 case OO_Call: Out <<
"cl";
break;
2720 case OO_Subscript: Out <<
"ix";
break;
2725 case OO_Conditional: Out <<
"qu";
break;
2728 case OO_Coawait: Out <<
"aw";
break;
2731 case OO_Spaceship: Out <<
"ss";
break;
2735 llvm_unreachable(
"Not an overloaded operator");
2764 if (TargetAS != 0 ||
2766 ASString =
"AS" + llvm::utostr(TargetAS);
2769 default: llvm_unreachable(
"Not a language specific address space");
2773 case LangAS::opencl_global:
2774 ASString =
"CLglobal";
2776 case LangAS::opencl_global_device:
2777 ASString =
"CLdevice";
2779 case LangAS::opencl_global_host:
2780 ASString =
"CLhost";
2782 case LangAS::opencl_local:
2783 ASString =
"CLlocal";
2785 case LangAS::opencl_constant:
2786 ASString =
"CLconstant";
2788 case LangAS::opencl_private:
2789 ASString =
"CLprivate";
2791 case LangAS::opencl_generic:
2792 ASString =
"CLgeneric";
2796 case LangAS::sycl_global:
2797 ASString =
"SYglobal";
2799 case LangAS::sycl_global_device:
2800 ASString =
"SYdevice";
2802 case LangAS::sycl_global_host:
2803 ASString =
"SYhost";
2805 case LangAS::sycl_local:
2806 ASString =
"SYlocal";
2808 case LangAS::sycl_private:
2809 ASString =
"SYprivate";
2812 case LangAS::cuda_device:
2813 ASString =
"CUdevice";
2815 case LangAS::cuda_constant:
2816 ASString =
"CUconstant";
2818 case LangAS::cuda_shared:
2819 ASString =
"CUshared";
2822 case LangAS::ptr32_sptr:
2823 ASString =
"ptr32_sptr";
2825 case LangAS::ptr32_uptr:
2829 if (!getASTContext().getTargetInfo().getTriple().isOSzOS())
2830 ASString =
"ptr32_uptr";
2837 if (!ASString.empty())
2838 mangleVendorQualifier(ASString);
2851 mangleVendorQualifier(
"__weak");
2855 mangleVendorQualifier(
"__unaligned");
2859 mangleVendorQualifier(
"__ptrauth");
2869 <<
unsigned(PtrAuth.isAddressDiscriminated())
2872 << PtrAuth.getExtraDiscriminator()
2887 mangleVendorQualifier(
"__strong");
2891 mangleVendorQualifier(
"__autoreleasing");
2914void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2918void CXXNameMangler::mangleVendorType(StringRef name) {
2925 switch (RefQualifier) {
2939void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2940 Context.mangleObjCMethodNameAsSourceName(MD, Out);
2953 Ctx.
getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver17)
2959 if (Ctx.
getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver6 &&
2966 if (DeducedTST->getDeducedType().isNull())
2971void CXXNameMangler::mangleType(
QualType T) {
3005 T =
T.getCanonicalType();
3012 = dyn_cast<TemplateSpecializationType>(
T))
3021 =
T.getSingleStepDesugaredType(Context.getASTContext());
3030 const Type *ty = split.
Ty;
3032 bool isSubstitutable =
3034 if (isSubstitutable && mangleSubstitution(
T))
3039 if (quals && isa<ArrayType>(
T)) {
3049 dyn_cast<DependentAddressSpaceType>(ty)) {
3051 mangleQualifiers(splitDAST.
Quals, DAST);
3054 mangleQualifiers(quals);
3062#define ABSTRACT_TYPE(CLASS, PARENT)
3063#define NON_CANONICAL_TYPE(CLASS, PARENT) \
3065 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
3067#define TYPE(CLASS, PARENT) \
3069 mangleType(static_cast<const CLASS##Type*>(ty)); \
3071#include "clang/AST/TypeNodes.inc"
3076 if (isSubstitutable)
3081 bool SuppressSubstitution) {
3082 if (mangleSubstitution(
Record))
3085 if (SuppressSubstitution)
3132 std::string type_name;
3136 if (NormalizeIntegers &&
T->isInteger()) {
3137 if (
T->isSignedInteger()) {
3138 switch (getASTContext().getTypeSize(
T)) {
3142 if (mangleSubstitution(BuiltinType::SChar))
3145 addSubstitution(BuiltinType::SChar);
3148 if (mangleSubstitution(BuiltinType::Short))
3151 addSubstitution(BuiltinType::Short);
3154 if (mangleSubstitution(BuiltinType::Int))
3157 addSubstitution(BuiltinType::Int);
3160 if (mangleSubstitution(BuiltinType::Long))
3163 addSubstitution(BuiltinType::Long);
3166 if (mangleSubstitution(BuiltinType::Int128))
3169 addSubstitution(BuiltinType::Int128);
3172 llvm_unreachable(
"Unknown integer size for normalization");
3175 switch (getASTContext().getTypeSize(
T)) {
3177 if (mangleSubstitution(BuiltinType::UChar))
3180 addSubstitution(BuiltinType::UChar);
3183 if (mangleSubstitution(BuiltinType::UShort))
3186 addSubstitution(BuiltinType::UShort);
3189 if (mangleSubstitution(BuiltinType::UInt))
3192 addSubstitution(BuiltinType::UInt);
3195 if (mangleSubstitution(BuiltinType::ULong))
3198 addSubstitution(BuiltinType::ULong);
3201 if (mangleSubstitution(BuiltinType::UInt128))
3204 addSubstitution(BuiltinType::UInt128);
3207 llvm_unreachable(
"Unknown integer size for normalization");
3212 switch (
T->getKind()) {
3213 case BuiltinType::Void:
3216 case BuiltinType::Bool:
3219 case BuiltinType::Char_U:
3220 case BuiltinType::Char_S:
3223 case BuiltinType::UChar:
3226 case BuiltinType::UShort:
3229 case BuiltinType::UInt:
3232 case BuiltinType::ULong:
3235 case BuiltinType::ULongLong:
3238 case BuiltinType::UInt128:
3241 case BuiltinType::SChar:
3244 case BuiltinType::WChar_S:
3245 case BuiltinType::WChar_U:
3248 case BuiltinType::Char8:
3251 case BuiltinType::Char16:
3254 case BuiltinType::Char32:
3257 case BuiltinType::Short:
3260 case BuiltinType::Int:
3263 case BuiltinType::Long:
3266 case BuiltinType::LongLong:
3269 case BuiltinType::Int128:
3272 case BuiltinType::Float16:
3275 case BuiltinType::ShortAccum:
3278 case BuiltinType::Accum:
3281 case BuiltinType::LongAccum:
3284 case BuiltinType::UShortAccum:
3287 case BuiltinType::UAccum:
3290 case BuiltinType::ULongAccum:
3293 case BuiltinType::ShortFract:
3296 case BuiltinType::Fract:
3299 case BuiltinType::LongFract:
3302 case BuiltinType::UShortFract:
3305 case BuiltinType::UFract:
3308 case BuiltinType::ULongFract:
3311 case BuiltinType::SatShortAccum:
3314 case BuiltinType::SatAccum:
3317 case BuiltinType::SatLongAccum:
3320 case BuiltinType::SatUShortAccum:
3323 case BuiltinType::SatUAccum:
3326 case BuiltinType::SatULongAccum:
3329 case BuiltinType::SatShortFract:
3332 case BuiltinType::SatFract:
3335 case BuiltinType::SatLongFract:
3338 case BuiltinType::SatUShortFract:
3341 case BuiltinType::SatUFract:
3344 case BuiltinType::SatULongFract:
3347 case BuiltinType::Half:
3350 case BuiltinType::Float:
3353 case BuiltinType::Double:
3356 case BuiltinType::LongDouble: {
3358 getASTContext().getLangOpts().OpenMP &&
3359 getASTContext().getLangOpts().OpenMPIsTargetDevice
3360 ? getASTContext().getAuxTargetInfo()
3361 : &getASTContext().getTargetInfo();
3365 case BuiltinType::Float128: {
3367 getASTContext().getLangOpts().OpenMP &&
3368 getASTContext().getLangOpts().OpenMPIsTargetDevice
3369 ? getASTContext().getAuxTargetInfo()
3370 : &getASTContext().getTargetInfo();
3374 case BuiltinType::BFloat16: {
3376 ((getASTContext().getLangOpts().OpenMP &&
3377 getASTContext().getLangOpts().OpenMPIsTargetDevice) ||
3378 getASTContext().getLangOpts().SYCLIsDevice)
3379 ? getASTContext().getAuxTargetInfo()
3380 : &getASTContext().getTargetInfo();
3384 case BuiltinType::Ibm128: {
3385 const TargetInfo *TI = &getASTContext().getTargetInfo();
3389 case BuiltinType::NullPtr:
3393#define BUILTIN_TYPE(Id, SingletonId)
3394#define PLACEHOLDER_TYPE(Id, SingletonId) \
3395 case BuiltinType::Id:
3396#include "clang/AST/BuiltinTypes.def"
3397 case BuiltinType::Dependent:
3399 llvm_unreachable(
"mangling a placeholder type");
3401 case BuiltinType::ObjCId:
3402 Out <<
"11objc_object";
3404 case BuiltinType::ObjCClass:
3405 Out <<
"10objc_class";
3407 case BuiltinType::ObjCSel:
3408 Out <<
"13objc_selector";
3410#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3411 case BuiltinType::Id: \
3412 type_name = "ocl_" #ImgType "_" #Suffix; \
3413 Out << type_name.size() << type_name; \
3415#include "clang/Basic/OpenCLImageTypes.def"
3416 case BuiltinType::OCLSampler:
3417 Out <<
"11ocl_sampler";
3419 case BuiltinType::OCLEvent:
3420 Out <<
"9ocl_event";
3422 case BuiltinType::OCLClkEvent:
3423 Out <<
"12ocl_clkevent";
3425 case BuiltinType::OCLQueue:
3426 Out <<
"9ocl_queue";
3428 case BuiltinType::OCLReserveID:
3429 Out <<
"13ocl_reserveid";
3431#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3432 case BuiltinType::Id: \
3433 type_name = "ocl_" #ExtType; \
3434 Out << type_name.size() << type_name; \
3436#include "clang/Basic/OpenCLExtensionTypes.def"
3440#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
3441 case BuiltinType::Id: \
3442 if (T->getKind() == BuiltinType::SveBFloat16 && \
3443 isCompatibleWith(LangOptions::ClangABI::Ver17)) { \
3445 mangleVendorType("__SVBFloat16_t"); \
3447 type_name = #MangledName; \
3448 Out << (type_name == #Name ? "u" : "") << type_name.size() << type_name; \
3451#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
3452 case BuiltinType::Id: \
3453 type_name = #MangledName; \
3454 Out << (type_name == #Name ? "u" : "") << type_name.size() << type_name; \
3456#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
3457 case BuiltinType::Id: \
3458 type_name = #MangledName; \
3459 Out << (type_name == #Name ? "u" : "") << type_name.size() << type_name; \
3461#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
3462 case BuiltinType::Id: \
3463 type_name = #MangledName; \
3464 Out << (type_name == #Name ? "u" : "") << type_name.size() << type_name; \
3466#include "clang/Basic/AArch64ACLETypes.def"
3467#define PPC_VECTOR_TYPE(Name, Id, Size) \
3468 case BuiltinType::Id: \
3469 mangleVendorType(#Name); \
3471#include "clang/Basic/PPCTypes.def"
3473#define RVV_TYPE(Name, Id, SingletonId) \
3474 case BuiltinType::Id: \
3475 mangleVendorType(Name); \
3477#include "clang/Basic/RISCVVTypes.def"
3478#define WASM_REF_TYPE(InternalName, MangledName, Id, SingletonId, AS) \
3479 case BuiltinType::Id: \
3480 mangleVendorType(MangledName); \
3482#include "clang/Basic/WebAssemblyReferenceTypes.def"
3483#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
3484 case BuiltinType::Id: \
3485 mangleVendorType(Name); \
3487#include "clang/Basic/AMDGPUTypes.def"
3488#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3489 case BuiltinType::Id: \
3490 mangleVendorType(#Name); \
3492#include "clang/Basic/HLSLIntangibleTypes.def"
3496StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
3516#define CC_VLS_CASE(ABI_VLEN) case CC_RISCVVLSCall_##ABI_VLEN:
3552 return "swiftasynccall";
3554 llvm_unreachable(
"bad calling convention");
3557void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *
T) {
3566 StringRef CCQualifier = getCallingConvQualifierName(
T->
getExtInfo().
getCC());
3567 if (!CCQualifier.empty())
3568 mangleVendorQualifier(CCQualifier);
3601 llvm_unreachable(
"Unrecognised SME attribute");
3616void CXXNameMangler::mangleSMEAttrs(
unsigned SMEAttrs) {
3636 Out <<
"Lj" <<
static_cast<unsigned>(Bitmask) <<
"EE";
3647 case ParameterABI::Ordinary:
3651 case ParameterABI::HLSLOut:
3652 case ParameterABI::HLSLInOut:
3657 case ParameterABI::SwiftContext:
3658 case ParameterABI::SwiftAsyncContext:
3659 case ParameterABI::SwiftErrorResult:
3660 case ParameterABI::SwiftIndirectResult:
3666 mangleVendorQualifier(
"ns_consumed");
3669 mangleVendorQualifier(
"noescape");
3679 Out <<
"11__SME_ATTRSI";
3681 mangleExtFunctionInfo(
T);
3698 mangleType(ExceptTy);
3709 mangleBareFunctionType(
T,
true);
3716 mangleSMEAttrs(SMEAttrs);
3725 FunctionTypeDepthState saved = FunctionTypeDepth.push();
3727 FunctionTypeDepth.enterResultType();
3729 FunctionTypeDepth.leaveResultType();
3731 FunctionTypeDepth.pop(saved);
3736 bool MangleReturnType,
3740 FunctionTypeDepthState saved = FunctionTypeDepth.push();
3743 if (MangleReturnType) {
3744 FunctionTypeDepth.enterResultType();
3748 mangleVendorQualifier(
"ns_returns_retained");
3753 auto SplitReturnTy = ReturnTy.
split();
3755 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
3757 mangleType(ReturnTy);
3759 FunctionTypeDepth.leaveResultType();
3781 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
3782 if (
Attr->isDynamic())
3783 Out <<
"U25pass_dynamic_object_size" <<
Attr->getType();
3785 Out <<
"U17pass_object_size" <<
Attr->getType();
3796 FunctionTypeDepth.enterResultType();
3800 FunctionTypeDepth.pop(saved);
3806 mangleName(
T->getDecl());
3811void CXXNameMangler::mangleType(
const EnumType *
T) {
3812 mangleType(
static_cast<const TagType*
>(
T));
3814void CXXNameMangler::mangleType(
const RecordType *
T) {
3815 mangleType(
static_cast<const TagType*
>(
T));
3817void CXXNameMangler::mangleType(
const TagType *
T) {
3818 mangleName(
T->getOriginalDecl()->getDefinitionOrSelf());
3825 Out <<
'A' <<
T->getSize() <<
'_';
3826 mangleType(
T->getElementType());
3831 if (
T->getSizeExpr())
3832 mangleExpression(
T->getSizeExpr());
3834 mangleType(
T->getElementType());
3841 if (
T->getSizeExpr())
3842 mangleExpression(
T->getSizeExpr());
3844 mangleType(
T->getElementType());
3848 mangleType(
T->getElementType());
3855 if (
auto *RD =
T->getMostRecentCXXRecordDecl())
3856 mangleCXXRecordDecl(RD);
3858 mangleType(
QualType(
T->getQualifier().getAsType(), 0));
3881 mangleType(PointeeType);
3886 mangleTemplateParameter(
T->getDepth(),
T->getIndex());
3895 Out <<
"_SUBSTPACK_";
3903 Out <<
"_SUBSTBUILTINPACK_";
3931 mangleType(
T->getElementType());
3937void CXXNameMangler::mangleNeonVectorType(
const VectorType *
T) {
3939 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3940 const char *EltName =
nullptr;
3941 if (
T->getVectorKind() == VectorKind::NeonPoly) {
3942 switch (cast<BuiltinType>(EltType)->
getKind()) {
3943 case BuiltinType::SChar:
3944 case BuiltinType::UChar:
3945 EltName =
"poly8_t";
3947 case BuiltinType::Short:
3948 case BuiltinType::UShort:
3949 EltName =
"poly16_t";
3951 case BuiltinType::LongLong:
3952 case BuiltinType::ULongLong:
3953 EltName =
"poly64_t";
3955 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
3958 switch (cast<BuiltinType>(EltType)->
getKind()) {
3959 case BuiltinType::SChar: EltName =
"int8_t";
break;
3960 case BuiltinType::UChar: EltName =
"uint8_t";
break;
3961 case BuiltinType::Short: EltName =
"int16_t";
break;
3962 case BuiltinType::UShort: EltName =
"uint16_t";
break;
3963 case BuiltinType::Int: EltName =
"int32_t";
break;
3964 case BuiltinType::UInt: EltName =
"uint32_t";
break;
3965 case BuiltinType::LongLong: EltName =
"int64_t";
break;
3966 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
3967 case BuiltinType::Double: EltName =
"float64_t";
break;
3968 case BuiltinType::Float: EltName =
"float32_t";
break;
3969 case BuiltinType::Half: EltName =
"float16_t";
break;
3970 case BuiltinType::BFloat16: EltName =
"bfloat16_t";
break;
3971 case BuiltinType::MFloat8:
3972 EltName =
"mfloat8_t";
3975 llvm_unreachable(
"unexpected Neon vector element type");
3978 const char *BaseName =
nullptr;
3979 unsigned BitSize = (
T->getNumElements() *
3980 getASTContext().getTypeSize(EltType));
3982 BaseName =
"__simd64_";
3984 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
3985 BaseName =
"__simd128_";
3987 Out << strlen(BaseName) + strlen(EltName);
3988 Out << BaseName << EltName;
3995 "cannot mangle this dependent neon vector type yet");
3996 Diags.
Report(
T->getAttributeLoc(), DiagID);
4001 case BuiltinType::SChar:
4003 case BuiltinType::Short:
4005 case BuiltinType::Int:
4007 case BuiltinType::Long:
4008 case BuiltinType::LongLong:
4010 case BuiltinType::UChar:
4012 case BuiltinType::UShort:
4014 case BuiltinType::UInt:
4016 case BuiltinType::ULong:
4017 case BuiltinType::ULongLong:
4019 case BuiltinType::Half:
4021 case BuiltinType::Float:
4023 case BuiltinType::Double:
4025 case BuiltinType::BFloat16:
4027 case BuiltinType::MFloat8:
4030 llvm_unreachable(
"Unexpected vector element base type");
4037void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *
T) {
4039 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
4041 (
T->getNumElements() * getASTContext().getTypeSize(EltType));
4044 assert((BitSize == 64 || BitSize == 128) &&
4045 "Neon vector type not 64 or 128 bits");
4048 if (
T->getVectorKind() == VectorKind::NeonPoly) {
4049 switch (cast<BuiltinType>(EltType)->
getKind()) {
4050 case BuiltinType::UChar:
4053 case BuiltinType::UShort:
4056 case BuiltinType::ULong:
4057 case BuiltinType::ULongLong:
4061 llvm_unreachable(
"unexpected Neon polynomial vector element type");
4067 (
"__" + EltName +
"x" + Twine(
T->getNumElements()) +
"_t").str();
4074 "cannot mangle this dependent neon vector type yet");
4075 Diags.
Report(
T->getAttributeLoc(), DiagID);
4102void CXXNameMangler::mangleAArch64FixedSveVectorType(
const VectorType *
T) {
4103 assert((
T->getVectorKind() == VectorKind::SveFixedLengthData ||
4104 T->getVectorKind() == VectorKind::SveFixedLengthPredicate) &&
4105 "expected fixed-length SVE vector!");
4109 "expected builtin type for fixed-length SVE vector!");
4112 switch (cast<BuiltinType>(EltType)->
getKind()) {
4113 case BuiltinType::SChar:
4116 case BuiltinType::UChar: {
4117 if (
T->getVectorKind() == VectorKind::SveFixedLengthData)
4123 case BuiltinType::Short:
4126 case BuiltinType::UShort:
4129 case BuiltinType::Int:
4132 case BuiltinType::UInt:
4135 case BuiltinType::Long:
4138 case BuiltinType::ULong:
4141 case BuiltinType::Half:
4144 case BuiltinType::Float:
4147 case BuiltinType::Double:
4150 case BuiltinType::BFloat16:
4154 llvm_unreachable(
"unexpected element type for fixed-length SVE vector!");
4157 unsigned VecSizeInBits = getASTContext().getTypeInfo(
T).Width;
4159 if (
T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
4162 Out <<
"9__SVE_VLSI";
4163 mangleVendorType(TypeName);
4164 Out <<
"Lj" << VecSizeInBits <<
"EE";
4167void CXXNameMangler::mangleAArch64FixedSveVectorType(
4172 "cannot mangle this dependent fixed-length SVE vector type yet");
4173 Diags.
Report(
T->getAttributeLoc(), DiagID);
4176void CXXNameMangler::mangleRISCVFixedRVVVectorType(
const VectorType *
T) {
4177 assert((
T->getVectorKind() == VectorKind::RVVFixedLengthData ||
4178 T->getVectorKind() == VectorKind::RVVFixedLengthMask ||
4179 T->getVectorKind() == VectorKind::RVVFixedLengthMask_1 ||
4180 T->getVectorKind() == VectorKind::RVVFixedLengthMask_2 ||
4181 T->getVectorKind() == VectorKind::RVVFixedLengthMask_4) &&
4182 "expected fixed-length RVV vector!");
4186 "expected builtin type for fixed-length RVV vector!");
4189 llvm::raw_svector_ostream TypeNameOS(TypeNameStr);
4190 TypeNameOS <<
"__rvv_";
4191 switch (cast<BuiltinType>(EltType)->
getKind()) {
4192 case BuiltinType::SChar:
4193 TypeNameOS <<
"int8";
4195 case BuiltinType::UChar:
4196 if (
T->getVectorKind() == VectorKind::RVVFixedLengthData)
4197 TypeNameOS <<
"uint8";
4199 TypeNameOS <<
"bool";
4201 case BuiltinType::Short:
4202 TypeNameOS <<
"int16";
4204 case BuiltinType::UShort:
4205 TypeNameOS <<
"uint16";
4207 case BuiltinType::Int:
4208 TypeNameOS <<
"int32";
4210 case BuiltinType::UInt:
4211 TypeNameOS <<
"uint32";
4213 case BuiltinType::Long:
4214 TypeNameOS <<
"int64";
4216 case BuiltinType::ULong:
4217 TypeNameOS <<
"uint64";
4219 case BuiltinType::Float16:
4220 TypeNameOS <<
"float16";
4222 case BuiltinType::Float:
4223 TypeNameOS <<
"float32";
4225 case BuiltinType::Double:
4226 TypeNameOS <<
"float64";
4229 llvm_unreachable(
"unexpected element type for fixed-length RVV vector!");
4232 unsigned VecSizeInBits;
4233 switch (
T->getVectorKind()) {
4234 case VectorKind::RVVFixedLengthMask_1:
4237 case VectorKind::RVVFixedLengthMask_2:
4240 case VectorKind::RVVFixedLengthMask_4:
4244 VecSizeInBits = getASTContext().getTypeInfo(
T).Width;
4249 auto VScale = getASTContext().getTargetInfo().getVScaleRange(
4250 getASTContext().getLangOpts(),
4251 TargetInfo::ArmStreamingKind::NotStreaming);
4252 unsigned VLen = VScale->first * llvm::RISCV::RVVBitsPerBlock;
4254 if (
T->getVectorKind() == VectorKind::RVVFixedLengthData) {
4256 if (VecSizeInBits >= VLen)
4257 TypeNameOS << (VecSizeInBits / VLen);
4259 TypeNameOS <<
'f' << (VLen / VecSizeInBits);
4261 TypeNameOS << (VLen / VecSizeInBits);
4265 Out <<
"9__RVV_VLSI";
4266 mangleVendorType(TypeNameStr);
4267 Out <<
"Lj" << VecSizeInBits <<
"EE";
4270void CXXNameMangler::mangleRISCVFixedRVVVectorType(
4275 "cannot mangle this dependent fixed-length RVV vector type yet");
4276 Diags.
Report(
T->getAttributeLoc(), DiagID);
4287void CXXNameMangler::mangleType(
const VectorType *
T) {
4288 if ((
T->getVectorKind() == VectorKind::Neon ||
4289 T->getVectorKind() == VectorKind::NeonPoly)) {
4290 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
4291 llvm::Triple::ArchType
Arch =
4292 getASTContext().getTargetInfo().getTriple().getArch();
4293 if ((
Arch == llvm::Triple::aarch64 ||
4294 Arch == llvm::Triple::aarch64_be) && !
Target.isOSDarwin())
4295 mangleAArch64NeonVectorType(
T);
4297 mangleNeonVectorType(
T);
4299 }
else if (
T->getVectorKind() == VectorKind::SveFixedLengthData ||
4300 T->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
4301 mangleAArch64FixedSveVectorType(
T);
4303 }
else if (
T->getVectorKind() == VectorKind::RVVFixedLengthData ||
4304 T->getVectorKind() == VectorKind::RVVFixedLengthMask ||
4305 T->getVectorKind() == VectorKind::RVVFixedLengthMask_1 ||
4306 T->getVectorKind() == VectorKind::RVVFixedLengthMask_2 ||
4307 T->getVectorKind() == VectorKind::RVVFixedLengthMask_4) {
4308 mangleRISCVFixedRVVVectorType(
T);
4311 Out <<
"Dv" <<
T->getNumElements() <<
'_';
4312 if (
T->getVectorKind() == VectorKind::AltiVecPixel)
4314 else if (
T->getVectorKind() == VectorKind::AltiVecBool)
4317 mangleType(
T->getElementType());
4321 if ((
T->getVectorKind() == VectorKind::Neon ||
4322 T->getVectorKind() == VectorKind::NeonPoly)) {
4323 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
4324 llvm::Triple::ArchType
Arch =
4325 getASTContext().getTargetInfo().getTriple().getArch();
4326 if ((
Arch == llvm::Triple::aarch64 ||
Arch == llvm::Triple::aarch64_be) &&
4328 mangleAArch64NeonVectorType(
T);
4330 mangleNeonVectorType(
T);
4332 }
else if (
T->getVectorKind() == VectorKind::SveFixedLengthData ||
4333 T->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
4334 mangleAArch64FixedSveVectorType(
T);
4336 }
else if (
T->getVectorKind() == VectorKind::RVVFixedLengthData) {
4337 mangleRISCVFixedRVVVectorType(
T);
4342 mangleExpression(
T->getSizeExpr());
4344 if (
T->getVectorKind() == VectorKind::AltiVecPixel)
4346 else if (
T->getVectorKind() == VectorKind::AltiVecBool)
4349 mangleType(
T->getElementType());
4357 mangleExpression(
T->getSizeExpr());
4359 mangleType(
T->getElementType());
4366 mangleVendorType(
"matrix_type");
4369 auto &ASTCtx = getASTContext();
4370 unsigned BitWidth = ASTCtx.getTypeSize(ASTCtx.getSizeType());
4371 llvm::APSInt Rows(BitWidth);
4372 Rows =
T->getNumRows();
4373 mangleIntegerLiteral(ASTCtx.getSizeType(), Rows);
4374 llvm::APSInt Columns(BitWidth);
4375 Columns =
T->getNumColumns();
4376 mangleIntegerLiteral(ASTCtx.getSizeType(), Columns);
4377 mangleType(
T->getElementType());
4384 mangleVendorType(
"matrix_type");
4387 mangleTemplateArgExpr(
T->getRowExpr());
4388 mangleTemplateArgExpr(
T->getColumnExpr());
4389 mangleType(
T->getElementType());
4395 mangleQualifiers(split.
Quals,
T);
4402 mangleType(
T->getPattern());
4406 if (!
T->hasSelectedType())
4407 mangleType(
T->getPattern());
4409 mangleType(
T->getSelectedType());
4413 mangleSourceName(
T->getDecl()->getIdentifier());
4418 if (
T->isKindOfType())
4419 Out <<
"U8__kindof";
4421 if (!
T->qual_empty()) {
4424 llvm::raw_svector_ostream QualOS(QualStr);
4425 QualOS <<
"objcproto";
4426 for (
const auto *I :
T->quals()) {
4427 StringRef
name = I->getName();
4430 mangleVendorQualifier(QualStr);
4433 mangleType(
T->getBaseType());
4435 if (
T->isSpecialized()) {
4438 for (
auto typeArg :
T->getTypeArgs())
4439 mangleType(typeArg);
4445 Out <<
"U13block_pointer";
4453 mangleType(
T->getOriginalDecl()->getCanonicalTemplateSpecializationType(
4458 if (
TemplateDecl *TD =
T->getTemplateName().getAsTemplateDecl()) {
4459 mangleTemplateName(TD,
T->template_arguments());
4464 mangleTemplatePrefix(
T->getTemplateName());
4469 mangleTemplateArgs(
T->getTemplateName(),
T->template_arguments());
4485 switch (
T->getKeyword()) {
4486 case ElaboratedTypeKeyword::None:
4487 case ElaboratedTypeKeyword::Typename:
4489 case ElaboratedTypeKeyword::Struct:
4490 case ElaboratedTypeKeyword::Class:
4491 case ElaboratedTypeKeyword::Interface:
4494 case ElaboratedTypeKeyword::Union:
4497 case ElaboratedTypeKeyword::Enum:
4503 manglePrefix(
T->getQualifier());
4504 mangleSourceName(
T->getIdentifier());
4513 getASTContext().getDependentTemplateName(
T->getDependentTemplateName());
4514 mangleTemplatePrefix(Prefix);
4519 mangleTemplateArgs(Prefix,
T->template_arguments());
4523void CXXNameMangler::mangleType(
const TypeOfType *
T) {
4536 Expr *
E =
T->getUnderlyingExpr();
4546 if (isa<DeclRefExpr>(
E) ||
4547 isa<MemberExpr>(
E) ||
4548 isa<UnresolvedLookupExpr>(
E) ||
4549 isa<DependentScopeDeclRefExpr>(
E) ||
4550 isa<CXXDependentScopeMemberExpr>(
E) ||
4551 isa<UnresolvedMemberExpr>(
E))
4555 mangleExpression(
E);
4563 StringRef BuiltinName;
4564 switch (
T->getUTTKind()) {
4565#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
4566 case UnaryTransformType::Enum: \
4567 BuiltinName = "__" #Trait; \
4569#include "clang/Basic/TransformTypeTraits.def"
4571 mangleVendorType(BuiltinName);
4575 mangleType(
T->getBaseType());
4579void CXXNameMangler::mangleType(
const AutoType *
T) {
4580 assert(
T->getDeducedType().isNull() &&
4581 "Deduced AutoType shouldn't be handled here!");
4582 assert(
T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
4583 "shouldn't need to mangle __auto_type!");
4588 if (
T->isConstrained() && !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
4589 Out << (
T->isDecltypeAuto() ?
"DK" :
"Dk");
4590 mangleTypeConstraint(
T->getTypeConstraintConcept(),
4591 T->getTypeConstraintArguments());
4593 Out << (
T->isDecltypeAuto() ?
"Dc" :
"Da");
4600 return mangleType(Deduced);
4604 "shouldn't form deduced TST unless we know we have a template");
4608void CXXNameMangler::mangleType(
const AtomicType *
T) {
4612 mangleType(
T->getValueType());
4615void CXXNameMangler::mangleType(
const PipeType *
T) {
4622void CXXNameMangler::mangleType(
const BitIntType *
T) {
4626 Out <<
"D" << (
T->isUnsigned() ?
"U" :
"B") <<
T->getNumBits() <<
"_";
4633 Out <<
"D" << (
T->isUnsigned() ?
"U" :
"B");
4634 mangleExpression(
T->getNumBitsExpr());
4639 mangleType(cast<ConstantArrayType>(
T));
4647 case llvm::dxil::ResourceClass::UAV:
4650 case llvm::dxil::ResourceClass::SRV:
4653 case llvm::dxil::ResourceClass::CBuffer:
4656 case llvm::dxil::ResourceClass::Sampler:
4664 if (
T->hasContainedType())
4666 mangleVendorQualifier(Str);
4668 if (
T->hasContainedType()) {
4669 mangleType(
T->getContainedType());
4671 mangleType(
T->getWrappedType());
4676 llvm::raw_svector_ostream TypeNameOS(TypeNameStr);
4678 TypeNameOS <<
"spirv_type";
4680 TypeNameOS <<
"_" <<
T->getOpcode();
4681 TypeNameOS <<
"_" <<
T->getSize();
4682 TypeNameOS <<
"_" <<
T->getAlignment();
4684 mangleVendorType(TypeNameStr);
4686 for (
auto &Operand :
T->getOperands()) {
4690 case SpirvOperandKind::ConstantId:
4691 mangleVendorQualifier(
"_Const");
4692 mangleIntegerLiteral(
Operand.getResultType(),
4693 llvm::APSInt(
Operand.getValue()));
4695 case SpirvOperandKind::Literal:
4696 mangleVendorQualifier(
"_Lit");
4697 mangleIntegerLiteral(Context.getASTContext().
IntTy,
4698 llvm::APSInt(
Operand.getValue()));
4700 case SpirvOperandKind::TypeId:
4701 mangleVendorQualifier(
"_Type");
4702 mangleType(
Operand.getResultType());
4705 llvm_unreachable(
"Invalid SpirvOperand kind");
4708 TypeNameOS <<
Operand.getKind();
4712void CXXNameMangler::mangleIntegerLiteral(
QualType T,
4713 const llvm::APSInt &
Value) {
4720 Out << (
Value.getBoolValue() ?
'1' :
'0');
4722 mangleNumber(
Value);
4727void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
4729 while (
const auto *RT =
Base->getType()->getAsCanonical<
RecordType>()) {
4730 if (!RT->getOriginalDecl()->isAnonymousStructOrUnion())
4732 const auto *ME = dyn_cast<MemberExpr>(
Base);
4735 Base = ME->getBase();
4736 IsArrow = ME->isArrow();
4739 if (
Base->isImplicitCXXThis()) {
4745 Out << (IsArrow ?
"pt" :
"dt");
4746 mangleExpression(
Base);
4751void CXXNameMangler::mangleMemberExpr(
const Expr *base,
bool isArrow,
4756 unsigned NumTemplateArgs,
4761 mangleMemberExprBase(base, isArrow);
4762 mangleUnresolvedName(Qualifier, member, TemplateArgs, NumTemplateArgs, arity);
4775 if (callee == fn)
return false;
4779 if (!lookup)
return false;
4796void CXXNameMangler::mangleCastExpression(
const Expr *
E, StringRef CastEncoding) {
4798 Out << CastEncoding;
4803void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
4805 InitList = Syntactic;
4806 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
4807 mangleExpression(InitList->
getInit(i));
4810void CXXNameMangler::mangleRequirement(
SourceLocation RequiresExprLoc,
4817 auto HandleSubstitutionFailure =
4822 "containing a substitution failure");
4828 case Requirement::RK_Type: {
4829 const auto *TR = cast<concepts::TypeRequirement>(Req);
4830 if (TR->isSubstitutionFailure())
4831 return HandleSubstitutionFailure(
4832 TR->getSubstitutionDiagnostic()->DiagLoc);
4835 mangleType(TR->getType()->getType());
4839 case Requirement::RK_Simple:
4840 case Requirement::RK_Compound: {
4841 const auto *ER = cast<concepts::ExprRequirement>(Req);
4842 if (ER->isExprSubstitutionFailure())
4843 return HandleSubstitutionFailure(
4844 ER->getExprSubstitutionDiagnostic()->DiagLoc);
4847 mangleExpression(ER->getExpr());
4849 if (ER->hasNoexceptRequirement())
4852 if (!ER->getReturnTypeRequirement().isEmpty()) {
4853 if (ER->getReturnTypeRequirement().isSubstitutionFailure())
4854 return HandleSubstitutionFailure(ER->getReturnTypeRequirement()
4855 .getSubstitutionDiagnostic()
4859 mangleTypeConstraint(ER->getReturnTypeRequirement().getTypeConstraint());
4864 case Requirement::RK_Nested:
4865 const auto *NR = cast<concepts::NestedRequirement>(Req);
4866 if (NR->hasInvalidConstraint()) {
4869 return HandleSubstitutionFailure(RequiresExprLoc);
4873 mangleExpression(NR->getConstraintExpr());
4878void CXXNameMangler::mangleExpression(
const Expr *
E,
unsigned Arity,
4879 bool AsTemplateArg) {
4908 QualType ImplicitlyConvertedToType;
4912 bool IsPrimaryExpr =
true;
4913 auto NotPrimaryExpr = [&] {
4914 if (AsTemplateArg && IsPrimaryExpr)
4916 IsPrimaryExpr =
false;
4919 auto MangleDeclRefExpr = [&](
const NamedDecl *
D) {
4930 mangleFunctionParam(cast<ParmVarDecl>(
D));
4933 case Decl::EnumConstant: {
4940 case Decl::NonTypeTemplateParm:
4953 case Expr::NoStmtClass:
4954#define ABSTRACT_STMT(Type)
4955#define EXPR(Type, Base)
4956#define STMT(Type, Base) \
4957 case Expr::Type##Class:
4958#include "clang/AST/StmtNodes.inc"
4963 case Expr::AddrLabelExprClass:
4964 case Expr::DesignatedInitUpdateExprClass:
4965 case Expr::ImplicitValueInitExprClass:
4966 case Expr::ArrayInitLoopExprClass:
4967 case Expr::ArrayInitIndexExprClass:
4968 case Expr::NoInitExprClass:
4969 case Expr::ParenListExprClass:
4970 case Expr::MSPropertyRefExprClass:
4971 case Expr::MSPropertySubscriptExprClass:
4972 case Expr::RecoveryExprClass:
4973 case Expr::ArraySectionExprClass:
4974 case Expr::OMPArrayShapingExprClass:
4975 case Expr::OMPIteratorExprClass:
4976 case Expr::CXXInheritedCtorInitExprClass:
4977 case Expr::CXXParenListInitExprClass:
4978 case Expr::PackIndexingExprClass:
4979 llvm_unreachable(
"unexpected statement kind");
4981 case Expr::ConstantExprClass:
4982 E = cast<ConstantExpr>(
E)->getSubExpr();
4986 case Expr::BlockExprClass:
4987 case Expr::ChooseExprClass:
4988 case Expr::CompoundLiteralExprClass:
4989 case Expr::ExtVectorElementExprClass:
4990 case Expr::GenericSelectionExprClass:
4991 case Expr::ObjCEncodeExprClass:
4992 case Expr::ObjCIsaExprClass:
4993 case Expr::ObjCIvarRefExprClass:
4994 case Expr::ObjCMessageExprClass:
4995 case Expr::ObjCPropertyRefExprClass:
4996 case Expr::ObjCProtocolExprClass:
4997 case Expr::ObjCSelectorExprClass:
4998 case Expr::ObjCStringLiteralClass:
4999 case Expr::ObjCBoxedExprClass:
5000 case Expr::ObjCArrayLiteralClass:
5001 case Expr::ObjCDictionaryLiteralClass:
5002 case Expr::ObjCSubscriptRefExprClass:
5003 case Expr::ObjCIndirectCopyRestoreExprClass:
5004 case Expr::ObjCAvailabilityCheckExprClass:
5005 case Expr::OffsetOfExprClass:
5006 case Expr::PredefinedExprClass:
5007 case Expr::ShuffleVectorExprClass:
5008 case Expr::ConvertVectorExprClass:
5009 case Expr::StmtExprClass:
5010 case Expr::ArrayTypeTraitExprClass:
5011 case Expr::ExpressionTraitExprClass:
5012 case Expr::VAArgExprClass:
5013 case Expr::CUDAKernelCallExprClass:
5014 case Expr::AsTypeExprClass:
5015 case Expr::PseudoObjectExprClass:
5016 case Expr::AtomicExprClass:
5017 case Expr::SourceLocExprClass:
5018 case Expr::EmbedExprClass:
5019 case Expr::BuiltinBitCastExprClass: {
5025 "cannot yet mangle expression type %0");
5033 case Expr::CXXUuidofExprClass: {
5038 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
5039 Out <<
"u8__uuidof";
5048 Out <<
"u8__uuidoft";
5052 Out <<
"u8__uuidofz";
5053 mangleExpression(UuidExp);
5060 case Expr::BinaryConditionalOperatorClass: {
5065 "?: operator with omitted middle operand cannot be mangled");
5072 case Expr::OpaqueValueExprClass:
5073 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
5075 case Expr::InitListExprClass: {
5078 mangleInitListElements(cast<InitListExpr>(
E));
5083 case Expr::DesignatedInitExprClass: {
5085 auto *DIE = cast<DesignatedInitExpr>(
E);
5086 for (
const auto &
Designator : DIE->designators()) {
5092 mangleExpression(DIE->getArrayIndex(
Designator));
5095 "unknown designator kind");
5097 mangleExpression(DIE->getArrayRangeStart(
Designator));
5098 mangleExpression(DIE->getArrayRangeEnd(
Designator));
5101 mangleExpression(DIE->getInit());
5105 case Expr::CXXDefaultArgExprClass:
5106 E = cast<CXXDefaultArgExpr>(
E)->getExpr();
5109 case Expr::CXXDefaultInitExprClass:
5110 E = cast<CXXDefaultInitExpr>(
E)->getExpr();
5113 case Expr::CXXStdInitializerListExprClass:
5114 E = cast<CXXStdInitializerListExpr>(
E)->getSubExpr();
5117 case Expr::SubstNonTypeTemplateParmExprClass: {
5120 auto *SNTTPE = cast<SubstNonTypeTemplateParmExpr>(
E);
5121 if (
auto *CE = dyn_cast<ConstantExpr>(SNTTPE->getReplacement())) {
5123 QualType ParamType = SNTTPE->getParameterType(Context.getASTContext());
5124 assert(CE->hasAPValueResult() &&
"expected the NTTP to have an APValue");
5125 mangleValueInTemplateArg(ParamType, CE->getAPValueResult(),
false,
5131 E = cast<SubstNonTypeTemplateParmExpr>(
E)->getReplacement();
5135 case Expr::UserDefinedLiteralClass:
5138 case Expr::CXXMemberCallExprClass:
5139 case Expr::CallExprClass: {
5160 if (isa<PackExpansionExpr>(Arg))
5161 CallArity = UnknownArity;
5163 mangleExpression(CE->
getCallee(), CallArity);
5165 mangleExpression(Arg);
5170 case Expr::CXXNewExprClass: {
5173 if (
New->isGlobalNew()) Out <<
"gs";
5174 Out << (
New->isArray() ?
"na" :
"nw");
5176 E =
New->placement_arg_end(); I !=
E; ++I)
5177 mangleExpression(*I);
5179 mangleType(
New->getAllocatedType());
5180 if (
New->hasInitializer()) {
5181 if (
New->getInitializationStyle() == CXXNewInitializationStyle::Braces)
5191 mangleExpression(*I);
5193 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
5194 mangleExpression(PLE->getExpr(i));
5195 }
else if (
New->getInitializationStyle() ==
5196 CXXNewInitializationStyle::Braces &&
5197 isa<InitListExpr>(
Init)) {
5199 mangleInitListElements(cast<InitListExpr>(
Init));
5201 mangleExpression(
Init);
5207 case Expr::CXXPseudoDestructorExprClass: {
5209 const auto *PDE = cast<CXXPseudoDestructorExpr>(
E);
5210 if (
const Expr *
Base = PDE->getBase())
5211 mangleMemberExprBase(
Base, PDE->isArrow());
5215 mangleUnresolvedPrefix(Qualifier,
5217 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
5221 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
5224 }
else if (Qualifier) {
5225 mangleUnresolvedPrefix(Qualifier);
5229 QualType DestroyedType = PDE->getDestroyedType();
5230 mangleUnresolvedTypeOrSimpleId(DestroyedType);
5234 case Expr::MemberExprClass: {
5245 case Expr::UnresolvedMemberExprClass: {
5256 case Expr::CXXDependentScopeMemberExprClass: {
5259 = cast<CXXDependentScopeMemberExpr>(
E);
5269 case Expr::UnresolvedLookupExprClass: {
5278 case Expr::CXXUnresolvedConstructExprClass: {
5284 assert(N == 1 &&
"unexpected form for list initialization");
5285 auto *IL = cast<InitListExpr>(CE->
getArg(0));
5288 mangleInitListElements(IL);
5295 if (N != 1) Out <<
'_';
5296 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
5297 if (N != 1) Out <<
'E';
5301 case Expr::CXXConstructExprClass: {
5303 const auto *CE = cast<CXXConstructExpr>(
E);
5308 "implicit CXXConstructExpr must have one argument");
5309 E = cast<CXXConstructExpr>(
E)->getArg(0);
5315 mangleExpression(
E);
5320 case Expr::CXXTemporaryObjectExprClass: {
5322 const auto *CE = cast<CXXTemporaryObjectExpr>(
E);
5331 if (!List && N != 1)
5333 if (CE->isStdInitListInitialization()) {
5339 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
5340 mangleInitListElements(ILE);
5343 mangleExpression(
E);
5350 case Expr::CXXScalarValueInitExprClass:
5357 case Expr::CXXNoexceptExprClass:
5360 mangleExpression(cast<CXXNoexceptExpr>(
E)->getOperand());
5363 case Expr::UnaryExprOrTypeTraitExprClass: {
5382 : ImplicitlyConvertedToType;
5384 mangleIntegerLiteral(
T,
V);
5390 auto MangleAlignofSizeofArg = [&] {
5401 StringRef Name = {}) {
5404 mangleVendorType(Name);
5415 MangleAlignofSizeofArg();
5417 case UETT_PreferredAlignOf:
5421 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
5422 MangleExtensionBuiltin(SAE,
"__alignof__");
5428 MangleAlignofSizeofArg();
5432 case UETT_VectorElements:
5433 case UETT_OpenMPRequiredSimdAlign:
5435 case UETT_PtrAuthTypeDiscriminator:
5436 case UETT_DataSizeOf: {
5447 case Expr::TypeTraitExprClass: {
5452 mangleVendorType(Spelling);
5454 mangleType(TSI->getType());
5460 case Expr::CXXThrowExprClass: {
5474 case Expr::CXXTypeidExprClass: {
5489 case Expr::CXXDeleteExprClass: {
5500 case Expr::UnaryOperatorClass: {
5509 case Expr::ArraySubscriptExprClass: {
5516 mangleExpression(AE->
getLHS());
5517 mangleExpression(AE->
getRHS());
5521 case Expr::MatrixSubscriptExprClass: {
5525 mangleExpression(ME->
getBase());
5531 case Expr::CompoundAssignOperatorClass:
5532 case Expr::BinaryOperatorClass: {
5540 mangleExpression(BO->
getLHS());
5541 mangleExpression(BO->
getRHS());
5545 case Expr::CXXRewrittenBinaryOperatorClass: {
5549 cast<CXXRewrittenBinaryOperator>(
E)->getDecomposedForm();
5552 mangleExpression(Decomposed.
LHS);
5553 mangleExpression(Decomposed.
RHS);
5557 case Expr::ConditionalOperatorClass: {
5560 mangleOperatorName(OO_Conditional, 3);
5561 mangleExpression(CO->
getCond());
5562 mangleExpression(CO->
getLHS(), Arity);
5563 mangleExpression(CO->
getRHS(), Arity);
5567 case Expr::ImplicitCastExprClass: {
5568 ImplicitlyConvertedToType =
E->
getType();
5569 E = cast<ImplicitCastExpr>(
E)->getSubExpr();
5573 case Expr::ObjCBridgedCastExprClass: {
5577 StringRef
Kind = cast<ObjCBridgedCastExpr>(
E)->getBridgeKindName();
5578 Out <<
"v1U" <<
Kind.size() <<
Kind;
5579 mangleCastExpression(
E,
"cv");
5583 case Expr::CStyleCastExprClass:
5585 mangleCastExpression(
E,
"cv");
5588 case Expr::CXXFunctionalCastExprClass: {
5590 auto *
Sub = cast<ExplicitCastExpr>(
E)->getSubExpr()->IgnoreImplicit();
5592 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
5593 if (CCE->getParenOrBraceRange().isInvalid())
5594 Sub = CCE->getArg(0)->IgnoreImplicit();
5595 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
5596 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
5597 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
5600 mangleInitListElements(IL);
5603 mangleCastExpression(
E,
"cv");
5608 case Expr::CXXStaticCastExprClass:
5610 mangleCastExpression(
E,
"sc");
5612 case Expr::CXXDynamicCastExprClass:
5614 mangleCastExpression(
E,
"dc");
5616 case Expr::CXXReinterpretCastExprClass:
5618 mangleCastExpression(
E,
"rc");
5620 case Expr::CXXConstCastExprClass:
5622 mangleCastExpression(
E,
"cc");
5624 case Expr::CXXAddrspaceCastExprClass:
5626 mangleCastExpression(
E,
"ac");
5629 case Expr::CXXOperatorCallExprClass: {
5638 for (
unsigned i = 0; i != NumArgs; ++i)
5639 mangleExpression(CE->
getArg(i));
5643 case Expr::ParenExprClass:
5644 E = cast<ParenExpr>(
E)->getSubExpr();
5647 case Expr::ConceptSpecializationExprClass: {
5648 auto *CSE = cast<ConceptSpecializationExpr>(
E);
5649 if (isCompatibleWith(LangOptions::ClangABI::Ver17)) {
5654 mangleTemplateName(CSE->getNamedConcept(), CSE->getTemplateArguments());
5660 mangleUnresolvedName(
5661 CSE->getNestedNameSpecifierLoc().getNestedNameSpecifier(),
5662 CSE->getConceptNameInfo().getName(),
5663 CSE->getTemplateArgsAsWritten()->getTemplateArgs(),
5664 CSE->getTemplateArgsAsWritten()->getNumTemplateArgs());
5668 case Expr::RequiresExprClass: {
5670 auto *RE = cast<RequiresExpr>(
E);
5674 if (RE->getLParenLoc().isValid()) {
5676 FunctionTypeDepthState saved = FunctionTypeDepth.push();
5677 if (RE->getLocalParameters().empty()) {
5680 for (
ParmVarDecl *Param : RE->getLocalParameters()) {
5688 FunctionTypeDepth.enterResultType();
5690 mangleRequirement(RE->getExprLoc(), Req);
5691 FunctionTypeDepth.pop(saved);
5696 mangleRequirement(RE->getExprLoc(), Req);
5702 case Expr::DeclRefExprClass:
5704 MangleDeclRefExpr(cast<DeclRefExpr>(
E)->getDecl());
5707 case Expr::SubstNonTypeTemplateParmPackExprClass:
5713 Out <<
"_SUBSTPACK_";
5716 case Expr::FunctionParmPackExprClass: {
5720 Out <<
"v110_SUBSTPACK";
5725 case Expr::DependentScopeDeclRefExprClass: {
5734 case Expr::CXXBindTemporaryExprClass:
5735 E = cast<CXXBindTemporaryExpr>(
E)->getSubExpr();
5738 case Expr::ExprWithCleanupsClass:
5739 E = cast<ExprWithCleanups>(
E)->getSubExpr();
5742 case Expr::FloatingLiteralClass: {
5749 case Expr::FixedPointLiteralClass:
5751 mangleFixedPointLiteral();
5754 case Expr::CharacterLiteralClass:
5758 Out << cast<CharacterLiteral>(
E)->getValue();
5763 case Expr::ObjCBoolLiteralExprClass:
5766 Out << (cast<ObjCBoolLiteralExpr>(
E)->getValue() ?
'1' :
'0');
5770 case Expr::CXXBoolLiteralExprClass:
5773 Out << (cast<CXXBoolLiteralExpr>(
E)->getValue() ?
'1' :
'0');
5777 case Expr::IntegerLiteralClass: {
5779 llvm::APSInt
Value(cast<IntegerLiteral>(
E)->getValue());
5781 Value.setIsSigned(
true);
5786 case Expr::ImaginaryLiteralClass: {
5794 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
5796 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
5798 mangleFloat(Imag->getValue());
5801 llvm::APSInt
Value(cast<IntegerLiteral>(IE->
getSubExpr())->getValue());
5803 Value.setIsSigned(
true);
5804 mangleNumber(
Value);
5810 case Expr::StringLiteralClass: {
5814 assert(isa<ConstantArrayType>(
E->
getType()));
5820 case Expr::GNUNullExprClass:
5823 mangleIntegerLiteral(
E->
getType(), llvm::APSInt(32));
5826 case Expr::CXXNullPtrLiteralExprClass: {
5832 case Expr::LambdaExprClass: {
5838 cast<LambdaExpr>(
E)->getLambdaClass()));
5843 case Expr::PackExpansionExprClass:
5846 mangleExpression(cast<PackExpansionExpr>(
E)->getPattern());
5849 case Expr::SizeOfPackExprClass: {
5851 auto *SPE = cast<SizeOfPackExpr>(
E);
5852 if (SPE->isPartiallySubstituted()) {
5854 for (
const auto &A : SPE->getPartialArguments())
5855 mangleTemplateArg(A,
false);
5863 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
5865 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
5866 mangleTemplateParameter(NTTP->getDepth(), NTTP->getIndex());
5868 = dyn_cast<TemplateTemplateParmDecl>(Pack))
5869 mangleTemplateParameter(TempTP->getDepth(), TempTP->getIndex());
5871 mangleFunctionParam(cast<ParmVarDecl>(Pack));
5875 case Expr::MaterializeTemporaryExprClass:
5876 E = cast<MaterializeTemporaryExpr>(
E)->getSubExpr();
5879 case Expr::CXXFoldExprClass: {
5881 auto *FE = cast<CXXFoldExpr>(
E);
5882 if (FE->isLeftFold())
5883 Out << (FE->getInit() ?
"fL" :
"fl");
5885 Out << (FE->getInit() ?
"fR" :
"fr");
5887 if (FE->getOperator() == BO_PtrMemD)
5895 mangleExpression(FE->getLHS());
5897 mangleExpression(FE->getRHS());
5901 case Expr::CXXThisExprClass:
5906 case Expr::CoawaitExprClass:
5909 Out <<
"v18co_await";
5910 mangleExpression(cast<CoawaitExpr>(
E)->getOperand());
5913 case Expr::DependentCoawaitExprClass:
5916 Out <<
"v18co_await";
5917 mangleExpression(cast<DependentCoawaitExpr>(
E)->getOperand());
5920 case Expr::CoyieldExprClass:
5923 Out <<
"v18co_yield";
5924 mangleExpression(cast<CoawaitExpr>(
E)->getOperand());
5926 case Expr::SYCLUniqueStableNameExprClass: {
5927 const auto *USN = cast<SYCLUniqueStableNameExpr>(
E);
5930 Out <<
"u33__builtin_sycl_unique_stable_name";
5931 mangleType(USN->getTypeSourceInfo()->getType());
5936 case Expr::HLSLOutArgExprClass:
5938 "cannot mangle hlsl temporary value; mangling wrong thing?");
5939 case Expr::OpenACCAsteriskSizeExprClass: {
5944 "cannot yet mangle OpenACC Asterisk Size expression");
5950 if (AsTemplateArg && !IsPrimaryExpr)
5982void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
5989 assert(parmDepth < FunctionTypeDepth.getDepth());
5990 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
5991 if (FunctionTypeDepth.isInResultType())
5994 if (nestingDepth == 0) {
5997 Out <<
"fL" << (nestingDepth - 1) <<
'p';
6005 &&
"parameter's type is still an array type?");
6008 dyn_cast<DependentAddressSpaceType>(parm->
getType())) {
6015 if (parmIndex != 0) {
6016 Out << (parmIndex - 1);
6044 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
6047 mangleName(InheritedFrom);
6101 if (
auto *FTD = dyn_cast_or_null<FunctionTemplateDecl>(
ResolvedTemplate)) {
6102 auto *RD = dyn_cast<CXXRecordDecl>(FTD->getDeclContext());
6103 if (!RD || !RD->isGenericLambda())
6119 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param))
6120 return TTP->hasTypeConstraint();
6137 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param))
6138 return NTTP->getType()->isInstantiationDependentType() ||
6139 NTTP->getType()->getContainedDeducedType();
6143 auto *TTP = cast<TemplateTemplateParmDecl>(Param);
6146 "A DeducedTemplateName shouldn't escape partial ordering");
6157 auto MangleTemplateParamListToString =
6159 unsigned DepthOffset) {
6160 llvm::raw_svector_ostream Stream(Buffer);
6161 CXXNameMangler(
Mangler.Context, Stream,
6162 WithTemplateDepthOffset{DepthOffset})
6163 .mangleTemplateParameterList(Params);
6166 MangleTemplateParamListToString(ParamTemplateHead,
6167 TTP->getTemplateParameters(), 0);
6171 MangleTemplateParamListToString(ArgTemplateHead,
6173 TTP->getTemplateParameters()->
getDepth());
6174 return ParamTemplateHead != ArgTemplateHead;
6184 return {
true,
nullptr};
6189 assert(ParamIdx < ResolvedTemplate->getTemplateParameters()->size() &&
6190 "no parameter for argument");
6211 return {
true,
nullptr};
6226 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param);
6227 bool NeedExactType = NTTP && NTTP->getType()->getContainedDeducedType();
6228 return {NeedExactType,
nullptr};
6240void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6242 unsigned NumTemplateArgs) {
6245 TemplateArgManglingInfo Info(*
this, TN);
6246 for (
unsigned i = 0; i != NumTemplateArgs; ++i) {
6247 mangleTemplateArg(Info, i, TemplateArgs[i].
getArgument());
6249 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6253void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6257 TemplateArgManglingInfo Info(*
this, TN);
6258 for (
unsigned i = 0, e = AL.
size(); i != e; ++i) {
6259 mangleTemplateArg(Info, i, AL[i]);
6261 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6265void CXXNameMangler::mangleTemplateArgs(
TemplateName TN,
6269 TemplateArgManglingInfo Info(*
this, TN);
6270 for (
unsigned i = 0; i != Args.size(); ++i) {
6271 mangleTemplateArg(Info, i, Args[i]);
6273 mangleRequiresClause(Info.getTrailingRequiresClauseToMangle());
6277void CXXNameMangler::mangleTemplateArg(TemplateArgManglingInfo &Info,
6279 TemplateArgManglingInfo::Info ArgInfo = Info.getArgInfo(Index, A);
6282 if (ArgInfo.TemplateParameterToMangle &&
6283 !isCompatibleWith(LangOptions::ClangABI::Ver17)) {
6290 mangleTemplateParamDecl(ArgInfo.TemplateParameterToMangle);
6293 mangleTemplateArg(A, ArgInfo.NeedExactType);
6296void CXXNameMangler::mangleTemplateArg(
TemplateArgument A,
bool NeedExactType) {
6306 llvm_unreachable(
"Cannot mangle NULL template argument");
6333 auto *TPO = cast<TemplateParamObjectDecl>(
D);
6334 mangleValueInTemplateArg(TPO->getType().getUnqualifiedType(),
6335 TPO->getValue(),
true,
6342 if (
D->isCXXInstanceMember())
6345 else if (
D->getType()->isArrayType() &&
6348 !isCompatibleWith(LangOptions::ClangABI::Ver11))
6369 true, NeedExactType);
6375 mangleTemplateArg(
P, NeedExactType);
6381void CXXNameMangler::mangleTemplateArgExpr(
const Expr *
E) {
6382 if (!isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6383 mangleExpression(
E, UnknownArity,
true);
6398 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(
E)) {
6400 if (isa<VarDecl>(
D) || isa<FunctionDecl>(
D)) {
6408 mangleExpression(
E);
6421 switch (
V.getKind()) {
6429 assert(RD &&
"unexpected type for record value");
6438 if (!FD->isUnnamedBitField() &&
6448 assert(RD &&
"unexpected type for union value");
6451 if (!FD->isUnnamedBitField())
6462 for (
unsigned I = 0, N =
V.getArrayInitializedElts(); I != N; ++I)
6470 for (
unsigned I = 0, N =
V.getVectorLength(); I != N; ++I)
6480 return V.getFloat().isPosZero();
6483 return !
V.getFixedPoint().getValue();
6486 return V.getComplexFloatReal().isPosZero() &&
6487 V.getComplexFloatImag().isPosZero();
6490 return !
V.getComplexIntReal() && !
V.getComplexIntImag();
6493 return V.isNullPointer();
6496 return !
V.getMemberPointerDecl();
6499 llvm_unreachable(
"Unhandled APValue::ValueKind enum");
6506 T = AT->getElementType();
6508 dyn_cast<FieldDecl>(
E.getAsBaseOrMember().getPointer()))
6512 cast<CXXRecordDecl>(
E.getAsBaseOrMember().getPointer()));
6553 Diags.
Report(UnionLoc, DiagID);
6560 bool NeedExactType) {
6563 T = getASTContext().getUnqualifiedArrayType(
T, Quals);
6566 bool IsPrimaryExpr =
true;
6567 auto NotPrimaryExpr = [&] {
6568 if (TopLevel && IsPrimaryExpr)
6570 IsPrimaryExpr =
false;
6574 switch (
V.getKind()) {
6583 llvm_unreachable(
"unexpected value kind in template argument");
6587 assert(RD &&
"unexpected type for record value");
6593 (Fields.back()->isUnnamedBitField() ||
6595 V.getStructField(Fields.back()->getFieldIndex())))) {
6599 if (Fields.empty()) {
6600 while (!Bases.empty() &&
6602 V.getStructBase(Bases.size() - 1)))
6603 Bases = Bases.drop_back();
6610 for (
unsigned I = 0, N = Bases.size(); I != N; ++I)
6611 mangleValueInTemplateArg(Bases[I].getType(),
V.getStructBase(I),
false);
6612 for (
unsigned I = 0, N = Fields.size(); I != N; ++I) {
6613 if (Fields[I]->isUnnamedBitField())
6615 mangleValueInTemplateArg(Fields[I]->getType(),
6616 V.getStructField(Fields[I]->getFieldIndex()),
6643 mangleSourceName(II);
6644 mangleValueInTemplateArg(FD->
getType(),
V.getUnionValue(),
false);
6658 unsigned N =
V.getArraySize();
6660 N =
V.getArrayInitializedElts();
6665 for (
unsigned I = 0; I != N; ++I) {
6666 const APValue &Elem = I <
V.getArrayInitializedElts()
6667 ?
V.getArrayInitializedElt(I)
6668 :
V.getArrayFiller();
6669 mangleValueInTemplateArg(ElemT, Elem,
false);
6681 unsigned N =
V.getVectorLength();
6684 for (
unsigned I = 0; I != N; ++I)
6685 mangleValueInTemplateArg(VT->
getElementType(),
V.getVectorElt(I),
false);
6691 mangleIntegerLiteral(
T,
V.getInt());
6695 mangleFloatLiteral(
T,
V.getFloat());
6699 mangleFixedPointLiteral();
6707 if (!
V.getComplexFloatReal().isPosZero() ||
6708 !
V.getComplexFloatImag().isPosZero())
6710 if (!
V.getComplexFloatImag().isPosZero())
6721 if (
V.getComplexIntReal().getBoolValue() ||
6722 V.getComplexIntImag().getBoolValue())
6724 if (
V.getComplexIntImag().getBoolValue())
6733 "unexpected type for LValue template arg");
6735 if (
V.isNullPointer()) {
6736 mangleNullPointer(
T);
6745 if (Offset.isZero()) {
6757 Out << Offset.getQuantity() <<
'E';
6765 if (!
V.hasLValuePath()) {
6781 bool IsArrayToPointerDecayMangledAsDecl =
false;
6782 if (TopLevel && Ctx.
getLangOpts().getClangABICompat() <=
6783 LangOptions::ClangABI::Ver11) {
6785 IsArrayToPointerDecayMangledAsDecl =
6786 BType->
isArrayType() &&
V.getLValuePath().size() == 1 &&
6787 V.getLValuePath()[0].getAsArrayIndex() == 0 &&
6791 if ((!
V.getLValuePath().empty() ||
V.isLValueOnePastTheEnd()) &&
6792 !IsArrayToPointerDecayMangledAsDecl) {
6809 if (NeedExactType &&
6811 !isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6831 mangleExpression(
E);
6835 mangleType(
QualType(TI.getType(), 0));
6838 llvm_unreachable(
"unexpected lvalue base kind in template argument");
6848 mangleNumber(
V.getLValueOffset().getQuantity());
6855 if (!
V.getLValueOffset().isZero())
6856 mangleNumber(
V.getLValueOffset().getQuantity());
6860 bool OnePastTheEnd =
V.isLValueOnePastTheEnd();
6864 if (
auto *CAT = dyn_cast<ConstantArrayType>(AT))
6865 OnePastTheEnd |= CAT->getSize() ==
E.getAsArrayIndex();
6866 TypeSoFar = AT->getElementType();
6868 const Decl *
D =
E.getAsBaseOrMember().getPointer();
6869 if (
auto *FD = dyn_cast<FieldDecl>(
D)) {
6894 if (!
V.getMemberPointerDecl()) {
6895 mangleNullPointer(
T);
6902 if (!
V.getMemberPointerPath().empty()) {
6905 }
else if (NeedExactType &&
6908 V.getMemberPointerDecl()->getType()) &&
6909 !isCompatibleWith(LangOptions::ClangABI::Ver11)) {
6914 mangle(
V.getMemberPointerDecl());
6916 if (!
V.getMemberPointerPath().empty()) {
6919 if (!Offset.isZero())
6920 mangleNumber(Offset.getQuantity());
6926 if (TopLevel && !IsPrimaryExpr)
6930void CXXNameMangler::mangleTemplateParameter(
unsigned Depth,
unsigned Index) {
6940 Depth += TemplateDepthOffset;
6942 Out <<
'L' << (Depth - 1) <<
'_';
6948void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
6951 }
else if (SeqID == 1) {
6961 for (; SeqID != 0; SeqID /= 36) {
6962 unsigned C = SeqID % 36;
6963 *I++ = (
C < 10 ?
'0' +
C :
'A' +
C - 10);
6966 Out.write(I.base(), I - BufferRef.rbegin());
6971void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
6972 bool result = mangleSubstitution(tname);
6973 assert(result &&
"no existing substitution for template name");
6979bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
6981 if (mangleStandardSubstitution(ND))
6985 return mangleSubstitution(
reinterpret_cast<uintptr_t>(ND));
6995bool CXXNameMangler::mangleSubstitution(
QualType T) {
6998 return mangleSubstitution(RD);
7003 return mangleSubstitution(TypePtr);
7008 return mangleSubstitution(TD);
7011 return mangleSubstitution(
7015bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
7016 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
7017 if (I == Substitutions.end())
7020 unsigned SeqID = I->second;
7029bool CXXNameMangler::isSpecializedAs(
QualType S, llvm::StringRef Name,
7043 if (!isStdNamespace(Context.getEffectiveDeclContext(SD)))
7047 if (TemplateArgs.
size() != 1)
7050 if (TemplateArgs[0].getAsType() != A)
7062bool CXXNameMangler::isStdCharSpecialization(
7064 bool HasAllocator) {
7069 if (TemplateArgs.
size() != (HasAllocator ? 3 : 2))
7072 QualType A = TemplateArgs[0].getAsType();
7080 if (!isSpecializedAs(TemplateArgs[1].getAsType(),
"char_traits", A))
7084 !isSpecializedAs(TemplateArgs[2].getAsType(),
"allocator", A))
7093bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
7095 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
7104 if (!isStdNamespace(Context.getEffectiveDeclContext(TD)))
7125 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
7126 if (!isStdNamespace(Context.getEffectiveDeclContext(SD)))
7135 if (isStdCharSpecialization(SD,
"basic_string",
true)) {
7142 if (isStdCharSpecialization(SD,
"basic_istream",
false)) {
7149 if (isStdCharSpecialization(SD,
"basic_ostream",
false)) {
7156 if (isStdCharSpecialization(SD,
"basic_iostream",
false)) {
7166void CXXNameMangler::addSubstitution(
QualType T) {
7169 addSubstitution(RD);
7175 addSubstitution(TypePtr);
7180 return addSubstitution(TD);
7186void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
7187 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
7188 Substitutions[Ptr] = SeqID++;
7191void CXXNameMangler::extendSubstitutions(CXXNameMangler*
Other) {
7192 assert(
Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
7193 if (
Other->SeqID > SeqID) {
7194 Substitutions.swap(
Other->Substitutions);
7195 SeqID =
Other->SeqID;
7200CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
7202 if (DisableDerivedAbiTags)
7203 return AbiTagList();
7205 llvm::raw_null_ostream NullOutStream;
7206 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
7207 TrackReturnTypeTags.disableDerivedAbiTags();
7211 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
7212 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
7214 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
7215 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
7217 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
7221CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
7223 if (DisableDerivedAbiTags)
7224 return AbiTagList();
7226 llvm::raw_null_ostream NullOutStream;
7227 CXXNameMangler TrackVariableType(*
this, NullOutStream);
7228 TrackVariableType.disableDerivedAbiTags();
7230 TrackVariableType.mangleType(VD->
getType());
7232 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
7235bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &
C,
7237 llvm::raw_null_ostream NullOutStream;
7238 CXXNameMangler TrackAbiTags(
C, NullOutStream,
nullptr,
true);
7239 TrackAbiTags.mangle(VD);
7240 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
7253void ItaniumMangleContextImpl::mangleCXXName(
GlobalDecl GD,
7256 assert((isa<FunctionDecl, VarDecl, TemplateParamObjectDecl>(
D)) &&
7257 "Invalid mangleName() call, argument is not a variable or function!");
7260 getASTContext().getSourceManager(),
7261 "Mangling declaration");
7263 if (
auto *CD = dyn_cast<CXXConstructorDecl>(
D)) {
7265 CXXNameMangler Mangler(*
this, Out, CD,
Type);
7269 if (
auto *DD = dyn_cast<CXXDestructorDecl>(
D)) {
7271 CXXNameMangler Mangler(*
this, Out, DD,
Type);
7275 CXXNameMangler Mangler(*
this, Out,
D);
7313 unsigned TypedDiscriminator =
7315 Mangler.mangleVendorQualifier(
"__vtptrauth");
7316 auto &ManglerStream = Mangler.getStream();
7317 ManglerStream <<
"I";
7318 if (
const auto *ExplicitAuth =
7319 PtrauthClassRD->
getAttr<VTablePointerAuthenticationAttr>()) {
7320 ManglerStream <<
"Lj" << ExplicitAuth->getKey();
7322 if (ExplicitAuth->getAddressDiscrimination() ==
7323 VTablePointerAuthenticationAttr::DefaultAddressDiscrimination)
7324 ManglerStream <<
"Lb" << LangOpts.PointerAuthVTPtrAddressDiscrimination;
7326 ManglerStream <<
"Lb"
7327 << (ExplicitAuth->getAddressDiscrimination() ==
7328 VTablePointerAuthenticationAttr::AddressDiscrimination);
7330 switch (ExplicitAuth->getExtraDiscrimination()) {
7331 case VTablePointerAuthenticationAttr::DefaultExtraDiscrimination: {
7332 if (LangOpts.PointerAuthVTPtrTypeDiscrimination)
7333 ManglerStream <<
"Lj" << TypedDiscriminator;
7335 ManglerStream <<
"Lj" << 0;
7338 case VTablePointerAuthenticationAttr::TypeDiscrimination:
7339 ManglerStream <<
"Lj" << TypedDiscriminator;
7341 case VTablePointerAuthenticationAttr::CustomDiscrimination:
7342 ManglerStream <<
"Lj" << ExplicitAuth->getCustomDiscriminationValue();
7344 case VTablePointerAuthenticationAttr::NoExtraDiscrimination:
7345 ManglerStream <<
"Lj" << 0;
7349 ManglerStream <<
"Lj"
7350 << (
unsigned)VTablePointerAuthenticationAttr::DefaultKey;
7351 ManglerStream <<
"Lb" << LangOpts.PointerAuthVTPtrAddressDiscrimination;
7352 if (LangOpts.PointerAuthVTPtrTypeDiscrimination)
7353 ManglerStream <<
"Lj" << TypedDiscriminator;
7355 ManglerStream <<
"Lj" << 0;
7357 ManglerStream <<
"E";
7360void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
7362 bool ElideOverrideInfo,
7371 assert(!isa<CXXDestructorDecl>(MD) &&
7372 "Use mangleCXXDtor for destructor decls!");
7373 CXXNameMangler Mangler(*
this, Out);
7374 Mangler.getStream() <<
"_ZT";
7376 Mangler.getStream() <<
'c';
7387 Mangler.mangleFunctionEncoding(MD);
7388 if (!ElideOverrideInfo)
7395 bool ElideOverrideInfo,
7399 CXXNameMangler Mangler(*
this, Out, DD,
Type);
7400 Mangler.getStream() <<
"_ZT";
7408 if (!ElideOverrideInfo)
7413void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *
D,
7417 CXXNameMangler Mangler(*
this, Out);
7420 Mangler.getStream() <<
"_ZGV";
7421 Mangler.mangleName(
D);
7424void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
7429 Out <<
"__cxx_global_var_init";
7432void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *
D,
7435 CXXNameMangler Mangler(*
this, Out);
7436 Mangler.getStream() <<
"__dtor_";
7437 if (shouldMangleDeclName(
D))
7440 Mangler.getStream() <<
D->getName();
7443void ItaniumMangleContextImpl::mangleDynamicStermFinalizer(
const VarDecl *
D,
7447 CXXNameMangler Mangler(*
this, Out);
7448 Mangler.getStream() <<
"__finalize_";
7449 if (shouldMangleDeclName(
D))
7452 Mangler.getStream() <<
D->getName();
7455void ItaniumMangleContextImpl::mangleSEHFilterExpression(
7456 GlobalDecl EnclosingDecl, raw_ostream &Out) {
7457 CXXNameMangler Mangler(*
this, Out);
7458 Mangler.getStream() <<
"__filt_";
7459 auto *EnclosingFD = cast<FunctionDecl>(EnclosingDecl.
getDecl());
7460 if (shouldMangleDeclName(EnclosingFD))
7461 Mangler.mangle(EnclosingDecl);
7463 Mangler.getStream() << EnclosingFD->getName();
7466void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
7467 GlobalDecl EnclosingDecl, raw_ostream &Out) {
7468 CXXNameMangler Mangler(*
this, Out);
7469 Mangler.getStream() <<
"__fin_";
7470 auto *EnclosingFD = cast<FunctionDecl>(EnclosingDecl.
getDecl());
7471 if (shouldMangleDeclName(EnclosingFD))
7472 Mangler.mangle(EnclosingDecl);
7474 Mangler.getStream() << EnclosingFD->getName();
7477void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *
D,
7480 CXXNameMangler Mangler(*
this, Out);
7481 Mangler.getStream() <<
"_ZTH";
7482 Mangler.mangleName(
D);
7486ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *
D,
7489 CXXNameMangler Mangler(*
this, Out);
7490 Mangler.getStream() <<
"_ZTW";
7491 Mangler.mangleName(
D);
7494void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *
D,
7495 unsigned ManglingNumber,
7499 CXXNameMangler Mangler(*
this, Out);
7500 Mangler.getStream() <<
"_ZGR";
7501 Mangler.mangleName(
D);
7502 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
7503 Mangler.mangleSeqID(ManglingNumber - 1);
7506void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
7509 CXXNameMangler Mangler(*
this, Out);
7510 Mangler.getStream() <<
"_ZTV";
7511 Mangler.mangleCXXRecordDecl(RD);
7514void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
7517 CXXNameMangler Mangler(*
this, Out);
7518 Mangler.getStream() <<
"_ZTT";
7519 Mangler.mangleCXXRecordDecl(RD);
7522void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
7527 CXXNameMangler Mangler(*
this, Out);
7528 Mangler.getStream() <<
"_ZTC";
7531 bool SuppressSubstitution =
7532 getASTContext().getLangOpts().getClangABICompat() <=
7533 LangOptions::ClangABI::Ver19;
7534 Mangler.mangleCXXRecordDecl(RD, SuppressSubstitution);
7535 Mangler.getStream() << Offset;
7536 Mangler.getStream() <<
'_';
7537 Mangler.mangleCXXRecordDecl(
Type);
7540void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
7542 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
7543 CXXNameMangler Mangler(*
this, Out);
7544 Mangler.getStream() <<
"_ZTI";
7545 Mangler.mangleType(Ty);
7548void ItaniumMangleContextImpl::mangleCXXRTTIName(
7549 QualType Ty, raw_ostream &Out,
bool NormalizeIntegers =
false) {
7551 CXXNameMangler Mangler(*
this, Out, NormalizeIntegers);
7552 Mangler.getStream() <<
"_ZTS";
7553 Mangler.mangleType(Ty);
7556void ItaniumMangleContextImpl::mangleCanonicalTypeName(
7557 QualType Ty, raw_ostream &Out,
bool NormalizeIntegers =
false) {
7558 mangleCXXRTTIName(Ty, Out, NormalizeIntegers);
7561void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
7562 llvm_unreachable(
"Can't mangle string literals");
7565void ItaniumMangleContextImpl::mangleLambdaSig(
const CXXRecordDecl *Lambda,
7567 CXXNameMangler Mangler(*
this, Out);
7568 Mangler.mangleLambdaSig(Lambda);
7571void ItaniumMangleContextImpl::mangleModuleInitializer(
const Module *M,
7574 CXXNameMangler Mangler(*
this, Out);
7575 Mangler.getStream() <<
"_ZGI";
7579 auto Partition = M->
Name.find(
':');
7580 Mangler.mangleModuleNamePrefix(
7581 StringRef(&M->
Name[Partition + 1], M->
Name.size() - Partition - 1),
7589 return new ItaniumMangleContextImpl(
7592 return std::nullopt;
7601 return new ItaniumMangleContextImpl(Context, Diags, DiscriminatorOverride,
Enums/classes describing ABI related information about constructors, destructors and thunks.
Defines the clang::ASTContext interface.
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
@ LLVM_MARK_AS_BITMASK_ENUM
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
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 ...
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
CharUnits getMemberPointerPathAdjustment(const APValue &MP) const
Find the 'this' offset for the member path in a pointer-to-member APValue.
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
uint16_t getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD)
Return the "other" discriminator used for the pointer auth schema used for vtable pointers in instanc...
const CXXRecordDecl * baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const
Resolve the root record to be used to derive the vtable pointer authentication policy for the specifi...
Represents a constant array type that does not decay to a pointer when used as a function parameter.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Attr - This represents one attribute.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
A binding in a decomposition declaration.
A fixed int type of a specified bitwidth.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a call to a C++ constructor.
Represents a C++ constructor within a class.
Represents a delete expression for memory deallocation and destructor calls, e.g.
bool isGlobalDelete() const
Represents a C++ member access expression where the actual member referenced could not be resolved be...
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
A call to an overloaded operator written using operator syntax.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Represents a C++ struct/union/class.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
TemplateParameterList * getGenericLambdaTemplateParameterList() const
Retrieve the generic lambda's template parameter list.
base_class_iterator bases_end()
bool isLambda() const
Determine whether this class describes a lambda function object.
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
base_class_iterator bases_begin()
TypeSourceInfo * getLambdaTypeInfo() const
ArrayRef< NamedDecl * > getLambdaExplicitTemplateParameters() const
Retrieve the lambda template parameters that were specified explicitly.
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator,...
A C++ throw-expression (C++ [except.throw]).
const Expr * getSubExpr() const
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
bool isTypeOperand() const
QualType getTypeOperand(const ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Expr * getExprOperand() const
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
bool isListInitialization() const
Determine whether this expression models list-initialization.
Expr * getArg(unsigned I)
unsigned getNumArgs() const
Retrieve the number of arguments.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Expr * getExprOperand() const
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
bool isTypeOperand() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
CharUnits - This is an opaque type for sizes expressed in character units.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
ConditionalOperator - The ?: ternary operator.
Expr * getCond() const
getCond - Return the expression representing the condition for the ?: operator.
Represents the canonical version of C arrays with a specified constant size.
Represents a concrete matrix type with constant number of rows and columns.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool 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
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
bool isParameterPack() const
Whether this declaration is a parameter pack.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SourceLocation getLocation() const
void setImplicit(bool I=true)
DeclContext * getDeclContext()
bool isInAnonymousNamespace() const
Module * getOwningModuleForLinkage() const
Get the module that owns this declaration for linkage purposes.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
@ CXXConversionFunctionName
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Represents the type decltype(expr) (C++11).
Represents a C++17 deduced template specialization type.
Represents an extended address space qualifier where the input address space value is dependent.
Expr * getAddrSpaceExpr() const
QualType getPointeeType() const
Represents a qualified type name for which the type name is dependent.
A qualified reference to a name whose declaration cannot yet be resolved.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
unsigned getNumTemplateArgs() const
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
TemplateArgumentLoc const * getTemplateArgs() const
Represents an array type in C++ whose size is a value-dependent expression.
Represents an extended vector type where either the type or size is dependent.
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Represents a template specialization type whose template cannot be resolved, e.g.
const DependentTemplateStorage & getDependentTemplateName() const
ArrayRef< TemplateArgument > template_arguments() const
Represents a dependent template name that cannot be resolved prior to template instantiation.
Represents a vector type where either the type or size is dependent.
Designator - A designator in a C99 designated initializer.
bool isArrayDesignator() const
bool isArrayRangeDesignator() const
bool isFieldDesignator() const
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
An instance of this object exists for each enum constant that is defined.
llvm::APSInt getInitVal() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
ExplicitCastExpr - An explicit cast written in the source code.
This represents one expression.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
ExtVectorType - Extended vector type.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
llvm::APFloat getValue() const
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isMemberLikeConstrainedFriend() const
Determine whether a function is a friend function that cannot be redeclared outside of its class,...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
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.
A class which abstracts out some details necessary for making a call.
CallingConv getCC() const
bool getProducesResult() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
bool isConsumed() const
Is this parameter considered "consumed" by Objective-C ARC? Consumed parameters must have retainable ...
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
@ 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
Represents an arbitrary, user-specified SPIR-V type instruction.
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
const Expr * getSubExpr() const
Represents a C array with an unspecified size.
Represents a field injected from an anonymous union/struct into the parent scope.
Describes an C or C++ initializer list.
unsigned getNumInits() const
InitListExpr * getSyntacticForm() const
const Expr * getInit(unsigned Init) const
The injected class name of a C++ class template or class template partial specialization.
virtual DiscriminatorOverrideTy getDiscriminatorOverride() const =0
virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXVTT(const CXXRecordDecl *RD, raw_ostream &)=0
virtual void mangleItaniumThreadLocalInit(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXCtorComdat(const CXXConstructorDecl *D, raw_ostream &)=0
virtual void mangleLambdaSig(const CXXRecordDecl *Lambda, raw_ostream &)=0
virtual void mangleCXXDtorComdat(const CXXDestructorDecl *D, raw_ostream &)=0
virtual void mangleItaniumThreadLocalWrapper(const VarDecl *D, raw_ostream &)=0
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
virtual void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset, const CXXRecordDecl *Type, raw_ostream &)=0
virtual void mangleModuleInitializer(const Module *Module, raw_ostream &)=0
UnsignedOrNone(*)(ASTContext &, const NamedDecl *) DiscriminatorOverrideTy
An lvalue reference type, per C++11 [dcl.ref].
ClangABI
Clang versions with different platform ABI conformance.
virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThunkInfo &Thunk, bool ElideOverrideInfo, raw_ostream &)=0
virtual void mangleCXXRTTI(QualType T, raw_ostream &)=0
virtual std::string getLambdaString(const CXXRecordDecl *Lambda)=0
virtual bool shouldMangleStringLiteral(const StringLiteral *SL)=0
ASTContext & getASTContext() const
uint64_t getAnonymousStructIdForDebugInfo(const NamedDecl *D)
virtual void mangleDynamicAtExitDestructor(const VarDecl *D, raw_ostream &)=0
virtual bool isUniqueInternalLinkageDecl(const NamedDecl *ND)
virtual void mangleSEHFilterExpression(GlobalDecl EnclosingDecl, raw_ostream &Out)=0
virtual void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, bool ElideOverrideInfo, raw_ostream &)=0
virtual void mangleCanonicalTypeName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
Generates a unique string for an externally visible type for use with TBAA or type uniquing.
virtual void mangleStringLiteral(const StringLiteral *SL, raw_ostream &)=0
virtual void mangleCXXName(GlobalDecl GD, raw_ostream &)=0
virtual void needsUniqueInternalLinkageNames()
virtual void mangleReferenceTemporary(const VarDecl *D, unsigned ManglingNumber, raw_ostream &)=0
virtual bool shouldMangleCXXName(const NamedDecl *D)=0
virtual void mangleCXXRTTIName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
virtual void mangleDynamicInitializer(const VarDecl *D, raw_ostream &)=0
virtual void mangleCXXVTable(const CXXRecordDecl *RD, raw_ostream &)=0
virtual void mangleSEHFinallyBlock(GlobalDecl EnclosingDecl, raw_ostream &Out)=0
virtual void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &)=0
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
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.
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() const
Describes a module or submodule.
std::string Name
The name of this module.
StringRef getPrimaryModuleInterfaceName() const
Get the primary module interface name from a partition.
bool isModulePartition() const
Is this a module partition.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
bool hasLinkage() const
Determine whether this declaration has linkage.
bool isExternallyVisible() const
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>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Interfaces are the core concept in Objective-C for object oriented design.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
Represents a class type in Objective C.
NestedNameSpecifier getQualifier() const
Fetches the nested-name qualifier, if one was given.
decls_iterator decls_begin() const
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
TemplateArgumentLoc const * getTemplateArgs() const
unsigned getNumTemplateArgs() const
DeclarationName getName() const
Gets the name looked up.
Represents a pack expansion of types.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
unsigned getFunctionScopeDepth() const
Pointer-authentication qualifiers.
PointerType - C99 6.7.5.1 - Pointer Declarators.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
A (possibly-)qualified type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
bool hasUnaligned() const
bool hasAddressSpace() const
PointerAuthQualifier getPointerAuth() const
ObjCLifetime getObjCLifetime() const
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getOriginalDecl() const
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Encodes a location in the source.
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
const char * getStmtClassName() const
StringLiteral - This represents a string literal expression, e.g.
Represents the result of substituting a builtin template as a pack.
A structure for storing the information associated with a substituted template template parameter.
TemplateName getReplacement() const
Represents the result of substituting a set of types for a template type parameter pack.
Represents the declaration of a struct/union/class/enum.
TypedefNameDecl * getTypedefNameForAnonDecl() const
Exposes information about the current target.
virtual const char * getFloat128Mangling() const
Return the mangled code of __float128.
virtual const char * getIbm128Mangling() const
Return the mangled code of __ibm128.
virtual const char * getLongDoubleMangling() const
Return the mangled code of long double.
virtual const char * getBFloat16Mangling() const
Return the mangled code of bfloat.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Location wrapper for a TemplateArgument.
Represents a template argument.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getIntegralType() const
Retrieve the type of the integral value.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
std::pair< TemplateDecl *, DefaultArguments > getTemplateDeclAndDefaultArgs() const
Retrieves the underlying template declaration that this template name refers to, along with the deduc...
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
A template parameter object.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Represents a type template specialization; the template must be a class template, a type alias templa...
ArrayRef< TemplateArgument > template_arguments() const
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
TemplateDecl * getNamedConcept() const
Symbolic representation of typeid(T) for some type T.
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
A container of type source information.
QualType getType() const
Return the type wrapped by this type source info.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
TypeTrait getTrait() const
Determine which type trait this expression uses.
The base class of the type hierarchy.
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
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
Base class for declarations which introduce a typedef-name.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
QualType getArgumentType() const
bool isArgumentType() const
UnaryExprOrTypeTrait getKind() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
Represents the dependent type named by a dependently-scoped typename using declaration,...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void print(llvm::raw_ostream &Out) const
Represents a variable declaration or definition.
Represents a variable template specialization, which refers to a variable template with a given set o...
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
QualType getElementType() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
RequirementKind getKind() const
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool Sub(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
CXXCtorType
C++ constructor types.
@ Ctor_Base
Base object ctor.
@ Ctor_DefaultClosure
Default closure variant of a ctor.
@ Ctor_CopyingClosure
Copying closure variant of a ctor.
@ Ctor_Complete
Complete object ctor.
@ Ctor_Comdat
The COMDAT used for ctors.
llvm::StringRef getParameterABISpelling(ParameterABI kind)
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
CXXDtorType
C++ destructor types.
@ Dtor_Comdat
The COMDAT used for dtors.
@ Dtor_Base
Base object dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
@ 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.
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
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
llvm::dxil::ResourceClass ResourceClass
union clang::ReturnAdjustment::VirtualAdjustment Virtual
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
Iterator for iterating over Stmt * arrays that contain only T *.
A this pointer adjustment.
union clang::ThisAdjustment::VirtualAdjustment Virtual
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
The this pointer adjustment as well as an optional return adjustment for a thunk.
ThisAdjustment This
The this pointer adjustment.
ReturnAdjustment Return
The return adjustment.
struct clang::ReturnAdjustment::VirtualAdjustment::@179 Itanium
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset.
struct clang::ThisAdjustment::VirtualAdjustment::@181 Itanium