32 #include "llvm/ADT/StringExtras.h"
33 #include "llvm/Support/ErrorHandling.h"
34 #include "llvm/Support/raw_ostream.h"
36 #define MANGLE_CHECKER 0
42 using namespace clang;
58 = dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
59 return ContextParam->getDeclContext();
63 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
65 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
66 return ContextParam->getDeclContext();
70 if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC)) {
71 return getEffectiveDeclContext(cast<Decl>(DC));
74 if (
const auto *VD = dyn_cast<VarDecl>(D))
76 return VD->getASTContext().getTranslationUnitDecl();
78 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
80 return FD->getASTContext().getTranslationUnitDecl();
86 return getEffectiveDeclContext(cast<Decl>(DC));
89 static bool isLocalContainerContext(
const DeclContext *DC) {
90 return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
96 if (isLocalContainerContext(DC))
97 return dyn_cast<RecordDecl>(D);
99 DC = getEffectiveDeclContext(D);
106 return ftd->getTemplatedDecl();
113 return (fn ? getStructor(fn) :
decl);
116 static bool isLambda(
const NamedDecl *ND) {
124 static const unsigned UnknownArity = ~0U;
127 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
128 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
129 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
139 bool shouldMangleCXXName(
const NamedDecl *D)
override;
140 bool shouldMangleStringLiteral(
const StringLiteral *)
override {
143 void mangleCXXName(
const NamedDecl *D, raw_ostream &)
override;
145 raw_ostream &)
override;
148 raw_ostream &)
override;
149 void mangleReferenceTemporary(
const VarDecl *D,
unsigned ManglingNumber,
150 raw_ostream &)
override;
151 void mangleCXXVTable(
const CXXRecordDecl *RD, raw_ostream &)
override;
152 void mangleCXXVTT(
const CXXRecordDecl *RD, raw_ostream &)
override;
155 void mangleCXXRTTI(
QualType T, raw_ostream &)
override;
156 void mangleCXXRTTIName(
QualType T, raw_ostream &)
override;
157 void mangleTypeName(
QualType T, raw_ostream &)
override;
159 raw_ostream &)
override;
161 raw_ostream &)
override;
165 void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &)
override;
166 void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &Out)
override;
167 void mangleDynamicAtExitDestructor(
const VarDecl *D,
168 raw_ostream &Out)
override;
169 void mangleSEHFilterExpression(
const NamedDecl *EnclosingDecl,
170 raw_ostream &Out)
override;
171 void mangleSEHFinallyBlock(
const NamedDecl *EnclosingDecl,
172 raw_ostream &Out)
override;
173 void mangleItaniumThreadLocalInit(
const VarDecl *D, raw_ostream &)
override;
174 void mangleItaniumThreadLocalWrapper(
const VarDecl *D,
175 raw_ostream &)
override;
177 void mangleStringLiteral(
const StringLiteral *, raw_ostream &)
override;
179 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
185 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
186 if (Tag->getName().empty() && !Tag->getTypedefNameForAnonDecl())
192 unsigned discriminator = getASTContext().getManglingNumber(ND);
193 if (discriminator == 1)
195 disc = discriminator - 2;
200 unsigned &discriminator = Uniquifier[ND];
201 if (!discriminator) {
202 const DeclContext *DC = getEffectiveDeclContext(ND);
203 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
205 if (discriminator == 1)
207 disc = discriminator-2;
214 class CXXNameMangler {
215 ItaniumMangleContextImpl &
Context;
217 bool NullOut =
false;
222 bool DisableDerivedAbiTags =
false;
233 class FunctionTypeDepthState {
236 enum { InResultTypeMask = 1 };
239 FunctionTypeDepthState() : Bits(0) {}
242 unsigned getDepth()
const {
247 bool isInResultType()
const {
248 return Bits & InResultTypeMask;
251 FunctionTypeDepthState push() {
252 FunctionTypeDepthState tmp = *
this;
253 Bits = (Bits & ~InResultTypeMask) + 2;
257 void enterResultType() {
258 Bits |= InResultTypeMask;
261 void leaveResultType() {
262 Bits &= ~InResultTypeMask;
265 void pop(FunctionTypeDepthState saved) {
266 assert(getDepth() == saved.getDepth() + 1);
281 class AbiTagState final {
283 explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
289 AbiTagState(
const AbiTagState &) =
delete;
290 AbiTagState &operator=(
const AbiTagState &) =
delete;
292 ~AbiTagState() { pop(); }
294 void write(raw_ostream &Out,
const NamedDecl *ND,
295 const AbiTagList *AdditionalAbiTags) {
297 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
299 !AdditionalAbiTags &&
300 "only function and variables need a list of additional abi tags");
301 if (
const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
302 if (
const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
303 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
304 AbiTag->tags().end());
312 if (
const auto *AbiTag = ND->
getAttr<AbiTagAttr>()) {
313 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
314 AbiTag->tags().end());
315 TagList.insert(TagList.end(), AbiTag->tags().begin(),
316 AbiTag->tags().end());
319 if (AdditionalAbiTags) {
320 UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(),
321 AdditionalAbiTags->end());
322 TagList.insert(TagList.end(), AdditionalAbiTags->begin(),
323 AdditionalAbiTags->end());
326 std::sort(TagList.begin(), TagList.end());
327 TagList.erase(std::unique(TagList.begin(), TagList.end()), TagList.end());
329 writeSortedUniqueAbiTags(Out, TagList);
332 const AbiTagList &getUsedAbiTags()
const {
return UsedAbiTags; }
333 void setUsedAbiTags(
const AbiTagList &AbiTags) {
334 UsedAbiTags = AbiTags;
337 const AbiTagList &getEmittedAbiTags()
const {
338 return EmittedAbiTags;
341 const AbiTagList &getSortedUniqueUsedAbiTags() {
342 std::sort(UsedAbiTags.begin(), UsedAbiTags.end());
343 UsedAbiTags.erase(std::unique(UsedAbiTags.begin(), UsedAbiTags.end()),
350 AbiTagList UsedAbiTags;
352 AbiTagList EmittedAbiTags;
354 AbiTagState *&LinkHead;
355 AbiTagState *Parent =
nullptr;
358 assert(LinkHead ==
this &&
359 "abi tag link head must point to us on destruction");
361 Parent->UsedAbiTags.insert(Parent->UsedAbiTags.end(),
362 UsedAbiTags.begin(), UsedAbiTags.end());
363 Parent->EmittedAbiTags.insert(Parent->EmittedAbiTags.end(),
364 EmittedAbiTags.begin(),
365 EmittedAbiTags.end());
370 void writeSortedUniqueAbiTags(raw_ostream &Out,
const AbiTagList &AbiTags) {
371 for (
const auto &Tag : AbiTags) {
372 EmittedAbiTags.push_back(Tag);
380 AbiTagState *AbiTags =
nullptr;
381 AbiTagState AbiTagsRoot;
383 llvm::DenseMap<uintptr_t, unsigned> Substitutions;
388 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
389 const NamedDecl *D =
nullptr,
bool NullOut_ =
false)
390 :
Context(C), Out(Out_), NullOut(NullOut_), Structor(getStructor(D)),
393 assert(!D || (!isa<CXXDestructorDecl>(D) &&
394 !isa<CXXConstructorDecl>(D)));
396 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
399 SeqID(0), AbiTagsRoot(AbiTags) { }
400 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
403 SeqID(0), AbiTagsRoot(AbiTags) { }
405 CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
406 :
Context(Outer.Context), Out(Out_), NullOut(
false),
407 Structor(Outer.Structor),
StructorType(Outer.StructorType),
408 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
409 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
411 CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
412 :
Context(Outer.Context), Out(Out_), NullOut(
true),
413 Structor(Outer.Structor),
StructorType(Outer.StructorType),
414 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
415 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
419 if (Out.str()[0] ==
'\01')
423 char *result = abi::__cxa_demangle(Out.str().str().c_str(), 0, 0, &status);
424 assert(status == 0 &&
"Could not demangle mangled name!");
428 raw_ostream &getStream() {
return Out; }
430 void disableDerivedAbiTags() { DisableDerivedAbiTags =
true; }
431 static bool shouldHaveAbiTags(ItaniumMangleContextImpl &C,
const VarDecl *VD);
434 void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
435 void mangleNumber(
const llvm::APSInt &
I);
436 void mangleNumber(int64_t Number);
437 void mangleFloat(
const llvm::APFloat &F);
439 void mangleSeqID(
unsigned SeqID);
442 void mangleNameOrStandardSubstitution(
const NamedDecl *ND);
446 bool mangleSubstitution(
const NamedDecl *ND);
447 bool mangleSubstitution(
QualType T);
453 bool mangleStandardSubstitution(
const NamedDecl *ND);
455 void addSubstitution(
const NamedDecl *ND) {
458 addSubstitution(reinterpret_cast<uintptr_t>(ND));
464 void extendSubstitutions(CXXNameMangler* Other);
467 bool recursive =
false);
471 unsigned NumTemplateArgs,
472 unsigned KnownArity = UnknownArity);
474 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
476 void mangleNameWithAbiTags(
const NamedDecl *ND,
477 const AbiTagList *AdditionalAbiTags);
480 unsigned NumTemplateArgs);
481 void mangleUnqualifiedName(
const NamedDecl *ND,
482 const AbiTagList *AdditionalAbiTags) {
483 mangleUnqualifiedName(ND, ND->
getDeclName(), UnknownArity,
488 const AbiTagList *AdditionalAbiTags);
489 void mangleUnscopedName(
const NamedDecl *ND,
490 const AbiTagList *AdditionalAbiTags);
492 const AbiTagList *AdditionalAbiTags);
494 const AbiTagList *AdditionalAbiTags);
497 void mangleSourceNameWithAbiTags(
498 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
499 void mangleLocalName(
const Decl *D,
500 const AbiTagList *AdditionalAbiTags);
501 void mangleBlockForPrefix(
const BlockDecl *Block);
502 void mangleUnqualifiedBlock(
const BlockDecl *Block);
505 const AbiTagList *AdditionalAbiTags,
506 bool NoFunction=
false);
509 unsigned NumTemplateArgs);
511 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
513 void mangleTemplatePrefix(
const TemplateDecl *ND,
bool NoFunction=
false);
515 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
516 StringRef Prefix =
"");
519 void mangleVendorQualifier(StringRef qualifier);
526 #define ABSTRACT_TYPE(CLASS, PARENT)
527 #define NON_CANONICAL_TYPE(CLASS, PARENT)
528 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
529 #include "clang/AST/TypeNodes.def"
531 void mangleType(
const TagType*);
533 static StringRef getCallingConvQualifierName(
CallingConv CC);
538 void mangleNeonVectorType(
const VectorType *T);
539 void mangleAArch64NeonVectorType(
const VectorType *T);
541 void mangleIntegerLiteral(
QualType T,
const llvm::APSInt &
Value);
542 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
543 void mangleMemberExpr(
const Expr *base,
bool isArrow,
548 unsigned NumTemplateArgs,
549 unsigned knownArity);
550 void mangleCastExpression(
const Expr *
E, StringRef CastEncoding);
551 void mangleInitListElements(
const InitListExpr *InitList);
552 void mangleExpression(
const Expr *
E,
unsigned Arity = UnknownArity);
557 unsigned NumTemplateArgs);
559 unsigned NumTemplateArgs);
563 void mangleTemplateParameter(
unsigned Index);
568 const AbiTagList *AdditionalAbiTags);
571 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
573 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
578 bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
583 if (FD->
hasAttr<OverloadableAttr>())
601 if (!getASTContext().getLangOpts().CPlusPlus)
605 if (VD && !isa<DecompositionDecl>(D)) {
611 const DeclContext *DC = getEffectiveDeclContext(D);
615 DC = getEffectiveParentContext(DC);
617 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
618 !isa<VarTemplateSpecializationDecl>(D))
625 void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
626 const AbiTagList *AdditionalAbiTags) {
627 assert(AbiTags &&
"require AbiTagState");
628 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
631 void CXXNameMangler::mangleSourceNameWithAbiTags(
632 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
634 writeAbiTags(ND, AdditionalAbiTags);
637 void CXXNameMangler::mangle(
const NamedDecl *D) {
643 mangleFunctionEncoding(FD);
644 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
647 mangleName(IFD->getAnonField());
649 mangleName(cast<FieldDecl>(D));
652 void CXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD) {
656 if (!
Context.shouldMangleDeclName(FD)) {
661 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
662 if (ReturnTypeAbiTags.empty()) {
665 mangleFunctionEncodingBareType(FD);
673 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
674 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
676 FunctionEncodingMangler.disableDerivedAbiTags();
677 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
680 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
681 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
685 const AbiTagList &UsedAbiTags =
686 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
687 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
688 AdditionalAbiTags.erase(
689 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
690 UsedAbiTags.begin(), UsedAbiTags.end(),
691 AdditionalAbiTags.begin()),
692 AdditionalAbiTags.end());
695 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
696 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
700 extendSubstitutions(&FunctionEncodingMangler);
703 void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
704 if (FD->
hasAttr<EnableIfAttr>()) {
705 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
706 Out <<
"Ua9enable_ifI";
709 for (AttrVec::const_reverse_iterator
I = FD->
getAttrs().rbegin(),
712 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
716 mangleExpression(EIA->getCond());
720 FunctionTypeDepth.pop(Saved);
725 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
726 if (
auto Inherited = CD->getInheritedConstructor())
727 FD = Inherited.getConstructor();
745 bool MangleReturnType =
false;
747 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
748 isa<CXXConversionDecl>(FD)))
749 MangleReturnType =
true;
752 FD = PrimaryTemplate->getTemplatedDecl();
756 MangleReturnType, FD);
760 while (isa<LinkageSpecDecl>(DC)) {
761 DC = getEffectiveParentContext(DC);
770 ->isTranslationUnit())
774 return II && II->
isStr(
"std");
783 return isStd(cast<NamespaceDecl>(DC));
789 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
798 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
799 TemplateArgs = &Spec->getTemplateArgs();
800 return Spec->getSpecializedTemplate();
805 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
806 TemplateArgs = &Spec->getTemplateArgs();
807 return Spec->getSpecializedTemplate();
813 void CXXNameMangler::mangleName(
const NamedDecl *ND) {
814 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
816 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
817 if (VariableTypeAbiTags.empty()) {
819 mangleNameWithAbiTags(VD,
nullptr);
824 llvm::raw_null_ostream NullOutStream;
825 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
826 VariableNameMangler.disableDerivedAbiTags();
827 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
830 const AbiTagList &UsedAbiTags =
831 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
832 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
833 AdditionalAbiTags.erase(
834 std::set_difference(VariableTypeAbiTags.begin(),
835 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
836 UsedAbiTags.end(), AdditionalAbiTags.begin()),
837 AdditionalAbiTags.end());
840 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
842 mangleNameWithAbiTags(ND,
nullptr);
846 void CXXNameMangler::mangleNameWithAbiTags(
const NamedDecl *ND,
847 const AbiTagList *AdditionalAbiTags) {
853 const DeclContext *DC = getEffectiveDeclContext(ND);
859 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
861 DC = getEffectiveParentContext(DC);
862 else if (GetLocalClassDecl(ND)) {
863 mangleLocalName(ND, AdditionalAbiTags);
873 mangleUnscopedTemplateName(TD, AdditionalAbiTags);
874 mangleTemplateArgs(*TemplateArgs);
878 mangleUnscopedName(ND, AdditionalAbiTags);
882 if (isLocalContainerContext(DC)) {
883 mangleLocalName(ND, AdditionalAbiTags);
887 mangleNestedName(ND, DC, AdditionalAbiTags);
890 void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
892 unsigned NumTemplateArgs) {
896 mangleUnscopedTemplateName(TD,
nullptr);
897 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
899 mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
903 void CXXNameMangler::mangleUnscopedName(
const NamedDecl *ND,
904 const AbiTagList *AdditionalAbiTags) {
911 mangleUnqualifiedName(ND, AdditionalAbiTags);
914 void CXXNameMangler::mangleUnscopedTemplateName(
915 const TemplateDecl *ND,
const AbiTagList *AdditionalAbiTags) {
918 if (mangleSubstitution(ND))
922 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
923 assert(!AdditionalAbiTags &&
924 "template template param cannot have abi tags");
925 mangleTemplateParameter(TTP->getIndex());
926 }
else if (isa<BuiltinTemplateDecl>(ND)) {
927 mangleUnscopedName(ND, AdditionalAbiTags);
935 void CXXNameMangler::mangleUnscopedTemplateName(
936 TemplateName Template,
const AbiTagList *AdditionalAbiTags) {
940 return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
942 if (mangleSubstitution(Template))
945 assert(!AdditionalAbiTags &&
946 "dependent template name cannot have abi tags");
949 assert(Dependent &&
"Not a dependent template name?");
951 mangleSourceName(Id);
953 mangleOperatorName(Dependent->
getOperator(), UnknownArity);
955 addSubstitution(Template);
958 void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
972 llvm::APInt valueBits = f.bitcastToAPInt();
973 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
974 assert(numCharacters != 0);
980 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
982 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
985 uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
986 hexDigit >>= (digitBitIndex % 64);
990 static const char charForHex[16] = {
991 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
992 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'
994 buffer[stringIndex] = charForHex[hexDigit];
997 Out.write(buffer.data(), numCharacters);
1000 void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
1001 if (Value.isSigned() && Value.isNegative()) {
1003 Value.abs().print(Out,
false);
1005 Value.print(Out,
false);
1009 void CXXNameMangler::mangleNumber(int64_t Number) {
1019 void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) {
1027 mangleNumber(NonVirtual);
1033 mangleNumber(NonVirtual);
1035 mangleNumber(Virtual);
1041 if (!mangleSubstitution(
QualType(TST, 0))) {
1042 mangleTemplatePrefix(TST->getTemplateName());
1047 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
1050 }
else if (
const auto *DTST =
1052 if (!mangleSubstitution(
QualType(DTST, 0))) {
1053 TemplateName Template = getASTContext().getDependentTemplateName(
1054 DTST->getQualifier(), DTST->getIdentifier());
1055 mangleTemplatePrefix(Template);
1060 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1061 addSubstitution(
QualType(DTST, 0));
1091 switch (qualifier->
getKind()) {
1103 llvm_unreachable(
"Can't mangle __super specifier");
1107 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1115 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1132 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1139 if (mangleUnresolvedTypeOrSimpleId(
QualType(type, 0), recursive ?
"N" :
""))
1148 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1166 void CXXNameMangler::mangleUnresolvedName(
1169 unsigned knownArity) {
1170 if (qualifier) mangleUnresolvedPrefix(qualifier);
1186 mangleOperatorName(name, knownArity);
1189 llvm_unreachable(
"Can't mangle a constructor name!");
1191 llvm_unreachable(
"Can't mangle a using directive name!");
1193 llvm_unreachable(
"Can't mangle a deduction guide name!");
1197 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1203 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1206 void CXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
1208 unsigned KnownArity,
1209 const AbiTagList *AdditionalAbiTags) {
1210 unsigned Arity = KnownArity;
1219 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1228 for (
auto *BD : DD->bindings())
1229 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1231 writeAbiTags(ND, AdditionalAbiTags);
1243 getEffectiveDeclContext(ND)->isFileContext())
1247 bool IsRegCall = FD &&
1251 mangleRegCallName(II);
1253 mangleSourceName(II);
1255 writeAbiTags(ND, AdditionalAbiTags);
1260 assert(ND &&
"mangling empty name without declaration");
1262 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1263 if (NS->isAnonymousNamespace()) {
1265 Out <<
"12_GLOBAL__N_1";
1270 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1285 &&
"Expected anonymous struct or union!");
1292 assert(FD->getIdentifier() &&
"Data member name isn't an identifier!");
1294 mangleSourceName(FD->getIdentifier());
1305 if (isa<ObjCContainerDecl>(ND))
1309 const TagDecl *TD = cast<TagDecl>(ND);
1312 "Typedef should not be in another decl context!");
1314 "Typedef was not named!");
1316 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1319 writeAbiTags(TD,
nullptr);
1327 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
1328 if (Record->isLambda() && Record->getLambdaManglingNumber()) {
1329 assert(!AdditionalAbiTags &&
1330 "Lambda type cannot have additional abi tags");
1331 mangleLambda(Record);
1337 unsigned UnnamedMangle = getASTContext().getManglingNumber(TD);
1339 if (UnnamedMangle > 1)
1340 Out << UnnamedMangle - 2;
1342 writeAbiTags(TD, AdditionalAbiTags);
1348 unsigned AnonStructId = NullOut ? 0 :
Context.getAnonymousStructId(TD);
1355 Str += llvm::utostr(AnonStructId);
1365 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1370 if (
auto Inherited =
1371 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1372 InheritedFrom = Inherited.getConstructor()->
getParent();
1373 InheritedTemplateArgs =
1374 Inherited.getConstructor()->getTemplateSpecializationArgs();
1380 mangleCXXCtorType(static_cast<CXXCtorType>(
StructorType), InheritedFrom);
1388 if (InheritedTemplateArgs)
1389 mangleTemplateArgs(*InheritedTemplateArgs);
1391 writeAbiTags(ND, AdditionalAbiTags);
1399 mangleCXXDtorType(static_cast<CXXDtorType>(
StructorType));
1404 writeAbiTags(ND, AdditionalAbiTags);
1408 if (ND && Arity == UnknownArity) {
1409 Arity = cast<FunctionDecl>(ND)->getNumParams();
1412 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1413 if (!MD->isStatic())
1419 mangleOperatorName(Name, Arity);
1420 writeAbiTags(ND, AdditionalAbiTags);
1424 llvm_unreachable(
"Can't mangle a deduction guide name!");
1427 llvm_unreachable(
"Can't mangle a using directive name!");
1431 void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1435 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__"
1439 void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1446 void CXXNameMangler::mangleNestedName(
const NamedDecl *ND,
1448 const AbiTagList *AdditionalAbiTags,
1456 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1462 mangleQualifiers(MethodQuals);
1463 mangleRefQualifier(Method->getRefQualifier());
1469 mangleTemplatePrefix(TD, NoFunction);
1470 mangleTemplateArgs(*TemplateArgs);
1473 manglePrefix(DC, NoFunction);
1474 mangleUnqualifiedName(ND, AdditionalAbiTags);
1479 void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1481 unsigned NumTemplateArgs) {
1486 mangleTemplatePrefix(TD);
1487 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1492 void CXXNameMangler::mangleLocalName(
const Decl *D,
1493 const AbiTagList *AdditionalAbiTags) {
1499 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1501 const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
1506 AbiTagState LocalAbiTags(AbiTags);
1509 mangleObjCMethodName(MD);
1510 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1511 mangleBlockForPrefix(BD);
1513 mangleFunctionEncoding(cast<FunctionDecl>(DC));
1517 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1536 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1538 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1540 mangleNumber(Num - 2);
1549 mangleUnqualifiedName(RD, AdditionalAbiTags);
1550 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1551 manglePrefix(getEffectiveDeclContext(BD),
true );
1552 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1553 mangleUnqualifiedBlock(BD);
1555 const NamedDecl *ND = cast<NamedDecl>(D);
1556 mangleNestedName(ND, getEffectiveDeclContext(ND), AdditionalAbiTags,
1559 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1563 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1565 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1567 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1569 mangleNumber(Num - 2);
1574 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1575 mangleUnqualifiedBlock(BD);
1577 mangleUnqualifiedName(cast<NamedDecl>(D), AdditionalAbiTags);
1580 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1582 if (
Context.getNextDiscriminator(ND, disc)) {
1586 Out <<
"__" << disc <<
'_';
1591 void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *Block) {
1592 if (GetLocalClassDecl(Block)) {
1593 mangleLocalName(Block,
nullptr);
1596 const DeclContext *DC = getEffectiveDeclContext(Block);
1597 if (isLocalContainerContext(DC)) {
1598 mangleLocalName(Block,
nullptr);
1601 manglePrefix(getEffectiveDeclContext(Block));
1602 mangleUnqualifiedBlock(Block);
1605 void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *Block) {
1608 Context->getDeclContext()->isRecord()) {
1609 const auto *ND = cast<NamedDecl>(
Context);
1611 mangleSourceNameWithAbiTags(ND);
1622 Number =
Context.getBlockId(Block,
false);
1629 void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
1641 Context->getDeclContext()->isRecord()) {
1643 = cast<NamedDecl>(
Context)->getIdentifier()) {
1644 mangleSourceName(Name);
1652 getAs<FunctionProtoType>();
1653 mangleBareFunctionType(Proto,
false,
1663 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
1665 mangleNumber(Number - 2);
1670 switch (qualifier->
getKind()) {
1676 llvm_unreachable(
"Can't mangle __super specifier");
1701 llvm_unreachable(
"unexpected nested name specifier");
1704 void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
1716 if (NoFunction && isLocalContainerContext(DC))
1719 assert(!isLocalContainerContext(DC));
1721 const NamedDecl *ND = cast<NamedDecl>(DC);
1722 if (mangleSubstitution(ND))
1728 mangleTemplatePrefix(TD);
1729 mangleTemplateArgs(*TemplateArgs);
1731 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1732 mangleUnqualifiedName(ND,
nullptr);
1735 addSubstitution(ND);
1738 void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
1743 return mangleTemplatePrefix(TD);
1746 manglePrefix(Qualified->getQualifier());
1750 mangleUnqualifiedName(
nullptr, (*Overloaded->begin())->getDeclName(),
1751 UnknownArity,
nullptr);
1756 assert(Dependent &&
"Unknown template name kind?");
1758 manglePrefix(Qualifier);
1759 mangleUnscopedTemplateName(Template,
nullptr);
1762 void CXXNameMangler::mangleTemplatePrefix(
const TemplateDecl *ND,
1770 if (mangleSubstitution(ND))
1774 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1775 mangleTemplateParameter(TTP->getIndex());
1777 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1778 if (isa<BuiltinTemplateDecl>(ND))
1779 mangleUnqualifiedName(ND,
nullptr);
1784 addSubstitution(ND);
1793 if (mangleSubstitution(TN))
1808 if (isa<TemplateTemplateParmDecl>(TD))
1809 mangleTemplateParameter(cast<TemplateTemplateParmDecl>(TD)->getIndex());
1815 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
1844 Out <<
"_SUBSTPACK_";
1849 addSubstitution(TN);
1852 bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
1858 case Type::Adjusted:
1861 case Type::BlockPointer:
1862 case Type::LValueReference:
1863 case Type::RValueReference:
1864 case Type::MemberPointer:
1865 case Type::ConstantArray:
1866 case Type::IncompleteArray:
1867 case Type::VariableArray:
1868 case Type::DependentSizedArray:
1869 case Type::DependentSizedExtVector:
1871 case Type::ExtVector:
1872 case Type::FunctionProto:
1873 case Type::FunctionNoProto:
1875 case Type::Attributed:
1877 case Type::DeducedTemplateSpecialization:
1878 case Type::PackExpansion:
1879 case Type::ObjCObject:
1880 case Type::ObjCInterface:
1881 case Type::ObjCObjectPointer:
1882 case Type::ObjCTypeParam:
1885 llvm_unreachable(
"type is illegal as a nested name specifier");
1887 case Type::SubstTemplateTypeParmPack:
1892 Out <<
"_SUBSTPACK_";
1899 case Type::TypeOfExpr:
1901 case Type::Decltype:
1902 case Type::TemplateTypeParm:
1903 case Type::UnaryTransform:
1904 case Type::SubstTemplateTypeParm:
1918 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
1921 case Type::UnresolvedUsing:
1922 mangleSourceNameWithAbiTags(
1923 cast<UnresolvedUsingType>(Ty)->getDecl());
1928 mangleSourceNameWithAbiTags(cast<TagType>(Ty)->getDecl());
1931 case Type::TemplateSpecialization: {
1933 cast<TemplateSpecializationType>(Ty);
1935 switch (TN.getKind()) {
1942 assert(TD &&
"no template for template specialization type");
1943 if (isa<TemplateTemplateParmDecl>(TD))
1944 goto unresolvedType;
1946 mangleSourceNameWithAbiTags(TD);
1952 llvm_unreachable(
"invalid base for a template specialization type");
1966 Out <<
"_SUBSTPACK_";
1975 case Type::InjectedClassName:
1976 mangleSourceNameWithAbiTags(
1977 cast<InjectedClassNameType>(Ty)->getDecl());
1980 case Type::DependentName:
1981 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
1984 case Type::DependentTemplateSpecialization: {
1986 cast<DependentTemplateSpecializationType>(Ty);
1992 case Type::Elaborated:
1993 return mangleUnresolvedTypeOrSimpleId(
1994 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
2000 void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
2010 llvm_unreachable(
"Not an operator name");
2033 case OO_New: Out <<
"nw";
break;
2035 case OO_Array_New: Out <<
"na";
break;
2037 case OO_Delete: Out <<
"dl";
break;
2039 case OO_Array_Delete: Out <<
"da";
break;
2043 Out << (Arity == 1?
"ps" :
"pl");
break;
2047 Out << (Arity == 1?
"ng" :
"mi");
break;
2051 Out << (Arity == 1?
"ad" :
"an");
break;
2056 Out << (Arity == 1?
"de" :
"ml");
break;
2058 case OO_Tilde: Out <<
"co";
break;
2060 case OO_Slash: Out <<
"dv";
break;
2062 case OO_Percent: Out <<
"rm";
break;
2064 case OO_Pipe: Out <<
"or";
break;
2066 case OO_Caret: Out <<
"eo";
break;
2068 case OO_Equal: Out <<
"aS";
break;
2070 case OO_PlusEqual: Out <<
"pL";
break;
2072 case OO_MinusEqual: Out <<
"mI";
break;
2074 case OO_StarEqual: Out <<
"mL";
break;
2076 case OO_SlashEqual: Out <<
"dV";
break;
2078 case OO_PercentEqual: Out <<
"rM";
break;
2080 case OO_AmpEqual: Out <<
"aN";
break;
2082 case OO_PipeEqual: Out <<
"oR";
break;
2084 case OO_CaretEqual: Out <<
"eO";
break;
2086 case OO_LessLess: Out <<
"ls";
break;
2088 case OO_GreaterGreater: Out <<
"rs";
break;
2090 case OO_LessLessEqual: Out <<
"lS";
break;
2092 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2094 case OO_EqualEqual: Out <<
"eq";
break;
2096 case OO_ExclaimEqual: Out <<
"ne";
break;
2098 case OO_Less: Out <<
"lt";
break;
2100 case OO_Greater: Out <<
"gt";
break;
2102 case OO_LessEqual: Out <<
"le";
break;
2104 case OO_GreaterEqual: Out <<
"ge";
break;
2106 case OO_Exclaim: Out <<
"nt";
break;
2108 case OO_AmpAmp: Out <<
"aa";
break;
2110 case OO_PipePipe: Out <<
"oo";
break;
2112 case OO_PlusPlus: Out <<
"pp";
break;
2114 case OO_MinusMinus: Out <<
"mm";
break;
2116 case OO_Comma: Out <<
"cm";
break;
2118 case OO_ArrowStar: Out <<
"pm";
break;
2120 case OO_Arrow: Out <<
"pt";
break;
2122 case OO_Call: Out <<
"cl";
break;
2124 case OO_Subscript: Out <<
"ix";
break;
2129 case OO_Conditional: Out <<
"qu";
break;
2132 case OO_Coawait: Out <<
"aw";
break;
2136 llvm_unreachable(
"Not an overloaded operator");
2140 void CXXNameMangler::mangleQualifiers(
Qualifiers Quals) {
2158 ASString =
"AS" + llvm::utostr(TargetAS);
2161 default: llvm_unreachable(
"Not a language specific address space");
2174 mangleVendorQualifier(ASString);
2187 mangleVendorQualifier(
"__weak");
2191 mangleVendorQualifier(
"__unaligned");
2203 mangleVendorQualifier(
"__strong");
2207 mangleVendorQualifier(
"__autoreleasing");
2230 void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2231 Out <<
'U' << name.size() << name;
2237 switch (RefQualifier) {
2251 void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2252 Context.mangleObjCMethodName(MD, Out);
2268 void CXXNameMangler::mangleType(
QualType T) {
2309 = dyn_cast<TemplateSpecializationType>(T))
2323 const Type *ty = split.
Ty;
2326 if (isSubstitutable && mangleSubstitution(T))
2331 if (quals && isa<ArrayType>(T)) {
2340 mangleQualifiers(quals);
2346 #define ABSTRACT_TYPE(CLASS, PARENT)
2347 #define NON_CANONICAL_TYPE(CLASS, PARENT) \
2349 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
2351 #define TYPE(CLASS, PARENT) \
2353 mangleType(static_cast<const CLASS##Type*>(ty)); \
2355 #include "clang/AST/TypeNodes.def"
2360 if (isSubstitutable)
2364 void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
2365 if (!mangleStandardSubstitution(ND))
2369 void CXXNameMangler::mangleType(
const BuiltinType *T) {
2399 std::string type_name;
2401 case BuiltinType::Void:
2404 case BuiltinType::Bool:
2407 case BuiltinType::Char_U:
2408 case BuiltinType::Char_S:
2411 case BuiltinType::UChar:
2414 case BuiltinType::UShort:
2417 case BuiltinType::UInt:
2420 case BuiltinType::ULong:
2423 case BuiltinType::ULongLong:
2426 case BuiltinType::UInt128:
2429 case BuiltinType::SChar:
2432 case BuiltinType::WChar_S:
2433 case BuiltinType::WChar_U:
2436 case BuiltinType::Char16:
2439 case BuiltinType::Char32:
2442 case BuiltinType::Short:
2445 case BuiltinType::Int:
2448 case BuiltinType::Long:
2451 case BuiltinType::LongLong:
2454 case BuiltinType::Int128:
2457 case BuiltinType::Half:
2460 case BuiltinType::Float:
2463 case BuiltinType::Double:
2466 case BuiltinType::LongDouble:
2467 Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
2471 case BuiltinType::Float128:
2472 if (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble())
2473 Out <<
"U10__float128";
2477 case BuiltinType::NullPtr:
2481 #define BUILTIN_TYPE(Id, SingletonId)
2482 #define PLACEHOLDER_TYPE(Id, SingletonId) \
2483 case BuiltinType::Id:
2484 #include "clang/AST/BuiltinTypes.def"
2485 case BuiltinType::Dependent:
2487 llvm_unreachable(
"mangling a placeholder type");
2489 case BuiltinType::ObjCId:
2490 Out <<
"11objc_object";
2492 case BuiltinType::ObjCClass:
2493 Out <<
"10objc_class";
2495 case BuiltinType::ObjCSel:
2496 Out <<
"13objc_selector";
2498 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2499 case BuiltinType::Id: \
2500 type_name = "ocl_" #ImgType "_" #Suffix; \
2501 Out << type_name.size() << type_name; \
2503 #include "clang/Basic/OpenCLImageTypes.def"
2504 case BuiltinType::OCLSampler:
2505 Out <<
"11ocl_sampler";
2507 case BuiltinType::OCLEvent:
2508 Out <<
"9ocl_event";
2510 case BuiltinType::OCLClkEvent:
2511 Out <<
"12ocl_clkevent";
2513 case BuiltinType::OCLQueue:
2514 Out <<
"9ocl_queue";
2516 case BuiltinType::OCLReserveID:
2517 Out <<
"13ocl_reserveid";
2522 StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
2548 llvm_unreachable(
"bad calling convention");
2551 void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *T) {
2560 StringRef CCQualifier = getCallingConvQualifierName(T->
getExtInfo().
getCC());
2561 if (!CCQualifier.empty())
2562 mangleVendorQualifier(CCQualifier);
2588 mangleVendorQualifier(
"ns_consumed");
2595 mangleExtFunctionInfo(T);
2612 mangleType(ExceptTy);
2615 }
else if (T->
isNothrow(getASTContext())) {
2623 mangleBareFunctionType(T,
true);
2637 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2639 FunctionTypeDepth.enterResultType();
2641 FunctionTypeDepth.leaveResultType();
2643 FunctionTypeDepth.pop(saved);
2648 bool MangleReturnType,
2652 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2655 if (MangleReturnType) {
2656 FunctionTypeDepth.enterResultType();
2660 mangleVendorQualifier(
"ns_returns_retained");
2665 auto SplitReturnTy = ReturnTy.
split();
2667 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
2669 mangleType(ReturnTy);
2671 FunctionTypeDepth.leaveResultType();
2678 FunctionTypeDepth.pop(saved);
2696 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
2697 Out <<
"U17pass_object_size" <<
Attr->getType();
2702 FunctionTypeDepth.pop(saved);
2717 void CXXNameMangler::mangleType(
const EnumType *T) {
2718 mangleType(static_cast<const TagType*>(T));
2720 void CXXNameMangler::mangleType(
const RecordType *T) {
2721 mangleType(static_cast<const TagType*>(T));
2723 void CXXNameMangler::mangleType(
const TagType *T) {
2731 Out <<
'A' << T->
getSize() <<
'_';
2780 mangleType(PointeeType);
2785 mangleTemplateParameter(T->
getIndex());
2794 Out <<
"_SUBSTPACK_";
2798 void CXXNameMangler::mangleType(
const PointerType *T) {
2820 void CXXNameMangler::mangleType(
const ComplexType *T) {
2828 void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
2830 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2831 const char *EltName =
nullptr;
2833 switch (cast<BuiltinType>(EltType)->getKind()) {
2834 case BuiltinType::SChar:
2835 case BuiltinType::UChar:
2836 EltName =
"poly8_t";
2838 case BuiltinType::Short:
2839 case BuiltinType::UShort:
2840 EltName =
"poly16_t";
2842 case BuiltinType::ULongLong:
2843 EltName =
"poly64_t";
2845 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
2848 switch (cast<BuiltinType>(EltType)->
getKind()) {
2849 case BuiltinType::SChar: EltName =
"int8_t";
break;
2850 case BuiltinType::UChar: EltName =
"uint8_t";
break;
2851 case BuiltinType::Short: EltName =
"int16_t";
break;
2852 case BuiltinType::UShort: EltName =
"uint16_t";
break;
2853 case BuiltinType::Int: EltName =
"int32_t";
break;
2854 case BuiltinType::UInt: EltName =
"uint32_t";
break;
2855 case BuiltinType::LongLong: EltName =
"int64_t";
break;
2856 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
2857 case BuiltinType::Double: EltName =
"float64_t";
break;
2858 case BuiltinType::Float: EltName =
"float32_t";
break;
2859 case BuiltinType::Half: EltName =
"float16_t";
break;
2861 llvm_unreachable(
"unexpected Neon vector element type");
2864 const char *BaseName =
nullptr;
2866 getASTContext().getTypeSize(EltType));
2868 BaseName =
"__simd64_";
2870 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
2871 BaseName =
"__simd128_";
2873 Out << strlen(BaseName) + strlen(EltName);
2874 Out << BaseName << EltName;
2879 case BuiltinType::SChar:
2881 case BuiltinType::Short:
2883 case BuiltinType::Int:
2885 case BuiltinType::Long:
2886 case BuiltinType::LongLong:
2888 case BuiltinType::UChar:
2890 case BuiltinType::UShort:
2892 case BuiltinType::UInt:
2894 case BuiltinType::ULong:
2895 case BuiltinType::ULongLong:
2897 case BuiltinType::Half:
2899 case BuiltinType::Float:
2901 case BuiltinType::Double:
2904 llvm_unreachable(
"Unexpected vector element base type");
2911 void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
2913 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2918 assert((BitSize == 64 || BitSize == 128) &&
2919 "Neon vector type not 64 or 128 bits");
2923 switch (cast<BuiltinType>(EltType)->getKind()) {
2924 case BuiltinType::UChar:
2927 case BuiltinType::UShort:
2930 case BuiltinType::ULong:
2931 case BuiltinType::ULongLong:
2935 llvm_unreachable(
"unexpected Neon polynomial vector element type");
2940 std::string TypeName =
2941 (
"__" + EltName +
"x" + Twine(T->
getNumElements()) +
"_t").str();
2942 Out << TypeName.length() << TypeName;
2953 void CXXNameMangler::mangleType(
const VectorType *T) {
2956 llvm::Triple Target = getASTContext().getTargetInfo().getTriple();
2957 llvm::Triple::ArchType Arch =
2958 getASTContext().getTargetInfo().getTriple().getArch();
2959 if ((Arch == llvm::Triple::aarch64 ||
2960 Arch == llvm::Triple::aarch64_be) && !Target.isOSDarwin())
2961 mangleAArch64NeonVectorType(T);
2963 mangleNeonVectorType(T);
2975 mangleType(static_cast<const VectorType*>(T));
2997 Out <<
"U8__kindof";
3002 llvm::raw_svector_ostream QualOS(QualStr);
3003 QualOS <<
"objcproto";
3004 for (
const auto *I : T->
quals()) {
3005 StringRef name = I->getName();
3006 QualOS << name.size() << name;
3008 Out <<
'U' << QualStr.size() << QualStr;
3017 mangleType(typeArg);
3023 Out <<
"U13block_pointer";
3038 if (mangleSubstitution(
QualType(T, 0)))
3091 getASTContext().getDependentTemplateName(T->
getQualifier(),
3093 mangleTemplatePrefix(Prefix);
3102 void CXXNameMangler::mangleType(
const TypeOfType *T) {
3114 void CXXNameMangler::mangleType(
const DecltypeType *T) {
3125 if (isa<DeclRefExpr>(E) ||
3126 isa<MemberExpr>(E) ||
3127 isa<UnresolvedLookupExpr>(E) ||
3128 isa<DependentScopeDeclRefExpr>(E) ||
3129 isa<CXXDependentScopeMemberExpr>(E) ||
3130 isa<UnresolvedMemberExpr>(E))
3134 mangleExpression(E);
3154 void CXXNameMangler::mangleType(
const AutoType *T) {
3159 "shouldn't need to mangle __auto_type!");
3175 void CXXNameMangler::mangleType(
const AtomicType *T) {
3182 void CXXNameMangler::mangleType(
const PipeType *T) {
3189 void CXXNameMangler::mangleIntegerLiteral(
QualType T,
3190 const llvm::APSInt &Value) {
3197 Out << (Value.getBoolValue() ?
'1' :
'0');
3199 mangleNumber(Value);
3205 void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
3208 if (!RT->getDecl()->isAnonymousStructOrUnion())
3213 Base = ME->getBase();
3214 IsArrow = ME->isArrow();
3223 Out << (IsArrow ?
"pt" :
"dt");
3224 mangleExpression(Base);
3229 void CXXNameMangler::mangleMemberExpr(
const Expr *base,
3235 unsigned NumTemplateArgs,
3240 mangleMemberExprBase(base, isArrow);
3241 mangleUnresolvedName(qualifier, member, TemplateArgs, NumTemplateArgs, arity);
3254 if (callee == fn)
return false;
3258 if (!lookup)
return false;
3275 void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
3277 Out << CastEncoding;
3282 void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
3284 InitList = Syntactic;
3285 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
3286 mangleExpression(InitList->
getInit(i));
3289 void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity) {
3313 QualType ImplicitlyConvertedToType;
3318 #define ABSTRACT_STMT(Type)
3319 #define EXPR(Type, Base)
3320 #define STMT(Type, Base) \
3321 case Expr::Type##Class:
3322 #include "clang/AST/StmtNodes.inc"
3327 case Expr::AddrLabelExprClass:
3328 case Expr::DesignatedInitUpdateExprClass:
3329 case Expr::ImplicitValueInitExprClass:
3330 case Expr::ArrayInitLoopExprClass:
3331 case Expr::ArrayInitIndexExprClass:
3332 case Expr::NoInitExprClass:
3333 case Expr::ParenListExprClass:
3334 case Expr::LambdaExprClass:
3335 case Expr::MSPropertyRefExprClass:
3336 case Expr::MSPropertySubscriptExprClass:
3337 case Expr::TypoExprClass:
3338 case Expr::OMPArraySectionExprClass:
3339 case Expr::CXXInheritedCtorInitExprClass:
3340 llvm_unreachable(
"unexpected statement kind");
3343 case Expr::BlockExprClass:
3344 case Expr::ChooseExprClass:
3345 case Expr::CompoundLiteralExprClass:
3346 case Expr::DesignatedInitExprClass:
3347 case Expr::ExtVectorElementExprClass:
3348 case Expr::GenericSelectionExprClass:
3349 case Expr::ObjCEncodeExprClass:
3350 case Expr::ObjCIsaExprClass:
3351 case Expr::ObjCIvarRefExprClass:
3352 case Expr::ObjCMessageExprClass:
3353 case Expr::ObjCPropertyRefExprClass:
3354 case Expr::ObjCProtocolExprClass:
3355 case Expr::ObjCSelectorExprClass:
3356 case Expr::ObjCStringLiteralClass:
3357 case Expr::ObjCBoxedExprClass:
3358 case Expr::ObjCArrayLiteralClass:
3359 case Expr::ObjCDictionaryLiteralClass:
3360 case Expr::ObjCSubscriptRefExprClass:
3361 case Expr::ObjCIndirectCopyRestoreExprClass:
3362 case Expr::ObjCAvailabilityCheckExprClass:
3363 case Expr::OffsetOfExprClass:
3364 case Expr::PredefinedExprClass:
3365 case Expr::ShuffleVectorExprClass:
3366 case Expr::ConvertVectorExprClass:
3367 case Expr::StmtExprClass:
3368 case Expr::TypeTraitExprClass:
3369 case Expr::ArrayTypeTraitExprClass:
3370 case Expr::ExpressionTraitExprClass:
3371 case Expr::VAArgExprClass:
3372 case Expr::CUDAKernelCallExprClass:
3373 case Expr::AsTypeExprClass:
3374 case Expr::PseudoObjectExprClass:
3375 case Expr::AtomicExprClass:
3381 "cannot yet mangle expression type %0");
3388 case Expr::CXXUuidofExprClass: {
3392 Out <<
"u8__uuidoft";
3396 Out <<
"u8__uuidofz";
3397 mangleExpression(UuidExp, Arity);
3403 case Expr::BinaryConditionalOperatorClass: {
3407 "?: operator with omitted middle operand cannot be mangled");
3414 case Expr::OpaqueValueExprClass:
3415 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
3417 case Expr::InitListExprClass: {
3419 mangleInitListElements(cast<InitListExpr>(E));
3424 case Expr::CXXDefaultArgExprClass:
3425 mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
3428 case Expr::CXXDefaultInitExprClass:
3429 mangleExpression(cast<CXXDefaultInitExpr>(E)->getExpr(), Arity);
3432 case Expr::CXXStdInitializerListExprClass:
3433 mangleExpression(cast<CXXStdInitializerListExpr>(E)->getSubExpr(), Arity);
3436 case Expr::SubstNonTypeTemplateParmExprClass:
3437 mangleExpression(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
3441 case Expr::UserDefinedLiteralClass:
3444 case Expr::CXXMemberCallExprClass:
3445 case Expr::CallExprClass: {
3465 if (isa<PackExpansionExpr>(Arg))
3466 CallArity = UnknownArity;
3468 mangleExpression(CE->
getCallee(), CallArity);
3470 mangleExpression(Arg);
3475 case Expr::CXXNewExprClass: {
3478 Out << (New->
isArray() ?
"na" :
"nw");
3481 mangleExpression(*I);
3495 mangleExpression(*I);
3496 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
3497 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
3498 mangleExpression(PLE->getExpr(i));
3500 isa<InitListExpr>(Init)) {
3502 mangleInitListElements(cast<InitListExpr>(Init));
3504 mangleExpression(Init);
3510 case Expr::CXXPseudoDestructorExprClass: {
3511 const auto *PDE = cast<CXXPseudoDestructorExpr>(
E);
3512 if (
const Expr *Base = PDE->getBase())
3513 mangleMemberExprBase(Base, PDE->isArrow());
3518 mangleUnresolvedPrefix(Qualifier,
3520 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
3524 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
3527 }
else if (Qualifier) {
3528 mangleUnresolvedPrefix(Qualifier);
3532 QualType DestroyedType = PDE->getDestroyedType();
3533 mangleUnresolvedTypeOrSimpleId(DestroyedType);
3537 case Expr::MemberExprClass: {
3547 case Expr::UnresolvedMemberExprClass: {
3557 case Expr::CXXDependentScopeMemberExprClass: {
3559 = cast<CXXDependentScopeMemberExpr>(
E);
3569 case Expr::UnresolvedLookupExprClass: {
3577 case Expr::CXXUnresolvedConstructExprClass: {
3583 if (N != 1) Out <<
'_';
3584 for (
unsigned I = 0; I != N; ++
I) mangleExpression(CE->
getArg(I));
3585 if (N != 1) Out <<
'E';
3589 case Expr::CXXConstructExprClass: {
3590 const auto *CE = cast<CXXConstructExpr>(
E);
3591 if (!CE->isListInitialization() || CE->isStdInitListInitialization()) {
3593 CE->getNumArgs() >= 1 &&
3594 (CE->getNumArgs() == 1 || isa<CXXDefaultArgExpr>(CE->
getArg(1))) &&
3595 "implicit CXXConstructExpr must have one argument");
3596 return mangleExpression(cast<CXXConstructExpr>(E)->getArg(0));
3599 for (
auto *E : CE->arguments())
3600 mangleExpression(E);
3605 case Expr::CXXTemporaryObjectExprClass: {
3606 const auto *CE = cast<CXXTemporaryObjectExpr>(
E);
3607 unsigned N = CE->getNumArgs();
3608 bool List = CE->isListInitialization();
3615 if (!List && N != 1)
3617 if (CE->isStdInitListInitialization()) {
3623 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
3624 mangleInitListElements(ILE);
3626 for (
auto *E : CE->arguments())
3627 mangleExpression(E);
3634 case Expr::CXXScalarValueInitExprClass:
3640 case Expr::CXXNoexceptExprClass:
3642 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
3645 case Expr::UnaryExprOrTypeTraitExprClass: {
3659 : ImplicitlyConvertedToType;
3661 mangleIntegerLiteral(T, V);
3675 "cannot yet mangle vec_step expression");
3683 "cannot yet mangle __builtin_omp_required_simd_align expression");
3697 case Expr::CXXThrowExprClass: {
3710 case Expr::CXXTypeidExprClass: {
3724 case Expr::CXXDeleteExprClass: {
3734 case Expr::UnaryOperatorClass: {
3742 case Expr::ArraySubscriptExprClass: {
3748 mangleExpression(AE->
getLHS());
3749 mangleExpression(AE->
getRHS());
3753 case Expr::CompoundAssignOperatorClass:
3754 case Expr::BinaryOperatorClass: {
3761 mangleExpression(BO->
getLHS());
3762 mangleExpression(BO->
getRHS());
3766 case Expr::ConditionalOperatorClass: {
3768 mangleOperatorName(OO_Conditional, 3);
3769 mangleExpression(CO->
getCond());
3770 mangleExpression(CO->
getLHS(), Arity);
3771 mangleExpression(CO->
getRHS(), Arity);
3775 case Expr::ImplicitCastExprClass: {
3776 ImplicitlyConvertedToType = E->
getType();
3777 E = cast<ImplicitCastExpr>(
E)->getSubExpr();
3781 case Expr::ObjCBridgedCastExprClass: {
3784 StringRef
Kind = cast<ObjCBridgedCastExpr>(
E)->getBridgeKindName();
3785 Out <<
"v1U" << Kind.size() <<
Kind;
3790 case Expr::CStyleCastExprClass:
3791 mangleCastExpression(E,
"cv");
3794 case Expr::CXXFunctionalCastExprClass: {
3795 auto *Sub = cast<ExplicitCastExpr>(
E)->getSubExpr()->IgnoreImplicit();
3797 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
3798 if (CCE->getParenOrBraceRange().isInvalid())
3799 Sub = CCE->getArg(0)->IgnoreImplicit();
3800 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
3801 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
3802 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
3805 mangleInitListElements(IL);
3808 mangleCastExpression(E,
"cv");
3813 case Expr::CXXStaticCastExprClass:
3814 mangleCastExpression(E,
"sc");
3816 case Expr::CXXDynamicCastExprClass:
3817 mangleCastExpression(E,
"dc");
3819 case Expr::CXXReinterpretCastExprClass:
3820 mangleCastExpression(E,
"rc");
3822 case Expr::CXXConstCastExprClass:
3823 mangleCastExpression(E,
"cc");
3826 case Expr::CXXOperatorCallExprClass: {
3834 for (
unsigned i = 0; i != NumArgs; ++i)
3835 mangleExpression(CE->
getArg(i));
3839 case Expr::ParenExprClass:
3840 mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
3843 case Expr::DeclRefExprClass: {
3844 const NamedDecl *D = cast<DeclRefExpr>(
E)->getDecl();
3855 mangleFunctionParam(cast<ParmVarDecl>(D));
3858 case Decl::EnumConstant: {
3864 case Decl::NonTypeTemplateParm: {
3866 mangleTemplateParameter(PD->
getIndex());
3875 case Expr::SubstNonTypeTemplateParmPackExprClass:
3880 Out <<
"_SUBSTPACK_";
3883 case Expr::FunctionParmPackExprClass: {
3886 Out <<
"v110_SUBSTPACK";
3891 case Expr::DependentScopeDeclRefExprClass: {
3899 case Expr::CXXBindTemporaryExprClass:
3900 mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
3903 case Expr::ExprWithCleanupsClass:
3904 mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
3907 case Expr::FloatingLiteralClass: {
3916 case Expr::CharacterLiteralClass:
3919 Out << cast<CharacterLiteral>(
E)->
getValue();
3924 case Expr::ObjCBoolLiteralExprClass:
3926 Out << (cast<ObjCBoolLiteralExpr>(
E)->
getValue() ?
'1' :
'0');
3930 case Expr::CXXBoolLiteralExprClass:
3932 Out << (cast<CXXBoolLiteralExpr>(
E)->
getValue() ?
'1' :
'0');
3936 case Expr::IntegerLiteralClass: {
3939 Value.setIsSigned(
true);
3944 case Expr::ImaginaryLiteralClass: {
3951 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
3953 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
3955 mangleFloat(Imag->getValue());
3960 Value.setIsSigned(
true);
3961 mangleNumber(Value);
3967 case Expr::StringLiteralClass: {
3970 assert(isa<ConstantArrayType>(E->
getType()));
3976 case Expr::GNUNullExprClass:
3980 case Expr::CXXNullPtrLiteralExprClass: {
3985 case Expr::PackExpansionExprClass:
3987 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
3990 case Expr::SizeOfPackExprClass: {
3991 auto *SPE = cast<SizeOfPackExpr>(
E);
3992 if (SPE->isPartiallySubstituted()) {
3994 for (
const auto &A : SPE->getPartialArguments())
3995 mangleTemplateArg(A);
4003 mangleTemplateParameter(TTP->getIndex());
4005 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
4006 mangleTemplateParameter(NTTP->getIndex());
4008 = dyn_cast<TemplateTemplateParmDecl>(Pack))
4009 mangleTemplateParameter(TempTP->getIndex());
4011 mangleFunctionParam(cast<ParmVarDecl>(Pack));
4015 case Expr::MaterializeTemporaryExprClass: {
4016 mangleExpression(cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr());
4020 case Expr::CXXFoldExprClass: {
4021 auto *FE = cast<CXXFoldExpr>(
E);
4022 if (FE->isLeftFold())
4023 Out << (FE->getInit() ?
"fL" :
"fl");
4025 Out << (FE->getInit() ?
"fR" :
"fr");
4027 if (FE->getOperator() == BO_PtrMemD)
4035 mangleExpression(FE->getLHS());
4037 mangleExpression(FE->getRHS());
4041 case Expr::CXXThisExprClass:
4045 case Expr::CoawaitExprClass:
4047 Out <<
"v18co_await";
4048 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4051 case Expr::DependentCoawaitExprClass:
4053 Out <<
"v18co_await";
4054 mangleExpression(cast<DependentCoawaitExpr>(E)->getOperand());
4057 case Expr::CoyieldExprClass:
4059 Out <<
"v18co_yield";
4060 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4093 void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
4100 assert(parmDepth < FunctionTypeDepth.getDepth());
4101 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
4102 if (FunctionTypeDepth.isInResultType())
4105 if (nestingDepth == 0) {
4108 Out <<
"fL" << (nestingDepth - 1) <<
'p';
4116 &&
"parameter's type is still an array type?");
4120 if (parmIndex != 0) {
4121 Out << (parmIndex - 1);
4126 void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T,
4149 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
4152 mangleName(InheritedFrom);
4155 void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
4178 unsigned NumTemplateArgs) {
4181 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4182 mangleTemplateArg(TemplateArgs[i].getArgument());
4189 for (
unsigned i = 0, e = AL.
size(); i != e; ++i)
4190 mangleTemplateArg(AL[i]);
4194 void CXXNameMangler::mangleTemplateArgs(
const TemplateArgument *TemplateArgs,
4195 unsigned NumTemplateArgs) {
4198 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4199 mangleTemplateArg(TemplateArgs[i]);
4213 llvm_unreachable(
"Cannot mangle NULL template argument");
4232 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
4234 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
4243 mangleExpression(E);
4257 if (compensateMangling) {
4259 mangleOperatorName(OO_Amp, 1);
4268 if (compensateMangling)
4284 mangleTemplateArg(
P);
4290 void CXXNameMangler::mangleTemplateParameter(
unsigned Index) {
4296 Out <<
'T' << (Index - 1) <<
'_';
4299 void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
4302 else if (SeqID > 1) {
4310 for (; SeqID != 0; SeqID /= 36) {
4311 unsigned C = SeqID % 36;
4312 *I++ = (C < 10 ?
'0' + C :
'A' + C - 10);
4315 Out.write(I.base(), I - BufferRef.rbegin());
4320 void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
4321 bool result = mangleSubstitution(tname);
4322 assert(result &&
"no existing substitution for template name");
4328 bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
4330 if (mangleStandardSubstitution(ND))
4334 return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
4344 bool CXXNameMangler::mangleSubstitution(
QualType T) {
4347 return mangleSubstitution(RT->getDecl());
4352 return mangleSubstitution(TypePtr);
4355 bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
4357 return mangleSubstitution(TD);
4360 return mangleSubstitution(
4364 bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
4365 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
4366 if (I == Substitutions.end())
4369 unsigned SeqID = I->second;
4403 if (TemplateArgs.
size() != 1)
4406 if (!
isCharType(TemplateArgs[0].getAsType()))
4412 template <std::
size_t StrLen>
4414 const char (&Str)[StrLen]) {
4419 if (TemplateArgs.
size() != 2)
4422 if (!
isCharType(TemplateArgs[0].getAsType()))
4431 bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
4433 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
4458 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
4468 if (TemplateArgs.
size() != 3)
4471 if (!
isCharType(TemplateArgs[0].getAsType()))
4508 void CXXNameMangler::addSubstitution(
QualType T) {
4511 addSubstitution(RT->getDecl());
4517 addSubstitution(TypePtr);
4520 void CXXNameMangler::addSubstitution(
TemplateName Template) {
4522 return addSubstitution(TD);
4528 void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
4529 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
4530 Substitutions[Ptr] = SeqID++;
4533 void CXXNameMangler::extendSubstitutions(CXXNameMangler* Other) {
4534 assert(Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
4535 if (Other->SeqID > SeqID) {
4536 Substitutions.swap(Other->Substitutions);
4537 SeqID = Other->SeqID;
4541 CXXNameMangler::AbiTagList
4542 CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
4544 if (DisableDerivedAbiTags)
4545 return AbiTagList();
4547 llvm::raw_null_ostream NullOutStream;
4548 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
4549 TrackReturnTypeTags.disableDerivedAbiTags();
4553 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
4554 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
4556 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
4557 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
4559 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4562 CXXNameMangler::AbiTagList
4563 CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
4565 if (DisableDerivedAbiTags)
4566 return AbiTagList();
4568 llvm::raw_null_ostream NullOutStream;
4569 CXXNameMangler TrackVariableType(*
this, NullOutStream);
4570 TrackVariableType.disableDerivedAbiTags();
4572 TrackVariableType.mangleType(VD->
getType());
4574 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4577 bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &C,
4579 llvm::raw_null_ostream NullOutStream;
4580 CXXNameMangler TrackAbiTags(C, NullOutStream,
nullptr,
true);
4581 TrackAbiTags.mangle(VD);
4582 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
4595 void ItaniumMangleContextImpl::mangleCXXName(
const NamedDecl *D,
4597 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
4598 "Invalid mangleName() call, argument is not a variable or function!");
4599 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
4600 "Invalid mangleName() call on 'structor decl!");
4603 getASTContext().getSourceManager(),
4604 "Mangling declaration");
4606 CXXNameMangler Mangler(*
this, Out, D);
4613 CXXNameMangler Mangler(*
this, Out, D, Type);
4620 CXXNameMangler Mangler(*
this, Out, D, Type);
4626 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
4632 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
4636 void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
4646 assert(!isa<CXXDestructorDecl>(MD) &&
4647 "Use mangleCXXDtor for destructor decls!");
4648 CXXNameMangler Mangler(*
this, Out);
4649 Mangler.getStream() <<
"_ZT";
4651 Mangler.getStream() <<
'c';
4662 Mangler.mangleFunctionEncoding(MD);
4665 void ItaniumMangleContextImpl::mangleCXXDtorThunk(
4670 CXXNameMangler Mangler(*
this, Out, DD, Type);
4671 Mangler.getStream() <<
"_ZT";
4674 Mangler.mangleCallOffset(ThisAdjustment.
NonVirtual,
4677 Mangler.mangleFunctionEncoding(DD);
4681 void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
4685 CXXNameMangler Mangler(*
this, Out);
4688 Mangler.getStream() <<
"_ZGV";
4689 Mangler.mangleName(D);
4692 void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
4697 Out <<
"__cxx_global_var_init";
4700 void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
4703 CXXNameMangler Mangler(*
this, Out);
4704 Mangler.getStream() <<
"__dtor_";
4705 if (shouldMangleDeclName(D))
4708 Mangler.getStream() << D->
getName();
4711 void ItaniumMangleContextImpl::mangleSEHFilterExpression(
4712 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4713 CXXNameMangler Mangler(*
this, Out);
4714 Mangler.getStream() <<
"__filt_";
4715 if (shouldMangleDeclName(EnclosingDecl))
4716 Mangler.mangle(EnclosingDecl);
4718 Mangler.getStream() << EnclosingDecl->
getName();
4721 void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
4722 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4723 CXXNameMangler Mangler(*
this, Out);
4724 Mangler.getStream() <<
"__fin_";
4725 if (shouldMangleDeclName(EnclosingDecl))
4726 Mangler.mangle(EnclosingDecl);
4728 Mangler.getStream() << EnclosingDecl->
getName();
4731 void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
4734 CXXNameMangler Mangler(*
this, Out);
4735 Mangler.getStream() <<
"_ZTH";
4736 Mangler.mangleName(D);
4740 ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
4743 CXXNameMangler Mangler(*
this, Out);
4744 Mangler.getStream() <<
"_ZTW";
4745 Mangler.mangleName(D);
4748 void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
4749 unsigned ManglingNumber,
4753 CXXNameMangler Mangler(*
this, Out);
4754 Mangler.getStream() <<
"_ZGR";
4755 Mangler.mangleName(D);
4756 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
4757 Mangler.mangleSeqID(ManglingNumber - 1);
4760 void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
4763 CXXNameMangler Mangler(*
this, Out);
4764 Mangler.getStream() <<
"_ZTV";
4765 Mangler.mangleNameOrStandardSubstitution(RD);
4768 void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
4771 CXXNameMangler Mangler(*
this, Out);
4772 Mangler.getStream() <<
"_ZTT";
4773 Mangler.mangleNameOrStandardSubstitution(RD);
4776 void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
4781 CXXNameMangler Mangler(*
this, Out);
4782 Mangler.getStream() <<
"_ZTC";
4783 Mangler.mangleNameOrStandardSubstitution(RD);
4784 Mangler.getStream() <<
Offset;
4785 Mangler.getStream() <<
'_';
4786 Mangler.mangleNameOrStandardSubstitution(Type);
4789 void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
4791 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
4792 CXXNameMangler Mangler(*
this, Out);
4793 Mangler.getStream() <<
"_ZTI";
4794 Mangler.mangleType(Ty);
4797 void ItaniumMangleContextImpl::mangleCXXRTTIName(
QualType Ty,
4800 CXXNameMangler Mangler(*
this, Out);
4801 Mangler.getStream() <<
"_ZTS";
4802 Mangler.mangleType(Ty);
4805 void ItaniumMangleContextImpl::mangleTypeName(
QualType Ty, raw_ostream &Out) {
4806 mangleCXXRTTIName(Ty, Out);
4809 void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
4810 llvm_unreachable(
"Can't mangle string literals");
4815 return new ItaniumMangleContextImpl(Context, Diags);
unsigned getNumElements() const
A call to an overloaded operator written using operator syntax.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Defines the clang::ASTContext interface.
unsigned getNumInits() const
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Expr * getSizeExpr() const
StmtClass getStmtClass() const
const Type * Ty
The locally-unqualified type.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
unsigned arg_size() const
Retrieve the number of arguments.
static Qualifiers fromCVRUMask(unsigned CVRU)
ExtParameterInfo getExtParameterInfo(unsigned I) const
The "enum" keyword introduces the elaborated-type-specifier.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
PointerType - C99 6.7.5.1 - Pointer Declarators.
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
TemplateName getReplacement() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool isConsumed() const
Is this parameter considered "consumed" by Objective-C ARC? Consumed parameters must have retainable ...
__auto_type (GNU extension)
The COMDAT used for ctors.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool isArgumentType() const
unsigned getNumArgs() const
Retrieve the number of template arguments.
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
bool isGlobalDelete() const
Defines the SourceManager interface.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Decl - This represents one declaration (or definition), e.g.
static bool isStreamCharSpecialization(const ClassTemplateSpecializationDecl *SD, const char(&Str)[StrLen])
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Defines the C++ template declaration subclasses.
Represents a C++11 auto or C++14 decltype(auto) type.
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
bool hasLinkage() const
Determine whether this declaration has linkage.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
unsigned getLength() const
Efficiently return the length of this identifier info.
std::unique_ptr< llvm::MemoryBuffer > Buffer
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
InitListExpr * getSyntacticForm() const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Represents a call to a C++ constructor.
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...
bool isDecltypeAuto() const
bool isBooleanType() const
A container of type source information.
unsigned getIndex() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Represents a C++ constructor within a class.
unsigned getNumTemplateArgs() const
A template template parameter that has been substituted for some other template name.
Default closure variant of a ctor.
const llvm::APInt & getSize() const
void * getAsOpaquePtr() const
An identifier, stored as an IdentifierInfo*.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
void removeObjCLifetime()
unsigned getBlockManglingNumber() const
const Expr * getCallee() const
ObjCLifetime getObjCLifetime() const
Represents an empty template argument, e.g., one that has not been deduced.
AutoTypeKeyword getKeyword() const
Represents a C++17 deduced template specialization type.
A this pointer adjustment.
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
A namespace, stored as a NamespaceDecl*.
UnaryExprOrTypeTrait getKind() const
A C++ throw-expression (C++ [except.throw]).
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
unsigned getNumArgs() const
Retrieve the number of template arguments.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
The collection of all-type qualifiers we support.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
bool isOpenCLSpecificType() const
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
QualType getElementType() const
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
ParameterABI getABI() const
Return the ABI treatment of this parameter.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty)
Represents a class type in Objective C.
Expr * getSizeExpr() const
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a dependent template name that cannot be resolved prior to template instantiation.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isReferenceType() const
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool isTranslationUnit() const
unsigned getCVRQualifiers() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Represents the result of substituting a set of types for a template type parameter pack...
TypeSourceInfo * getLambdaTypeInfo() const
Expr * getArg(unsigned I)
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
Expr * getUnderlyingExpr() const
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
An rvalue reference type, per C++11 [dcl.ref].
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
A qualified template name, where the qualification is kept to describe the source code as written...
An lvalue ref-qualifier was provided (&).
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags)
QualType getBaseType() const
Gets the base type of this object type.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
QualType getReturnType() const
The "struct" keyword introduces the elaborated-type-specifier.
UnresolvedUsingTypenameDecl * getDecl() const
Expr * getInitializer()
The initializer of this new-expression.
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
Expr * getExprOperand() const
static bool isStdNamespace(const DeclContext *DC)
Concrete class used by the front-end to report problems and issues.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
Represents a typeof (or typeof) expression (a GCC extension).
Expr * getNoexceptExpr() const
A builtin binary operation expression such as "x + y" or "x <= y".
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
RecordDecl * getDecl() const
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
Enums/classes describing ABI related information about constructors, destructors and thunks...
TypeClass getTypeClass() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
Represents a C++ member access expression where the actual member referenced could not be resolved be...
detail::InMemoryDirectory::const_iterator I
is ARM Neon polynomial vector
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
arg_iterator placement_arg_end()
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
bool addressSpaceMapManglingFor(unsigned AS) const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
QualType getInjectedSpecializationType() const
ConditionalOperator - The ?: ternary operator.
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
Const iterator for iterating over Stmt * arrays that contain only Expr *.
ExtInfo getExtInfo() const
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
A dependent template name that has not been resolved to a template (or set of templates).
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
union clang::ReturnAdjustment::VirtualAdjustment Virtual
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
bool hasUnaligned() const
Represents an array type in C++ whose size is a value-dependent expression.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
CXXDtorType
C++ destructor types.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
QualType getPointeeType() const
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
static const DeclContext * IgnoreLinkageSpecDecls(const DeclContext *DC)
StringRef getName() const
Return the actual identifier string.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Declaration of a template type parameter.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Represents a C++ destructor within a class.
New-expression has a C++11 list-initializer.
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
ArgKind getKind() const
Return the kind of stored template argument.
const ParmVarDecl * getParamDecl(unsigned i) const
DeclContext * getDeclContext()
A structure for storing the information associated with a substituted template template parameter...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
static SVal getValue(SVal val, SValBuilder &svalBuilder)
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
QualType getAllocatedType() const
Expr * getSubExpr() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFunctionOrMethod() const
Qualifiers Quals
The local qualifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
bool isExternallyVisible() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
struct clang::ThisAdjustment::VirtualAdjustment::@118 Itanium
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
QualType getElementType() const
A type, stored as a Type*.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
The COMDAT used for dtors.
static StringRef getIdentifier(const Token &Tok)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
TypedefNameDecl * getTypedefNameForAnonDecl() const
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
decls_iterator decls_begin() const
unsigned getNumTemplateArgs() const
static bool hasMangledSubstitutionQualifiers(QualType T)
Determine whether the given type has any qualifiers that are relevant for substitutions.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const IdentifierInfo * getIdentifier() const
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
A template template parameter pack that has been substituted for a template template argument pack...
There is no lifetime qualification on this type.
is AltiVec 'vector Pixel'
Assigning into this object requires the old value to be released and the new value to be retained...
Encodes a location in the source.
TemplateArgumentLoc const * getTemplateArgs() const
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
QualType getElementType() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
bool isBuiltinType() const
Helper methods to distinguish type categories.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
TagDecl - Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
VectorKind getVectorKind() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Represents a static or instance method of a struct/union/class.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
This file defines OpenMP nodes for declarative directives.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
bool isNothrow(const ASTContext &Ctx, bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
bool hasInitializer() const
Whether this new-expression has any initializer at all.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
is AltiVec 'vector bool ...'
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
const T * castAs() const
Member-template castAs<specific type>.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset. ...
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
QualType getType() const
Return the type wrapped by this type source info.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
CXXCtorType
C++ constructor types.
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
QualType getPointeeType() const
A qualified reference to a name whose declaration cannot yet be resolved.
Represents a pack expansion of types.
Decl * getBlockManglingContextDecl() const
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
Expr * getSizeExpr() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Base class for declarations which introduce a typedef-name.
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
Represents a template name that was expressed as a qualified name.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
const Expr * getSubExpr() const
ThisAdjustment This
The this pointer adjustment.
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
TemplateArgumentLoc const * getTemplateArgs() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
bool getProducesResult() const
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
const llvm::APSInt & getInitVal() const
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
DeclarationName - The name of a declaration.
The "union" keyword introduces the elaborated-type-specifier.
CallingConv getCC() const
The "class" keyword introduces the elaborated-type-specifier.
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
bool isTypeOperand() const
unsigned getFunctionScopeDepth() const
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
ExplicitCastExpr - An explicit cast written in the source code.
A type that was preceded by the 'template' keyword, stored as a Type*.
bool isLambda() const
Determine whether this class describes a lambda function object.
union clang::ThisAdjustment::VirtualAdjustment Virtual
llvm::APFloat getValue() const
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Represents a pointer to an Objective C object.
Not an overloaded operator.
const TemplateArgument * getArgs() const
Retrieve the template arguments.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
const T * getAs() const
Member-template getAs<specific type>'.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
unsigned getTypeQuals() const
QualType getCanonicalType() const
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
struct clang::ReturnAdjustment::VirtualAdjustment::@116 Itanium
QualType getIntegralType() const
Retrieve the type of the integral value.
ExtVectorType - Extended vector type.
const TemplateArgument * getArgs() const
Retrieve the template arguments.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
ReturnAdjustment Return
The return adjustment.
Expr * getExprOperand() const
llvm::StringRef getParameterABISpelling(ParameterABI kind)
unsigned getAddressSpace() const
const Expr * getSubExpr() const
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
NestedNameSpecifier * getQualifier() const
The template argument is actually a parameter pack.
arg_iterator placement_arg_begin()
QualType getPointeeType() const
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
const Type * getClass() const
Reading or writing from this object requires a barrier call.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool hasAddressSpace() const
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++ struct/union/class.
Represents a template specialization type whose template cannot be resolved, e.g. ...
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
ElaboratedTypeKeyword getKeyword() const
A structure for storing the information associated with an overloaded template name.
Declaration of a class template.
This class is used for builtin types like 'int'.
static bool isCharSpecialization(QualType T, const char *Name)
Returns whether a given type is a template specialization of a given name with a single argument of t...
static bool isCharType(QualType T)
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
QualType getParamTypeForDecl() const
Copying closure variant of a ctor.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
DeclarationName getName() const
Gets the name looked up.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
static Qualifiers fromCVRMask(unsigned CVR)
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
TagDecl * getDecl() const
static Decl::Kind getKind(const Decl *D)
unsigned getTargetAddressSpace(QualType T) const
A reference to a declared variable, function, enum, etc.
Represents a type template specialization; the template must be a class template, a type alias templa...
QualType getElementType() const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
const Expr * getInit(unsigned Init) const
A set of overloaded template declarations.
NamedDecl - This represents a decl with a name.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Represents a C array with a specified size that is not an integer-constant-expression.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
No keyword precedes the qualified type name.
static bool isStd(const NamespaceDecl *NS)
Return whether a given namespace is the 'std' namespace.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isTypeOperand() const
const char * getStmtClassName() const
The global specifier '::'. There is no stored value.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
The "__interface" keyword introduces the elaborated-type-specifier.
ArrayRef< QualType > exceptions() const
Represents the canonical version of C arrays with a specified constant size.
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
Attr - This represents one attribute.
A single template declaration.
This parameter (which must have pointer type) is a Swift indirect result parameter.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType getArgumentType() const