32 #include "llvm/ADT/StringExtras.h" 33 #include "llvm/Support/ErrorHandling.h" 34 #include "llvm/Support/raw_ostream.h" 36 #define MANGLE_CHECKER 0 42 using namespace clang;
58 = dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl()))
59 return ContextParam->getDeclContext();
63 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
65 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
66 return ContextParam->getDeclContext();
70 if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC)) {
71 return getEffectiveDeclContext(cast<Decl>(DC));
74 if (
const auto *VD = dyn_cast<VarDecl>(D))
76 return VD->getASTContext().getTranslationUnitDecl();
78 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
80 return FD->getASTContext().getTranslationUnitDecl();
86 return getEffectiveDeclContext(cast<Decl>(DC));
89 static bool isLocalContainerContext(
const DeclContext *DC) {
90 return isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) || isa<BlockDecl>(DC);
96 if (isLocalContainerContext(DC))
97 return dyn_cast<RecordDecl>(D);
99 DC = getEffectiveDeclContext(D);
106 return ftd->getTemplatedDecl();
113 return (fn ? getStructor(fn) :
decl);
116 static bool isLambda(
const NamedDecl *ND) {
124 static const unsigned UnknownArity = ~0U;
127 typedef std::pair<const DeclContext*, IdentifierInfo*> DiscriminatorKeyTy;
128 llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
129 llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
132 explicit ItaniumMangleContextImpl(
ASTContext &Context,
139 bool shouldMangleCXXName(
const NamedDecl *D)
override;
140 bool shouldMangleStringLiteral(
const StringLiteral *)
override {
143 void mangleCXXName(
const NamedDecl *D, raw_ostream &)
override;
145 raw_ostream &)
override;
148 raw_ostream &)
override;
149 void mangleReferenceTemporary(
const VarDecl *D,
unsigned ManglingNumber,
150 raw_ostream &)
override;
151 void mangleCXXVTable(
const CXXRecordDecl *RD, raw_ostream &)
override;
152 void mangleCXXVTT(
const CXXRecordDecl *RD, raw_ostream &)
override;
155 void mangleCXXRTTI(
QualType T, raw_ostream &)
override;
156 void mangleCXXRTTIName(
QualType T, raw_ostream &)
override;
157 void mangleTypeName(
QualType T, raw_ostream &)
override;
159 raw_ostream &)
override;
161 raw_ostream &)
override;
165 void mangleStaticGuardVariable(
const VarDecl *D, raw_ostream &)
override;
166 void mangleDynamicInitializer(
const VarDecl *D, raw_ostream &Out)
override;
167 void mangleDynamicAtExitDestructor(
const VarDecl *D,
168 raw_ostream &Out)
override;
169 void mangleSEHFilterExpression(
const NamedDecl *EnclosingDecl,
170 raw_ostream &Out)
override;
171 void mangleSEHFinallyBlock(
const NamedDecl *EnclosingDecl,
172 raw_ostream &Out)
override;
173 void mangleItaniumThreadLocalInit(
const VarDecl *D, raw_ostream &)
override;
174 void mangleItaniumThreadLocalWrapper(
const VarDecl *D,
175 raw_ostream &)
override;
177 void mangleStringLiteral(
const StringLiteral *, raw_ostream &)
override;
179 bool getNextDiscriminator(
const NamedDecl *ND,
unsigned &disc) {
185 if (
const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
186 if (Tag->getName().empty() && !Tag->getTypedefNameForAnonDecl())
192 unsigned discriminator = getASTContext().getManglingNumber(ND);
193 if (discriminator == 1)
195 disc = discriminator - 2;
200 unsigned &discriminator = Uniquifier[ND];
201 if (!discriminator) {
202 const DeclContext *DC = getEffectiveDeclContext(ND);
203 discriminator = ++Discriminator[std::make_pair(DC, ND->
getIdentifier())];
205 if (discriminator == 1)
207 disc = discriminator-2;
214 class CXXNameMangler {
215 ItaniumMangleContextImpl &Context;
217 bool NullOut =
false;
222 bool DisableDerivedAbiTags =
false;
233 class FunctionTypeDepthState {
236 enum { InResultTypeMask = 1 };
239 FunctionTypeDepthState() : Bits(0) {}
242 unsigned getDepth()
const {
247 bool isInResultType()
const {
248 return Bits & InResultTypeMask;
251 FunctionTypeDepthState push() {
252 FunctionTypeDepthState tmp = *
this;
253 Bits = (Bits & ~InResultTypeMask) + 2;
257 void enterResultType() {
258 Bits |= InResultTypeMask;
261 void leaveResultType() {
262 Bits &= ~InResultTypeMask;
265 void pop(FunctionTypeDepthState saved) {
266 assert(getDepth() == saved.getDepth() + 1);
281 class AbiTagState final {
283 explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
289 AbiTagState(
const AbiTagState &) =
delete;
290 AbiTagState &operator=(
const AbiTagState &) =
delete;
292 ~AbiTagState() { pop(); }
294 void write(raw_ostream &Out,
const NamedDecl *ND,
295 const AbiTagList *AdditionalAbiTags) {
297 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
299 !AdditionalAbiTags &&
300 "only function and variables need a list of additional abi tags");
301 if (
const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
302 if (
const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
303 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
304 AbiTag->tags().end());
312 if (
const auto *AbiTag = ND->
getAttr<AbiTagAttr>()) {
313 UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
314 AbiTag->tags().end());
315 TagList.insert(TagList.end(), AbiTag->tags().begin(),
316 AbiTag->tags().end());
319 if (AdditionalAbiTags) {
320 UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(),
321 AdditionalAbiTags->end());
322 TagList.insert(TagList.end(), AdditionalAbiTags->begin(),
323 AdditionalAbiTags->end());
326 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;
384 llvm::DenseMap<StringRef, unsigned> ModuleSubstitutions;
386 ASTContext &getASTContext()
const {
return Context.getASTContext(); }
389 CXXNameMangler(ItaniumMangleContextImpl &
C, raw_ostream &Out_,
390 const NamedDecl *D =
nullptr,
bool NullOut_ =
false)
391 : Context(C), Out(Out_), NullOut(NullOut_), Structor(getStructor(D)),
394 assert(!D || (!isa<CXXDestructorDecl>(D) &&
395 !isa<CXXConstructorDecl>(D)));
397 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
399 : Context(C), Out(Out_), Structor(getStructor(D)),
StructorType(Type),
400 SeqID(0), AbiTagsRoot(AbiTags) { }
401 CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
403 : Context(C), Out(Out_), Structor(getStructor(D)),
StructorType(Type),
404 SeqID(0), AbiTagsRoot(AbiTags) { }
406 CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
407 : Context(Outer.Context), Out(Out_), NullOut(
false),
408 Structor(Outer.Structor),
StructorType(Outer.StructorType),
409 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
410 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
412 CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
413 : Context(Outer.Context), Out(Out_), NullOut(
true),
414 Structor(Outer.Structor),
StructorType(Outer.StructorType),
415 SeqID(Outer.SeqID), FunctionTypeDepth(Outer.FunctionTypeDepth),
416 AbiTagsRoot(AbiTags), Substitutions(Outer.Substitutions) {}
420 if (Out.str()[0] ==
'\01')
424 char *result = abi::__cxa_demangle(Out.str().str().c_str(), 0, 0, &status);
425 assert(status == 0 &&
"Could not demangle mangled name!");
429 raw_ostream &getStream() {
return Out; }
431 void disableDerivedAbiTags() { DisableDerivedAbiTags =
true; }
432 static bool shouldHaveAbiTags(ItaniumMangleContextImpl &C,
const VarDecl *VD);
435 void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
436 void mangleNumber(
const llvm::APSInt &I);
437 void mangleNumber(int64_t Number);
438 void mangleFloat(
const llvm::APFloat &F);
440 void mangleSeqID(
unsigned SeqID);
443 void mangleNameOrStandardSubstitution(
const NamedDecl *ND);
447 bool mangleSubstitution(
const NamedDecl *ND);
448 bool mangleSubstitution(
QualType T);
454 bool mangleStandardSubstitution(
const NamedDecl *ND);
456 void addSubstitution(
const NamedDecl *ND) {
459 addSubstitution(reinterpret_cast<uintptr_t>(ND));
465 void extendSubstitutions(CXXNameMangler* Other);
468 bool recursive =
false);
472 unsigned NumTemplateArgs,
473 unsigned KnownArity = UnknownArity);
475 void mangleFunctionEncodingBareType(
const FunctionDecl *FD);
477 void mangleNameWithAbiTags(
const NamedDecl *ND,
478 const AbiTagList *AdditionalAbiTags);
479 void mangleModuleName(
const Module *M);
480 void mangleModuleNamePrefix(StringRef Name);
483 unsigned NumTemplateArgs);
484 void mangleUnqualifiedName(
const NamedDecl *ND,
485 const AbiTagList *AdditionalAbiTags) {
486 mangleUnqualifiedName(ND, ND->
getDeclName(), UnknownArity,
491 const AbiTagList *AdditionalAbiTags);
492 void mangleUnscopedName(
const NamedDecl *ND,
493 const AbiTagList *AdditionalAbiTags);
495 const AbiTagList *AdditionalAbiTags);
497 const AbiTagList *AdditionalAbiTags);
500 void mangleSourceNameWithAbiTags(
501 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags =
nullptr);
502 void mangleLocalName(
const Decl *D,
503 const AbiTagList *AdditionalAbiTags);
504 void mangleBlockForPrefix(
const BlockDecl *Block);
505 void mangleUnqualifiedBlock(
const BlockDecl *Block);
508 const AbiTagList *AdditionalAbiTags,
509 bool NoFunction=
false);
512 unsigned NumTemplateArgs);
514 void manglePrefix(
const DeclContext *DC,
bool NoFunction=
false);
516 void mangleTemplatePrefix(
const TemplateDecl *ND,
bool NoFunction=
false);
518 bool mangleUnresolvedTypeOrSimpleId(
QualType DestroyedType,
519 StringRef Prefix =
"");
522 void mangleVendorQualifier(StringRef qualifier);
529 #define ABSTRACT_TYPE(CLASS, PARENT) 530 #define NON_CANONICAL_TYPE(CLASS, PARENT) 531 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T); 532 #include "clang/AST/TypeNodes.def" 534 void mangleType(
const TagType*);
536 static StringRef getCallingConvQualifierName(
CallingConv CC);
541 void mangleNeonVectorType(
const VectorType *T);
542 void mangleAArch64NeonVectorType(
const VectorType *T);
544 void mangleIntegerLiteral(
QualType T,
const llvm::APSInt &
Value);
545 void mangleMemberExprBase(
const Expr *base,
bool isArrow);
546 void mangleMemberExpr(
const Expr *base,
bool isArrow,
551 unsigned NumTemplateArgs,
552 unsigned knownArity);
553 void mangleCastExpression(
const Expr *E, StringRef CastEncoding);
554 void mangleInitListElements(
const InitListExpr *InitList);
555 void mangleExpression(
const Expr *E,
unsigned Arity = UnknownArity);
560 unsigned NumTemplateArgs);
562 unsigned NumTemplateArgs);
566 void mangleTemplateParameter(
unsigned Index);
571 const AbiTagList *AdditionalAbiTags);
574 AbiTagList makeFunctionReturnTypeTags(
const FunctionDecl *FD);
576 AbiTagList makeVariableTypeTags(
const VarDecl *VD);
581 bool ItaniumMangleContextImpl::shouldMangleCXXName(
const NamedDecl *D) {
586 if (FD->
hasAttr<OverloadableAttr>())
604 if (!getASTContext().getLangOpts().CPlusPlus)
608 if (VD && !isa<DecompositionDecl>(D)) {
614 const DeclContext *DC = getEffectiveDeclContext(D);
618 DC = getEffectiveParentContext(DC);
620 !CXXNameMangler::shouldHaveAbiTags(*
this, VD) &&
621 !isa<VarTemplateSpecializationDecl>(D))
628 void CXXNameMangler::writeAbiTags(
const NamedDecl *ND,
629 const AbiTagList *AdditionalAbiTags) {
630 assert(AbiTags &&
"require AbiTagState");
631 AbiTags->write(Out, ND, DisableDerivedAbiTags ?
nullptr : AdditionalAbiTags);
634 void CXXNameMangler::mangleSourceNameWithAbiTags(
635 const NamedDecl *ND,
const AbiTagList *AdditionalAbiTags) {
637 writeAbiTags(ND, AdditionalAbiTags);
640 void CXXNameMangler::mangle(
const NamedDecl *D) {
646 mangleFunctionEncoding(FD);
647 else if (
const VarDecl *VD = dyn_cast<VarDecl>(D))
650 mangleName(IFD->getAnonField());
652 mangleName(cast<FieldDecl>(D));
655 void CXXNameMangler::mangleFunctionEncoding(
const FunctionDecl *FD) {
659 if (!Context.shouldMangleDeclName(FD)) {
664 AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
665 if (ReturnTypeAbiTags.empty()) {
668 mangleFunctionEncodingBareType(FD);
676 llvm::raw_svector_ostream FunctionEncodingStream(FunctionEncodingBuf);
677 CXXNameMangler FunctionEncodingMangler(*
this, FunctionEncodingStream);
679 FunctionEncodingMangler.disableDerivedAbiTags();
680 FunctionEncodingMangler.mangleNameWithAbiTags(FD,
nullptr);
683 size_t EncodingPositionStart = FunctionEncodingStream.str().size();
684 FunctionEncodingMangler.mangleFunctionEncodingBareType(FD);
688 const AbiTagList &UsedAbiTags =
689 FunctionEncodingMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
690 AbiTagList AdditionalAbiTags(ReturnTypeAbiTags.size());
691 AdditionalAbiTags.erase(
692 std::set_difference(ReturnTypeAbiTags.begin(), ReturnTypeAbiTags.end(),
693 UsedAbiTags.begin(), UsedAbiTags.end(),
694 AdditionalAbiTags.begin()),
695 AdditionalAbiTags.end());
698 mangleNameWithAbiTags(FD, &AdditionalAbiTags);
699 Out << FunctionEncodingStream.str().substr(EncodingPositionStart);
703 extendSubstitutions(&FunctionEncodingMangler);
706 void CXXNameMangler::mangleFunctionEncodingBareType(
const FunctionDecl *FD) {
707 if (FD->
hasAttr<EnableIfAttr>()) {
708 FunctionTypeDepthState Saved = FunctionTypeDepth.push();
709 Out <<
"Ua9enable_ifI";
712 for (AttrVec::const_reverse_iterator I = FD->
getAttrs().rbegin(),
715 EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
719 mangleExpression(EIA->getCond());
723 FunctionTypeDepth.pop(Saved);
728 if (
auto *CD = dyn_cast<CXXConstructorDecl>(FD))
729 if (
auto Inherited = CD->getInheritedConstructor())
730 FD = Inherited.getConstructor();
748 bool MangleReturnType =
false;
750 if (!(isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD) ||
751 isa<CXXConversionDecl>(FD)))
752 MangleReturnType =
true;
755 FD = PrimaryTemplate->getTemplatedDecl();
759 MangleReturnType, FD);
763 while (isa<LinkageSpecDecl>(DC)) {
764 DC = getEffectiveParentContext(DC);
773 ->isTranslationUnit())
777 return II && II->
isStr(
"std");
786 return isStd(cast<NamespaceDecl>(DC));
792 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
801 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
802 TemplateArgs = &Spec->getTemplateArgs();
803 return Spec->getSpecializedTemplate();
808 dyn_cast<VarTemplateSpecializationDecl>(ND)) {
809 TemplateArgs = &Spec->getTemplateArgs();
810 return Spec->getSpecializedTemplate();
816 void CXXNameMangler::mangleName(
const NamedDecl *ND) {
817 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
819 AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
820 if (VariableTypeAbiTags.empty()) {
822 mangleNameWithAbiTags(VD,
nullptr);
827 llvm::raw_null_ostream NullOutStream;
828 CXXNameMangler VariableNameMangler(*
this, NullOutStream);
829 VariableNameMangler.disableDerivedAbiTags();
830 VariableNameMangler.mangleNameWithAbiTags(VD,
nullptr);
833 const AbiTagList &UsedAbiTags =
834 VariableNameMangler.AbiTagsRoot.getSortedUniqueUsedAbiTags();
835 AbiTagList AdditionalAbiTags(VariableTypeAbiTags.size());
836 AdditionalAbiTags.erase(
837 std::set_difference(VariableTypeAbiTags.begin(),
838 VariableTypeAbiTags.end(), UsedAbiTags.begin(),
839 UsedAbiTags.end(), AdditionalAbiTags.begin()),
840 AdditionalAbiTags.end());
843 mangleNameWithAbiTags(VD, &AdditionalAbiTags);
845 mangleNameWithAbiTags(ND,
nullptr);
849 void CXXNameMangler::mangleNameWithAbiTags(
const NamedDecl *ND,
850 const AbiTagList *AdditionalAbiTags) {
856 const DeclContext *DC = getEffectiveDeclContext(ND);
862 if (isLocalContainerContext(DC) && ND->
hasLinkage() && !isLambda(ND))
864 DC = getEffectiveParentContext(DC);
865 else if (GetLocalClassDecl(ND)) {
866 mangleLocalName(ND, AdditionalAbiTags);
872 if (isLocalContainerContext(DC)) {
873 mangleLocalName(ND, AdditionalAbiTags);
889 mangleUnscopedTemplateName(TD, AdditionalAbiTags);
890 mangleTemplateArgs(*TemplateArgs);
894 mangleUnscopedName(ND, AdditionalAbiTags);
898 mangleNestedName(ND, DC, AdditionalAbiTags);
901 void CXXNameMangler::mangleModuleName(
const Module *M) {
908 mangleModuleNamePrefix(M->
Name);
912 void CXXNameMangler::mangleModuleNamePrefix(StringRef Name) {
915 auto It = ModuleSubstitutions.find(Name);
916 if (It != ModuleSubstitutions.end()) {
918 Out << '_' << static_cast<char>(
'0' + It->second);
920 Out <<
'W' << (It->second - 10) <<
'_';
926 auto Parts = Name.rsplit(
'.');
927 if (Parts.second.empty())
928 Parts.second = Parts.first;
930 mangleModuleNamePrefix(Parts.first);
932 Out << Parts.second.size() << Parts.second;
933 ModuleSubstitutions.insert({Name, ModuleSubstitutions.size()});
936 void CXXNameMangler::mangleTemplateName(
const TemplateDecl *TD,
938 unsigned NumTemplateArgs) {
942 mangleUnscopedTemplateName(TD,
nullptr);
943 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
945 mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
949 void CXXNameMangler::mangleUnscopedName(
const NamedDecl *ND,
950 const AbiTagList *AdditionalAbiTags) {
957 mangleUnqualifiedName(ND, AdditionalAbiTags);
960 void CXXNameMangler::mangleUnscopedTemplateName(
961 const TemplateDecl *ND,
const AbiTagList *AdditionalAbiTags) {
964 if (mangleSubstitution(ND))
968 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
969 assert(!AdditionalAbiTags &&
970 "template template param cannot have abi tags");
971 mangleTemplateParameter(TTP->getIndex());
972 }
else if (isa<BuiltinTemplateDecl>(ND)) {
973 mangleUnscopedName(ND, AdditionalAbiTags);
981 void CXXNameMangler::mangleUnscopedTemplateName(
982 TemplateName Template,
const AbiTagList *AdditionalAbiTags) {
986 return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
988 if (mangleSubstitution(Template))
991 assert(!AdditionalAbiTags &&
992 "dependent template name cannot have abi tags");
995 assert(Dependent &&
"Not a dependent template name?");
997 mangleSourceName(
Id);
999 mangleOperatorName(Dependent->
getOperator(), UnknownArity);
1001 addSubstitution(Template);
1004 void CXXNameMangler::mangleFloat(
const llvm::APFloat &f) {
1018 llvm::APInt valueBits = f.bitcastToAPInt();
1019 unsigned numCharacters = (valueBits.getBitWidth() + 3) / 4;
1020 assert(numCharacters != 0);
1026 for (
unsigned stringIndex = 0; stringIndex != numCharacters; ++stringIndex) {
1028 unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
1031 uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
1032 hexDigit >>= (digitBitIndex % 64);
1036 static const char charForHex[16] = {
1037 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
1038 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' 1040 buffer[stringIndex] = charForHex[hexDigit];
1043 Out.write(buffer.data(), numCharacters);
1046 void CXXNameMangler::mangleNumber(
const llvm::APSInt &
Value) {
1047 if (Value.isSigned() && Value.isNegative()) {
1049 Value.abs().print(Out,
false);
1051 Value.print(Out,
false);
1055 void CXXNameMangler::mangleNumber(int64_t Number) {
1065 void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) {
1073 mangleNumber(NonVirtual);
1079 mangleNumber(NonVirtual);
1081 mangleNumber(Virtual);
1087 if (!mangleSubstitution(
QualType(TST, 0))) {
1088 mangleTemplatePrefix(TST->getTemplateName());
1093 mangleTemplateArgs(TST->getArgs(), TST->getNumArgs());
1096 }
else if (
const auto *DTST =
1098 if (!mangleSubstitution(
QualType(DTST, 0))) {
1099 TemplateName Template = getASTContext().getDependentTemplateName(
1100 DTST->getQualifier(), DTST->getIdentifier());
1101 mangleTemplatePrefix(Template);
1106 mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1107 addSubstitution(
QualType(DTST, 0));
1137 switch (qualifier->
getKind()) {
1149 llvm_unreachable(
"Can't mangle __super specifier");
1153 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1161 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1178 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1185 if (mangleUnresolvedTypeOrSimpleId(
QualType(type, 0), recursive ?
"N" :
""))
1194 mangleUnresolvedPrefix(qualifier->
getPrefix(),
1212 void CXXNameMangler::mangleUnresolvedName(
1215 unsigned knownArity) {
1216 if (qualifier) mangleUnresolvedPrefix(qualifier);
1232 mangleOperatorName(name, knownArity);
1235 llvm_unreachable(
"Can't mangle a constructor name!");
1237 llvm_unreachable(
"Can't mangle a using directive name!");
1239 llvm_unreachable(
"Can't mangle a deduction guide name!");
1243 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1249 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1252 void CXXNameMangler::mangleUnqualifiedName(
const NamedDecl *ND,
1254 unsigned KnownArity,
1255 const AbiTagList *AdditionalAbiTags) {
1256 unsigned Arity = KnownArity;
1265 if (
auto *DD = dyn_cast<DecompositionDecl>(ND)) {
1274 for (
auto *BD : DD->bindings())
1275 mangleSourceName(BD->getDeclName().getAsIdentifierInfo());
1277 writeAbiTags(ND, AdditionalAbiTags);
1297 getEffectiveDeclContext(ND)->isFileContext() &&
1302 bool IsRegCall = FD &&
1306 mangleRegCallName(II);
1308 mangleSourceName(II);
1310 writeAbiTags(ND, AdditionalAbiTags);
1315 assert(ND &&
"mangling empty name without declaration");
1317 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
1318 if (NS->isAnonymousNamespace()) {
1320 Out <<
"12_GLOBAL__N_1";
1325 if (
const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
1340 &&
"Expected anonymous struct or union!");
1347 assert(FD->getIdentifier() &&
"Data member name isn't an identifier!");
1349 mangleSourceName(FD->getIdentifier());
1360 if (isa<ObjCContainerDecl>(ND))
1364 const TagDecl *TD = cast<TagDecl>(ND);
1367 "Typedef should not be in another decl context!");
1369 "Typedef was not named!");
1371 assert(!AdditionalAbiTags &&
"Type cannot have additional abi tags");
1374 writeAbiTags(TD,
nullptr);
1382 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
1383 if (Record->isLambda() && Record->getLambdaManglingNumber()) {
1384 assert(!AdditionalAbiTags &&
1385 "Lambda type cannot have additional abi tags");
1386 mangleLambda(Record);
1392 unsigned UnnamedMangle = getASTContext().getManglingNumber(TD);
1394 if (UnnamedMangle > 1)
1395 Out << UnnamedMangle - 2;
1397 writeAbiTags(TD, AdditionalAbiTags);
1403 unsigned AnonStructId = NullOut ? 0 : Context.getAnonymousStructId(TD);
1410 Str += llvm::utostr(AnonStructId);
1420 llvm_unreachable(
"Can't mangle Objective-C selector names here!");
1425 if (
auto Inherited =
1426 cast<CXXConstructorDecl>(ND)->getInheritedConstructor()) {
1427 InheritedFrom = Inherited.getConstructor()->
getParent();
1428 InheritedTemplateArgs =
1429 Inherited.getConstructor()->getTemplateSpecializationArgs();
1435 mangleCXXCtorType(static_cast<CXXCtorType>(
StructorType), InheritedFrom);
1443 if (InheritedTemplateArgs)
1444 mangleTemplateArgs(*InheritedTemplateArgs);
1446 writeAbiTags(ND, AdditionalAbiTags);
1454 mangleCXXDtorType(static_cast<CXXDtorType>(
StructorType));
1459 writeAbiTags(ND, AdditionalAbiTags);
1463 if (ND && Arity == UnknownArity) {
1464 Arity = cast<FunctionDecl>(ND)->getNumParams();
1467 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND))
1468 if (!MD->isStatic())
1474 mangleOperatorName(Name, Arity);
1475 writeAbiTags(ND, AdditionalAbiTags);
1479 llvm_unreachable(
"Can't mangle a deduction guide name!");
1482 llvm_unreachable(
"Can't mangle a using directive name!");
1486 void CXXNameMangler::mangleRegCallName(
const IdentifierInfo *II) {
1490 Out << II->
getLength() +
sizeof(
"__regcall3__") - 1 <<
"__regcall3__" 1494 void CXXNameMangler::mangleSourceName(
const IdentifierInfo *II) {
1501 void CXXNameMangler::mangleNestedName(
const NamedDecl *ND,
1503 const AbiTagList *AdditionalAbiTags,
1511 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
1517 mangleQualifiers(MethodQuals);
1518 mangleRefQualifier(Method->getRefQualifier());
1524 mangleTemplatePrefix(TD, NoFunction);
1525 mangleTemplateArgs(*TemplateArgs);
1528 manglePrefix(DC, NoFunction);
1529 mangleUnqualifiedName(ND, AdditionalAbiTags);
1534 void CXXNameMangler::mangleNestedName(
const TemplateDecl *TD,
1536 unsigned NumTemplateArgs) {
1541 mangleTemplatePrefix(TD);
1542 mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
1547 void CXXNameMangler::mangleLocalName(
const Decl *D,
1548 const AbiTagList *AdditionalAbiTags) {
1554 assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
1556 const DeclContext *DC = getEffectiveDeclContext(RD ? RD : D);
1561 AbiTagState LocalAbiTags(AbiTags);
1564 mangleObjCMethodName(MD);
1565 else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
1566 mangleBlockForPrefix(BD);
1568 mangleFunctionEncoding(cast<FunctionDecl>(DC));
1572 LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
1591 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1593 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1595 mangleNumber(Num - 2);
1604 mangleUnqualifiedName(RD, AdditionalAbiTags);
1605 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1606 manglePrefix(getEffectiveDeclContext(BD),
true );
1607 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1608 mangleUnqualifiedBlock(BD);
1610 const NamedDecl *ND = cast<NamedDecl>(D);
1611 mangleNestedName(ND, getEffectiveDeclContext(ND), AdditionalAbiTags,
1614 }
else if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
1618 = dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl())) {
1620 = dyn_cast<FunctionDecl>(Parm->getDeclContext())) {
1622 unsigned Num = Func->getNumParams() - Parm->getFunctionScopeIndex();
1624 mangleNumber(Num - 2);
1629 assert(!AdditionalAbiTags &&
"Block cannot have additional abi tags");
1630 mangleUnqualifiedBlock(BD);
1632 mangleUnqualifiedName(cast<NamedDecl>(D), AdditionalAbiTags);
1635 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
1637 if (Context.getNextDiscriminator(ND, disc)) {
1641 Out <<
"__" << disc <<
'_';
1646 void CXXNameMangler::mangleBlockForPrefix(
const BlockDecl *Block) {
1647 if (GetLocalClassDecl(Block)) {
1648 mangleLocalName(Block,
nullptr);
1651 const DeclContext *DC = getEffectiveDeclContext(Block);
1652 if (isLocalContainerContext(DC)) {
1653 mangleLocalName(Block,
nullptr);
1656 manglePrefix(getEffectiveDeclContext(Block));
1657 mangleUnqualifiedBlock(Block);
1660 void CXXNameMangler::mangleUnqualifiedBlock(
const BlockDecl *Block) {
1662 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1663 Context->getDeclContext()->isRecord()) {
1664 const auto *ND = cast<NamedDecl>(Context);
1666 mangleSourceNameWithAbiTags(ND);
1677 Number = Context.getBlockId(Block,
false);
1688 void CXXNameMangler::mangleLambda(
const CXXRecordDecl *Lambda) {
1699 if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
1700 !isa<ParmVarDecl>(Context)) {
1704 = cast<NamedDecl>(Context)->getIdentifier()) {
1705 mangleSourceName(Name);
1707 if (
isTemplate(cast<NamedDecl>(Context), TemplateArgs))
1708 mangleTemplateArgs(*TemplateArgs);
1716 getAs<FunctionProtoType>();
1717 mangleBareFunctionType(Proto,
false,
1727 assert(Number > 0 &&
"Lambda should be mangled as an unnamed class");
1729 mangleNumber(Number - 2);
1734 switch (qualifier->
getKind()) {
1740 llvm_unreachable(
"Can't mangle __super specifier");
1765 llvm_unreachable(
"unexpected nested name specifier");
1768 void CXXNameMangler::manglePrefix(
const DeclContext *DC,
bool NoFunction) {
1780 if (NoFunction && isLocalContainerContext(DC))
1783 assert(!isLocalContainerContext(DC));
1785 const NamedDecl *ND = cast<NamedDecl>(DC);
1786 if (mangleSubstitution(ND))
1792 mangleTemplatePrefix(TD);
1793 mangleTemplateArgs(*TemplateArgs);
1795 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1796 mangleUnqualifiedName(ND,
nullptr);
1799 addSubstitution(ND);
1802 void CXXNameMangler::mangleTemplatePrefix(
TemplateName Template) {
1807 return mangleTemplatePrefix(TD);
1810 manglePrefix(Qualified->getQualifier());
1814 mangleUnqualifiedName(
nullptr, (*Overloaded->begin())->getDeclName(),
1815 UnknownArity,
nullptr);
1820 assert(Dependent &&
"Unknown template name kind?");
1822 manglePrefix(Qualifier);
1823 mangleUnscopedTemplateName(Template,
nullptr);
1826 void CXXNameMangler::mangleTemplatePrefix(
const TemplateDecl *ND,
1834 if (mangleSubstitution(ND))
1838 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
1839 mangleTemplateParameter(TTP->getIndex());
1841 manglePrefix(getEffectiveDeclContext(ND), NoFunction);
1842 if (isa<BuiltinTemplateDecl>(ND))
1843 mangleUnqualifiedName(ND,
nullptr);
1848 addSubstitution(ND);
1857 if (mangleSubstitution(TN))
1872 if (isa<TemplateTemplateParmDecl>(TD))
1873 mangleTemplateParameter(cast<TemplateTemplateParmDecl>(TD)->getIndex());
1879 llvm_unreachable(
"can't mangle an overloaded template name as a <type>");
1908 Out <<
"_SUBSTPACK_";
1913 addSubstitution(TN);
1916 bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(
QualType Ty,
1922 case Type::Adjusted:
1925 case Type::BlockPointer:
1926 case Type::LValueReference:
1927 case Type::RValueReference:
1928 case Type::MemberPointer:
1929 case Type::ConstantArray:
1930 case Type::IncompleteArray:
1931 case Type::VariableArray:
1932 case Type::DependentSizedArray:
1933 case Type::DependentAddressSpace:
1934 case Type::DependentSizedExtVector:
1936 case Type::ExtVector:
1937 case Type::FunctionProto:
1938 case Type::FunctionNoProto:
1940 case Type::Attributed:
1942 case Type::DeducedTemplateSpecialization:
1943 case Type::PackExpansion:
1944 case Type::ObjCObject:
1945 case Type::ObjCInterface:
1946 case Type::ObjCObjectPointer:
1947 case Type::ObjCTypeParam:
1950 llvm_unreachable(
"type is illegal as a nested name specifier");
1952 case Type::SubstTemplateTypeParmPack:
1957 Out <<
"_SUBSTPACK_";
1964 case Type::TypeOfExpr:
1966 case Type::Decltype:
1967 case Type::TemplateTypeParm:
1968 case Type::UnaryTransform:
1969 case Type::SubstTemplateTypeParm:
1983 mangleSourceNameWithAbiTags(cast<TypedefType>(Ty)->getDecl());
1986 case Type::UnresolvedUsing:
1987 mangleSourceNameWithAbiTags(
1988 cast<UnresolvedUsingType>(Ty)->getDecl());
1993 mangleSourceNameWithAbiTags(cast<TagType>(Ty)->getDecl());
1996 case Type::TemplateSpecialization: {
1998 cast<TemplateSpecializationType>(Ty);
2000 switch (TN.getKind()) {
2007 assert(TD &&
"no template for template specialization type");
2008 if (isa<TemplateTemplateParmDecl>(TD))
2009 goto unresolvedType;
2011 mangleSourceNameWithAbiTags(TD);
2017 llvm_unreachable(
"invalid base for a template specialization type");
2031 Out <<
"_SUBSTPACK_";
2040 case Type::InjectedClassName:
2041 mangleSourceNameWithAbiTags(
2042 cast<InjectedClassNameType>(Ty)->getDecl());
2045 case Type::DependentName:
2046 mangleSourceName(cast<DependentNameType>(Ty)->
getIdentifier());
2049 case Type::DependentTemplateSpecialization: {
2051 cast<DependentTemplateSpecializationType>(Ty);
2057 case Type::Elaborated:
2058 return mangleUnresolvedTypeOrSimpleId(
2059 cast<ElaboratedType>(Ty)->getNamedType(), Prefix);
2065 void CXXNameMangler::mangleOperatorName(
DeclarationName Name,
unsigned Arity) {
2075 llvm_unreachable(
"Not an operator name");
2098 case OO_New: Out <<
"nw";
break;
2100 case OO_Array_New: Out <<
"na";
break;
2102 case OO_Delete: Out <<
"dl";
break;
2104 case OO_Array_Delete: Out <<
"da";
break;
2108 Out << (Arity == 1?
"ps" :
"pl");
break;
2112 Out << (Arity == 1?
"ng" :
"mi");
break;
2116 Out << (Arity == 1?
"ad" :
"an");
break;
2121 Out << (Arity == 1?
"de" :
"ml");
break;
2123 case OO_Tilde: Out <<
"co";
break;
2125 case OO_Slash: Out <<
"dv";
break;
2127 case OO_Percent: Out <<
"rm";
break;
2129 case OO_Pipe: Out <<
"or";
break;
2131 case OO_Caret: Out <<
"eo";
break;
2133 case OO_Equal: Out <<
"aS";
break;
2135 case OO_PlusEqual: Out <<
"pL";
break;
2137 case OO_MinusEqual: Out <<
"mI";
break;
2139 case OO_StarEqual: Out <<
"mL";
break;
2141 case OO_SlashEqual: Out <<
"dV";
break;
2143 case OO_PercentEqual: Out <<
"rM";
break;
2145 case OO_AmpEqual: Out <<
"aN";
break;
2147 case OO_PipeEqual: Out <<
"oR";
break;
2149 case OO_CaretEqual: Out <<
"eO";
break;
2151 case OO_LessLess: Out <<
"ls";
break;
2153 case OO_GreaterGreater: Out <<
"rs";
break;
2155 case OO_LessLessEqual: Out <<
"lS";
break;
2157 case OO_GreaterGreaterEqual: Out <<
"rS";
break;
2159 case OO_EqualEqual: Out <<
"eq";
break;
2161 case OO_ExclaimEqual: Out <<
"ne";
break;
2163 case OO_Less: Out <<
"lt";
break;
2165 case OO_Greater: Out <<
"gt";
break;
2167 case OO_LessEqual: Out <<
"le";
break;
2169 case OO_GreaterEqual: Out <<
"ge";
break;
2171 case OO_Exclaim: Out <<
"nt";
break;
2173 case OO_AmpAmp: Out <<
"aa";
break;
2175 case OO_PipePipe: Out <<
"oo";
break;
2177 case OO_PlusPlus: Out <<
"pp";
break;
2179 case OO_MinusMinus: Out <<
"mm";
break;
2181 case OO_Comma: Out <<
"cm";
break;
2183 case OO_ArrowStar: Out <<
"pm";
break;
2185 case OO_Arrow: Out <<
"pt";
break;
2187 case OO_Call: Out <<
"cl";
break;
2189 case OO_Subscript: Out <<
"ix";
break;
2194 case OO_Conditional: Out <<
"qu";
break;
2197 case OO_Coawait: Out <<
"aw";
break;
2200 case OO_Spaceship: Out <<
"ss";
break;
2204 llvm_unreachable(
"Not an overloaded operator");
2234 ASString =
"AS" + llvm::utostr(TargetAS);
2237 default: llvm_unreachable(
"Not a language specific address space");
2251 if (!ASString.empty())
2252 mangleVendorQualifier(ASString);
2265 mangleVendorQualifier(
"__weak");
2269 mangleVendorQualifier(
"__unaligned");
2281 mangleVendorQualifier(
"__strong");
2285 mangleVendorQualifier(
"__autoreleasing");
2308 void CXXNameMangler::mangleVendorQualifier(StringRef name) {
2309 Out <<
'U' << name.size() << name;
2315 switch (RefQualifier) {
2329 void CXXNameMangler::mangleObjCMethodName(
const ObjCMethodDecl *MD) {
2330 Context.mangleObjCMethodName(MD, Out);
2346 void CXXNameMangler::mangleType(
QualType T) {
2387 = dyn_cast<TemplateSpecializationType>(T))
2388 if (!TST->isTypeAlias())
2401 const Type *ty = split.
Ty;
2404 if (isSubstitutable && mangleSubstitution(T))
2409 if (quals && isa<ArrayType>(T)) {
2419 dyn_cast<DependentAddressSpaceType>(ty)) {
2421 mangleQualifiers(splitDAST.
Quals, DAST);
2424 mangleQualifiers(quals);
2432 #define ABSTRACT_TYPE(CLASS, PARENT) 2433 #define NON_CANONICAL_TYPE(CLASS, PARENT) \ 2435 llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \ 2437 #define TYPE(CLASS, PARENT) \ 2439 mangleType(static_cast<const CLASS##Type*>(ty)); \ 2441 #include "clang/AST/TypeNodes.def" 2446 if (isSubstitutable)
2450 void CXXNameMangler::mangleNameOrStandardSubstitution(
const NamedDecl *ND) {
2451 if (!mangleStandardSubstitution(ND))
2455 void CXXNameMangler::mangleType(
const BuiltinType *T) {
2486 std::string type_name;
2488 case BuiltinType::Void:
2491 case BuiltinType::Bool:
2494 case BuiltinType::Char_U:
2495 case BuiltinType::Char_S:
2498 case BuiltinType::UChar:
2501 case BuiltinType::UShort:
2504 case BuiltinType::UInt:
2507 case BuiltinType::ULong:
2510 case BuiltinType::ULongLong:
2513 case BuiltinType::UInt128:
2516 case BuiltinType::SChar:
2519 case BuiltinType::WChar_S:
2520 case BuiltinType::WChar_U:
2523 case BuiltinType::Char16:
2526 case BuiltinType::Char32:
2529 case BuiltinType::Short:
2532 case BuiltinType::Int:
2535 case BuiltinType::Long:
2538 case BuiltinType::LongLong:
2541 case BuiltinType::Int128:
2544 case BuiltinType::Float16:
2547 case BuiltinType::Half:
2550 case BuiltinType::Float:
2553 case BuiltinType::Double:
2556 case BuiltinType::LongDouble:
2557 Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
2561 case BuiltinType::Float128:
2562 if (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble())
2563 Out <<
"U10__float128";
2567 case BuiltinType::NullPtr:
2571 #define BUILTIN_TYPE(Id, SingletonId) 2572 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2573 case BuiltinType::Id: 2574 #include "clang/AST/BuiltinTypes.def" 2575 case BuiltinType::Dependent:
2577 llvm_unreachable(
"mangling a placeholder type");
2579 case BuiltinType::ObjCId:
2580 Out <<
"11objc_object";
2582 case BuiltinType::ObjCClass:
2583 Out <<
"10objc_class";
2585 case BuiltinType::ObjCSel:
2586 Out <<
"13objc_selector";
2588 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2589 case BuiltinType::Id: \ 2590 type_name = "ocl_" #ImgType "_" #Suffix; \ 2591 Out << type_name.size() << type_name; \ 2593 #include "clang/Basic/OpenCLImageTypes.def" 2594 case BuiltinType::OCLSampler:
2595 Out <<
"11ocl_sampler";
2597 case BuiltinType::OCLEvent:
2598 Out <<
"9ocl_event";
2600 case BuiltinType::OCLClkEvent:
2601 Out <<
"12ocl_clkevent";
2603 case BuiltinType::OCLQueue:
2604 Out <<
"9ocl_queue";
2606 case BuiltinType::OCLReserveID:
2607 Out <<
"13ocl_reserveid";
2612 StringRef CXXNameMangler::getCallingConvQualifierName(
CallingConv CC) {
2638 llvm_unreachable(
"bad calling convention");
2641 void CXXNameMangler::mangleExtFunctionInfo(
const FunctionType *T) {
2650 StringRef CCQualifier = getCallingConvQualifierName(T->
getExtInfo().
getCC());
2651 if (!CCQualifier.empty())
2652 mangleVendorQualifier(CCQualifier);
2678 mangleVendorQualifier(
"ns_consumed");
2681 mangleVendorQualifier(
"noescape");
2688 mangleExtFunctionInfo(T);
2705 mangleType(ExceptTy);
2708 }
else if (T->
isNothrow(getASTContext())) {
2716 mangleBareFunctionType(T,
true);
2730 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2732 FunctionTypeDepth.enterResultType();
2734 FunctionTypeDepth.leaveResultType();
2736 FunctionTypeDepth.pop(saved);
2741 bool MangleReturnType,
2745 FunctionTypeDepthState saved = FunctionTypeDepth.push();
2748 if (MangleReturnType) {
2749 FunctionTypeDepth.enterResultType();
2753 mangleVendorQualifier(
"ns_returns_retained");
2758 auto SplitReturnTy = ReturnTy.
split();
2760 ReturnTy = getASTContext().getQualifiedType(SplitReturnTy);
2762 mangleType(ReturnTy);
2764 FunctionTypeDepth.leaveResultType();
2771 FunctionTypeDepth.pop(saved);
2776 for (
unsigned I = 0, E = Proto->
getNumParams(); I != E; ++I) {
2789 assert(
Attr->getType() <= 9 &&
Attr->getType() >= 0);
2790 Out <<
"U17pass_object_size" <<
Attr->getType();
2795 FunctionTypeDepth.pop(saved);
2810 void CXXNameMangler::mangleType(
const EnumType *T) {
2811 mangleType(static_cast<const TagType*>(T));
2813 void CXXNameMangler::mangleType(
const RecordType *T) {
2814 mangleType(static_cast<const TagType*>(T));
2816 void CXXNameMangler::mangleType(
const TagType *T) {
2824 Out <<
'A' << T->
getSize() <<
'_';
2873 mangleType(PointeeType);
2878 mangleTemplateParameter(T->
getIndex());
2887 Out <<
"_SUBSTPACK_";
2891 void CXXNameMangler::mangleType(
const PointerType *T) {
2913 void CXXNameMangler::mangleType(
const ComplexType *T) {
2921 void CXXNameMangler::mangleNeonVectorType(
const VectorType *T) {
2923 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
2924 const char *EltName =
nullptr;
2926 switch (cast<BuiltinType>(EltType)->getKind()) {
2927 case BuiltinType::SChar:
2928 case BuiltinType::UChar:
2929 EltName =
"poly8_t";
2931 case BuiltinType::Short:
2932 case BuiltinType::UShort:
2933 EltName =
"poly16_t";
2935 case BuiltinType::ULongLong:
2936 EltName =
"poly64_t";
2938 default: llvm_unreachable(
"unexpected Neon polynomial vector element type");
2941 switch (cast<BuiltinType>(EltType)->
getKind()) {
2942 case BuiltinType::SChar: EltName =
"int8_t";
break;
2943 case BuiltinType::UChar: EltName =
"uint8_t";
break;
2944 case BuiltinType::Short: EltName =
"int16_t";
break;
2945 case BuiltinType::UShort: EltName =
"uint16_t";
break;
2946 case BuiltinType::Int: EltName =
"int32_t";
break;
2947 case BuiltinType::UInt: EltName =
"uint32_t";
break;
2948 case BuiltinType::LongLong: EltName =
"int64_t";
break;
2949 case BuiltinType::ULongLong: EltName =
"uint64_t";
break;
2950 case BuiltinType::Double: EltName =
"float64_t";
break;
2951 case BuiltinType::Float: EltName =
"float32_t";
break;
2952 case BuiltinType::Half: EltName =
"float16_t";
break;
2954 llvm_unreachable(
"unexpected Neon vector element type");
2957 const char *BaseName =
nullptr;
2959 getASTContext().getTypeSize(EltType));
2961 BaseName =
"__simd64_";
2963 assert(BitSize == 128 &&
"Neon vector type not 64 or 128 bits");
2964 BaseName =
"__simd128_";
2966 Out << strlen(BaseName) + strlen(EltName);
2967 Out << BaseName << EltName;
2972 case BuiltinType::SChar:
2974 case BuiltinType::Short:
2976 case BuiltinType::Int:
2978 case BuiltinType::Long:
2979 case BuiltinType::LongLong:
2981 case BuiltinType::UChar:
2983 case BuiltinType::UShort:
2985 case BuiltinType::UInt:
2987 case BuiltinType::ULong:
2988 case BuiltinType::ULongLong:
2990 case BuiltinType::Half:
2992 case BuiltinType::Float:
2994 case BuiltinType::Double:
2997 llvm_unreachable(
"Unexpected vector element base type");
3004 void CXXNameMangler::mangleAArch64NeonVectorType(
const VectorType *T) {
3006 assert(EltType->
isBuiltinType() &&
"Neon vector element not a BuiltinType");
3011 assert((BitSize == 64 || BitSize == 128) &&
3012 "Neon vector type not 64 or 128 bits");
3016 switch (cast<BuiltinType>(EltType)->getKind()) {
3017 case BuiltinType::UChar:
3020 case BuiltinType::UShort:
3023 case BuiltinType::ULong:
3024 case BuiltinType::ULongLong:
3028 llvm_unreachable(
"unexpected Neon polynomial vector element type");
3033 std::string TypeName =
3034 (
"__" + EltName +
"x" + Twine(T->
getNumElements()) +
"_t").str();
3035 Out << TypeName.length() << TypeName;
3046 void CXXNameMangler::mangleType(
const VectorType *T) {
3049 llvm::Triple Target = getASTContext().getTargetInfo().getTriple();
3050 llvm::Triple::ArchType Arch =
3051 getASTContext().getTargetInfo().getTriple().getArch();
3052 if ((Arch == llvm::Triple::aarch64 ||
3053 Arch == llvm::Triple::aarch64_be) && !Target.isOSDarwin())
3054 mangleAArch64NeonVectorType(T);
3056 mangleNeonVectorType(T);
3068 mangleType(static_cast<const VectorType*>(T));
3079 mangleQualifiers(split.
Quals, T);
3096 Out <<
"U8__kindof";
3101 llvm::raw_svector_ostream QualOS(QualStr);
3102 QualOS <<
"objcproto";
3103 for (
const auto *I : T->
quals()) {
3104 StringRef name = I->getName();
3105 QualOS << name.size() << name;
3107 Out <<
'U' << QualStr.size() << QualStr;
3116 mangleType(typeArg);
3122 Out <<
"U13block_pointer";
3137 if (mangleSubstitution(
QualType(T, 0)))
3190 getASTContext().getDependentTemplateName(T->
getQualifier(),
3192 mangleTemplatePrefix(Prefix);
3201 void CXXNameMangler::mangleType(
const TypeOfType *T) {
3213 void CXXNameMangler::mangleType(
const DecltypeType *T) {
3224 if (isa<DeclRefExpr>(E) ||
3225 isa<MemberExpr>(E) ||
3226 isa<UnresolvedLookupExpr>(E) ||
3227 isa<DependentScopeDeclRefExpr>(E) ||
3228 isa<CXXDependentScopeMemberExpr>(E) ||
3229 isa<UnresolvedMemberExpr>(E))
3233 mangleExpression(E);
3253 void CXXNameMangler::mangleType(
const AutoType *T) {
3258 "shouldn't need to mangle __auto_type!");
3274 void CXXNameMangler::mangleType(
const AtomicType *T) {
3281 void CXXNameMangler::mangleType(
const PipeType *T) {
3288 void CXXNameMangler::mangleIntegerLiteral(
QualType T,
3289 const llvm::APSInt &Value) {
3296 Out << (Value.getBoolValue() ?
'1' :
'0');
3298 mangleNumber(Value);
3304 void CXXNameMangler::mangleMemberExprBase(
const Expr *
Base,
bool IsArrow) {
3307 if (!RT->getDecl()->isAnonymousStructOrUnion())
3312 Base = ME->getBase();
3313 IsArrow = ME->isArrow();
3322 Out << (IsArrow ?
"pt" :
"dt");
3323 mangleExpression(Base);
3328 void CXXNameMangler::mangleMemberExpr(
const Expr *base,
3334 unsigned NumTemplateArgs,
3339 mangleMemberExprBase(base, isArrow);
3340 mangleUnresolvedName(qualifier, member, TemplateArgs, NumTemplateArgs, arity);
3353 if (callee == fn)
return false;
3357 if (!lookup)
return false;
3374 void CXXNameMangler::mangleCastExpression(
const Expr *E, StringRef CastEncoding) {
3376 Out << CastEncoding;
3381 void CXXNameMangler::mangleInitListElements(
const InitListExpr *InitList) {
3383 InitList = Syntactic;
3384 for (
unsigned i = 0, e = InitList->
getNumInits(); i != e; ++i)
3385 mangleExpression(InitList->
getInit(i));
3388 void CXXNameMangler::mangleExpression(
const Expr *E,
unsigned Arity) {
3412 QualType ImplicitlyConvertedToType;
3417 #define ABSTRACT_STMT(Type) 3418 #define EXPR(Type, Base) 3419 #define STMT(Type, Base) \ 3420 case Expr::Type##Class: 3421 #include "clang/AST/StmtNodes.inc" 3426 case Expr::AddrLabelExprClass:
3427 case Expr::DesignatedInitUpdateExprClass:
3428 case Expr::ImplicitValueInitExprClass:
3429 case Expr::ArrayInitLoopExprClass:
3430 case Expr::ArrayInitIndexExprClass:
3431 case Expr::NoInitExprClass:
3432 case Expr::ParenListExprClass:
3433 case Expr::LambdaExprClass:
3434 case Expr::MSPropertyRefExprClass:
3435 case Expr::MSPropertySubscriptExprClass:
3436 case Expr::TypoExprClass:
3437 case Expr::OMPArraySectionExprClass:
3438 case Expr::CXXInheritedCtorInitExprClass:
3439 llvm_unreachable(
"unexpected statement kind");
3442 case Expr::BlockExprClass:
3443 case Expr::ChooseExprClass:
3444 case Expr::CompoundLiteralExprClass:
3445 case Expr::ExtVectorElementExprClass:
3446 case Expr::GenericSelectionExprClass:
3447 case Expr::ObjCEncodeExprClass:
3448 case Expr::ObjCIsaExprClass:
3449 case Expr::ObjCIvarRefExprClass:
3450 case Expr::ObjCMessageExprClass:
3451 case Expr::ObjCPropertyRefExprClass:
3452 case Expr::ObjCProtocolExprClass:
3453 case Expr::ObjCSelectorExprClass:
3454 case Expr::ObjCStringLiteralClass:
3455 case Expr::ObjCBoxedExprClass:
3456 case Expr::ObjCArrayLiteralClass:
3457 case Expr::ObjCDictionaryLiteralClass:
3458 case Expr::ObjCSubscriptRefExprClass:
3459 case Expr::ObjCIndirectCopyRestoreExprClass:
3460 case Expr::ObjCAvailabilityCheckExprClass:
3461 case Expr::OffsetOfExprClass:
3462 case Expr::PredefinedExprClass:
3463 case Expr::ShuffleVectorExprClass:
3464 case Expr::ConvertVectorExprClass:
3465 case Expr::StmtExprClass:
3466 case Expr::TypeTraitExprClass:
3467 case Expr::ArrayTypeTraitExprClass:
3468 case Expr::ExpressionTraitExprClass:
3469 case Expr::VAArgExprClass:
3470 case Expr::CUDAKernelCallExprClass:
3471 case Expr::AsTypeExprClass:
3472 case Expr::PseudoObjectExprClass:
3473 case Expr::AtomicExprClass:
3479 "cannot yet mangle expression type %0");
3486 case Expr::CXXUuidofExprClass: {
3490 Out <<
"u8__uuidoft";
3494 Out <<
"u8__uuidofz";
3495 mangleExpression(UuidExp, Arity);
3501 case Expr::BinaryConditionalOperatorClass: {
3505 "?: operator with omitted middle operand cannot be mangled");
3512 case Expr::OpaqueValueExprClass:
3513 llvm_unreachable(
"cannot mangle opaque value; mangling wrong thing?");
3515 case Expr::InitListExprClass: {
3517 mangleInitListElements(cast<InitListExpr>(E));
3522 case Expr::DesignatedInitExprClass: {
3523 auto *DIE = cast<DesignatedInitExpr>(E);
3524 for (
const auto &
Designator : DIE->designators()) {
3530 mangleExpression(DIE->getArrayIndex(
Designator));
3533 "unknown designator kind");
3535 mangleExpression(DIE->getArrayRangeStart(
Designator));
3536 mangleExpression(DIE->getArrayRangeEnd(
Designator));
3539 mangleExpression(DIE->getInit());
3543 case Expr::CXXDefaultArgExprClass:
3544 mangleExpression(cast<CXXDefaultArgExpr>(E)->getExpr(), Arity);
3547 case Expr::CXXDefaultInitExprClass:
3548 mangleExpression(cast<CXXDefaultInitExpr>(E)->getExpr(), Arity);
3551 case Expr::CXXStdInitializerListExprClass:
3552 mangleExpression(cast<CXXStdInitializerListExpr>(E)->getSubExpr(), Arity);
3555 case Expr::SubstNonTypeTemplateParmExprClass:
3556 mangleExpression(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
3560 case Expr::UserDefinedLiteralClass:
3563 case Expr::CXXMemberCallExprClass:
3564 case Expr::CallExprClass: {
3565 const CallExpr *CE = cast<CallExpr>(E);
3584 if (isa<PackExpansionExpr>(Arg))
3585 CallArity = UnknownArity;
3587 mangleExpression(CE->
getCallee(), CallArity);
3589 mangleExpression(Arg);
3594 case Expr::CXXNewExprClass: {
3597 Out << (New->
isArray() ?
"na" :
"nw");
3600 mangleExpression(*I);
3614 mangleExpression(*I);
3615 }
else if (
const ParenListExpr *PLE = dyn_cast<ParenListExpr>(Init)) {
3616 for (
unsigned i = 0, e = PLE->getNumExprs(); i != e; ++i)
3617 mangleExpression(PLE->getExpr(i));
3619 isa<InitListExpr>(Init)) {
3621 mangleInitListElements(cast<InitListExpr>(Init));
3623 mangleExpression(Init);
3629 case Expr::CXXPseudoDestructorExprClass: {
3630 const auto *PDE = cast<CXXPseudoDestructorExpr>(E);
3631 if (
const Expr *Base = PDE->getBase())
3632 mangleMemberExprBase(Base, PDE->isArrow());
3636 mangleUnresolvedPrefix(Qualifier,
3638 mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType());
3642 if (!mangleUnresolvedTypeOrSimpleId(ScopeInfo->getType()))
3645 }
else if (Qualifier) {
3646 mangleUnresolvedPrefix(Qualifier);
3650 QualType DestroyedType = PDE->getDestroyedType();
3651 mangleUnresolvedTypeOrSimpleId(DestroyedType);
3655 case Expr::MemberExprClass: {
3665 case Expr::UnresolvedMemberExprClass: {
3675 case Expr::CXXDependentScopeMemberExprClass: {
3677 = cast<CXXDependentScopeMemberExpr>(E);
3687 case Expr::UnresolvedLookupExprClass: {
3695 case Expr::CXXUnresolvedConstructExprClass: {
3700 assert(N == 1 &&
"unexpected form for list initialization");
3701 auto *IL = cast<InitListExpr>(CE->
getArg(0));
3704 mangleInitListElements(IL);
3711 if (N != 1) Out <<
'_';
3712 for (
unsigned I = 0; I != N; ++I) mangleExpression(CE->
getArg(I));
3713 if (N != 1) Out <<
'E';
3717 case Expr::CXXConstructExprClass: {
3718 const auto *CE = cast<CXXConstructExpr>(E);
3719 if (!CE->isListInitialization() || CE->isStdInitListInitialization()) {
3721 CE->getNumArgs() >= 1 &&
3722 (CE->getNumArgs() == 1 || isa<CXXDefaultArgExpr>(CE->getArg(1))) &&
3723 "implicit CXXConstructExpr must have one argument");
3724 return mangleExpression(cast<CXXConstructExpr>(E)->getArg(0));
3727 for (
auto *E : CE->arguments())
3728 mangleExpression(E);
3733 case Expr::CXXTemporaryObjectExprClass: {
3734 const auto *CE = cast<CXXTemporaryObjectExpr>(E);
3735 unsigned N = CE->getNumArgs();
3736 bool List = CE->isListInitialization();
3742 mangleType(CE->getType());
3743 if (!List && N != 1)
3745 if (CE->isStdInitListInitialization()) {
3750 cast<CXXStdInitializerListExpr>(CE->getArg(0)->IgnoreImplicit());
3751 auto *ILE = cast<InitListExpr>(SILE->getSubExpr()->IgnoreImplicit());
3752 mangleInitListElements(ILE);
3754 for (
auto *E : CE->arguments())
3755 mangleExpression(E);
3762 case Expr::CXXScalarValueInitExprClass:
3768 case Expr::CXXNoexceptExprClass:
3770 mangleExpression(cast<CXXNoexceptExpr>(E)->getOperand());
3773 case Expr::UnaryExprOrTypeTraitExprClass: {
3787 : ImplicitlyConvertedToType;
3789 mangleIntegerLiteral(T, V);
3803 "cannot yet mangle vec_step expression");
3811 "cannot yet mangle __builtin_omp_required_simd_align expression");
3825 case Expr::CXXThrowExprClass: {
3838 case Expr::CXXTypeidExprClass: {
3852 case Expr::CXXDeleteExprClass: {
3862 case Expr::UnaryOperatorClass: {
3870 case Expr::ArraySubscriptExprClass: {
3876 mangleExpression(AE->
getLHS());
3877 mangleExpression(AE->
getRHS());
3881 case Expr::CompoundAssignOperatorClass:
3882 case Expr::BinaryOperatorClass: {
3889 mangleExpression(BO->
getLHS());
3890 mangleExpression(BO->
getRHS());
3894 case Expr::ConditionalOperatorClass: {
3896 mangleOperatorName(OO_Conditional, 3);
3897 mangleExpression(CO->
getCond());
3898 mangleExpression(CO->
getLHS(), Arity);
3899 mangleExpression(CO->
getRHS(), Arity);
3903 case Expr::ImplicitCastExprClass: {
3904 ImplicitlyConvertedToType = E->
getType();
3905 E = cast<ImplicitCastExpr>(E)->getSubExpr();
3909 case Expr::ObjCBridgedCastExprClass: {
3912 StringRef
Kind = cast<ObjCBridgedCastExpr>(E)->getBridgeKindName();
3913 Out <<
"v1U" << Kind.size() <<
Kind;
3918 case Expr::CStyleCastExprClass:
3919 mangleCastExpression(E,
"cv");
3922 case Expr::CXXFunctionalCastExprClass: {
3923 auto *Sub = cast<ExplicitCastExpr>(E)->getSubExpr()->IgnoreImplicit();
3925 if (
auto *CCE = dyn_cast<CXXConstructExpr>(Sub))
3926 if (CCE->getParenOrBraceRange().isInvalid())
3927 Sub = CCE->getArg(0)->IgnoreImplicit();
3928 if (
auto *StdInitList = dyn_cast<CXXStdInitializerListExpr>(Sub))
3929 Sub = StdInitList->getSubExpr()->IgnoreImplicit();
3930 if (
auto *IL = dyn_cast<InitListExpr>(Sub)) {
3933 mangleInitListElements(IL);
3936 mangleCastExpression(E,
"cv");
3941 case Expr::CXXStaticCastExprClass:
3942 mangleCastExpression(E,
"sc");
3944 case Expr::CXXDynamicCastExprClass:
3945 mangleCastExpression(E,
"dc");
3947 case Expr::CXXReinterpretCastExprClass:
3948 mangleCastExpression(E,
"rc");
3950 case Expr::CXXConstCastExprClass:
3951 mangleCastExpression(E,
"cc");
3954 case Expr::CXXOperatorCallExprClass: {
3962 for (
unsigned i = 0; i != NumArgs; ++i)
3963 mangleExpression(CE->
getArg(i));
3967 case Expr::ParenExprClass:
3968 mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
3971 case Expr::DeclRefExprClass: {
3972 const NamedDecl *D = cast<DeclRefExpr>(E)->getDecl();
3983 mangleFunctionParam(cast<ParmVarDecl>(D));
3986 case Decl::EnumConstant: {
3992 case Decl::NonTypeTemplateParm: {
3994 mangleTemplateParameter(PD->
getIndex());
4003 case Expr::SubstNonTypeTemplateParmPackExprClass:
4008 Out <<
"_SUBSTPACK_";
4011 case Expr::FunctionParmPackExprClass: {
4014 Out <<
"v110_SUBSTPACK";
4019 case Expr::DependentScopeDeclRefExprClass: {
4027 case Expr::CXXBindTemporaryExprClass:
4028 mangleExpression(cast<CXXBindTemporaryExpr>(E)->getSubExpr());
4031 case Expr::ExprWithCleanupsClass:
4032 mangleExpression(cast<ExprWithCleanups>(E)->getSubExpr(), Arity);
4035 case Expr::FloatingLiteralClass: {
4044 case Expr::CharacterLiteralClass:
4047 Out << cast<CharacterLiteral>(E)->
getValue();
4052 case Expr::ObjCBoolLiteralExprClass:
4054 Out << (cast<ObjCBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4058 case Expr::CXXBoolLiteralExprClass:
4060 Out << (cast<CXXBoolLiteralExpr>(E)->
getValue() ?
'1' :
'0');
4064 case Expr::IntegerLiteralClass: {
4067 Value.setIsSigned(
true);
4072 case Expr::ImaginaryLiteralClass: {
4079 dyn_cast<FloatingLiteral>(IE->
getSubExpr())) {
4081 mangleFloat(llvm::APFloat(Imag->getValue().getSemantics()));
4083 mangleFloat(Imag->getValue());
4088 Value.setIsSigned(
true);
4089 mangleNumber(Value);
4095 case Expr::StringLiteralClass: {
4098 assert(isa<ConstantArrayType>(E->
getType()));
4104 case Expr::GNUNullExprClass:
4108 case Expr::CXXNullPtrLiteralExprClass: {
4113 case Expr::PackExpansionExprClass:
4115 mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
4118 case Expr::SizeOfPackExprClass: {
4119 auto *SPE = cast<SizeOfPackExpr>(E);
4120 if (SPE->isPartiallySubstituted()) {
4122 for (
const auto &A : SPE->getPartialArguments())
4123 mangleTemplateArg(A);
4131 mangleTemplateParameter(TTP->getIndex());
4133 = dyn_cast<NonTypeTemplateParmDecl>(Pack))
4134 mangleTemplateParameter(NTTP->getIndex());
4136 = dyn_cast<TemplateTemplateParmDecl>(Pack))
4137 mangleTemplateParameter(TempTP->getIndex());
4139 mangleFunctionParam(cast<ParmVarDecl>(Pack));
4143 case Expr::MaterializeTemporaryExprClass: {
4144 mangleExpression(cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr());
4148 case Expr::CXXFoldExprClass: {
4149 auto *FE = cast<CXXFoldExpr>(E);
4150 if (FE->isLeftFold())
4151 Out << (FE->getInit() ?
"fL" :
"fl");
4153 Out << (FE->getInit() ?
"fR" :
"fr");
4155 if (FE->getOperator() == BO_PtrMemD)
4163 mangleExpression(FE->getLHS());
4165 mangleExpression(FE->getRHS());
4169 case Expr::CXXThisExprClass:
4173 case Expr::CoawaitExprClass:
4175 Out <<
"v18co_await";
4176 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4179 case Expr::DependentCoawaitExprClass:
4181 Out <<
"v18co_await";
4182 mangleExpression(cast<DependentCoawaitExpr>(E)->getOperand());
4185 case Expr::CoyieldExprClass:
4187 Out <<
"v18co_yield";
4188 mangleExpression(cast<CoawaitExpr>(E)->getOperand());
4221 void CXXNameMangler::mangleFunctionParam(
const ParmVarDecl *parm) {
4228 assert(parmDepth < FunctionTypeDepth.getDepth());
4229 unsigned nestingDepth = FunctionTypeDepth.getDepth() - parmDepth;
4230 if (FunctionTypeDepth.isInResultType())
4233 if (nestingDepth == 0) {
4236 Out <<
"fL" << (nestingDepth - 1) <<
'p';
4244 &&
"parameter's type is still an array type?");
4247 dyn_cast<DependentAddressSpaceType>(parm->
getType())) {
4254 if (parmIndex != 0) {
4255 Out << (parmIndex - 1);
4260 void CXXNameMangler::mangleCXXCtorType(
CXXCtorType T,
4283 llvm_unreachable(
"closure constructors don't exist for the Itanium ABI!");
4286 mangleName(InheritedFrom);
4289 void CXXNameMangler::mangleCXXDtorType(
CXXDtorType T) {
4312 unsigned NumTemplateArgs) {
4315 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4323 for (
unsigned i = 0, e = AL.
size(); i != e; ++i)
4324 mangleTemplateArg(AL[i]);
4328 void CXXNameMangler::mangleTemplateArgs(
const TemplateArgument *TemplateArgs,
4329 unsigned NumTemplateArgs) {
4332 for (
unsigned i = 0; i != NumTemplateArgs; ++i)
4333 mangleTemplateArg(TemplateArgs[i]);
4347 llvm_unreachable(
"Cannot mangle NULL template argument");
4366 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
4368 if (isa<VarDecl>(D) || isa<FunctionDecl>(D)) {
4377 mangleExpression(E);
4391 if (compensateMangling) {
4393 mangleOperatorName(OO_Amp, 1);
4402 if (compensateMangling)
4418 mangleTemplateArg(
P);
4424 void CXXNameMangler::mangleTemplateParameter(
unsigned Index) {
4430 Out <<
'T' << (Index - 1) <<
'_';
4433 void CXXNameMangler::mangleSeqID(
unsigned SeqID) {
4436 else if (SeqID > 1) {
4444 for (; SeqID != 0; SeqID /= 36) {
4445 unsigned C = SeqID % 36;
4446 *I++ = (C < 10 ?
'0' +
C :
'A' + C - 10);
4449 Out.write(I.base(), I - BufferRef.rbegin());
4454 void CXXNameMangler::mangleExistingSubstitution(
TemplateName tname) {
4455 bool result = mangleSubstitution(tname);
4456 assert(result &&
"no existing substitution for template name");
4462 bool CXXNameMangler::mangleSubstitution(
const NamedDecl *ND) {
4464 if (mangleStandardSubstitution(ND))
4468 return mangleSubstitution(reinterpret_cast<uintptr_t>(ND));
4478 bool CXXNameMangler::mangleSubstitution(
QualType T) {
4481 return mangleSubstitution(RT->getDecl());
4486 return mangleSubstitution(TypePtr);
4489 bool CXXNameMangler::mangleSubstitution(
TemplateName Template) {
4491 return mangleSubstitution(TD);
4494 return mangleSubstitution(
4498 bool CXXNameMangler::mangleSubstitution(
uintptr_t Ptr) {
4499 llvm::DenseMap<uintptr_t, unsigned>::iterator I = Substitutions.find(Ptr);
4500 if (I == Substitutions.end())
4503 unsigned SeqID = I->second;
4537 if (TemplateArgs.
size() != 1)
4540 if (!
isCharType(TemplateArgs[0].getAsType()))
4546 template <std::
size_t StrLen>
4548 const char (&Str)[StrLen]) {
4553 if (TemplateArgs.
size() != 2)
4556 if (!
isCharType(TemplateArgs[0].getAsType()))
4565 bool CXXNameMangler::mangleStandardSubstitution(
const NamedDecl *ND) {
4567 if (
const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) {
4592 dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
4602 if (TemplateArgs.
size() != 3)
4605 if (!
isCharType(TemplateArgs[0].getAsType()))
4642 void CXXNameMangler::addSubstitution(
QualType T) {
4645 addSubstitution(RT->getDecl());
4651 addSubstitution(TypePtr);
4654 void CXXNameMangler::addSubstitution(
TemplateName Template) {
4656 return addSubstitution(TD);
4662 void CXXNameMangler::addSubstitution(
uintptr_t Ptr) {
4663 assert(!Substitutions.count(Ptr) &&
"Substitution already exists!");
4664 Substitutions[Ptr] = SeqID++;
4667 void CXXNameMangler::extendSubstitutions(CXXNameMangler* Other) {
4668 assert(Other->SeqID >= SeqID &&
"Must be superset of substitutions!");
4669 if (Other->SeqID > SeqID) {
4670 Substitutions.swap(Other->Substitutions);
4671 SeqID = Other->SeqID;
4675 CXXNameMangler::AbiTagList
4676 CXXNameMangler::makeFunctionReturnTypeTags(
const FunctionDecl *FD) {
4678 if (DisableDerivedAbiTags)
4679 return AbiTagList();
4681 llvm::raw_null_ostream NullOutStream;
4682 CXXNameMangler TrackReturnTypeTags(*
this, NullOutStream);
4683 TrackReturnTypeTags.disableDerivedAbiTags();
4687 FunctionTypeDepthState saved = TrackReturnTypeTags.FunctionTypeDepth.push();
4688 TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
4690 TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
4691 TrackReturnTypeTags.FunctionTypeDepth.pop(saved);
4693 return TrackReturnTypeTags.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4696 CXXNameMangler::AbiTagList
4697 CXXNameMangler::makeVariableTypeTags(
const VarDecl *VD) {
4699 if (DisableDerivedAbiTags)
4700 return AbiTagList();
4702 llvm::raw_null_ostream NullOutStream;
4703 CXXNameMangler TrackVariableType(*
this, NullOutStream);
4704 TrackVariableType.disableDerivedAbiTags();
4706 TrackVariableType.mangleType(VD->
getType());
4708 return TrackVariableType.AbiTagsRoot.getSortedUniqueUsedAbiTags();
4711 bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &
C,
4713 llvm::raw_null_ostream NullOutStream;
4714 CXXNameMangler TrackAbiTags(C, NullOutStream,
nullptr,
true);
4715 TrackAbiTags.mangle(VD);
4716 return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
4729 void ItaniumMangleContextImpl::mangleCXXName(
const NamedDecl *D,
4731 assert((isa<FunctionDecl>(D) || isa<VarDecl>(D)) &&
4732 "Invalid mangleName() call, argument is not a variable or function!");
4733 assert(!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) &&
4734 "Invalid mangleName() call on 'structor decl!");
4737 getASTContext().getSourceManager(),
4738 "Mangling declaration");
4740 CXXNameMangler Mangler(*
this, Out, D);
4747 CXXNameMangler Mangler(*
this, Out, D, Type);
4754 CXXNameMangler Mangler(*
this, Out, D, Type);
4760 CXXNameMangler Mangler(*
this, Out, D,
Ctor_Comdat);
4766 CXXNameMangler Mangler(*
this, Out, D,
Dtor_Comdat);
4770 void ItaniumMangleContextImpl::mangleThunk(
const CXXMethodDecl *MD,
4780 assert(!isa<CXXDestructorDecl>(MD) &&
4781 "Use mangleCXXDtor for destructor decls!");
4782 CXXNameMangler Mangler(*
this, Out);
4783 Mangler.getStream() <<
"_ZT";
4785 Mangler.getStream() <<
'c';
4796 Mangler.mangleFunctionEncoding(MD);
4799 void ItaniumMangleContextImpl::mangleCXXDtorThunk(
4804 CXXNameMangler Mangler(*
this, Out, DD, Type);
4805 Mangler.getStream() <<
"_ZT";
4808 Mangler.mangleCallOffset(ThisAdjustment.
NonVirtual,
4811 Mangler.mangleFunctionEncoding(DD);
4815 void ItaniumMangleContextImpl::mangleStaticGuardVariable(
const VarDecl *D,
4819 CXXNameMangler Mangler(*
this, Out);
4822 Mangler.getStream() <<
"_ZGV";
4823 Mangler.mangleName(D);
4826 void ItaniumMangleContextImpl::mangleDynamicInitializer(
const VarDecl *MD,
4831 Out <<
"__cxx_global_var_init";
4834 void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(
const VarDecl *D,
4837 CXXNameMangler Mangler(*
this, Out);
4838 Mangler.getStream() <<
"__dtor_";
4839 if (shouldMangleDeclName(D))
4842 Mangler.getStream() << D->
getName();
4845 void ItaniumMangleContextImpl::mangleSEHFilterExpression(
4846 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4847 CXXNameMangler Mangler(*
this, Out);
4848 Mangler.getStream() <<
"__filt_";
4849 if (shouldMangleDeclName(EnclosingDecl))
4850 Mangler.mangle(EnclosingDecl);
4852 Mangler.getStream() << EnclosingDecl->
getName();
4855 void ItaniumMangleContextImpl::mangleSEHFinallyBlock(
4856 const NamedDecl *EnclosingDecl, raw_ostream &Out) {
4857 CXXNameMangler Mangler(*
this, Out);
4858 Mangler.getStream() <<
"__fin_";
4859 if (shouldMangleDeclName(EnclosingDecl))
4860 Mangler.mangle(EnclosingDecl);
4862 Mangler.getStream() << EnclosingDecl->
getName();
4865 void ItaniumMangleContextImpl::mangleItaniumThreadLocalInit(
const VarDecl *D,
4868 CXXNameMangler Mangler(*
this, Out);
4869 Mangler.getStream() <<
"_ZTH";
4870 Mangler.mangleName(D);
4874 ItaniumMangleContextImpl::mangleItaniumThreadLocalWrapper(
const VarDecl *D,
4877 CXXNameMangler Mangler(*
this, Out);
4878 Mangler.getStream() <<
"_ZTW";
4879 Mangler.mangleName(D);
4882 void ItaniumMangleContextImpl::mangleReferenceTemporary(
const VarDecl *D,
4883 unsigned ManglingNumber,
4887 CXXNameMangler Mangler(*
this, Out);
4888 Mangler.getStream() <<
"_ZGR";
4889 Mangler.mangleName(D);
4890 assert(ManglingNumber > 0 &&
"Reference temporary mangling number is zero!");
4891 Mangler.mangleSeqID(ManglingNumber - 1);
4894 void ItaniumMangleContextImpl::mangleCXXVTable(
const CXXRecordDecl *RD,
4897 CXXNameMangler Mangler(*
this, Out);
4898 Mangler.getStream() <<
"_ZTV";
4899 Mangler.mangleNameOrStandardSubstitution(RD);
4902 void ItaniumMangleContextImpl::mangleCXXVTT(
const CXXRecordDecl *RD,
4905 CXXNameMangler Mangler(*
this, Out);
4906 Mangler.getStream() <<
"_ZTT";
4907 Mangler.mangleNameOrStandardSubstitution(RD);
4910 void ItaniumMangleContextImpl::mangleCXXCtorVTable(
const CXXRecordDecl *RD,
4915 CXXNameMangler Mangler(*
this, Out);
4916 Mangler.getStream() <<
"_ZTC";
4917 Mangler.mangleNameOrStandardSubstitution(RD);
4918 Mangler.getStream() <<
Offset;
4919 Mangler.getStream() <<
'_';
4920 Mangler.mangleNameOrStandardSubstitution(Type);
4923 void ItaniumMangleContextImpl::mangleCXXRTTI(
QualType Ty, raw_ostream &Out) {
4925 assert(!Ty.
hasQualifiers() &&
"RTTI info cannot have top-level qualifiers");
4926 CXXNameMangler Mangler(*
this, Out);
4927 Mangler.getStream() <<
"_ZTI";
4928 Mangler.mangleType(Ty);
4931 void ItaniumMangleContextImpl::mangleCXXRTTIName(
QualType Ty,
4934 CXXNameMangler Mangler(*
this, Out);
4935 Mangler.getStream() <<
"_ZTS";
4936 Mangler.mangleType(Ty);
4939 void ItaniumMangleContextImpl::mangleTypeName(
QualType Ty, raw_ostream &Out) {
4940 mangleCXXRTTIName(Ty, Out);
4943 void ItaniumMangleContextImpl::mangleStringLiteral(
const StringLiteral *, raw_ostream &) {
4944 llvm_unreachable(
"Can't mangle string literals");
4949 return new ItaniumMangleContextImpl(Context, Diags);
A call to an overloaded operator written using operator syntax.
ParameterABI getABI() const
Return the ABI treatment of this parameter.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
const Type * Ty
The locally-unqualified type.
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
An instance of this class is created to represent a function declaration or definition.
std::string Name
The name of this module.
static Qualifiers fromCVRUMask(unsigned CVRU)
The "enum" keyword introduces the elaborated-type-specifier.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
PointerType - C99 6.7.5.1 - Pointer Declarators.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
QualType getPointeeType() const
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
A (possibly-)qualified type.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static const TemplateArgument & getArgument(const TemplateArgument &A)
QualType getInjectedSpecializationType() const
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
const Expr * getSubExpr() const
__auto_type (GNU extension)
The COMDAT used for ctors.
const Expr * getInit(unsigned Init) const
bool isListInitialization() const
Determine whether this expression models list-initialization.
Expr * getUnderlyingExpr() const
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
FunctionType - C99 6.7.5.3 - Function Declarators.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
TemplateArgumentLoc const * getTemplateArgs() const
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Defines the SourceManager interface.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
bool isDecltypeAuto() const
Decl - This represents one declaration (or definition), e.g.
TagDecl * getDecl() const
static bool isStreamCharSpecialization(const ClassTemplateSpecializationDecl *SD, const char(&Str)[StrLen])
llvm::APFloat getValue() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Defines the C++ template declaration subclasses.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++11 auto or C++14 decltype(auto) type.
unsigned getBlockManglingNumber() const
The base class of the type hierarchy.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
bool isArrayRangeDesignator() const
Represents a call to a C++ constructor.
static bool isParenthesizedADLCallee(const CallExpr *call)
Look at the callee of the given call expression and determine if it's a parenthesized id-expression w...
A container of type source information.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Represents a C++ constructor within a class.
A template template parameter that has been substituted for some other template name.
Default closure variant of a ctor.
QualType getElementType() const
const Expr * getSubExpr() const
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
An identifier, stored as an IdentifierInfo*.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
void removeObjCLifetime()
unsigned getNumParams() const
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
const T * getAs() const
Member-template getAs<specific type>'.
Represents an empty template argument, e.g., one that has not been deduced.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Represents a C++17 deduced template specialization type.
A this pointer adjustment.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
A namespace, stored as a NamespaceDecl*.
DeclarationName getName() const
Gets the name looked up.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
A C++ throw-expression (C++ [except.throw]).
Expr * getExprOperand() const
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
QualType getIntegralType() const
Retrieve the type of the integral value.
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
The collection of all-type qualifiers we support.
Expr * getExprOperand() const
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
const char * getStmtClassName() const
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
RecordDecl - Represents a struct/union/class.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
bool isInAnonymousNamespace() const
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty)
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a class type in Objective C.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a dependent template name that cannot be resolved prior to template instantiation.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
const llvm::APSInt & getInitVal() const
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
bool isReferenceType() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
bool addressSpaceMapManglingFor(LangAS AS) const
Represents the result of substituting a set of types for a template type parameter pack...
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Expr * getArg(unsigned I)
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
TypeSourceInfo * getLambdaTypeInfo() const
TemplateName getReplacement() const
QualType getParamTypeForDecl() const
Describes a module or submodule.
unsigned getTypeQuals() const
bool getProducesResult() const
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
An rvalue reference type, per C++11 [dcl.ref].
UnresolvedUsingTypenameDecl * getDecl() const
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
A qualified template name, where the qualification is kept to describe the source code as written...
An lvalue ref-qualifier was provided (&).
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags)
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
bool hasAddressSpace() const
The "struct" keyword introduces the elaborated-type-specifier.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Expr * getInitializer()
The initializer of this new-expression.
static bool isStdNamespace(const DeclContext *DC)
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
Concrete class used by the front-end to report problems and issues.
Represents a typeof (or typeof) expression (a GCC extension).
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
A builtin binary operation expression such as "x + y" or "x <= y".
LangAS getAddressSpace() const
const Type * getClass() const
bool isLambda() const
Determine whether this class describes a lambda function object.
Expr * getSizeExpr() const
const TemplateArgument * getArgs() const
Retrieve the template arguments.
bool isNothrow(const ASTContext &Ctx, bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Enums/classes describing ABI related information about constructors, destructors and thunks...
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
void * getAsOpaquePtr() const
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
is ARM Neon polynomial vector
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Expr * getSizeExpr() const
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool isTypeOperand() const
QualType getElementType() const
arg_iterator placement_arg_end()
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
Expr * getAddrSpaceExpr() const
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
ConditionalOperator - The ?: ternary operator.
QualType getBaseType() const
Gets the base type of this object type.
Const iterator for iterating over Stmt * arrays that contain only Expr *.
Represents a prototype with parameter type info, e.g.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
A dependent template name that has not been resolved to a template (or set of templates).
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
union clang::ReturnAdjustment::VirtualAdjustment Virtual
bool hasQualifiers() const
Determine whether this type has any qualifiers.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Represents an array type in C++ whose size is a value-dependent expression.
CXXDtorType
C++ destructor types.
QualType getElementType() const
unsigned getNumArgs() const
Retrieve the number of template arguments.
unsigned getFunctionScopeDepth() const
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
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)
QualType getPointeeType() const
TemplateDecl * getTemplateDecl() const
The template declaration to which this qualified name refers.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TemplateArgumentLoc const * getTemplateArgs() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
const FunctionProtoType * T
Declaration of a template type parameter.
unsigned getIndex() const
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
const T * castAs() const
Member-template castAs<specific type>.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Represents a C++ destructor within a class.
New-expression has a C++11 list-initializer.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
unsigned getNumInits() const
bool isArrayDesignator() const
bool isImplicitAccess() const
True if this is an implicit access, i.e.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
const Expr * getCallee() const
QualType getArgumentType() const
ObjCLifetime getObjCLifetime() const
unsigned getNumTemplateArgs() const
DeclContext * getDeclContext()
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
A structure for storing the information associated with a substituted template template parameter...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
decls_iterator decls_begin() const
static SVal getValue(SVal val, SValBuilder &svalBuilder)
Defines the clang::TypeLoc interface and its subclasses.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
A namespace alias, stored as a NamespaceAliasDecl*.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static StringRef mangleAArch64VectorBase(const BuiltinType *EltType)
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isFunctionOrMethod() const
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Qualifiers Quals
The local qualifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool hasInitializer() const
Whether this new-expression has any initializer at all.
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
struct clang::ThisAdjustment::VirtualAdjustment::@118 Itanium
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
The COMDAT used for dtors.
static StringRef getIdentifier(const Token &Tok)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
static bool hasMangledSubstitutionQualifiers(QualType T)
Determine whether the given type has any qualifiers that are relevant for substitutions.
A template template parameter pack that has been substituted for a template template argument pack...
There is no lifetime qualification on this type.
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
is AltiVec 'vector Pixel'
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
ExtParameterInfo getExtParameterInfo(unsigned I) const
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ElaboratedTypeKeyword getKeyword() const
QualType getSignatureParameterType(QualType T) const
Retrieve the parameter type as adjusted for use in the signature of a function, decaying array and fu...
Encodes a location in the source.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
Expr * getSubExpr() const
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
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...
CallingConv getCC() const
QualType getElementType() const
bool isFieldDesignator() const
Represents a static or instance method of a struct/union/class.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
bool isConsumed() const
Is this parameter considered "consumed" by Objective-C ARC? Consumed parameters must have retainable ...
QualType getAllocatedType() const
const ParmVarDecl * getParamDecl(unsigned i) const
This file defines OpenMP nodes for declarative directives.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
Expr * getNoexceptExpr() const
UnaryExprOrTypeTrait getKind() const
is AltiVec 'vector bool ...'
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
Decl * getBlockManglingContextDecl() const
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
AutoTypeKeyword getKeyword() const
TypeClass getTypeClass() const
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset. ...
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
bool isArgumentType() const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
CXXCtorType
C++ constructor types.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
A qualified reference to a name whose declaration cannot yet be resolved.
QualType getPointeeType() const
Represents a pack expansion of types.
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
StringRef getName() const
Return the actual identifier string.
Base class for declarations which introduce a typedef-name.
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Represents a template argument.
Represents a template name that was expressed as a qualified name.
bool isTypeOperand() const
Dataflow Directional Tag Classes.
ThisAdjustment This
The this pointer adjustment.
ExtInfo getExtInfo() const
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
NestedNameSpecifier * getQualifier() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
The template argument is a pack expansion of a template name that was provided for a template templat...
const TemplateArgument * getArgs() const
Retrieve the template arguments.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
bool isDependentAddressSpaceType() const
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
VectorKind getVectorKind() const
ArrayRef< QualType > exceptions() const
The "union" keyword introduces the elaborated-type-specifier.
bool isBooleanType() const
The "class" keyword introduces the elaborated-type-specifier.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
A pointer to member type per C++ 8.3.3 - Pointers to members.
ExplicitCastExpr - An explicit cast written in the source code.
A type that was preceded by the 'template' keyword, stored as a Type*.
union clang::ThisAdjustment::VirtualAdjustment Virtual
Represents a pointer to an Objective C object.
Not an overloaded operator.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
unsigned getNumArgs() const
Retrieve the number of template arguments.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const llvm::APInt & getSize() const
struct clang::ReturnAdjustment::VirtualAdjustment::@116 Itanium
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.
llvm::StringRef getParameterABISpelling(ParameterABI kind)
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
The template argument is actually a parameter pack.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
arg_iterator placement_arg_begin()
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
unsigned arg_size() const
Retrieve the number of arguments.
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
A template argument list.
Reading or writing from this object requires a barrier call.
ArgKind getKind() const
Return the kind of stored template argument.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool hasUnaligned() const
Represents a C++ struct/union/class.
Represents a template specialization type whose template cannot be resolved, e.g. ...
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
A structure for storing the information associated with an overloaded template name.
Declaration of a class template.
This class is used for builtin types like 'int'.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
static bool isCharSpecialization(QualType T, const char *Name)
Returns whether a given type is a template specialization of a given name with a single argument of t...
static bool isCharType(QualType T)
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isGlobalDelete() const
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
Copying closure variant of a ctor.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
static Qualifiers fromCVRMask(unsigned CVR)
static Decl::Kind getKind(const Decl *D)
unsigned getNumElements() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
Designator - A designator in a C99 designated initializer.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
A set of overloaded template declarations.
NamedDecl - This represents a decl with a name.
bool isTranslationUnit() const
bool isOpenCLSpecificType() const
Represents a C array with a specified size that is not an integer-constant-expression.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
No keyword precedes the qualified type name.
static bool isStd(const NamespaceDecl *NS)
Return whether a given namespace is the 'std' namespace.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned getTargetAddressSpace(QualType T) const
unsigned getNumTemplateArgs() const
The global specifier '::'. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
The "__interface" keyword introduces the elaborated-type-specifier.
Represents the canonical version of C arrays with a specified constant size.
InitListExpr * getSyntacticForm() const
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
bool hasLinkage() const
Determine whether this declaration has linkage.
Attr - This represents one attribute.
QualType getPointeeType() const
bool isExternallyVisible() const
QualType getType() const
Return the type wrapped by this type source info.
A single template declaration.
This parameter (which must have pointer type) is a Swift indirect result parameter.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
const IdentifierInfo * getIdentifier() const
Expr * getSizeExpr() const
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.