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;
132 explicit ItaniumMangleContextImpl(
ASTContext &Context,
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 llvm::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 llvm::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;
384 llvm::DenseMap<StringRef, unsigned> ModuleSubstitutions;
386 ASTContext &getASTContext()
const {
return Context.getASTContext(); }
389 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
390 const NamedDecl *D =
nullptr,
bool NullOut_ =
false)
391 : Context(C), Out(Out_), NullOut(NullOut_), Structor(getStructor(D)),
394 assert(!D || (!isa<CXXDestructorDecl>(D) &&
395 !isa<CXXConstructorDecl>(D)));
397 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
399 : Context(C), Out(Out_), Structor(getStructor(D)),
StructorType(Type),
400 SeqID(0), AbiTagsRoot(AbiTags) { }
401 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
403 : Context(C), Out(Out_), Structor(getStructor(D)),
StructorType(Type),
404 SeqID(0), AbiTagsRoot(AbiTags) { }
406 CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
407 : Context(Outer.Context), Out(Out_), NullOut(
false),
408 Structor(Outer.Structor),
StructorType(Outer.StructorType),
409 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
410 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
412 CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
413 : Context(Outer.Context), Out(Out_), NullOut(
true),
414 Structor(Outer.Structor),
StructorType(Outer.StructorType),
415 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
416 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
420 if (Out.str()[0] ==
'\01')
424 char *result = abi::__cxa_demangle(Out.str().str().c_str(), 0, 0, &status);
425 assert(status == 0 &&
"Could not demangle mangled name!");
429 raw_ostream &getStream() {
return Out; }
431 void disableDerivedAbiTags() { DisableDerivedAbiTags =
true; }
432 static bool shouldHaveAbiTags(ItaniumMangleContextImpl &C,
const VarDecl *VD);
435 void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
436 void mangleNumber(
const llvm::APSInt &I);
437 void mangleNumber(int64_t Number);
438 void mangleFloat(
const llvm::APFloat &F);
440 void mangleSeqID(
unsigned SeqID);
443 void mangleNameOrStandardSubstitution(
const NamedDecl *ND);
447 bool mangleSubstitution(
const NamedDecl *ND);
448 bool mangleSubstitution(
QualType T);
454 bool mangleStandardSubstitution(
const NamedDecl *ND);
456 void addSubstitution(
const NamedDecl *ND) {
459 addSubstitution(reinterpret_cast<uintptr_t>(ND));
465 void extendSubstitutions(CXXNameMangler* Other);
468 bool recursive =
false);
472 unsigned NumTemplateArgs,
473 unsigned KnownArity = UnknownArity);
475 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
477 void mangleNameWithAbiTags(
const NamedDecl *ND,
478 const AbiTagList *AdditionalAbiTags);
479 void mangleModuleName(
const Module *M);
480 void mangleModuleNamePrefix(StringRef Name);
483 unsigned NumTemplateArgs);
484 void mangleUnqualifiedName(
const NamedDecl *ND,
485 const AbiTagList *AdditionalAbiTags) {
486 mangleUnqualifiedName(ND, ND->
getDeclName(), UnknownArity,
491 const AbiTagList *AdditionalAbiTags);
492 void mangleUnscopedName(
const NamedDecl *ND,
493 const AbiTagList *AdditionalAbiTags);
495 const AbiTagList *AdditionalAbiTags);
497 const AbiTagList *AdditionalAbiTags);
500 void mangleSourceNameWithAbiTags(
501 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
502 void mangleLocalName(
const Decl *D,
503 const AbiTagList *AdditionalAbiTags);
504 void mangleBlockForPrefix(
const BlockDecl *Block);
505 void mangleUnqualifiedBlock(
const BlockDecl *Block);
508 const AbiTagList *AdditionalAbiTags,
509 bool NoFunction=
false);
512 unsigned NumTemplateArgs);
514 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
516 void mangleTemplatePrefix(
const TemplateDecl *ND,
bool NoFunction=
false);
518 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
519 StringRef Prefix =
"");
522 void mangleVendorQualifier(StringRef qualifier);
529 #define ABSTRACT_TYPE(CLASS, PARENT) 530 #define NON_CANONICAL_TYPE(CLASS, PARENT) 531 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T); 532 #include "clang/AST/TypeNodes.def" 534 void mangleType(
const TagType*);
536 static StringRef getCallingConvQualifierName(
CallingConv CC);
541 void mangleNeonVectorType(
const VectorType *T);
543 void mangleAArch64NeonVectorType(
const VectorType *T);
546 void mangleIntegerLiteral(
QualType T,
const llvm::APSInt &
Value);
547 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
548 void mangleMemberExpr(
const Expr *base,
bool isArrow,
553 unsigned NumTemplateArgs,
554 unsigned knownArity);
555 void mangleCastExpression(
const Expr *E, StringRef CastEncoding);
556 void mangleInitListElements(
const InitListExpr *InitList);
557 void mangleExpression(
const Expr *E,
unsigned Arity = UnknownArity);
562 unsigned NumTemplateArgs);
564 unsigned NumTemplateArgs);
568 void mangleTemplateParameter(
unsigned Index);
573 const AbiTagList *AdditionalAbiTags);
576 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
578 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
583 bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
588 if (FD->
hasAttr<OverloadableAttr>())
618 if (!getASTContext().getLangOpts().CPlusPlus)
622 if (VD && !isa<DecompositionDecl>(D)) {
628 const DeclContext *DC = getEffectiveDeclContext(D);
632 DC = getEffectiveParentContext(DC);
634 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
635 !isa<VarTemplateSpecializationDecl>(D))
642 void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
643 const AbiTagList *AdditionalAbiTags) {
644 assert(AbiTags &&
"require AbiTagState");
645 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
648 void CXXNameMangler::mangleSourceNameWithAbiTags(
649 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
651 writeAbiTags(ND, AdditionalAbiTags);
654 void CXXNameMangler::mangle(
const NamedDecl *D) {
660 mangleFunctionEncoding(FD);
661 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
664 mangleName(IFD->getAnonField());
666 mangleName(cast<FieldDecl>(D));
669 void CXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD) {
673 if (!Context.shouldMangleDeclName(FD)) {
678 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
679 if (ReturnTypeAbiTags.empty()) {
682 mangleFunctionEncodingBareType(FD);
690 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
691 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
693 FunctionEncodingMangler.disableDerivedAbiTags();
694 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
697 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
698 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
702 const AbiTagList &UsedAbiTags =
703 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
704 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
705 AdditionalAbiTags.erase(
706 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
707 UsedAbiTags.begin(), UsedAbiTags.end(),
708 AdditionalAbiTags.begin()),
709 AdditionalAbiTags.end());
712 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
713 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
717 extendSubstitutions(&FunctionEncodingMangler);
720 void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
721 if (FD->
hasAttr<EnableIfAttr>()) {
722 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
723 Out <<
"Ua9enable_ifI";
726 for (AttrVec::const_reverse_iterator I = FD->
getAttrs().rbegin(),
729 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
733 mangleExpression(EIA->getCond());
737 FunctionTypeDepth.pop(Saved);
742 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
743 if (
auto Inherited = CD->getInheritedConstructor())
744 FD = Inherited.getConstructor();
762 bool MangleReturnType =
false;
764 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
765 isa<CXXConversionDecl>(FD)))
766 MangleReturnType =
true;
769 FD = PrimaryTemplate->getTemplatedDecl();
773 MangleReturnType, FD);
777 while (isa<LinkageSpecDecl>(DC)) {
778 DC = getEffectiveParentContext(DC);
787 ->isTranslationUnit())
791 return II && II->
isStr(
"std");
800 return isStd(cast<NamespaceDecl>(DC));
806 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
815 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
816 TemplateArgs = &Spec->getTemplateArgs();
817 return Spec->getSpecializedTemplate();
822 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
823 TemplateArgs = &Spec->getTemplateArgs();
824 return Spec->getSpecializedTemplate();
830 void CXXNameMangler::mangleName(
const NamedDecl *ND) {
831 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
833 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
834 if (VariableTypeAbiTags.empty()) {
836 mangleNameWithAbiTags(VD,
nullptr);
841 llvm::raw_null_ostream NullOutStream;
842 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
843 VariableNameMangler.disableDerivedAbiTags();
844 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
847 const AbiTagList &UsedAbiTags =
848 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
849 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
850 AdditionalAbiTags.erase(
851 std::set_difference(VariableTypeAbiTags.begin(),
852 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
853 UsedAbiTags.end(), AdditionalAbiTags.begin()),
854 AdditionalAbiTags.end());
857 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
859 mangleNameWithAbiTags(ND,
nullptr);
863 void CXXNameMangler::mangleNameWithAbiTags(
const NamedDecl *ND,
864 const AbiTagList *AdditionalAbiTags) {
870 const DeclContext *DC = getEffectiveDeclContext(ND);
876 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
878 DC = getEffectiveParentContext(DC);
879 else if (GetLocalClassDecl(ND)) {
880 mangleLocalName(ND, AdditionalAbiTags);
886 if (isLocalContainerContext(DC)) {
887 mangleLocalName(ND, AdditionalAbiTags);
903 mangleUnscopedTemplateName(TD, AdditionalAbiTags);
904 mangleTemplateArgs(*TemplateArgs);
908 mangleUnscopedName(ND, AdditionalAbiTags);
912 mangleNestedName(ND, DC, AdditionalAbiTags);
915 void CXXNameMangler::mangleModuleName(
const Module *M) {
922 mangleModuleNamePrefix(M->
Name);
926 void CXXNameMangler::mangleModuleNamePrefix(StringRef Name) {
929 auto It = ModuleSubstitutions.find(Name);
930 if (It != ModuleSubstitutions.end()) {
932 Out << '_' << static_cast<char>(
'0' + It->second);
934 Out <<
'W' << (It->second - 10) <<
'_';
940 auto Parts = Name.rsplit(
'.');
941 if (Parts.second.empty())
942 Parts.second = Parts.first;
944 mangleModuleNamePrefix(Parts.first);
946 Out << Parts.second.size() << Parts.second;
947 ModuleSubstitutions.insert({Name, ModuleSubstitutions.size()});
950 void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
952 unsigned NumTemplateArgs) {
956 mangleUnscopedTemplateName(TD,
nullptr);
957 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
959 mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
963 void CXXNameMangler::mangleUnscopedName(
const NamedDecl *ND,
964 const AbiTagList *AdditionalAbiTags) {
971 mangleUnqualifiedName(ND, AdditionalAbiTags);
974 void CXXNameMangler::mangleUnscopedTemplateName(
975 const TemplateDecl *ND,
const AbiTagList *AdditionalAbiTags) {
978 if (mangleSubstitution(ND))
982 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
983 assert(!AdditionalAbiTags &&
984 "template template param cannot have abi tags");
985 mangleTemplateParameter(TTP->getIndex());
986 }
else if (isa<BuiltinTemplateDecl>(ND)) {
987 mangleUnscopedName(ND, AdditionalAbiTags);
995 void CXXNameMangler::mangleUnscopedTemplateName(
996 TemplateName Template,
const AbiTagList *AdditionalAbiTags) {
1000 return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
1002 if (mangleSubstitution(Template))
1005 assert(!AdditionalAbiTags &&
1006 "dependent template name cannot have abi tags");
1009 assert(Dependent &&
"Not a dependent template name?");
1011 mangleSourceName(
Id);
1013 mangleOperatorName(Dependent->
getOperator(), UnknownArity);
1015 addSubstitution(Template);
1018 void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
1032 llvm::APInt valueBits = f.bitcastToAPInt();
1033 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
1034 assert(numCharacters != 0);
1040 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
1042 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
1045 uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
1046 hexDigit >>= (digitBitIndex % 64);
1050 static const char charForHex[16] = {
1051 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
1052 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' 1054 buffer[stringIndex] = charForHex[hexDigit];
1057 Out.write(buffer.data(), numCharacters);
1060 void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
1061 if (Value.isSigned() && Value.isNegative()) {
1063 Value.abs().print(Out,
false);
1065 Value.print(Out,
false);
1069 void CXXNameMangler::mangleNumber(int64_t Number) {
1079 void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) {
1087 mangleNumber(NonVirtual);
1093 mangleNumber(NonVirtual);
1095 mangleNumber(Virtual);
1101 if (!mangleSubstitution(
QualType(TST, 0))) {
1102 mangleTemplatePrefix(TST->getTemplateName());
1107 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
1110 }
else if (
const auto *DTST =
1112 if (!mangleSubstitution(
QualType(DTST, 0))) {
1113 TemplateName Template = getASTContext().getDependentTemplateName(
1114 DTST->getQualifier(), DTST->getIdentifier());
1115 mangleTemplatePrefix(Template);
1120 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1121 addSubstitution(
QualType(DTST, 0));
1151 switch (qualifier->
getKind()) {
1163 llvm_unreachable(
"Can't mangle __super specifier");
1167 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1175 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1192 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1199 if (mangleUnresolvedTypeOrSimpleId(
QualType(type, 0), recursive ?
"N" :
""))
1208 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1226 void CXXNameMangler::mangleUnresolvedName(
1229 unsigned knownArity) {
1230 if (qualifier) mangleUnresolvedPrefix(qualifier);
1246 mangleOperatorName(name, knownArity);
1249 llvm_unreachable(
"Can't mangle a constructor name!");
1251 llvm_unreachable(
"Can't mangle a using directive name!");
1253 llvm_unreachable(
"Can't mangle a deduction guide name!");
1257 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1263 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1266 void CXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
1268 unsigned KnownArity,
1269 const AbiTagList *AdditionalAbiTags) {
1270 unsigned Arity = KnownArity;
1279 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1288 for (
auto *BD : DD->bindings())
1289 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1291 writeAbiTags(ND, AdditionalAbiTags);
1311 getEffectiveDeclContext(ND)->isFileContext() &&
1316 bool IsRegCall = FD &&
1320 mangleRegCallName(II);
1322 mangleSourceName(II);
1324 writeAbiTags(ND, AdditionalAbiTags);
1329 assert(ND &&
"mangling empty name without declaration");
1331 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1332 if (NS->isAnonymousNamespace()) {
1334 Out <<
"12_GLOBAL__N_1";
1339 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1353 &&
"Expected anonymous struct or union!");
1360 assert(FD->getIdentifier() &&
"Data member name isn't an identifier!");
1362 mangleSourceName(FD->getIdentifier());
1373 if (isa<ObjCContainerDecl>(ND))
1377 const TagDecl *TD = cast<TagDecl>(ND);
1380 "Typedef should not be in another decl context!");
1382 "Typedef was not named!");
1384 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1387 writeAbiTags(TD,
nullptr);
1395 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
1396 if (Record->isLambda() && Record->getLambdaManglingNumber()) {
1397 assert(!AdditionalAbiTags &&
1398 "Lambda type cannot have additional abi tags");
1399 mangleLambda(Record);
1405 unsigned UnnamedMangle = getASTContext().getManglingNumber(TD);
1407 if (UnnamedMangle > 1)
1408 Out << UnnamedMangle - 2;
1410 writeAbiTags(TD, AdditionalAbiTags);
1416 unsigned AnonStructId = NullOut ? 0 : Context.getAnonymousStructId(TD);
1423 Str += llvm::utostr(AnonStructId);
1433 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1438 if (
auto Inherited =
1439 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1440 InheritedFrom = Inherited.getConstructor()->
getParent();
1441 InheritedTemplateArgs =
1442 Inherited.getConstructor()->getTemplateSpecializationArgs();
1448 mangleCXXCtorType(static_cast<CXXCtorType>(
StructorType), InheritedFrom);
1456 if (InheritedTemplateArgs)
1457 mangleTemplateArgs(*InheritedTemplateArgs);
1459 writeAbiTags(ND, AdditionalAbiTags);
1467 mangleCXXDtorType(static_cast<CXXDtorType>(
StructorType));
1472 writeAbiTags(ND, AdditionalAbiTags);
1476 if (ND && Arity == UnknownArity) {
1477 Arity = cast<FunctionDecl>(ND)->getNumParams();
1480 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1481 if (!MD->isStatic())
1487 mangleOperatorName(Name, Arity);
1488 writeAbiTags(ND, AdditionalAbiTags);
1492 llvm_unreachable(
"Can't mangle a deduction guide name!");
1495 llvm_unreachable(
"Can't mangle a using directive name!");
1499 void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1503 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__" 1507 void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1514 void CXXNameMangler::mangleNestedName(
const NamedDecl *ND,
1516 const AbiTagList *AdditionalAbiTags,
1524 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1530 mangleQualifiers(MethodQuals);
1531 mangleRefQualifier(Method->getRefQualifier());
1537 mangleTemplatePrefix(TD, NoFunction);
1538 mangleTemplateArgs(*TemplateArgs);
1541 manglePrefix(DC, NoFunction);
1542 mangleUnqualifiedName(ND, AdditionalAbiTags);
1547 void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1549 unsigned NumTemplateArgs) {
1554 mangleTemplatePrefix(TD);
1555 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1560 void CXXNameMangler::mangleLocalName(
const Decl *D,
1561 const AbiTagList *AdditionalAbiTags) {
1567 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1569 const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
1574 AbiTagState LocalAbiTags(AbiTags);
1577 mangleObjCMethodName(MD);
1578 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1579 mangleBlockForPrefix(BD);
1581 mangleFunctionEncoding(cast<FunctionDecl>(DC));
1585 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1604 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1606 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1608 mangleNumber(Num - 2);
1617 mangleUnqualifiedName(RD, AdditionalAbiTags);
1618 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1619 manglePrefix(getEffectiveDeclContext(BD),
true );
1620 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1621 mangleUnqualifiedBlock(BD);
1623 const NamedDecl *ND = cast<NamedDecl>(D);
1624 mangleNestedName(ND, getEffectiveDeclContext(ND), AdditionalAbiTags,
1627 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1631 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1633 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1635 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1637 mangleNumber(Num - 2);
1642 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1643 mangleUnqualifiedBlock(BD);
1645 mangleUnqualifiedName(cast<NamedDecl>(D), AdditionalAbiTags);
1648 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1650 if (Context.getNextDiscriminator(ND, disc)) {
1654 Out <<
"__" << disc <<
'_';
1659 void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *Block) {
1660 if (GetLocalClassDecl(Block)) {
1661 mangleLocalName(Block,
nullptr);
1664 const DeclContext *DC = getEffectiveDeclContext(Block);
1665 if (isLocalContainerContext(DC)) {
1666 mangleLocalName(Block,
nullptr);
1669 manglePrefix(getEffectiveDeclContext(Block));
1670 mangleUnqualifiedBlock(Block);
1673 void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *Block) {
1675 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1676 Context->getDeclContext()->isRecord()) {
1677 const auto *ND = cast<NamedDecl>(Context);
1679 mangleSourceNameWithAbiTags(ND);
1690 Number = Context.getBlockId(Block,
false);
1701 void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
1712 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1713 !isa<ParmVarDecl>(Context)) {
1717 = cast<NamedDecl>(Context)->getIdentifier()) {
1718 mangleSourceName(Name);
1720 if (
isTemplate(cast<NamedDecl>(Context), TemplateArgs))
1721 mangleTemplateArgs(*TemplateArgs);
1729 getAs<FunctionProtoType>();
1730 mangleBareFunctionType(Proto,
false,
1740 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
1742 mangleNumber(Number - 2);
1747 switch (qualifier->
getKind()) {
1753 llvm_unreachable(
"Can't mangle __super specifier");
1778 llvm_unreachable(
"unexpected nested name specifier");
1781 void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
1793 if (NoFunction && isLocalContainerContext(DC))
1796 assert(!isLocalContainerContext(DC));
1798 const NamedDecl *ND = cast<NamedDecl>(DC);
1799 if (mangleSubstitution(ND))
1805 mangleTemplatePrefix(TD);
1806 mangleTemplateArgs(*TemplateArgs);
1808 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1809 mangleUnqualifiedName(ND,
nullptr);
1812 addSubstitution(ND);
1815 void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
1820 return mangleTemplatePrefix(TD);
1823 manglePrefix(Qualified->getQualifier());
1827 mangleUnqualifiedName(
nullptr, (*Overloaded->begin())->getDeclName(),
1828 UnknownArity,
nullptr);
1833 assert(Dependent &&
"Unknown template name kind?");
1835 manglePrefix(Qualifier);
1836 mangleUnscopedTemplateName(Template,
nullptr);
1839 void CXXNameMangler::mangleTemplatePrefix(
const TemplateDecl *ND,
1847 if (mangleSubstitution(ND))
1851 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1852 mangleTemplateParameter(TTP->getIndex());
1854 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1855 if (isa<BuiltinTemplateDecl>(ND))
1856 mangleUnqualifiedName(ND,
nullptr);
1861 addSubstitution(ND);
1870 if (mangleSubstitution(TN))
1885 if (isa<TemplateTemplateParmDecl>(TD))
1886 mangleTemplateParameter(cast<TemplateTemplateParmDecl>(TD)->getIndex());
1892 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
1921 Out <<
"_SUBSTPACK_";
1926 addSubstitution(TN);
1929 bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
1935 case Type::Adjusted:
1938 case Type::BlockPointer:
1939 case Type::LValueReference:
1940 case Type::RValueReference:
1941 case Type::MemberPointer:
1942 case Type::ConstantArray:
1943 case Type::IncompleteArray:
1944 case Type::VariableArray:
1945 case Type::DependentSizedArray:
1946 case Type::DependentAddressSpace:
1947 case Type::DependentVector:
1948 case Type::DependentSizedExtVector:
1950 case Type::ExtVector:
1951 case Type::FunctionProto:
1952 case Type::FunctionNoProto:
1954 case Type::Attributed:
1956 case Type::DeducedTemplateSpecialization:
1957 case Type::PackExpansion:
1958 case Type::ObjCObject:
1959 case Type::ObjCInterface:
1960 case Type::ObjCObjectPointer:
1961 case Type::ObjCTypeParam:
1964 llvm_unreachable(
"type is illegal as a nested name specifier");
1966 case Type::SubstTemplateTypeParmPack:
1971 Out <<
"_SUBSTPACK_";
1978 case Type::TypeOfExpr:
1980 case Type::Decltype:
1981 case Type::TemplateTypeParm:
1982 case Type::UnaryTransform:
1983 case Type::SubstTemplateTypeParm:
1997 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
2000 case Type::UnresolvedUsing:
2001 mangleSourceNameWithAbiTags(
2002 cast<UnresolvedUsingType>(Ty)->getDecl());
2007 mangleSourceNameWithAbiTags(cast<TagType>(Ty)->getDecl());
2010 case Type::TemplateSpecialization: {
2012 cast<TemplateSpecializationType>(Ty);
2014 switch (TN.getKind()) {
2021 assert(TD &&
"no template for template specialization type");
2022 if (isa<TemplateTemplateParmDecl>(TD))
2023 goto unresolvedType;
2025 mangleSourceNameWithAbiTags(TD);
2031 llvm_unreachable(
"invalid base for a template specialization type");
2045 Out <<
"_SUBSTPACK_";
2054 case Type::InjectedClassName:
2055 mangleSourceNameWithAbiTags(
2056 cast<InjectedClassNameType>(Ty)->getDecl());
2059 case Type::DependentName:
2060 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
2063 case Type::DependentTemplateSpecialization: {
2065 cast<DependentTemplateSpecializationType>(Ty);
2071 case Type::Elaborated:
2072 return mangleUnresolvedTypeOrSimpleId(
2073 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
2079 void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
2089 llvm_unreachable(
"Not an operator name");
2112 case OO_New: Out <<
"nw";
break;
2114 case OO_Array_New: Out <<
"na";
break;
2116 case OO_Delete: Out <<
"dl";
break;
2118 case OO_Array_Delete: Out <<
"da";
break;
2122 Out << (Arity == 1?
"ps" :
"pl");
break;
2126 Out << (Arity == 1?
"ng" :
"mi");
break;
2130 Out << (Arity == 1?
"ad" :
"an");
break;
2135 Out << (Arity == 1?
"de" :
"ml");
break;
2137 case OO_Tilde: Out <<
"co";
break;
2139 case OO_Slash: Out <<
"dv";
break;
2141 case OO_Percent: Out <<
"rm";
break;
2143 case OO_Pipe: Out <<
"or";
break;
2145 case OO_Caret: Out <<
"eo";
break;
2147 case OO_Equal: Out <<
"aS";
break;
2149 case OO_PlusEqual: Out <<
"pL";
break;
2151 case OO_MinusEqual: Out <<
"mI";
break;
2153 case OO_StarEqual: Out <<
"mL";
break;
2155 case OO_SlashEqual: Out <<
"dV";
break;
2157 case OO_PercentEqual: Out <<
"rM";
break;
2159 case OO_AmpEqual: Out <<
"aN";
break;
2161 case OO_PipeEqual: Out <<
"oR";
break;
2163 case OO_CaretEqual: Out <<
"eO";
break;
2165 case OO_LessLess: Out <<
"ls";
break;
2167 case OO_GreaterGreater: Out <<
"rs";
break;
2169 case OO_LessLessEqual: Out <<
"lS";
break;
2171 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2173 case OO_EqualEqual: Out <<
"eq";
break;
2175 case OO_ExclaimEqual: Out <<
"ne";
break;
2177 case OO_Less: Out <<
"lt";
break;
2179 case OO_Greater: Out <<
"gt";
break;
2181 case OO_LessEqual: Out <<
"le";
break;
2183 case OO_GreaterEqual: Out <<
"ge";
break;
2185 case OO_Exclaim: Out <<
"nt";
break;
2187 case OO_AmpAmp: Out <<
"aa";
break;
2189 case OO_PipePipe: Out <<
"oo";
break;
2191 case OO_PlusPlus: Out <<
"pp";
break;
2193 case OO_MinusMinus: Out <<
"mm";
break;
2195 case OO_Comma: Out <<
"cm";
break;
2197 case OO_ArrowStar: Out <<
"pm";
break;
2199 case OO_Arrow: Out <<
"pt";
break;
2201 case OO_Call: Out <<
"cl";
break;
2203 case OO_Subscript: Out <<
"ix";
break;
2208 case OO_Conditional: Out <<
"qu";
break;
2211 case OO_Coawait: Out <<
"aw";
break;
2214 case OO_Spaceship: Out <<
"ss";
break;
2218 llvm_unreachable(
"Not an overloaded operator");
2248 ASString =
"AS" + llvm::utostr(TargetAS);
2251 default: llvm_unreachable(
"Not a language specific address space");
2265 if (!ASString.empty())
2266 mangleVendorQualifier(ASString);
2279 mangleVendorQualifier(
"__weak");
2283 mangleVendorQualifier(
"__unaligned");
2295 mangleVendorQualifier(
"__strong");
2299 mangleVendorQualifier(
"__autoreleasing");
2322 void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2323 Out <<
'U' << name.size() << name;
2329 switch (RefQualifier) {
2343 void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2344 Context.mangleObjCMethodName(MD, Out);
2365 void CXXNameMangler::mangleType(
QualType T) {
2406 = dyn_cast<TemplateSpecializationType>(T))
2407 if (!TST->isTypeAlias())
2420 const Type *ty = split.
Ty;
2422 bool isSubstitutable =
2424 if (isSubstitutable && mangleSubstitution(T))
2429 if (quals && isa<ArrayType>(T)) {
2439 dyn_cast<DependentAddressSpaceType>(ty)) {
2441 mangleQualifiers(splitDAST.
Quals, DAST);
2444 mangleQualifiers(quals);
2452 #define ABSTRACT_TYPE(CLASS, PARENT) 2453 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 2455 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 2457 #define TYPE(CLASS, PARENT) \ 2459 mangleType(static_cast<const CLASS##Type*>(ty)); \ 2461 #include "clang/AST/TypeNodes.def" 2466 if (isSubstitutable)
2470 void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
2471 if (!mangleStandardSubstitution(ND))
2475 void CXXNameMangler::mangleType(
const BuiltinType *T) {
2506 std::string type_name;
2508 case BuiltinType::Void:
2511 case BuiltinType::Bool:
2514 case BuiltinType::Char_U:
2515 case BuiltinType::Char_S:
2518 case BuiltinType::UChar:
2521 case BuiltinType::UShort:
2524 case BuiltinType::UInt:
2527 case BuiltinType::ULong:
2530 case BuiltinType::ULongLong:
2533 case BuiltinType::UInt128:
2536 case BuiltinType::SChar:
2539 case BuiltinType::WChar_S:
2540 case BuiltinType::WChar_U:
2543 case BuiltinType::Char8:
2546 case BuiltinType::Char16:
2549 case BuiltinType::Char32:
2552 case BuiltinType::Short:
2555 case BuiltinType::Int:
2558 case BuiltinType::Long:
2561 case BuiltinType::LongLong:
2564 case BuiltinType::Int128:
2567 case BuiltinType::Float16:
2570 case BuiltinType::ShortAccum:
2571 case BuiltinType::Accum:
2572 case BuiltinType::LongAccum:
2573 case BuiltinType::UShortAccum:
2574 case BuiltinType::UAccum:
2575 case BuiltinType::ULongAccum:
2576 case BuiltinType::ShortFract:
2577 case BuiltinType::Fract:
2578 case BuiltinType::LongFract:
2579 case BuiltinType::UShortFract:
2580 case BuiltinType::UFract:
2581 case BuiltinType::ULongFract:
2582 case BuiltinType::SatShortAccum:
2583 case BuiltinType::SatAccum:
2584 case BuiltinType::SatLongAccum:
2585 case BuiltinType::SatUShortAccum:
2586 case BuiltinType::SatUAccum:
2587 case BuiltinType::SatULongAccum:
2588 case BuiltinType::SatShortFract:
2589 case BuiltinType::SatFract:
2590 case BuiltinType::SatLongFract:
2591 case BuiltinType::SatUShortFract:
2592 case BuiltinType::SatUFract:
2593 case BuiltinType::SatULongFract:
2594 llvm_unreachable(
"Fixed point types are disabled for c++");
2595 case BuiltinType::Half:
2598 case BuiltinType::Float:
2601 case BuiltinType::Double:
2604 case BuiltinType::LongDouble:
2605 Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
2609 case BuiltinType::Float128:
2610 if (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble())
2611 Out <<
"U10__float128";
2615 case BuiltinType::NullPtr:
2619 #define BUILTIN_TYPE(Id, SingletonId) 2620 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2621 case BuiltinType::Id: 2622 #include "clang/AST/BuiltinTypes.def" 2623 case BuiltinType::Dependent:
2625 llvm_unreachable(
"mangling a placeholder type");
2627 case BuiltinType::ObjCId:
2628 Out <<
"11objc_object";
2630 case BuiltinType::ObjCClass:
2631 Out <<
"10objc_class";
2633 case BuiltinType::ObjCSel:
2634 Out <<
"13objc_selector";
2636 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2637 case BuiltinType::Id: \ 2638 type_name = "ocl_" #ImgType "_" #Suffix; \ 2639 Out << type_name.size() << type_name; \ 2641 #include "clang/Basic/OpenCLImageTypes.def" 2642 case BuiltinType::OCLSampler:
2643 Out <<
"11ocl_sampler";
2645 case BuiltinType::OCLEvent:
2646 Out <<
"9ocl_event";
2648 case BuiltinType::OCLClkEvent:
2649 Out <<
"12ocl_clkevent";
2651 case BuiltinType::OCLQueue:
2652 Out <<
"9ocl_queue";
2654 case BuiltinType::OCLReserveID:
2655 Out <<
"13ocl_reserveid";
2660 StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
2686 llvm_unreachable(
"bad calling convention");
2689 void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *T) {
2698 StringRef CCQualifier = getCallingConvQualifierName(T->
getExtInfo().
getCC());
2699 if (!CCQualifier.empty())
2700 mangleVendorQualifier(CCQualifier);
2726 mangleVendorQualifier(
"ns_consumed");
2729 mangleVendorQualifier(
"noescape");
2736 mangleExtFunctionInfo(T);
2753 mangleType(ExceptTy);
2764 mangleBareFunctionType(T,
true);
2778 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2780 FunctionTypeDepth.enterResultType();
2782 FunctionTypeDepth.leaveResultType();
2784 FunctionTypeDepth.pop(saved);
2789 bool MangleReturnType,
2793 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2796 if (MangleReturnType) {
2797 FunctionTypeDepth.enterResultType();
2801 mangleVendorQualifier(
"ns_returns_retained");
2806 auto SplitReturnTy = ReturnTy.
split();
2808 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
2810 mangleType(ReturnTy);
2812 FunctionTypeDepth.leaveResultType();
2819 FunctionTypeDepth.pop(saved);
2824 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2837 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
2838 Out <<
"U17pass_object_size" <<
Attr->getType();
2843 FunctionTypeDepth.pop(saved);
2858 void CXXNameMangler::mangleType(
const EnumType *T) {
2859 mangleType(static_cast<const TagType*>(T));
2861 void CXXNameMangler::mangleType(
const RecordType *T) {
2862 mangleType(static_cast<const TagType*>(T));
2864 void CXXNameMangler::mangleType(
const TagType *T) {
2872 Out <<
'A' << T->
getSize() <<
'_';
2921 mangleType(PointeeType);
2926 mangleTemplateParameter(T->
getIndex());
2935 Out <<
"_SUBSTPACK_";
2939 void CXXNameMangler::mangleType(
const PointerType *T) {
2961 void CXXNameMangler::mangleType(
const ComplexType *T) {
2969 void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
2971 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2972 const char *EltName =
nullptr;
2974 switch (cast<BuiltinType>(EltType)->getKind()) {
2975 case BuiltinType::SChar:
2976 case BuiltinType::UChar:
2977 EltName =
"poly8_t";
2979 case BuiltinType::Short:
2980 case BuiltinType::UShort:
2981 EltName =
"poly16_t";
2983 case BuiltinType::ULongLong:
2984 EltName =
"poly64_t";
2986 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
2989 switch (cast<BuiltinType>(EltType)->
getKind()) {
2990 case BuiltinType::SChar: EltName =
"int8_t";
break;
2991 case BuiltinType::UChar: EltName =
"uint8_t";
break;
2992 case BuiltinType::Short: EltName =
"int16_t";
break;
2993 case BuiltinType::UShort: EltName =
"uint16_t";
break;
2994 case BuiltinType::Int: EltName =
"int32_t";
break;
2995 case BuiltinType::UInt: EltName =
"uint32_t";
break;
2996 case BuiltinType::LongLong: EltName =
"int64_t";
break;
2997 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
2998 case BuiltinType::Double: EltName =
"float64_t";
break;
2999 case BuiltinType::Float: EltName =
"float32_t";
break;
3000 case BuiltinType::Half: EltName =
"float16_t";
break;
3002 llvm_unreachable(
"unexpected Neon vector element type");
3005 const char *BaseName =
nullptr;
3007 getASTContext().getTypeSize(EltType));
3009 BaseName =
"__simd64_";
3011 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
3012 BaseName =
"__simd128_";
3014 Out << strlen(BaseName) + strlen(EltName);
3015 Out << BaseName << EltName;
3022 "cannot mangle this dependent neon vector type yet");
3028 case BuiltinType::SChar:
3030 case BuiltinType::Short:
3032 case BuiltinType::Int:
3034 case BuiltinType::Long:
3035 case BuiltinType::LongLong:
3037 case BuiltinType::UChar:
3039 case BuiltinType::UShort:
3041 case BuiltinType::UInt:
3043 case BuiltinType::ULong:
3044 case BuiltinType::ULongLong:
3046 case BuiltinType::Half:
3048 case BuiltinType::Float:
3050 case BuiltinType::Double:
3053 llvm_unreachable(
"Unexpected vector element base type");
3060 void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
3062 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3067 assert((BitSize == 64 || BitSize == 128) &&
3068 "Neon vector type not 64 or 128 bits");
3072 switch (cast<BuiltinType>(EltType)->getKind()) {
3073 case BuiltinType::UChar:
3076 case BuiltinType::UShort:
3079 case BuiltinType::ULong:
3080 case BuiltinType::ULongLong:
3084 llvm_unreachable(
"unexpected Neon polynomial vector element type");
3089 std::string TypeName =
3090 (
"__" + EltName +
"x" + Twine(T->
getNumElements()) +
"_t").str();
3091 Out << TypeName.length() << TypeName;
3097 "cannot mangle this dependent neon vector type yet");
3109 void CXXNameMangler::mangleType(
const VectorType *T) {
3112 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
3113 llvm::Triple::ArchType Arch =
3114 getASTContext().getTargetInfo().getTriple().getArch();
3115 if ((Arch == llvm::Triple::aarch64 ||
3116 Arch == llvm::Triple::aarch64_be) && !Target.isOSDarwin())
3117 mangleAArch64NeonVectorType(T);
3119 mangleNeonVectorType(T);
3134 llvm::Triple
Target = getASTContext().getTargetInfo().getTriple();
3135 llvm::Triple::ArchType Arch =
3136 getASTContext().getTargetInfo().getTriple().getArch();
3137 if ((Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be) &&
3138 !Target.isOSDarwin())
3139 mangleAArch64NeonVectorType(T);
3141 mangleNeonVectorType(T);
3157 mangleType(static_cast<const VectorType*>(T));
3168 mangleQualifiers(split.
Quals, T);
3185 Out <<
"U8__kindof";
3190 llvm::raw_svector_ostream QualOS(QualStr);
3191 QualOS <<
"objcproto";
3192 for (
const auto *I : T->
quals()) {
3193 StringRef name = I->getName();
3194 QualOS << name.size() << name;
3196 Out <<
'U' << QualStr.size() << QualStr;
3205 mangleType(typeArg);
3211 Out <<
"U13block_pointer";
3226 if (mangleSubstitution(
QualType(T, 0)))
3279 getASTContext().getDependentTemplateName(T->
getQualifier(),
3281 mangleTemplatePrefix(Prefix);
3290 void CXXNameMangler::mangleType(
const TypeOfType *T) {
3302 void CXXNameMangler::mangleType(
const DecltypeType *T) {
3313 if (isa<DeclRefExpr>(E) ||
3314 isa<MemberExpr>(E) ||
3315 isa<UnresolvedLookupExpr>(E) ||
3316 isa<DependentScopeDeclRefExpr>(E) ||
3317 isa<CXXDependentScopeMemberExpr>(E) ||
3318 isa<UnresolvedMemberExpr>(E))
3322 mangleExpression(E);
3342 void CXXNameMangler::mangleType(
const AutoType *T) {
3344 "Deduced AutoType shouldn't be handled here!");
3346 "shouldn't need to mangle __auto_type!");
3362 void CXXNameMangler::mangleType(
const AtomicType *T) {
3369 void CXXNameMangler::mangleType(
const PipeType *T) {
3376 void CXXNameMangler::mangleIntegerLiteral(
QualType T,
3377 const llvm::APSInt &Value) {
3384 Out << (Value.getBoolValue() ?
'1' :
'0');
3386 mangleNumber(Value);
3392 void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
3395 if (!RT->getDecl()->isAnonymousStructOrUnion())
3400 Base = ME->getBase();
3401 IsArrow = ME->isArrow();
3410 Out << (IsArrow ?
"pt" :
"dt");
3411 mangleExpression(Base);
3416 void CXXNameMangler::mangleMemberExpr(
const Expr *base,
3422 unsigned NumTemplateArgs,
3427 mangleMemberExprBase(base, isArrow);
3428 mangleUnresolvedName(qualifier, member, TemplateArgs, NumTemplateArgs, arity);
3441 if (callee == fn)
return false;
3445 if (!lookup)
return false;
3462 void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
3464 Out << CastEncoding;
3469 void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
3471 InitList = Syntactic;
3472 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
3473 mangleExpression(InitList->
getInit(i));
3476 void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity) {
3500 QualType ImplicitlyConvertedToType;
3505 #define ABSTRACT_STMT(Type) 3506 #define EXPR(Type, Base) 3507 #define STMT(Type, Base) \ 3508 case Expr::Type##Class: 3509 #include "clang/AST/StmtNodes.inc" 3514 case Expr::AddrLabelExprClass:
3515 case Expr::DesignatedInitUpdateExprClass:
3516 case Expr::ImplicitValueInitExprClass:
3517 case Expr::ArrayInitLoopExprClass:
3518 case Expr::ArrayInitIndexExprClass:
3519 case Expr::NoInitExprClass:
3520 case Expr::ParenListExprClass:
3521 case Expr::LambdaExprClass:
3522 case Expr::MSPropertyRefExprClass:
3523 case Expr::MSPropertySubscriptExprClass:
3524 case Expr::TypoExprClass:
3525 case Expr::OMPArraySectionExprClass:
3526 case Expr::CXXInheritedCtorInitExprClass:
3527 llvm_unreachable(
"unexpected statement kind");
3530 case Expr::BlockExprClass:
3531 case Expr::ChooseExprClass:
3532 case Expr::CompoundLiteralExprClass:
3533 case Expr::ExtVectorElementExprClass:
3534 case Expr::GenericSelectionExprClass:
3535 case Expr::ObjCEncodeExprClass:
3536 case Expr::ObjCIsaExprClass:
3537 case Expr::ObjCIvarRefExprClass:
3538 case Expr::ObjCMessageExprClass:
3539 case Expr::ObjCPropertyRefExprClass:
3540 case Expr::ObjCProtocolExprClass:
3541 case Expr::ObjCSelectorExprClass:
3542 case Expr::ObjCStringLiteralClass:
3543 case Expr::ObjCBoxedExprClass:
3544 case Expr::ObjCArrayLiteralClass:
3545 case Expr::ObjCDictionaryLiteralClass:
3546 case Expr::ObjCSubscriptRefExprClass:
3547 case Expr::ObjCIndirectCopyRestoreExprClass:
3548 case Expr::ObjCAvailabilityCheckExprClass:
3549 case Expr::OffsetOfExprClass:
3550 case Expr::PredefinedExprClass:
3551 case Expr::ShuffleVectorExprClass:
3552 case Expr::ConvertVectorExprClass:
3553 case Expr::StmtExprClass:
3554 case Expr::TypeTraitExprClass:
3555 case Expr::ArrayTypeTraitExprClass:
3556 case Expr::ExpressionTraitExprClass:
3557 case Expr::VAArgExprClass:
3558 case Expr::CUDAKernelCallExprClass:
3559 case Expr::AsTypeExprClass:
3560 case Expr::PseudoObjectExprClass:
3561 case Expr::AtomicExprClass:
3562 case Expr::FixedPointLiteralClass:
3568 "cannot yet mangle expression type %0");
3575 case Expr::CXXUuidofExprClass: {
3579 Out <<
"u8__uuidoft";
3583 Out <<
"u8__uuidofz";
3584 mangleExpression(UuidExp, Arity);
3590 case Expr::BinaryConditionalOperatorClass: {
3594 "?: operator with omitted middle operand cannot be mangled");
3601 case Expr::OpaqueValueExprClass:
3602 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
3604 case Expr::InitListExprClass: {
3606 mangleInitListElements(cast<InitListExpr>(E));
3611 case Expr::DesignatedInitExprClass: {
3612 auto *DIE = cast<DesignatedInitExpr>(E);
3613 for (
const auto &
Designator : DIE->designators()) {
3619 mangleExpression(DIE->getArrayIndex(
Designator));
3622 "unknown designator kind");
3624 mangleExpression(DIE->getArrayRangeStart(
Designator));
3625 mangleExpression(DIE->getArrayRangeEnd(
Designator));
3628 mangleExpression(DIE->getInit());
3632 case Expr::CXXDefaultArgExprClass:
3633 mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
3636 case Expr::CXXDefaultInitExprClass:
3637 mangleExpression(cast<CXXDefaultInitExpr>(E)->getExpr(), Arity);
3640 case Expr::CXXStdInitializerListExprClass:
3641 mangleExpression(cast<CXXStdInitializerListExpr>(E)->getSubExpr(), Arity);
3644 case Expr::SubstNonTypeTemplateParmExprClass:
3645 mangleExpression(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
3649 case Expr::UserDefinedLiteralClass:
3652 case Expr::CXXMemberCallExprClass:
3653 case Expr::CallExprClass: {
3654 const CallExpr *CE = cast<CallExpr>(E);
3673 if (isa<PackExpansionExpr>(Arg))
3674 CallArity = UnknownArity;
3676 mangleExpression(CE->
getCallee(), CallArity);
3678 mangleExpression(Arg);
3683 case Expr::CXXNewExprClass: {
3686 Out << (New->
isArray() ?
"na" :
"nw");
3689 mangleExpression(*I);
3703 mangleExpression(*I);
3704 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
3705 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
3706 mangleExpression(PLE->getExpr(i));
3708 isa<InitListExpr>(Init)) {
3710 mangleInitListElements(cast<InitListExpr>(Init));
3712 mangleExpression(Init);
3718 case Expr::CXXPseudoDestructorExprClass: {
3719 const auto *PDE = cast<CXXPseudoDestructorExpr>(E);
3720 if (
const Expr *Base = PDE->getBase())
3721 mangleMemberExprBase(Base, PDE->isArrow());
3725 mangleUnresolvedPrefix(Qualifier,
3727 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
3731 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
3734 }
else if (Qualifier) {
3735 mangleUnresolvedPrefix(Qualifier);
3739 QualType DestroyedType = PDE->getDestroyedType();
3740 mangleUnresolvedTypeOrSimpleId(DestroyedType);
3744 case Expr::MemberExprClass: {
3754 case Expr::UnresolvedMemberExprClass: {
3764 case Expr::CXXDependentScopeMemberExprClass: {
3766 = cast<CXXDependentScopeMemberExpr>(E);
3776 case Expr::UnresolvedLookupExprClass: {
3784 case Expr::CXXUnresolvedConstructExprClass: {
3789 assert(N == 1 &&
"unexpected form for list initialization");
3790 auto *IL = cast<InitListExpr>(CE->
getArg(0));
3793 mangleInitListElements(IL);
3800 if (N != 1) Out <<
'_';
3801 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
3802 if (N != 1) Out <<
'E';
3806 case Expr::CXXConstructExprClass: {
3807 const auto *CE = cast<CXXConstructExpr>(E);
3808 if (!CE->isListInitialization() || CE->isStdInitListInitialization()) {
3810 CE->getNumArgs() >= 1 &&
3811 (CE->getNumArgs() == 1 || isa<CXXDefaultArgExpr>(CE->getArg(1))) &&
3812 "implicit CXXConstructExpr must have one argument");
3813 return mangleExpression(cast<CXXConstructExpr>(E)->getArg(0));
3816 for (
auto *E : CE->arguments())
3817 mangleExpression(E);
3822 case Expr::CXXTemporaryObjectExprClass: {
3823 const auto *CE = cast<CXXTemporaryObjectExpr>(E);
3824 unsigned N = CE->getNumArgs();
3825 bool List = CE->isListInitialization();
3831 mangleType(CE->getType());
3832 if (!List && N != 1)
3834 if (CE->isStdInitListInitialization()) {
3839 cast<CXXStdInitializerListExpr>(CE->getArg(0)->IgnoreImplicit());
3840 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
3841 mangleInitListElements(ILE);
3843 for (
auto *E : CE->arguments())
3844 mangleExpression(E);
3851 case Expr::CXXScalarValueInitExprClass:
3857 case Expr::CXXNoexceptExprClass:
3859 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
3862 case Expr::UnaryExprOrTypeTraitExprClass: {
3876 : ImplicitlyConvertedToType;
3878 mangleIntegerLiteral(T, V);
3892 "cannot yet mangle vec_step expression");
3900 "cannot yet mangle __builtin_omp_required_simd_align expression");
3914 case Expr::CXXThrowExprClass: {
3927 case Expr::CXXTypeidExprClass: {
3941 case Expr::CXXDeleteExprClass: {
3951 case Expr::UnaryOperatorClass: {
3959 case Expr::ArraySubscriptExprClass: {
3965 mangleExpression(AE->
getLHS());
3966 mangleExpression(AE->
getRHS());
3970 case Expr::CompoundAssignOperatorClass:
3971 case Expr::BinaryOperatorClass: {
3978 mangleExpression(BO->
getLHS());
3979 mangleExpression(BO->
getRHS());
3983 case Expr::ConditionalOperatorClass: {
3985 mangleOperatorName(OO_Conditional, 3);
3986 mangleExpression(CO->
getCond());
3987 mangleExpression(CO->
getLHS(), Arity);
3988 mangleExpression(CO->
getRHS(), Arity);
3992 case Expr::ImplicitCastExprClass: {
3993 ImplicitlyConvertedToType = E->
getType();
3994 E = cast<ImplicitCastExpr>(E)->getSubExpr();
3998 case Expr::ObjCBridgedCastExprClass: {
4001 StringRef
Kind = cast<ObjCBridgedCastExpr>(E)->getBridgeKindName();
4002 Out <<
"v1U" << Kind.size() <<
Kind;
4007 case Expr::CStyleCastExprClass:
4008 mangleCastExpression(E,
"cv");
4011 case Expr::CXXFunctionalCastExprClass: {
4012 auto *Sub = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreImplicit();
4014 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
4015 if (CCE->getParenOrBraceRange().isInvalid())
4016 Sub = CCE->getArg(0)->IgnoreImplicit();
4017 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
4018 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
4019 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
4022 mangleInitListElements(IL);
4025 mangleCastExpression(E,
"cv");
4030 case Expr::CXXStaticCastExprClass:
4031 mangleCastExpression(E,
"sc");
4033 case Expr::CXXDynamicCastExprClass:
4034 mangleCastExpression(E,
"dc");
4036 case Expr::CXXReinterpretCastExprClass:
4037 mangleCastExpression(E,
"rc");
4039 case Expr::CXXConstCastExprClass:
4040 mangleCastExpression(E,
"cc");
4043 case Expr::CXXOperatorCallExprClass: {
4051 for (
unsigned i = 0; i != NumArgs; ++i)
4052 mangleExpression(CE->
getArg(i));
4056 case Expr::ParenExprClass:
4057 mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
4060 case Expr::DeclRefExprClass: {
4061 const NamedDecl *D = cast<DeclRefExpr>(E)->getDecl();
4072 mangleFunctionParam(cast<ParmVarDecl>(D));
4075 case Decl::EnumConstant: {
4081 case Decl::NonTypeTemplateParm: {
4083 mangleTemplateParameter(PD->
getIndex());
4092 case Expr::SubstNonTypeTemplateParmPackExprClass:
4097 Out <<
"_SUBSTPACK_";
4100 case Expr::FunctionParmPackExprClass: {
4103 Out <<
"v110_SUBSTPACK";
4108 case Expr::DependentScopeDeclRefExprClass: {
4116 case Expr::CXXBindTemporaryExprClass:
4117 mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
4120 case Expr::ExprWithCleanupsClass:
4121 mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
4124 case Expr::FloatingLiteralClass: {
4133 case Expr::CharacterLiteralClass:
4136 Out << cast<CharacterLiteral>(E)->
getValue();
4141 case Expr::ObjCBoolLiteralExprClass:
4143 Out << (cast<ObjCBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4147 case Expr::CXXBoolLiteralExprClass:
4149 Out << (cast<CXXBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4153 case Expr::IntegerLiteralClass: {
4156 Value.setIsSigned(
true);
4161 case Expr::ImaginaryLiteralClass: {
4168 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
4170 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
4172 mangleFloat(Imag->getValue());
4177 Value.setIsSigned(
true);
4178 mangleNumber(Value);
4184 case Expr::StringLiteralClass: {
4187 assert(isa<ConstantArrayType>(E->
getType()));
4193 case Expr::GNUNullExprClass:
4197 case Expr::CXXNullPtrLiteralExprClass: {
4202 case Expr::PackExpansionExprClass:
4204 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
4207 case Expr::SizeOfPackExprClass: {
4208 auto *SPE = cast<SizeOfPackExpr>(E);
4209 if (SPE->isPartiallySubstituted()) {
4211 for (
const auto &A : SPE->getPartialArguments())
4212 mangleTemplateArg(A);
4220 mangleTemplateParameter(TTP->getIndex());
4222 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
4223 mangleTemplateParameter(NTTP->getIndex());
4225 = dyn_cast<TemplateTemplateParmDecl>(Pack))
4226 mangleTemplateParameter(TempTP->getIndex());
4228 mangleFunctionParam(cast<ParmVarDecl>(Pack));
4232 case Expr::MaterializeTemporaryExprClass: {
4233 mangleExpression(cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr());
4237 case Expr::CXXFoldExprClass: {
4238 auto *FE = cast<CXXFoldExpr>(E);
4239 if (FE->isLeftFold())
4240 Out << (FE->getInit() ?
"fL" :
"fl");
4242 Out << (FE->getInit() ?
"fR" :
"fr");
4244 if (FE->getOperator() == BO_PtrMemD)
4252 mangleExpression(FE->getLHS());
4254 mangleExpression(FE->getRHS());
4258 case Expr::CXXThisExprClass:
4262 case Expr::CoawaitExprClass:
4264 Out <<
"v18co_await";
4265 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4268 case Expr::DependentCoawaitExprClass:
4270 Out <<
"v18co_await";
4271 mangleExpression(cast<DependentCoawaitExpr>(E)->getOperand());
4274 case Expr::CoyieldExprClass:
4276 Out <<
"v18co_yield";
4277 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4310 void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
4317 assert(parmDepth < FunctionTypeDepth.getDepth());
4318 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
4319 if (FunctionTypeDepth.isInResultType())
4322 if (nestingDepth == 0) {
4325 Out <<
"fL" << (nestingDepth - 1) <<
'p';
4333 &&
"parameter's type is still an array type?");
4336 dyn_cast<DependentAddressSpaceType>(parm->
getType())) {
4343 if (parmIndex != 0) {
4344 Out << (parmIndex - 1);
4349 void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T,
4372 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
4375 mangleName(InheritedFrom);
4378 void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
4401 unsigned NumTemplateArgs) {
4404 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4412 for (
unsigned i = 0, e = AL.
size(); i != e; ++i)
4413 mangleTemplateArg(AL[i]);
4417 void CXXNameMangler::mangleTemplateArgs(
const TemplateArgument *TemplateArgs,
4418 unsigned NumTemplateArgs) {
4421 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4422 mangleTemplateArg(TemplateArgs[i]);
4436 llvm_unreachable(
"Cannot mangle NULL template argument");
4455 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
4457 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
4466 mangleExpression(E);
4480 if (compensateMangling) {
4482 mangleOperatorName(OO_Amp, 1);
4491 if (compensateMangling)
4507 mangleTemplateArg(
P);
4513 void CXXNameMangler::mangleTemplateParameter(
unsigned Index) {
4519 Out <<
'T' << (Index - 1) <<
'_';
4522 void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
4525 else if (SeqID > 1) {
4533 for (; SeqID != 0; SeqID /= 36) {
4534 unsigned C = SeqID % 36;
4535 *I++ = (C < 10 ?
'0' +
C :
'A' + C - 10);
4538 Out.write(I.base(), I - BufferRef.rbegin());
4543 void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
4544 bool result = mangleSubstitution(tname);
4545 assert(result &&
"no existing substitution for template name");
4551 bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
4553 if (mangleStandardSubstitution(ND))
4557 return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
4567 bool CXXNameMangler::mangleSubstitution(
QualType T) {
4570 return mangleSubstitution(RT->getDecl());
4575 return mangleSubstitution(TypePtr);
4578 bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
4580 return mangleSubstitution(TD);
4583 return mangleSubstitution(
4587 bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
4588 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
4589 if (I == Substitutions.end())
4592 unsigned SeqID = I->second;
4626 if (TemplateArgs.
size() != 1)
4629 if (!
isCharType(TemplateArgs[0].getAsType()))
4635 template <std::
size_t StrLen>
4637 const char (&Str)[StrLen]) {
4642 if (TemplateArgs.
size() != 2)
4645 if (!
isCharType(TemplateArgs[0].getAsType()))
4654 bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
4656 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
4681 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
4691 if (TemplateArgs.
size() != 3)
4694 if (!
isCharType(TemplateArgs[0].getAsType()))
4731 void CXXNameMangler::addSubstitution(
QualType T) {
4734 addSubstitution(RT->getDecl());
4740 addSubstitution(TypePtr);
4743 void CXXNameMangler::addSubstitution(
TemplateName Template) {
4745 return addSubstitution(TD);
4751 void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
4752 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
4753 Substitutions[Ptr] = SeqID++;
4756 void CXXNameMangler::extendSubstitutions(CXXNameMangler* Other) {
4757 assert(Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
4758 if (Other->SeqID > SeqID) {
4759 Substitutions.swap(Other->Substitutions);
4760 SeqID = Other->SeqID;
4764 CXXNameMangler::AbiTagList
4765 CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
4767 if (DisableDerivedAbiTags)
4768 return AbiTagList();
4770 llvm::raw_null_ostream NullOutStream;
4771 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
4772 TrackReturnTypeTags.disableDerivedAbiTags();
4776 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
4777 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
4779 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
4780 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
4782 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4785 CXXNameMangler::AbiTagList
4786 CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
4788 if (DisableDerivedAbiTags)
4789 return AbiTagList();
4791 llvm::raw_null_ostream NullOutStream;
4792 CXXNameMangler TrackVariableType(*
this, NullOutStream);
4793 TrackVariableType.disableDerivedAbiTags();
4795 TrackVariableType.mangleType(VD->
getType());
4797 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4800 bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &
C,
4802 llvm::raw_null_ostream NullOutStream;
4803 CXXNameMangler TrackAbiTags(C, NullOutStream,
nullptr,
true);
4804 TrackAbiTags.mangle(VD);
4805 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
4818 void ItaniumMangleContextImpl::mangleCXXName(
const NamedDecl *D,
4820 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
4821 "Invalid mangleName() call, argument is not a variable or function!");
4822 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
4823 "Invalid mangleName() call on 'structor decl!");
4826 getASTContext().getSourceManager(),
4827 "Mangling declaration");
4829 CXXNameMangler Mangler(*
this, Out, D);
4836 CXXNameMangler Mangler(*
this, Out, D, Type);
4843 CXXNameMangler Mangler(*
this, Out, D, Type);
4849 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
4855 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
4859 void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
4869 assert(!isa<CXXDestructorDecl>(MD) &&
4870 "Use mangleCXXDtor for destructor decls!");
4871 CXXNameMangler Mangler(*
this, Out);
4872 Mangler.getStream() <<
"_ZT";
4874 Mangler.getStream() <<
'c';
4885 Mangler.mangleFunctionEncoding(MD);
4888 void ItaniumMangleContextImpl::mangleCXXDtorThunk(
4893 CXXNameMangler Mangler(*
this, Out, DD, Type);
4894 Mangler.getStream() <<
"_ZT";
4897 Mangler.mangleCallOffset(ThisAdjustment.
NonVirtual,
4900 Mangler.mangleFunctionEncoding(DD);
4904 void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
4908 CXXNameMangler Mangler(*
this, Out);
4911 Mangler.getStream() <<
"_ZGV";
4912 Mangler.mangleName(D);
4915 void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
4920 Out <<
"__cxx_global_var_init";
4923 void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
4926 CXXNameMangler Mangler(*
this, Out);
4927 Mangler.getStream() <<
"__dtor_";
4928 if (shouldMangleDeclName(D))
4931 Mangler.getStream() << D->
getName();
4934 void ItaniumMangleContextImpl::mangleSEHFilterExpression(
4935 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4936 CXXNameMangler Mangler(*
this, Out);
4937 Mangler.getStream() <<
"__filt_";
4938 if (shouldMangleDeclName(EnclosingDecl))
4939 Mangler.mangle(EnclosingDecl);
4941 Mangler.getStream() << EnclosingDecl->
getName();
4944 void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
4945 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4946 CXXNameMangler Mangler(*
this, Out);
4947 Mangler.getStream() <<
"__fin_";
4948 if (shouldMangleDeclName(EnclosingDecl))
4949 Mangler.mangle(EnclosingDecl);
4951 Mangler.getStream() << EnclosingDecl->
getName();
4954 void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
4957 CXXNameMangler Mangler(*
this, Out);
4958 Mangler.getStream() <<
"_ZTH";
4959 Mangler.mangleName(D);
4963 ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
4966 CXXNameMangler Mangler(*
this, Out);
4967 Mangler.getStream() <<
"_ZTW";
4968 Mangler.mangleName(D);
4971 void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
4972 unsigned ManglingNumber,
4976 CXXNameMangler Mangler(*
this, Out);
4977 Mangler.getStream() <<
"_ZGR";
4978 Mangler.mangleName(D);
4979 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
4980 Mangler.mangleSeqID(ManglingNumber - 1);
4983 void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
4986 CXXNameMangler Mangler(*
this, Out);
4987 Mangler.getStream() <<
"_ZTV";
4988 Mangler.mangleNameOrStandardSubstitution(RD);
4991 void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
4994 CXXNameMangler Mangler(*
this, Out);
4995 Mangler.getStream() <<
"_ZTT";
4996 Mangler.mangleNameOrStandardSubstitution(RD);
4999 void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
5004 CXXNameMangler Mangler(*
this, Out);
5005 Mangler.getStream() <<
"_ZTC";
5006 Mangler.mangleNameOrStandardSubstitution(RD);
5007 Mangler.getStream() <<
Offset;
5008 Mangler.getStream() <<
'_';
5009 Mangler.mangleNameOrStandardSubstitution(Type);
5012 void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
5014 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
5015 CXXNameMangler Mangler(*
this, Out);
5016 Mangler.getStream() <<
"_ZTI";
5017 Mangler.mangleType(Ty);
5020 void ItaniumMangleContextImpl::mangleCXXRTTIName(
QualType Ty,
5023 CXXNameMangler Mangler(*
this, Out);
5024 Mangler.getStream() <<
"_ZTS";
5025 Mangler.mangleType(Ty);
5028 void ItaniumMangleContextImpl::mangleTypeName(
QualType Ty, raw_ostream &Out) {
5029 mangleCXXRTTIName(Ty, Out);
5032 void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
5033 llvm_unreachable(
"Can't mangle string literals");
5038 return new ItaniumMangleContextImpl(Context, Diags);
A call to an overloaded operator written using operator syntax.
ParameterABI getABI() const
Return the ABI treatment of this parameter.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
const Type * Ty
The locally-unqualified type.
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
Represents a function declaration or definition.
std::string Name
The name of this module.
static Qualifiers fromCVRUMask(unsigned CVRU)
The "enum" keyword introduces the elaborated-type-specifier.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
PointerType - C99 6.7.5.1 - Pointer Declarators.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Attempt to be ABI-compatible with code generated by Clang 6.0.x (SVN r321711).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static const TemplateArgument & getArgument(const TemplateArgument &A)
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
const Expr * getSubExpr() const
__auto_type (GNU extension)
The COMDAT used for ctors.
const Expr * getInit(unsigned Init) const
bool isListInitialization() const
Determine whether this expression models list-initialization.
Expr * getUnderlyingExpr() const
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
FunctionType - C99 6.7.5.3 - Function Declarators.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
TemplateArgumentLoc const * getTemplateArgs() const
An instance of this object exists for each enum constant that is defined.
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.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
bool isDecltypeAuto() const
Decl - This represents one declaration (or definition), e.g.
TagDecl * getDecl() const
static bool isStreamCharSpecialization(const ClassTemplateSpecializationDecl *SD, const char(&Str)[StrLen])
llvm::APFloat getValue() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Defines the C++ template declaration subclasses.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++11 auto or C++14 decltype(auto) type.
unsigned getBlockManglingNumber() const
The base class of the type hierarchy.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
bool isArrayRangeDesignator() const
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...
A container of type source information.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
SourceLocation getAttributeLoc() const
Represents a C++ constructor within a class.
A template template parameter that has been substituted for some other template name.
Default closure variant of a ctor.
QualType getElementType() const
const Expr * getSubExpr() const
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
An identifier, stored as an IdentifierInfo*.
Represents a variable declaration or definition.
void removeObjCLifetime()
unsigned getNumParams() const
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.
const T * getAs() const
Member-template getAs<specific type>'.
Represents an empty template argument, e.g., one that has not been deduced.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Represents a C++17 deduced template specialization type.
A this pointer adjustment.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
A namespace, stored as a NamespaceDecl*.
DeclarationName getName() const
Gets the name looked up.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
A C++ throw-expression (C++ [except.throw]).
Expr * getExprOperand() const
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
QualType getIntegralType() const
Retrieve the type of the integral value.
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
The collection of all-type qualifiers we support.
Expr * getExprOperand() const
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
const char * getStmtClassName() const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a struct/union/class.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
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.
bool isNothrow(bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
bool isInAnonymousNamespace() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a class type in Objective C.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
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.
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...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Represents a member of a struct/union/class.
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
const llvm::APSInt & getInitVal() const
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
bool isReferenceType() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
bool addressSpaceMapManglingFor(LangAS AS) const
Represents the result of substituting a set of types for a template type parameter pack...
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
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. ...
TypeSourceInfo * getLambdaTypeInfo() const
TemplateName getReplacement() const
QualType getParamTypeForDecl() const
Describes a module or submodule.
unsigned getTypeQuals() const
bool getProducesResult() 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].
UnresolvedUsingTypenameDecl * getDecl() const
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
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)
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
bool hasAddressSpace() const
The "struct" keyword introduces the elaborated-type-specifier.
struct clang::ReturnAdjustment::VirtualAdjustment::@117 Itanium
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Expr * getInitializer()
The initializer of this new-expression.
static bool isStdNamespace(const DeclContext *DC)
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
Concrete class used by the front-end to report problems and issues.
Represents a typeof (or typeof) expression (a GCC extension).
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
A builtin binary operation expression such as "x + y" or "x <= y".
LangAS getAddressSpace() const
const Type * getClass() const
bool isLambda() const
Determine whether this class describes a lambda function object.
Expr * getSizeExpr() const
const TemplateArgument * getArgs() const
Retrieve the template arguments.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Enums/classes describing ABI related information about constructors, destructors and thunks...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
void * getAsOpaquePtr() const
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
is ARM Neon polynomial vector
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Expr * getSizeExpr() const
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool isTypeOperand() const
Expr * getSizeExpr() const
QualType getElementType() const
arg_iterator placement_arg_end()
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
Expr * getAddrSpaceExpr() const
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
llvm::StringRef getParameterABISpelling(ParameterABI kind)
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
ConditionalOperator - The ?: ternary operator.
QualType getBaseType() const
Gets the base type of this object type.
Const iterator for iterating over Stmt * arrays that contain only Expr *.
Represents a prototype with parameter type info, e.g.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
A dependent template name that has not been resolved to a template (or set of templates).
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
union clang::ReturnAdjustment::VirtualAdjustment Virtual
bool hasQualifiers() const
Determine whether this type has any qualifiers.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Represents an array type in C++ whose size is a value-dependent expression.
CXXDtorType
C++ destructor types.
QualType getElementType() const
unsigned getNumArgs() const
Retrieve the number of template arguments.
unsigned getFunctionScopeDepth() const
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Expr - This represents one expression.
static const DeclContext * IgnoreLinkageSpecDecls(const DeclContext *DC)
QualType getPointeeType() const
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TemplateArgumentLoc const * getTemplateArgs() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
Declaration of a template type parameter.
unsigned getIndex() const
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
const T * castAs() const
Member-template castAs<specific type>.
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.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
unsigned getNumInits() const
bool isArrayDesignator() const
bool isImplicitAccess() const
True if this is an implicit access, i.e.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
const Expr * getCallee() const
QualType getArgumentType() const
ObjCLifetime getObjCLifetime() const
unsigned getNumTemplateArgs() const
DeclContext * getDeclContext()
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
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. ...
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
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).
decls_iterator decls_begin() const
static SVal getValue(SVal val, SValBuilder &svalBuilder)
Defines the clang::TypeLoc interface and its subclasses.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
A namespace alias, stored as a NamespaceAliasDecl*.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
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 isFunctionOrMethod() const
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Qualifiers Quals
The local qualifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool hasInitializer() const
Whether this new-expression has any initializer at all.
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
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.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
static bool hasMangledSubstitutionQualifiers(QualType T)
Determine whether the given type has any qualifiers that are relevant for substitutions.
A template template parameter pack that has been substituted for a template template argument pack...
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
There is no lifetime qualification on this type.
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
is AltiVec 'vector Pixel'
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
ExtParameterInfo getExtParameterInfo(unsigned I) const
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ElaboratedTypeKeyword getKeyword() const
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
Encodes a location in the source.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
Expr * getSubExpr() const
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
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...
CallingConv getCC() const
QualType getElementType() const
Represents a vector type where either the type or size is dependent.
bool isFieldDesignator() const
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.
bool isConsumed() const
Is this parameter considered "consumed" by Objective-C ARC? Consumed parameters must have retainable ...
QualType getAllocatedType() const
const ParmVarDecl * getParamDecl(unsigned i) const
This file defines OpenMP nodes for declarative directives.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
Expr * getNoexceptExpr() const
UnaryExprOrTypeTrait getKind() const
is AltiVec 'vector bool ...'
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
Decl * getBlockManglingContextDecl() const
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
AutoTypeKeyword getKeyword() const
TypeClass getTypeClass() const
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset. ...
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
bool isArgumentType() const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
CXXCtorType
C++ constructor types.
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.
A qualified reference to a name whose declaration cannot yet be resolved.
QualType getPointeeType() const
Represents a pack expansion of types.
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
StringRef getName() const
Return the actual identifier string.
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...
Represents a template argument.
Represents a template name that was expressed as a qualified name.
bool isTypeOperand() const
Dataflow Directional Tag Classes.
ThisAdjustment This
The this pointer adjustment.
ExtInfo getExtInfo() const
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
NestedNameSpecifier * getQualifier() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
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 getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
The template argument is a pack expansion of a template name that was provided for a template templat...
const TemplateArgument * getArgs() const
Retrieve the template arguments.
Represents a field injected from an anonymous union/struct into the parent scope. ...
bool isDependentAddressSpaceType() const
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
VectorKind getVectorKind() const
ArrayRef< QualType > exceptions() const
The "union" keyword introduces the elaborated-type-specifier.
bool isBooleanType() const
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
The "class" keyword introduces the elaborated-type-specifier.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
struct clang::ThisAdjustment::VirtualAdjustment::@119 Itanium
A pointer to member type per C++ 8.3.3 - Pointers to members.
ExplicitCastExpr - An explicit cast written in the source code.
A type that was preceded by the 'template' keyword, stored as a Type*.
union clang::ThisAdjustment::VirtualAdjustment Virtual
Represents a pointer to an Objective C object.
Not an overloaded operator.
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.
unsigned getNumArgs() const
Retrieve the number of template arguments.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const llvm::APInt & getSize() const
ExtVectorType - Extended vector type.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
ReturnAdjustment Return
The return adjustment.
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
The template argument is actually a parameter pack.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
arg_iterator placement_arg_begin()
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
unsigned arg_size() const
Retrieve the number of arguments.
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
A template argument list.
VectorType::VectorKind getVectorKind() const
Reading or writing from this object requires a barrier call.
ArgKind getKind() const
Return the kind of stored template argument.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty, ASTContext &Ctx)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool hasUnaligned() const
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.
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
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'.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
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...
bool isGlobalDelete() const
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
Copying closure variant of a ctor.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
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]).
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
static Decl::Kind getKind(const Decl *D)
unsigned getNumElements() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
Designator - A designator in a C99 designated initializer.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
A set of overloaded template declarations.
This represents a decl that may have a name.
bool isTranslationUnit() const
bool isOpenCLSpecificType() const
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.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned getTargetAddressSpace(QualType T) const
unsigned getNumTemplateArgs() const
QualType getElementType() const
The global specifier '::'. There is no stored value.
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.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
const LangOptions & getLangOpts() const
The "__interface" keyword introduces the elaborated-type-specifier.
Represents the canonical version of C arrays with a specified constant size.
InitListExpr * getSyntacticForm() const
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
bool hasLinkage() const
Determine whether this declaration has linkage.
Attr - This represents one attribute.
QualType getPointeeType() const
bool isExternallyVisible() const
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
This parameter (which must have pointer type) is a Swift indirect result parameter.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
const IdentifierInfo * getIdentifier() const
Expr * getSizeExpr() const
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.