32 #include "llvm/ADT/StringExtras.h"
33 #include "llvm/Support/ErrorHandling.h"
34 #include "llvm/Support/raw_ostream.h"
36 #define MANGLE_CHECKER 0
42 using namespace clang;
58 = dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
59 return ContextParam->getDeclContext();
63 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
65 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
66 return ContextParam->getDeclContext();
70 if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC)) {
71 return getEffectiveDeclContext(cast<Decl>(DC));
74 if (
const auto *VD = dyn_cast<VarDecl>(D))
76 return VD->getASTContext().getTranslationUnitDecl();
78 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
80 return FD->getASTContext().getTranslationUnitDecl();
86 return getEffectiveDeclContext(cast<Decl>(DC));
89 static bool isLocalContainerContext(
const DeclContext *DC) {
90 return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
96 if (isLocalContainerContext(DC))
97 return dyn_cast<RecordDecl>(D);
99 DC = getEffectiveDeclContext(D);
106 return ftd->getTemplatedDecl();
113 return (fn ? getStructor(fn) :
decl);
116 static bool isLambda(
const NamedDecl *ND) {
124 static const unsigned UnknownArity = ~0U;
127 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
128 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
129 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
139 bool shouldMangleCXXName(
const NamedDecl *D)
override;
140 bool shouldMangleStringLiteral(
const StringLiteral *)
override {
143 void mangleCXXName(
const NamedDecl *D, raw_ostream &)
override;
145 raw_ostream &)
override;
148 raw_ostream &)
override;
149 void mangleReferenceTemporary(
const VarDecl *D,
unsigned ManglingNumber,
150 raw_ostream &)
override;
151 void mangleCXXVTable(
const CXXRecordDecl *RD, raw_ostream &)
override;
152 void mangleCXXVTT(
const CXXRecordDecl *RD, raw_ostream &)
override;
155 void mangleCXXRTTI(
QualType T, raw_ostream &)
override;
156 void mangleCXXRTTIName(
QualType T, raw_ostream &)
override;
157 void mangleTypeName(
QualType T, raw_ostream &)
override;
159 raw_ostream &)
override;
161 raw_ostream &)
override;
165 void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &)
override;
166 void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &Out)
override;
167 void mangleDynamicAtExitDestructor(
const VarDecl *D,
168 raw_ostream &Out)
override;
169 void mangleSEHFilterExpression(
const NamedDecl *EnclosingDecl,
170 raw_ostream &Out)
override;
171 void mangleSEHFinallyBlock(
const NamedDecl *EnclosingDecl,
172 raw_ostream &Out)
override;
173 void mangleItaniumThreadLocalInit(
const VarDecl *D, raw_ostream &)
override;
174 void mangleItaniumThreadLocalWrapper(
const VarDecl *D,
175 raw_ostream &)
override;
177 void mangleStringLiteral(
const StringLiteral *, raw_ostream &)
override;
179 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
185 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
186 if (Tag->getName().empty() && !Tag->getTypedefNameForAnonDecl())
192 unsigned discriminator = getASTContext().getManglingNumber(ND);
193 if (discriminator == 1)
195 disc = discriminator - 2;
200 unsigned &discriminator = Uniquifier[ND];
201 if (!discriminator) {
202 const DeclContext *DC = getEffectiveDeclContext(ND);
203 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
205 if (discriminator == 1)
207 disc = discriminator-2;
214 class CXXNameMangler {
215 ItaniumMangleContextImpl &
Context;
217 bool NullOut =
false;
222 bool DisableDerivedAbiTags =
false;
233 class FunctionTypeDepthState {
236 enum { InResultTypeMask = 1 };
239 FunctionTypeDepthState() : Bits(0) {}
242 unsigned getDepth()
const {
247 bool isInResultType()
const {
248 return Bits & InResultTypeMask;
251 FunctionTypeDepthState push() {
252 FunctionTypeDepthState tmp = *
this;
253 Bits = (Bits & ~InResultTypeMask) + 2;
257 void enterResultType() {
258 Bits |= InResultTypeMask;
261 void leaveResultType() {
262 Bits &= ~InResultTypeMask;
265 void pop(FunctionTypeDepthState saved) {
266 assert(getDepth() == saved.getDepth() + 1);
281 class AbiTagState final {
283 explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
289 AbiTagState(
const AbiTagState &) =
delete;
290 AbiTagState &operator=(
const AbiTagState &) =
delete;
292 ~AbiTagState() { pop(); }
294 void write(raw_ostream &Out,
const NamedDecl *ND,
295 const AbiTagList *AdditionalAbiTags) {
296 ND = cast<NamedDecl>(ND->getCanonicalDecl());
297 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
299 !AdditionalAbiTags &&
300 "only function and variables need a list of additional abi tags");
301 if (
const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
302 if (
const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
303 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
304 AbiTag->tags().end());
312 if (
const auto *AbiTag = ND->getAttr<AbiTagAttr>()) {
313 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
314 AbiTag->tags().end());
315 TagList.insert(TagList.end(), AbiTag->tags().begin(),
316 AbiTag->tags().end());
319 if (AdditionalAbiTags) {
320 UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(),
321 AdditionalAbiTags->end());
322 TagList.insert(TagList.end(), AdditionalAbiTags->begin(),
323 AdditionalAbiTags->end());
326 std::sort(TagList.begin(), TagList.end());
327 TagList.erase(std::unique(TagList.begin(), TagList.end()), TagList.end());
329 writeSortedUniqueAbiTags(Out, TagList);
332 const AbiTagList &getUsedAbiTags()
const {
return UsedAbiTags; }
333 void setUsedAbiTags(
const AbiTagList &AbiTags) {
334 UsedAbiTags = AbiTags;
337 const AbiTagList &getEmittedAbiTags()
const {
338 return EmittedAbiTags;
341 const AbiTagList &getSortedUniqueUsedAbiTags() {
342 std::sort(UsedAbiTags.begin(), UsedAbiTags.end());
343 UsedAbiTags.erase(std::unique(UsedAbiTags.begin(), UsedAbiTags.end()),
350 AbiTagList UsedAbiTags;
352 AbiTagList EmittedAbiTags;
354 AbiTagState *&LinkHead;
355 AbiTagState *Parent =
nullptr;
358 assert(LinkHead ==
this &&
359 "abi tag link head must point to us on destruction");
361 Parent->UsedAbiTags.insert(Parent->UsedAbiTags.end(),
362 UsedAbiTags.begin(), UsedAbiTags.end());
363 Parent->EmittedAbiTags.insert(Parent->EmittedAbiTags.end(),
364 EmittedAbiTags.begin(),
365 EmittedAbiTags.end());
370 void writeSortedUniqueAbiTags(raw_ostream &Out,
const AbiTagList &AbiTags) {
371 for (
const auto &Tag : AbiTags) {
372 EmittedAbiTags.push_back(Tag);
380 AbiTagState *AbiTags =
nullptr;
381 AbiTagState AbiTagsRoot;
383 llvm::DenseMap<uintptr_t, unsigned> Substitutions;
388 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
389 const NamedDecl *D =
nullptr,
bool NullOut_ =
false)
390 :
Context(C), Out(Out_), NullOut(NullOut_), Structor(getStructor(D)),
393 assert(!D || (!isa<CXXDestructorDecl>(D) &&
394 !isa<CXXConstructorDecl>(D)));
396 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
399 SeqID(0), AbiTagsRoot(AbiTags) { }
400 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
403 SeqID(0), AbiTagsRoot(AbiTags) { }
405 CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
406 :
Context(Outer.Context), Out(Out_), NullOut(
false),
407 Structor(Outer.Structor),
StructorType(Outer.StructorType),
408 SeqID(Outer.SeqID), AbiTagsRoot(AbiTags) {}
410 CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
411 :
Context(Outer.Context), Out(Out_), NullOut(
true),
412 Structor(Outer.Structor),
StructorType(Outer.StructorType),
413 SeqID(Outer.SeqID), AbiTagsRoot(AbiTags) {}
417 if (Out.str()[0] ==
'\01')
421 char *result = abi::__cxa_demangle(Out.str().str().c_str(), 0, 0, &status);
422 assert(status == 0 &&
"Could not demangle mangled name!");
426 raw_ostream &getStream() {
return Out; }
428 void disableDerivedAbiTags() { DisableDerivedAbiTags =
true; }
429 static bool shouldHaveAbiTags(ItaniumMangleContextImpl &C,
const VarDecl *VD);
432 void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
433 void mangleNumber(
const llvm::APSInt &
I);
434 void mangleNumber(int64_t Number);
435 void mangleFloat(
const llvm::APFloat &F);
437 void mangleSeqID(
unsigned SeqID);
440 void mangleNameOrStandardSubstitution(
const NamedDecl *ND);
444 bool mangleSubstitution(
const NamedDecl *ND);
445 bool mangleSubstitution(
QualType T);
451 bool mangleStandardSubstitution(
const NamedDecl *ND);
453 void addSubstitution(
const NamedDecl *ND) {
454 ND = cast<NamedDecl>(ND->getCanonicalDecl());
456 addSubstitution(reinterpret_cast<uintptr_t>(ND));
463 bool recursive =
false);
466 unsigned KnownArity = UnknownArity);
468 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
470 void mangleNameWithAbiTags(
const NamedDecl *ND,
471 const AbiTagList *AdditionalAbiTags);
474 unsigned NumTemplateArgs);
475 void mangleUnqualifiedName(
const NamedDecl *ND,
476 const AbiTagList *AdditionalAbiTags) {
477 mangleUnqualifiedName(ND, ND->
getDeclName(), UnknownArity,
482 const AbiTagList *AdditionalAbiTags);
483 void mangleUnscopedName(
const NamedDecl *ND,
484 const AbiTagList *AdditionalAbiTags);
486 const AbiTagList *AdditionalAbiTags);
488 const AbiTagList *AdditionalAbiTags);
490 void mangleSourceNameWithAbiTags(
491 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
492 void mangleLocalName(
const Decl *D,
493 const AbiTagList *AdditionalAbiTags);
494 void mangleBlockForPrefix(
const BlockDecl *Block);
495 void mangleUnqualifiedBlock(
const BlockDecl *Block);
498 const AbiTagList *AdditionalAbiTags,
499 bool NoFunction=
false);
502 unsigned NumTemplateArgs);
504 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
506 void mangleTemplatePrefix(
const TemplateDecl *ND,
bool NoFunction=
false);
508 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
509 StringRef Prefix =
"");
512 void mangleVendorQualifier(StringRef qualifier);
519 #define ABSTRACT_TYPE(CLASS, PARENT)
520 #define NON_CANONICAL_TYPE(CLASS, PARENT)
521 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
522 #include "clang/AST/TypeNodes.def"
524 void mangleType(
const TagType*);
526 static StringRef getCallingConvQualifierName(
CallingConv CC);
531 void mangleNeonVectorType(
const VectorType *T);
532 void mangleAArch64NeonVectorType(
const VectorType *T);
534 void mangleIntegerLiteral(
QualType T,
const llvm::APSInt &
Value);
535 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
536 void mangleMemberExpr(
const Expr *base,
bool isArrow,
540 unsigned knownArity);
541 void mangleCastExpression(
const Expr *
E, StringRef CastEncoding);
542 void mangleInitListElements(
const InitListExpr *InitList);
543 void mangleExpression(
const Expr *
E,
unsigned Arity = UnknownArity);
548 unsigned NumTemplateArgs);
550 unsigned NumTemplateArgs);
554 void mangleTemplateParameter(
unsigned Index);
559 const AbiTagList *AdditionalAbiTags);
562 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
564 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
569 bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
574 if (FD->hasAttr<OverloadableAttr>())
592 if (!getASTContext().getLangOpts().CPlusPlus)
602 const DeclContext *DC = getEffectiveDeclContext(D);
606 DC = getEffectiveParentContext(DC);
608 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
609 !isa<VarTemplateSpecializationDecl>(D))
616 void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
617 const AbiTagList *AdditionalAbiTags) {
618 assert(AbiTags &&
"require AbiTagState");
619 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
622 void CXXNameMangler::mangleSourceNameWithAbiTags(
623 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
625 writeAbiTags(ND, AdditionalAbiTags);
628 void CXXNameMangler::mangle(
const NamedDecl *D) {
634 mangleFunctionEncoding(FD);
635 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
638 mangleName(IFD->getAnonField());
640 mangleName(cast<FieldDecl>(D));
643 void CXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD) {
647 if (!
Context.shouldMangleDeclName(FD)) {
652 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
653 if (ReturnTypeAbiTags.empty()) {
656 mangleFunctionEncodingBareType(FD);
664 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
665 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
667 FunctionEncodingMangler.disableDerivedAbiTags();
668 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
671 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
672 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
676 const AbiTagList &UsedAbiTags =
677 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
678 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
679 AdditionalAbiTags.erase(
680 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
681 UsedAbiTags.begin(), UsedAbiTags.end(),
682 AdditionalAbiTags.begin()),
683 AdditionalAbiTags.end());
686 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
687 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
690 void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
691 if (FD->hasAttr<EnableIfAttr>()) {
692 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
693 Out <<
"Ua9enable_ifI";
696 for (AttrVec::const_reverse_iterator
I = FD->getAttrs().rbegin(),
697 E = FD->getAttrs().rend();
699 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
703 mangleExpression(EIA->getCond());
707 FunctionTypeDepth.pop(Saved);
712 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
713 if (
auto Inherited = CD->getInheritedConstructor())
714 FD = Inherited.getConstructor();
732 bool MangleReturnType =
false;
734 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
735 isa<CXXConversionDecl>(FD)))
736 MangleReturnType =
true;
739 FD = PrimaryTemplate->getTemplatedDecl();
743 MangleReturnType, FD);
747 while (isa<LinkageSpecDecl>(DC)) {
748 DC = getEffectiveParentContext(DC);
757 ->isTranslationUnit())
761 return II && II->
isStr(
"std");
770 return isStd(cast<NamespaceDecl>(DC));
776 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
785 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
786 TemplateArgs = &Spec->getTemplateArgs();
787 return Spec->getSpecializedTemplate();
792 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
793 TemplateArgs = &Spec->getTemplateArgs();
794 return Spec->getSpecializedTemplate();
800 void CXXNameMangler::mangleName(
const NamedDecl *ND) {
801 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
803 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
804 if (VariableTypeAbiTags.empty()) {
806 mangleNameWithAbiTags(VD,
nullptr);
811 llvm::raw_null_ostream NullOutStream;
812 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
813 VariableNameMangler.disableDerivedAbiTags();
814 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
817 const AbiTagList &UsedAbiTags =
818 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
819 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
820 AdditionalAbiTags.erase(
821 std::set_difference(VariableTypeAbiTags.begin(),
822 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
823 UsedAbiTags.end(), AdditionalAbiTags.begin()),
824 AdditionalAbiTags.end());
827 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
829 mangleNameWithAbiTags(ND,
nullptr);
833 void CXXNameMangler::mangleNameWithAbiTags(
const NamedDecl *ND,
834 const AbiTagList *AdditionalAbiTags) {
840 const DeclContext *DC = getEffectiveDeclContext(ND);
846 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
848 DC = getEffectiveParentContext(DC);
849 else if (GetLocalClassDecl(ND)) {
850 mangleLocalName(ND, AdditionalAbiTags);
860 mangleUnscopedTemplateName(TD, AdditionalAbiTags);
861 mangleTemplateArgs(*TemplateArgs);
865 mangleUnscopedName(ND, AdditionalAbiTags);
869 if (isLocalContainerContext(DC)) {
870 mangleLocalName(ND, AdditionalAbiTags);
874 mangleNestedName(ND, DC, AdditionalAbiTags);
877 void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
879 unsigned NumTemplateArgs) {
883 mangleUnscopedTemplateName(TD,
nullptr);
884 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
886 mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
890 void CXXNameMangler::mangleUnscopedName(
const NamedDecl *ND,
891 const AbiTagList *AdditionalAbiTags) {
898 mangleUnqualifiedName(ND, AdditionalAbiTags);
901 void CXXNameMangler::mangleUnscopedTemplateName(
902 const TemplateDecl *ND,
const AbiTagList *AdditionalAbiTags) {
905 if (mangleSubstitution(ND))
909 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
910 assert(!AdditionalAbiTags &&
911 "template template param cannot have abi tags");
912 mangleTemplateParameter(TTP->getIndex());
913 }
else if (isa<BuiltinTemplateDecl>(ND)) {
914 mangleUnscopedName(ND, AdditionalAbiTags);
922 void CXXNameMangler::mangleUnscopedTemplateName(
923 TemplateName Template,
const AbiTagList *AdditionalAbiTags) {
927 return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
929 if (mangleSubstitution(Template))
932 assert(!AdditionalAbiTags &&
933 "dependent template name cannot have abi tags");
936 assert(Dependent &&
"Not a dependent template name?");
938 mangleSourceName(Id);
940 mangleOperatorName(Dependent->
getOperator(), UnknownArity);
942 addSubstitution(Template);
945 void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
959 llvm::APInt valueBits = f.bitcastToAPInt();
960 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
961 assert(numCharacters != 0);
967 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
969 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
972 llvm::integerPart hexDigit
973 = valueBits.getRawData()[digitBitIndex / llvm::integerPartWidth];
974 hexDigit >>= (digitBitIndex % llvm::integerPartWidth);
978 static const char charForHex[16] = {
979 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
980 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'
982 buffer[stringIndex] = charForHex[hexDigit];
985 Out.write(buffer.data(), numCharacters);
988 void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
989 if (Value.isSigned() && Value.isNegative()) {
991 Value.abs().print(Out,
false);
993 Value.print(Out,
false);
997 void CXXNameMangler::mangleNumber(int64_t Number) {
1007 void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) {
1015 mangleNumber(NonVirtual);
1021 mangleNumber(NonVirtual);
1023 mangleNumber(Virtual);
1029 if (!mangleSubstitution(
QualType(TST, 0))) {
1030 mangleTemplatePrefix(TST->getTemplateName());
1035 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
1038 }
else if (
const auto *DTST =
1040 if (!mangleSubstitution(
QualType(DTST, 0))) {
1041 TemplateName Template = getASTContext().getDependentTemplateName(
1042 DTST->getQualifier(), DTST->getIdentifier());
1043 mangleTemplatePrefix(Template);
1048 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1049 addSubstitution(
QualType(DTST, 0));
1079 switch (qualifier->
getKind()) {
1091 llvm_unreachable(
"Can't mangle __super specifier");
1095 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1103 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1120 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1127 if (mangleUnresolvedTypeOrSimpleId(
QualType(type, 0), recursive ?
"N" :
""))
1136 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1156 unsigned knownArity) {
1157 if (qualifier) mangleUnresolvedPrefix(qualifier);
1173 mangleOperatorName(name, knownArity);
1176 llvm_unreachable(
"Can't mangle a constructor name!");
1178 llvm_unreachable(
"Can't mangle a using directive name!");
1182 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1186 void CXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
1188 unsigned KnownArity,
1189 const AbiTagList *AdditionalAbiTags) {
1190 unsigned Arity = KnownArity;
1204 getEffectiveDeclContext(ND)->isFileContext())
1207 mangleSourceName(II);
1208 writeAbiTags(ND, AdditionalAbiTags);
1213 assert(ND &&
"mangling empty name without declaration");
1215 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1216 if (NS->isAnonymousNamespace()) {
1218 Out <<
"12_GLOBAL__N_1";
1223 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1238 &&
"Expected anonymous struct or union!");
1245 assert(FD->getIdentifier() &&
"Data member name isn't an identifier!");
1247 mangleSourceName(FD->getIdentifier());
1258 if (isa<ObjCContainerDecl>(ND))
1262 const TagDecl *TD = cast<TagDecl>(ND);
1264 assert(TD->getDeclContext() == D->getDeclContext() &&
1265 "Typedef should not be in another decl context!");
1267 "Typedef was not named!");
1269 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1272 writeAbiTags(TD,
nullptr);
1280 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
1281 if (Record->isLambda() && Record->getLambdaManglingNumber()) {
1282 assert(!AdditionalAbiTags &&
1283 "Lambda type cannot have additional abi tags");
1284 mangleLambda(Record);
1290 unsigned UnnamedMangle = getASTContext().getManglingNumber(TD);
1292 if (UnnamedMangle > 1)
1293 Out << UnnamedMangle - 2;
1295 writeAbiTags(TD, AdditionalAbiTags);
1301 unsigned AnonStructId = NullOut ? 0 :
Context.getAnonymousStructId(TD);
1308 Str += llvm::utostr(AnonStructId);
1318 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1323 if (
auto Inherited =
1324 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1325 InheritedFrom = Inherited.getConstructor()->
getParent();
1326 InheritedTemplateArgs =
1327 Inherited.getConstructor()->getTemplateSpecializationArgs();
1333 mangleCXXCtorType(static_cast<CXXCtorType>(
StructorType), InheritedFrom);
1341 if (InheritedTemplateArgs)
1342 mangleTemplateArgs(*InheritedTemplateArgs);
1344 writeAbiTags(ND, AdditionalAbiTags);
1352 mangleCXXDtorType(static_cast<CXXDtorType>(
StructorType));
1357 writeAbiTags(ND, AdditionalAbiTags);
1361 if (ND && Arity == UnknownArity) {
1362 Arity = cast<FunctionDecl>(ND)->getNumParams();
1365 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1366 if (!MD->isStatic())
1372 mangleOperatorName(Name, Arity);
1373 writeAbiTags(ND, AdditionalAbiTags);
1377 llvm_unreachable(
"Can't mangle a using directive name!");
1381 void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1388 void CXXNameMangler::mangleNestedName(
const NamedDecl *ND,
1390 const AbiTagList *AdditionalAbiTags,
1398 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1404 mangleQualifiers(MethodQuals);
1405 mangleRefQualifier(Method->getRefQualifier());
1411 mangleTemplatePrefix(TD, NoFunction);
1412 mangleTemplateArgs(*TemplateArgs);
1415 manglePrefix(DC, NoFunction);
1416 mangleUnqualifiedName(ND, AdditionalAbiTags);
1421 void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1423 unsigned NumTemplateArgs) {
1428 mangleTemplatePrefix(TD);
1429 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1434 void CXXNameMangler::mangleLocalName(
const Decl *D,
1435 const AbiTagList *AdditionalAbiTags) {
1441 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1443 const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
1448 AbiTagState LocalAbiTags(AbiTags);
1451 mangleObjCMethodName(MD);
1452 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1453 mangleBlockForPrefix(BD);
1455 mangleFunctionEncoding(cast<FunctionDecl>(DC));
1459 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1478 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1480 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1482 mangleNumber(Num - 2);
1491 mangleUnqualifiedName(RD, AdditionalAbiTags);
1492 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1493 manglePrefix(getEffectiveDeclContext(BD),
true );
1494 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1495 mangleUnqualifiedBlock(BD);
1497 const NamedDecl *ND = cast<NamedDecl>(D);
1498 mangleNestedName(ND, getEffectiveDeclContext(ND), AdditionalAbiTags,
1501 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1505 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1507 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1509 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1511 mangleNumber(Num - 2);
1516 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1517 mangleUnqualifiedBlock(BD);
1519 mangleUnqualifiedName(cast<NamedDecl>(D), AdditionalAbiTags);
1522 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1524 if (
Context.getNextDiscriminator(ND, disc)) {
1528 Out <<
"__" << disc <<
'_';
1533 void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *Block) {
1534 if (GetLocalClassDecl(Block)) {
1535 mangleLocalName(Block,
nullptr);
1538 const DeclContext *DC = getEffectiveDeclContext(Block);
1539 if (isLocalContainerContext(DC)) {
1540 mangleLocalName(Block,
nullptr);
1543 manglePrefix(getEffectiveDeclContext(Block));
1544 mangleUnqualifiedBlock(Block);
1547 void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *Block) {
1550 Context->getDeclContext()->isRecord()) {
1551 const auto *ND = cast<NamedDecl>(
Context);
1553 mangleSourceNameWithAbiTags(ND);
1564 Number =
Context.getBlockId(Block,
false);
1571 void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
1583 Context->getDeclContext()->isRecord()) {
1585 = cast<NamedDecl>(
Context)->getIdentifier()) {
1586 mangleSourceName(Name);
1594 getAs<FunctionProtoType>();
1595 mangleBareFunctionType(Proto,
false,
1605 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
1607 mangleNumber(Number - 2);
1612 switch (qualifier->
getKind()) {
1618 llvm_unreachable(
"Can't mangle __super specifier");
1643 llvm_unreachable(
"unexpected nested name specifier");
1646 void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
1658 if (NoFunction && isLocalContainerContext(DC))
1661 assert(!isLocalContainerContext(DC));
1663 const NamedDecl *ND = cast<NamedDecl>(DC);
1664 if (mangleSubstitution(ND))
1670 mangleTemplatePrefix(TD);
1671 mangleTemplateArgs(*TemplateArgs);
1673 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1674 mangleUnqualifiedName(ND,
nullptr);
1677 addSubstitution(ND);
1680 void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
1685 return mangleTemplatePrefix(TD);
1688 manglePrefix(Qualified->getQualifier());
1692 mangleUnqualifiedName(
nullptr, (*Overloaded->begin())->getDeclName(),
1693 UnknownArity,
nullptr);
1698 assert(Dependent &&
"Unknown template name kind?");
1700 manglePrefix(Qualifier);
1701 mangleUnscopedTemplateName(Template,
nullptr);
1704 void CXXNameMangler::mangleTemplatePrefix(
const TemplateDecl *ND,
1712 if (mangleSubstitution(ND))
1716 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1717 mangleTemplateParameter(TTP->getIndex());
1719 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1720 if (isa<BuiltinTemplateDecl>(ND))
1721 mangleUnqualifiedName(ND,
nullptr);
1726 addSubstitution(ND);
1735 if (mangleSubstitution(TN))
1750 if (isa<TemplateTemplateParmDecl>(TD))
1751 mangleTemplateParameter(cast<TemplateTemplateParmDecl>(TD)->getIndex());
1757 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
1786 Out <<
"_SUBSTPACK_";
1791 addSubstitution(TN);
1794 bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
1800 case Type::Adjusted:
1803 case Type::BlockPointer:
1804 case Type::LValueReference:
1805 case Type::RValueReference:
1806 case Type::MemberPointer:
1807 case Type::ConstantArray:
1808 case Type::IncompleteArray:
1809 case Type::VariableArray:
1810 case Type::DependentSizedArray:
1811 case Type::DependentSizedExtVector:
1813 case Type::ExtVector:
1814 case Type::FunctionProto:
1815 case Type::FunctionNoProto:
1817 case Type::Attributed:
1819 case Type::PackExpansion:
1820 case Type::ObjCObject:
1821 case Type::ObjCInterface:
1822 case Type::ObjCObjectPointer:
1825 llvm_unreachable(
"type is illegal as a nested name specifier");
1827 case Type::SubstTemplateTypeParmPack:
1832 Out <<
"_SUBSTPACK_";
1839 case Type::TypeOfExpr:
1841 case Type::Decltype:
1842 case Type::TemplateTypeParm:
1843 case Type::UnaryTransform:
1844 case Type::SubstTemplateTypeParm:
1858 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
1861 case Type::UnresolvedUsing:
1862 mangleSourceNameWithAbiTags(
1863 cast<UnresolvedUsingType>(Ty)->getDecl());
1868 mangleSourceNameWithAbiTags(cast<TagType>(Ty)->getDecl());
1871 case Type::TemplateSpecialization: {
1873 cast<TemplateSpecializationType>(Ty);
1875 switch (TN.getKind()) {
1882 assert(TD &&
"no template for template specialization type");
1883 if (isa<TemplateTemplateParmDecl>(TD))
1884 goto unresolvedType;
1886 mangleSourceNameWithAbiTags(TD);
1892 llvm_unreachable(
"invalid base for a template specialization type");
1906 Out <<
"_SUBSTPACK_";
1911 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
1915 case Type::InjectedClassName:
1916 mangleSourceNameWithAbiTags(
1917 cast<InjectedClassNameType>(Ty)->getDecl());
1920 case Type::DependentName:
1921 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
1924 case Type::DependentTemplateSpecialization: {
1926 cast<DependentTemplateSpecializationType>(Ty);
1927 mangleSourceName(DTST->getIdentifier());
1928 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1932 case Type::Elaborated:
1933 return mangleUnresolvedTypeOrSimpleId(
1934 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
1940 void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
1949 llvm_unreachable(
"Not an operator name");
1972 case OO_New: Out <<
"nw";
break;
1974 case OO_Array_New: Out <<
"na";
break;
1976 case OO_Delete: Out <<
"dl";
break;
1978 case OO_Array_Delete: Out <<
"da";
break;
1982 Out << (Arity == 1?
"ps" :
"pl");
break;
1986 Out << (Arity == 1?
"ng" :
"mi");
break;
1990 Out << (Arity == 1?
"ad" :
"an");
break;
1995 Out << (Arity == 1?
"de" :
"ml");
break;
1997 case OO_Tilde: Out <<
"co";
break;
1999 case OO_Slash: Out <<
"dv";
break;
2001 case OO_Percent: Out <<
"rm";
break;
2003 case OO_Pipe: Out <<
"or";
break;
2005 case OO_Caret: Out <<
"eo";
break;
2007 case OO_Equal: Out <<
"aS";
break;
2009 case OO_PlusEqual: Out <<
"pL";
break;
2011 case OO_MinusEqual: Out <<
"mI";
break;
2013 case OO_StarEqual: Out <<
"mL";
break;
2015 case OO_SlashEqual: Out <<
"dV";
break;
2017 case OO_PercentEqual: Out <<
"rM";
break;
2019 case OO_AmpEqual: Out <<
"aN";
break;
2021 case OO_PipeEqual: Out <<
"oR";
break;
2023 case OO_CaretEqual: Out <<
"eO";
break;
2025 case OO_LessLess: Out <<
"ls";
break;
2027 case OO_GreaterGreater: Out <<
"rs";
break;
2029 case OO_LessLessEqual: Out <<
"lS";
break;
2031 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2033 case OO_EqualEqual: Out <<
"eq";
break;
2035 case OO_ExclaimEqual: Out <<
"ne";
break;
2037 case OO_Less: Out <<
"lt";
break;
2039 case OO_Greater: Out <<
"gt";
break;
2041 case OO_LessEqual: Out <<
"le";
break;
2043 case OO_GreaterEqual: Out <<
"ge";
break;
2045 case OO_Exclaim: Out <<
"nt";
break;
2047 case OO_AmpAmp: Out <<
"aa";
break;
2049 case OO_PipePipe: Out <<
"oo";
break;
2051 case OO_PlusPlus: Out <<
"pp";
break;
2053 case OO_MinusMinus: Out <<
"mm";
break;
2055 case OO_Comma: Out <<
"cm";
break;
2057 case OO_ArrowStar: Out <<
"pm";
break;
2059 case OO_Arrow: Out <<
"pt";
break;
2061 case OO_Call: Out <<
"cl";
break;
2063 case OO_Subscript: Out <<
"ix";
break;
2068 case OO_Conditional: Out <<
"qu";
break;
2071 case OO_Coawait: Out <<
"aw";
break;
2075 llvm_unreachable(
"Not an overloaded operator");
2079 void CXXNameMangler::mangleQualifiers(
Qualifiers Quals) {
2096 ASString =
"AS" + llvm::utostr(TargetAS);
2099 default: llvm_unreachable(
"Not a language specific address space");
2110 mangleVendorQualifier(ASString);
2124 mangleVendorQualifier(
"__weak");
2128 mangleVendorQualifier(
"__strong");
2132 mangleVendorQualifier(
"__autoreleasing");
2155 void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2156 Out <<
'U' << name.size() << name;
2162 switch (RefQualifier) {
2176 void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2177 Context.mangleObjCMethodName(MD, Out);
2193 void CXXNameMangler::mangleType(
QualType T) {
2218 = dyn_cast<TemplateSpecializationType>(T))
2219 if (!TST->isTypeAlias())
2232 const Type *ty = split.
Ty;
2235 if (isSubstitutable && mangleSubstitution(T))
2240 if (quals && isa<ArrayType>(T)) {
2249 mangleQualifiers(quals);
2255 #define ABSTRACT_TYPE(CLASS, PARENT)
2256 #define NON_CANONICAL_TYPE(CLASS, PARENT) \
2258 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
2260 #define TYPE(CLASS, PARENT) \
2262 mangleType(static_cast<const CLASS##Type*>(ty)); \
2264 #include "clang/AST/TypeNodes.def"
2269 if (isSubstitutable)
2273 void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
2274 if (!mangleStandardSubstitution(ND))
2278 void CXXNameMangler::mangleType(
const BuiltinType *T) {
2308 std::string type_name;
2310 case BuiltinType::Void:
2313 case BuiltinType::Bool:
2316 case BuiltinType::Char_U:
2317 case BuiltinType::Char_S:
2320 case BuiltinType::UChar:
2323 case BuiltinType::UShort:
2326 case BuiltinType::UInt:
2329 case BuiltinType::ULong:
2332 case BuiltinType::ULongLong:
2335 case BuiltinType::UInt128:
2338 case BuiltinType::SChar:
2341 case BuiltinType::WChar_S:
2342 case BuiltinType::WChar_U:
2345 case BuiltinType::Char16:
2348 case BuiltinType::Char32:
2351 case BuiltinType::Short:
2354 case BuiltinType::Int:
2357 case BuiltinType::Long:
2360 case BuiltinType::LongLong:
2363 case BuiltinType::Int128:
2366 case BuiltinType::Half:
2369 case BuiltinType::Float:
2372 case BuiltinType::Double:
2375 case BuiltinType::LongDouble:
2376 Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
2380 case BuiltinType::Float128:
2381 if (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble())
2382 Out <<
"U10__float128";
2386 case BuiltinType::NullPtr:
2390 #define BUILTIN_TYPE(Id, SingletonId)
2391 #define PLACEHOLDER_TYPE(Id, SingletonId) \
2392 case BuiltinType::Id:
2393 #include "clang/AST/BuiltinTypes.def"
2394 case BuiltinType::Dependent:
2396 llvm_unreachable(
"mangling a placeholder type");
2398 case BuiltinType::ObjCId:
2399 Out <<
"11objc_object";
2401 case BuiltinType::ObjCClass:
2402 Out <<
"10objc_class";
2404 case BuiltinType::ObjCSel:
2405 Out <<
"13objc_selector";
2407 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2408 case BuiltinType::Id: \
2409 type_name = "ocl_" #ImgType "_" #Suffix; \
2410 Out << type_name.size() << type_name; \
2412 #include "clang/Basic/OpenCLImageTypes.def"
2413 case BuiltinType::OCLSampler:
2414 Out <<
"11ocl_sampler";
2416 case BuiltinType::OCLEvent:
2417 Out <<
"9ocl_event";
2419 case BuiltinType::OCLClkEvent:
2420 Out <<
"12ocl_clkevent";
2422 case BuiltinType::OCLQueue:
2423 Out <<
"9ocl_queue";
2425 case BuiltinType::OCLNDRange:
2426 Out <<
"11ocl_ndrange";
2428 case BuiltinType::OCLReserveID:
2429 Out <<
"13ocl_reserveid";
2434 StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
2459 llvm_unreachable(
"bad calling convention");
2462 void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *T) {
2471 StringRef CCQualifier = getCallingConvQualifierName(T->
getExtInfo().
getCC());
2472 if (!CCQualifier.empty())
2473 mangleVendorQualifier(CCQualifier);
2499 mangleVendorQualifier(
"ns_consumed");
2506 mangleExtFunctionInfo(T);
2516 mangleBareFunctionType(T,
true);
2530 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2532 FunctionTypeDepth.enterResultType();
2534 FunctionTypeDepth.leaveResultType();
2536 FunctionTypeDepth.pop(saved);
2541 bool MangleReturnType,
2545 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2548 if (MangleReturnType) {
2549 FunctionTypeDepth.enterResultType();
2553 mangleVendorQualifier(
"ns_returns_retained");
2558 auto SplitReturnTy = ReturnTy.
split();
2560 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
2562 mangleType(ReturnTy);
2564 FunctionTypeDepth.leaveResultType();
2571 FunctionTypeDepth.pop(saved);
2589 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
2590 Out <<
"U17pass_object_size" <<
Attr->getType();
2595 FunctionTypeDepth.pop(saved);
2610 void CXXNameMangler::mangleType(
const EnumType *T) {
2611 mangleType(static_cast<const TagType*>(T));
2613 void CXXNameMangler::mangleType(
const RecordType *T) {
2614 mangleType(static_cast<const TagType*>(T));
2616 void CXXNameMangler::mangleType(
const TagType *T) {
2624 Out <<
'A' << T->
getSize() <<
'_';
2673 mangleType(PointeeType);
2678 mangleTemplateParameter(T->
getIndex());
2687 Out <<
"_SUBSTPACK_";
2691 void CXXNameMangler::mangleType(
const PointerType *T) {
2713 void CXXNameMangler::mangleType(
const ComplexType *T) {
2721 void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
2723 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2724 const char *EltName =
nullptr;
2726 switch (cast<BuiltinType>(EltType)->getKind()) {
2727 case BuiltinType::SChar:
2728 case BuiltinType::UChar:
2729 EltName =
"poly8_t";
2731 case BuiltinType::Short:
2732 case BuiltinType::UShort:
2733 EltName =
"poly16_t";
2735 case BuiltinType::ULongLong:
2736 EltName =
"poly64_t";
2738 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
2741 switch (cast<BuiltinType>(EltType)->
getKind()) {
2742 case BuiltinType::SChar: EltName =
"int8_t";
break;
2743 case BuiltinType::UChar: EltName =
"uint8_t";
break;
2744 case BuiltinType::Short: EltName =
"int16_t";
break;
2745 case BuiltinType::UShort: EltName =
"uint16_t";
break;
2746 case BuiltinType::Int: EltName =
"int32_t";
break;
2747 case BuiltinType::UInt: EltName =
"uint32_t";
break;
2748 case BuiltinType::LongLong: EltName =
"int64_t";
break;
2749 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
2750 case BuiltinType::Double: EltName =
"float64_t";
break;
2751 case BuiltinType::Float: EltName =
"float32_t";
break;
2752 case BuiltinType::Half: EltName =
"float16_t";
break;
2754 llvm_unreachable(
"unexpected Neon vector element type");
2757 const char *BaseName =
nullptr;
2759 getASTContext().getTypeSize(EltType));
2761 BaseName =
"__simd64_";
2763 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
2764 BaseName =
"__simd128_";
2766 Out << strlen(BaseName) + strlen(EltName);
2767 Out << BaseName << EltName;
2772 case BuiltinType::SChar:
2774 case BuiltinType::Short:
2776 case BuiltinType::Int:
2778 case BuiltinType::Long:
2779 case BuiltinType::LongLong:
2781 case BuiltinType::UChar:
2783 case BuiltinType::UShort:
2785 case BuiltinType::UInt:
2787 case BuiltinType::ULong:
2788 case BuiltinType::ULongLong:
2790 case BuiltinType::Half:
2792 case BuiltinType::Float:
2794 case BuiltinType::Double:
2797 llvm_unreachable(
"Unexpected vector element base type");
2804 void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
2806 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2811 assert((BitSize == 64 || BitSize == 128) &&
2812 "Neon vector type not 64 or 128 bits");
2816 switch (cast<BuiltinType>(EltType)->getKind()) {
2817 case BuiltinType::UChar:
2820 case BuiltinType::UShort:
2823 case BuiltinType::ULong:
2824 case BuiltinType::ULongLong:
2828 llvm_unreachable(
"unexpected Neon polynomial vector element type");
2833 std::string TypeName =
2834 (
"__" + EltName +
"x" + Twine(T->
getNumElements()) +
"_t").str();
2835 Out << TypeName.length() << TypeName;
2846 void CXXNameMangler::mangleType(
const VectorType *T) {
2849 llvm::Triple Target = getASTContext().getTargetInfo().getTriple();
2850 llvm::Triple::ArchType Arch =
2851 getASTContext().getTargetInfo().getTriple().getArch();
2852 if ((Arch == llvm::Triple::aarch64 ||
2853 Arch == llvm::Triple::aarch64_be) && !Target.isOSDarwin())
2854 mangleAArch64NeonVectorType(T);
2856 mangleNeonVectorType(T);
2868 mangleType(static_cast<const VectorType*>(T));
2890 Out <<
"U8__kindof";
2895 llvm::raw_svector_ostream QualOS(QualStr);
2896 QualOS <<
"objcproto";
2897 for (
const auto *I : T->
quals()) {
2898 StringRef name = I->getName();
2899 QualOS << name.size() << name;
2901 Out <<
'U' << QualStr.size() << QualStr;
2910 mangleType(typeArg);
2916 Out <<
"U13block_pointer";
2928 if (
TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl()) {
2929 mangleTemplateName(TD, T->getArgs(), T->getNumArgs());
2931 if (mangleSubstitution(
QualType(T, 0)))
2934 mangleTemplatePrefix(T->getTemplateName());
2939 mangleTemplateArgs(T->getArgs(), T->getNumArgs());
2970 llvm_unreachable(
"unexpected keyword for dependent type name");
2985 getASTContext().getDependentTemplateName(T->getQualifier(),
2986 T->getIdentifier());
2987 mangleTemplatePrefix(Prefix);
2992 mangleTemplateArgs(T->getArgs(), T->getNumArgs());
2996 void CXXNameMangler::mangleType(
const TypeOfType *T) {
3008 void CXXNameMangler::mangleType(
const DecltypeType *T) {
3019 if (isa<DeclRefExpr>(E) ||
3020 isa<MemberExpr>(E) ||
3021 isa<UnresolvedLookupExpr>(E) ||
3022 isa<DependentScopeDeclRefExpr>(E) ||
3023 isa<CXXDependentScopeMemberExpr>(E) ||
3024 isa<UnresolvedMemberExpr>(E))
3028 mangleExpression(E);
3048 void CXXNameMangler::mangleType(
const AutoType *T) {
3053 "shouldn't need to mangle __auto_type!");
3059 void CXXNameMangler::mangleType(
const AtomicType *T) {
3066 void CXXNameMangler::mangleType(
const PipeType *T) {
3073 void CXXNameMangler::mangleIntegerLiteral(
QualType T,
3074 const llvm::APSInt &Value) {
3081 Out << (Value.getBoolValue() ?
'1' :
'0');
3083 mangleNumber(Value);
3089 void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
3092 if (!RT->getDecl()->isAnonymousStructOrUnion())
3097 Base = ME->getBase();
3098 IsArrow = ME->isArrow();
3107 Out << (IsArrow ?
"pt" :
"dt");
3108 mangleExpression(Base);
3113 void CXXNameMangler::mangleMemberExpr(
const Expr *base,
3122 mangleMemberExprBase(base, isArrow);
3123 mangleUnresolvedName(qualifier, member, arity);
3136 if (callee == fn)
return false;
3140 if (!lookup)
return false;
3157 void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
3159 Out << CastEncoding;
3164 void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
3166 InitList = Syntactic;
3167 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
3168 mangleExpression(InitList->
getInit(i));
3171 void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity) {
3195 QualType ImplicitlyConvertedToType;
3198 switch (E->getStmtClass()) {
3199 case Expr::NoStmtClass:
3200 #define ABSTRACT_STMT(Type)
3201 #define EXPR(Type, Base)
3202 #define STMT(Type, Base) \
3203 case Expr::Type##Class:
3204 #include "clang/AST/StmtNodes.inc"
3209 case Expr::AddrLabelExprClass:
3210 case Expr::DesignatedInitUpdateExprClass:
3211 case Expr::ImplicitValueInitExprClass:
3212 case Expr::NoInitExprClass:
3213 case Expr::ParenListExprClass:
3214 case Expr::LambdaExprClass:
3215 case Expr::MSPropertyRefExprClass:
3216 case Expr::MSPropertySubscriptExprClass:
3217 case Expr::TypoExprClass:
3218 case Expr::OMPArraySectionExprClass:
3219 case Expr::CXXInheritedCtorInitExprClass:
3220 llvm_unreachable(
"unexpected statement kind");
3223 case Expr::BlockExprClass:
3224 case Expr::ChooseExprClass:
3225 case Expr::CompoundLiteralExprClass:
3226 case Expr::DesignatedInitExprClass:
3227 case Expr::ExtVectorElementExprClass:
3228 case Expr::GenericSelectionExprClass:
3229 case Expr::ObjCEncodeExprClass:
3230 case Expr::ObjCIsaExprClass:
3231 case Expr::ObjCIvarRefExprClass:
3232 case Expr::ObjCMessageExprClass:
3233 case Expr::ObjCPropertyRefExprClass:
3234 case Expr::ObjCProtocolExprClass:
3235 case Expr::ObjCSelectorExprClass:
3236 case Expr::ObjCStringLiteralClass:
3237 case Expr::ObjCBoxedExprClass:
3238 case Expr::ObjCArrayLiteralClass:
3239 case Expr::ObjCDictionaryLiteralClass:
3240 case Expr::ObjCSubscriptRefExprClass:
3241 case Expr::ObjCIndirectCopyRestoreExprClass:
3242 case Expr::ObjCAvailabilityCheckExprClass:
3243 case Expr::OffsetOfExprClass:
3244 case Expr::PredefinedExprClass:
3245 case Expr::ShuffleVectorExprClass:
3246 case Expr::ConvertVectorExprClass:
3247 case Expr::StmtExprClass:
3248 case Expr::TypeTraitExprClass:
3249 case Expr::ArrayTypeTraitExprClass:
3250 case Expr::ExpressionTraitExprClass:
3251 case Expr::VAArgExprClass:
3252 case Expr::CUDAKernelCallExprClass:
3253 case Expr::AsTypeExprClass:
3254 case Expr::PseudoObjectExprClass:
3255 case Expr::AtomicExprClass:
3261 "cannot yet mangle expression type %0");
3263 << E->getStmtClassName() << E->getSourceRange();
3268 case Expr::CXXUuidofExprClass: {
3272 Out <<
"u8__uuidoft";
3276 Out <<
"u8__uuidofz";
3277 mangleExpression(UuidExp, Arity);
3283 case Expr::BinaryConditionalOperatorClass: {
3287 "?: operator with omitted middle operand cannot be mangled");
3289 << E->getStmtClassName() << E->getSourceRange();
3294 case Expr::OpaqueValueExprClass:
3295 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
3297 case Expr::InitListExprClass: {
3299 mangleInitListElements(cast<InitListExpr>(E));
3304 case Expr::CXXDefaultArgExprClass:
3305 mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
3308 case Expr::CXXDefaultInitExprClass:
3309 mangleExpression(cast<CXXDefaultInitExpr>(E)->getExpr(), Arity);
3312 case Expr::CXXStdInitializerListExprClass:
3313 mangleExpression(cast<CXXStdInitializerListExpr>(E)->getSubExpr(), Arity);
3316 case Expr::SubstNonTypeTemplateParmExprClass:
3317 mangleExpression(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
3321 case Expr::UserDefinedLiteralClass:
3324 case Expr::CXXMemberCallExprClass:
3325 case Expr::CallExprClass: {
3345 if (isa<PackExpansionExpr>(Arg))
3346 CallArity = UnknownArity;
3348 mangleExpression(CE->
getCallee(), CallArity);
3350 mangleExpression(Arg);
3355 case Expr::CXXNewExprClass: {
3358 Out << (New->
isArray() ?
"na" :
"nw");
3361 mangleExpression(*I);
3375 mangleExpression(*I);
3376 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
3377 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
3378 mangleExpression(PLE->getExpr(i));
3380 isa<InitListExpr>(Init)) {
3382 mangleInitListElements(cast<InitListExpr>(Init));
3384 mangleExpression(Init);
3390 case Expr::CXXPseudoDestructorExprClass: {
3391 const auto *PDE = cast<CXXPseudoDestructorExpr>(
E);
3392 if (
const Expr *Base = PDE->getBase())
3393 mangleMemberExprBase(Base, PDE->isArrow());
3398 mangleUnresolvedPrefix(Qualifier,
3400 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
3404 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
3407 }
else if (Qualifier) {
3408 mangleUnresolvedPrefix(Qualifier);
3412 QualType DestroyedType = PDE->getDestroyedType();
3413 mangleUnresolvedTypeOrSimpleId(DestroyedType);
3417 case Expr::MemberExprClass: {
3425 case Expr::UnresolvedMemberExprClass: {
3435 case Expr::CXXDependentScopeMemberExprClass: {
3437 = cast<CXXDependentScopeMemberExpr>(
E);
3447 case Expr::UnresolvedLookupExprClass: {
3459 case Expr::CXXUnresolvedConstructExprClass: {
3465 if (N != 1) Out <<
'_';
3466 for (
unsigned I = 0; I != N; ++
I) mangleExpression(CE->
getArg(I));
3467 if (N != 1) Out <<
'E';
3471 case Expr::CXXConstructExprClass: {
3472 const auto *CE = cast<CXXConstructExpr>(
E);
3473 if (!CE->isListInitialization() || CE->isStdInitListInitialization()) {
3475 CE->getNumArgs() >= 1 &&
3476 (CE->getNumArgs() == 1 || isa<CXXDefaultArgExpr>(CE->
getArg(1))) &&
3477 "implicit CXXConstructExpr must have one argument");
3478 return mangleExpression(cast<CXXConstructExpr>(E)->
getArg(0));
3481 for (
auto *E : CE->arguments())
3482 mangleExpression(E);
3487 case Expr::CXXTemporaryObjectExprClass: {
3488 const auto *CE = cast<CXXTemporaryObjectExpr>(
E);
3489 unsigned N = CE->getNumArgs();
3490 bool List = CE->isListInitialization();
3497 if (!List && N != 1)
3499 if (CE->isStdInitListInitialization()) {
3505 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
3506 mangleInitListElements(ILE);
3508 for (
auto *E : CE->arguments())
3509 mangleExpression(E);
3516 case Expr::CXXScalarValueInitExprClass:
3522 case Expr::CXXNoexceptExprClass:
3524 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
3527 case Expr::UnaryExprOrTypeTraitExprClass: {
3541 : ImplicitlyConvertedToType;
3543 mangleIntegerLiteral(T, V);
3557 "cannot yet mangle vec_step expression");
3565 "cannot yet mangle __builtin_omp_required_simd_align expression");
3579 case Expr::CXXThrowExprClass: {
3592 case Expr::CXXTypeidExprClass: {
3606 case Expr::CXXDeleteExprClass: {
3616 case Expr::UnaryOperatorClass: {
3624 case Expr::ArraySubscriptExprClass: {
3630 mangleExpression(AE->
getLHS());
3631 mangleExpression(AE->
getRHS());
3635 case Expr::CompoundAssignOperatorClass:
3636 case Expr::BinaryOperatorClass: {
3643 mangleExpression(BO->
getLHS());
3644 mangleExpression(BO->
getRHS());
3648 case Expr::ConditionalOperatorClass: {
3650 mangleOperatorName(OO_Conditional, 3);
3651 mangleExpression(CO->
getCond());
3652 mangleExpression(CO->
getLHS(), Arity);
3653 mangleExpression(CO->
getRHS(), Arity);
3657 case Expr::ImplicitCastExprClass: {
3658 ImplicitlyConvertedToType = E->
getType();
3659 E = cast<ImplicitCastExpr>(
E)->getSubExpr();
3663 case Expr::ObjCBridgedCastExprClass: {
3666 StringRef
Kind = cast<ObjCBridgedCastExpr>(
E)->getBridgeKindName();
3667 Out <<
"v1U" << Kind.size() <<
Kind;
3671 case Expr::CStyleCastExprClass:
3672 mangleCastExpression(E,
"cv");
3675 case Expr::CXXFunctionalCastExprClass: {
3676 auto *Sub = cast<ExplicitCastExpr>(
E)->getSubExpr()->IgnoreImplicit();
3678 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
3679 if (CCE->getParenOrBraceRange().isInvalid())
3680 Sub = CCE->getArg(0)->IgnoreImplicit();
3681 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
3682 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
3683 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
3686 mangleInitListElements(IL);
3689 mangleCastExpression(E,
"cv");
3694 case Expr::CXXStaticCastExprClass:
3695 mangleCastExpression(E,
"sc");
3697 case Expr::CXXDynamicCastExprClass:
3698 mangleCastExpression(E,
"dc");
3700 case Expr::CXXReinterpretCastExprClass:
3701 mangleCastExpression(E,
"rc");
3703 case Expr::CXXConstCastExprClass:
3704 mangleCastExpression(E,
"cc");
3707 case Expr::CXXOperatorCallExprClass: {
3712 for (
unsigned i = 0; i !=
NumArgs; ++i)
3713 mangleExpression(CE->
getArg(i));
3717 case Expr::ParenExprClass:
3718 mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
3721 case Expr::DeclRefExprClass: {
3722 const NamedDecl *D = cast<DeclRefExpr>(
E)->getDecl();
3724 switch (D->getKind()) {
3733 mangleFunctionParam(cast<ParmVarDecl>(D));
3736 case Decl::EnumConstant: {
3742 case Decl::NonTypeTemplateParm: {
3744 mangleTemplateParameter(PD->
getIndex());
3753 case Expr::SubstNonTypeTemplateParmPackExprClass:
3758 Out <<
"_SUBSTPACK_";
3761 case Expr::FunctionParmPackExprClass: {
3764 Out <<
"v110_SUBSTPACK";
3769 case Expr::DependentScopeDeclRefExprClass: {
3781 case Expr::CXXBindTemporaryExprClass:
3782 mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
3785 case Expr::ExprWithCleanupsClass:
3786 mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
3789 case Expr::FloatingLiteralClass: {
3798 case Expr::CharacterLiteralClass:
3801 Out << cast<CharacterLiteral>(
E)->
getValue();
3806 case Expr::ObjCBoolLiteralExprClass:
3808 Out << (cast<ObjCBoolLiteralExpr>(
E)->
getValue() ?
'1' :
'0');
3812 case Expr::CXXBoolLiteralExprClass:
3814 Out << (cast<CXXBoolLiteralExpr>(
E)->
getValue() ?
'1' :
'0');
3818 case Expr::IntegerLiteralClass: {
3821 Value.setIsSigned(
true);
3826 case Expr::ImaginaryLiteralClass: {
3833 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
3835 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
3837 mangleFloat(Imag->getValue());
3842 Value.setIsSigned(
true);
3843 mangleNumber(Value);
3849 case Expr::StringLiteralClass: {
3852 assert(isa<ConstantArrayType>(E->
getType()));
3858 case Expr::GNUNullExprClass:
3862 case Expr::CXXNullPtrLiteralExprClass: {
3867 case Expr::PackExpansionExprClass:
3869 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
3872 case Expr::SizeOfPackExprClass: {
3873 auto *SPE = cast<SizeOfPackExpr>(
E);
3874 if (SPE->isPartiallySubstituted()) {
3876 for (
const auto &A : SPE->getPartialArguments())
3877 mangleTemplateArg(A);
3885 mangleTemplateParameter(TTP->getIndex());
3887 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
3888 mangleTemplateParameter(NTTP->getIndex());
3890 = dyn_cast<TemplateTemplateParmDecl>(Pack))
3891 mangleTemplateParameter(TempTP->getIndex());
3893 mangleFunctionParam(cast<ParmVarDecl>(Pack));
3897 case Expr::MaterializeTemporaryExprClass: {
3898 mangleExpression(cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr());
3902 case Expr::CXXFoldExprClass: {
3903 auto *FE = cast<CXXFoldExpr>(
E);
3904 if (FE->isLeftFold())
3905 Out << (FE->getInit() ?
"fL" :
"fl");
3907 Out << (FE->getInit() ?
"fR" :
"fr");
3909 if (FE->getOperator() == BO_PtrMemD)
3917 mangleExpression(FE->getLHS());
3919 mangleExpression(FE->getRHS());
3923 case Expr::CXXThisExprClass:
3927 case Expr::CoawaitExprClass:
3929 Out <<
"v18co_await";
3930 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
3933 case Expr::CoyieldExprClass:
3935 Out <<
"v18co_yield";
3936 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
3969 void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
3976 assert(parmDepth < FunctionTypeDepth.getDepth());
3977 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
3978 if (FunctionTypeDepth.isInResultType())
3981 if (nestingDepth == 0) {
3984 Out <<
"fL" << (nestingDepth - 1) <<
'p';
3992 &&
"parameter's type is still an array type?");
3996 if (parmIndex != 0) {
3997 Out << (parmIndex - 1);
4002 void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T,
4025 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
4028 mangleName(InheritedFrom);
4031 void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
4054 unsigned NumTemplateArgs) {
4057 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4058 mangleTemplateArg(TemplateArgs[i].getArgument());
4065 for (
unsigned i = 0, e = AL.
size(); i != e; ++i)
4066 mangleTemplateArg(AL[i]);
4070 void CXXNameMangler::mangleTemplateArgs(
const TemplateArgument *TemplateArgs,
4071 unsigned NumTemplateArgs) {
4074 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4075 mangleTemplateArg(TemplateArgs[i]);
4089 llvm_unreachable(
"Cannot mangle NULL template argument");
4108 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
4110 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
4119 mangleExpression(E);
4133 if (compensateMangling) {
4135 mangleOperatorName(OO_Amp, 1);
4144 if (compensateMangling)
4160 mangleTemplateArg(
P);
4166 void CXXNameMangler::mangleTemplateParameter(
unsigned Index) {
4172 Out <<
'T' << (Index - 1) <<
'_';
4175 void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
4178 else if (SeqID > 1) {
4186 for (; SeqID != 0; SeqID /= 36) {
4187 unsigned C = SeqID % 36;
4188 *I++ = (C < 10 ?
'0' + C :
'A' + C - 10);
4191 Out.write(I.base(), I - BufferRef.rbegin());
4196 void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
4197 bool result = mangleSubstitution(tname);
4198 assert(result &&
"no existing substitution for template name");
4204 bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
4206 if (mangleStandardSubstitution(ND))
4209 ND = cast<NamedDecl>(ND->getCanonicalDecl());
4210 return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
4220 bool CXXNameMangler::mangleSubstitution(
QualType T) {
4223 return mangleSubstitution(RT->getDecl());
4228 return mangleSubstitution(TypePtr);
4231 bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
4233 return mangleSubstitution(TD);
4236 return mangleSubstitution(
4240 bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
4242 if (I == Substitutions.end())
4245 unsigned SeqID = I->second;
4279 if (TemplateArgs.
size() != 1)
4282 if (!
isCharType(TemplateArgs[0].getAsType()))
4288 template <std::
size_t StrLen>
4290 const char (&Str)[StrLen]) {
4295 if (TemplateArgs.
size() != 2)
4298 if (!
isCharType(TemplateArgs[0].getAsType()))
4307 bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
4309 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
4334 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
4344 if (TemplateArgs.
size() != 3)
4347 if (!
isCharType(TemplateArgs[0].getAsType()))
4384 void CXXNameMangler::addSubstitution(
QualType T) {
4387 addSubstitution(RT->getDecl());
4393 addSubstitution(TypePtr);
4396 void CXXNameMangler::addSubstitution(
TemplateName Template) {
4398 return addSubstitution(TD);
4404 void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
4405 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
4406 Substitutions[Ptr] = SeqID++;
4409 CXXNameMangler::AbiTagList
4410 CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
4412 if (DisableDerivedAbiTags)
4413 return AbiTagList();
4415 llvm::raw_null_ostream NullOutStream;
4416 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
4417 TrackReturnTypeTags.disableDerivedAbiTags();
4421 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
4423 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
4425 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4428 CXXNameMangler::AbiTagList
4429 CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
4431 if (DisableDerivedAbiTags)
4432 return AbiTagList();
4434 llvm::raw_null_ostream NullOutStream;
4435 CXXNameMangler TrackVariableType(*
this, NullOutStream);
4436 TrackVariableType.disableDerivedAbiTags();
4438 TrackVariableType.mangleType(VD->
getType());
4440 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4443 bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &C,
4445 llvm::raw_null_ostream NullOutStream;
4446 CXXNameMangler TrackAbiTags(C, NullOutStream,
nullptr,
true);
4447 TrackAbiTags.mangle(VD);
4448 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
4461 void ItaniumMangleContextImpl::mangleCXXName(
const NamedDecl *D,
4463 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
4464 "Invalid mangleName() call, argument is not a variable or function!");
4465 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
4466 "Invalid mangleName() call on 'structor decl!");
4469 getASTContext().getSourceManager(),
4470 "Mangling declaration");
4472 CXXNameMangler Mangler(*
this, Out, D);
4479 CXXNameMangler Mangler(*
this, Out, D, Type);
4486 CXXNameMangler Mangler(*
this, Out, D, Type);
4492 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
4498 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
4502 void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
4512 assert(!isa<CXXDestructorDecl>(MD) &&
4513 "Use mangleCXXDtor for destructor decls!");
4514 CXXNameMangler Mangler(*
this, Out);
4515 Mangler.getStream() <<
"_ZT";
4517 Mangler.getStream() <<
'c';
4528 Mangler.mangleFunctionEncoding(MD);
4531 void ItaniumMangleContextImpl::mangleCXXDtorThunk(
4536 CXXNameMangler Mangler(*
this, Out, DD, Type);
4537 Mangler.getStream() <<
"_ZT";
4540 Mangler.mangleCallOffset(ThisAdjustment.
NonVirtual,
4543 Mangler.mangleFunctionEncoding(DD);
4547 void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
4551 CXXNameMangler Mangler(*
this, Out);
4554 Mangler.getStream() <<
"_ZGV";
4555 Mangler.mangleName(D);
4558 void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
4563 Out <<
"__cxx_global_var_init";
4566 void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
4569 CXXNameMangler Mangler(*
this, Out);
4570 Mangler.getStream() <<
"__dtor_";
4571 if (shouldMangleDeclName(D))
4574 Mangler.getStream() << D->
getName();
4577 void ItaniumMangleContextImpl::mangleSEHFilterExpression(
4578 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4579 CXXNameMangler Mangler(*
this, Out);
4580 Mangler.getStream() <<
"__filt_";
4581 if (shouldMangleDeclName(EnclosingDecl))
4582 Mangler.mangle(EnclosingDecl);
4584 Mangler.getStream() << EnclosingDecl->
getName();
4587 void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
4588 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4589 CXXNameMangler Mangler(*
this, Out);
4590 Mangler.getStream() <<
"__fin_";
4591 if (shouldMangleDeclName(EnclosingDecl))
4592 Mangler.mangle(EnclosingDecl);
4594 Mangler.getStream() << EnclosingDecl->
getName();
4597 void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
4600 CXXNameMangler Mangler(*
this, Out);
4601 Mangler.getStream() <<
"_ZTH";
4602 Mangler.mangleName(D);
4606 ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
4609 CXXNameMangler Mangler(*
this, Out);
4610 Mangler.getStream() <<
"_ZTW";
4611 Mangler.mangleName(D);
4614 void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
4615 unsigned ManglingNumber,
4619 CXXNameMangler Mangler(*
this, Out);
4620 Mangler.getStream() <<
"_ZGR";
4621 Mangler.mangleName(D);
4622 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
4623 Mangler.mangleSeqID(ManglingNumber - 1);
4626 void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
4629 CXXNameMangler Mangler(*
this, Out);
4630 Mangler.getStream() <<
"_ZTV";
4631 Mangler.mangleNameOrStandardSubstitution(RD);
4634 void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
4637 CXXNameMangler Mangler(*
this, Out);
4638 Mangler.getStream() <<
"_ZTT";
4639 Mangler.mangleNameOrStandardSubstitution(RD);
4642 void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
4647 CXXNameMangler Mangler(*
this, Out);
4648 Mangler.getStream() <<
"_ZTC";
4649 Mangler.mangleNameOrStandardSubstitution(RD);
4650 Mangler.getStream() <<
Offset;
4651 Mangler.getStream() <<
'_';
4652 Mangler.mangleNameOrStandardSubstitution(Type);
4655 void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
4657 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
4658 CXXNameMangler Mangler(*
this, Out);
4659 Mangler.getStream() <<
"_ZTI";
4660 Mangler.mangleType(Ty);
4663 void ItaniumMangleContextImpl::mangleCXXRTTIName(
QualType Ty,
4666 CXXNameMangler Mangler(*
this, Out);
4667 Mangler.getStream() <<
"_ZTS";
4668 Mangler.mangleType(Ty);
4671 void ItaniumMangleContextImpl::mangleTypeName(
QualType Ty, raw_ostream &Out) {
4672 mangleCXXRTTIName(Ty, Out);
4675 void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
4676 llvm_unreachable(
"Can't mangle string literals");
4681 return new ItaniumMangleContextImpl(Context, Diags);
unsigned getNumElements() const
A call to an overloaded operator written using operator syntax.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Defines the clang::ASTContext interface.
unsigned getNumInits() const
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Expr * getSizeExpr() const
const Type * Ty
The locally-unqualified type.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
unsigned arg_size() const
Retrieve the number of arguments.
ExtParameterInfo getExtParameterInfo(unsigned I) const
The "enum" keyword introduces the elaborated-type-specifier.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
PointerType - C99 6.7.5.1 - Pointer Declarators.
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
TemplateName getReplacement() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool isConsumed() const
Is this parameter considered "consumed" by Objective-C ARC? Consumed parameters must have retainable ...
__auto_type (GNU extension)
The COMDAT used for ctors.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool isArgumentType() const
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
bool isGlobalDelete() const
Defines the SourceManager interface.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
ConstExprIterator const_arg_iterator
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
static bool isStreamCharSpecialization(const ClassTemplateSpecializationDecl *SD, const char(&Str)[StrLen])
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Defines the C++ template declaration subclasses.
Represents a C++11 auto or C++14 decltype(auto) type.
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
bool hasLinkage() const
Determine whether this declaration has linkage.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
unsigned getLength() const
Efficiently return the length of this identifier info.
std::unique_ptr< llvm::MemoryBuffer > Buffer
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
InitListExpr * getSyntacticForm() const
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgument > Args, QualType Canon)
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Represents a call to a C++ constructor.
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
static bool isParenthesizedADLCallee(const CallExpr *call)
Look at the callee of the given call expression and determine if it's a parenthesized id-expression w...
bool isDecltypeAuto() const
bool isBooleanType() const
A container of type source information.
unsigned getIndex() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Represents a C++ constructor within a class.
unsigned getNumTemplateArgs() const
A template template parameter that has been substituted for some other template name.
Default closure variant of a ctor.
const llvm::APInt & getSize() const
void * getAsOpaquePtr() const
An identifier, stored as an IdentifierInfo*.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
void removeObjCLifetime()
unsigned getBlockManglingNumber() const
const Expr * getCallee() const
ObjCLifetime getObjCLifetime() const
Represents an empty template argument, e.g., one that has not been deduced.
AutoTypeKeyword getKeyword() const
A this pointer adjustment.
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
A namespace, stored as a NamespaceDecl*.
UnaryExprOrTypeTrait getKind() const
A C++ throw-expression (C++ [except.throw]).
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
The collection of all-type qualifiers we support.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
bool isOpenCLSpecificType() const
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
QualType getElementType() const
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
ParameterABI getABI() const
Return the ABI treatment of this parameter.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty)
Represents a class type in Objective C.
Expr * getSizeExpr() const
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a dependent template name that cannot be resolved prior to template instantiation.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isReferenceType() const
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool isTranslationUnit() const
unsigned getCVRQualifiers() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Represents the result of substituting a set of types for a template type parameter pack...
TypeSourceInfo * getLambdaTypeInfo() const
Expr * getArg(unsigned I)
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
Expr * getUnderlyingExpr() const
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
An rvalue reference type, per C++11 [dcl.ref].
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
A qualified template name, where the qualification is kept to describe the source code as written...
An lvalue ref-qualifier was provided (&).
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags)
QualType getBaseType() const
Gets the base type of this object type.
QualType getReturnType() const
The "struct" keyword introduces the elaborated-type-specifier.
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
UnresolvedUsingTypenameDecl * getDecl() const
Expr * getInitializer()
The initializer of this new-expression.
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
Expr * getExprOperand() const
static bool isStdNamespace(const DeclContext *DC)
Concrete class used by the front-end to report problems and issues.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
Represents a typeof (or typeof) expression (a GCC extension).
A builtin binary operation expression such as "x + y" or "x <= y".
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
RecordDecl * getDecl() const
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
Enums/classes describing ABI related information about constructors, destructors and thunks...
TypeClass getTypeClass() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
Represents a C++ member access expression where the actual member referenced could not be resolved be...
detail::InMemoryDirectory::const_iterator I
is ARM Neon polynomial vector
arg_iterator placement_arg_end()
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
bool addressSpaceMapManglingFor(unsigned AS) const
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
struct clang::ReturnAdjustment::VirtualAdjustment::@110 Itanium
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
QualType getInjectedSpecializationType() const
ConditionalOperator - The ?: ternary operator.
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
ExtInfo getExtInfo() const
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
A dependent template name that has not been resolved to a template (or set of templates).
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
union clang::ReturnAdjustment::VirtualAdjustment Virtual
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Represents an array type in C++ whose size is a value-dependent expression.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
CXXDtorType
C++ destructor types.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
QualType getPointeeType() const
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
static const DeclContext * IgnoreLinkageSpecDecls(const DeclContext *DC)
StringRef getName() const
Return the actual identifier string.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Declaration of a template type parameter.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Represents a C++ destructor within a class.
New-expression has a C++11 list-initializer.
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
ArgKind getKind() const
Return the kind of stored template argument.
const ParmVarDecl * getParamDecl(unsigned i) const
A structure for storing the information associated with a substituted template template parameter...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
static SVal getValue(SVal val, SValBuilder &svalBuilder)
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
QualType getAllocatedType() const
Expr * getSubExpr() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFunctionOrMethod() const
Qualifiers Quals
The local qualifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
bool isExternallyVisible() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
QualType getElementType() const
A type, stored as a Type*.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
The COMDAT used for dtors.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
TypedefNameDecl * getTypedefNameForAnonDecl() const
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
decls_iterator decls_begin() const
unsigned getNumTemplateArgs() const
static bool hasMangledSubstitutionQualifiers(QualType T)
Determine whether the given type has any qualifiers that are relevant for substitutions.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
A template template parameter pack that has been substituted for a template template argument pack...
There is no lifetime qualification on this type.
is AltiVec 'vector Pixel'
Assigning into this object requires the old value to be released and the new value to be retained...
Encodes a location in the source.
TemplateArgumentLoc const * getTemplateArgs() const
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
const TemplateArgument * iterator
QualType getElementType() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
bool isBuiltinType() const
Helper methods to distinguish type categories.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
TagDecl - Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
VectorKind getVectorKind() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Represents a static or instance method of a struct/union/class.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
This file defines OpenMP nodes for declarative directives.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
bool hasInitializer() const
Whether this new-expression has any initializer at all.
is AltiVec 'vector bool ...'
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
const T * castAs() const
Member-template castAs<specific type>.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset. ...
const IdentifierInfo * getIdentifier() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
QualType getType() const
Return the type wrapped by this type source info.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
CXXCtorType
C++ constructor types.
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
QualType getPointeeType() const
A qualified reference to a name whose declaration cannot yet be resolved.
Represents a pack expansion of types.
Decl * getBlockManglingContextDecl() const
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
Expr * getSizeExpr() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Base class for declarations which introduce a typedef-name.
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
Represents a template name that was expressed as a qualified name.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
const Expr * getSubExpr() const
ThisAdjustment This
The this pointer adjustment.
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
struct clang::ThisAdjustment::VirtualAdjustment::@112 Itanium
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
TemplateArgumentLoc const * getTemplateArgs() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
bool getProducesResult() const
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
const llvm::APSInt & getInitVal() const
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
DeclarationName - The name of a declaration.
The "union" keyword introduces the elaborated-type-specifier.
CallingConv getCC() const
The "class" keyword introduces the elaborated-type-specifier.
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
bool isTypeOperand() const
unsigned getFunctionScopeDepth() const
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
ExplicitCastExpr - An explicit cast written in the source code.
A type that was preceded by the 'template' keyword, stored as a Type*.
bool isLambda() const
Determine whether this class describes a lambda function object.
union clang::ThisAdjustment::VirtualAdjustment Virtual
llvm::APFloat getValue() const
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Represents a pointer to an Objective C object.
Not an overloaded operator.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
const T * getAs() const
Member-template getAs<specific type>'.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
unsigned getTypeQuals() const
QualType getCanonicalType() const
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
QualType getIntegralType() const
Retrieve the type of the integral value.
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.
Expr * getExprOperand() const
llvm::StringRef getParameterABISpelling(ParameterABI kind)
unsigned getAddressSpace() const
const Expr * getSubExpr() const
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
The template argument is actually a parameter pack.
arg_iterator placement_arg_begin()
QualType getPointeeType() const
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
const Type * getClass() const
Reading or writing from this object requires a barrier call.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool hasAddressSpace() const
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
ConstExprIterator const_arg_iterator
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++ struct/union/class.
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
ElaboratedTypeKeyword getKeyword() const
A structure for storing the information associated with an overloaded template name.
Declaration of a class template.
This class is used for builtin types like 'int'.
static bool isCharSpecialization(QualType T, const char *Name)
Returns whether a given type is a template specialization of a given name with a single argument of t...
static bool isCharType(QualType T)
QualType getParamTypeForDecl() const
Copying closure variant of a ctor.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
DeclarationName getName() const
Gets the name looked up.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
static Qualifiers fromCVRMask(unsigned CVR)
TagDecl * getDecl() const
static Decl::Kind getKind(const Decl *D)
unsigned getTargetAddressSpace(QualType T) const
A reference to a declared variable, function, enum, etc.
QualType getElementType() const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
const Expr * getInit(unsigned Init) const
A set of overloaded template declarations.
NamedDecl - This represents a decl with a name.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Represents a C array with a specified size that is not an integer-constant-expression.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
static bool isStd(const NamespaceDecl *NS)
Return whether a given namespace is the 'std' namespace.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isTypeOperand() const
The global specifier '::'. There is no stored value.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
TemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon, QualType Aliased)
The "__interface" keyword introduces the elaborated-type-specifier.
Represents the canonical version of C arrays with a specified constant size.
Declaration of a template function.
Attr - This represents one attribute.
A single template declaration.
This parameter (which must have pointer type) is a Swift indirect result parameter.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType getArgumentType() const
QualType getDeducedType() const
Get the type deduced for this auto type, or null if it's either not been deduced or was deduced to a ...